package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import net.minecraft.network.play.server.S29PacketSoundEffect import net.minecraft.network.play.server.S2APacketParticles import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class MinecraftData { @SubscribeEvent(receiveCanceled = true) fun onSoundPacket(event: PacketEvent.ReceiveEvent) { if (!LorenzUtils.inSkyBlock) return val packet = event.packet if (packet !is S29PacketSoundEffect) return if (PlaySoundEvent( packet.soundName, LorenzVec(packet.x, packet.y, packet.z), packet.pitch, packet.volume ).postAndCatch() ) { event.isCanceled = true } } @SubscribeEvent(receiveCanceled = true) fun onParticlePacketReceive(event: PacketEvent.ReceiveEvent) { if (!LorenzUtils.inSkyBlock) return val packet = event.packet if (packet !is S2APacketParticles) return if (ReceiveParticleEvent( packet.particleType!!, LorenzVec(packet.xCoordinate, packet.yCoordinate, packet.zCoordinate), packet.particleCount, packet.particleSpeed, LorenzVec(packet.xOffset, packet.yOffset, packet.zOffset), packet.isLongDistance, packet.particleArgs, ).postAndCatch() ) { event.isCanceled = true } } }