Java Code Examples for net.minecraft.entity.EntityLiving#isChild()

The following examples show how to use net.minecraft.entity.EntityLiving#isChild() . 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: ItemMobSpawner.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void loadSpawners(World world) {
    if (loaded) return;
    loaded = true;
    HashMap<Class<Entity>, String> classToStringMapping = (HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
    HashMap<Class<Entity>, Integer> classToIDMapping = (HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
    for (Class<Entity> eclass : classToStringMapping.keySet()) {
        if (!EntityLiving.class.isAssignableFrom(eclass))
            continue;
        try {
            EntityLiving entityliving = (EntityLiving) eclass.getConstructor(new Class[]{World.class}).newInstance(world);
            entityliving.isChild();

            int id = classToIDMapping.get(eclass);
            String name = classToStringMapping.get(eclass);

            if (name.equals("EnderDragon"))
                continue;

            IDtoNameMap.put(id, name);

            if (name.equals("Pig"))
                idPig = id;
        } catch (Throwable ignored) {
        }
    }

    for(Iterator<Entry<Integer, String>> it = IDtoNameMap.entrySet().iterator(); it.hasNext();) {
        Entry<Integer, String> e = it.next();
        if(getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig"))
            it.remove();
    }
}
 
Example 2
Source File: UpgradeKilling.java    From BetterChests with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void update(IUpgradableBlock chest, ItemStack stack) {
	if (UpgradeHelper.INSTANCE.getFrequencyTick(chest, stack, 100) != 0) {
		return;
	}

	AxisAlignedBB bb = new AxisAlignedBB(chest.getPosition()).grow(RADIUS);

	TObjectIntMap<Class<? extends EntityLiving>> map = new TObjectIntHashMap<>();

	for (EntityLiving entity : chest.getWorldObj().getEntitiesWithinAABB(EntityLiving.class, bb)) {
		if (entity.isDead) {
			continue;
		}

		if (entity instanceof EntityAnimal) {
			EntityAnimal animal = (EntityAnimal) entity;
			if (entity.isChild()) {
				continue;
			}
			int currentAnimals = map.get(animal.getClass());
			if (currentAnimals < ANIMALS_TO_KEEP_ALIVE) {
				map.put(animal.getClass(), currentAnimals + 1);
				continue;
			}
		}

		if (hasUpgradeOperationCost(chest)) {
			EntityPlayer source = null;
			if (chest.isUpgradeInstalled(DummyUpgradeType.AI.getStack())) {
				source = chest.getFakePlayer();
			}
			entity.attackEntityFrom(getDamageSource(source), 10);
			drawUpgradeOperationCode(chest);
		}
	}
}