From 409d7b9cb9ca42d728e68da910e42e4c9f33bdb1 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Tue, 11 Jul 2023 21:40:33 +0300 Subject: [PATCH] Backport to Minecraft version 1.19.4 --- build.gradle | 11 +++++--- gradle.properties | 10 +++---- .../cstav/genshinstrument/GInstrumentMod.java | 1 - .../genshinstrument/ModCreativeModeTabs.java | 17 +++++------- .../genshinstrument/client/ClientUtil.java | 8 ++++++ .../partial/AbstractGridInstrumentScreen.java | 27 +++++++++++-------- .../partial/AbstractInstrumentScreen.java | 8 +++--- .../instrument/partial/note/NoteButton.java | 20 +++++++++----- .../instrument/partial/note/NoteRing.java | 11 +++++--- .../vintagelyre/VintageNoteButton.java | 13 ++++++--- .../AbstractInstrumentOptionsScreen.java | 10 +++---- .../instrument/FloralZitherOptionsScreen.java | 8 +++--- .../criteria/InstrumentPlayedTrigger.java | 6 ++--- .../event/InstrumentPlayedEvent.java | 2 +- .../cstav/genshinstrument/item/ModItems.java | 5 ---- .../instrument/CloseInstrumentPacket.java | 2 +- .../NotifyInstrumentOpenPacket.java | 2 +- .../genshinstrument/util/ServerUtil.java | 4 +-- src/main/resources/fabric.mod.json | 2 +- 19 files changed, 94 insertions(+), 73 deletions(-) diff --git a/build.gradle b/build.gradle index e416a01..bf04c14 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ version = project.mod_version group = project.maven_group base { - archivesName = project.archives_base_name+"-fabric" + archivesName = project.archives_base_name+"-fabric-"+project.minecraft_version } repositories { @@ -26,6 +26,11 @@ repositories { url "https://cursemaven.com" } maven { url 'https://maven.terraformersmc.com/releases/' } + + maven { + name = "Fuzs Mod Resources" + url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" + } } } @@ -38,11 +43,11 @@ dependencies { } modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + modApi "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:${project.forge_config_api_port_version}" + // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation "curse.maven:forge-config-api-port-fabric-547434:${project.forge_config_api_port_version}" - modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}" // Uncomment the following line to enable the deprecated Fabric API modules. diff --git a/gradle.properties b/gradle.properties index e338c1a..b29b97b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20 -parchment_mappings=1.20.1:2023.07.02 +minecraft_version=1.19.4 +parchment_mappings=1.19.4:2023.06.26 loader_version=0.14.21 # Mod Properties @@ -14,6 +14,6 @@ maven_group=com.cstav.genshinstrument archives_base_name=genshinstrument # Dependencies -fabric_version=0.83.0+1.20 -modmenu_version=7.0.1 -forge_config_api_port_version=4576917 \ No newline at end of file +fabric_version=0.85.0+1.19.4 +modmenu_version=6.2.3 +forge_config_api_port_version=6.0.2 \ No newline at end of file diff --git a/src/main/java/com/cstav/genshinstrument/GInstrumentMod.java b/src/main/java/com/cstav/genshinstrument/GInstrumentMod.java index c598ea7..513bdf2 100644 --- a/src/main/java/com/cstav/genshinstrument/GInstrumentMod.java +++ b/src/main/java/com/cstav/genshinstrument/GInstrumentMod.java @@ -21,7 +21,6 @@ public void onInitialize() { ModSounds.regsiter(); - ModCreativeModeTabs.regsiter(); ModItems.register(); } diff --git a/src/main/java/com/cstav/genshinstrument/ModCreativeModeTabs.java b/src/main/java/com/cstav/genshinstrument/ModCreativeModeTabs.java index d423923..aa75fb2 100644 --- a/src/main/java/com/cstav/genshinstrument/ModCreativeModeTabs.java +++ b/src/main/java/com/cstav/genshinstrument/ModCreativeModeTabs.java @@ -3,8 +3,6 @@ import com.cstav.genshinstrument.item.ModItems; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab; @@ -12,14 +10,11 @@ public class ModCreativeModeTabs { - public static final CreativeModeTab INSTRUMENTS = FabricItemGroup.builder() - .icon(() -> new ItemStack(ModItems.FLORAL_ZITHER)) - .title(Component.translatable("genshinstrument.itemGroup.instruments")) - .build(); - - public static void regsiter() { - Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, new ResourceLocation(GInstrumentMod.MODID, "instruments_group"), INSTRUMENTS); - - } + public static final CreativeModeTab + INSTRUMENTS = FabricItemGroup.builder(new ResourceLocation(GInstrumentMod.MODID, "instruments_group")) + .icon(() -> new ItemStack(ModItems.FLORAL_ZITHER)) + .title(Component.translatable("genshinstrument.itemGroup.instruments")) + .build() + ; } diff --git a/src/main/java/com/cstav/genshinstrument/client/ClientUtil.java b/src/main/java/com/cstav/genshinstrument/client/ClientUtil.java index 03dca17..ad43ce1 100644 --- a/src/main/java/com/cstav/genshinstrument/client/ClientUtil.java +++ b/src/main/java/com/cstav/genshinstrument/client/ClientUtil.java @@ -7,6 +7,8 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.resources.ResourceLocation; @Environment(EnvType.CLIENT) public class ClientUtil { @@ -36,4 +38,10 @@ public static void resetShaderColor() { setShaderColor(Color.WHITE); } + + public static void displaySprite(final ResourceLocation location) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderTexture(0, location); + } + } diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractGridInstrumentScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractGridInstrumentScreen.java index a846aa7..c854080 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractGridInstrumentScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractGridInstrumentScreen.java @@ -13,10 +13,11 @@ import com.cstav.genshinstrument.client.keyMaps.KeyMappings; import com.mojang.blaze3d.platform.InputConstants.Key; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.layouts.AbstractLayout; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; @@ -82,17 +83,17 @@ protected void init() { @Override - public void render(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick) { + public void render(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) { if (ModClientConfigs.RENDER_BACKGROUND.get()) { RenderSystem.enableBlend(); RenderSystem.enableDepthTest(); ClientUtil.setShaderColor(Color.WHITE, .6f); - renderInstrumentBackground(gui); + renderInstrumentBackground(poseStack); ClientUtil.resetShaderColor(); } - super.render(gui, pMouseX, pMouseY, pPartialTick); + super.render(poseStack, pMouseX, pMouseY, pPartialTick); } @@ -101,20 +102,22 @@ public void render(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick * This render method will only work for a 3-column instrument. Overwrite it * to customize the background. */ - protected void renderInstrumentBackground(final GuiGraphics gui) { + protected void renderInstrumentBackground(final PoseStack poseStack) { if (columns() != 3) return; final int clefX = grid.getX() - NoteButton.getSize() + 8; for (int i = 0; i < columns(); i++) { - renderClef(gui, i, clefX); - renderStaff(gui, i); + renderClef(poseStack, i, clefX); + renderStaff(poseStack, i); } } - protected void renderClef(final GuiGraphics gui, final int index, final int x) { - gui.blit(getResourceFromGlob("background/clefs.png"), + protected void renderClef(final PoseStack poseStack, final int index, final int x) { + ClientUtil.displaySprite(getResourceFromGlob("background/clefs.png")); + + GuiComponent.blit(poseStack, x, grid.getY() + (NoteButton.getSize() + 16) * index, index * CLEF_WIDTH, 0, CLEF_WIDTH, CLEF_HEIGHT, @@ -122,8 +125,10 @@ protected void renderClef(final GuiGraphics gui, final int index, final int x) { ); } - protected void renderStaff(final GuiGraphics gui, final int index) { - gui.blit(getResourceFromGlob("background/staff.png"), + protected void renderStaff(final PoseStack poseStack, final int index) { + ClientUtil.displaySprite(getResourceFromGlob("background/staff.png")); + + GuiComponent.blit(poseStack, grid.getX() + 2, grid.getY() + 8 + ((NoteButton.getSize() + NoteGrid.PADDING_VERT + 6) * index), 0, 0, grid.getWidth() - 5, NoteButton.getSize(), diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java index 353ef4e..95df26a 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java @@ -11,10 +11,10 @@ import com.cstav.genshinstrument.util.ModEntityData; import com.mojang.blaze3d.platform.InputConstants.Key; import com.mojang.blaze3d.platform.InputConstants.Type; +import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; @@ -197,10 +197,10 @@ private void unlockFocused() { private boolean isOptionsActive = false; @Override - public void render(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick) { - super.render(gui, pMouseX, pMouseY, pPartialTick); + public void render(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) { + super.render(poseStack, pMouseX, pMouseY, pPartialTick); if (ioa()) - optionsScreen.render(gui, pMouseX, pMouseY, pPartialTick); + optionsScreen.render(poseStack, pMouseX, pMouseY, pPartialTick); } protected void onOptionsOpen() { diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteButton.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteButton.java index d7fafd4..ede672f 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteButton.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteButton.java @@ -15,11 +15,12 @@ import com.cstav.genshinstrument.sound.NoteSound; import com.cstav.genshinstrument.util.CommonUtil; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.narration.NarratedElementType; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -155,13 +156,15 @@ public boolean isPlaying() { } + @Override - public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float partialTick) { + public void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTick) { RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); RenderSystem.enableDepthTest(); rings.removeIf((ring) -> !ring.isPlaying()); - rings.forEach((ring) -> ring.render(gui)); + rings.forEach((ring) -> ring.render(poseStack)); final InstrumentThemeLoader theme = instrumentScreen.getThemeLoader(); final Color @@ -172,6 +175,7 @@ public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float partialT // Button + ClientUtil.displaySprite(noteBgLocation); // width = full color, width * 2 = border, 0 = normal int blitOffset = @@ -183,7 +187,7 @@ public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float partialT (width * 2) : 0; - gui.blit(noteBgLocation, + GuiComponent.blit(poseStack, this.getX(), this.getY(), blitOffset, 0, width, height, @@ -191,10 +195,12 @@ public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float partialT ); // Note + ClientUtil.displaySprite(noteLocation); + final int noteWidth = width/2, noteHeight = height/2; ClientUtil.setShaderColor((isPlaying() && !foreignPlaying) ? pressedNoteTheme : labelTheme); - gui.blit(noteLocation, + GuiComponent.blit(poseStack, this.getX() + noteWidth/2, this.getY() + noteHeight/2, //NOTE: I have no clue whatsoever how on earth these 1.025 and .9 multipliers actually work. // Like seriously wtf why fkuaherjgaeorg i hate maths @@ -209,8 +215,8 @@ public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float partialT // Label //FIXME: All text rendered this way are making their way to the top of // the render stack, for some reason - gui.drawCenteredString( - minecraft.font, getMessage(), + drawCenteredString( + poseStack, minecraft.font, getMessage(), textX, textY, ((isPlaying() && !foreignPlaying) ? pressedNoteTheme : noteTheme).getRGB() ); diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteRing.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteRing.java index 4719543..14c5e96 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteRing.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/note/NoteRing.java @@ -6,10 +6,11 @@ import com.cstav.genshinstrument.client.ClientUtil; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractInstrumentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.animation.RingAnimationController; +import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiComponent; import net.minecraft.resources.ResourceLocation; @Environment(EnvType.CLIENT) @@ -32,7 +33,7 @@ public NoteRing(final NoteButton note, final boolean isForeign) { } - public void render(final GuiGraphics gui) { + public void render(final PoseStack poseStack) { if (!ringAnimation.isPlaying()) return; @@ -41,10 +42,12 @@ public void render(final GuiGraphics gui) { final Point ringCenter = ClientUtil.getInitCenter(note.getInitX(), note.getInitY(), NoteButton.getSize(), size); + ClientUtil.displaySprite( + new ResourceLocation(GInstrumentMod.MODID, AbstractInstrumentScreen.getGlobalRootPath() + RING_GLOB_FILENAME) + ); ClientUtil.setShaderColor(note.instrumentScreen.getThemeLoader().getNoteTheme(), alpha); - gui.blit( - new ResourceLocation(GInstrumentMod.MODID, AbstractInstrumentScreen.getGlobalRootPath() + RING_GLOB_FILENAME), + GuiComponent.blit(poseStack, ringCenter.x, ringCenter.y, 0, 0, size, size, diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/vintagelyre/VintageNoteButton.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/vintagelyre/VintageNoteButton.java index 7a6f4f9..26da795 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/vintagelyre/VintageNoteButton.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/vintagelyre/VintageNoteButton.java @@ -1,13 +1,15 @@ package com.cstav.genshinstrument.client.gui.screens.instrument.vintagelyre; +import com.cstav.genshinstrument.client.ClientUtil; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractGridInstrumentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteGridButton; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier; import com.cstav.genshinstrument.sound.NoteSound; +import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiComponent; import net.minecraft.resources.ResourceLocation; @Environment(EnvType.CLIENT) @@ -28,8 +30,8 @@ private boolean shouldRenderThingy() { } @Override - public void renderWidget(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick) { - super.renderWidget(gui, pMouseX, pMouseY, pPartialTick); + public void renderWidget(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) { + super.renderWidget(poseStack, pMouseX, pMouseY, pPartialTick); if (!shouldRenderThingy()) return; @@ -37,7 +39,10 @@ public void renderWidget(GuiGraphics gui, int pMouseX, int pMouseY, float pParti final int textureWidth = (int)(width * TEXTURE_MULTIPLIER), textureHeight = (int)(height * TEXTURE_MULTIPLIER); - gui.blit(thingyLocation, + + ClientUtil.displaySprite(thingyLocation); + + GuiComponent.blit(poseStack, getX() - 1, getY() - 5, isPlaying() ? textureWidth/2 : 0, 0, textureWidth/2, textureHeight, diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java index ad66b39..6e76814 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java @@ -13,11 +13,11 @@ import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel; import com.cstav.genshinstrument.sound.NoteSound; import com.ibm.icu.text.DecimalFormat; +import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.CycleButton; @@ -289,12 +289,12 @@ protected void onSharedInstrumentChanged(final CycleButton button, fina @Override - public void render(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick) { - renderBackground(gui); + public void render(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) { + renderBackground(poseStack); - gui.drawCenteredString(font, title, width/2, 20, Color.WHITE.getRGB()); + drawCenteredString(poseStack, font, title, width/2, 20, Color.WHITE.getRGB()); - super.render(gui, pMouseX, pMouseY, pPartialTick); + super.render(poseStack, pMouseX, pMouseY, pPartialTick); } diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/FloralZitherOptionsScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/FloralZitherOptionsScreen.java index cdc52fb..00f547a 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/FloralZitherOptionsScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/FloralZitherOptionsScreen.java @@ -5,10 +5,10 @@ import com.cstav.genshinstrument.client.config.ModClientConfigs; import com.cstav.genshinstrument.client.config.enumType.ZitherSoundType; import com.cstav.genshinstrument.client.gui.screens.instrument.floralzither.FloralZitherScreen; +import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.CycleButton; import net.minecraft.client.gui.layouts.GridLayout; import net.minecraft.client.gui.layouts.GridLayout.RowHelper; @@ -53,10 +53,10 @@ protected void initOptionsGrid(GridLayout grid, RowHelper rowHelper) { } @Override - public void render(GuiGraphics gui, int pMouseX, int pMouseY, float pPartialTick) { - super.render(gui, pMouseX, pMouseY, pPartialTick); + public void render(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) { + super.render(poseStack, pMouseX, pMouseY, pPartialTick); - gui.drawCenteredString(font, + drawCenteredString(poseStack, font, Component.translatable("button.genshinstrument.zither_options"), width/2, heightBefore + SPACE_BEFORE + SPACER_HEIGHT , Color.WHITE.getRGB()); diff --git a/src/main/java/com/cstav/genshinstrument/criteria/InstrumentPlayedTrigger.java b/src/main/java/com/cstav/genshinstrument/criteria/InstrumentPlayedTrigger.java index 0b4f46a..753609f 100644 --- a/src/main/java/com/cstav/genshinstrument/criteria/InstrumentPlayedTrigger.java +++ b/src/main/java/com/cstav/genshinstrument/criteria/InstrumentPlayedTrigger.java @@ -4,8 +4,8 @@ import com.google.gson.JsonObject; import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance; -import net.minecraft.advancements.critereon.ContextAwarePredicate; import net.minecraft.advancements.critereon.DeserializationContext; +import net.minecraft.advancements.critereon.EntityPredicate.Composite; import net.minecraft.advancements.critereon.ItemPredicate; import net.minecraft.advancements.critereon.SerializationContext; import net.minecraft.advancements.critereon.SimpleCriterionTrigger; @@ -35,7 +35,7 @@ public ResourceLocation getId() { } @Override - protected TriggerInstance createInstance(JsonObject pJson, ContextAwarePredicate player, DeserializationContext pContext) { + protected TriggerInstance createInstance(JsonObject pJson, Composite player, DeserializationContext pContext) { return new TriggerInstance(player, ItemPredicate.fromJson(pJson.get("instrument"))); } @@ -49,7 +49,7 @@ public void trigger(final ServerPlayer player, final ItemStack instrument) { public static class TriggerInstance extends AbstractCriterionTriggerInstance { private final ItemPredicate item; - public TriggerInstance(ContextAwarePredicate pPlayer, ItemPredicate item) { + public TriggerInstance(Composite pPlayer, ItemPredicate item) { super(ID, pPlayer); this.item = item; } diff --git a/src/main/java/com/cstav/genshinstrument/event/InstrumentPlayedEvent.java b/src/main/java/com/cstav/genshinstrument/event/InstrumentPlayedEvent.java index cde50f7..2716b57 100644 --- a/src/main/java/com/cstav/genshinstrument/event/InstrumentPlayedEvent.java +++ b/src/main/java/com/cstav/genshinstrument/event/InstrumentPlayedEvent.java @@ -67,7 +67,7 @@ public static class ByPlayerArgs extends InstrumentPlayedEventArgs { public final InteractionHand hand; public ByPlayerArgs(NoteSound sound, Player player, InteractionHand hand, ResourceLocation instrumentId, boolean isClientSide) { - super(sound, player.level(), player.blockPosition(), instrumentId, isClientSide); + super(sound, player.getLevel(), player.blockPosition(), instrumentId, isClientSide); this.player = player; this.hand = hand; diff --git a/src/main/java/com/cstav/genshinstrument/item/ModItems.java b/src/main/java/com/cstav/genshinstrument/item/ModItems.java index 0e66380..fb36493 100644 --- a/src/main/java/com/cstav/genshinstrument/item/ModItems.java +++ b/src/main/java/com/cstav/genshinstrument/item/ModItems.java @@ -6,7 +6,6 @@ import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTabs; @@ -43,11 +42,7 @@ private static void addToItemGroups(final Item item) { addToTab(ModCreativeModeTabs.INSTRUMENTS, item); addToTab(CreativeModeTabs.TOOLS_AND_UTILITIES, item); } - private static void addToTab(final CreativeModeTab tab, final Item item) { - addToTab(BuiltInRegistries.CREATIVE_MODE_TAB.getResourceKey(tab).get(), item); - } - private static void addToTab(final ResourceKey tab, final Item item) { ItemGroupEvents.modifyEntriesEvent(tab).register((content) -> content.accept(item)); } diff --git a/src/main/java/com/cstav/genshinstrument/networking/packets/instrument/CloseInstrumentPacket.java b/src/main/java/com/cstav/genshinstrument/networking/packets/instrument/CloseInstrumentPacket.java index 949122b..667f68e 100644 --- a/src/main/java/com/cstav/genshinstrument/networking/packets/instrument/CloseInstrumentPacket.java +++ b/src/main/java/com/cstav/genshinstrument/networking/packets/instrument/CloseInstrumentPacket.java @@ -21,7 +21,7 @@ public CloseInstrumentPacket(FriendlyByteBuf buf) {} public void handle(Player player, PacketSender responseSender) { ModEntityData.setInstrumentOpen(player, false); - for (final Player oPlayer : player.level().players()) + for (final Player oPlayer : player.getLevel().players()) ModPacketHandler.sendToClient(new NotifyInstrumentOpenPacket(player.getUUID(), false), (ServerPlayer)oPlayer); } diff --git a/src/main/java/com/cstav/genshinstrument/networking/packets/instrument/NotifyInstrumentOpenPacket.java b/src/main/java/com/cstav/genshinstrument/networking/packets/instrument/NotifyInstrumentOpenPacket.java index 432efb1..31771fb 100644 --- a/src/main/java/com/cstav/genshinstrument/networking/packets/instrument/NotifyInstrumentOpenPacket.java +++ b/src/main/java/com/cstav/genshinstrument/networking/packets/instrument/NotifyInstrumentOpenPacket.java @@ -34,7 +34,7 @@ public void write(FriendlyByteBuf buf) { @Override public void handle(Player player, PacketSender responseSender) { - ModEntityData.setInstrumentOpen(player.level().getPlayerByUUID(playerUUID), isOpen); + ModEntityData.setInstrumentOpen(player.getLevel().getPlayerByUUID(playerUUID), isOpen); } } diff --git a/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java b/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java index a063519..4d32839 100644 --- a/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java +++ b/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java @@ -36,7 +36,7 @@ public class ServerUtil { */ public static void sendPlayNotePackets(ServerPlayer player, InteractionHand hand, NoteSound sound, ResourceLocation instrumentId, float pitch) { - for (final Player listener : noteListeners(player.level(), player.blockPosition())) + for (final Player listener : noteListeners(player.getLevel(), player.blockPosition())) ModPacketHandler.sendToClient( new PlayNotePacket( player.blockPosition(), sound, pitch, instrumentId, @@ -47,7 +47,7 @@ public static void sendPlayNotePackets(ServerPlayer player, InteractionHand hand // Trigger an instrument game event // This is done so that sculk sensors can pick up the instrument's sound - player.level().gameEvent( + player.getLevel().gameEvent( GameEvent.INSTRUMENT_PLAY, player.blockPosition(), GameEvent.Context.of(player) ); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index cf35fc2..1032714 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -32,7 +32,7 @@ ], "depends": { "fabricloader": ">=0.14.21", - "minecraft": "~1.20", + "minecraft": "~1.19.4", "java": ">=17", "fabric-api": "*", "forgeconfigapiport": "*"