@Override public void setInventorySlotContents(int i, ItemStack itemstack) { items[i] = itemstack; if (i == 0) { iterateBpt(); done = false; } }
@Override public void setInventorySlotContents(int i, ItemStack itemstack) { inv.setInventorySlotContents(i, itemstack); if (!worldObj.isRemote) { if (i == 0) { iterateBpt(false); done = false; } } }
@Override public ItemStack decrStackSize(int i, int j) { ItemStack result = inv.decrStackSize(i, j); if (!worldObj.isRemote) { if (i == 0) { BuildCraftCore.instance.sendToWorld( new PacketCommand(this, "clearItemRequirements", null), worldObj); iterateBpt(false); } } return result; }
@Override public ItemStack decrStackSize(int i, int j) { ItemStack result; if (items[i] == null) { result = null; } else if (items[i].stackSize > j) { result = items[i].splitStack(j); } else { ItemStack tmp = items[i]; items[i] = null; result = tmp; } if (i == 0) { iterateBpt(); } return result; }
@Override public void doWork() { if (CoreProxy.proxy.isRenderWorld(worldObj)) { return; } if (done) { return; } if (builderRobot != null && !builderRobot.readyToBuild()) { return; } if (powerProvider.useEnergy(25, 25, true) < 25) { return; } iterateBpt(); if (bluePrintBuilder != null && !bluePrintBuilder.done) { if (!box.isInitialized()) { box.initialize(bluePrintBuilder); } if (builderRobot == null) { builderRobot = new EntityRobot(worldObj, box); worldObj.spawnEntityInWorld(builderRobot); } box.createLasers(worldObj, LaserKind.Stripes); builderRobot.scheduleContruction( bluePrintBuilder.getNextBlock( worldObj, new SurroundingInventory(worldObj, xCoord, yCoord, zCoord)), bluePrintBuilder.getContext()); } }
@Override public void initialize() { super.initialize(); if (CoreProxy.proxy.isRenderWorld(worldObj)) return; for (int x = xCoord - 1; x <= xCoord + 1; ++x) { for (int y = yCoord - 1; y <= yCoord + 1; ++y) { for (int z = zCoord - 1; z <= zCoord + 1; ++z) { TileEntity tile = worldObj.getBlockTileEntity(x, y, z); if (tile instanceof TilePathMarker) { path = ((TilePathMarker) tile).getPath(); for (BlockIndex b : path) { worldObj.setBlockWithNotify(b.i, b.j, b.k, 0); BuildCraftBuilders.pathMarkerBlock.dropBlockAsItem( worldObj, b.i, b.j, b.k, BuildCraftBuilders.pathMarkerBlock.blockID, 0); } break; } } } } if (path != null && pathLasers == null) { path.getFirst().i = xCoord; path.getFirst().j = yCoord; path.getFirst().k = zCoord; createLasersForPath(); } iterateBpt(); }
@Override public void updateEntity() { super.updateEntity(); if (worldObj.isRemote) { return; } if ((currentBuilder == null || currentBuilder.isDone(this)) && box.isInitialized()) { box.reset(); sendNetworkUpdate(); return; } iterateBpt(false); if (mode != Mode.Off) { if (getWorldObj().getWorldInfo().getGameType() == GameType.CREATIVE) { build(); } else if (getBattery().getEnergyStored() > POWER_ACTIVATION) { build(); } } if (!isBuilding && this.isBuildingBlueprint()) { updateRequirements(); } isBuilding = this.isBuildingBlueprint(); if (done) { return; } else if (getBattery().getEnergyStored() < 25) { return; } }
@Override public void initialize() { super.initialize(); if (worldObj.isRemote) { return; } if (initNBT != null) { iterateBpt(true); if (initNBT.hasKey("iterator")) { BlockIndex expectedTo = new BlockIndex(initNBT.getCompoundTag("iterator")); while (!done && currentBuilder != null && currentPathIterator != null) { BlockIndex bi = new BlockIndex( (int) currentPathIterator.ix, (int) currentPathIterator.iy, (int) currentPathIterator.iz); if (bi.equals(expectedTo)) { break; } iterateBpt(true); } } if (currentBuilder != null) { currentBuilder.loadBuildStateToNBT(initNBT.getCompoundTag("builderState"), this); } initNBT = null; } box.kind = Kind.STRIPES; for (int x = xCoord - 1; x <= xCoord + 1; ++x) { for (int y = yCoord - 1; y <= yCoord + 1; ++y) { for (int z = zCoord - 1; z <= zCoord + 1; ++z) { TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof TilePathMarker) { path = ((TilePathMarker) tile).getPath(); for (BlockIndex b : path) { worldObj.setBlockToAir(b.x, b.y, b.z); BuildCraftBuilders.pathMarkerBlock.dropBlockAsItem(worldObj, b.x, b.y, b.z, 0, 0); } break; } } } } if (path != null && pathLasers.size() == 0) { createLasersForPath(); sendNetworkUpdate(); } iterateBpt(false); }