migrated model of blueprint support, now slot-specific instead of block-type-specific

This commit is contained in:
SpaceToad 2014-03-04 21:03:37 +01:00
parent ed0834c04e
commit 8a7b612402
53 changed files with 547 additions and 872 deletions

View file

@ -17,9 +17,9 @@ import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.bptblocks.BptBlockBed; import buildcraft.api.bptblocks.BptBlockBed;
import buildcraft.api.bptblocks.BptBlockCustomStack; import buildcraft.api.bptblocks.BptBlockCustomStack;
import buildcraft.api.bptblocks.BptBlockDelegate;
import buildcraft.api.bptblocks.BptBlockDirt; import buildcraft.api.bptblocks.BptBlockDirt;
import buildcraft.api.bptblocks.BptBlockDoor; import buildcraft.api.bptblocks.BptBlockDoor;
import buildcraft.api.bptblocks.BptBlockFluid; import buildcraft.api.bptblocks.BptBlockFluid;
@ -141,86 +141,85 @@ public class BuildCraftBuilders extends BuildCraftMod {
// Register save handler // Register save handler
MinecraftForge.EVENT_BUS.register(new EventHandlerBuilders()); MinecraftForge.EVENT_BUS.register(new EventHandlerBuilders());
new BptBlockIgnore(Blocks.snow); BlueprintManager.registerSchematicClass(Blocks.snow, BptBlockIgnore.class);
new BptBlockIgnore(Blocks.tallgrass); BlueprintManager.registerSchematicClass(Blocks.tallgrass, BptBlockIgnore.class);
new BptBlockIgnore(Blocks.ice); BlueprintManager.registerSchematicClass(Blocks.ice, BptBlockIgnore.class);
new BptBlockIgnore(Blocks.piston_head); BlueprintManager.registerSchematicClass(Blocks.piston_head, BptBlockIgnore.class);
new BptBlockDirt(Blocks.dirt); BlueprintManager.registerSchematicClass(Blocks.dirt, BptBlockDirt.class);
new BptBlockDirt(Blocks.grass); BlueprintManager.registerSchematicClass(Blocks.grass, BptBlockDirt.class);
new BptBlockDirt(Blocks.farmland); BlueprintManager.registerSchematicClass(Blocks.farmland, BptBlockDirt.class);
new BptBlockDelegate(Blocks.unlit_redstone_torch, Blocks.redstone_torch); BlueprintManager.registerSchematicClass(Blocks.torch, BptBlockWallSide.class);
new BptBlockDelegate(Blocks.lit_furnace, Blocks.furnace); BlueprintManager.registerSchematicClass(Blocks.redstone_torch, BptBlockWallSide.class);
new BptBlockDelegate(Blocks.piston_extension, Blocks.piston); BlueprintManager.registerSchematicClass(Blocks.unlit_redstone_torch, BptBlockWallSide.class);
new BptBlockWallSide(Blocks.torch); BlueprintManager.registerSchematicClass(Blocks.ladder, BptBlockRotateMeta.class, new int[]{2, 5, 3, 4}, true);
new BptBlockWallSide(Blocks.redstone_torch); BlueprintManager.registerSchematicClass(Blocks.fence_gate, BptBlockRotateMeta.class, new int[]{0, 1, 2, 3}, true);
new BptBlockRotateMeta(Blocks.ladder, new int[]{2, 5, 3, 4}, true); BlueprintManager.registerSchematicClass(Blocks.furnace, BptBlockRotateInventory.class, new int[]{2, 5, 3, 4}, true);
new BptBlockRotateMeta(Blocks.fence_gate, new int[]{0, 1, 2, 3}, true); BlueprintManager.registerSchematicClass(Blocks.lit_furnace, BptBlockRotateInventory.class, new int[]{2, 5, 3, 4}, true);
BlueprintManager.registerSchematicClass(Blocks.chest, BptBlockRotateInventory.class, new int[]{2, 5, 3, 4}, true);
BlueprintManager.registerSchematicClass(Blocks.dispenser, BptBlockRotateInventory.class, new int[]{2, 5, 3, 4}, true);
new BptBlockRotateInventory(Blocks.furnace, new int[]{2, 5, 3, 4}, true); BlueprintManager.registerSchematicClass(Blocks.brewing_stand, BptBlockInventory.class);
new BptBlockRotateInventory(Blocks.chest, new int[]{2, 5, 3, 4}, true);
new BptBlockRotateInventory(Blocks.dispenser, new int[]{2, 5, 3, 4}, true);
new BptBlockInventory(Blocks.brewing_stand); BlueprintManager.registerSchematicClass(Blocks.vine, BptBlockRotateMeta.class, new int[]{1, 4, 8, 2}, false);
BlueprintManager.registerSchematicClass(Blocks.trapdoor, BptBlockRotateMeta.class, new int[]{0, 1, 2, 3}, false);
new BptBlockRotateMeta(Blocks.vine, new int[]{1, 4, 8, 2}, false); BlueprintManager.registerSchematicClass(Blocks.wooden_button, BptBlockLever.class);
new BptBlockRotateMeta(Blocks.trapdoor, new int[]{0, 1, 2, 3}, false); BlueprintManager.registerSchematicClass(Blocks.stone_button, BptBlockLever.class);
BlueprintManager.registerSchematicClass(Blocks.lever, BptBlockLever.class);
new BptBlockLever(Blocks.wooden_button); BlueprintManager.registerSchematicClass(Blocks.stone, BptBlockCustomStack.class, new ItemStack(Blocks.stone));
new BptBlockLever(Blocks.stone_button); BlueprintManager.registerSchematicClass(Blocks.redstone_wire, BptBlockCustomStack.class, new ItemStack(Items.redstone));
new BptBlockLever(Blocks.lever); BlueprintManager.registerSchematicClass(Blocks.cake, BptBlockCustomStack.class, new ItemStack(Items.cake));
new BptBlockCustomStack(Blocks.stone, new ItemStack(Blocks.stone));
new BptBlockCustomStack(Blocks.redstone_wire, new ItemStack(Items.redstone));
new BptBlockCustomStack(Blocks.cake, new ItemStack(Items.cake));
//new BptBlockCustomStack(Blocks.crops.blockID, new ItemStack(Items.seeds)); //new BptBlockCustomStack(Blocks.crops.blockID, new ItemStack(Items.seeds));
new BptBlockCustomStack(Blocks.pumpkin_stem, new ItemStack(Items.pumpkin_seeds)); BlueprintManager.registerSchematicClass(Blocks.pumpkin_stem, BptBlockCustomStack.class, new ItemStack(Items.pumpkin_seeds));
new BptBlockCustomStack(Blocks.melon_stem, new ItemStack(Items.melon_seeds)); BlueprintManager.registerSchematicClass(Blocks.melon_stem, BptBlockCustomStack.class, new ItemStack(Items.melon_seeds));
new BptBlockCustomStack(Blocks.glowstone, new ItemStack(Blocks.glowstone)); BlueprintManager.registerSchematicClass(Blocks.glowstone, BptBlockCustomStack.class, new ItemStack(Blocks.glowstone));
new BptBlockRedstoneRepeater(Blocks.powered_repeater); BlueprintManager.registerSchematicClass(Blocks.powered_repeater, BptBlockRedstoneRepeater.class);
new BptBlockRedstoneRepeater(Blocks.unpowered_repeater); BlueprintManager.registerSchematicClass(Blocks.unpowered_repeater, BptBlockRedstoneRepeater.class);
new BptBlockFluid(Blocks.water, new ItemStack(Items.water_bucket)); BlueprintManager.registerSchematicClass(Blocks.water, BptBlockFluid.class, new ItemStack(Items.water_bucket));
new BptBlockFluid(Blocks.flowing_water, new ItemStack(Items.water_bucket)); BlueprintManager.registerSchematicClass(Blocks.flowing_water, BptBlockFluid.class, new ItemStack(Items.water_bucket));
new BptBlockFluid(Blocks.lava, new ItemStack(Items.lava_bucket)); BlueprintManager.registerSchematicClass(Blocks.lava, BptBlockFluid.class, new ItemStack(Items.lava_bucket));
new BptBlockFluid(Blocks.flowing_lava, new ItemStack(Items.lava_bucket)); BlueprintManager.registerSchematicClass(Blocks.flowing_lava, BptBlockFluid.class, new ItemStack(Items.lava_bucket));
new BptBlockIgnoreMeta(Blocks.rail); BlueprintManager.registerSchematicClass(Blocks.rail, BptBlockIgnoreMeta.class);
new BptBlockIgnoreMeta(Blocks.detector_rail); BlueprintManager.registerSchematicClass(Blocks.detector_rail, BptBlockIgnoreMeta.class);
new BptBlockIgnoreMeta(Blocks.glass_pane); BlueprintManager.registerSchematicClass(Blocks.glass_pane, BptBlockIgnoreMeta.class);
new BptBlockPiston(Blocks.piston); BlueprintManager.registerSchematicClass(Blocks.piston, BptBlockPiston.class);
new BptBlockPiston(Blocks.sticky_piston); BlueprintManager.registerSchematicClass(Blocks.piston_extension, BptBlockPiston.class);
BlueprintManager.registerSchematicClass(Blocks.sticky_piston, BptBlockPiston.class);
new BptBlockPumpkin(Blocks.lit_pumpkin); BlueprintManager.registerSchematicClass(Blocks.lit_pumpkin, BptBlockPumpkin.class);
new BptBlockStairs(Blocks.stone_stairs); BlueprintManager.registerSchematicClass(Blocks.stone_stairs, BptBlockStairs.class);
new BptBlockStairs(Blocks.oak_stairs); BlueprintManager.registerSchematicClass(Blocks.oak_stairs, BptBlockStairs.class);
new BptBlockStairs(Blocks.nether_brick_stairs); BlueprintManager.registerSchematicClass(Blocks.nether_brick_stairs, BptBlockStairs.class);
new BptBlockStairs(Blocks.brick_stairs); BlueprintManager.registerSchematicClass(Blocks.brick_stairs, BptBlockStairs.class);
new BptBlockStairs(Blocks.stone_brick_stairs); BlueprintManager.registerSchematicClass(Blocks.stone_brick_stairs, BptBlockStairs.class);
new BptBlockDoor(Blocks.wooden_button, new ItemStack(Items.wooden_door)); BlueprintManager.registerSchematicClass(Blocks.wooden_button, BptBlockDoor.class, new ItemStack(Items.wooden_door));
new BptBlockDoor(Blocks.iron_door, new ItemStack(Items.iron_door)); BlueprintManager.registerSchematicClass(Blocks.iron_door, BptBlockDoor.class, new ItemStack(Items.iron_door));
new BptBlockBed(Blocks.bed); BlueprintManager.registerSchematicClass(Blocks.bed, BptBlockBed.class);
new BptBlockSign(Blocks.wall_sign, true); BlueprintManager.registerSchematicClass(Blocks.wall_sign, BptBlockSign.class, true);
new BptBlockSign(Blocks.standing_sign, false); BlueprintManager.registerSchematicClass(Blocks.standing_sign, BptBlockSign.class, false);
// BUILDCRAFT BLOCKS // BUILDCRAFT BLOCKS
new BptBlockRotateInventory(architectBlock, new int[]{2, 5, 3, 4}, true); BlueprintManager.registerSchematicClass(architectBlock, BptBlockRotateInventory.class, new int[]{2, 5, 3, 4}, true);
new BptBlockRotateInventory(builderBlock, new int[]{2, 5, 3, 4}, true); BlueprintManager.registerSchematicClass(builderBlock, BptBlockRotateInventory.class, new int[]{2, 5, 3, 4}, true);
new BptBlockInventory(libraryBlock); BlueprintManager.registerSchematicClass(libraryBlock, BptBlockInventory.class);
new BptBlockWallSide(markerBlock); BlueprintManager.registerSchematicClass(markerBlock, BptBlockWallSide.class);
new BptBlockWallSide(pathMarkerBlock); BlueprintManager.registerSchematicClass(pathMarkerBlock, BptBlockWallSide.class);
if (BuildCraftCore.loadDefaultRecipes) { if (BuildCraftCore.loadDefaultRecipes) {
loadRecipes(); loadRecipes();

View file

@ -24,6 +24,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.fuels.IronEngineCoolant; import buildcraft.api.fuels.IronEngineCoolant;
import buildcraft.api.fuels.IronEngineFuel; import buildcraft.api.fuels.IronEngineFuel;
import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.api.recipes.BuildcraftRecipes;
@ -250,7 +251,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
new BptBlockEngine(engineBlock); BlueprintManager.registerSchematicClass(engineBlock, BptBlockEngine.class);
if (BuildCraftCore.loadDefaultRecipes) { if (BuildCraftCore.loadDefaultRecipes) {
loadRecipes(); loadRecipes();

View file

@ -22,6 +22,7 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms; import buildcraft.core.InterModComms;
import buildcraft.core.Version; import buildcraft.core.Version;
@ -145,10 +146,10 @@ public class BuildCraftFactory extends BuildCraftMod {
FactoryProxy.proxy.initializeTileEntities(); FactoryProxy.proxy.initializeTileEntities();
new BptBlockAutoWorkbench(autoWorkbenchBlock); BlueprintManager.registerSchematicClass(autoWorkbenchBlock, BptBlockAutoWorkbench.class);
new BptBlockFrame(frameBlock); BlueprintManager.registerSchematicClass(frameBlock, BptBlockFrame.class);
new BptBlockRefinery(refineryBlock); BlueprintManager.registerSchematicClass(refineryBlock, BptBlockRefinery.class);
new BptBlockTank(tankBlock); BlueprintManager.registerSchematicClass(tankBlock, BptBlockTank.class);
if (BuildCraftCore.loadDefaultRecipes) { if (BuildCraftCore.loadDefaultRecipes) {
loadRecipes(); loadRecipes();

View file

@ -15,6 +15,7 @@ import java.util.List;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.bptblocks.BptBlockInventory; import buildcraft.api.bptblocks.BptBlockInventory;
import buildcraft.api.bptblocks.BptBlockRotateMeta; import buildcraft.api.bptblocks.BptBlockRotateMeta;
import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.api.recipes.BuildcraftRecipes;
@ -93,8 +94,8 @@ public class BuildCraftSilicon extends BuildCraftMod {
CoreProxy.proxy.registerTileEntity(TileAdvancedCraftingTable.class, "net.minecraft.src.buildcraft.factory.TileAssemblyAdvancedWorkbench"); CoreProxy.proxy.registerTileEntity(TileAdvancedCraftingTable.class, "net.minecraft.src.buildcraft.factory.TileAssemblyAdvancedWorkbench");
CoreProxy.proxy.registerTileEntity(TileIntegrationTable.class, "net.minecraft.src.buildcraft.factory.TileIntegrationTable"); CoreProxy.proxy.registerTileEntity(TileIntegrationTable.class, "net.minecraft.src.buildcraft.factory.TileIntegrationTable");
new BptBlockRotateMeta(laserBlock, new int[]{2, 5, 3, 4}, true); BlueprintManager.registerSchematicClass(laserBlock, BptBlockRotateMeta.class, new int[]{2, 5, 3, 4}, true);
new BptBlockInventory(assemblyTableBlock); BlueprintManager.registerSchematicClass(assemblyTableBlock, BptBlockInventory.class);
if (BuildCraftCore.loadDefaultRecipes) { if (BuildCraftCore.loadDefaultRecipes) {
loadRecipes(); loadRecipes();

View file

@ -21,6 +21,7 @@ import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IIconProvider;
import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.ActionManager;
import buildcraft.api.gates.GateExpansions; import buildcraft.api.gates.GateExpansions;
@ -429,7 +430,7 @@ public class BuildCraftTransport extends BuildCraftMod {
TransportProxy.proxy.registerTileEntities(); TransportProxy.proxy.registerTileEntities();
new BptBlockPipe(genericPipeBlock); BlueprintManager.registerSchematicClass(genericPipeBlock, BptBlockPipe.class);
new BptPipeIron(pipeItemsIron); new BptPipeIron(pipeItemsIron);
new BptPipeIron(pipeFluidsIron); new BptPipeIron(pipeFluidsIron);

View file

@ -8,23 +8,54 @@
*/ */
package buildcraft.api.blueprints; package buildcraft.api.blueprints;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import net.minecraft.block.Block; import net.minecraft.block.Block;
public class BlueprintManager { public class BlueprintManager {
private static final HashMap <Block, BptBlock> bptBlockRegistry = new HashMap<Block, BptBlock>(); private static class SchematicConstructor {
Class clas;
public static void registerBptBlock (Block block, BptBlock bptBlock) { Object [] params;
bptBlockRegistry.put(block, bptBlock);
} }
public static BptBlock getBptBlock (Block block) { private static final HashMap <Block, SchematicConstructor> schematicClasses =
if (!bptBlockRegistry.containsKey(block)) { new HashMap<Block, SchematicConstructor>();
registerBptBlock(block, new BptBlock(block));
public static void registerSchematicClass (Block block, Class clas, Object ... params) {
SchematicConstructor c = new SchematicConstructor ();
c.clas = clas;
c.params = params;
schematicClasses.put(block, c);
}
public static BptBlock newSchematic (Block block) {
if (!schematicClasses.containsKey(block)) {
registerSchematicClass(block, BptBlock.class);
} }
return bptBlockRegistry.get(block); try {
SchematicConstructor c = schematicClasses.get(block);
return (BptBlock) c.clas.getConstructors() [0].newInstance(c.params);
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
} }
} }

146
common/buildcraft/api/blueprints/BptBlock.java Normal file → Executable file
View file

@ -16,7 +16,11 @@ import net.minecraft.block.BlockContainer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import buildcraft.core.network.NetworkData;
import buildcraft.core.utils.Utils;
/** /**
* This class allow to specify specific behavior for blocks stored in * This class allow to specify specific behavior for blocks stored in
@ -53,24 +57,72 @@ import net.minecraft.tileentity.TileEntity;
*/ */
public class BptBlock { public class BptBlock {
public final Block block; @NetworkData
public Block block = null;
public BptBlock(Block block) { @NetworkData
this.block = block; public int x, y, z, meta = 0;
BlueprintManager.registerBptBlock(block, this);
/**
* This field contains requirements for a given block when stored in the
* blueprint. Modders can either rely on this list or compute their own int
* BptBlock.
*/
@NetworkData
public ArrayList<ItemStack> storedRequirements = new ArrayList<ItemStack>();
/**
* This tree contains additional data to be stored in the blueprint. By
* default, it will be initialized from BptBlock.initializeFromWorld with
* the standard readNBT function of the corresponding tile (if any) and will
* be loaded from BptBlock.buildBlock using the standard writeNBT function.
*/
@NetworkData
public NBTTagCompound cpt = new NBTTagCompound();
public enum Mode {
ClearIfInvalid, Build
};
public Mode mode = Mode.Build;
@SuppressWarnings("unchecked")
@Override
public BptBlock clone() {
BptBlock obj = BlueprintManager.newSchematic(block);
obj.x = x;
obj.y = y;
obj.z = z;
obj.block = block;
obj.meta = meta;
obj.cpt = (NBTTagCompound) cpt.copy();
obj.storedRequirements = (ArrayList<ItemStack>) storedRequirements.clone();
obj.mode = mode;
return obj;
} }
public final LinkedList<ItemStack> getRequirements(IBptContext context) {
LinkedList<ItemStack> res = new LinkedList<ItemStack>();
addRequirements(context, res);
return res;
}
/** /**
* Returns the requirements needed to build this block. When the * Returns the requirements needed to build this block. When the
* requirements are met, they will be removed all at once from the builder, * requirements are met, they will be removed all at once from the builder,
* before calling buildBlock. * before calling buildBlock.
*/ */
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
if (slot.block != null) { if (block != null) {
if (slot.storedRequirements.size() != 0) { if (storedRequirements.size() != 0) {
requirements.addAll(slot.storedRequirements); requirements.addAll(storedRequirements);
} else { } else {
requirements.add(new ItemStack(slot.block, 1, slot.meta)); requirements.add(new ItemStack(block, 1, meta));
} }
} }
} }
@ -92,7 +144,7 @@ public class BptBlock {
* returns: what was used (similer to req, but created from stack, so that * returns: what was used (similer to req, but created from stack, so that
* any NBT based differences are drawn from the correct source) * any NBT based differences are drawn from the correct source)
*/ */
public ItemStack useItem(BptSlotInfo slot, IBptContext context, ItemStack req, ItemStack stack) { public ItemStack useItem(IBptContext context, ItemStack req, ItemStack stack) {
ItemStack result = stack.copy(); ItemStack result = stack.copy();
if (stack.isItemStackDamageable()) { if (stack.isItemStackDamageable()) {
if (req.getItemDamage() + stack.getItemDamage() <= stack.getMaxDamage()) { if (req.getItemDamage() + stack.getItemDamage() <= stack.getMaxDamage()) {
@ -130,34 +182,34 @@ public class BptBlock {
* the blueprint at the location given by the slot. By default, this * the blueprint at the location given by the slot. By default, this
* subprogram is permissive and doesn't take into account metadata. * subprogram is permissive and doesn't take into account metadata.
*/ */
public boolean isValid(BptSlotInfo slot, IBptContext context) { public boolean isValid(IBptContext context) {
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z) && slot.meta == context.world().getBlockMetadata(slot.x, slot.y, slot.z); return block == context.world().getBlock(x, y, z) && meta == context.world().getBlockMetadata(x, y, z);
} }
/** /**
* Perform a 90 degree rotation to the slot. * Perform a 90 degree rotation to the slot.
*/ */
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
} }
/** /**
* Places the block in the world, at the location specified in the slot. * Places the block in the world, at the location specified in the slot.
*/ */
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
// Meta needs to be specified twice, depending on the block behavior // Meta needs to be specified twice, depending on the block behavior
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta, 3); context.world().setBlock(x, y, z, block, meta, 3);
//context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta, 3); //context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta, 3);
if (slot.block instanceof BlockContainer) { if (block instanceof BlockContainer) {
TileEntity tile = context.world().getTileEntity(slot.x, slot.y, slot.z); TileEntity tile = context.world().getTileEntity(x, y, z);
slot.cpt.setInteger("x", slot.x); cpt.setInteger("x", x);
slot.cpt.setInteger("y", slot.y); cpt.setInteger("y", y);
slot.cpt.setInteger("z", slot.z); cpt.setInteger("z", z);
if (tile != null) { if (tile != null) {
tile.readFromNBT(slot.cpt); tile.readFromNBT(cpt);
} }
// By default, clear the inventory to avoid possible dupe bugs // By default, clear the inventory to avoid possible dupe bugs
@ -175,7 +227,7 @@ public class BptBlock {
* Return true if the block should not be placed to the world. Requirements * Return true if the block should not be placed to the world. Requirements
* will not be asked on such a block, and building will not be called. * will not be asked on such a block, and building will not be called.
*/ */
public boolean ignoreBuilding(BptSlotInfo slot) { public boolean ignoreBuilding() {
return false; return false;
} }
@ -188,21 +240,21 @@ public class BptBlock {
* By default, if the block is a BlockContainer, tile information will be to * By default, if the block is a BlockContainer, tile information will be to
* save / load the block. * save / load the block.
*/ */
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) { public void initializeFromWorld(IBptContext context, int x, int y, int z) {
if (slot.block instanceof BlockContainer) { if (block instanceof BlockContainer) {
TileEntity tile = context.world().getTileEntity(x, y, z); TileEntity tile = context.world().getTileEntity(x, y, z);
if (tile != null) { if (tile != null) {
tile.writeToNBT(slot.cpt); tile.writeToNBT(cpt);
} }
} }
if (slot.block != null) { if (block != null) {
ArrayList<ItemStack> req = slot.block.getDrops(context.world(), x, ArrayList<ItemStack> req = block.getDrops(context.world(), x,
y, z, context.world().getBlockMetadata(x, y, z), 0); y, z, context.world().getBlockMetadata(x, y, z), 0);
if (req != null) { if (req != null) {
slot.storedRequirements.addAll(req); storedRequirements.addAll(req);
} }
} }
} }
@ -212,11 +264,47 @@ public class BptBlock {
* blocks. This may be useful to adjust variable depending on surrounding * blocks. This may be useful to adjust variable depending on surrounding
* blocks that may not be there already at initial building. * blocks that may not be there already at initial building.
*/ */
public void postProcessing(BptSlotInfo slot, IBptContext context) { public void postProcessing(IBptContext context) {
} }
private boolean starMatch(String s1, String s2) { private boolean starMatch(String s1, String s2) {
return s1.equals("*") || s2.equals("*") || s1.equals(s2); return s1.equals("*") || s2.equals("*") || s1.equals(s2);
} }
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
nbt.setInteger("blockId", registry.getIdForBlock(block));
nbt.setInteger("blockMeta", meta);
nbt.setTag("blockCpt", cpt);
NBTTagList rq = new NBTTagList();
for (ItemStack stack : storedRequirements) {
NBTTagCompound sub = new NBTTagCompound();
stack.writeToNBT(stack.writeToNBT(sub));
sub.setInteger("id", Item.itemRegistry.getIDForObject(registry
.getItemForId(sub.getInteger("id"))));
rq.appendTag(sub);
}
nbt.setTag("rq", rq);
}
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
block = registry.getBlockForId(nbt.getInteger("blockId"));
meta = nbt.getInteger("blockMeta");
cpt = nbt.getCompoundTag("blockCpt");
NBTTagList rq = nbt.getTagList("rq", Utils.NBTTag_Types.NBTTagList.ordinal());
for (int i = 0; i < rq.tagCount(); ++i) {
NBTTagCompound sub = rq.getCompoundTagAt(i);
// Maps the id in the blueprint to the id in the world
sub.setInteger("id", Item.itemRegistry.getIDForObject(registry
.getItemForId(sub.getInteger("id"))));
storedRequirements.add(ItemStack.loadItemStackFromNBT(sub));
}
}
} }

View file

@ -17,7 +17,7 @@ import net.minecraft.nbt.NBTTagList;
public class BptBlockUtils { public class BptBlockUtils {
public static void requestInventoryContents(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public static void requestInventoryContents(BptBlock slot, IBptContext context, LinkedList<ItemStack> requirements) {
ItemStack[] stacks = getItemStacks(slot, context); ItemStack[] stacks = getItemStacks(slot, context);
for (ItemStack stack : stacks) { for (ItemStack stack : stacks) {
@ -27,7 +27,7 @@ public class BptBlockUtils {
} }
} }
public static void initializeInventoryContents(BptSlotInfo slot, IBptContext context, IInventory inventory) { public static void initializeInventoryContents(BptBlock slot, IBptContext context, IInventory inventory) {
ItemStack[] stacks = new ItemStack[inventory.getSizeInventory()]; ItemStack[] stacks = new ItemStack[inventory.getSizeInventory()];
for (int i = 0; i < inventory.getSizeInventory(); ++i) { for (int i = 0; i < inventory.getSizeInventory(); ++i) {
@ -37,7 +37,7 @@ public class BptBlockUtils {
setItemStacks(slot, context, stacks); setItemStacks(slot, context, stacks);
} }
public static void buildInventoryContents(BptSlotInfo slot, IBptContext context, IInventory inventory) { public static void buildInventoryContents(BptBlock slot, IBptContext context, IInventory inventory) {
ItemStack[] stacks = getItemStacks(slot, context); ItemStack[] stacks = getItemStacks(slot, context);
for (int i = 0; i < stacks.length; ++i) { for (int i = 0; i < stacks.length; ++i) {
@ -45,11 +45,12 @@ public class BptBlockUtils {
} }
} }
public static ItemStack[] getItemStacks(BptSlotInfo slot, IBptContext context) { public static ItemStack[] getItemStacks(BptBlock slot, IBptContext context) {
NBTTagList list = (NBTTagList) slot.cpt.getTag("inv"); NBTTagList list = (NBTTagList) slot.cpt.getTag("inv");
if (list == null) if (list == null) {
return new ItemStack[0]; return new ItemStack[0];
}
ItemStack stacks[] = new ItemStack[list.tagCount()]; ItemStack stacks[] = new ItemStack[list.tagCount()];
@ -64,14 +65,12 @@ public class BptBlockUtils {
return stacks; return stacks;
} }
public static void setItemStacks(BptSlotInfo slot, IBptContext context, ItemStack[] stacks) { public static void setItemStacks(BptBlock slot, IBptContext context, ItemStack[] stacks) {
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < stacks.length; ++i) { for (ItemStack stack : stacks) {
NBTTagCompound cpt = new NBTTagCompound(); NBTTagCompound cpt = new NBTTagCompound();
nbttaglist.appendTag(cpt); nbttaglist.appendTag(cpt);
ItemStack stack = stacks[i];
if (stack != null && stack.stackSize != 0) { if (stack != null && stack.stackSize != 0) {
stack.writeToNBT(cpt); stack.writeToNBT(cpt);
//context.storeId(stack.itemID); //context.storeId(stack.itemID);

View file

@ -1,61 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.blueprints;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import buildcraft.core.network.NetworkData;
/**
* This class records a slot, either from a blueprint or from a block placed in
* the world.
*/
public class BptSlotInfo {
@NetworkData
public Block block = null;
@NetworkData
public int x, y, z, meta = 0;
/**
* This field contains requirements for a given block when stored in the
* blueprint. Modders can either rely on this list or compute their own int
* BptBlock.
*/
@NetworkData
public ArrayList<ItemStack> storedRequirements = new ArrayList<ItemStack>();
/**
* This tree contains additional data to be stored in the blueprint. By
* default, it will be initialized from BptBlock.initializeFromWorld with
* the standard readNBT function of the corresponding tile (if any) and will
* be loaded from BptBlock.buildBlock using the standard writeNBT function.
*/
@NetworkData
public NBTTagCompound cpt = new NBTTagCompound();
@Override
public BptSlotInfo clone() {
BptSlotInfo obj = new BptSlotInfo();
obj.x = x;
obj.y = y;
obj.z = z;
obj.block = block;
obj.meta = meta;
obj.cpt = (NBTTagCompound) cpt.copy();
return obj;
}
}

View file

@ -10,59 +10,53 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockBed extends BptBlock { public class BptBlockBed extends BptBlock {
public BptBlockBed(Block block) {
super(block);
}
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
if ((slot.meta & 8) == 0) { if ((meta & 8) == 0) {
requirements.add(new ItemStack(Items.bed)); requirements.add(new ItemStack(Items.bed));
} }
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
int orientation = (slot.meta & 7); int orientation = (meta & 7);
int others = slot.meta - orientation; int others = meta - orientation;
switch (orientation) { switch (orientation) {
case 0: case 0:
slot.meta = 1 + others; meta = 1 + others;
break; break;
case 1: case 1:
slot.meta = 2 + others; meta = 2 + others;
break; break;
case 2: case 2:
slot.meta = 3 + others; meta = 3 + others;
break; break;
case 3: case 3:
slot.meta = 0 + others; meta = 0 + others;
break; break;
} }
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
if ((slot.meta & 8) != 0) { if ((meta & 8) != 0) {
return; return;
} }
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1); context.world().setBlock(x, y, z, block, meta, 3);
int x2 = slot.x; int x2 = x;
int z2 = slot.z; int z2 = z;
switch (slot.meta) { switch (meta) {
case 0: case 0:
z2++; z2++;
break; break;
@ -77,11 +71,11 @@ public class BptBlockBed extends BptBlock {
break; break;
} }
context.world().setBlock(x2, slot.y, z2, slot.block, slot.meta + 8,1); context.world().setBlock(x2, y, z2, block, meta + 8,1);
} }
@Override @Override
public boolean ignoreBuilding(BptSlotInfo slot) { public boolean ignoreBuilding() {
return (slot.meta & 8) != 0; return (meta & 8) != 0;
} }
} }

View file

@ -10,24 +10,20 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockCustomStack extends BptBlock { public class BptBlockCustomStack extends BptBlock {
final ItemStack customStack; final ItemStack customStack;
public BptBlockCustomStack(Block block, ItemStack customStack) { public BptBlockCustomStack(ItemStack customStack) {
super(block);
this.customStack = customStack; this.customStack = customStack;
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(customStack.copy()); requirements.add(customStack.copy());
} }

View file

@ -1,63 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.bptblocks;
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;
public class BptBlockDelegate extends BptBlock {
final Block delegateTo;
BptBlock delegated;
public BptBlockDelegate(Block block, Block delegateTo) {
super(block);
this.delegateTo = delegateTo;
}
@Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
BptSlotInfo newSlot = slot.clone();
slot.block = delegateTo;
getDelegated ().addRequirements(newSlot, context, requirements);
}
@Override
public boolean isValid(BptSlotInfo slot, IBptContext context) {
BptSlotInfo newSlot = slot.clone();
slot.block = delegateTo;
return getDelegated ().isValid(newSlot, context);
}
@Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
BptSlotInfo newSlot = slot.clone();
slot.block = delegateTo;
getDelegated().rotateLeft(newSlot, context);
}
private BptBlock getDelegated () {
if (delegated == null) {
delegated = BlueprintManager.getBptBlock(delegateTo);
}
return delegated;
}
}

View file

@ -14,28 +14,23 @@ import net.minecraft.block.Block;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockDirt extends BptBlock { public class BptBlockDirt extends BptBlock {
public BptBlockDirt(Block block) {
super(block);
}
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Blocks.dirt)); requirements.add(new ItemStack(Blocks.dirt));
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
context.world().setBlock(slot.x, slot.y, slot.z, Blocks.dirt, slot.meta,1); context.world().setBlock(x, y, z, Blocks.dirt, meta, 3);
} }
@Override @Override
public boolean isValid(BptSlotInfo slot, IBptContext context) { public boolean isValid(IBptContext context) {
Block block = context.world().getBlock(slot.x, slot.y, slot.z); Block block = context.world().getBlock(x, y, z);
return block == Blocks.dirt || block == Blocks.grass || block == Blocks.farmland; return block == Blocks.dirt || block == Blocks.grass || block == Blocks.farmland;
} }

View file

@ -10,62 +10,58 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockDoor extends BptBlock { public class BptBlockDoor extends BptBlock {
final ItemStack stack; final ItemStack stack;
public BptBlockDoor(Block block, ItemStack stack) { public BptBlockDoor(ItemStack stack) {
super(block);
this.stack = stack; this.stack = stack;
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
if ((slot.meta & 8) == 0) { if ((meta & 8) == 0) {
requirements.add(stack.copy()); requirements.add(stack.copy());
} }
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
int orientation = (slot.meta & 3); int orientation = (meta & 3);
int others = slot.meta - orientation; int others = meta - orientation;
switch (orientation) { switch (orientation) {
case 0: case 0:
slot.meta = 1 + others; meta = 1 + others;
break; break;
case 1: case 1:
slot.meta = 2 + others; meta = 2 + others;
break; break;
case 2: case 2:
slot.meta = 3 + others; meta = 3 + others;
break; break;
case 3: case 3:
slot.meta = 0 + others; meta = 0 + others;
break; break;
} }
} }
@Override @Override
public boolean ignoreBuilding(BptSlotInfo slot) { public boolean ignoreBuilding() {
return (slot.meta & 8) != 0; return (meta & 8) != 0;
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1); context.world().setBlock(x, y, z, block, meta, 3);
context.world().setBlock(slot.x, slot.y + 1, slot.z, slot.block, slot.meta + 8,1); context.world().setBlock(x, y + 1, z, block, meta + 8, 3);
context.world().setBlockMetadataWithNotify(slot.x, slot.y + 1, slot.z, slot.meta + 8,1); context.world().setBlockMetadataWithNotify(x, y + 1, z, meta + 8, 3);
context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta,1); context.world().setBlockMetadataWithNotify(x, y, z, meta, 3);
} }
} }

View file

@ -10,52 +10,48 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockFluid extends BptBlock { public class BptBlockFluid extends BptBlock {
private final ItemStack bucketStack; private final ItemStack bucketStack;
public BptBlockFluid(Block block, ItemStack bucketStack) { public BptBlockFluid(ItemStack bucketStack) {
super(block);
this.bucketStack = bucketStack; this.bucketStack = bucketStack;
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
if (slot.meta == 0) { if (meta == 0) {
requirements.add(bucketStack.copy()); requirements.add(bucketStack.copy());
} }
} }
@Override @Override
public boolean isValid(BptSlotInfo slot, IBptContext context) { public boolean isValid(IBptContext context) {
if (slot.meta == 0) { if (meta == 0) {
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z) && context.world().getBlockMetadata(slot.x, slot.y, slot.z) == 0; return block == context.world().getBlock(x, y, z) && context.world().getBlockMetadata(x, y, z) == 0;
} else { } else {
return true; return true;
} }
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
} }
@Override @Override
public boolean ignoreBuilding(BptSlotInfo slot) { public boolean ignoreBuilding() {
return slot.meta != 0; return meta != 0;
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
if (slot.meta == 0) { if (meta == 0) {
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, 0,1); context.world().setBlock(x, y, z, block, 0,1);
} }
} }

View file

@ -10,35 +10,29 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockIgnore extends BptBlock { public class BptBlockIgnore extends BptBlock {
public BptBlockIgnore(Block block) { @Override
super(block); public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 0, 0));
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public boolean isValid(IBptContext context) {
requirements.add(new ItemStack(slot.block, 0, 0));
}
@Override
public boolean isValid(BptSlotInfo slot, IBptContext context) {
return true; return true;
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
} }
@Override @Override
public boolean ignoreBuilding(BptSlotInfo slot) { public boolean ignoreBuilding() {
return true; return true;
} }

View file

@ -10,25 +10,19 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockIgnoreMeta extends BptBlock { public class BptBlockIgnoreMeta extends BptBlock {
public BptBlockIgnoreMeta(Block block) { @Override
super(block); public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 1, 0));
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public boolean isValid(IBptContext context) {
requirements.add(new ItemStack(slot.block, 1, 0)); return block == context.world().getBlock(x, y, z);
}
@Override
public boolean isValid(BptSlotInfo slot, IBptContext context) {
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z);
} }
} }

View file

@ -8,24 +8,17 @@
*/ */
package buildcraft.api.bptblocks; package buildcraft.api.bptblocks;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockInventory extends BptBlock { public class BptBlockInventory extends BptBlock {
public BptBlockInventory(Block block) {
super(block);
}
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
super.buildBlock(slot, context); super.buildBlock(context);
IInventory inv = (IInventory) context.world().getTileEntity(slot.x, slot.y, slot.z); IInventory inv = (IInventory) context.world().getTileEntity(x, y, z);
for (int i = 0; i < inv.getSizeInventory(); ++i) { for (int i = 0; i < inv.getSizeInventory(); ++i) {
inv.setInventorySlotContents(i, null); inv.setInventorySlotContents(i, null);

View file

@ -10,29 +10,23 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockLever extends BptBlockWallSide { public class BptBlockLever extends BptBlockWallSide {
public BptBlockLever(Block block) {
super(block);
}
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
//requirements.add(new ItemStack(slot.blockId, 1, 0)); //requirements.add(new ItemStack(slot.blockId, 1, 0));
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
int status = slot.meta - (slot.meta & 7); int status = meta - (meta & 7);
slot.meta -= status; meta -= status;
super.rotateLeft(slot, context); super.rotateLeft(context);
slot.meta += status; meta += status;
} }
} }

View file

@ -8,21 +8,19 @@
*/ */
package buildcraft.api.bptblocks; package buildcraft.api.bptblocks;
import net.minecraft.block.Block;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockPiston extends BptBlockRotateMeta { public class BptBlockPiston extends BptBlockRotateMeta {
public BptBlockPiston(Block block) { public BptBlockPiston() {
super(block, new int[] { 2, 5, 3, 4 }, true); super(new int[] { 2, 5, 3, 4 }, true);
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
int meta = slot.meta & 7; int localMeta = meta & 7;
//context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, meta,1); context.world().setBlock(x, y, z, block, localMeta, 3);
} }
} }

View file

@ -10,42 +10,36 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockPumpkin extends BptBlock { public class BptBlockPumpkin extends BptBlock {
public BptBlockPumpkin(Block block) { @Override
super(block); public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 1, 0));
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public boolean isValid(IBptContext context) {
requirements.add(new ItemStack(slot.block, 1, 0)); return block == context.world().getBlock(x, y, z);
} }
@Override @Override
public boolean isValid(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z); switch (meta) {
}
@Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
switch (slot.meta) {
case 0: case 0:
slot.meta = 1; meta = 1;
break; break;
case 1: case 1:
slot.meta = 2; meta = 2;
break; break;
case 2: case 2:
slot.meta = 3; meta = 3;
break; break;
case 3: case 3:
slot.meta = 0; meta = 0;
break; break;
} }
} }

View file

@ -10,40 +10,34 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockRedstoneRepeater extends BptBlock { public class BptBlockRedstoneRepeater extends BptBlock {
public BptBlockRedstoneRepeater(Block block) {
super(block);
}
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Items.repeater)); requirements.add(new ItemStack(Items.repeater));
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
int step = slot.meta - (slot.meta & 3); int step = meta - (meta & 3);
switch (slot.meta - step) { switch (meta - step) {
case 0: case 0:
slot.meta = 1 + step; meta = 1 + step;
break; break;
case 1: case 1:
slot.meta = 2 + step; meta = 2 + step;
break; break;
case 2: case 2:
slot.meta = 3 + step; meta = 3 + step;
break; break;
case 3: case 3:
slot.meta = 0 + step; meta = 0 + step;
break; break;
} }
} }

View file

@ -8,24 +8,21 @@
*/ */
package buildcraft.api.bptblocks; package buildcraft.api.bptblocks;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
@Deprecated
public class BptBlockRotateInventory extends BptBlockRotateMeta { public class BptBlockRotateInventory extends BptBlockRotateMeta {
public BptBlockRotateInventory(Block block, int[] rotations, boolean rotateForward) { public BptBlockRotateInventory(int[] rotations, boolean rotateForward) {
super(block, rotations, rotateForward); super(rotations, rotateForward);
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
super.buildBlock(slot, context); super.buildBlock(context);
IInventory inv = (IInventory) context.world().getTileEntity(slot.x, slot.y, slot.z); IInventory inv = (IInventory) context.world().getTileEntity(x, y, z);
for (int i = 0; i < inv.getSizeInventory(); ++i) { for (int i = 0; i < inv.getSizeInventory(); ++i) {
inv.setInventorySlotContents(i, null); inv.setInventorySlotContents(i, null);

View file

@ -10,10 +10,8 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockRotateMeta extends BptBlock { public class BptBlockRotateMeta extends BptBlock {
@ -23,17 +21,15 @@ public class BptBlockRotateMeta extends BptBlock {
int infoMask = 0; int infoMask = 0;
public BptBlockRotateMeta(Block block, int[] rotations, boolean rotateForward) { public BptBlockRotateMeta(int[] rotations, boolean rotateForward) {
super(block);
rot = rotations; rot = rotations;
for (int i = 0; i < rot.length; ++i) { for (int element : rot) {
if (rot[i] < 4) { if (element < 4) {
infoMask = (infoMask < 3 ? 3 : infoMask); infoMask = (infoMask < 3 ? 3 : infoMask);
} else if (rot[i] < 8) { } else if (element < 8) {
infoMask = (infoMask < 7 ? 7 : infoMask); infoMask = (infoMask < 7 ? 7 : infoMask);
} else if (rot[i] < 16) { } else if (element < 16) {
infoMask = (infoMask < 15 ? 15 : infoMask); infoMask = (infoMask < 15 ? 15 : infoMask);
} }
} }
@ -42,19 +38,19 @@ public class BptBlockRotateMeta extends BptBlock {
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(slot.block, 1, 0)); requirements.add(new ItemStack(block, 1, 0));
} }
@Override @Override
public boolean isValid(BptSlotInfo slot, IBptContext context) { public boolean isValid(IBptContext context) {
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z); return block == context.world().getBlock(x, y, z);
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
int pos = slot.meta & infoMask; int pos = meta & infoMask;
int others = slot.meta - pos; int others = meta - pos;
if (rotateForward) { if (rotateForward) {
if (pos == rot[0]) { if (pos == rot[0]) {
@ -78,7 +74,7 @@ public class BptBlockRotateMeta extends BptBlock {
} }
} }
slot.meta = pos + others; meta = pos + others;
} }
} }

View file

@ -10,40 +10,36 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockSign extends BptBlock { public class BptBlockSign extends BptBlock {
boolean isWall; boolean isWall;
public BptBlockSign(Block block, boolean isWall) { public BptBlockSign(boolean isWall) {
super(block);
this.isWall = isWall; this.isWall = isWall;
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(Items.sign)); requirements.add(new ItemStack(Items.sign));
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
if (!isWall) { if (!isWall) {
double angle = ((slot.meta) * 360.0) / 16.0; double angle = ((meta) * 360.0) / 16.0;
angle += 90.0; angle += 90.0;
if (angle >= 360) { if (angle >= 360) {
angle -= 360; angle -= 360;
} }
slot.meta = (int) (angle / 360.0 * 16.0); meta = (int) (angle / 360.0 * 16.0);
} else { } else {
slot.meta = ForgeDirection.values()[slot.meta].getRotation(ForgeDirection.UP).ordinal(); meta = ForgeDirection.values()[meta].getRotation(ForgeDirection.UP).ordinal();
} }
} }
} }

View file

@ -10,42 +10,36 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockStairs extends BptBlock { public class BptBlockStairs extends BptBlock {
public BptBlockStairs(Block block) { @Override
super(block); public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 1, 0));
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public boolean isValid(IBptContext context) {
requirements.add(new ItemStack(slot.block, 1, 0)); return block == context.world().getBlock(x, y, z);
} }
@Override @Override
public boolean isValid(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z); switch (meta) {
}
@Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
switch (slot.meta) {
case 0: case 0:
slot.meta = 2; meta = 2;
break; break;
case 1: case 1:
slot.meta = 3; meta = 3;
break; break;
case 2: case 2:
slot.meta = 1; meta = 1;
break; break;
case 3: case 3:
slot.meta = 0; meta = 0;
break; break;
} }
} }

View file

@ -10,42 +10,36 @@ package buildcraft.api.bptblocks;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockWallSide extends BptBlock { public class BptBlockWallSide extends BptBlock {
public BptBlockWallSide(Block block) { @Override
super(block); public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
requirements.add(new ItemStack(block, 1, 0));
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void rotateLeft(IBptContext context) {
requirements.add(new ItemStack(slot.block, 1, 0));
}
@Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
final int XPos = 2; final int XPos = 2;
final int XNeg = 1; final int XNeg = 1;
final int ZPos = 4; final int ZPos = 4;
final int ZNeg = 3; final int ZNeg = 3;
switch (slot.meta) { switch (meta) {
case XPos: case XPos:
slot.meta = ZPos; meta = ZPos;
break; break;
case ZNeg: case ZNeg:
slot.meta = XPos; meta = XPos;
break; break;
case XNeg: case XNeg:
slot.meta = ZNeg; meta = ZNeg;
break; break;
case ZPos: case ZPos:
slot.meta = XNeg; meta = XNeg;
break; break;
} }
} }

View file

@ -20,6 +20,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftBuilders; import buildcraft.BuildCraftBuilders;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler;
@ -38,7 +39,6 @@ import buildcraft.core.blueprints.BlueprintBase;
import buildcraft.core.blueprints.BptBuilderBase; import buildcraft.core.blueprints.BptBuilderBase;
import buildcraft.core.blueprints.BptBuilderBlueprint; import buildcraft.core.blueprints.BptBuilderBlueprint;
import buildcraft.core.blueprints.BptContext; import buildcraft.core.blueprints.BptContext;
import buildcraft.core.blueprints.BptSlot;
import buildcraft.core.network.NetworkData; import buildcraft.core.network.NetworkData;
import buildcraft.core.robots.EntityRobot; import buildcraft.core.robots.EntityRobot;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
@ -637,7 +637,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory,
public void debugForceBlueprintCompletion () { public void debugForceBlueprintCompletion () {
if (bluePrintBuilder != null) { if (bluePrintBuilder != null) {
BptSlot slot = bluePrintBuilder.getNextBlock(worldObj, this); BptBlock slot = bluePrintBuilder.getNextBlock(worldObj, this);
if (slot != null) { if (slot != null) {
slot.buildBlock(bluePrintBuilder.context); slot.buildBlock(bluePrintBuilder.context);

View file

@ -12,7 +12,7 @@ import buildcraft.api.builder.BlockHandler;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
public final class BlockSchematic extends Schematic { public final class BlockSchematic extends SchematicOld {
public static BlockSchematic create(NBTTagCompound nbt) { public static BlockSchematic create(NBTTagCompound nbt) {
return null; return null;

View file

@ -33,7 +33,7 @@ public class BlueprintBuilder implements IAreaProvider {
this.y = y - blueprint.anchorY; this.y = y - blueprint.anchorY;
this.z = translateZ(z, -blueprint.anchorX, -blueprint.anchorZ); this.z = translateZ(z, -blueprint.anchorX, -blueprint.anchorZ);
builders = new ArrayList<SchematicBuilder>(blueprint.schematicSequence.size()); builders = new ArrayList<SchematicBuilder>(blueprint.schematicSequence.size());
for (Schematic schematic : blueprint.schematicSequence) { for (SchematicOld schematic : blueprint.schematicSequence) {
BlockHandler handler = schematic.getHandler(); BlockHandler handler = schematic.getHandler();
if (handler != null) { if (handler != null) {
builders.add(new SchematicBuilder(schematic, handler)); builders.add(new SchematicBuilder(schematic, handler));
@ -107,11 +107,11 @@ public class BlueprintBuilder implements IAreaProvider {
public class SchematicBuilder { public class SchematicBuilder {
public final Schematic schematic; public final SchematicOld schematic;
public final BlockHandler handler; public final BlockHandler handler;
private boolean complete; private boolean complete;
private SchematicBuilder(Schematic schematic, BlockHandler handler) { private SchematicBuilder(SchematicOld schematic, BlockHandler handler) {
this.schematic = schematic; this.schematic = schematic;
this.handler = handler; this.handler = handler;
} }

View file

@ -12,7 +12,7 @@ import buildcraft.api.builder.BlockHandler;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
public final class ItemSchematic extends Schematic { public final class ItemSchematic extends SchematicOld {
public static ItemSchematic create(NBTTagCompound nbt) { public static ItemSchematic create(NBTTagCompound nbt) {
return null; return null;

View file

@ -11,7 +11,7 @@ package buildcraft.builders.blueprints;
import buildcraft.api.builder.BlockHandler; import buildcraft.api.builder.BlockHandler;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
public final class MaskSchematic extends Schematic { public final class MaskSchematic extends SchematicOld {
private static MaskHandler handler = new MaskHandler(); private static MaskHandler handler = new MaskHandler();

View file

@ -37,11 +37,11 @@ public class SchematicBlueprint {
public BlueprintMeta meta; public BlueprintMeta meta;
@NetworkData @NetworkData
public Schematic[][][] schematics; public SchematicOld[][][] schematics;
// TODO: Save this somewhere, this is the sequence in which blocks are // TODO: Save this somewhere, this is the sequence in which blocks are
// ordered to be build // ordered to be build
public ArrayList<Schematic> schematicSequence = new ArrayList<Schematic>(); public ArrayList<SchematicOld> schematicSequence = new ArrayList<SchematicOld>();
@NetworkData @NetworkData
public int sizeX, sizeY, sizeZ; public int sizeX, sizeY, sizeZ;
@ -72,7 +72,7 @@ public class SchematicBlueprint {
this.sizeY = sizeY; this.sizeY = sizeY;
this.sizeZ = sizeZ; this.sizeZ = sizeZ;
schematics = new Schematic[sizeX][sizeY][sizeZ]; schematics = new SchematicOld[sizeX][sizeY][sizeZ];
} }
public SchematicBlueprint(BlueprintMeta meta, int sizeX, int sizeY, int sizeZ) { public SchematicBlueprint(BlueprintMeta meta, int sizeX, int sizeY, int sizeZ) {
@ -82,7 +82,7 @@ public class SchematicBlueprint {
this.sizeY = sizeY; this.sizeY = sizeY;
this.sizeZ = sizeZ; this.sizeZ = sizeZ;
schematics = new Schematic[sizeX][sizeY][sizeZ]; schematics = new SchematicOld[sizeX][sizeY][sizeZ];
} }
protected SchematicBlueprint(BlueprintMeta meta, NBTTagCompound nbt) { protected SchematicBlueprint(BlueprintMeta meta, NBTTagCompound nbt) {
@ -100,7 +100,7 @@ public class SchematicBlueprint {
for (int i = 0; i < blockList.tagCount(); i++) { for (int i = 0; i < blockList.tagCount(); i++) {
NBTTagCompound blockNBT = (NBTTagCompound) blockList.getCompoundTagAt(i); NBTTagCompound blockNBT = (NBTTagCompound) blockList.getCompoundTagAt(i);
Schematic schematic = Schematic.createSchematicFromNBT(blockNBT); SchematicOld schematic = SchematicOld.createSchematicFromNBT(blockNBT);
schematics[schematic.x][schematic.y][schematic.z] = schematic; schematics[schematic.x][schematic.y][schematic.z] = schematic;
} }
} }
@ -139,7 +139,7 @@ public class SchematicBlueprint {
meta.setCreator(creator); meta.setCreator(creator);
} }
public void setSchematic(int x, int y, int z, Schematic schematic) { public void setSchematic(int x, int y, int z, SchematicOld schematic) {
schematic.x = x; schematic.x = x;
schematic.y = y; schematic.y = y;
schematic.z = z; schematic.z = z;
@ -151,7 +151,7 @@ public class SchematicBlueprint {
BlockHandler handler = BlockHandler.get(block); BlockHandler handler = BlockHandler.get(block);
try { try {
if (handler.canSaveToSchematic(world, x, y, z)) { if (handler.canSaveToSchematic(world, x, y, z)) {
Schematic schematic = BlockSchematic.create(block); SchematicOld schematic = BlockSchematic.create(block);
handler.saveToSchematic(world, x, y, z, schematic.data); handler.saveToSchematic(world, x, y, z, schematic.data);
setSchematic(x, y, z, schematic); setSchematic(x, y, z, schematic);
} }
@ -168,7 +168,7 @@ public class SchematicBlueprint {
BlockHandler handler = BlockHandler.get(item.getItem()); BlockHandler handler = BlockHandler.get(item.getItem());
try { try {
if (handler.canSaveToSchematic(item)) { if (handler.canSaveToSchematic(item)) {
Schematic schematic = ItemSchematic.create(item.getItem()); SchematicOld schematic = ItemSchematic.create(item.getItem());
handler.saveToSchematic(item, schematic.data); handler.saveToSchematic(item, schematic.data);
setSchematic(x, y, z, schematic); setSchematic(x, y, z, schematic);
} }
@ -196,7 +196,7 @@ public class SchematicBlueprint {
setSchematic(x, y, z, schematic); setSchematic(x, y, z, schematic);
} }
public Schematic getBlock(int x, int y, int z) { public SchematicOld getBlock(int x, int y, int z) {
return schematics[x][y][z]; return schematics[x][y][z];
} }
@ -209,8 +209,8 @@ public class SchematicBlueprint {
* *
* @return List<BlockScematic> * @return List<BlockScematic>
*/ */
public LinkedList<Schematic> getBuildList() { public LinkedList<SchematicOld> getBuildList() {
LinkedList<Schematic> list = new LinkedList<Schematic>(); LinkedList<SchematicOld> list = new LinkedList<SchematicOld>();
for (int y = 0; y < sizeY; y++) { for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
@ -228,7 +228,7 @@ public class SchematicBlueprint {
if (costs != null) if (costs != null)
return costs; return costs;
List<ItemStack> stacks = new ArrayList<ItemStack>(); List<ItemStack> stacks = new ArrayList<ItemStack>();
for (Schematic schematic : getBuildList()) { for (SchematicOld schematic : getBuildList()) {
BlockHandler handler = BlockHandler.get(schematic.id); BlockHandler handler = BlockHandler.get(schematic.id);
List<ItemStack> requirements = handler.getCostForSchematic(schematic.data); List<ItemStack> requirements = handler.getCostForSchematic(schematic.data);
for (ItemStack newStack : requirements) { for (ItemStack newStack : requirements) {

View file

@ -12,7 +12,7 @@ import buildcraft.api.builder.BlockHandler;
import buildcraft.core.network.NetworkData; import buildcraft.core.network.NetworkData;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
public abstract class Schematic { public abstract class SchematicOld {
@NetworkData @NetworkData
public int id; public int id;
@ -32,11 +32,11 @@ public abstract class Schematic {
/** /**
* Only to be class by the serializer * Only to be class by the serializer
*/ */
public Schematic() { public SchematicOld() {
} }
protected Schematic(int id) { protected SchematicOld(int id) {
this.id = id; this.id = id;
} }
@ -56,9 +56,9 @@ public abstract class Schematic {
data = nbt.getCompoundTag("data"); data = nbt.getCompoundTag("data");
} }
public static Schematic createSchematicFromNBT(NBTTagCompound nbt) { public static SchematicOld createSchematicFromNBT(NBTTagCompound nbt) {
String schematicType = nbt.getString("schematicType"); String schematicType = nbt.getString("schematicType");
Schematic schematic; SchematicOld schematic;
if (schematicType.equals("block")) { if (schematicType.equals("block")) {
schematic = BlockSchematic.create(nbt); schematic = BlockSchematic.create(nbt);
} else if (schematicType.equals("item")) { } else if (schematicType.equals("item")) {

View file

@ -1,21 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.core.blueprints.BlueprintBase;
import net.minecraft.tileentity.TileEntity;
public interface IBptContributor {
public void saveToBluePrint(TileEntity builder, BlueprintBase bluePrint, BptSlotInfo slot);
public void loadFromBluePrint(TileEntity builder, BlueprintBase bluePrint, BptSlotInfo slot);
}

View file

@ -8,12 +8,14 @@
*/ */
package buildcraft.core.blueprints; package buildcraft.core.blueprints;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
import buildcraft.core.IBptContributor;
import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
@ -27,22 +29,18 @@ public class Blueprint extends BlueprintBase {
} }
public void readFromWorld(IBptContext context, TileEntity anchorTile, int x, int y, int z) { public void readFromWorld(IBptContext context, TileEntity anchorTile, int x, int y, int z) {
BptSlot slot = new BptSlot(); Block block = anchorTile.getWorldObj().getBlock(x, y, z);
BptBlock slot = BlueprintManager.newSchematic(block);
slot.x = (int) (x - context.surroundingBox().pMin().x); slot.x = (int) (x - context.surroundingBox().pMin().x);
slot.y = (int) (y - context.surroundingBox().pMin().y); slot.y = (int) (y - context.surroundingBox().pMin().y);
slot.z = (int) (z - context.surroundingBox().pMin().z); slot.z = (int) (z - context.surroundingBox().pMin().z);
slot.block = anchorTile.getWorldObj().getBlock(x, y, z); slot.block = block;
slot.meta = anchorTile.getWorldObj().getBlockMetadata(x, y, z); slot.meta = anchorTile.getWorldObj().getBlockMetadata(x, y, z);
if (slot.block instanceof BlockContainer) { if (slot.block instanceof BlockContainer) {
TileEntity tile = anchorTile.getWorldObj().getTileEntity(x, y, z); TileEntity tile = anchorTile.getWorldObj().getTileEntity(x, y, z);
if (tile != null && tile instanceof IBptContributor) {
IBptContributor contributor = (IBptContributor) tile;
contributor.saveToBluePrint(anchorTile, this, slot);
}
} }
try { try {
@ -91,7 +89,10 @@ public class Blueprint extends BlueprintBase {
for (int z = 0; z < sizeZ; ++z) { for (int z = 0; z < sizeZ; ++z) {
NBTTagCompound cpt = nbtContents.getCompoundTagAt(index); NBTTagCompound cpt = nbtContents.getCompoundTagAt(index);
index++; index++;
contents[x][y][z] = new BptSlot();
int blockId = cpt.getInteger("blockId");
contents[x][y][z] = BlueprintManager.newSchematic(mapping.getBlockForId(blockId));
contents[x][y][z].readFromNBT(cpt, mapping); contents[x][y][z].readFromNBT(cpt, mapping);
} }
} }

View file

@ -11,6 +11,8 @@ package buildcraft.core.blueprints;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.MappingRegistry; import buildcraft.api.blueprints.MappingRegistry;
import buildcraft.builders.blueprints.BlueprintId; import buildcraft.builders.blueprints.BlueprintId;
import buildcraft.core.Box; import buildcraft.core.Box;
@ -21,7 +23,7 @@ import buildcraft.core.utils.BCLog;
public abstract class BlueprintBase { public abstract class BlueprintBase {
@NetworkData @NetworkData
public BptSlot contents[][][]; public BptBlock contents[][][];
@NetworkData @NetworkData
public int anchorX, anchorY, anchorZ; public int anchorX, anchorY, anchorZ;
@ -45,7 +47,7 @@ public abstract class BlueprintBase {
} }
public BlueprintBase(int sizeX, int sizeY, int sizeZ) { public BlueprintBase(int sizeX, int sizeY, int sizeZ) {
contents = new BptSlot[sizeX][sizeY][sizeZ]; contents = new BptBlock[sizeX][sizeY][sizeZ];
this.sizeX = sizeX; this.sizeX = sizeX;
this.sizeY = sizeY; this.sizeY = sizeY;
@ -58,7 +60,7 @@ public abstract class BlueprintBase {
public void setBlock(int x, int y, int z, Block block) { 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] = BlueprintManager.newSchematic(block);
contents[x][y][z].x = x; contents[x][y][z].x = x;
contents[x][y][z].y = y; contents[x][y][z].y = y;
contents[x][y][z].z = z; contents[x][y][z].z = z;
@ -68,7 +70,7 @@ public abstract class BlueprintBase {
} }
public void rotateLeft(BptContext context) { public void rotateLeft(BptContext context) {
BptSlot newContents[][][] = new BptSlot[sizeZ][sizeY][sizeX]; BptBlock newContents[][][] = new BptBlock[sizeZ][sizeY][sizeX];
for (int x = 0; x < sizeZ; ++x) { for (int x = 0; x < sizeZ; ++x) {
for (int y = 0; y < sizeY; ++y) { for (int y = 0; y < sizeY; ++y) {
@ -159,7 +161,7 @@ public abstract class BlueprintBase {
author = nbt.getString("author"); author = nbt.getString("author");
contents = new BptSlot [sizeX][sizeY][sizeZ]; contents = new BptBlock [sizeX][sizeY][sizeZ];
try { try {
loadContents (nbt); loadContents (nbt);
@ -231,7 +233,7 @@ public abstract class BlueprintBase {
res.id = id; res.id = id;
res.author = author; res.author = author;
res.contents = new BptSlot[sizeX][sizeY][sizeZ]; res.contents = new BptBlock[sizeX][sizeY][sizeZ];
res.mapping = mapping.clone (); res.mapping = mapping.clone ();

View file

@ -1,15 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.blueprints;
import buildcraft.api.blueprints.BptSlotInfo;
public class BptActionBuild extends BptSlotInfo {
}

View file

@ -10,6 +10,7 @@ package buildcraft.core.blueprints;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World; import net.minecraft.world.World;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.IAreaProvider;
import buildcraft.core.Box; import buildcraft.core.Box;
import buildcraft.core.IBuilderInventory; import buildcraft.core.IBuilderInventory;
@ -34,7 +35,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
context = bluePrint.getContext(world, box); context = bluePrint.getContext(world, box);
} }
public abstract BptSlot getNextBlock(World world, IBuilderInventory inv); public abstract BptBlock getNextBlock(World world, IBuilderInventory inv);
@Override @Override
public int xMin() { public int xMin() {

View file

@ -18,19 +18,20 @@ import java.util.Map.Entry;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType; import net.minecraft.world.WorldSettings.GameType;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptBlock.Mode;
import buildcraft.api.core.StackKey; import buildcraft.api.core.StackKey;
import buildcraft.core.IBuilderInventory; import buildcraft.core.IBuilderInventory;
import buildcraft.core.blueprints.BptSlot.Mode;
import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BCLog;
import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.BlockUtil;
public class BptBuilderBlueprint extends BptBuilderBase { public class BptBuilderBlueprint extends BptBuilderBase {
LinkedList<BptSlot> clearList = new LinkedList<BptSlot>(); LinkedList<BptBlock> clearList = new LinkedList<BptBlock>();
LinkedList<BptSlot> primaryList = new LinkedList<BptSlot>(); LinkedList<BptBlock> primaryList = new LinkedList<BptBlock>();
LinkedList<BptSlot> secondaryList = new LinkedList<BptSlot>(); LinkedList<BptBlock> secondaryList = new LinkedList<BptBlock>();
LinkedList<BptSlot> postProcessingList = new LinkedList<BptSlot>(); LinkedList<BptBlock> postProcessingList = new LinkedList<BptBlock>();
public LinkedList <ItemStack> neededItems = new LinkedList <ItemStack> (); public LinkedList <ItemStack> neededItems = new LinkedList <ItemStack> ();
@ -44,12 +45,12 @@ public class BptBuilderBlueprint extends BptBuilderBase {
int yCoord = j + y - bluePrint.anchorY; int yCoord = j + y - bluePrint.anchorY;
int zCoord = k + z - bluePrint.anchorZ; int zCoord = k + z - bluePrint.anchorZ;
BptSlot slot = bluePrint.contents[i][j][k]; BptBlock slot = bluePrint.contents[i][j][k];
if (slot != null) { if (slot != null) {
slot = slot.clone(); slot = slot.clone();
} else { } else {
slot = new BptSlot(); slot = new BptBlock();
slot.meta = 0; slot.meta = 0;
slot.block = null; slot.block = null;
} }
@ -73,12 +74,12 @@ public class BptBuilderBlueprint extends BptBuilderBase {
int yCoord = j + y - bluePrint.anchorY; int yCoord = j + y - bluePrint.anchorY;
int zCoord = k + z - bluePrint.anchorZ; int zCoord = k + z - bluePrint.anchorZ;
BptSlot slot = bluePrint.contents[i][j][k]; BptBlock slot = bluePrint.contents[i][j][k];
if (slot != null) { if (slot != null) {
slot = slot.clone(); slot = slot.clone();
} else { } else {
slot = new BptSlot(); slot = new BptBlock();
slot.meta = 0; slot.meta = 0;
slot.block = null; slot.block = null;
} }
@ -116,9 +117,9 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} }
@Override @Override
public BptSlot getNextBlock(World world, IBuilderInventory inv) { public BptBlock getNextBlock(World world, IBuilderInventory inv) {
if (clearList.size() != 0) { if (clearList.size() != 0) {
BptSlot slot = internalGetNextBlock(world, inv, clearList); BptBlock slot = internalGetNextBlock(world, inv, clearList);
checkDone(); checkDone();
if (slot != null) { if (slot != null) {
@ -127,7 +128,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} }
if (primaryList.size() != 0) { if (primaryList.size() != 0) {
BptSlot slot = internalGetNextBlock(world, inv, primaryList); BptBlock slot = internalGetNextBlock(world, inv, primaryList);
checkDone(); checkDone();
if (slot != null) { if (slot != null) {
@ -136,7 +137,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} }
if (secondaryList.size() != 0) { if (secondaryList.size() != 0) {
BptSlot slot = internalGetNextBlock(world, inv, secondaryList); BptBlock slot = internalGetNextBlock(world, inv, secondaryList);
checkDone(); checkDone();
if (slot != null) { if (slot != null) {
@ -149,13 +150,13 @@ public class BptBuilderBlueprint extends BptBuilderBase {
return null; return null;
} }
public BptSlot internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<BptSlot> list) { public BptBlock internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<BptBlock> list) {
LinkedList<BptSlot> failSlots = new LinkedList<BptSlot>(); LinkedList<BptBlock> failSlots = new LinkedList<BptBlock>();
BptSlot result = null; BptBlock result = null;
while (list.size() > 0) { while (list.size() > 0) {
BptSlot slot = list.removeFirst(); BptBlock slot = list.removeFirst();
boolean getNext = false; boolean getNext = false;
@ -168,7 +169,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
getNext = false; getNext = false;
} }
if (getNext) if (getNext) {
if (slot.mode == Mode.ClearIfInvalid) { if (slot.mode == Mode.ClearIfInvalid) {
if (!BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)) { if (!BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)) {
result = slot; result = slot;
@ -188,6 +189,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} else { } else {
failSlots.add(slot); failSlots.add(slot);
} }
}
} }
list.addAll(failSlots); list.addAll(failSlots);
@ -195,7 +197,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
return result; return result;
} }
public boolean checkRequirements(IBuilderInventory inv, BptSlot slot) { public boolean checkRequirements(IBuilderInventory inv, BptBlock slot) {
if (slot.block == null) { if (slot.block == null) {
return true; return true;
} }
@ -204,10 +206,11 @@ public class BptBuilderBlueprint extends BptBuilderBase {
LinkedList<ItemStack> tmpInv = new LinkedList<ItemStack>(); LinkedList<ItemStack> tmpInv = new LinkedList<ItemStack>();
try { try {
for (ItemStack stk : slot.getRequirements(context)) for (ItemStack stk : slot.getRequirements(context)) {
if (stk != null) { if (stk != null) {
tmpReq.add(stk.copy()); tmpReq.add(stk.copy());
} }
}
} catch (Throwable t) { } catch (Throwable t) {
// Defensive code against errors in implementers // Defensive code against errors in implementers
t.printStackTrace(); t.printStackTrace();
@ -255,7 +258,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
return true; return true;
} }
public void useRequirements(IBuilderInventory inv, BptSlot slot) { public void useRequirements(IBuilderInventory inv, BptBlock slot) {
if (slot.block == null) { if (slot.block == null) {
return; return;
} }
@ -263,10 +266,11 @@ public class BptBuilderBlueprint extends BptBuilderBase {
LinkedList<ItemStack> tmpReq = new LinkedList<ItemStack>(); LinkedList<ItemStack> tmpReq = new LinkedList<ItemStack>();
try { try {
for (ItemStack stk : slot.getRequirements(context)) for (ItemStack stk : slot.getRequirements(context)) {
if (stk != null) { if (stk != null) {
tmpReq.add(stk.copy()); tmpReq.add(stk.copy());
} }
}
} catch (Throwable t) { } catch (Throwable t) {
// Defensive code against errors in implementers // Defensive code against errors in implementers
t.printStackTrace(); t.printStackTrace();
@ -314,8 +318,9 @@ public class BptBuilderBlueprint extends BptBuilderBase {
}*/ }*/
} }
if (reqStk.stackSize != 0) if (reqStk.stackSize != 0) {
return; return;
}
if (smallStack) { if (smallStack) {
itr.set(usedStack); // set to the actual item used. itr.set(usedStack); // set to the actual item used.
} }
@ -329,7 +334,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
HashMap <StackKey, Integer> computeStacks = new HashMap <StackKey, Integer> (); HashMap <StackKey, Integer> computeStacks = new HashMap <StackKey, Integer> ();
for (BptSlot slot : primaryList) { for (BptBlock slot : primaryList) {
LinkedList<ItemStack> stacks = new LinkedList<ItemStack>(); LinkedList<ItemStack> stacks = new LinkedList<ItemStack>();
@ -360,7 +365,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} }
} }
for (BptSlot slot : secondaryList) { for (BptBlock slot : secondaryList) {
LinkedList<ItemStack> stacks = slot.getRequirements(context); LinkedList<ItemStack> stacks = slot.getRequirements(context);
for (ItemStack stack : stacks) { for (ItemStack stack : stacks) {
@ -409,7 +414,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
@Override @Override
public void postProcessing(World world) { public void postProcessing(World world) {
for (BptSlot s : postProcessingList) { for (BptBlock s : postProcessingList) {
try { try {
s.postProcessing(context); s.postProcessing(context);
} catch (Throwable t) { } catch (Throwable t) {

View file

@ -8,16 +8,17 @@
*/ */
package buildcraft.core.blueprints; package buildcraft.core.blueprints;
import buildcraft.core.IBuilderInventory;
import buildcraft.core.blueprints.BptSlot.Mode;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptBlock.Mode;
import buildcraft.core.IBuilderInventory;
public class BptBuilderTemplate extends BptBuilderBase { public class BptBuilderTemplate extends BptBuilderBase {
LinkedList<BptSlot> clearList = new LinkedList<BptSlot>(); LinkedList<BptBlock> clearList = new LinkedList<BptBlock>();
LinkedList<BptSlot> buildList = new LinkedList<BptSlot>(); LinkedList<BptBlock> buildList = new LinkedList<BptBlock>();
public BptBuilderTemplate(BlueprintBase bluePrint, World world, int x, int y, int z) { public BptBuilderTemplate(BlueprintBase bluePrint, World world, int x, int y, int z) {
super(bluePrint, world, x, y, z); super(bluePrint, world, x, y, z);
@ -29,10 +30,10 @@ public class BptBuilderTemplate extends BptBuilderBase {
int yCoord = j + y - bluePrint.anchorY; int yCoord = j + y - bluePrint.anchorY;
int zCoord = k + z - bluePrint.anchorZ; int zCoord = k + z - bluePrint.anchorZ;
BptSlot slot = bluePrint.contents[i][j][k]; BptBlock slot = bluePrint.contents[i][j][k];
if (slot == null || slot.block == null) { if (slot == null || slot.block == null) {
slot = new BptSlot(); slot = new BptBlock();
slot.meta = 0; slot.meta = 0;
slot.block = null; slot.block = null;
slot.x = xCoord; slot.x = xCoord;
@ -54,12 +55,12 @@ public class BptBuilderTemplate extends BptBuilderBase {
int yCoord = j + y - bluePrint.anchorY; int yCoord = j + y - bluePrint.anchorY;
int zCoord = k + z - bluePrint.anchorZ; int zCoord = k + z - bluePrint.anchorZ;
BptSlot slot = bluePrint.contents[i][j][k]; BptBlock slot = bluePrint.contents[i][j][k];
if (slot != null) { if (slot != null) {
slot = slot.clone(); slot = slot.clone();
} else { } else {
slot = new BptSlot(); slot = new BptBlock();
slot.meta = 0; slot.meta = 0;
slot.block = null; slot.block = null;
} }
@ -87,25 +88,27 @@ public class BptBuilderTemplate extends BptBuilderBase {
} }
@Override @Override
public BptSlot getNextBlock(World world, IBuilderInventory inv) { public BptBlock getNextBlock(World world, IBuilderInventory inv) {
if (clearList.size() != 0) { if (clearList.size() != 0) {
BptSlot slot = internalGetNextBlock(world, inv, clearList); BptBlock slot = internalGetNextBlock(world, inv, clearList);
checkDone(); checkDone();
if (slot != null) if (slot != null) {
return slot; return slot;
else } else {
return null; return null;
}
} }
if (buildList.size() != 0) { if (buildList.size() != 0) {
BptSlot slot = internalGetNextBlock(world, inv, buildList); BptBlock slot = internalGetNextBlock(world, inv, buildList);
checkDone(); checkDone();
if (slot != null) if (slot != null) {
return slot; return slot;
else } else {
return null; return null;
}
} }
checkDone(); checkDone();
@ -113,11 +116,11 @@ public class BptBuilderTemplate extends BptBuilderBase {
return null; return null;
} }
public BptSlot internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<BptSlot> list) { public BptBlock internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<BptBlock> list) {
BptSlot result = null; BptBlock result = null;
while (list.size() > 0) { while (list.size() > 0) {
BptSlot slot = list.getFirst(); BptBlock slot = list.getFirst();
// Note from CJ: I have no idea what this code is supposed to do, so I'm not touching it. // Note from CJ: I have no idea what this code is supposed to do, so I'm not touching it.
/*if (slot.blockId == world.getBlockId(slot.x, slot.y, slot.z)) { /*if (slot.blockId == world.getBlockId(slot.x, slot.y, slot.z)) {

View file

@ -1,38 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.blueprints;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
public class BptItem {
public void addRequirements(BptSlotInfo slot, LinkedList<ItemStack> requirements) {
}
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
}
public void buildBlock(BptSlotInfo slot, IBptContext context) {
}
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) {
}
public void postProcessing(BptSlotInfo slot, IBptContext context) {
}
}

View file

@ -1,139 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.blueprints;
import java.util.ArrayList;
import java.util.LinkedList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import buildcraft.api.blueprints.BlueprintManager;
import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext;
import buildcraft.api.blueprints.MappingRegistry;
import buildcraft.core.utils.Utils;
public class BptSlot extends BptSlotInfo {
public enum Mode {
ClearIfInvalid, Build
};
public Mode mode = Mode.Build;
public ItemStack stackToUse;
BptBlock bptBlock = null;
public boolean isValid(IBptContext context) {
return getBpt().isValid(this, context);
}
public void rotateLeft(IBptContext context) {
getBpt().rotateLeft(this, context);
}
public boolean ignoreBuilding() {
return getBpt().ignoreBuilding(this);
}
public void initializeFromWorld(IBptContext context, int xs, int ys, int zs) {
getBpt().initializeFromWorld(this, context, xs, ys, zs);
}
public void postProcessing(IBptContext context) {
getBpt().postProcessing(this, context);
}
public LinkedList<ItemStack> getRequirements(IBptContext context) {
LinkedList<ItemStack> res = new LinkedList<ItemStack>();
getBpt().addRequirements(this, context, res);
return res;
}
public final void buildBlock(IBptContext context) {
getBpt ().buildBlock(this, context);
}
// returns what was used
public ItemStack useItem(IBptContext context, ItemStack req, ItemStack stack) {
return getBpt().useItem(this, context, req, stack);
}
@SuppressWarnings("unchecked")
@Override
public BptSlot clone() {
BptSlot obj = new BptSlot();
obj.x = x;
obj.y = y;
obj.z = z;
obj.block = block;
obj.meta = meta;
obj.cpt = (NBTTagCompound) cpt.copy();
obj.storedRequirements = (ArrayList<ItemStack>) storedRequirements.clone();
if (stackToUse != null) {
obj.stackToUse = stackToUse.copy();
}
obj.mode = mode;
return obj;
}
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
nbt.setInteger("blockId", registry.getIdForBlock(block));
nbt.setInteger("blockMeta", meta);
nbt.setTag("blockCpt", cpt);
NBTTagList rq = new NBTTagList();
for (ItemStack stack : storedRequirements) {
NBTTagCompound sub = new NBTTagCompound();
stack.writeToNBT(stack.writeToNBT(sub));
sub.setInteger("id", Item.itemRegistry.getIDForObject(registry
.getItemForId(sub.getInteger("id"))));
rq.appendTag(sub);
}
nbt.setTag("rq", rq);
}
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
block = registry.getBlockForId(nbt.getInteger("blockId"));
meta = nbt.getInteger("blockMeta");
cpt = nbt.getCompoundTag("blockCpt");
NBTTagList rq = nbt.getTagList("rq", Utils.NBTTag_Types.NBTTagList.ordinal());
for (int i = 0; i < rq.tagCount(); ++i) {
NBTTagCompound sub = rq.getCompoundTagAt(i);
// Maps the id in the blueprint to the id in the world
sub.setInteger("id", Item.itemRegistry.getIDForObject(registry
.getItemForId(sub.getInteger("id"))));
storedRequirements.add(ItemStack.loadItemStackFromNBT(sub));
}
}
public BptBlock getBpt () {
if (bptBlock == null) {
bptBlock = BlueprintManager.getBptBlock(block);
}
return bptBlock;
}
}

View file

@ -8,41 +8,35 @@
*/ */
package buildcraft.energy; package buildcraft.energy;
import net.minecraft.block.Block;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockEngine extends BptBlock { public class BptBlockEngine extends BptBlock {
public BptBlockEngine(Block block) {
super(block);
}
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
int o = slot.cpt.getInteger("orientation"); int o = cpt.getInteger("orientation");
o = ForgeDirection.values()[o].getRotation(ForgeDirection.DOWN).ordinal(); o = ForgeDirection.values()[o].getRotation(ForgeDirection.DOWN).ordinal();
slot.cpt.setInteger("orientation", o); cpt.setInteger("orientation", o);
} }
@Override @Override
public void initializeFromWorld(BptSlotInfo bptSlot, IBptContext context, int x, int y, int z) { public void initializeFromWorld(IBptContext context, int x, int y, int z) {
TileEngine engine = (TileEngine) context.world().getTileEntity(x, y, z); TileEngine engine = (TileEngine) context.world().getTileEntity(x, y, z);
bptSlot.cpt.setInteger("orientation", engine.orientation.ordinal()); cpt.setInteger("orientation", engine.orientation.ordinal());
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1); context.world().setBlock(x, y, z, block, meta,1);
TileEngine engine = (TileEngine) context.world().getTileEntity(slot.x, slot.y, slot.z); TileEngine engine = (TileEngine) context.world().getTileEntity(x, y, z);
engine.orientation = ForgeDirection.getOrientation(slot.cpt.getInteger("orientation")); engine.orientation = ForgeDirection.getOrientation(cpt.getInteger("orientation"));
} }
} }

View file

@ -10,41 +10,35 @@ package buildcraft.factory;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptBlockUtils; import buildcraft.api.blueprints.BptBlockUtils;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockAutoWorkbench extends BptBlock { public class BptBlockAutoWorkbench extends BptBlock {
public BptBlockAutoWorkbench(Block block) { @Override
super(block); public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
super.addRequirements(context, requirements);
BptBlockUtils.requestInventoryContents(this, context, requirements);
} }
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void initializeFromWorld(IBptContext context, int x, int y, int z) {
super.addRequirements(slot, context, requirements);
BptBlockUtils.requestInventoryContents(slot, context, requirements);
}
@Override
public void initializeFromWorld(BptSlotInfo bptSlot, IBptContext context, int x, int y, int z) {
IInventory inventory = (IInventory) context.world().getTileEntity(x, y, z); IInventory inventory = (IInventory) context.world().getTileEntity(x, y, z);
BptBlockUtils.initializeInventoryContents(bptSlot, context, inventory); BptBlockUtils.initializeInventoryContents(this, context, inventory);
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
super.buildBlock(slot, context); super.buildBlock(context);
IInventory inventory = (IInventory) context.world().getTileEntity(slot.x, slot.y, slot.z); IInventory inventory = (IInventory) context.world().getTileEntity(x, y, z);
BptBlockUtils.buildInventoryContents(slot, context, inventory); BptBlockUtils.buildInventoryContents(this, context, inventory);
} }
} }

View file

@ -10,20 +10,14 @@ package buildcraft.factory;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockFrame extends BptBlock { public class BptBlockFrame extends BptBlock {
public BptBlockFrame(Block block) {
super(block);
}
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
} }

View file

@ -8,25 +8,19 @@
*/ */
package buildcraft.factory; package buildcraft.factory;
import net.minecraft.block.Block;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockRefinery extends BptBlock { public class BptBlockRefinery extends BptBlock {
public BptBlockRefinery(Block block) { @Override
super(block); public void rotateLeft(IBptContext context) {
meta = ForgeDirection.values()[meta].getRotation(ForgeDirection.DOWN).ordinal();
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void initializeFromWorld(IBptContext context, int x, int y, int z) {
slot.meta = ForgeDirection.values()[slot.meta].getRotation(ForgeDirection.DOWN).ordinal();
}
@Override
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) {
TileRefinery refinery = (TileRefinery) context.world().getTileEntity(x, y, z); TileRefinery refinery = (TileRefinery) context.world().getTileEntity(x, y, z);
// slot.cpt.setInteger("filter0", refinery.getFilter(0)); // slot.cpt.setInteger("filter0", refinery.getFilter(0));
@ -34,21 +28,21 @@ public class BptBlockRefinery extends BptBlock {
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
super.buildBlock(slot, context); super.buildBlock(context);
TileRefinery refinery = (TileRefinery) context.world().getTileEntity(slot.x, slot.y, slot.z); TileRefinery refinery = (TileRefinery) context.world().getTileEntity(x, y, z);
int filter0 = slot.cpt.getInteger("filter0"); int filter0 = cpt.getInteger("filter0");
int filter1 = slot.cpt.getInteger("filter1"); int filter1 = cpt.getInteger("filter1");
int filterMeta0 = 0; int filterMeta0 = 0;
int filterMeta1 = 0; int filterMeta1 = 0;
if (slot.cpt.hasKey("filterMeta0")) { if (cpt.hasKey("filterMeta0")) {
filterMeta0 = slot.cpt.getInteger("filterMeta0"); filterMeta0 = cpt.getInteger("filterMeta0");
} }
if (slot.cpt.hasKey("filterMeta1")) { if (cpt.hasKey("filterMeta1")) {
filterMeta1 = slot.cpt.getInteger("filterMeta1"); filterMeta1 = cpt.getInteger("filterMeta1");
} }
// refinery.setFilter(0, filter0, filterMeta0); // refinery.setFilter(0, filter0, filterMeta0);

View file

@ -8,25 +8,19 @@
*/ */
package buildcraft.factory; package buildcraft.factory;
import net.minecraft.block.Block;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptBlockTank extends BptBlock { public class BptBlockTank extends BptBlock {
public BptBlockTank(Block block) {
super(block);
}
@Override @Override
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) { public void initializeFromWorld(IBptContext context, int x, int y, int z) {
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1); context.world().setBlock(x, y, z, block, meta, 3);
} }
} }

View file

@ -10,12 +10,10 @@ package buildcraft.transport.blueprints;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.BptSlotInfo;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.BlockGenericPipe;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
@ -23,84 +21,80 @@ import buildcraft.transport.TileGenericPipe.SideProperties;
public class BptBlockPipe extends BptBlock { public class BptBlockPipe extends BptBlock {
public BptBlockPipe(Block block) {
super(block);
}
@Override @Override
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) { public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
Item pipeItem = context.getMappingRegistry().getItemForId (slot.cpt.getInteger("pipeId")); Item pipeItem = context.getMappingRegistry().getItemForId (cpt.getInteger("pipeId"));
requirements.add(new ItemStack(pipeItem)); requirements.add(new ItemStack(pipeItem));
requirements.addAll(slot.storedRequirements); requirements.addAll(storedRequirements);
} }
@Override @Override
public boolean isValid(BptSlotInfo slot, IBptContext context) { public boolean isValid(IBptContext context) {
Pipe pipe = BlockGenericPipe.getPipe(context.world(), slot.x, slot.y, slot.z); Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z);
if (BlockGenericPipe.isValid(pipe)) { if (BlockGenericPipe.isValid(pipe)) {
return pipe.item == context.getMappingRegistry().getItemForId( return pipe.item == context.getMappingRegistry().getItemForId(
slot.cpt.getInteger("pipeId")); cpt.getInteger("pipeId"));
} else { } else {
return false; return false;
} }
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(IBptContext context) {
SideProperties props = new SideProperties (); SideProperties props = new SideProperties ();
props.readFromNBT(slot.cpt); props.readFromNBT(cpt);
props.rotateLeft(); props.rotateLeft();
props.writeToNBT(slot.cpt); props.writeToNBT(cpt);
Item pipeItem = context.getMappingRegistry().getItemForId(slot.cpt.getInteger("pipeId")); Item pipeItem = context.getMappingRegistry().getItemForId(cpt.getInteger("pipeId"));
if (BptPipeExtension.contains(pipeItem)) { if (BptPipeExtension.contains(pipeItem)) {
BptPipeExtension.get(pipeItem).rotateLeft(slot, context); BptPipeExtension.get(pipeItem).rotateLeft(this, context);
} }
} }
@Override @Override
public void buildBlock(BptSlotInfo slot, IBptContext context) { public void buildBlock(IBptContext context) {
slot.cpt.setInteger("x", slot.x); cpt.setInteger("x", x);
slot.cpt.setInteger("y", slot.y); cpt.setInteger("y", y);
slot.cpt.setInteger("z", slot.z); cpt.setInteger("z", z);
slot.cpt.setInteger( cpt.setInteger(
"pipeId", "pipeId",
Item.getIdFromItem(context.getMappingRegistry().getItemForId( Item.getIdFromItem(context.getMappingRegistry().getItemForId(
slot.cpt.getInteger("pipeId")))); cpt.getInteger("pipeId"))));
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta, 3); context.world().setBlock(x, y, z, block, meta, 3);
TileEntity tile = context.world().getTileEntity(slot.x, slot.y, slot.z); TileEntity tile = context.world().getTileEntity(x, y, z);
tile.readFromNBT(slot.cpt); tile.readFromNBT(cpt);
} }
@Override @Override
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) { public void initializeFromWorld(IBptContext context, int x, int y, int z) {
TileEntity tile = context.world().getTileEntity(x, y, z); TileEntity tile = context.world().getTileEntity(x, y, z);
Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z); Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z);
if (BlockGenericPipe.isValid(pipe)) { if (BlockGenericPipe.isValid(pipe)) {
slot.storedRequirements.addAll(pipe.computeItemDrop ()); storedRequirements.addAll(pipe.computeItemDrop ());
tile.writeToNBT(slot.cpt); tile.writeToNBT(cpt);
// This overrides the default pipeId // This overrides the default pipeId
slot.cpt.setInteger("pipeId", context.getMappingRegistry() cpt.setInteger("pipeId", context.getMappingRegistry()
.getIdForItem(pipe.item)); .getIdForItem(pipe.item));
} }
} }
@Override @Override
public void postProcessing(BptSlotInfo slot, IBptContext context) { public void postProcessing(IBptContext context) {
Item pipeItem = context.getMappingRegistry().getItemForId(slot.cpt.getInteger("pipeId")); Item pipeItem = context.getMappingRegistry().getItemForId(cpt.getInteger("pipeId"));
if (BptPipeExtension.contains(pipeItem)) { if (BptPipeExtension.contains(pipeItem)) {
BptPipeExtension.get(pipeItem).postProcessing(slot, context); BptPipeExtension.get(pipeItem).postProcessing(this, context);
} }
} }
} }

View file

@ -10,7 +10,7 @@ package buildcraft.transport.blueprints;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.inventory.SimpleInventory;
@ -22,7 +22,7 @@ public class BptItemPipeFilters extends BptPipeExtension {
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(BptBlock slot, IBptContext context) {
SimpleInventory inv = new SimpleInventory(54, "Filters", 1); SimpleInventory inv = new SimpleInventory(54, "Filters", 1);
SimpleInventory newInv = new SimpleInventory(54, "Filters", 1); SimpleInventory newInv = new SimpleInventory(54, "Filters", 1);
inv.readFromNBT(slot.cpt); inv.readFromNBT(slot.cpt);

View file

@ -3,7 +3,7 @@ package buildcraft.transport.blueprints;
import java.util.HashMap; import java.util.HashMap;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptPipeExtension { public class BptPipeExtension {
@ -14,11 +14,11 @@ public class BptPipeExtension {
bptPipeExtensionRegistry.put(i, this); bptPipeExtensionRegistry.put(i, this);
} }
public void postProcessing(BptSlotInfo slot, IBptContext context) { public void postProcessing(BptBlock slot, IBptContext context) {
} }
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(BptBlock slot, IBptContext context) {
} }

View file

@ -10,7 +10,7 @@ package buildcraft.transport.blueprints;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptPipeIron extends BptPipeExtension { public class BptPipeIron extends BptPipeExtension {
@ -20,7 +20,7 @@ public class BptPipeIron extends BptPipeExtension {
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(BptBlock slot, IBptContext context) {
int orientation = slot.meta & 7; int orientation = slot.meta & 7;
int others = slot.meta - orientation; int others = slot.meta - orientation;

View file

@ -10,7 +10,7 @@ package buildcraft.transport.blueprints;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.BptBlock;
import buildcraft.api.blueprints.IBptContext; import buildcraft.api.blueprints.IBptContext;
public class BptPipeWooden extends BptPipeExtension { public class BptPipeWooden extends BptPipeExtension {
@ -20,7 +20,7 @@ public class BptPipeWooden extends BptPipeExtension {
} }
@Override @Override
public void rotateLeft(BptSlotInfo slot, IBptContext context) { public void rotateLeft(BptBlock slot, IBptContext context) {
int orientation = slot.meta & 7; int orientation = slot.meta & 7;
int others = slot.meta - orientation; int others = slot.meta - orientation;