use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.
the class CoordTrackUpgradeHandler method getDronePath.
public static PathEntity getDronePath(EntityPlayer player, int x, int y, int z) {
World worldObj = player.worldObj;
EntityDrone drone = new EntityDrone(worldObj);
drone.setPosition(player.posX, player.posY - 2, player.posZ);
return new EntityPathNavigateDrone(drone, worldObj).getEntityPathToXYZ(drone, x, y, z, SEARCH_RANGE, true, true, false, true);
}
use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.
the class ModelDroneMinigun method render.
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
EntityDrone drone = (EntityDrone) entity;
renderMinigun(drone != null ? drone.getMinigun() : null, f5, 0, true);
}
use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.
the class DroneAIPlace method isValidPosition.
@Override
protected boolean isValidPosition(ChunkPosition pos) {
if (drone.getWorld().isAirBlock(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) {
boolean failedOnPlacement = false;
for (int i = 0; i < drone.getInventory().getSizeInventory(); i++) {
ItemStack droneStack = drone.getInventory().getStackInSlot(i);
if (droneStack != null && droneStack.getItem() instanceof ItemBlock) {
if (widget.isItemValidForFilters(droneStack)) {
if (((ItemBlock) droneStack.getItem()).field_150939_a.canPlaceBlockOnSide(drone.getWorld(), pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ, ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides()).ordinal())) {
if (drone instanceof EntityDrone) {
EntityDrone entity = (EntityDrone) drone;
//Teleport the drone to make sure it isn't in the way of placing a block.
entity.setPosition(entity.posX, entity.posY + 200, entity.posZ);
}
if (drone.getWorld().canPlaceEntityOnSide(((ItemBlock) droneStack.getItem()).field_150939_a, pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ, false, 0, null, droneStack)) {
if (drone instanceof EntityDrone) {
EntityDrone entity = (EntityDrone) drone;
entity.setPosition(entity.posX, entity.posY - 200, entity.posZ);
}
return true;
} else {
if (drone instanceof EntityDrone) {
EntityDrone entity = (EntityDrone) drone;
entity.setPosition(entity.posX, entity.posY - 200, entity.posZ);
}
drone.addDebugEntry("gui.progWidget.place.debug.entityInWay", pos);
failedOnPlacement = true;
}
} else {
failedOnPlacement = true;
drone.addDebugEntry("gui.progWidget.place.debug.cantPlaceBlock", pos);
}
}
}
}
if (!failedOnPlacement)
abort();
}
return false;
}
use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.
the class ContainerAmadron method retrieveOrderItems.
public static EntityDrone retrieveOrderItems(AmadronOffer offer, int times, World itemWorld, ChunkPosition itemPos, World liquidWorld, ChunkPosition liquidPos) {
if (offer.getInput() instanceof ItemStack) {
if (itemWorld == null || itemPos == null)
return null;
ItemStack queryingItems = (ItemStack) offer.getInput();
int amount = queryingItems.stackSize * times;
List<ItemStack> stacks = new ArrayList<ItemStack>();
while (amount > 0) {
ItemStack stack = queryingItems.copy();
stack.stackSize = Math.min(amount, stack.getMaxStackSize());
stacks.add(stack);
amount -= stack.stackSize;
}
return (EntityDrone) PneumaticRegistry.getInstance().retrieveItemsAmazonStyle(itemWorld, itemPos.chunkPosX, itemPos.chunkPosY, itemPos.chunkPosZ, stacks.toArray(new ItemStack[stacks.size()]));
} else {
if (liquidWorld == null || liquidPos == null)
return null;
FluidStack queryingFluid = ((FluidStack) offer.getInput()).copy();
queryingFluid.amount *= times;
return (EntityDrone) PneumaticRegistry.getInstance().retrieveFluidAmazonStyle(liquidWorld, liquidPos.chunkPosX, liquidPos.chunkPosY, liquidPos.chunkPosZ, queryingFluid);
}
}
use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.
the class DroneSpecialVariableHandler method onSpecialVariableRetrieving.
@SubscribeEvent
public void onSpecialVariableRetrieving(SpecialVariableRetrievalEvent.CoordinateVariable.Drone event) {
if (event.specialVarName.equalsIgnoreCase("owner")) {
EntityDrone drone = (EntityDrone) event.drone;
EntityPlayer player = drone.getOwner();
if (player != null)
event.coordinate = getPosForEntity(player);
} else if (event.specialVarName.equalsIgnoreCase("drone")) {
event.coordinate = getPosForEntity(event.drone);
} else if (event.specialVarName.toLowerCase().startsWith("player=")) {
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(event.specialVarName.substring("player=".length()));
if (player != null)
event.coordinate = getPosForEntity(player);
}
}
Aggregations