worked on old bpt files, and fixed requirements computation
This commit is contained in:
parent
4ab0eaf290
commit
d52acfa732
24 changed files with 263 additions and 256 deletions
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -69,7 +70,7 @@ public class BptBlock {
|
|||
if (slot.storedRequirements.size() != 0) {
|
||||
requirements.addAll(slot.storedRequirements);
|
||||
} else {
|
||||
// requirements.add(new ItemStack(slot.blockId, 1, slot.meta));
|
||||
requirements.add(new ItemStack(slot.block, 1, slot.meta));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,8 +131,7 @@ public class BptBlock {
|
|||
* subprogram is permissive and doesn't take into account metadata.
|
||||
*/
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
//return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z) && slot.meta == context.world().getBlockMetadata(slot.x, slot.y, slot.z);
|
||||
return false;
|
||||
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z) && slot.meta == context.world().getBlockMetadata(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,7 +189,7 @@ public class BptBlock {
|
|||
* save / load the block.
|
||||
*/
|
||||
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) {
|
||||
/*if (Block.blocksList[slot.blockId] instanceof BlockContainer) {
|
||||
if (slot.block instanceof BlockContainer) {
|
||||
TileEntity tile = context.world().getTileEntity(x, y, z);
|
||||
|
||||
if (tile != null) {
|
||||
|
@ -197,13 +197,14 @@ public class BptBlock {
|
|||
}
|
||||
}
|
||||
|
||||
if (Block.blocksList[slot.blockId] != null) {
|
||||
ArrayList<ItemStack> req = Block.blocksList[slot.blockId].getBlockDropped(context.world(), x, y, z, context.world().getBlockMetadata(x, y, z), 0);
|
||||
if (slot.block != null) {
|
||||
ArrayList<ItemStack> req = slot.block.getDrops(context.world(), x,
|
||||
y, z, context.world().getBlockMetadata(x, y, z), 0);
|
||||
|
||||
if (req != null) {
|
||||
slot.storedRequirements.addAll(req);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,10 +53,11 @@ public class BptBlockBed extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
if ((slot.meta & 8) != 0)
|
||||
if ((slot.meta & 8) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1);
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1);
|
||||
|
||||
int x2 = slot.x;
|
||||
int z2 = slot.z;
|
||||
|
@ -76,7 +77,7 @@ public class BptBlockBed extends BptBlock {
|
|||
break;
|
||||
}
|
||||
|
||||
//context.world().setBlock(x2, slot.y, z2, slot.block, slot.meta + 8,1);
|
||||
context.world().setBlock(x2, slot.y, z2, slot.block, slot.meta + 8,1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.LinkedList;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
@ -19,6 +20,7 @@ import buildcraft.api.blueprints.IBptContext;
|
|||
public class BptBlockDelegate extends BptBlock {
|
||||
|
||||
final Block delegateTo;
|
||||
BptBlock delegated;
|
||||
|
||||
public BptBlockDelegate(Block block, Block delegateTo) {
|
||||
super(block);
|
||||
|
@ -31,11 +33,7 @@ public class BptBlockDelegate extends BptBlock {
|
|||
BptSlotInfo newSlot = slot.clone();
|
||||
slot.block = delegateTo;
|
||||
|
||||
//if (BlueprintManager.blockBptProps[delegateTo] != null) {
|
||||
// BlueprintManager.blockBptProps[delegateTo].addRequirements(newSlot, context, requirements);
|
||||
//} else {
|
||||
// super.addRequirements(newSlot, context, requirements);
|
||||
//}
|
||||
getDelegated ().addRequirements(newSlot, context, requirements);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,12 +41,7 @@ public class BptBlockDelegate extends BptBlock {
|
|||
BptSlotInfo newSlot = slot.clone();
|
||||
slot.block = delegateTo;
|
||||
|
||||
//if (BlueprintManager.blockBptProps[delegateTo] != null)
|
||||
// return BlueprintManager.blockBptProps[delegateTo].isValid(newSlot, context);
|
||||
//else
|
||||
// return super.isValid(newSlot, context);
|
||||
|
||||
return false;
|
||||
return getDelegated ().isValid(newSlot, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,11 +49,15 @@ public class BptBlockDelegate extends BptBlock {
|
|||
BptSlotInfo newSlot = slot.clone();
|
||||
slot.block = delegateTo;
|
||||
|
||||
//if (BlueprintManager.blockBptProps[delegateTo] != null) {
|
||||
// BlueprintManager.blockBptProps[delegateTo].rotateLeft(newSlot, context);
|
||||
//} else {
|
||||
// super.rotateLeft(newSlot, context);
|
||||
//}
|
||||
getDelegated().rotateLeft(newSlot, context);
|
||||
}
|
||||
|
||||
private BptBlock getDelegated () {
|
||||
if (delegated == null) {
|
||||
delegated = BlueprintManager.getBptBlock(delegateTo);
|
||||
}
|
||||
|
||||
return delegated;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ package buildcraft.api.bptblocks;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
|
@ -24,19 +25,18 @@ public class BptBlockDirt extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
//requirements.add(new ItemStack(Block.dirt));
|
||||
requirements.add(new ItemStack(Blocks.dirt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
//context.world().setBlock(slot.x, slot.y, slot.z, Block.dirt.blockID, slot.meta,1);
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, Blocks.dirt, slot.meta,1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
//int id = context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
Block block = context.world().getBlock(slot.x, slot.y, slot.z);
|
||||
|
||||
//return id == Block.dirt.blockID || id == Block.grass.blockID || id == Block.tilledField.blockID;
|
||||
return false;
|
||||
return block == Blocks.dirt || block == Blocks.grass || block == Blocks.farmland;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ public class BptBlockDoor extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
//context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1);
|
||||
//context.world().setBlock(slot.x, slot.y + 1, slot.z, slot.blockId, slot.meta + 8,1);
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1);
|
||||
context.world().setBlock(slot.x, slot.y + 1, slot.z, slot.block, slot.meta + 8,1);
|
||||
|
||||
context.world().setBlockMetadataWithNotify(slot.x, slot.y + 1, slot.z, slot.meta + 8,1);
|
||||
context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta,1);
|
||||
|
|
|
@ -35,10 +35,11 @@ public class BptBlockFluid extends BptBlock {
|
|||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
//if (slot.meta == 0)
|
||||
// return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z) && context.world().getBlockMetadata(slot.x, slot.y, slot.z) == 0;
|
||||
//else
|
||||
if (slot.meta == 0) {
|
||||
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z) && context.world().getBlockMetadata(slot.x, slot.y, slot.z) == 0;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,9 +54,9 @@ public class BptBlockFluid extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
//if (slot.meta == 0) {
|
||||
// context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, 0,1);
|
||||
//}
|
||||
if (slot.meta == 0) {
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, 0,1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class BptBlockIgnore extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
//requirements.add(new ItemStack(slot.blockId, 0, 0));
|
||||
requirements.add(new ItemStack(slot.block, 0, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,12 +24,11 @@ public class BptBlockIgnoreMeta extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
//requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
//return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
return false;
|
||||
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,12 @@ public class BptBlockPumpkin extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
//requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
//return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
return false;
|
||||
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,7 @@ package buildcraft.api.bptblocks;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
|
@ -24,7 +25,7 @@ public class BptBlockRedstoneRepeater extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
//requirements.add(new ItemStack(Item.redstoneRepeater));
|
||||
requirements.add(new ItemStack(Items.repeater));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,13 +43,12 @@ public class BptBlockRotateMeta extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
//requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
//return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
return false;
|
||||
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,9 @@ package buildcraft.api.bptblocks;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
@ -28,7 +30,7 @@ public class BptBlockSign extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
//requirements.add(new ItemStack(Item.sign));
|
||||
requirements.add(new ItemStack(Items.sign));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +43,7 @@ public class BptBlockSign extends BptBlock {
|
|||
}
|
||||
slot.meta = (int) (angle / 360.0 * 16.0);
|
||||
} else {
|
||||
// slot.meta = ForgeDirection.values()[slot.meta].rotateLeft().ordinal();
|
||||
slot.meta = ForgeDirection.values()[slot.meta].getRotation(ForgeDirection.UP).ordinal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,12 @@ public class BptBlockStairs extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
//requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
//return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
return false;
|
||||
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@ public class BptBlockWallSide extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
//requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,45 +8,51 @@
|
|||
*/
|
||||
package buildcraft.api.core;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class StackWrapper {
|
||||
/**
|
||||
* This class is used whenever stacks needs to be stored as keys.
|
||||
*/
|
||||
public class StackKey {
|
||||
|
||||
public final ItemStack stack;
|
||||
|
||||
public StackWrapper(ItemStack stack) {
|
||||
public StackKey(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
|
||||
|
||||
hash = 67 * hash + stack.getItem().hashCode();
|
||||
|
||||
hash = 67 * hash + stack.getItemDamage();
|
||||
|
||||
|
||||
if (stack.stackTagCompound != null) {
|
||||
hash = 67 * hash + stack.stackTagCompound.hashCode();
|
||||
}
|
||||
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null)
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
} else if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
final StackWrapper other = (StackWrapper) obj;
|
||||
if (stack.getItem() != other.stack.getItem())
|
||||
}
|
||||
|
||||
final StackKey other = (StackKey) obj;
|
||||
|
||||
if (stack.getItem() != other.stack.getItem()) {
|
||||
return false;
|
||||
if (stack.getHasSubtypes() && stack.getItemDamage() != other.stack.getItemDamage())
|
||||
} else if (stack.getHasSubtypes() && stack.getItemDamage() != other.stack.getItemDamage()) {
|
||||
return false;
|
||||
if (stack.stackTagCompound != null && !stack.stackTagCompound.equals(other.stack.stackTagCompound))
|
||||
} else if (stack.stackTagCompound != null && !stack.stackTagCompound.equals(other.stack.stackTagCompound)) {
|
||||
return false;
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
import buildcraft.api.core.StackWrapper;
|
||||
import buildcraft.api.core.StackKey;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -22,10 +22,10 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
public final class IronEngineCoolant {
|
||||
|
||||
public static Map<String, Coolant> liquidCoolants = new HashMap<String, Coolant>();
|
||||
public static Map<StackWrapper, FluidStack> solidCoolants = new HashMap<StackWrapper, FluidStack>();
|
||||
public static Map<StackKey, FluidStack> solidCoolants = new HashMap<StackKey, FluidStack>();
|
||||
|
||||
public static FluidStack getFluidCoolant(ItemStack stack) {
|
||||
return solidCoolants.get(new StackWrapper(stack));
|
||||
return solidCoolants.get(new StackKey(stack));
|
||||
}
|
||||
|
||||
public static Coolant getCoolant(ItemStack stack) {
|
||||
|
@ -65,7 +65,7 @@ public final class IronEngineCoolant {
|
|||
*/
|
||||
public static void addCoolant(final ItemStack stack, final FluidStack coolant) {
|
||||
if (stack != null && stack.getItem() != null && coolant != null) {
|
||||
solidCoolants.put(new StackWrapper(stack), coolant);
|
||||
solidCoolants.put(new StackKey(stack), coolant);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory,
|
|||
result = null;
|
||||
}
|
||||
|
||||
debugForceBlueprintCompletion(result, context);
|
||||
//debugForceBlueprintCompletion(result, context);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -636,4 +636,12 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory,
|
|||
slot.buildBlock(context);
|
||||
}
|
||||
}
|
||||
|
||||
public BptBuilderBase getBlueprint () {
|
||||
if (bluePrintBuilder != null) {
|
||||
return bluePrintBuilder;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,10 @@
|
|||
*/
|
||||
package buildcraft.builders.gui;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -76,23 +79,20 @@ public class GuiBuilder extends GuiAdvancedInterface {
|
|||
((ItemSlot) slots[s]).stack = null;
|
||||
}
|
||||
|
||||
/*Blueprint blueprint = builder.getBlueprint();
|
||||
if(blueprint != null){
|
||||
Collection<ItemStack> needs = blueprint.getCost();
|
||||
Collection<ItemStack> needs = builder.getNeededItems();
|
||||
|
||||
if (needs != null) {
|
||||
int s = 0;
|
||||
if (needs != null) {
|
||||
int s = 0;
|
||||
|
||||
for (ItemStack stack : needs) {
|
||||
if (s >= slots.length) {
|
||||
break;
|
||||
}
|
||||
|
||||
((ItemSlot) slots[s]).stack = stack.copy();
|
||||
s++;
|
||||
for (ItemStack stack : needs) {
|
||||
if (s >= slots.length) {
|
||||
break;
|
||||
}
|
||||
|
||||
((ItemSlot) slots[s]).stack = stack.copy();
|
||||
s++;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
drawBackgroundSlots();
|
||||
}
|
||||
|
|
|
@ -8,14 +8,17 @@
|
|||
*/
|
||||
package buildcraft.core.blueprints;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ListIterator;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings.GameType;
|
||||
import buildcraft.api.core.StackKey;
|
||||
import buildcraft.core.IBuilderInventory;
|
||||
import buildcraft.core.blueprints.BptSlot.Mode;
|
||||
import buildcraft.core.utils.BCLog;
|
||||
|
@ -29,26 +32,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
|
||||
LinkedList<BptSlot> postProcessingList = new LinkedList<BptSlot>();
|
||||
|
||||
public TreeSet<ItemStack> neededItems = new TreeSet<ItemStack>(new Comparator<ItemStack>() {
|
||||
|
||||
@Override
|
||||
public int compare(ItemStack o1, ItemStack o2) {
|
||||
if (o1.stackSize > o2.stackSize)
|
||||
return -1;
|
||||
else if (o1.stackSize < o2.stackSize)
|
||||
return 1;
|
||||
//else if (o1.itemID > o2.itemID)
|
||||
// return -1;
|
||||
//else if (o1.itemID < o2.itemID)
|
||||
// return 1;
|
||||
else if (o1.getItemDamage() > o2.getItemDamage())
|
||||
return -1;
|
||||
else if (o1.getItemDamage() < o2.getItemDamage())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
public LinkedList <ItemStack> neededItems = new LinkedList <ItemStack> ();
|
||||
|
||||
public BptBuilderBlueprint(Blueprint bluePrint, World world, int x, int y, int z) {
|
||||
super(bluePrint, world, x, y, z);
|
||||
|
@ -343,22 +327,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
public void recomputeNeededItems() {
|
||||
neededItems.clear();
|
||||
|
||||
/*TreeMap<ItemStack, Integer> computeStacks = new TreeMap<ItemStack, Integer>(new Comparator<ItemStack>() {
|
||||
|
||||
@Override
|
||||
public int compare(ItemStack o1, ItemStack o2) {
|
||||
if (o1.itemID > o2.itemID)
|
||||
return 1;
|
||||
else if (o1.itemID < o2.itemID)
|
||||
return -1;
|
||||
else if (o1.getItemDamage() > o2.getItemDamage())
|
||||
return 1;
|
||||
else if (o1.getItemDamage() < o2.getItemDamage())
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
});*/
|
||||
HashMap <StackKey, Integer> computeStacks = new HashMap <StackKey, Integer> ();
|
||||
|
||||
for (BptSlot slot : primaryList) {
|
||||
|
||||
|
@ -372,50 +341,70 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
BCLog.logger.throwing("BptBuilderBlueprint", "recomputeIfNeeded", t);
|
||||
}
|
||||
|
||||
/*for (ItemStack stack : stacks) {
|
||||
if (stack == null || stack.itemID == 0) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack == null || stack.getItem() == null || stack.stackSize == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!computeStacks.containsKey(stack)) {
|
||||
computeStacks.put(stack.copy(), stack.stackSize);
|
||||
StackKey key = new StackKey(stack);
|
||||
|
||||
if (!computeStacks.containsKey(key)) {
|
||||
computeStacks.put(key, stack.stackSize);
|
||||
} else {
|
||||
Integer num = computeStacks.get(stack);
|
||||
Integer num = computeStacks.get(key);
|
||||
num += stack.stackSize;
|
||||
|
||||
computeStacks.put(stack, num);
|
||||
computeStacks.put(key, num);
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
for (BptSlot slot : secondaryList) {
|
||||
LinkedList<ItemStack> stacks = slot.getRequirements(context);
|
||||
|
||||
/*for (ItemStack stack : stacks) {
|
||||
if (stack == null || stack.itemID <= 0 || stack.itemID >= Item.itemsList.length || stack.stackSize == 0 || stack.getItem() == null) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack == null || stack.getItem() == null || stack.stackSize == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!computeStacks.containsKey(stack)) {
|
||||
computeStacks.put(stack.copy(), stack.stackSize);
|
||||
StackKey key = new StackKey(stack);
|
||||
|
||||
if (!computeStacks.containsKey(key)) {
|
||||
computeStacks.put(key, stack.stackSize);
|
||||
} else {
|
||||
Integer num = computeStacks.get(stack);
|
||||
Integer num = computeStacks.get(key);
|
||||
num += stack.stackSize;
|
||||
|
||||
computeStacks.put(stack, num);
|
||||
computeStacks.put(key, num);
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/*for (ItemStack stack : computeStacks.keySet())
|
||||
if (stack.isItemStackDamageable()) {
|
||||
neededItems.add(new ItemStack(stack.getItem()));
|
||||
} else {
|
||||
neededItems.add(new ItemStack(stack.itemID, computeStacks.get(stack), stack.getItemDamage()));
|
||||
for (Entry<StackKey, Integer> e : computeStacks.entrySet()) {
|
||||
ItemStack newStack = e.getKey().stack.copy();
|
||||
newStack.stackSize = e.getValue();
|
||||
neededItems.add(newStack);
|
||||
}
|
||||
|
||||
Collections.sort (neededItems, new Comparator<ItemStack>() {
|
||||
@Override
|
||||
public int compare(ItemStack o1, ItemStack o2) {
|
||||
if (o1.stackSize > o2.stackSize) {
|
||||
return -1;
|
||||
} else if (o1.stackSize < o2.stackSize) {
|
||||
return 1;
|
||||
} else if (o1.getItemDamage() > o2.getItemDamage()) {
|
||||
return -1;
|
||||
} else if (o1.getItemDamage() < o2.getItemDamage()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,7 @@ public class BptBlockEngine extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
//context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1);
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1);
|
||||
|
||||
TileEngine engine = (TileEngine) context.world().getTileEntity(slot.x, slot.y, slot.z);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class BptBlockTank extends BptBlock {
|
|||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
//context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1);
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1076,8 +1076,9 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
|||
}
|
||||
|
||||
public static boolean placePipe(Pipe pipe, World world, int i, int j, int k, Block block, int meta) {
|
||||
if (world.isRemote)
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean placed = world.setBlock(i, j, k, block, meta, 3);
|
||||
|
||||
|
@ -1091,13 +1092,13 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
|||
}
|
||||
|
||||
public static Pipe getPipe(IBlockAccess blockAccess, int i, int j, int k) {
|
||||
|
||||
TileEntity tile = blockAccess.getTileEntity(i, j, k);
|
||||
|
||||
if (!(tile instanceof TileGenericPipe) || tile.isInvalid())
|
||||
if (!(tile instanceof TileGenericPipe) || tile.isInvalid()) {
|
||||
return null;
|
||||
|
||||
return ((TileGenericPipe) tile).pipe;
|
||||
} else {
|
||||
return ((TileGenericPipe) tile).pipe;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFullyDefined(Pipe pipe) {
|
||||
|
|
|
@ -252,8 +252,9 @@ public class PipeTransportItems extends PipeTransport {
|
|||
private void moveSolids() {
|
||||
items.flush();
|
||||
|
||||
if (!container.getWorldObj().isRemote)
|
||||
if (!container.getWorldObj().isRemote) {
|
||||
items.purgeCorruptedItems();
|
||||
}
|
||||
|
||||
items.iterating = true;
|
||||
for (TravelingItem item : items) {
|
||||
|
|
|
@ -11,6 +11,7 @@ package buildcraft.transport.blueprints;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
|
@ -28,113 +29,115 @@ public class BptBlockPipe extends BptBlock {
|
|||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
int pipeId = slot.cpt.getInteger("pipeId");
|
||||
|
||||
//requirements.add(new ItemStack(pipeId, 1, 0));
|
||||
requirements.add(new ItemStack((Item) Item.itemRegistry.getObjectById(pipeId)));
|
||||
|
||||
// if (slot.cpt.hasKey("wire0")) {
|
||||
// requirements.add(new ItemStack(BuildCraftTransport.pipeWire));
|
||||
// }
|
||||
//
|
||||
// if (slot.cpt.hasKey("wire1")) {
|
||||
// requirements.add(new ItemStack(BuildCraftTransport.bluePipeWire));
|
||||
// }
|
||||
//
|
||||
// if (slot.cpt.hasKey("wire2")) {
|
||||
// requirements.add(new ItemStack(BuildCraftTransport.greenPipeWire));
|
||||
// }
|
||||
//
|
||||
// if (slot.cpt.hasKey("wire3")) {
|
||||
// requirements.add(new ItemStack(BuildCraftTransport.yellowPipeWire));
|
||||
// }
|
||||
/*if (slot.cpt.hasKey("wire0")) {
|
||||
requirements.add(new ItemStack(BuildCraftTransport.pipeWire, 1, 0));
|
||||
}
|
||||
|
||||
// if (slot.cpt.hasKey("gate")) {
|
||||
// int gateId = slot.cpt.getInteger("gate");
|
||||
// if (slot.cpt.hasKey("hasPulser") && slot.cpt.getBoolean("hasPulser")) {
|
||||
// requirements.add(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, gateId - 1));
|
||||
// } else {
|
||||
// requirements.add(new ItemStack(BuildCraftTransport.pipeGate, 1, gateId - 1));
|
||||
// }
|
||||
// }
|
||||
if (slot.cpt.hasKey("wire1")) {
|
||||
requirements.add(new ItemStack(BuildCraftTransport.pipeWire, 1, 1));
|
||||
}
|
||||
|
||||
//if (BuildCraftCore.itemBptProps[pipeId] != null) {
|
||||
// BuildCraftCore.itemBptProps[pipeId].addRequirements(slot, requirements);
|
||||
//}
|
||||
if (slot.cpt.hasKey("wire2")) {
|
||||
requirements.add(new ItemStack(BuildCraftTransport.pipeWire, 1, 2));
|
||||
}
|
||||
|
||||
if (slot.cpt.hasKey("wire3")) {
|
||||
requirements.add(new ItemStack(BuildCraftTransport.pipeWire, 1, 3));
|
||||
}
|
||||
|
||||
if (slot.cpt.hasKey("gate")) {
|
||||
int gateId = slot.cpt.getInteger("gate");
|
||||
if (slot.cpt.hasKey("hasPulser") && slot.cpt.getBoolean("hasPulser")) {
|
||||
requirements.add(new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, gateId - 1));
|
||||
} else {
|
||||
requirements.add(new ItemStack(BuildCraftTransport.pipeGate, 1, gateId - 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (BuildCraftCore.itemBptProps[pipeId] != null) {
|
||||
BuildCraftCore.itemBptProps[pipeId].addRequirements(slot, requirements);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
Pipe pipe = BlockGenericPipe.getPipe(context.world(), slot.x, slot.y, slot.z);
|
||||
|
||||
//if (BlockGenericPipe.isValid(pipe))
|
||||
// return pipe.itemID == slot.cpt.getInteger("pipeId");
|
||||
//else
|
||||
// return false;
|
||||
|
||||
return false;
|
||||
if (BlockGenericPipe.isValid(pipe)) {
|
||||
return pipe.item == Item.itemRegistry.getObjectById(slot.cpt
|
||||
.getInteger("pipeId"));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int pipeId = slot.cpt.getInteger("pipeId");
|
||||
|
||||
//if (BuildCraftCore.itemBptProps[pipeId] != null) {
|
||||
// BuildCraftCore.itemBptProps[pipeId].rotateLeft(slot, context);
|
||||
//}
|
||||
/*if (BuildCraftCore.itemBptProps[pipeId] != null) {
|
||||
BuildCraftCore.itemBptProps[pipeId].rotateLeft(slot, context);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
int pipeId = slot.cpt.getInteger("pipeId");
|
||||
|
||||
//Pipe pipe = BlockGenericPipe.createPipe(pipeId);
|
||||
Pipe pipe = BlockGenericPipe.createPipe((Item) Item.itemRegistry
|
||||
.getObjectById(pipeId));
|
||||
|
||||
//for (int i = 0; i < pipe.wireSet.length; ++i)
|
||||
// if (slot.cpt.hasKey("wire" + i)) {
|
||||
// pipe.wireSet[i] = true;
|
||||
// }
|
||||
for (int i = 0; i < pipe.wireSet.length; ++i) {
|
||||
if (slot.cpt.hasKey("wire" + i)) {
|
||||
pipe.wireSet[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// if (slot.cpt.hasKey("gate")) {
|
||||
// // / TODO: Does not save/load custom gates
|
||||
// int gateId = slot.cpt.getInteger("gate");
|
||||
// GateVanilla newGate;
|
||||
// if (slot.cpt.hasKey("hasPulser") && slot.cpt.getBoolean("hasPulser")) {
|
||||
// newGate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, gateId - 1));
|
||||
// } else {
|
||||
// newGate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGate, 1, gateId - 1));
|
||||
// }
|
||||
// pipe.gate = newGate;
|
||||
//
|
||||
// for (int i = 0; i < 8; ++i) {
|
||||
// if (slot.cpt.hasKey("trigger" + i)) {
|
||||
//// pipe.gate.actions[i] = ActionManager.triggers[slot.cpt.getInteger("trigger" + i)];
|
||||
// }
|
||||
//
|
||||
// if (slot.cpt.hasKey("triggerParameter" + i)) {
|
||||
// ItemStack s = ItemStack.loadItemStackFromNBT((NBTTagCompound) slot.cpt.getTag("triggerParameter" + i));
|
||||
//
|
||||
// if (s != null) {
|
||||
//// pipe.triggerParameters[i] = new TriggerParameter();
|
||||
//// pipe.triggerParameters[i].set(s);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (slot.cpt.hasKey("action" + i)) {
|
||||
//// pipe.activatedActions[i] = ActionManager.actions[slot.cpt.getInteger("action" + i)];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/*if (slot.cpt.hasKey("gate")) {
|
||||
int gateId = slot.cpt.getInteger("gate");
|
||||
GateVanilla newGate;
|
||||
if (slot.cpt.hasKey("hasPulser") && slot.cpt.getBoolean("hasPulser")) {
|
||||
newGate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGateAutarchic, 1, gateId - 1));
|
||||
} else {
|
||||
newGate = new GateVanilla(pipe, new ItemStack(BuildCraftTransport.pipeGate, 1, gateId - 1));
|
||||
}
|
||||
pipe.gate = newGate;
|
||||
|
||||
//BlockGenericPipe.placePipe(pipe, context.world(), slot.x, slot.y, slot.z, slot.blockId, slot.meta);
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
if (slot.cpt.hasKey("trigger" + i)) {
|
||||
pipe.gate.actions[i] = ActionManager.triggers[slot.cpt.getInteger("trigger" + i)];
|
||||
}
|
||||
|
||||
//if (BuildCraftCore.itemBptProps[pipeId] != null) {
|
||||
// BuildCraftCore.itemBptProps[pipeId].buildBlock(slot, context);
|
||||
//}
|
||||
if (slot.cpt.hasKey("triggerParameter" + i)) {
|
||||
ItemStack s = ItemStack.loadItemStackFromNBT((NBTTagCompound) slot.cpt.getTag("triggerParameter" + i));
|
||||
|
||||
if (s != null) {
|
||||
pipe.triggerParameters[i] = new TriggerParameter();
|
||||
pipe.triggerParameters[i].set(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (slot.cpt.hasKey("action" + i)) {
|
||||
pipe.activatedActions[i] = ActionManager.actions[slot.cpt.getInteger("action" + i)];
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
BlockGenericPipe.placePipe(pipe, context.world(), slot.x, slot.y,
|
||||
slot.z, slot.block, slot.meta);
|
||||
|
||||
/*if (BuildCraftCore.itemBptProps[pipeId] != null) {
|
||||
BuildCraftCore.itemBptProps[pipeId].buildBlock(slot, context);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeFromWorld(BptSlotInfo bptSlot, IBptContext context, int x, int y, int z) {
|
||||
Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z);
|
||||
|
||||
if (BlockGenericPipe.isValid(pipe)) {
|
||||
/*if (BlockGenericPipe.isValid(pipe)) {
|
||||
//bptSlot.cpt.setInteger("pipeId", pipe.itemID);
|
||||
|
||||
for (int i = 0; i < pipe.wireSet.length; ++i)
|
||||
|
@ -143,34 +146,34 @@ public class BptBlockPipe extends BptBlock {
|
|||
}
|
||||
|
||||
// / TODO: Does not save/load custom gates
|
||||
// if (pipe.hasGate()) {
|
||||
// bptSlot.cpt.setInteger("gate", pipe.gate.kind.ordinal());
|
||||
// if (pipe.gate instanceof GateVanilla) {
|
||||
// bptSlot.cpt.setBoolean("hasPulser", ((GateVanilla) pipe.gate).hasPulser());
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < 8; ++i) {
|
||||
//// if (pipe.activatedTriggers[i] != null) {
|
||||
//// bptSlot.cpt.setInteger("trigger" + i, pipe.activatedTriggers[i].getId());
|
||||
//// }
|
||||
////
|
||||
//// if (pipe.triggerParameters[i] != null) {
|
||||
//// NBTTagCompound subCpt = new NBTTagCompound();
|
||||
//// pipe.triggerParameters[i].getItemStack().writeToNBT(subCpt);
|
||||
////
|
||||
//// bptSlot.cpt.setTag("triggerParameter" + i, subCpt);
|
||||
//// }
|
||||
////
|
||||
//// if (pipe.activatedActions[i] != null) {
|
||||
//// bptSlot.cpt.setInteger("action" + i, pipe.activatedActions[i].getId());
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
if (pipe.hasGate()) {
|
||||
bptSlot.cpt.setInteger("gate", pipe.gate.kind.ordinal());
|
||||
if (pipe.gate instanceof GateVanilla) {
|
||||
bptSlot.cpt.setBoolean("hasPulser", ((GateVanilla) pipe.gate).hasPulser());
|
||||
}
|
||||
|
||||
//if (BuildCraftCore.itemBptProps[pipe.itemID] != null) {
|
||||
// BuildCraftCore.itemBptProps[pipe.itemID].initializeFromWorld(bptSlot, context, x, y, z);
|
||||
//}
|
||||
}
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
if (pipe.activatedTriggers[i] != null) {
|
||||
bptSlot.cpt.setInteger("trigger" + i, pipe.activatedTriggers[i].getId());
|
||||
}
|
||||
|
||||
if (pipe.triggerParameters[i] != null) {
|
||||
NBTTagCompound subCpt = new NBTTagCompound();
|
||||
pipe.triggerParameters[i].getItemStack().writeToNBT(subCpt);
|
||||
|
||||
bptSlot.cpt.setTag("triggerParameter" + i, subCpt);
|
||||
}
|
||||
|
||||
if (pipe.activatedActions[i] != null) {
|
||||
bptSlot.cpt.setInteger("action" + i, pipe.activatedActions[i].getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (BuildCraftCore.itemBptProps[pipe.itemID] != null) {
|
||||
BuildCraftCore.itemBptProps[pipe.itemID].initializeFromWorld(bptSlot, context, x, y, z);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue