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;
}
Aggregations