diff --git a/gradle.properties b/gradle.properties index bd3d2d9a..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.1 +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/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/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/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( ( 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..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; }; } @@ -122,14 +118,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; @@ -168,7 +169,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 +180,7 @@ protected String getPath() { /** * Override this method if you want to reference another directory for resources */ - protected ResourceLocation getSourcePath() { + public ResourceLocation getSourcePath() { return getInstrumentId(); } @@ -299,7 +302,10 @@ public void onOptionsClose() { 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) { InstrumentOpenProvider.setClosed(minecraft.player); ModPacketHandler.sendToServer(new CloseInstrumentPacket()); 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()); } 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, 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/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/options/instrument/AbstractInstrumentOptionsScreen.java index c215128f..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() @@ -224,14 +221,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 + Component.translatable("button.genshinstrument.accurate_notes"), this::onAccurateNotesChanged ); - rowHelper.addChild(accurateAccidentals); + rowHelper.addChild(accurateNotes); if (labels != null) { @@ -300,7 +297,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) 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(); } 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/networking/ModPacketHandler.java b/src/main/java/com/cstav/genshinstrument/networking/ModPacketHandler.java index 7268ed43..044b0d9c 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; @@ -44,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/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/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()) - // } ; /** 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) } diff --git a/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java b/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java index 3705f9d6..e3cb6cfb 100644 --- a/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java +++ b/src/main/java/com/cstav/genshinstrument/util/ServerUtil.java @@ -194,14 +194,17 @@ 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); player.level().players().forEach((nearbyPlayer) -> ModPacketHandler.sendToClient( - new NotifyInstrumentOpenPacket(player.getUUID(), true, playPos), + new NotifyInstrumentOpenPacket(player.getUUID(), playPos), (ServerPlayer)nearbyPlayer ) ); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 6417c7c6..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.1" #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/