Search in sources :

Example 1 with DroneEntityBase

use of pneumaticCraft.common.ai.DroneEntityBase 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)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entity (net.minecraft.entity.Entity)1 EntityAgeable (net.minecraft.entity.EntityAgeable)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 ItemStack (net.minecraft.item.ItemStack)1 DroneEntityBase (pneumaticCraft.common.ai.DroneEntityBase)1