diff --git a/src/main/java/pokefenn/totemic/api/music/DefaultMusicAcceptor.java b/src/main/java/pokefenn/totemic/api/music/DefaultMusicAcceptor.java index e171d360..33ba2f0f 100644 --- a/src/main/java/pokefenn/totemic/api/music/DefaultMusicAcceptor.java +++ b/src/main/java/pokefenn/totemic/api/music/DefaultMusicAcceptor.java @@ -63,16 +63,14 @@ public MusicResult acceptMusic(MusicInstrument instr, int amount, Vec3 from, @Nu /** * Returns the amount of music stored from the given instrument. */ - public int getMusicAmount(MusicInstrument instr) - { + public int getMusicAmount(MusicInstrument instr) { return music.getInt(instr); } /** * Sets the amount of music for the given instrument. This method does not check if the amount exceeds the maximum. */ - public void setMusicAmount(MusicInstrument instr, int amount) - { + public void setMusicAmount(MusicInstrument instr, int amount) { Objects.requireNonNull(instr); int oldVal = music.getInt(instr); if(amount != oldVal) { diff --git a/src/main/java/pokefenn/totemic/block/totem/entity/StateStartup.java b/src/main/java/pokefenn/totemic/block/totem/entity/StateStartup.java index 85639c41..c5b65b8e 100644 --- a/src/main/java/pokefenn/totemic/block/totem/entity/StateStartup.java +++ b/src/main/java/pokefenn/totemic/block/totem/entity/StateStartup.java @@ -15,6 +15,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; +import net.minecraftforge.network.PacketDistributor; import pokefenn.totemic.Totemic; import pokefenn.totemic.advancements.ModCriteriaTriggers; import pokefenn.totemic.api.TotemicAPI; @@ -62,7 +63,7 @@ public boolean canAcceptMusic(MusicInstrument instr) { public MusicResult acceptMusic(MusicInstrument instr, int amount, Vec3 from, @Nullable Entity entity) { var result = musicHandler.acceptMusic(instr, amount, from, entity); if(result.isSuccess()) { - NetworkHandler.channel.send(NetworkHandler.nearTile(tile, 16), + NetworkHandler.channel.send(PacketDistributor.TRACKING_CHUNK.with(() -> tile.getLevel().getChunkAt(tile.getBlockPos())), new ClientboundPacketStartupMusic(tile.getBlockPos(), instr, musicHandler.getMusicAmount(instr))); tile.setChanged(); } diff --git a/src/main/java/pokefenn/totemic/block/totem/entity/TotemBaseBlockEntity.java b/src/main/java/pokefenn/totemic/block/totem/entity/TotemBaseBlockEntity.java index fb6fe3c9..becb301c 100644 --- a/src/main/java/pokefenn/totemic/block/totem/entity/TotemBaseBlockEntity.java +++ b/src/main/java/pokefenn/totemic/block/totem/entity/TotemBaseBlockEntity.java @@ -175,9 +175,7 @@ public void load(CompoundTag tag) { @Override public CompoundTag getUpdateTag() { - var tag = new CompoundTag(); - saveAdditional(tag); - return tag; + return saveWithoutMetadata(); } @Override diff --git a/src/main/java/pokefenn/totemic/block/totem/entity/TotemPoleBlockEntity.java b/src/main/java/pokefenn/totemic/block/totem/entity/TotemPoleBlockEntity.java index bc2216e8..1b66a4e5 100644 --- a/src/main/java/pokefenn/totemic/block/totem/entity/TotemPoleBlockEntity.java +++ b/src/main/java/pokefenn/totemic/block/totem/entity/TotemPoleBlockEntity.java @@ -53,9 +53,7 @@ public void load(CompoundTag tag) { @Override public CompoundTag getUpdateTag() { - var tag = new CompoundTag(); - saveAdditional(tag); - return tag; + return saveWithoutMetadata(); } @Override diff --git a/src/main/java/pokefenn/totemic/network/NetworkHandler.java b/src/main/java/pokefenn/totemic/network/NetworkHandler.java index 0ac64b71..8d5374b3 100644 --- a/src/main/java/pokefenn/totemic/network/NetworkHandler.java +++ b/src/main/java/pokefenn/totemic/network/NetworkHandler.java @@ -2,15 +2,9 @@ import java.util.Optional; -import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.network.NetworkDirection; import net.minecraftforge.network.NetworkRegistry; -import net.minecraftforge.network.PacketDistributor; -import net.minecraftforge.network.PacketDistributor.PacketTarget; -import net.minecraftforge.network.PacketDistributor.TargetPoint; import net.minecraftforge.network.simple.SimpleChannel; import pokefenn.totemic.api.TotemicAPI; @@ -24,12 +18,4 @@ public static void init() { channel.registerMessage(0, ServerboundPacketMouseWheel.class, ServerboundPacketMouseWheel::encode, ServerboundPacketMouseWheel::decode, ServerboundPacketMouseWheel::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER)); channel.registerMessage(1, ClientboundPacketStartupMusic.class, ClientboundPacketStartupMusic::encode, ClientboundPacketStartupMusic::decode, ClientboundPacketStartupMusic::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT)); } - - public static PacketTarget nearPosition(Level level, BlockPos pos, double radius) { - return PacketDistributor.NEAR.with(TargetPoint.p(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, radius, level.dimension())); - } - - public static PacketTarget nearTile(BlockEntity tile, double radius) { - return nearPosition(tile.getLevel(), tile.getBlockPos(), radius); - } }