resurected minimum amount of blueprint for quarry frame

This commit is contained in:
SpaceToad 2014-02-11 22:46:50 +01:00
parent 3580d4b34a
commit ebbc8d2146
12 changed files with 99 additions and 80 deletions

View file

@ -57,7 +57,7 @@ public class BptBlock {
* buildBlock.
*/
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
if (slot.blockId != 0) {
if (slot.block != null) {
if (slot.storedRequirements.size() != 0) {
requirements.addAll(slot.storedRequirements);
} else {
@ -133,20 +133,20 @@ public class BptBlock {
*/
public void buildBlock(BptSlotInfo slot, IBptContext context) {
// Meta needs to be specified twice, depending on the block behavior
//context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,3);
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta, 0);
//context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta,3);
/*if (Block.blocksList[slot.blockId] instanceof BlockContainer) {
if (slot.block instanceof BlockContainer) {
TileEntity tile = context.world().getTileEntity(slot.x, slot.y, slot.z);
slot.cpt.setInteger("x", slot.x);
slot.cpt.setInteger("y", slot.y);
slot.cpt.setInteger("z", slot.z);
//slot.cpt.setInteger("x", slot.x);
//slot.cpt.setInteger("y", slot.y);
//slot.cpt.setInteger("z", slot.z);
if (tile != null) {
tile.readFromNBT(slot.cpt);
}
}*/
//if (tile != null) {
// tile.readFromNBT(slot.cpt);
//}
}
}
/**

View file

@ -22,7 +22,7 @@ import net.minecraft.nbt.NBTTagCompound;
@Deprecated
public class BptSlotInfo {
public int blockId = 0;
public Block block = null;
public int meta = 0;
public int x;
public int y;
@ -46,7 +46,7 @@ public class BptSlotInfo {
obj.x = x;
obj.y = y;
obj.z = z;
obj.blockId = blockId;
obj.block = block;
obj.meta = meta;
obj.cpt = (NBTTagCompound) cpt.copy();

View file

@ -13,15 +13,18 @@ import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
@Deprecated
public class BptBlockDelegate extends BptBlock {
final int delegateTo;
final Block delegateTo;
public BptBlockDelegate(int blockId, int delegateTo) {
public BptBlockDelegate(int blockId, Block delegateTo) {
super(blockId);
this.delegateTo = delegateTo;
@ -30,7 +33,7 @@ public class BptBlockDelegate extends BptBlock {
@Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
BptSlotInfo newSlot = slot.clone();
slot.blockId = delegateTo;
slot.block = delegateTo;
//if (BlueprintManager.blockBptProps[delegateTo] != null) {
// BlueprintManager.blockBptProps[delegateTo].addRequirements(newSlot, context, requirements);
@ -42,7 +45,7 @@ public class BptBlockDelegate extends BptBlock {
@Override
public boolean isValid(BptSlotInfo slot, IBptContext context) {
BptSlotInfo newSlot = slot.clone();
slot.blockId = delegateTo;
slot.block = delegateTo;
//if (BlueprintManager.blockBptProps[delegateTo] != null)
// return BlueprintManager.blockBptProps[delegateTo].isValid(newSlot, context);
@ -55,7 +58,7 @@ public class BptBlockDelegate extends BptBlock {
@Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
BptSlotInfo newSlot = slot.clone();
slot.blockId = delegateTo;
slot.block = delegateTo;
//if (BlueprintManager.blockBptProps[delegateTo] != null) {
// BlueprintManager.blockBptProps[delegateTo].rotateLeft(newSlot, context);

View file

@ -288,6 +288,7 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
} else {
setInventorySlotContents(3, BuildCraftBuilders.getBptItemStack(stack[2].getItem(), 0, null));
}
setInventorySlotContents(2, null);
}
}

View file

@ -198,35 +198,28 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
}
protected void build() {
updateWait();
if (targets.size() > 0) {
Action a = targets.getFirst();
if (a.slot != null) {
BptSlot target = a.slot;
//System.out.printf("RobotChanging %d %d %d %s\n",target.x, target.y, target.z, target.mode);
if (wait <= 0 && BlockUtil.canChangeBlock(worldObj, target.x, target.y, target.z)) {
if (!worldObj.isRemote) {
if (target.mode == Mode.ClearIfInvalid) {
if (!target.isValid(a.context)) {
worldObj.setBlockToAir(target.x, target.y, target.z);
}
} else if (target.stackToUse != null) {
worldObj.setBlockToAir(target.x, target.y, target.z);
throw new RuntimeException("NOT IMPLEMENTED");
// target.stackToUse.getItem().onItemUse(target.stackToUse,
// CoreProxy.getBuildCraftPlayer(worldObj), worldObj, target.x, target.y - 1,
// target.z, 1);
} else {
try {
target.buildBlock(a.context);
} catch (Throwable t) {
@ -239,7 +232,6 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
targets.pop();
}
} else if (a.builder != null) {
a.builder.postProcessing(worldObj);
targets.pop();
@ -280,10 +272,8 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
}
public void scheduleContruction(BptSlot slot, BptContext context) {
if (slot != null) {
targets.add(new Action(slot, context));
}
}

View file

@ -61,14 +61,14 @@ public abstract class BptBase {
}
public void setBlock(int x, int y, int z, Block block) {
/*if (contents[x][y][z] == null) {
if (contents[x][y][z] == null) {
contents[x][y][z] = new BptSlot();
contents[x][y][z].x = x;
contents[x][y][z].y = y;
contents[x][y][z].z = z;
}
contents[x][y][z].blockId = blockId;*/
contents[x][y][z].block = block;
}
public void rotateLeft(BptContext context) {
@ -195,7 +195,7 @@ public abstract class BptBase {
continue;
}
if (contents[x][y][z].blockId != bpt.contents[x][y][z].blockId)
if (contents[x][y][z].block != bpt.contents[x][y][z].block)
return false;
}
}

View file

@ -13,15 +13,18 @@ import buildcraft.core.IBuilderInventory;
import buildcraft.core.blueprints.BptSlot.Mode;
import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.BlockUtil;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.TreeMap;
import java.util.TreeSet;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType;
public class BptBuilderBlueprint extends BptBuilderBase {
@ -69,7 +72,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} else {
slot = new BptSlot();
slot.meta = 0;
slot.blockId = 0;
slot.block = null;
}
slot.x = xCoord;
@ -98,7 +101,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} else {
slot = new BptSlot();
slot.meta = 0;
slot.blockId = 0;
slot.block = null;
}
slot.x = xCoord;
@ -107,13 +110,13 @@ public class BptBuilderBlueprint extends BptBuilderBase {
slot.mode = Mode.Build;
/*if (slot.blockId != 0 && Block.blocksList[slot.blockId].isOpaqueCube()) {
if (slot.block != null && slot.block.isOpaqueCube()) {
primaryList.add(slot);
} else {
secondaryList.add(slot);
}*/
}
if (slot.blockId != 0) {
if (slot.block != null) {
postProcessingList.add(slot.clone());
}
}
@ -139,30 +142,33 @@ public class BptBuilderBlueprint extends BptBuilderBase {
BptSlot slot = internalGetNextBlock(world, inv, clearList);
checkDone();
if (slot != null)
if (slot != null) {
return slot;
else
} else {
return null;
}
}
if (primaryList.size() != 0) {
BptSlot slot = internalGetNextBlock(world, inv, primaryList);
checkDone();
if (slot != null)
if (slot != null) {
return slot;
else
} else {
return null;
}
}
if (secondaryList.size() != 0) {
BptSlot slot = internalGetNextBlock(world, inv, secondaryList);
checkDone();
if (slot != null)
if (slot != null) {
return slot;
else
} else {
return null;
}
}
checkDone();
@ -189,13 +195,13 @@ public class BptBuilderBlueprint extends BptBuilderBase {
getNext = false;
}
/*if (getNext)
if (getNext)
if (slot.mode == Mode.ClearIfInvalid) {
if (!BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)) {
result = slot;
break;
}
} else if (world.getWorldInfo().getGameType() == EnumGameType.CREATIVE) {
} else if (world.getWorldInfo().getGameType() == GameType.CREATIVE) {
// In creative, we don't use blocks given in the builder
result = slot;
@ -208,8 +214,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
break;
} else {
failSlots.add(slot);
}
*/
}
}
list.addAll(failSlots);
@ -218,8 +223,9 @@ public class BptBuilderBlueprint extends BptBuilderBase {
}
public boolean checkRequirements(IBuilderInventory inv, BptSlot slot) {
if (slot.blockId == 0)
if (slot.block == null) {
return true;
}
LinkedList<ItemStack> tmpReq = new LinkedList<ItemStack>();
LinkedList<ItemStack> tmpInv = new LinkedList<ItemStack>();
@ -277,8 +283,9 @@ public class BptBuilderBlueprint extends BptBuilderBase {
}
public void useRequirements(IBuilderInventory inv, BptSlot slot) {
if (slot.blockId == 0)
if (slot.block == null) {
return;
}
LinkedList<ItemStack> tmpReq = new LinkedList<ItemStack>();

View file

@ -32,10 +32,10 @@ public class BptBuilderTemplate extends BptBuilderBase {
BptSlot slot = bluePrint.contents[i][j][k];
if (slot == null || slot.blockId == 0) {
if (slot == null || slot.block == null) {
slot = new BptSlot();
slot.meta = 0;
slot.blockId = 0;
slot.block = null;
slot.x = xCoord;
slot.y = yCoord;
slot.z = zCoord;
@ -62,7 +62,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
} else {
slot = new BptSlot();
slot.meta = 0;
slot.blockId = 0;
slot.block = null;
}
slot.x = xCoord;
@ -71,7 +71,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
slot.mode = Mode.Build;
if (slot.blockId != 0) {
if (slot.block != null) {
buildList.add(slot);
}
}

View file

@ -3,7 +3,10 @@ package buildcraft.core.blueprints;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -17,8 +20,14 @@ public class BptSlot extends BptSlotInfo {
public ItemStack stackToUse;
public boolean isValid(IBptContext context) {
//return BlueprintManager.blockBptProps[blockId].isValid(this, context);
return false;
// the following line is just to resurect quarry building
if (block == null && context.world().getBlock(x, y, z) == Blocks.air) {
return true;
} else {
return block == context.world().getBlock(x, y, z);
}
//return BlueprintManager.blockBptProps[blockId].isValid(this, context);
}
public void rotateLeft(IBptContext context) {
@ -47,6 +56,10 @@ public class BptSlot extends BptSlotInfo {
}
public final void buildBlock(IBptContext context) {
// the following line is just to resurect quarry building
context.world().setBlock (x, y, z, block);
context.world().setBlockMetadataWithNotify(x, y, z, meta, 0);
//BlueprintManager.blockBptProps[blockId].buildBlock(this, context);
}
@ -64,7 +77,7 @@ public class BptSlot extends BptSlotInfo {
obj.x = x;
obj.y = y;
obj.z = z;
obj.blockId = blockId;
obj.block = block;
obj.meta = meta;
obj.cpt = (NBTTagCompound) cpt.copy();
obj.storedRequirements = (LinkedList<ItemStack>) storedRequirements.clone();

View file

@ -28,7 +28,7 @@ public class BptTemplate extends BptBase {
boolean first = true;
for (int x = 0; x < sizeX; ++x) {
/*for (int x = 0; x < sizeX; ++x) {
for (int y = 0; y < sizeY; ++y) {
for (int z = 0; z < sizeZ; ++z) {
if (first) {
@ -40,7 +40,7 @@ public class BptTemplate extends BptBase {
writer.write(contents[x][y][z].blockId + "");
}
}
}
}*/
}
@Override
@ -51,7 +51,7 @@ public class BptTemplate extends BptBase {
String[] mask = val.split(",");
int maskIndex = 0;
for (int x = 0; x < sizeX; ++x) {
/*for (int x = 0; x < sizeX; ++x) {
for (int y = 0; y < sizeY; ++y) {
for (int z = 0; z < sizeZ; ++z) {
contents[x][y][z] = new BptSlot();
@ -63,7 +63,7 @@ public class BptTemplate extends BptBase {
maskIndex++;
}
}
}
}*/
}
}

View file

@ -86,8 +86,8 @@ public class BlockTank extends BlockContainer {
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) {
System.out.println ("ACTIVATED");
ItemStack current = entityplayer.inventory.getCurrentItem();
if (current != null) {
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);

View file

@ -143,11 +143,14 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
super.updateEntity();
return;
}
if (!!worldObj.isRemote && isAlive) {
super.updateEntity();
return;
}
super.updateEntity();
if (inProcess) {
double energyToUse = 2 + powerHandler.getEnergyStored() / 500;
@ -161,23 +164,21 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
if (!worldObj.isRemote && inProcess) {
sendNetworkUpdate();
}
if (inProcess || !isDigging)
if (inProcess || !isDigging) {
return;
}
createUtilsIfNeeded();
if (bluePrintBuilder != null) {
builderDone = bluePrintBuilder.done;
if (!builderDone) {
buildFrame();
return;
} else {
if (builder != null && builder.done()) {
box.deleteLasers();
builder.setDead();
builder = null;
@ -188,7 +189,6 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
if (builder == null) {
dig();
}
}
@Override
@ -198,8 +198,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
protected void buildFrame() {
float mj = 25 * BuildCraftFactory.miningMultiplier;
powerHandler.configure(50 * BuildCraftFactory.miningMultiplier, 100 * BuildCraftFactory.miningMultiplier, mj, MAX_ENERGY * BuildCraftFactory.miningMultiplier);
if (powerHandler.useEnergy(mj, mj, true) != mj)
if (powerHandler.useEnergy(mj, mj, true) != mj) {
return;
}
if (builder == null) {
builder = new EntityRobot(worldObj, box);
@ -214,12 +216,13 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
protected void dig() {
powerHandler.configure(100 * BuildCraftFactory.miningMultiplier, 500 * BuildCraftFactory.miningMultiplier, BuildCraftFactory.MINING_MJ_COST_PER_BLOCK, MAX_ENERGY * BuildCraftFactory.miningMultiplier);
float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier;
if (powerHandler.useEnergy(mj, mj, true) != mj)
float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier;
if (powerHandler.useEnergy(mj, mj, true) != mj) {
return;
}
if (!findTarget(true)) {
// I believe the issue is box going null becuase of bad chunkloader positioning
if (arm != null && box != null) {
setTarget(box.xMin + 1, yCoord + 2, box.zMin + 1);
@ -238,8 +241,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
private final LinkedList<int[]> visitList = Lists.newLinkedList();
public boolean findTarget(boolean doSet) {
if (worldObj.isRemote)
if (worldObj.isRemote) {
return false;
}
boolean columnVisitListIsUpdated = false;
@ -251,8 +255,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
if (!doSet)
return !visitList.isEmpty();
if (visitList.isEmpty())
if (visitList.isEmpty()) {
return false;
}
int[] nextTarget = visitList.removeFirst();
@ -267,12 +272,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
}
}
}
if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty())
{
if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty()) {
nextTarget = visitList.removeFirst();
}
else if (columnVisitListIsUpdated && nextTarget == null)
{
} else if (columnVisitListIsUpdated && nextTarget == null) {
return false;
}
@ -289,6 +292,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
Integer[][] columnHeights = new Integer[bluePrintBuilder.bluePrint.sizeX - 2][bluePrintBuilder.bluePrint.sizeZ - 2];
boolean[][] blockedColumns = new boolean[bluePrintBuilder.bluePrint.sizeX - 2][bluePrintBuilder.bluePrint.sizeZ - 2];
for (int searchY = yCoord + 3; searchY >= 1 && searchY >= yCoord - BuildCraftFactory.miningDepth; --searchY) {
int startX, endX, incX;
@ -341,8 +345,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
}
// Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this
if (visitList.size() > bluePrintBuilder.bluePrint.sizeZ * bluePrintBuilder.bluePrint.sizeX * 2)
if (visitList.size() > bluePrintBuilder.bluePrint.sizeZ * bluePrintBuilder.bluePrint.sizeX * 2) {
return;
}
}
}
}