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;
}
};
}
Aggregations