From 168183ecb60b06afdaef797767fa0cc817995019 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Fri, 4 Aug 2023 22:39:58 +0300 Subject: [PATCH 01/18] Fix server unwaware of block/item instrument state --- src/main/java/com/cstav/genshinstrument/util/ServerUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java b/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java index 3705f9d6..33616c70 100644 --- a/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java +++ b/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java @@ -194,7 +194,10 @@ private static boolean sendOpenPacket(ServerPlayer player, InteractionHand usedH onOpenRequest.send(player, usedHand); // Update the the capabilty on server - InstrumentOpenProvider.setOpen(player, pos); + if (pos == null) + InstrumentOpenProvider.setOpen(player); + else + InstrumentOpenProvider.setOpen(player, pos); // And clients final Optional playPos = Optional.ofNullable(pos); From c22b5273f7efb6f7475576f73fbee725b1edf925 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Fri, 4 Aug 2023 23:01:50 +0300 Subject: [PATCH 02/18] Remove useless comment --- src/main/java/com/cstav/genshinstrument/sound/NoteSound.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/cstav/genshinstrument/sound/NoteSound.java b/src/main/java/com/cstav/genshinstrument/sound/NoteSound.java index d55f679c..e063157f 100644 --- a/src/main/java/com/cstav/genshinstrument/sound/NoteSound.java +++ b/src/main/java/com/cstav/genshinstrument/sound/NoteSound.java @@ -207,7 +207,6 @@ public static int clampPitch(final int pitch) { */ public static float getPitchByNoteOffset(final int pitch) { return (float)Math.pow(2, (double)pitch / LabelUtil.NOTES_PER_SCALE); - // (float)Math.pow(2.0D, (double)(pNote - 12) / 12.0D) } From 035454a7e68388a93707aeeddac580f02623e453 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 00:14:05 +0300 Subject: [PATCH 03/18] Rename accurate accidentals to notes --- .../options/instrument/AbstractInstrumentOptionsScreen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 c215128f..4de62a51 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 @@ -224,14 +224,14 @@ protected void initVisualsSection(final GridLayout grid, final RowHelper rowHelp ); rowHelper.addChild(sharedInstrument); - final CycleButton accurateAccidentals = CycleButton.booleanBuilder(CommonComponents.OPTION_ON, CommonComponents.OPTION_OFF) + final CycleButton accurateNotes = CycleButton.booleanBuilder(CommonComponents.OPTION_ON, CommonComponents.OPTION_OFF) .withInitialValue(ModClientConfigs.ACCURATE_NOTES.get()) .withTooltip((value) -> Tooltip.create(Component.translatable("button.genshinstrument.accurate_notes.tooltip"))) .create(0, 0, getSmallButtonWidth(), getButtonHeight(), Component.translatable("button.genshinstrument.accurate_notes"), this::onAccurateAccidentalsChanged ); - rowHelper.addChild(accurateAccidentals); + rowHelper.addChild(accurateNotes); if (labels != null) { From c9c6f8052a4479fdc4fb54a1bd74923cad93f008 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 00:15:42 +0300 Subject: [PATCH 04/18] Fix naming of onAccurateNotesChanged method --- .../options/instrument/AbstractInstrumentOptionsScreen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 4de62a51..9587363c 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 @@ -229,7 +229,7 @@ protected void initVisualsSection(final GridLayout grid, final RowHelper rowHelp .withTooltip((value) -> Tooltip.create(Component.translatable("button.genshinstrument.accurate_notes.tooltip"))) .create(0, 0, getSmallButtonWidth(), getButtonHeight(), - Component.translatable("button.genshinstrument.accurate_notes"), this::onAccurateAccidentalsChanged + Component.translatable("button.genshinstrument.accurate_notes"), this::onAccurateNotesChanged ); rowHelper.addChild(accurateNotes); @@ -300,7 +300,7 @@ protected void onEmitRingChanged(final CycleButton button, final boolea protected void onSharedInstrumentChanged(final CycleButton button, final boolean value) { ModClientConfigs.SHARED_INSTRUMENT.set(value); } - protected void onAccurateAccidentalsChanged(final CycleButton button, final boolean value) { + protected void onAccurateNotesChanged(final CycleButton button, final boolean value) { ModClientConfigs.ACCURATE_NOTES.set(value); if (isOverlay) From 93c787c923a9fbc497d74874386cd9b3b91bc02f Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 00:36:27 +0300 Subject: [PATCH 05/18] Fix typo --- .../gui/screens/instrument/partial/notegrid/NoteGrid.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/notegrid/NoteGrid.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/notegrid/NoteGrid.java index 338beb63..3089de8f 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/notegrid/NoteGrid.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/notegrid/NoteGrid.java @@ -80,7 +80,7 @@ public NoteGrid(NoteSound[] noteSounds, AbstractGridInstrumentScreen instrumentS } /** - * Creates a note with for a singular sound type instrument + * Creates a note for a singular sound type instrument */ protected NoteButton createNote(int row, int column, int pitch) { return new NoteGridButton(row, column, From d9c28ab59be9eceb55b01f1185fb5d34ebca3488 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 14:50:40 +0300 Subject: [PATCH 06/18] Fix constructor formatting og NoteButton --- .../gui/screens/instrument/partial/note/NoteButton.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 1da8af32..3a38630d 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 @@ -50,8 +50,8 @@ public NoteButtonIdentifier getIdentifier() { protected abstract NoteButtonRenderer initNoteRenderer(); - public NoteButton(NoteSound sound, - NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen, int pitch) { + public NoteButton(NoteSound sound, NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen, + int pitch) { super(0, 0, 42, 42, Component.empty()); @@ -62,9 +62,7 @@ public NoteButton(NoteSound sound, this.instrumentScreen = instrumentScreen; this.pitch = pitch; } - public NoteButton(NoteSound sound, - NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen) { - + public NoteButton(NoteSound sound, NoteLabelSupplier labelSupplier, AbstractInstrumentScreen instrumentScreen) { this(sound, labelSupplier, instrumentScreen, instrumentScreen.getPitch()); } From 9b69cf506296cc09a34070a134d95d22628846c9 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 15:07:38 +0300 Subject: [PATCH 07/18] Update docs for getPath --- .../instrument/partial/AbstractInstrumentScreen.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 857aedb4..3da55681 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 @@ -168,7 +168,9 @@ public static ResourceLocation getInternalResourceFromGlob(final String path) { return new ResourceLocation(GInstrumentMod.MODID, getGlobalRootPath() + path); } /** - * Shorthand for {@code getRootPath() + getInstrumentId()} + * Gets the resource path under this instrument. + * It will usually be {@code textures/gui/instrument//}. + * {@code instrument} is as specified by {@link AbstractInstrumentScreen#getSourcePath getSourcePath}. */ protected String getPath() { return getGlobalRootPath() + getSourcePath().getPath() + "/"; @@ -177,7 +179,7 @@ protected String getPath() { /** * Override this method if you want to reference another directory for resources */ - protected ResourceLocation getSourcePath() { + public ResourceLocation getSourcePath() { return getInstrumentId(); } From 4fb2d7a7540f3b330aaacf0febdbce8c2ae25e43 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 15:19:06 +0300 Subject: [PATCH 08/18] Modify conversion method of ABC_1 label type --- .../client/config/enumType/label/NoteGridLabel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java index 9a106839..8aaf74d4 100644 --- a/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java +++ b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java @@ -28,7 +28,7 @@ public enum NoteGridLabel implements INoteLabel { ).append(LabelUtil.getCutNoteName(ng(note)).substring(1)) ), ABC_1((note) -> Component.literal( - LabelUtil.ABC[ng(note).row]+"" + (gs(note).columns() - ng(note).column) + String.valueOf(LabelUtil.ABC[ng(note).row]) + (gs(note).columns() - ng(note).column) )), ABC_2((note) -> Component.literal( ( From 2d96c425417aed1ea2fa687d824049571daa97e4 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 19:05:54 +0300 Subject: [PATCH 09/18] lastScreen defaulting to grid, labels not updating --- .../instrument/AbstractInstrumentOptionsScreen.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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 9587363c..31327aa4 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 @@ -8,7 +8,6 @@ import com.cstav.genshinstrument.client.config.ModClientConfigs; import com.cstav.genshinstrument.client.config.enumType.InstrumentChannelType; -import com.cstav.genshinstrument.client.config.enumType.label.NoteGridLabel; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractInstrumentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel; @@ -83,7 +82,7 @@ protected int getButtonHeight() { public final boolean isOverlay; protected final @Nullable INoteLabel[] labels; - protected final @Nullable INoteLabel currLabel; + protected @Nullable INoteLabel currLabel; /** * Override to {@code false} tp disable the pitch slider from the options. @@ -104,7 +103,6 @@ public AbstractInstrumentOptionsScreen(@Nullable AbstractInstrumentScreen screen lastScreen = null; labels = getLabels(); - currLabel = getCurrentLabel(); } public AbstractInstrumentOptionsScreen(final Screen lastScreen) { super(Component.translatable("button.genshinstrument.instrumentOptions")); @@ -113,13 +111,12 @@ public AbstractInstrumentOptionsScreen(final Screen lastScreen) { this.instrumentScreen = null; this.lastScreen = lastScreen; - // Default to NoteGridLabel's values - labels = NoteGridLabel.values(); - currLabel = ModClientConfigs.GRID_LABEL_TYPE.get(); + labels = getLabels(); } @Override protected void init() { + currLabel = getCurrentLabel(); final GridLayout grid = new GridLayout(); grid.defaultCellSetting() From bdfe0ebacf19fcccccffa7344e397dab92e58468 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 19:10:10 +0300 Subject: [PATCH 10/18] Fix mod config screen crashing --- .../options/instrument/GridInstrumentOptionsScreen.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/GridInstrumentOptionsScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/GridInstrumentOptionsScreen.java index 4f837bd0..69177c0a 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/GridInstrumentOptionsScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/GridInstrumentOptionsScreen.java @@ -54,7 +54,8 @@ protected void saveLabel(final INoteLabel newLabel) { @Override public boolean isPitchSliderEnabled() { - return !((AbstractGridInstrumentScreen)instrumentScreen).isSSTI(); + return (instrumentScreen == null) || + !((AbstractGridInstrumentScreen)instrumentScreen).isSSTI(); } From 688eb85ca2f6d362faf98b455d7d5d2a06a575c7 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 21:37:53 +0300 Subject: [PATCH 11/18] Remove useless packet NotifyInstrumentClosed --- .../partial/AbstractInstrumentBlock.java | 4 +- .../networking/ModPacketHandler.java | 3 +- .../instrument/CloseInstrumentPacket.java | 2 +- .../NotifyInstrumentClosedPacket.java | 43 ------------------- .../NotifyInstrumentOpenPacket.java | 14 +++++- .../genshinstrument/util/ServerUtil.java | 2 +- 6 files changed, 18 insertions(+), 50 deletions(-) delete mode 100644 src/main/java/com/cstav/genshinstrument/networking/packet/instrument/NotifyInstrumentClosedPacket.java diff --git a/src/main/java/com/cstav/genshinstrument/block/partial/AbstractInstrumentBlock.java b/src/main/java/com/cstav/genshinstrument/block/partial/AbstractInstrumentBlock.java index f850411e..9f91fb4f 100644 --- a/src/main/java/com/cstav/genshinstrument/block/partial/AbstractInstrumentBlock.java +++ b/src/main/java/com/cstav/genshinstrument/block/partial/AbstractInstrumentBlock.java @@ -7,7 +7,7 @@ import com.cstav.genshinstrument.client.ModArmPose; import com.cstav.genshinstrument.networking.ModPacketHandler; import com.cstav.genshinstrument.networking.OpenInstrumentPacketSender; -import com.cstav.genshinstrument.networking.packet.instrument.NotifyInstrumentClosedPacket; +import com.cstav.genshinstrument.networking.packet.instrument.NotifyInstrumentOpenPacket; import com.cstav.genshinstrument.util.ServerUtil; import net.minecraft.client.model.HumanoidModel.ArmPose; @@ -91,7 +91,7 @@ public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState for (final Player player : pLevel.players()) { ibe.users.forEach((user) -> { InstrumentOpenProvider.setClosed(pLevel.getPlayerByUUID(user)); - ModPacketHandler.sendToClient(new NotifyInstrumentClosedPacket(user), (ServerPlayer)player); + ModPacketHandler.sendToClient(new NotifyInstrumentOpenPacket(user, false), (ServerPlayer)player); }); } } diff --git a/src/main/java/com/cstav/genshinstrument/networking/ModPacketHandler.java b/src/main/java/com/cstav/genshinstrument/networking/ModPacketHandler.java index 7268ed43..af9c2e6d 100644 --- a/src/main/java/com/cstav/genshinstrument/networking/ModPacketHandler.java +++ b/src/main/java/com/cstav/genshinstrument/networking/ModPacketHandler.java @@ -9,7 +9,6 @@ import com.cstav.genshinstrument.networking.buttonidentifier.NoteGridButtonIdentifier; import com.cstav.genshinstrument.networking.packet.instrument.CloseInstrumentPacket; import com.cstav.genshinstrument.networking.packet.instrument.InstrumentPacket; -import com.cstav.genshinstrument.networking.packet.instrument.NotifyInstrumentClosedPacket; import com.cstav.genshinstrument.networking.packet.instrument.NotifyInstrumentOpenPacket; import com.cstav.genshinstrument.networking.packet.instrument.OpenInstrumentPacket; import com.cstav.genshinstrument.networking.packet.instrument.PlayNotePacket; @@ -28,7 +27,7 @@ public class ModPacketHandler { @SuppressWarnings("unchecked") public static final List> ACCEPTABLE_PACKETS = List.of(new Class[] { InstrumentPacket.class, PlayNotePacket.class, OpenInstrumentPacket.class, CloseInstrumentPacket.class, - NotifyInstrumentOpenPacket.class, NotifyInstrumentClosedPacket.class + NotifyInstrumentOpenPacket.class }); private static int id = 0; diff --git a/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/CloseInstrumentPacket.java b/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/CloseInstrumentPacket.java index d6620820..66fd7e90 100644 --- a/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/CloseInstrumentPacket.java +++ b/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/CloseInstrumentPacket.java @@ -28,7 +28,7 @@ public void handle(final Supplier supplier) { InstrumentOpenProvider.setClosed(player); for (final Player oPlayer : player.level().players()) - ModPacketHandler.sendToClient(new NotifyInstrumentClosedPacket(player.getUUID()), (ServerPlayer)oPlayer); + ModPacketHandler.sendToClient(new NotifyInstrumentOpenPacket(player.getUUID(), false), (ServerPlayer)oPlayer); }); context.setPacketHandled(true); diff --git a/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/NotifyInstrumentClosedPacket.java b/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/NotifyInstrumentClosedPacket.java deleted file mode 100644 index 44584cf4..00000000 --- a/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/NotifyInstrumentClosedPacket.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.cstav.genshinstrument.networking.packet.instrument; - -import java.util.UUID; -import java.util.function.Supplier; - -import com.cstav.genshinstrument.capability.instrumentOpen.InstrumentOpenProvider; -import com.cstav.genshinstrument.networking.IModPacket; - -import net.minecraft.client.Minecraft; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraftforge.network.NetworkDirection; -import net.minecraftforge.network.NetworkEvent.Context; - -public class NotifyInstrumentClosedPacket implements IModPacket { - public static final NetworkDirection NETWORK_DIRECTION = NetworkDirection.PLAY_TO_CLIENT; - - - private final UUID playerUUID; - public NotifyInstrumentClosedPacket(UUID playerUUID) { - this.playerUUID = playerUUID; - } - public NotifyInstrumentClosedPacket(final FriendlyByteBuf buf) { - playerUUID = buf.readUUID(); - } - - @Override - public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(playerUUID); - } - - - @Override - public void handle(Supplier supplier) { - final Context context = supplier.get(); - - context.enqueueWork(() -> - InstrumentOpenProvider.setClosed(Minecraft.getInstance().level.getPlayerByUUID(playerUUID)) - ); - - context.setPacketHandled(true); - } - -} diff --git a/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/NotifyInstrumentOpenPacket.java b/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/NotifyInstrumentOpenPacket.java index 480f4f1e..c36501a8 100644 --- a/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/NotifyInstrumentOpenPacket.java +++ b/src/main/java/com/cstav/genshinstrument/networking/packet/instrument/NotifyInstrumentOpenPacket.java @@ -22,11 +22,23 @@ public class NotifyInstrumentOpenPacket implements IModPacket { private final boolean isOpen; private final Optional pos; - public NotifyInstrumentOpenPacket(UUID playerUUID, boolean isOpen, Optional pos) { + public NotifyInstrumentOpenPacket(UUID playerUUID, final boolean isOpen) { this.playerUUID = playerUUID; + this.isOpen = isOpen; + this.pos = Optional.empty(); + } + /** + * Constructs a {@link NotifyInstrumentOpenPacket} that notifies of an open state + * with an optional instrument block position. + */ + public NotifyInstrumentOpenPacket(UUID playerUUID, Optional pos) { + this.playerUUID = playerUUID; + + this.isOpen = true; this.pos = pos; } + public NotifyInstrumentOpenPacket(final FriendlyByteBuf buf) { playerUUID = buf.readUUID(); isOpen = buf.readBoolean(); diff --git a/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java b/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java index 33616c70..e3cb6cfb 100644 --- a/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java +++ b/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java @@ -204,7 +204,7 @@ private static boolean sendOpenPacket(ServerPlayer player, InteractionHand usedH player.level().players().forEach((nearbyPlayer) -> ModPacketHandler.sendToClient( - new NotifyInstrumentOpenPacket(player.getUUID(), true, playPos), + new NotifyInstrumentOpenPacket(player.getUUID(), playPos), (ServerPlayer)nearbyPlayer ) ); From 5e30ab4b51dc414a687d4e1c2c15b936e1cbd177 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 21:54:13 +0300 Subject: [PATCH 12/18] Bump mod version to v3.2.1, protocol to 4.6 --- gradle.properties | 2 +- .../com/cstav/genshinstrument/networking/ModPacketHandler.java | 2 +- src/main/resources/META-INF/mods.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index bd3d2d9a..dc131d46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -49,7 +49,7 @@ mod_name=Genshin Instruments # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=CC-BY-NC 4.0 # The mod version. See https://semver.org/ -mod_version=3.2.1 +mod_version=3.2.2 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/cstav/genshinstrument/networking/ModPacketHandler.java b/src/main/java/com/cstav/genshinstrument/networking/ModPacketHandler.java index af9c2e6d..044b0d9c 100644 --- a/src/main/java/com/cstav/genshinstrument/networking/ModPacketHandler.java +++ b/src/main/java/com/cstav/genshinstrument/networking/ModPacketHandler.java @@ -43,7 +43,7 @@ public static void registerPackets() { }); - private static final String PROTOCOL_VERSION = "4.5"; + private static final String PROTOCOL_VERSION = "4.6"; public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel( new ResourceLocation(GInstrumentMod.MODID, "main"), diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 6417c7c6..a2e5ad5c 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -17,7 +17,7 @@ issueTrackerURL="https://github.com/StavWasPlayZ/Genshin-Instruments/issues/" #o # The modid of the mod modId="genshinstrument" #mandatory # The version number of the mod -version="3.2.1" #mandatory +version="3.2.2" #mandatory # A display name for the mod displayName="Genshin Instruments" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/ From 54490ecd6a2840d6449e00243d4b92b47e81cac5 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 23:47:25 +0300 Subject: [PATCH 13/18] add TODOs --- .../partial/AbstractInstrumentScreen.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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 3da55681..faf546f2 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 @@ -122,14 +122,19 @@ public boolean handleAbruptClosing() { return true; } + //TODO handle the below server-side + // Handle item not in hand seperately // This is done like so because there is no event (that I know of) for when an item is moved/removed - if ( - (InstrumentOpenProvider.isItem(player) && interactionHand.isPresent()) - && !(player.getItemInHand(interactionHand.get()).getItem() instanceof InstrumentItem) - ) { - onClose(true); - return true; + if (InstrumentOpenProvider.isItem(player)) { + if (interactionHand.isPresent() + && !(player.getItemInHand(interactionHand.get()).getItem() instanceof InstrumentItem) + ) { + onClose(true); + return true; + } + } else { + //TODO add rule for block instruments to be in a distance of NoteSound.LOCAL_RANGE to play } return false; From 40564e104b304a5b42488fd2743759f143a839cf Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sat, 5 Aug 2023 23:49:17 +0300 Subject: [PATCH 14/18] Another TODO --- .../screens/instrument/partial/AbstractInstrumentScreen.java | 2 ++ 1 file changed, 2 insertions(+) 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 faf546f2..198f4f83 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 @@ -306,7 +306,9 @@ public void onOptionsClose() { public void onClose() { onClose(true); } + //TODO Remove this method public void onClose(final boolean notify) { + // This should always be false after the above move to server todo is implemented if (notify) { InstrumentOpenProvider.setClosed(minecraft.player); ModPacketHandler.sendToServer(new CloseInstrumentPacket()); From 1eaed9d1be64b2d9250cbe711645f0d507cda4b8 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sun, 6 Aug 2023 02:09:53 +0300 Subject: [PATCH 15/18] Fully remove tests --- .../block/LyreInstrumentBlock.java | 29 ------- .../block/ModBlockEntities.java | 1 - .../test/banjo/BanjoInstrumentScreen.java | 81 ------------------- .../cstav/genshinstrument/item/ModItems.java | 8 -- .../genshinstrument/sound/ModSounds.java | 5 -- 5 files changed, 124 deletions(-) delete mode 100644 src/main/java/com/cstav/genshinstrument/block/LyreInstrumentBlock.java delete mode 100644 src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/test/banjo/BanjoInstrumentScreen.java diff --git a/src/main/java/com/cstav/genshinstrument/block/LyreInstrumentBlock.java b/src/main/java/com/cstav/genshinstrument/block/LyreInstrumentBlock.java deleted file mode 100644 index 27c1f3dc..00000000 --- a/src/main/java/com/cstav/genshinstrument/block/LyreInstrumentBlock.java +++ /dev/null @@ -1,29 +0,0 @@ -// package com.cstav.genshinstrument.block; - -// import com.cstav.genshinstrument.block.partial.AbstractInstrumentBlock; -// import com.cstav.genshinstrument.block.partial.InstrumentBlockEntity; -// import com.cstav.genshinstrument.networking.OpenInstrumentPacketSender; -// import com.cstav.genshinstrument.util.ServerUtil; - -// import net.minecraft.core.BlockPos; -// import net.minecraft.world.level.block.state.BlockState; - - -// //TODO remove after tests -// public class LyreInstrumentBlock extends AbstractInstrumentBlock { - -// public LyreInstrumentBlock(Properties pProperties) { -// super(pProperties); -// } - -// @Override -// public InstrumentBlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { -// return new InstrumentBlockEntity(pPos, pState); -// } - -// @Override -// protected OpenInstrumentPacketSender instrumentPacketSender() { -// return (player, hand) -> ServerUtil.sendInternalOpenPacket(player, hand, "windsong_lyre"); -// } - -// } diff --git a/src/main/java/com/cstav/genshinstrument/block/ModBlockEntities.java b/src/main/java/com/cstav/genshinstrument/block/ModBlockEntities.java index c54a62ef..404bdb97 100644 --- a/src/main/java/com/cstav/genshinstrument/block/ModBlockEntities.java +++ b/src/main/java/com/cstav/genshinstrument/block/ModBlockEntities.java @@ -14,7 +14,6 @@ public static void register(final IEventBus bus) { BETS.register(bus); } - // //TODO remove after tests // public static final RegistryObject> INSTRUMENT_BE = BETS.register("instrument_be", () -> // BlockEntityType.Builder.of((pos, state) -> new InstrumentBlockEntity(pos, state), ModBlocks.LYRE_BLOCK.get()) // .build(null) diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/test/banjo/BanjoInstrumentScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/test/banjo/BanjoInstrumentScreen.java deleted file mode 100644 index 32f2e8cc..00000000 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/test/banjo/BanjoInstrumentScreen.java +++ /dev/null @@ -1,81 +0,0 @@ -// package com.cstav.genshinstrument.client.gui.screens.instrument.test.banjo; - -// import com.cstav.genshinstrument.GInstrumentMod; -// import com.cstav.genshinstrument.client.gui.screens.instrument.floralzither.FloralZitherScreen; -// import com.cstav.genshinstrument.client.gui.screens.instrument.partial.InstrumentThemeLoader; -// import com.cstav.genshinstrument.client.gui.screens.instrument.partial.notegrid.AbstractGridInstrumentScreen; -// import com.cstav.genshinstrument.sound.ModSounds; -// import com.cstav.genshinstrument.sound.NoteSound; - -// import net.minecraft.client.Minecraft; -// import net.minecraft.resources.ResourceLocation; -// import net.minecraft.world.InteractionHand; -// import net.minecraftforge.api.distmarker.Dist; -// import net.minecraftforge.api.distmarker.OnlyIn; -// import net.minecraftforge.fml.common.Mod.EventBusSubscriber; - -// //TODO remove after tests -// @OnlyIn(Dist.CLIENT) -// @EventBusSubscriber(Dist.CLIENT) -// public class BanjoInstrumentScreen extends AbstractGridInstrumentScreen { -// public static final String INSTRUMENT_ID = "banjo"; -// public static final String[] NOTES_LAYOUT = {"F#", "G", "G#", "A", "A#", "B", "C", "C#", "D", "D#", "E", "F"}; - - -// @Override -// public int rows() { -// return 8; -// } - -// @SuppressWarnings("resource") -// public int getNoteSize() { -// final int guiScale = Minecraft.getInstance().options.guiScale().get(); - -// return switch (guiScale) { -// case 0 -> 40; -// case 1 -> 35; -// case 2 -> 41; -// case 3 -> 48; -// case 4 -> 41; -// default -> guiScale * 18; -// }; -// } - - -// public BanjoInstrumentScreen(InteractionHand hand) { -// super(hand); -// } -// @Override -// public ResourceLocation getInstrumentId() { -// return new ResourceLocation(GInstrumentMod.MODID, INSTRUMENT_ID); -// } - - -// @Override -// protected ResourceLocation getSourcePath() { -// return new ResourceLocation(GInstrumentMod.MODID, FloralZitherScreen.INSTRUMENT_ID); -// } - - -// @Override -// public NoteSound[] getSounds() { -// return ModSounds.BANJO; -// } - -// @Override -// public String[] noteLayout() { -// return NOTES_LAYOUT; -// } - -// @Override -// public boolean isSSTI() { -// return true; -// } - - -// private static final InstrumentThemeLoader THEME_LOADER = initThemeLoader(GInstrumentMod.MODID, FloralZitherScreen.INSTRUMENT_ID); -// @Override -// public InstrumentThemeLoader getThemeLoader() { -// return THEME_LOADER; -// } -// } diff --git a/src/main/java/com/cstav/genshinstrument/item/ModItems.java b/src/main/java/com/cstav/genshinstrument/item/ModItems.java index 7a4c276e..09352bc2 100644 --- a/src/main/java/com/cstav/genshinstrument/item/ModItems.java +++ b/src/main/java/com/cstav/genshinstrument/item/ModItems.java @@ -44,14 +44,6 @@ public static void register(final IEventBus bus) { (player, hand) -> sendInternalOpenPacket(player, hand, "glorious_drum") ) ) - - - // //TODO remove after tests - // BANJO = ITEMS.register("banjo", () -> - // new InstrumentItem( - // (player, hand) -> sendInternalOpenPacket(player, hand, "banjo") - // ) - // ) ; diff --git a/src/main/java/com/cstav/genshinstrument/sound/ModSounds.java b/src/main/java/com/cstav/genshinstrument/sound/ModSounds.java index 23fafaf1..a5f82be3 100644 --- a/src/main/java/com/cstav/genshinstrument/sound/ModSounds.java +++ b/src/main/java/com/cstav/genshinstrument/sound/ModSounds.java @@ -30,11 +30,6 @@ public static void register(final IEventBus bus) { registerNote(SOUNDS, loc("glorious_drum_don")), registerNote(SOUNDS, loc("glorious_drum_ka"), true) } - - //TODO remove after tests - // BANJO = new NoteSound[] { - // new NoteSound(NoteBlockInstrument.BANJO.getSoundEvent().get(), Optional.empty()) - // } ; /** From 9367d935ee9851a6c03475b64779142149f42dc2 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sun, 6 Aug 2023 02:10:50 +0300 Subject: [PATCH 16/18] Deprecated close method --- .../gui/screens/instrument/partial/AbstractInstrumentScreen.java | 1 + 1 file changed, 1 insertion(+) 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 198f4f83..e9278b7c 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 @@ -307,6 +307,7 @@ public void onClose() { onClose(true); } //TODO Remove this method + @Deprecated(forRemoval = true) public void onClose(final boolean notify) { // This should always be false after the above move to server todo is implemented if (notify) { From 9c95b928d1ab4eef522fd8b889b6bbb42e176662 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sun, 6 Aug 2023 14:54:43 +0300 Subject: [PATCH 17/18] Fix humongous notes --- .../instrument/partial/AbstractInstrumentScreen.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 e9278b7c..7b92644f 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 @@ -37,15 +37,11 @@ public abstract class AbstractInstrumentScreen extends Screen { @SuppressWarnings("resource") public int getNoteSize() { - final int guiScale = Minecraft.getInstance().options.guiScale().get(); - - return switch (guiScale) { - case 0 -> 40; + return switch (Minecraft.getInstance().options.guiScale().get()) { case 1 -> 35; case 2 -> 46; case 3 -> 48; - case 4 -> 41; - default -> guiScale * 18; + default -> 40; }; } From 1eccc61a082e2392c75c3e2d06b0025770440e00 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Sun, 6 Aug 2023 15:00:19 +0300 Subject: [PATCH 18/18] Bump version to v3.2.2.1 --- gradle.properties | 2 +- src/main/resources/META-INF/mods.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index dc131d46..c10c32ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -49,7 +49,7 @@ mod_name=Genshin Instruments # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=CC-BY-NC 4.0 # The mod version. See https://semver.org/ -mod_version=3.2.2 +mod_version=3.2.2.1 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a2e5ad5c..28fb09c1 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -17,7 +17,7 @@ issueTrackerURL="https://github.com/StavWasPlayZ/Genshin-Instruments/issues/" #o # The modid of the mod modId="genshinstrument" #mandatory # The version number of the mod -version="3.2.2" #mandatory +version="3.2.2.1" #mandatory # A display name for the mod displayName="Genshin Instruments" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/