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;
}
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;
}
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;
}
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;
}
}
}
}
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;
}
Aggregations