Search in sources :

Example 21 with EntityDrone

use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.

the class ContainerAmadron method handleGUIButtonPress.

@Override
public void handleGUIButtonPress(int guiID, EntityPlayer player) {
    super.handleGUIButtonPress(guiID, player);
    if (guiID == 1) {
        for (int i = 0; i < shoppingItems.length; i++) {
            if (shoppingItems[i] >= 0) {
                AmadronOffer offer = offers.get(shoppingItems[i]);
                ChunkPosition itemPos = ItemAmadronTablet.getItemProvidingLocation(player.getCurrentEquippedItem());
                World itemWorld = null;
                if (itemPos == null) {
                    itemPos = new ChunkPosition((int) player.posX, (int) player.posY, (int) player.posZ);
                    itemWorld = player.worldObj;
                } else {
                    itemWorld = PneumaticCraftUtils.getWorldForDimension(ItemAmadronTablet.getItemProvidingDimension(player.getCurrentEquippedItem()));
                }
                ChunkPosition liquidPos = ItemAmadronTablet.getLiquidProvidingLocation(player.getCurrentEquippedItem());
                World liquidWorld = null;
                if (liquidPos != null) {
                    liquidWorld = PneumaticCraftUtils.getWorldForDimension(ItemAmadronTablet.getLiquidProvidingDimension(player.getCurrentEquippedItem()));
                }
                EntityDrone drone = retrieveOrderItems(offer, shoppingAmounts[i], itemWorld, itemPos, liquidWorld, liquidPos);
                if (drone != null)
                    drone.setHandlingOffer(offer, shoppingAmounts[i], player.getCurrentEquippedItem(), player.getCommandSenderName());
            }
        }
        Arrays.fill(shoppingAmounts, 0);
        Arrays.fill(shoppingItems, -1);
    } else if (guiID == 2) {
        player.openGui(PneumaticCraft.instance, CommonProxy.EnumGuiId.AMADRON_ADD_TRADE.ordinal(), player.worldObj, 0, 0, 0);
    }
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ChunkPosition(net.minecraft.world.ChunkPosition) AmadronOffer(pneumaticCraft.common.recipes.AmadronOffer) World(net.minecraft.world.World)

Example 22 with EntityDrone

use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.

the class ItemDrone method onItemUse.

@Override
public boolean onItemUse(ItemStack iStack, EntityPlayer player, World world, int x, int y, int z, int side, float vecX, float vecY, float vecZ) {
    if (!world.isRemote) {
        EntityDrone drone = new EntityDrone(world, player);
        ForgeDirection dir = ForgeDirection.getOrientation(side);
        drone.setPosition(x + 0.5 + dir.offsetX, y + 0.5 + dir.offsetY, z + 0.5 + dir.offsetZ);
        world.spawnEntityInWorld(drone);
        NBTTagCompound stackTag = iStack.getTagCompound();
        NBTTagCompound entityTag = new NBTTagCompound();
        drone.writeEntityToNBT(entityTag);
        if (stackTag != null) {
            entityTag.setTag("widgets", stackTag.getTagList("widgets", 10).copy());
            entityTag.setFloat("currentAir", stackTag.getFloat("currentAir"));
            entityTag.setInteger("color", stackTag.getInteger("color"));
            NBTTagCompound invTag = stackTag.getCompoundTag("UpgradeInventory");
            if (invTag != null)
                entityTag.setTag("Inventory", invTag.copy());
        }
        drone.readEntityFromNBT(entityTag);
        if (iStack.hasDisplayName())
            drone.setCustomNameTag(iStack.getDisplayName());
        drone.naturallySpawned = false;
        drone.onSpawnWithEgg(null);
        iStack.stackSize--;
    }
    return true;
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 23 with EntityDrone

use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.

the class ItemLogisticsDrone method onItemUse.

@Override
public boolean onItemUse(ItemStack iStack, EntityPlayer player, World world, int x, int y, int z, int side, float vecX, float vecY, float vecZ) {
    if (!world.isRemote) {
        EntityDrone drone = new EntityLogisticsDrone(world, player);
        ForgeDirection dir = ForgeDirection.getOrientation(side);
        drone.setPosition(x + 0.5 + dir.offsetX, y + 0.5 + dir.offsetY, z + 0.5 + dir.offsetZ);
        world.spawnEntityInWorld(drone);
        NBTTagCompound stackTag = iStack.getTagCompound();
        NBTTagCompound entityTag = new NBTTagCompound();
        drone.writeEntityToNBT(entityTag);
        if (stackTag != null) {
            entityTag.setFloat("currentAir", stackTag.getFloat("currentAir"));
            entityTag.setInteger("color", stackTag.getInteger("color"));
            NBTTagCompound invTag = stackTag.getCompoundTag("UpgradeInventory");
            if (invTag != null)
                entityTag.setTag("Inventory", invTag.copy());
        }
        drone.readEntityFromNBT(entityTag);
        addLogisticsProgram(x, y, z, drone.progWidgets);
        if (iStack.hasDisplayName())
            drone.setCustomNameTag(iStack.getDisplayName());
        drone.naturallySpawned = false;
        drone.onSpawnWithEgg(null);
        iStack.stackSize--;
    }
    return true;
}
Also used : EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) EntityLogisticsDrone(pneumaticCraft.common.entity.living.EntityLogisticsDrone) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 24 with EntityDrone

use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.

the class PacketSyncDroneEntityProgWidgets method handleClientSide.

@Override
public void handleClientSide(PacketSyncDroneEntityProgWidgets message, EntityPlayer player) {
    Entity entity = player.worldObj.getEntityByID(message.entityId);
    if (entity instanceof EntityDrone) {
        EntityDrone drone = (EntityDrone) entity;
        List<IProgWidget> widgets = drone.getProgWidgets();
        widgets.clear();
        widgets.addAll(message.progWidgets);
    }
}
Also used : Entity(net.minecraft.entity.Entity) IProgWidget(pneumaticCraft.common.progwidgets.IProgWidget) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone)

Example 25 with EntityDrone

use of pneumaticCraft.common.entity.living.EntityDrone in project PneumaticCraft by MineMaarten.

the class ProgrammedDroneUtils method deliverItemsAmazonStyle.

public static EntityCreature deliverItemsAmazonStyle(World world, int x, int y, int z, 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 == null)
            throw new IllegalArgumentException("You can't supply a null stack to be delivered!");
        if (stack.getItem() == null)
            throw new IllegalArgumentException("You can't supply a stack with a null item to be delivered!");
    }
    EntityDrone drone = getChargedDispenserUpgradeDrone(world);
    //Program the drone
    int startY = world.getHeightValue(x + 30, z) + 30;
    drone.setPosition(x + 30, startY, z);
    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);
    ProgWidgetArea area = new ProgWidgetArea();
    area.setX(107);
    area.setY(52);
    area.x1 = x;
    area.y1 = y;
    area.z1 = z;
    widgets.add(area);
    area = new ProgWidgetArea();
    area.setX(107);
    area.setY(74);
    area.x1 = x;
    area.z1 = z;
    if (drone.isBlockValidPathfindBlock(x, y, z)) {
        for (int i = 0; i < 5 && drone.isBlockValidPathfindBlock(area.x1, i + y + 1, area.z1); i++) {
            area.y1 = y + i;
        }
    } else {
        area.y1 = world.getHeightValue(x, z) + 10;
        //Worst case scenario, there are definately no blocks here.
        if (!drone.isBlockValidPathfindBlock(area.x1, area.y1, area.z1))
            area.y1 = 260;
    }
    widgets.add(area);
    area = new ProgWidgetArea();
    area.setX(107);
    area.setY(96);
    area.x1 = x + 30;
    area.y1 = startY;
    area.z1 = z;
    widgets.add(area);
    TileEntityProgrammer.updatePuzzleConnections(widgets);
    for (int i = 0; i < deliveredStacks.length; i++) {
        drone.getInventory().setInventorySlotContents(i, deliveredStacks[i].copy());
    }
    world.spawnEntityInWorld(drone);
    return drone;
}
Also used : ProgWidgetDropItem(pneumaticCraft.common.progwidgets.ProgWidgetDropItem) IProgWidget(pneumaticCraft.common.progwidgets.IProgWidget) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ProgWidgetGoToLocation(pneumaticCraft.common.progwidgets.ProgWidgetGoToLocation) ProgWidgetArea(pneumaticCraft.common.progwidgets.ProgWidgetArea) ProgWidgetInventoryExport(pneumaticCraft.common.progwidgets.ProgWidgetInventoryExport) ProgWidgetSuicide(pneumaticCraft.common.progwidgets.ProgWidgetSuicide) ItemStack(net.minecraft.item.ItemStack) ProgWidgetStart(pneumaticCraft.common.progwidgets.ProgWidgetStart)

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