Skip to content

Commit

Permalink
Ported to 1.19
Browse files Browse the repository at this point in the history
*Replaced Text references
*Updated PlaceholderAPI implementation slightly.
*Now using v2 of Fabric API commands registry
*Incremented version
+Added json endpoint for future documentation.
  • Loading branch information
CleverNucleus committed Jul 21, 2022
1 parent aef9891 commit 4e97c7f
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 151 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/github/clevernucleus/playerex/PlayerEx.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import com.github.clevernucleus.playerex.factory.RefundFactory;
import com.github.clevernucleus.playerex.impl.CommandsImpl;

import eu.pb4.placeholders.PlaceholderAPI;
import eu.pb4.placeholders.api.Placeholders;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.networking.v1.ServerLoginConnectionEvents;
Expand Down Expand Up @@ -55,7 +55,7 @@ public void onInitialize() {

DamageFactory.STORE.forEach(ExAPI::registerDamageModification);
RefundFactory.STORE.forEach(ExAPI::registerRefundCondition);
PlaceholderFactory.STORE.forEach(PlaceholderAPI::register);
PlaceholderFactory.STORE.forEach(Placeholders::register);

Registry.register(Registry.SOUND_EVENT, LEVEL_UP_SOUND.getId(), LEVEL_UP_SOUND);
Registry.register(Registry.SOUND_EVENT, SP_SPEND_SOUND.getId(), SP_SPEND_SOUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;

@Environment(EnvType.CLIENT)
Expand Down Expand Up @@ -84,8 +82,8 @@ public static void appendChildrenToTooltip(List<Text> tooltip, final Supplier<En
double value = child.getValue();
double displ = displayValue(() -> (EntityAttribute)attribute2, value);
String formt = formatValue(() -> (EntityAttribute)attribute2, displ);
MutableText mutableText = new LiteralText(formt + " ");
mutableText.append(new TranslatableText(((EntityAttribute)attribute2).getTranslationKey()));
MutableText mutableText = Text.literal(formt + " ");
mutableText.append(Text.translatable(((EntityAttribute)attribute2).getTranslationKey()));
tooltip.add(mutableText.formatted(Formatting.GRAY));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

/**
Expand Down Expand Up @@ -57,7 +56,7 @@ public static RenderComponent of(final Function<LivingEntity, Text> functionIn,
* @return
*/
public static RenderComponent of(final Supplier<EntityAttribute> attributeIn, final Function<Double, Text> functionIn, final Function<Double, List<Text>> tooltipIn, final int dx, final int dy) {
return new RenderComponent(livingEntity -> DataAttributesAPI.ifPresent(livingEntity, attributeIn, LiteralText.EMPTY, functionIn), livingEntity -> DataAttributesAPI.ifPresent(livingEntity, attributeIn, new ArrayList<Text>(), tooltipIn), dx, dy);
return new RenderComponent(livingEntity -> DataAttributesAPI.ifPresent(livingEntity, attributeIn, Text.empty(), functionIn), livingEntity -> DataAttributesAPI.ifPresent(livingEntity, attributeIn, new ArrayList<Text>(), tooltipIn), dx, dy);
}

private boolean isMouseOver(float xIn, float yIn, float widthIn, float heightIn, int mouseX, int mouseY) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

Expand All @@ -40,7 +39,7 @@ public static Map<Identifier, Supplier<Page>> pages() {
}

public static Page findPage(final Identifier pageId) {
return PAGES.getOrDefault(pageId, () -> new Page(pageId, BLANK, LiteralText.EMPTY)).get();
return PAGES.getOrDefault(pageId, () -> new Page(pageId, BLANK, Text.empty())).get();
}

public static Collection<PageLayer.Builder> findPageLayers(final Identifier pageId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
import net.minecraft.client.gui.screen.ingame.HandledScreens;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public class PlayerExClient implements ClientModInitializer {
public static final Identifier GUI = new Identifier(ExAPI.MODID, "textures/gui/gui.png");
public static final Identifier ATTRIBUTES_PAGE = new Identifier(ExAPI.MODID, "attributes");
public static final Identifier COMBAT_PAGE = new Identifier(ExAPI.MODID, "combat");
public static final Page INVENTORY = new Page(new Identifier(ExAPI.MODID, "inventory"), new Identifier(ExAPI.MODID, "textures/gui/inventory.png"), new TranslatableText("playerex.gui.page.inventory.title"));
public static final Page INVENTORY = new Page(new Identifier(ExAPI.MODID, "inventory"), new Identifier(ExAPI.MODID, "textures/gui/inventory.png"), Text.translatable("playerex.gui.page.inventory.title"));
public static KeyBinding keyBinding;

@Override
Expand All @@ -39,8 +39,8 @@ public void onInitializeClient() {

keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("playerex.key.screen", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_R, "key.categories.inventory"));
HandledScreens.register(PlayerEx.EX_SCREEN, ExScreen::new);
PageRegistry.registerPage(ATTRIBUTES_PAGE, new Identifier(ExAPI.MODID, "textures/gui/attributes.png"), new TranslatableText("playerex.gui.page.attributes.title"));
PageRegistry.registerPage(COMBAT_PAGE, new Identifier(ExAPI.MODID, "textures/gui/combat.png"), new TranslatableText("playerex.gui.page.combat.title"));
PageRegistry.registerPage(ATTRIBUTES_PAGE, new Identifier(ExAPI.MODID, "textures/gui/attributes.png"), Text.translatable("playerex.gui.page.attributes.title"));
PageRegistry.registerPage(COMBAT_PAGE, new Identifier(ExAPI.MODID, "textures/gui/combat.png"), Text.translatable("playerex.gui.page.combat.title"));
PageRegistry.registerLayer(ATTRIBUTES_PAGE, AttributesPageLayer::new);
PageRegistry.registerLayer(COMBAT_PAGE, CombatPageLayer::new);

Expand Down
Loading

0 comments on commit 4e97c7f

Please sign in to comment.