Search in sources :

Example 1 with SPacketSpawnGlobalEntity

use of net.minecraft.network.play.server.SPacketSpawnGlobalEntity in project Wurst-MC-1.12 by Wurst-Imperium.

the class PlayerFinderMod method onReceivedPacket.

@Override
public void onReceivedPacket(PacketInputEvent event) {
    if (WMinecraft.getPlayer() == null)
        return;
    Packet packet = event.getPacket();
    // get packet position
    BlockPos newPos = null;
    if (packet instanceof SPacketEffect) {
        SPacketEffect effect = (SPacketEffect) packet;
        newPos = effect.getSoundPos();
    } else if (packet instanceof SPacketSoundEffect) {
        SPacketSoundEffect sound = (SPacketSoundEffect) packet;
        newPos = new BlockPos(sound.getX(), sound.getY(), sound.getZ());
    } else if (packet instanceof SPacketSpawnGlobalEntity) {
        SPacketSpawnGlobalEntity lightning = (SPacketSpawnGlobalEntity) packet;
        newPos = new BlockPos(lightning.getX() / 32D, lightning.getY() / 32D, lightning.getZ() / 32D);
    }
    if (newPos == null)
        return;
    // check distance to player
    BlockPos playerPos = new BlockPos(WMinecraft.getPlayer());
    if (Math.abs(playerPos.getX() - newPos.getX()) > 250 || Math.abs(playerPos.getZ() - newPos.getZ()) > 250)
        pos = newPos;
}
Also used : SPacketEffect(net.minecraft.network.play.server.SPacketEffect) SPacketSoundEffect(net.minecraft.network.play.server.SPacketSoundEffect) Packet(net.minecraft.network.Packet) BlockPos(net.minecraft.util.math.BlockPos) SPacketSpawnGlobalEntity(net.minecraft.network.play.server.SPacketSpawnGlobalEntity)

Aggregations

Packet (net.minecraft.network.Packet)1 SPacketEffect (net.minecraft.network.play.server.SPacketEffect)1 SPacketSoundEffect (net.minecraft.network.play.server.SPacketSoundEffect)1 SPacketSpawnGlobalEntity (net.minecraft.network.play.server.SPacketSpawnGlobalEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1