diff --git a/gradle.properties b/gradle.properties index 94c71e8..64f4700 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,6 +5,6 @@ yarn_mappings=1.18.1+build.18 loader_version=0.12.12 fabric_version=0.45.2+1.18 -mod_version = 3.0.0 +mod_version = 3.0.1 maven_group = net.ludocrypt archives_base_name = limlib diff --git a/src/main/java/net/ludocrypt/limlib/access/ClientPlayNetworkHandlerAccess.java b/src/main/java/net/ludocrypt/limlib/access/ClientPlayNetworkHandlerAccess.java deleted file mode 100644 index da79afb..0000000 --- a/src/main/java/net/ludocrypt/limlib/access/ClientPlayNetworkHandlerAccess.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.ludocrypt.limlib.access; - -import net.ludocrypt.limlib.api.sound.TravelSoundPacket; - -public interface ClientPlayNetworkHandlerAccess { - - public default void handleTravelSound(TravelSoundPacket travelSound) { - } - -} diff --git a/src/main/java/net/ludocrypt/limlib/api/sound/TravelSoundPacket.java b/src/main/java/net/ludocrypt/limlib/api/sound/TravelSoundPacket.java deleted file mode 100644 index 124b94d..0000000 --- a/src/main/java/net/ludocrypt/limlib/api/sound/TravelSoundPacket.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.ludocrypt.limlib.api.sound; - -import net.ludocrypt.limlib.access.ClientPlayNetworkHandlerAccess; -import net.minecraft.network.Packet; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.listener.ClientPlayPacketListener; -import net.minecraft.sound.SoundEvent; -import net.minecraft.util.registry.Registry; - -public class TravelSoundPacket implements Packet { - private final SoundEvent sound; - - public TravelSoundPacket(SoundEvent sound) { - this.sound = sound; - - } - - public TravelSoundPacket(PacketByteBuf buf) { - this.sound = Registry.SOUND_EVENT.get(buf.readIdentifier()); - } - - @Override - public void write(PacketByteBuf buf) { - buf.writeIdentifier(this.sound.getId()); - } - - @Override - public void apply(ClientPlayPacketListener clientPlayPacketListener) { - if (clientPlayPacketListener instanceof ClientPlayNetworkHandlerAccess) { - ((ClientPlayNetworkHandlerAccess) clientPlayPacketListener).handleTravelSound(this); - } - } - - public SoundEvent getSound() { - return sound; - } - -} diff --git a/src/main/java/net/ludocrypt/limlib/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/net/ludocrypt/limlib/mixin/ClientPlayNetworkHandlerMixin.java deleted file mode 100644 index bfec65e..0000000 --- a/src/main/java/net/ludocrypt/limlib/mixin/ClientPlayNetworkHandlerMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.ludocrypt.limlib.mixin; - -import org.spongepowered.asm.mixin.Mixin; - -import net.ludocrypt.limlib.access.ClientPlayNetworkHandlerAccess; -import net.ludocrypt.limlib.api.sound.TravelSoundPacket; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.sound.PositionedSoundInstance; -import net.minecraft.network.NetworkThreadUtils; - -@Mixin(ClientPlayNetworkHandler.class) -public class ClientPlayNetworkHandlerMixin implements ClientPlayNetworkHandlerAccess { - - @Override - public void handleTravelSound(TravelSoundPacket travelSound) { - MinecraftClient client = MinecraftClient.getInstance(); - NetworkThreadUtils.forceMainThread(travelSound, ((ClientPlayNetworkHandler) (Object) this), client); - if (client != null) { - client.getSoundManager().play(PositionedSoundInstance.ambient(travelSound.getSound(), client.world.getRandom().nextFloat() * 0.4F + 0.8F, 0.25F)); - } - } - -} diff --git a/src/main/java/net/ludocrypt/limlib/mixin/ServerPlayerEntityMixin.java b/src/main/java/net/ludocrypt/limlib/mixin/ServerPlayerEntityMixin.java index 56c7ead..e1ec058 100644 --- a/src/main/java/net/ludocrypt/limlib/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/net/ludocrypt/limlib/mixin/ServerPlayerEntityMixin.java @@ -12,13 +12,14 @@ import com.mojang.authlib.GameProfile; -import net.ludocrypt.limlib.api.sound.TravelSoundPacket; import net.ludocrypt.limlib.impl.sound.LiminalTravelSounds; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket; import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; +import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -37,7 +38,7 @@ public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile public void limlib$moveToWorld(ServerWorld to, CallbackInfoReturnable ci) { Optional optional = LiminalTravelSounds.getCurrent(((ServerPlayerEntity) (Object) this).getWorld(), to); if (optional.isPresent()) { - this.networkHandler.sendPacket(new TravelSoundPacket(optional.get())); + this.networkHandler.sendPacket(new PlaySoundS2CPacket(optional.get(), SoundCategory.AMBIENT, this.getX(), this.getY(), this.getZ(), world.getRandom().nextFloat() * 0.4F + 0.8F, 0.25F)); } } diff --git a/src/main/resources/limlib.mixins.json b/src/main/resources/limlib.mixins.json index 8fe90ca..f67516b 100644 --- a/src/main/resources/limlib.mixins.json +++ b/src/main/resources/limlib.mixins.json @@ -11,7 +11,6 @@ "ServerPlayerEntityMixin" ], "client": [ - "ClientPlayNetworkHandlerMixin", "DimensionEffectsMixin", "SoundManagerAccessor", "SoundSystemAccessor",