/** * Sends a packet to the player to remove an entity. */ public void removeEntity(Entity entityIn) { if (entityIn instanceof EntityPlayer) { this.connection.sendPacket(new SPacketDestroyEntities(new int[] {entityIn.getEntityId()})); } else { this.entityRemoveQueue.add(Integer.valueOf(entityIn.getEntityId())); } }
/** * Locally eliminates the entities. Invoked by the server when the items are in fact destroyed, or the player is no * longer registered as required to monitor them. The latter happens when distance between the player and item * increases beyond a certain treshold (typically the viewing distance) */ public void handleDestroyEntities(SPacketDestroyEntities packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); for (int i = 0; i < packetIn.getEntityIDs().length; ++i) { this.clientWorldController.removeEntityFromWorld(packetIn.getEntityIDs()[i]); } }
/** * Called to update the entity's position/logic. */ public void onUpdate() { this.interactionManager.updateBlockRemoving(); --this.respawnInvulnerabilityTicks; if (this.hurtResistantTime > 0) { --this.hurtResistantTime; } this.openContainer.detectAndSendChanges(); if (!this.world.isRemote && !this.openContainer.canInteractWith(this)) { this.closeScreen(); this.openContainer = this.inventoryContainer; } while (!this.entityRemoveQueue.isEmpty()) { int i = Math.min(this.entityRemoveQueue.size(), Integer.MAX_VALUE); int[] aint = new int[i]; Iterator<Integer> iterator = this.entityRemoveQueue.iterator(); int j = 0; while (iterator.hasNext() && j < i) { aint[j++] = ((Integer)iterator.next()).intValue(); iterator.remove(); } this.connection.sendPacket(new SPacketDestroyEntities(aint)); } Entity entity = this.getSpectatingEntity(); if (entity != this) { if (entity.isEntityAlive()) { this.setPositionAndRotation(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); this.mcServer.getPlayerList().serverUpdateMovingPlayer(this); if (this.isSneaking()) { this.setSpectatingEntity(this); } } else { this.setSpectatingEntity(this); } } }
/** * Called to update the entity's position/logic. */ public void onUpdate() { this.interactionManager.updateBlockRemoving(); --this.respawnInvulnerabilityTicks; if (this.hurtResistantTime > 0) { --this.hurtResistantTime; } this.openContainer.detectAndSendChanges(); if (!this.worldObj.isRemote && this.openContainer != null && !this.openContainer.canInteractWith(this)) { this.closeScreen(); this.openContainer = this.inventoryContainer; } while (!this.entityRemoveQueue.isEmpty()) { int i = Math.min(this.entityRemoveQueue.size(), Integer.MAX_VALUE); int[] aint = new int[i]; Iterator<Integer> iterator = this.entityRemoveQueue.iterator(); int j = 0; while (iterator.hasNext() && j < i) { aint[j++] = ((Integer)iterator.next()).intValue(); iterator.remove(); } this.connection.sendPacket(new SPacketDestroyEntities(aint)); } Entity entity = this.getSpectatingEntity(); if (entity != this) { if (entity.isEntityAlive()) { this.setPositionAndRotation(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); this.mcServer.getPlayerList().serverUpdateMountedMovingPlayer(this); if (this.isSneaking()) { this.setSpectatingEntity(this); } } else { this.setSpectatingEntity(this); } } }
/** * Locally eliminates the entities. Invoked by the server when the items are in fact destroyed, or the player is no * longer registered as required to monitor them. The latter happens when distance between the player and item * increases beyond a certain treshold (typically the viewing distance) */ void handleDestroyEntities(SPacketDestroyEntities packetIn);