Search in sources :

Example 11 with EntityDrone

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

the class ProgrammedDroneUtils method getChargedDispenserUpgradeDrone.

private static EntityDrone getChargedDispenserUpgradeDrone(World world) {
    EntityDrone drone = new EntityDrone(world);
    NBTTagCompound tag = new NBTTagCompound();
    drone.writeEntityToNBT(tag);
    NBTTagList upgradeList = new NBTTagList();
    NBTTagCompound slotEntry = new NBTTagCompound();
    slotEntry.setByte("Slot", (byte) 0);
    new ItemStack(Itemss.machineUpgrade, 64, ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE).writeToNBT(slotEntry);
    upgradeList.appendTag(slotEntry);
    slotEntry = new NBTTagCompound();
    slotEntry.setByte("Slot", (byte) 1);
    new ItemStack(Itemss.machineUpgrade, 10, ItemMachineUpgrade.UPGRADE_SPEED_DAMAGE).writeToNBT(slotEntry);
    upgradeList.appendTag(slotEntry);
    NBTTagCompound inv = new NBTTagCompound();
    inv.setTag("Items", upgradeList);
    tag.setTag("Inventory", inv);
    tag.setFloat("currentAir", 100000);
    drone.readEntityFromNBT(tag);
    drone.setCustomNameTag(StatCollector.translateToLocal("drone.amadronDeliveryDrone"));
    //Don't let the drone be dropped when wrenching it.
    drone.naturallySpawned = true;
    return drone;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 12 with EntityDrone

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

the class ProgrammedDroneUtils method retrieveItemsAmazonStyle.

public static EntityCreature retrieveItemsAmazonStyle(World world, int x, int y, int z, 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 == null)
            throw new IllegalArgumentException("You can't query a null stack!");
        if (stack.getItem() == null)
            throw new IllegalArgumentException("You can't query a stack with a null item!");
    }
    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);
    int yBase = 52;
    for (ItemStack stack : queriedStacks) {
        ProgWidgetInventoryImport im = new ProgWidgetInventoryImport();
        im.setX(92);
        im.setY(yBase);
        im.setCount(stack.stackSize);
        im.setUseCount(true);
        widgets.add(im);
        ProgWidgetArea area = new ProgWidgetArea();
        area.setX(107);
        area.setY(yBase);
        area.x1 = x;
        area.y1 = y;
        area.z1 = z;
        widgets.add(area);
        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);
    ProgWidgetArea area = new ProgWidgetArea();
    area.setX(107);
    area.setY(yBase);
    area.x1 = x + 30;
    area.y1 = startY;
    area.z1 = z;
    widgets.add(area);
    ProgWidgetSuicide suicide = new ProgWidgetSuicide();
    suicide.setX(92);
    suicide.setY(yBase + 11);
    widgets.add(suicide);
    TileEntityProgrammer.updatePuzzleConnections(widgets);
    world.spawnEntityInWorld(drone);
    return drone;
}
Also used : ProgWidgetInventoryImport(pneumaticCraft.common.progwidgets.ProgWidgetInventoryImport) IProgWidget(pneumaticCraft.common.progwidgets.IProgWidget) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ProgWidgetItemFilter(pneumaticCraft.common.progwidgets.ProgWidgetItemFilter) ProgWidgetGoToLocation(pneumaticCraft.common.progwidgets.ProgWidgetGoToLocation) ProgWidgetArea(pneumaticCraft.common.progwidgets.ProgWidgetArea) ProgWidgetSuicide(pneumaticCraft.common.progwidgets.ProgWidgetSuicide) ItemStack(net.minecraft.item.ItemStack) ProgWidgetStart(pneumaticCraft.common.progwidgets.ProgWidgetStart)

Example 13 with EntityDrone

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

the class ProgrammedDroneUtils method retrieveFluidAmazonStyle.

public static EntityCreature retrieveFluidAmazonStyle(World world, int x, int y, int z, 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.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);
    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 = x;
    area.y1 = y;
    area.z1 = z;
    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 = x + 30;
    area.y1 = startY;
    area.z1 = z;
    widgets.add(area);
    ProgWidgetSuicide suicide = new ProgWidgetSuicide();
    suicide.setX(92);
    suicide.setY(yBase + 11);
    widgets.add(suicide);
    TileEntityProgrammer.updatePuzzleConnections(widgets);
    world.spawnEntityInWorld(drone);
    return drone;
}
Also used : ProgWidgetLiquidImport(pneumaticCraft.common.progwidgets.ProgWidgetLiquidImport) IProgWidget(pneumaticCraft.common.progwidgets.IProgWidget) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ProgWidgetLiquidFilter(pneumaticCraft.common.progwidgets.ProgWidgetLiquidFilter) ProgWidgetGoToLocation(pneumaticCraft.common.progwidgets.ProgWidgetGoToLocation) ProgWidgetArea(pneumaticCraft.common.progwidgets.ProgWidgetArea) ProgWidgetSuicide(pneumaticCraft.common.progwidgets.ProgWidgetSuicide) ProgWidgetStart(pneumaticCraft.common.progwidgets.ProgWidgetStart)

Example 14 with EntityDrone

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

the class GuiDroneDebuggerOptions method initGui.

@Override
public void initGui(IGuiScreen gui) {
    GuiScreen guiScreen = (GuiScreen) gui;
    screenWidth = guiScreen.width;
    screenHeight = guiScreen.height;
    if (PneumaticCraft.proxy.getPlayer() != null) {
        ItemStack helmet = PneumaticCraft.proxy.getPlayer().getCurrentArmor(3);
        if (helmet != null) {
            int entityId = NBTUtil.getInteger(helmet, NBTKeys.PNEUMATIC_HELMET_DEBUGGING_DRONE);
            Entity entity = PneumaticCraft.proxy.getClientWorld().getEntityByID(entityId);
            if (entity instanceof EntityDrone) {
                selectedDrone = (EntityDrone) entity;
            }
        }
    }
    int spacing = 20;
    programmingStartX = spacing;
    programmingWidth = guiScreen.width - spacing * 2;
    programmingHeight = guiScreen.height - spacing - PROGRAMMING_START_Y;
    programmerUnit = new DebugInfoProgrammerUnit(selectedDrone != null ? selectedDrone.getProgWidgets() : new ArrayList<IProgWidget>(), gui.getFontRenderer(), 0, 0, guiScreen.width, guiScreen.height, 100, programmingStartX, PROGRAMMING_START_Y, programmingWidth, programmingHeight, 0, 0, 0);
    if (selectedDrone != null) {
        for (IProgWidget widget : selectedDrone.getProgWidgets()) {
            if (widget instanceof ProgWidgetStart) {
                programmerUnit.gotoPiece(widget);
                break;
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) IProgWidget(pneumaticCraft.common.progwidgets.IProgWidget) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) IGuiScreen(pneumaticCraft.api.client.pneumaticHelmet.IGuiScreen) GuiScreen(net.minecraft.client.gui.GuiScreen) ItemStack(net.minecraft.item.ItemStack) ProgWidgetStart(pneumaticCraft.common.progwidgets.ProgWidgetStart)

Example 15 with EntityDrone

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

the class RenderTarget method render.

public void render(float partialTicks, boolean justRenderWhenHovering) {
    for (IEntityTrackEntry tracker : trackEntries) {
        tracker.render(entity, partialTicks);
    }
    double x = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks;
    double y = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks + entity.height / 2D;
    double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks;
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    float red;
    float green;
    float blue;
    float alpha = 0.5F;
    if (entity instanceof EntityDrone) {
        red = 1;
        green = 1;
        blue = 0;
    } else if (entity instanceof EntityMob || entity instanceof EntitySlime) {
        red = 1;
        green = 0;
        blue = 0;
    } else {
        red = 0;
        green = 1;
        blue = 0;
    }
    float size = entity.height * 0.5F;
    if (ticksExisted < 60) {
        size += 5 - Math.abs(ticksExisted) * 0.083F;
        alpha = Math.abs(ticksExisted) * 0.005F;
    }
    GL11.glTranslated(x, y, z);
    GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(180.0F - RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
    GL11.glColor4d(red, green, blue, alpha);
    float renderSize = oldSize + (size - oldSize) * partialTicks;
    circle1.render(renderSize, partialTicks);
    circle2.render(renderSize + 0.2D, partialTicks);
    int targetAcquireProgress = (int) ((ticksExisted - 50) / 0.7F);
    if (ticksExisted <= 120 && ticksExisted > 50) {
        GL11.glColor4d(0, 1, 0, 0.8D);
        RenderProgressBar.render(0D, 0.4D, 1.8D, 0.9D, 0, targetAcquireProgress);
    }
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    FontRenderer fontRenderer = RenderManager.instance.getFontRenderer();
    GL11.glScaled(0.02D, 0.02D, 0.02D);
    GL11.glColor4d(red, green, blue, alpha);
    if (ticksExisted > 120) {
        if (justRenderWhenHovering && !isLookingAtTarget) {
            stat.closeWindow();
        } else {
            stat.openWindow();
        }
        textList = new ArrayList<String>();
        for (IEntityTrackEntry tracker : trackEntries) {
            tracker.addInfo(entity, textList);
        }
        stat.setText(textList);
        stat.render(-1, -1, partialTicks);
    } else if (ticksExisted > 50) {
        fontRenderer.drawString("Acquiring Target...", 0, 0, 0x7F7F7F);
        fontRenderer.drawString(targetAcquireProgress + "%", 37, 28, 0x002F00);
    } else if (ticksExisted < -30) {
        stat.closeWindow();
        //if(stat.getWidth() > stat.getMinWidth() || stat.getHeight() > stat.getMinHeight()) {
        //    stat.setText(new ArrayList<String>());
        stat.render(-1, -1, partialTicks);
        //            }
        fontRenderer.drawString("Lost Target!", 0, 0, 0xFF0000);
    }
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
    oldSize = size;
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) IEntityTrackEntry(pneumaticCraft.api.client.pneumaticHelmet.IEntityTrackEntry) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) EntitySlime(net.minecraft.entity.monster.EntitySlime) FontRenderer(net.minecraft.client.gui.FontRenderer)

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