Search in sources :

Example 1 with EntityButterfly

use of forestry.lepidopterology.entities.EntityButterfly in project ForestryMC by ForestryMC.

the class ItemButterflyGE method onEntityItemUpdate.

@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
    if (type != EnumFlutterType.BUTTERFLY) {
        return false;
    }
    if (entityItem.world.isRemote || entityItem.ticksExisted < 80) {
        return false;
    }
    if (rand.nextInt(24) != 0) {
        return false;
    }
    IButterfly butterfly = ButterflyManager.butterflyRoot.getMember(entityItem.getItem());
    if (butterfly == null) {
        return false;
    }
    if (!butterfly.canTakeFlight(entityItem.world, entityItem.posX, entityItem.posY, entityItem.posZ)) {
        return false;
    }
    if (entityItem.world.countEntities(EntityButterfly.class) > ModuleLepidopterology.entityConstraint) {
        return false;
    }
    EntityUtil.spawnEntity(entityItem.world, new EntityButterfly(entityItem.world, butterfly, entityItem.getPosition()), entityItem.posX, entityItem.posY, entityItem.posZ);
    if (!entityItem.getItem().isEmpty()) {
        entityItem.getItem().shrink(1);
    } else {
        entityItem.setDead();
    }
    return true;
}
Also used : IButterfly(forestry.api.lepidopterology.IButterfly) EntityButterfly(forestry.lepidopterology.entities.EntityButterfly)

Aggregations

IButterfly (forestry.api.lepidopterology.IButterfly)1 EntityButterfly (forestry.lepidopterology.entities.EntityButterfly)1