Search in sources :

Example 1 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class ProgrammedDroneUtils method getChargedDispenserUpgradeDrone.

private static EntityDrone getChargedDispenserUpgradeDrone(World world) {
    EntityDrone drone = new EntityDrone(world, null);
    NBTTagCompound tag = new NBTTagCompound();
    drone.writeEntityToNBT(tag);
    ItemStackHandler upgrades = new ItemStackHandler(9);
    upgrades.setStackInSlot(0, new ItemStack(ItemRegistry.getInstance().getUpgrade(EnumUpgrade.DISPENSER), 64));
    upgrades.setStackInSlot(1, new ItemStack(ItemRegistry.getInstance().getUpgrade(EnumUpgrade.SPEED), 10));
    tag.setTag(ChargeableItemHandler.NBT_UPGRADE_TAG, upgrades.serializeNBT());
    tag.setTag("Inventory", new NBTTagCompound());
    tag.setFloat("currentAir", 100000);
    drone.readEntityFromNBT(tag);
    // FIXME: we really need to get a clientside localization here (on the server side)
    drone.setCustomNameTag(net.minecraft.util.text.translation.I18n.translateToLocal("drone.amadronDeliveryDrone"));
    // Don't let the drone be dropped when wrenching it.
    drone.naturallySpawned = true;
    return drone;
}
Also used : ItemStackHandler(net.minecraftforge.items.ItemStackHandler) EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 2 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class ProgrammedDroneUtils method retrieveFluidAmazonStyle.

public static EntityCreature retrieveFluidAmazonStyle(World world, BlockPos pos, FluidStack queriedFluid) {
    if (world.isRemote)
        return null;
    if (queriedFluid == null)
        throw new IllegalArgumentException("Can't query a null FluidStack");
    if (queriedFluid.amount <= 0)
        throw new IllegalArgumentException("Can't query a FluidStack with an amount of <= 0");
    EntityDrone drone = getChargedDispenserUpgradeDrone(world);
    // Program the drone
    int startY = world.getHeight(pos.add(30, 0, 0)).getY() + 30;
    drone.setPosition(pos.getX() + 30, startY, pos.getZ());
    List<IProgWidget> widgets = drone.progWidgets;
    ProgWidgetStart start = new ProgWidgetStart();
    start.setX(92);
    start.setY(41);
    widgets.add(start);
    int yBase = 52;
    ProgWidgetLiquidImport im = new ProgWidgetLiquidImport();
    im.setX(92);
    im.setY(yBase);
    im.setCount(queriedFluid.amount);
    im.setUseCount(true);
    widgets.add(im);
    ProgWidgetArea area = new ProgWidgetArea();
    area.setX(107);
    area.setY(yBase);
    area.x1 = pos.getX();
    area.y1 = pos.getY();
    area.z1 = pos.getZ();
    widgets.add(area);
    ProgWidgetLiquidFilter filter = new ProgWidgetLiquidFilter();
    filter.setX(107);
    filter.setY(yBase + 11);
    filter.setFluid(queriedFluid.getFluid());
    widgets.add(filter);
    yBase += 22;
    ProgWidgetGoToLocation gotoPiece = new ProgWidgetGoToLocation();
    gotoPiece.setX(92);
    gotoPiece.setY(yBase);
    widgets.add(gotoPiece);
    area = new ProgWidgetArea();
    area.setX(107);
    area.setY(yBase);
    area.x1 = pos.getX() + 30;
    area.y1 = startY;
    area.z1 = pos.getZ();
    widgets.add(area);
    ProgWidgetSuicide suicide = new ProgWidgetSuicide();
    suicide.setX(92);
    suicide.setY(yBase + 11);
    widgets.add(suicide);
    TileEntityProgrammer.updatePuzzleConnections(widgets);
    world.spawnEntity(drone);
    return drone;
}
Also used : EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone)

Example 3 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class ProgrammedDroneUtils method deliverFluidAmazonStyle.

public static EntityCreature deliverFluidAmazonStyle(World world, BlockPos pos, FluidStack deliveredFluid) {
    if (world.isRemote)
        return null;
    if (deliveredFluid == null)
        throw new IllegalArgumentException("Can't deliver a null FluidStack");
    if (deliveredFluid.amount <= 0)
        throw new IllegalArgumentException("Can't deliver a FluidStack with an amount of <= 0");
    EntityDrone drone = getChargedDispenserUpgradeDrone(world);
    // Program the drone
    int startY = world.getHeight(pos.add(30, 0, 0)).getY() + 30;
    drone.setPosition(pos.getX() + 30, startY, pos.getZ());
    List<IProgWidget> widgets = drone.progWidgets;
    ProgWidgetStart start = new ProgWidgetStart();
    start.setX(92);
    start.setY(41);
    widgets.add(start);
    ProgWidgetLiquidExport export = new ProgWidgetLiquidExport();
    export.setX(92);
    export.setY(52);
    widgets.add(export);
    ProgWidgetGoToLocation gotoPiece = new ProgWidgetGoToLocation();
    gotoPiece.setX(92);
    gotoPiece.setY(74);
    widgets.add(gotoPiece);
    ProgWidgetSuicide suicide = new ProgWidgetSuicide();
    suicide.setX(92);
    suicide.setY(85);
    widgets.add(suicide);
    // fluid export
    ProgWidgetArea area = new ProgWidgetArea();
    area.setX(107);
    area.setY(52);
    area.x1 = pos.getX();
    area.y1 = pos.getY();
    area.z1 = pos.getZ();
    widgets.add(area);
    // go to
    area = new ProgWidgetArea();
    area.setX(107);
    area.setY(74);
    area.x1 = pos.getX() + 30;
    area.y1 = startY;
    area.z1 = pos.getZ();
    widgets.add(area);
    TileEntityProgrammer.updatePuzzleConnections(widgets);
    drone.getTank().fill(deliveredFluid, true);
    world.spawnEntity(drone);
    return drone;
}
Also used : EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone)

Example 4 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class ProgrammedDroneUtils method retrieveItemsAmazonStyle.

public static EntityCreature retrieveItemsAmazonStyle(World world, BlockPos pos, ItemStack... queriedStacks) {
    if (world.isRemote)
        return null;
    if (queriedStacks.length == 0)
        throw new IllegalArgumentException("You need to query at least 1 stack!");
    if (queriedStacks.length > 65)
        throw new IllegalArgumentException("You can only query up to 65 stacks at once!");
    for (ItemStack stack : queriedStacks) {
        if (stack.isEmpty())
            throw new IllegalArgumentException("You can't query a null stack!");
    }
    EntityDrone drone = getChargedDispenserUpgradeDrone(world);
    int startY = world.getHeight(pos.add(30, 0, 0)).getY() + 30;
    drone.setPosition(pos.getX() + 30, startY, pos.getZ());
    List<IProgWidget> widgets = drone.progWidgets;
    // Program the drone
    ProgWidgetStart start = new ProgWidgetStart();
    start.setX(92);
    start.setY(41);
    widgets.add(start);
    int yBase = 52;
    for (ItemStack stack : queriedStacks) {
        ProgWidgetInventoryImport im = new ProgWidgetInventoryImport();
        im.setX(92);
        im.setY(yBase);
        im.setCount(stack.getCount());
        im.setUseCount(true);
        widgets.add(im);
        // inventory import
        ProgWidgetArea area = new ProgWidgetArea();
        area.setX(107);
        area.setY(yBase);
        area.x1 = pos.getX();
        area.y1 = pos.getY();
        area.z1 = pos.getZ();
        widgets.add(area);
        // filter for inventory import
        ProgWidgetItemFilter filter = new ProgWidgetItemFilter();
        filter.setX(107);
        filter.setY(yBase + 11);
        filter.setFilter(stack);
        filter.useMetadata = true;
        filter.useNBT = true;
        widgets.add(filter);
        yBase += 22;
    }
    ProgWidgetGoToLocation gotoPiece = new ProgWidgetGoToLocation();
    gotoPiece.setX(92);
    gotoPiece.setY(yBase);
    widgets.add(gotoPiece);
    // go to
    ProgWidgetArea area = new ProgWidgetArea();
    area.setX(107);
    area.setY(yBase);
    area.x1 = pos.getX() + 30;
    area.y1 = startY;
    area.z1 = pos.getZ();
    widgets.add(area);
    ProgWidgetSuicide suicide = new ProgWidgetSuicide();
    suicide.setX(92);
    suicide.setY(yBase + 11);
    widgets.add(suicide);
    TileEntityProgrammer.updatePuzzleConnections(widgets);
    world.spawnEntity(drone);
    return drone;
}
Also used : EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) ItemStack(net.minecraft.item.ItemStack)

Example 5 with EntityDrone

use of me.desht.pneumaticcraft.common.entity.living.EntityDrone in project pnc-repressurized by TeamPneumatic.

the class ProgrammedDroneUtils method deliverItemsAmazonStyle.

public static EntityCreature deliverItemsAmazonStyle(World world, BlockPos pos, ItemStack... deliveredStacks) {
    if (world.isRemote)
        return null;
    if (deliveredStacks.length == 0)
        throw new IllegalArgumentException("You need to deliver at least 1 stack!");
    if (deliveredStacks.length > 65)
        throw new IllegalArgumentException("You can only deliver up to 65 stacks at once!");
    for (ItemStack stack : deliveredStacks) {
        if (stack.isEmpty())
            throw new IllegalArgumentException("You can't supply a null stack to be delivered!");
    }
    EntityDrone drone = getChargedDispenserUpgradeDrone(world);
    // Program the drone
    int startY = world.getHeight(pos.add(30, 0, 0)).getY() + 30;
    drone.setPosition(pos.getX() + 30, startY, pos.getZ());
    List<IProgWidget> widgets = drone.progWidgets;
    ProgWidgetStart start = new ProgWidgetStart();
    start.setX(92);
    start.setY(41);
    widgets.add(start);
    ProgWidgetInventoryExport export = new ProgWidgetInventoryExport();
    export.setX(92);
    export.setY(52);
    widgets.add(export);
    ProgWidgetDropItem drop = new ProgWidgetDropItem();
    drop.setX(92);
    drop.setY(74);
    widgets.add(drop);
    ProgWidgetGoToLocation gotoPiece = new ProgWidgetGoToLocation();
    gotoPiece.setX(92);
    gotoPiece.setY(96);
    widgets.add(gotoPiece);
    ProgWidgetSuicide suicide = new ProgWidgetSuicide();
    suicide.setX(92);
    suicide.setY(107);
    widgets.add(suicide);
    // inventory export
    ProgWidgetArea area = new ProgWidgetArea();
    area.setX(107);
    area.setY(52);
    area.x1 = pos.getX();
    area.y1 = pos.getY();
    area.z1 = pos.getZ();
    widgets.add(area);
    // drop item
    area = new ProgWidgetArea();
    area.setX(107);
    area.setY(74);
    area.x1 = pos.getX();
    area.z1 = pos.getZ();
    if (drone.isBlockValidPathfindBlock(pos)) {
        for (int i = 0; i < 5 && drone.isBlockValidPathfindBlock(new BlockPos(area.x1, area.y1, area.z1)); i++) {
            area.y1 = pos.getY() + i;
        }
    } else {
        area.y1 = world.getHeight(pos).getY() + 10;
        if (!drone.isBlockValidPathfindBlock(new BlockPos(area.x1, area.y1, area.z1)))
            // Worst case scenario, there are definately no blocks here.
            area.y1 = 260;
    }
    widgets.add(area);
    // go to
    area = new ProgWidgetArea();
    area.setX(107);
    area.setY(96);
    area.x1 = pos.getX() + 30;
    area.y1 = startY;
    area.z1 = pos.getZ();
    widgets.add(area);
    TileEntityProgrammer.updatePuzzleConnections(widgets);
    for (int i = 0; i < deliveredStacks.length; i++) {
        drone.getInv().setStackInSlot(i, deliveredStacks[i].copy());
    }
    world.spawnEntity(drone);
    return drone;
}
Also used : EntityDrone(me.desht.pneumaticcraft.common.entity.living.EntityDrone) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityDrone (me.desht.pneumaticcraft.common.entity.living.EntityDrone)26 ItemStack (net.minecraft.item.ItemStack)10 Entity (net.minecraft.entity.Entity)6 BlockPos (net.minecraft.util.math.BlockPos)4 World (net.minecraft.world.World)4 AmadronOffer (me.desht.pneumaticcraft.common.recipes.AmadronOffer)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 IProgWidget (me.desht.pneumaticcraft.common.progwidgets.IProgWidget)2 Block (net.minecraft.block.Block)2 ItemBlock (net.minecraft.item.ItemBlock)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 ArrayList (java.util.ArrayList)1 IEntityTrackEntry (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IEntityTrackEntry)1 IGuiScreen (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IGuiScreen)1 AmadronRetrievalEvent (me.desht.pneumaticcraft.api.drone.AmadronRetrievalEvent)1 EntityPathNavigateDrone (me.desht.pneumaticcraft.common.ai.EntityPathNavigateDrone)1