Search in sources :

Example 1 with EntityDrone

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);
}
Also used : EntityPathNavigateDrone(pneumaticCraft.common.ai.EntityPathNavigateDrone) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) World(net.minecraft.world.World)

Example 2 with EntityDrone

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);
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone)

Example 3 with EntityDrone

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;
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 4 with EntityDrone

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);
    }
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) FluidStack(net.minecraftforge.fluids.FluidStack) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 5 with EntityDrone

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);
    }
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityDrone (pneumaticCraft.common.entity.living.EntityDrone)25 ItemStack (net.minecraft.item.ItemStack)10 IProgWidget (pneumaticCraft.common.progwidgets.IProgWidget)6 Entity (net.minecraft.entity.Entity)5 ProgWidgetStart (pneumaticCraft.common.progwidgets.ProgWidgetStart)5 World (net.minecraft.world.World)4 ProgWidgetArea (pneumaticCraft.common.progwidgets.ProgWidgetArea)4 ProgWidgetGoToLocation (pneumaticCraft.common.progwidgets.ProgWidgetGoToLocation)4 ProgWidgetSuicide (pneumaticCraft.common.progwidgets.ProgWidgetSuicide)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 ChunkPosition (net.minecraft.world.ChunkPosition)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 AmadronOffer (pneumaticCraft.common.recipes.AmadronOffer)3 ArrayList (java.util.ArrayList)2 ItemBlock (net.minecraft.item.ItemBlock)2 TileEntity (net.minecraft.tileentity.TileEntity)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 Block (net.minecraft.block.Block)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1