Java Code Examples for net.minecraft.world.World#getLoadedEntityList()

The following examples show how to use net.minecraft.world.World#getLoadedEntityList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContainerLifecycleCommands.java    From mobycraft with Apache License 2.0 6 votes vote down vote up
public void killChaosMonkeys() {
	World world = sender.getEntityWorld();
	int numberOfMonkeys = 0;
	for (Entity entity : world.getLoadedEntityList()) {
		if (entity instanceof EntityChaosMonkey) {
			entity.setDead();
			numberOfMonkeys++;
		}
	}

	if (numberOfMonkeys == 0) {
		sendErrorMessage("There are no Chaos Monkeys in this world!");
	} else if (numberOfMonkeys == 1) {
		sendConfirmMessage("Killed 1 Chaos Monkey.");
	} else {
		sendConfirmMessage("Killed " + numberOfMonkeys + " Chaos Monkeys.");
	}
}
 
Example 2
Source File: TileAIShutdown.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void removeTrackedEntities(World world, int x, int y, int z) {
    ChunkCoordinates cc = new ChunkCoordinates(x, y, z);
    if(trackedEntities.containsKey(cc)) {
        for (AffectedEntity ae : trackedEntities.get(cc)) {
            for (Object objE : world.getLoadedEntityList()) {
                if(objE != null && objE instanceof EntityLiving &&
                        !((EntityLiving) objE).isDead &&
                        ((EntityLiving) objE).getUniqueID().equals(ae.eUUID)) {
                    ((EntityLiving) objE).tasks.taskEntries = ae.tasks;
                    ((EntityLiving) objE).targetTasks.taskEntries = ae.targetTasks;
                    injEntityLivingBase.setObject(objE);
                    injEntityLivingBase.setField("ignoreCollisions", false);
                    injEntityLivingBase.setObject(null);
                }
            }
        }
        trackedEntities.remove(new ChunkCoordinates(x, y, z));
    }
}