public static void sendToClient(IMessage toSend, EntityPlayer player) { if (player == null) { System.out.println("null player"); return; } packetPipeline.sendTo(toSend, (EntityPlayerMP) player); }
@SubscribeEvent public void entityJoin(EntityJoinWorldEvent evt) { if (!evt.world.isRemote && evt.entity instanceof EntityPlayerMP) { packetPipeline.sendTo(new WorldDataPacket(evt.world.getSeed()), (EntityPlayerMP) evt.entity); } if (evt.entity instanceof EntityZombie) { if (((EntityZombie) evt.entity).isChild()) { ((EntityZombie) evt.entity).setChild(false); } } }
/** Send message to all within 64 blocks that have this chunk loaded */ public static void sendToNearby(World world, BlockPos pos, IMessage toSend) { if (world instanceof WorldServer) { WorldServer ws = (WorldServer) world; for (EntityPlayer player : ws.playerEntities) { EntityPlayerMP playerMP = (EntityPlayerMP) player; if (playerMP.getDistanceSq(pos) < 64 * 64 && ws.getPlayerChunkMap() .isPlayerWatchingChunk(playerMP, pos.getX() >> 4, pos.getZ() >> 4)) { HANDLER.sendTo(toSend, playerMP); } } } }
public static void sendTo(EntityPlayerMP playerMP, IMessage toSend) { HANDLER.sendTo(toSend, playerMP); }