Java Code Examples for net.minecraft.entity.Entity#getClass()

The following examples show how to use net.minecraft.entity.Entity#getClass() . 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: EntityHandler.java    From wailanbt with MIT License 6 votes vote down vote up
@Override
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
    Entity currentEntity = accessor.getEntity();
    Class currentEntityClass = currentEntity.getClass();
    if (EntityList.classToStringMapping.containsKey(currentEntityClass)) {
        NBTTagCompound n = accessor.getNBTData();
        //LogHelper.info(n.toString());
        EntityPlayer player = accessor.getPlayer();
        ItemStack holdItemReal = player.getHeldItem();
        String holdItemNameReal = "";
        if (holdItemReal != null) {
            holdItemNameReal = Item.itemRegistry.getNameForObject(holdItemReal.getItem());
        }
        NBTHandler.flag=1;
        NBTHandler.id= EntityList.getEntityString(currentEntity);
        //currenttip.add(NBTHandler.id);
        List<String> tips = NBTHandler.getTipsFromNBT(n, holdItemNameReal);
        currenttip.addAll(tips);
    }
    return currenttip;
}
 
Example 2
Source File: CustomSpawner.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public final int despawnMobWithMinimum(WorldServer worldObj, Class class1, int minimum)
{
    int killedcount = 0;
    int mobcount = countEntities(class1, worldObj);
    for (int j = 0; j < worldObj.loadedEntityList.size(); j++)
    {
        if ((mobcount - killedcount) <= minimum)
        {
            worldObj.updateEntities();
            return killedcount;
        }
        Entity entity = (Entity) worldObj.loadedEntityList.get(j);
        if (!(entity instanceof EntityLiving))
        {
            continue;
        }
        if (class1 == entity.getClass())
        {
            killedcount += entityDespawnCheck(worldObj, (EntityLiving) entity);
        }
    }
    worldObj.updateEntities();
    return killedcount;

}
 
Example 3
Source File: DataTrackerManager.java    From multiconnect with MIT License 5 votes vote down vote up
public static synchronized void startTrackingOldTrackedData(Entity entity) {
    for (Class<?> clazz = entity.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
        List<Pair<TrackedData<?>, ?>> trackedData = oldTrackedData.get(clazz);
        if (trackedData != null) {
            for (Pair<TrackedData<?>, ?> pair : trackedData) {
                doStartTracking(entity, pair.getLeft(), pair.getRight());
            }
        }
    }
}
 
Example 4
Source File: MoCEntityAnimal.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Used in getBoogey to specify what kind of entity to look for
 * 
 * @param entity
 * @return
 */
public boolean entitiesToInclude(Entity entity)
{
	return ( (entity.getClass() != this.getClass()) && (entity instanceof EntityLiving) && ((entity.width >= 0.5D) || (entity.height >= 0.5D))

	);
}
 
Example 5
Source File: CustomSpawner.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public final int despawnMob(WorldServer worldObj, List<Class> classList)
{
    int count = 0;
    if (classList == null)
    {
        classList = vanillaClassList;
    }

    for (int j = 0; j < worldObj.loadedEntityList.size(); j++)
    {
        Entity entity = (Entity) worldObj.loadedEntityList.get(j);
        if (!(entity instanceof EntityLiving))
        {
            continue;
        }
        for (Iterator iterator = classList.iterator(); iterator.hasNext();)
        {
            if (iterator != null)
            {
                Class class2 = (Class) iterator.next();
                if (class2 == entity.getClass())
                {
                    count += entityDespawnCheck(worldObj, (EntityLiving) entity);
                }
            }
        }

    }
    return count;
}
 
Example 6
Source File: DropCapture.java    From OpenModsLib with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onEntityConstruct(EntityJoinWorldEvent evt) {
	final Entity e = evt.getEntity();
	if (e != null
			&& e.getClass() == EntityItem.class
			&& !e.world.isRemote) {
		final EntityItem ei = (EntityItem)e;

		for (CaptureContext c : captures)
			if (c.check(ei)) break;
	}
}
 
Example 7
Source File: CauldronHooks.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public static byte canSushchestvoTick(Entity entity, World world)
{
    if (entity == null || world.sushchestvoConfig == null) { return 0; }
    if (!MinecraftServer.sushchestvoConfig.skipEntityTicks.getValue()) { return 1; }
    
    int cX = net.minecraft.util.MathHelper.floor_double( entity.posX ) >> 4, cZ = net.minecraft.util.MathHelper.floor_double( entity.posZ ) >> 4;
    int iX = net.minecraft.util.MathHelper.floor_double( entity.posX ), iZ = net.minecraft.util.MathHelper.floor_double( entity.posZ );
    	SushchestvoCache seCache = sushchestvoCache.get(entity.getClass());
        if (seCache == null)
        {
            String seConfigPath = entity.getClass().getName().replace(".", "-");
            seConfigPath = seConfigPath.replaceAll("[^A-Za-z0-9\\-]", ""); // Fix up odd class names to prevent YAML errors
            seCache = new SushchestvoCache(entity.getClass(), world.getWorldInfo().getWorldName().toLowerCase(), seConfigPath, world.sushchestvoConfig.getBoolean(seConfigPath + ".tick-no-players", false), world.sushchestvoConfig.getBoolean(seConfigPath + ".never-ever-tick", false), world.sushchestvoConfig.getInt(seConfigPath + ".tick-interval", 1));
            sushchestvoCache.put(entity.getClass(), seCache);
        }

        if(seCache.neverEverTick)
        {
        	return -1;
        }

        // Skip tick interval
        if (seCache.tickInterval > 0 && (world.getWorldInfo().getWorldTotalTime() % seCache.tickInterval == 0L))
        {
            return 0;
        }

        // Tick with no players near?
        if (seCache.tickNoPlayers)
        {
            return 1;
        }

    	if(world.chunkProvider instanceof ChunkProviderServer) // Thermos - allow the server to tick entities that are in chunks trying to unload
    	{
    		ChunkProviderServer cps = ((ChunkProviderServer)world.chunkProvider);
    		if(cps.chunksToUnload.contains(cX, cZ))
    		{
    			Chunk c = cps.getChunkIfLoaded(cX, cZ);
    			if(c != null)
    			{
    				if(c.lastAccessedTick < 2L)
    				{
    					return 1;
    				}
    			}
    		}
    	}
    	
        return -1;
}
 
Example 8
Source File: HackableCow.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canHack(Entity entity, EntityPlayer player){
    return entity.getClass() == EntityCow.class;
}
 
Example 9
Source File: HackableBat.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canHack(Entity entity, EntityPlayer player){
    return entity.getClass() == EntityBat.class;
}