Search in sources :

Example 1 with PlaySoundS2CPacket

use of net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket in project Liminal-Library by LudoCrypt.

the class ServerPlayerEntityMixin method limlib$moveToWorld.

@Inject(method = "moveToWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;sendPacket(Lnet/minecraft/network/Packet;)V", ordinal = 5, shift = Shift.AFTER))
public void limlib$moveToWorld(ServerWorld to, CallbackInfoReturnable<Entity> ci) {
    Optional<SoundEvent> sound = LiminalSoundRegistry.getCurrent(moveToWorld$from, to);
    if (sound != null) {
        this.networkHandler.sendPacket(new PlaySoundS2CPacket(sound.get(), SoundCategory.AMBIENT, this.getX(), this.getY(), this.getZ(), 0.25F, world.getRandom().nextFloat() * 0.4F + 0.8F));
    }
    this.moveToWorld$from = null;
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) PlaySoundS2CPacket(net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

PlaySoundS2CPacket (net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket)1 SoundEvent (net.minecraft.sound.SoundEvent)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1