public void handleSetPassengers(SPacketSetPassengers packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); if (entity == null) { LOGGER.warn("Received passengers for unknown entity"); } else { boolean flag = entity.isRidingOrBeingRiddenBy(this.gameController.player); entity.removePassengers(); for (int i : packetIn.getPassengerIds()) { Entity entity1 = this.clientWorldController.getEntityByID(i); if (entity1 != null) { entity1.startRiding(entity, true); if (entity1 == this.gameController.player && !flag) { this.gameController.ingameGUI.setRecordPlaying(I18n.format("mount.onboard", new Object[] {GameSettings.getKeyDisplayString(this.gameController.gameSettings.keyBindSneak.getKeyCode())}), false); } } } } }
public void handleSetPassengers(SPacketSetPassengers packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); if (entity == null) { LOGGER.warn("Received passengers for unknown entity"); } else { boolean flag = entity.isRidingOrBeingRiddenBy(this.gameController.thePlayer); entity.removePassengers(); for (int i : packetIn.getPassengerIds()) { Entity entity1 = this.clientWorldController.getEntityByID(i); if (entity1 == null) { LOGGER.warn("Received unknown passenger for {}", new Object[] {entity}); } else { entity1.startRiding(entity, true); if (entity1 == this.gameController.thePlayer && !flag) { this.gameController.ingameGUI.setRecordPlaying(I18n.format("mount.onboard", new Object[] {this.gameController.gameSettings.keyBindSneak.getDisplayName()}), false); } } } } }
/** * This is the method that is responsible for actually sending the update to each client. * @param playerMP The Player. */ private void updateClient(EntityPlayerMP playerMP) { if (entity.isBeingRidden()) { playerMP.connection.sendPacket(new SPacketSetPassengers(entity)); } for (PassengerTeleporter passenger : passengers) { passenger.updateClients(); } }
/** * Send packets to player for every tracked entity in this chunk that is either leashed to something or someone, or * has passengers */ public void sendLeashedEntitiesInChunk(EntityPlayerMP player, Chunk chunkIn) { List<Entity> list = Lists.<Entity>newArrayList(); List<Entity> list1 = Lists.<Entity>newArrayList(); for (EntityTrackerEntry entitytrackerentry : this.trackedEntities) { Entity entity = entitytrackerentry.getTrackedEntity(); if (entity != player && entity.chunkCoordX == chunkIn.xPosition && entity.chunkCoordZ == chunkIn.zPosition) { entitytrackerentry.updatePlayerEntity(player); if (entity instanceof EntityLiving && ((EntityLiving)entity).getLeashedToEntity() != null) { list.add(entity); } if (!entity.getPassengers().isEmpty()) { list1.add(entity); } } } if (!list.isEmpty()) { for (Entity entity1 : list) { player.connection.sendPacket(new SPacketEntityAttach(entity1, ((EntityLiving)entity1).getLeashedToEntity())); } } if (!list1.isEmpty()) { for (Entity entity2 : list1) { player.connection.sendPacket(new SPacketSetPassengers(entity2)); } } }
void handleSetPassengers(SPacketSetPassengers packetIn);