diff --git a/build.gradle b/build.gradle index 5739f44..d831d7d 100644 --- a/build.gradle +++ b/build.gradle @@ -60,11 +60,15 @@ dependencies { modImplementation include("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cca_version}") modImplementation include("eu.pb4:sgui:${project.sgui_version}") - modImplementation include("eu.pb4:polymer:${project.polymer_version}") + modImplementation include("eu.pb4:polymer-resource-pack:${project.polymer_version}") modImplementation include("eu.pb4:player-data-api:${project.pda_version}") modImplementation include("fr.catcore:server-translations-api:${project.translation_version}") + modLocalRuntime "eu.pb4:polymer-autohost:${project.polymer_version}" + modCompileOnly "eu.pb4:polymer-core:${project.polymer_version}" + modLocalRuntime "eu.pb4:polymer-core:${project.polymer_version}" + // Dev Runtime testmodImplementation sourceSets.main.output //modLocalRuntime "com.terraformersmc:modmenu:${project.mod_menu_version}" diff --git a/gradle.properties b/gradle.properties index 26e475a..c1ade98 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,4 +19,4 @@ port_version=1 polymer_version=0.3.1+1.19.3 sgui_version=1.2.0+1.19.3 translation_version=1.4.19+1.19.3 -pda_version=0.2.3+1.19.3 +pda_version=0.2.2+1.19.3 diff --git a/src/main/java/dev/emi/trinkets/api/Trinket.java b/src/main/java/dev/emi/trinkets/api/Trinket.java index 15a924c..4ae2c4a 100644 --- a/src/main/java/dev/emi/trinkets/api/Trinket.java +++ b/src/main/java/dev/emi/trinkets/api/Trinket.java @@ -23,8 +23,6 @@ import net.minecraft.sound.SoundEvents; import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.registry.Registry; public interface Trinket { @@ -133,7 +131,7 @@ default Multimap getModifiers(ItemStac * @param entity The entity that is breaking the stack */ default void onBreak(ItemStack stack, SlotReference slot, LivingEntity entity) { - ((LivingEntityAccessor) entity).invokePlayEquipmentBreakEffects(stack); + } default TrinketEnums.DropRule getDropRule(ItemStack stack, SlotReference slot, LivingEntity entity) { diff --git a/src/main/java/dev/emi/trinkets/api/TrinketsApi.java b/src/main/java/dev/emi/trinkets/api/TrinketsApi.java index cffb684..4f9a1d0 100644 --- a/src/main/java/dev/emi/trinkets/api/TrinketsApi.java +++ b/src/main/java/dev/emi/trinkets/api/TrinketsApi.java @@ -21,15 +21,14 @@ import net.minecraft.network.PacketByteBuf; import net.minecraft.particle.ItemStackParticleEffect; import net.minecraft.particle.ParticleTypes; +import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundEvents; -import net.minecraft.tag.TagKey; import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.registry.Registry; import java.util.HashMap; import java.util.Map; @@ -88,7 +87,7 @@ public static void onTrinketBroken(ItemStack stack, SlotReference ref, LivingEnt world.spawnParticles(new ItemStackParticleEffect(ParticleTypes.ITEM, stack), vec3d2.x, vec3d2.y, vec3d2.z, 0, vec3d.x, vec3d.y + 0.05D, vec3d.z, 1); } if (!entity.isSilent()) { - world.playSoundFromEntity(null, entity, SoundEvents.ENTITY_ITEM_BREAK, entity.getSoundCategory(), 0.8F, 0.8F + world.random.nextFloat() * 0.4F, world.random.nextInt()); + world.playSoundFromEntity(null, entity, Registries.SOUND_EVENT.getEntry(SoundEvents.ENTITY_ITEM_BREAK), entity.getSoundCategory(), 0.8F, 0.8F + world.random.nextFloat() * 0.4F, world.random.nextInt()); } } } diff --git a/src/main/java/dev/emi/trinkets/data/SlotLoader.java b/src/main/java/dev/emi/trinkets/data/SlotLoader.java index c4e0f5d..fc08c1e 100644 --- a/src/main/java/dev/emi/trinkets/data/SlotLoader.java +++ b/src/main/java/dev/emi/trinkets/data/SlotLoader.java @@ -24,17 +24,16 @@ import dev.emi.trinkets.api.TrinketEnums.DropRule; import dev.emi.trinkets.data.SlotLoader.GroupData; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; -import net.minecraft.command.CommandRegistryWrapper; import net.minecraft.command.argument.ItemStringReader; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.registry.Registries; import net.minecraft.resource.Resource; import net.minecraft.resource.ResourceManager; import net.minecraft.resource.SinglePreparationResourceReloader; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; import net.minecraft.util.profiler.Profiler; -import net.minecraft.util.registry.Registry; public class SlotLoader extends SinglePreparationResourceReloader> implements IdentifiableResourceReloadListener { @@ -166,7 +165,7 @@ SlotType create(String group, String name) { ItemStack iconItem; try { - var decode = ItemStringReader.item(CommandRegistryWrapper.of(Registry.ITEM), new StringReader(this.iconItem)); + var decode = ItemStringReader.item(Registries.ITEM.getReadOnlyWrapper(), new StringReader(this.iconItem)); var stack = new ItemStack(decode.item().value()); stack.setNbt(decode.nbt()); diff --git a/src/main/java/dev/emi/trinkets/poly/Elements.java b/src/main/java/dev/emi/trinkets/poly/Elements.java index c599814..0981895 100644 --- a/src/main/java/dev/emi/trinkets/poly/Elements.java +++ b/src/main/java/dev/emi/trinkets/poly/Elements.java @@ -1,7 +1,7 @@ package dev.emi.trinkets.poly; import dev.emi.trinkets.TrinketsMain; -import eu.pb4.polymer.api.resourcepack.PolymerModelData; +import eu.pb4.polymer.resourcepack.api.PolymerModelData; import eu.pb4.sgui.api.elements.GuiElementBuilder; import net.minecraft.item.Items; import net.minecraft.text.Text; @@ -9,12 +9,12 @@ public class Elements { public static final GuiElementBuilder FILLER = new GuiElementBuilder(Items.WHITE_STAINED_GLASS_PANE).setName(Text.empty()) - .setCustomModelData(GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/filler"), Items.WHITE_STAINED_GLASS_PANE).value()); + .setCustomModelData(GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/polybuttons/filler"), Items.WHITE_STAINED_GLASS_PANE).value()); public static final GuiElementBuilder FILLER_NAVBAR = new GuiElementBuilder(Items.BLACK_STAINED_GLASS_PANE).setName(Text.empty()); - public static final PolymerModelData PREVIOUS = GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/previous"), Items.GREEN_STAINED_GLASS_PANE); - public static final PolymerModelData NEXT = GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/next"), Items.GREEN_STAINED_GLASS_PANE); - public static final PolymerModelData SUBPAGE = GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/subpage"), Items.LIGHT_BLUE_STAINED_GLASS_PANE); + public static final PolymerModelData PREVIOUS = GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/polybuttons/previous"), Items.GREEN_STAINED_GLASS_PANE); + public static final PolymerModelData NEXT = GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/polybuttons/next"), Items.GREEN_STAINED_GLASS_PANE); + public static final PolymerModelData SUBPAGE = GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/polybuttons/subpage"), Items.LIGHT_BLUE_STAINED_GLASS_PANE); } diff --git a/src/main/java/dev/emi/trinkets/poly/GuiModels.java b/src/main/java/dev/emi/trinkets/poly/GuiModels.java index db39bcc..d83565a 100644 --- a/src/main/java/dev/emi/trinkets/poly/GuiModels.java +++ b/src/main/java/dev/emi/trinkets/poly/GuiModels.java @@ -1,9 +1,9 @@ package dev.emi.trinkets.poly; import dev.emi.trinkets.TrinketsMain; -import eu.pb4.polymer.api.resourcepack.PolymerModelData; -import eu.pb4.polymer.api.resourcepack.PolymerRPBuilder; -import eu.pb4.polymer.api.resourcepack.PolymerRPUtils; +import eu.pb4.polymer.resourcepack.api.PolymerModelData; +import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils; +import eu.pb4.polymer.resourcepack.api.ResourcePackBuilder; import net.minecraft.item.Item; import net.minecraft.util.Identifier; @@ -21,16 +21,16 @@ public class GuiModels { public static PolymerModelData getOrCreate(Identifier icon, Item item) { if (init) { init = false; - PolymerRPUtils.addAssetSource(TrinketsMain.MOD_ID); + PolymerResourcePackUtils.addModAssets(TrinketsMain.MOD_ID); - PolymerRPUtils.RESOURCE_PACK_CREATION_EVENT.register(GuiModels::createFiles); + PolymerResourcePackUtils.RESOURCE_PACK_CREATION_EVENT.register(GuiModels::createFiles); } MODELS.add(icon); - return MODEL_MAP.computeIfAbsent(item, i -> new HashMap<>()).computeIfAbsent(icon, i -> PolymerRPUtils.requestModel(item, icon)); + return MODEL_MAP.computeIfAbsent(item, i -> new HashMap<>()).computeIfAbsent(icon, i -> PolymerResourcePackUtils.requestModel(item, icon)); } - private static void createFiles(PolymerRPBuilder polymerRPBuilder) { + private static void createFiles(ResourcePackBuilder polymerRPBuilder) { for (var id : MODELS) { var json = """ { @@ -49,7 +49,7 @@ private static void createFiles(PolymerRPBuilder polymerRPBuilder) { { "parent": "minecraft:item/handheld", "textures": { - "layer0": "trinkets:gui/filler" + "layer0": "trinkets:gui/polybuttons/filler" }, "display": { "gui": { @@ -60,7 +60,7 @@ private static void createFiles(PolymerRPBuilder polymerRPBuilder) { } } """; - polymerRPBuilder.addData("assets/trinkets/models/gui/filler.json", json.getBytes(StandardCharsets.UTF_8)); + polymerRPBuilder.addData("assets/trinkets/models/gui/polybuttons/filler.json", json.getBytes(StandardCharsets.UTF_8)); } } } diff --git a/src/main/java/dev/emi/trinkets/poly/TrinketsFlatUI.java b/src/main/java/dev/emi/trinkets/poly/TrinketsFlatUI.java index 468dc9d..93197e2 100644 --- a/src/main/java/dev/emi/trinkets/poly/TrinketsFlatUI.java +++ b/src/main/java/dev/emi/trinkets/poly/TrinketsFlatUI.java @@ -5,7 +5,7 @@ import dev.emi.trinkets.api.TrinketComponent; import dev.emi.trinkets.api.TrinketInventory; import dev.emi.trinkets.api.TrinketsApi; -import eu.pb4.polymer.api.resourcepack.PolymerRPUtils; +import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils; import eu.pb4.sgui.api.elements.GuiElementBuilder; import eu.pb4.sgui.api.gui.SimpleGui; import net.minecraft.item.ItemStack; @@ -58,7 +58,7 @@ public TrinketsFlatUI(ServerPlayerEntity player, boolean compact) { .flatMap((x) -> x.values().stream().sorted(Comparator.comparingInt(a -> a.getSlotType().getOrder()))) .collect(Collectors.toList()); - this.setTitle(PolymerRPUtils.hasPack(player) + this.setTitle(PolymerResourcePackUtils.hasPack(player) ? Text.empty().append(Text.literal(compact ? "-1." : "-0.") .setStyle(Style.EMPTY.withColor(Formatting.WHITE).withFont(new Identifier(TrinketsMain.MOD_ID, "gui")))) .append(Text.translatable("trinkets.name")) @@ -77,7 +77,7 @@ public static int open(ServerPlayerEntity player) { } public void drawLines() { - if (this.compact && !PolymerRPUtils.hasPack(this.player)) { + if (this.compact && !PolymerResourcePackUtils.hasPack(this.player)) { for (int x = 0; x < 5; x++) { this.setSlot(9 * x + 4, Elements.FILLER); } @@ -130,7 +130,7 @@ private void drawLine(int index, TrinketInventory trinketInventory, int subPage) this.setSlot(base + slot++, Elements.FILLER); } - boolean hasPack = PolymerRPUtils.hasPack(player); + boolean hasPack = PolymerResourcePackUtils.hasPack(player); if (trinketInventory.size() <= invSize) { for (int i = 0; i < invSize; i++) { @@ -189,7 +189,7 @@ private void drawLine(int index, TrinketInventory trinketInventory, int subPage) } private void drawNavbar() { - boolean addNavbarFiller = !PolymerRPUtils.hasPack(this.player); + boolean addNavbarFiller = !PolymerResourcePackUtils.hasPack(this.player); if (this.inventories.size() > this.displayPerPage) { @@ -249,6 +249,6 @@ private void drawNavbar() { public static final void playClickSound(ServerPlayerEntity player) { - player.playSound(SoundEvents.UI_BUTTON_CLICK, SoundCategory.MASTER, 0.7f, 1); + player.playSound(SoundEvents.UI_BUTTON_CLICK.value(), SoundCategory.MASTER, 0.7f, 1); } } diff --git a/src/main/resources/assets/minecraft/atlases/blocks.json b/src/main/resources/assets/minecraft/atlases/blocks.json new file mode 100644 index 0000000..bc1d4d6 --- /dev/null +++ b/src/main/resources/assets/minecraft/atlases/blocks.json @@ -0,0 +1,14 @@ +{ + "sources": [ + { + "type": "directory", + "source": "gui/slots", + "prefix": "gui/slots/" + }, + { + "type": "directory", + "source": "gui/polybuttons", + "prefix": "gui/polybuttons/" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/trinkets/font/gui.json b/src/main/resources/assets/trinkets/font/gui.json index 6e7123b..0927e01 100644 --- a/src/main/resources/assets/trinkets/font/gui.json +++ b/src/main/resources/assets/trinkets/font/gui.json @@ -9,7 +9,7 @@ }, { "type": "bitmap", - "file": "trinkets:gui/flat_gui.png", + "file": "trinkets:font_gui/flat_gui.png", "ascent": 13, "height": 256, "chars": [ @@ -18,7 +18,7 @@ }, { "type": "bitmap", - "file": "trinkets:gui/flat_gui_compact.png", + "file": "trinkets:font_gui/flat_gui_compact.png", "ascent": 13, "height": 256, "chars": [ diff --git a/src/main/resources/assets/trinkets/textures/gui/flat_gui.png b/src/main/resources/assets/trinkets/textures/font_gui/flat_gui.png similarity index 100% rename from src/main/resources/assets/trinkets/textures/gui/flat_gui.png rename to src/main/resources/assets/trinkets/textures/font_gui/flat_gui.png diff --git a/src/main/resources/assets/trinkets/textures/gui/flat_gui_compact.png b/src/main/resources/assets/trinkets/textures/font_gui/flat_gui_compact.png similarity index 100% rename from src/main/resources/assets/trinkets/textures/gui/flat_gui_compact.png rename to src/main/resources/assets/trinkets/textures/font_gui/flat_gui_compact.png diff --git a/src/main/resources/assets/trinkets/textures/gui/more_slots.png b/src/main/resources/assets/trinkets/textures/gui/more_slots.png deleted file mode 100644 index 900dda2..0000000 Binary files a/src/main/resources/assets/trinkets/textures/gui/more_slots.png and /dev/null differ diff --git a/src/main/resources/assets/trinkets/textures/gui/blank_back.png b/src/main/resources/assets/trinkets/textures/gui/polybuttons/blank_back.png similarity index 100% rename from src/main/resources/assets/trinkets/textures/gui/blank_back.png rename to src/main/resources/assets/trinkets/textures/gui/polybuttons/blank_back.png diff --git a/src/main/resources/assets/trinkets/textures/gui/filler.png b/src/main/resources/assets/trinkets/textures/gui/polybuttons/filler.png similarity index 100% rename from src/main/resources/assets/trinkets/textures/gui/filler.png rename to src/main/resources/assets/trinkets/textures/gui/polybuttons/filler.png diff --git a/src/main/resources/assets/trinkets/textures/gui/next.png b/src/main/resources/assets/trinkets/textures/gui/polybuttons/next.png similarity index 100% rename from src/main/resources/assets/trinkets/textures/gui/next.png rename to src/main/resources/assets/trinkets/textures/gui/polybuttons/next.png diff --git a/src/main/resources/assets/trinkets/textures/gui/previous.png b/src/main/resources/assets/trinkets/textures/gui/polybuttons/previous.png similarity index 100% rename from src/main/resources/assets/trinkets/textures/gui/previous.png rename to src/main/resources/assets/trinkets/textures/gui/polybuttons/previous.png diff --git a/src/main/resources/assets/trinkets/textures/gui/subpage.png b/src/main/resources/assets/trinkets/textures/gui/polybuttons/subpage.png similarity index 100% rename from src/main/resources/assets/trinkets/textures/gui/subpage.png rename to src/main/resources/assets/trinkets/textures/gui/polybuttons/subpage.png diff --git a/src/testmod/java/dev/emi/trinkets/TestTrinket.java b/src/testmod/java/dev/emi/trinkets/TestTrinket.java index e35f19e..2fbe5a9 100644 --- a/src/testmod/java/dev/emi/trinkets/TestTrinket.java +++ b/src/testmod/java/dev/emi/trinkets/TestTrinket.java @@ -4,7 +4,8 @@ import dev.emi.trinkets.api.SlotAttributes; import dev.emi.trinkets.api.SlotReference; import dev.emi.trinkets.api.TrinketItem; -import eu.pb4.polymer.api.item.PolymerItem; +import eu.pb4.polymer.core.api.item.PolymerItem; +import net.minecraft.client.item.TooltipContext; import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.EntityAttribute;