Search in sources :

Example 1 with EntityAgeable

use of net.minecraft.entity.EntityAgeable in project PneumaticCraft by MineMaarten.

the class ProgWidgetEntityRightClick method getWidgetAI.

@Override
public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) {
    return new DroneEntityBase<IProgWidget, EntityLivingBase>(drone, widget) {

        private final List<Entity> visitedEntities = new ArrayList<Entity>();

        @Override
        protected boolean isEntityValid(Entity entity) {
            return entity instanceof EntityLivingBase && !visitedEntities.contains(entity);
        }

        @Override
        protected boolean doAction() {
            visitedEntities.add(targetedEntity);
            boolean activated = false;
            ItemStack stack = drone.getInventory().getStackInSlot(0);
            if (stack != null && stack.getItem().itemInteractionForEntity(stack, drone.getFakePlayer(), targetedEntity)) {
                activated = true;
            }
            if (!activated && targetedEntity instanceof EntityAgeable && ((EntityAgeable) targetedEntity).interact(drone.getFakePlayer())) {
                activated = true;
            }
            DroneAIBlockInteract.transferToDroneFromFakePlayer(drone);
            //return activated; <-- will right click as long as it's sucessfully activated.
            return false;
        }
    };
}
Also used : Entity(net.minecraft.entity.Entity) DroneEntityBase(pneumaticCraft.common.ai.DroneEntityBase) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) EntityAgeable(net.minecraft.entity.EntityAgeable)

Example 2 with EntityAgeable

use of net.minecraft.entity.EntityAgeable in project MineFactoryReloaded by powercrystals.

the class ItemSyringeGrowth method inject.

@Override
public boolean inject(World world, EntityLiving entity, ItemStack syringe) {
    if (entity instanceof EntityAgeable) {
        ((EntityAgeable) entity).setGrowingAge(0);
    } else {
        EntityGiantZombie e = new EntityGiantZombie(world);
        e.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
        world.spawnEntityInWorld(e);
        entity.setDead();
    }
    return true;
}
Also used : EntityGiantZombie(net.minecraft.entity.monster.EntityGiantZombie) EntityAgeable(net.minecraft.entity.EntityAgeable)

Example 3 with EntityAgeable

use of net.minecraft.entity.EntityAgeable in project MineFactoryReloaded by powercrystals.

the class ItemSyringeZombie method inject.

@Override
public boolean inject(World world, EntityLiving entity, ItemStack syringe) {
    if (world.rand.nextInt(100) < 5) {
        Entity e;
        if (entity instanceof EntityPig) {
            e = new EntityPigZombie(world);
        } else {
            e = new EntityZombie(world);
        }
        e.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
        world.spawnEntityInWorld(e);
        entity.setDead();
    } else {
        ((EntityAgeable) entity).setGrowingAge(0);
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) EntityZombie(net.minecraft.entity.monster.EntityZombie) EntityPig(net.minecraft.entity.passive.EntityPig) EntityPigZombie(net.minecraft.entity.monster.EntityPigZombie) EntityAgeable(net.minecraft.entity.EntityAgeable)

Example 4 with EntityAgeable

use of net.minecraft.entity.EntityAgeable in project MineFactoryReloaded by powercrystals.

the class TileEntityChronotyper method activateMachine.

@Override
protected boolean activateMachine() {
    List<?> entities = worldObj.getEntitiesWithinAABB(EntityAgeable.class, _areaManager.getHarvestArea().toAxisAlignedBB());
    for (Object o : entities) {
        if (!(o instanceof EntityAgeable)) {
            continue;
        }
        EntityAgeable a = (EntityAgeable) o;
        if ((a.getGrowingAge() < 0 && !_moveOld) || (a.getGrowingAge() >= 0 && _moveOld)) {
            BlockPosition bp = BlockPosition.fromFactoryTile(this);
            bp.moveBackwards(1);
            a.setPosition(bp.x + 0.5, bp.y + 0.5, bp.z + 0.5);
            return true;
        }
    }
    setIdleTicks(getIdleTicksMax());
    return false;
}
Also used : BlockPosition(powercrystals.core.position.BlockPosition) EntityAgeable(net.minecraft.entity.EntityAgeable)

Example 5 with EntityAgeable

use of net.minecraft.entity.EntityAgeable in project NetherEx by LogicTechCorp.

the class EntityAIPigtificateMate method giveBirth.

private void giveBirth() {
    EntityAgeable baby = pigtificate.createChild(mate);
    mate.setGrowingAge(6000);
    pigtificate.setGrowingAge(6000);
    mate.setWillingToMate(false);
    pigtificate.setWillingToMate(false);
    final BabyEntitySpawnEvent event = new BabyEntitySpawnEvent(pigtificate, mate, baby);
    if (MinecraftForge.EVENT_BUS.post(event) || event.getChild() == null) {
        return;
    }
    baby = event.getChild();
    baby.setGrowingAge(-24000);
    baby.setLocationAndAngles(pigtificate.posX, pigtificate.posY, pigtificate.posZ, 0.0F, 0.0F);
    world.spawnEntity(baby);
    world.setEntityState(baby, (byte) 12);
}
Also used : BabyEntitySpawnEvent(net.minecraftforge.event.entity.living.BabyEntitySpawnEvent) EntityAgeable(net.minecraft.entity.EntityAgeable)

Aggregations

EntityAgeable (net.minecraft.entity.EntityAgeable)8 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityZombie (net.minecraft.entity.monster.EntityZombie)2 IBullet (blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Random (java.util.Random)1 EntityGiantZombie (net.minecraft.entity.monster.EntityGiantZombie)1 EntityPigZombie (net.minecraft.entity.monster.EntityPigZombie)1 EntityPig (net.minecraft.entity.passive.EntityPig)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 BabyEntitySpawnEvent (net.minecraftforge.event.entity.living.BabyEntitySpawnEvent)1 DroneEntityBase (pneumaticCraft.common.ai.DroneEntityBase)1 BlockPosition (powercrystals.core.position.BlockPosition)1