public void handleEntityAttach(SPacketEntityAttach packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); Entity entity1 = this.clientWorldController.getEntityByID(packetIn.getVehicleEntityId()); if (entity instanceof EntityLiving) { if (entity1 != null) { ((EntityLiving)entity).setLeashedToEntity(entity1, false); } else { ((EntityLiving)entity).clearLeashed(false, false); } } }
/** * Removes the leash from this entity */ public void clearLeashed(boolean sendPacket, boolean dropLead) { if (this.isLeashed) { this.isLeashed = false; this.leashedToEntity = null; if (!this.world.isRemote && dropLead) { this.dropItem(Items.LEAD, 1); } if (!this.world.isRemote && sendPacket && this.world instanceof WorldServer) { ((WorldServer)this.world).getEntityTracker().sendToAllTrackingEntity(this, new SPacketEntityAttach(this, (Entity)null)); } } }
/** * Sets the entity to be leashed to. */ public void setLeashedToEntity(Entity entityIn, boolean sendAttachNotification) { this.isLeashed = true; this.leashedToEntity = entityIn; if (!this.world.isRemote && sendAttachNotification && this.world instanceof WorldServer) { ((WorldServer)this.world).getEntityTracker().sendToAllTrackingEntity(this, new SPacketEntityAttach(this, this.leashedToEntity)); } if (this.isRiding()) { this.dismountRidingEntity(); } }
/** * Removes the leash from this entity */ public void clearLeashed(boolean sendPacket, boolean dropLead) { if (this.isLeashed) { this.isLeashed = false; this.leashedToEntity = null; if (!this.worldObj.isRemote && dropLead) { this.dropItem(Items.LEAD, 1); } if (!this.worldObj.isRemote && sendPacket && this.worldObj instanceof WorldServer) { ((WorldServer)this.worldObj).getEntityTracker().sendToAllTrackingEntity(this, new SPacketEntityAttach(this, (Entity)null)); } } }
/** * Sets the entity to be leashed to. */ public void setLeashedToEntity(Entity entityIn, boolean sendAttachNotification) { this.isLeashed = true; this.leashedToEntity = entityIn; if (!this.worldObj.isRemote && sendAttachNotification && this.worldObj instanceof WorldServer) { ((WorldServer)this.worldObj).getEntityTracker().sendToAllTrackingEntity(this, new SPacketEntityAttach(this, this.leashedToEntity)); } if (this.isRiding()) { this.dismountRidingEntity(); } }
/** * 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 handleEntityAttach(SPacketEntityAttach packetIn);