migrated model of blueprint support, now slot-specific instead of block-type-specific
This commit is contained in:
parent
ed0834c04e
commit
8a7b612402
53 changed files with 547 additions and 872 deletions
|
@ -17,9 +17,9 @@ import net.minecraftforge.client.event.TextureStitchEvent;
|
|||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.api.bptblocks.BptBlockBed;
|
||||
import buildcraft.api.bptblocks.BptBlockCustomStack;
|
||||
import buildcraft.api.bptblocks.BptBlockDelegate;
|
||||
import buildcraft.api.bptblocks.BptBlockDirt;
|
||||
import buildcraft.api.bptblocks.BptBlockDoor;
|
||||
import buildcraft.api.bptblocks.BptBlockFluid;
|
||||
|
@ -141,86 +141,85 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
|||
// Register save handler
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandlerBuilders());
|
||||
|
||||
new BptBlockIgnore(Blocks.snow);
|
||||
new BptBlockIgnore(Blocks.tallgrass);
|
||||
new BptBlockIgnore(Blocks.ice);
|
||||
new BptBlockIgnore(Blocks.piston_head);
|
||||
BlueprintManager.registerSchematicClass(Blocks.snow, BptBlockIgnore.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.tallgrass, BptBlockIgnore.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.ice, BptBlockIgnore.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.piston_head, BptBlockIgnore.class);
|
||||
|
||||
new BptBlockDirt(Blocks.dirt);
|
||||
new BptBlockDirt(Blocks.grass);
|
||||
new BptBlockDirt(Blocks.farmland);
|
||||
BlueprintManager.registerSchematicClass(Blocks.dirt, BptBlockDirt.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.grass, BptBlockDirt.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.farmland, BptBlockDirt.class);
|
||||
|
||||
new BptBlockDelegate(Blocks.unlit_redstone_torch, Blocks.redstone_torch);
|
||||
new BptBlockDelegate(Blocks.lit_furnace, Blocks.furnace);
|
||||
new BptBlockDelegate(Blocks.piston_extension, Blocks.piston);
|
||||
BlueprintManager.registerSchematicClass(Blocks.torch, BptBlockWallSide.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.redstone_torch, BptBlockWallSide.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.unlit_redstone_torch, BptBlockWallSide.class);
|
||||
|
||||
new BptBlockWallSide(Blocks.torch);
|
||||
new BptBlockWallSide(Blocks.redstone_torch);
|
||||
BlueprintManager.registerSchematicClass(Blocks.ladder, BptBlockRotateMeta.class, new int[]{2, 5, 3, 4}, true);
|
||||
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);
|
||||
new BptBlockRotateMeta(Blocks.fence_gate, new int[]{0, 1, 2, 3}, true);
|
||||
BlueprintManager.registerSchematicClass(Blocks.furnace, BptBlockRotateInventory.class, new int[]{2, 5, 3, 4}, 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);
|
||||
new BptBlockRotateInventory(Blocks.chest, new int[]{2, 5, 3, 4}, true);
|
||||
new BptBlockRotateInventory(Blocks.dispenser, new int[]{2, 5, 3, 4}, true);
|
||||
BlueprintManager.registerSchematicClass(Blocks.brewing_stand, BptBlockInventory.class);
|
||||
|
||||
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);
|
||||
new BptBlockRotateMeta(Blocks.trapdoor, new int[]{0, 1, 2, 3}, false);
|
||||
BlueprintManager.registerSchematicClass(Blocks.wooden_button, BptBlockLever.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.stone_button, BptBlockLever.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.lever, BptBlockLever.class);
|
||||
|
||||
new BptBlockLever(Blocks.wooden_button);
|
||||
new BptBlockLever(Blocks.stone_button);
|
||||
new BptBlockLever(Blocks.lever);
|
||||
|
||||
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));
|
||||
BlueprintManager.registerSchematicClass(Blocks.stone, BptBlockCustomStack.class, new ItemStack(Blocks.stone));
|
||||
BlueprintManager.registerSchematicClass(Blocks.redstone_wire, BptBlockCustomStack.class, new ItemStack(Items.redstone));
|
||||
BlueprintManager.registerSchematicClass(Blocks.cake, BptBlockCustomStack.class, new ItemStack(Items.cake));
|
||||
//new BptBlockCustomStack(Blocks.crops.blockID, new ItemStack(Items.seeds));
|
||||
new BptBlockCustomStack(Blocks.pumpkin_stem, new ItemStack(Items.pumpkin_seeds));
|
||||
new BptBlockCustomStack(Blocks.melon_stem, new ItemStack(Items.melon_seeds));
|
||||
new BptBlockCustomStack(Blocks.glowstone, new ItemStack(Blocks.glowstone));
|
||||
BlueprintManager.registerSchematicClass(Blocks.pumpkin_stem, BptBlockCustomStack.class, new ItemStack(Items.pumpkin_seeds));
|
||||
BlueprintManager.registerSchematicClass(Blocks.melon_stem, BptBlockCustomStack.class, new ItemStack(Items.melon_seeds));
|
||||
BlueprintManager.registerSchematicClass(Blocks.glowstone, BptBlockCustomStack.class, new ItemStack(Blocks.glowstone));
|
||||
|
||||
new BptBlockRedstoneRepeater(Blocks.powered_repeater);
|
||||
new BptBlockRedstoneRepeater(Blocks.unpowered_repeater);
|
||||
BlueprintManager.registerSchematicClass(Blocks.powered_repeater, BptBlockRedstoneRepeater.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.unpowered_repeater, BptBlockRedstoneRepeater.class);
|
||||
|
||||
new BptBlockFluid(Blocks.water, new ItemStack(Items.water_bucket));
|
||||
new BptBlockFluid(Blocks.flowing_water, new ItemStack(Items.water_bucket));
|
||||
new BptBlockFluid(Blocks.lava, new ItemStack(Items.lava_bucket));
|
||||
new BptBlockFluid(Blocks.flowing_lava, new ItemStack(Items.lava_bucket));
|
||||
BlueprintManager.registerSchematicClass(Blocks.water, BptBlockFluid.class, new ItemStack(Items.water_bucket));
|
||||
BlueprintManager.registerSchematicClass(Blocks.flowing_water, BptBlockFluid.class, new ItemStack(Items.water_bucket));
|
||||
BlueprintManager.registerSchematicClass(Blocks.lava, BptBlockFluid.class, new ItemStack(Items.lava_bucket));
|
||||
BlueprintManager.registerSchematicClass(Blocks.flowing_lava, BptBlockFluid.class, new ItemStack(Items.lava_bucket));
|
||||
|
||||
new BptBlockIgnoreMeta(Blocks.rail);
|
||||
new BptBlockIgnoreMeta(Blocks.detector_rail);
|
||||
new BptBlockIgnoreMeta(Blocks.glass_pane);
|
||||
BlueprintManager.registerSchematicClass(Blocks.rail, BptBlockIgnoreMeta.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.detector_rail, BptBlockIgnoreMeta.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.glass_pane, BptBlockIgnoreMeta.class);
|
||||
|
||||
new BptBlockPiston(Blocks.piston);
|
||||
new BptBlockPiston(Blocks.sticky_piston);
|
||||
BlueprintManager.registerSchematicClass(Blocks.piston, BptBlockPiston.class);
|
||||
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);
|
||||
new BptBlockStairs(Blocks.oak_stairs);
|
||||
new BptBlockStairs(Blocks.nether_brick_stairs);
|
||||
new BptBlockStairs(Blocks.brick_stairs);
|
||||
new BptBlockStairs(Blocks.stone_brick_stairs);
|
||||
BlueprintManager.registerSchematicClass(Blocks.stone_stairs, BptBlockStairs.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.oak_stairs, BptBlockStairs.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.nether_brick_stairs, BptBlockStairs.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.brick_stairs, BptBlockStairs.class);
|
||||
BlueprintManager.registerSchematicClass(Blocks.stone_brick_stairs, BptBlockStairs.class);
|
||||
|
||||
new BptBlockDoor(Blocks.wooden_button, new ItemStack(Items.wooden_door));
|
||||
new BptBlockDoor(Blocks.iron_door, new ItemStack(Items.iron_door));
|
||||
BlueprintManager.registerSchematicClass(Blocks.wooden_button, BptBlockDoor.class, new ItemStack(Items.wooden_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);
|
||||
new BptBlockSign(Blocks.standing_sign, false);
|
||||
BlueprintManager.registerSchematicClass(Blocks.wall_sign, BptBlockSign.class, true);
|
||||
BlueprintManager.registerSchematicClass(Blocks.standing_sign, BptBlockSign.class, false);
|
||||
|
||||
// BUILDCRAFT BLOCKS
|
||||
|
||||
new BptBlockRotateInventory(architectBlock, new int[]{2, 5, 3, 4}, true);
|
||||
new BptBlockRotateInventory(builderBlock, new int[]{2, 5, 3, 4}, true);
|
||||
BlueprintManager.registerSchematicClass(architectBlock, BptBlockRotateInventory.class, 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);
|
||||
new BptBlockWallSide(pathMarkerBlock);
|
||||
BlueprintManager.registerSchematicClass(markerBlock, BptBlockWallSide.class);
|
||||
BlueprintManager.registerSchematicClass(pathMarkerBlock, BptBlockWallSide.class);
|
||||
|
||||
if (BuildCraftCore.loadDefaultRecipes) {
|
||||
loadRecipes();
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.minecraftforge.fluids.Fluid;
|
|||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.api.fuels.IronEngineCoolant;
|
||||
import buildcraft.api.fuels.IronEngineFuel;
|
||||
import buildcraft.api.recipes.BuildcraftRecipes;
|
||||
|
@ -250,7 +251,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
new BptBlockEngine(engineBlock);
|
||||
BlueprintManager.registerSchematicClass(engineBlock, BptBlockEngine.class);
|
||||
|
||||
if (BuildCraftCore.loadDefaultRecipes) {
|
||||
loadRecipes();
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
|||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.InterModComms;
|
||||
import buildcraft.core.Version;
|
||||
|
@ -145,10 +146,10 @@ public class BuildCraftFactory extends BuildCraftMod {
|
|||
|
||||
FactoryProxy.proxy.initializeTileEntities();
|
||||
|
||||
new BptBlockAutoWorkbench(autoWorkbenchBlock);
|
||||
new BptBlockFrame(frameBlock);
|
||||
new BptBlockRefinery(refineryBlock);
|
||||
new BptBlockTank(tankBlock);
|
||||
BlueprintManager.registerSchematicClass(autoWorkbenchBlock, BptBlockAutoWorkbench.class);
|
||||
BlueprintManager.registerSchematicClass(frameBlock, BptBlockFrame.class);
|
||||
BlueprintManager.registerSchematicClass(refineryBlock, BptBlockRefinery.class);
|
||||
BlueprintManager.registerSchematicClass(tankBlock, BptBlockTank.class);
|
||||
|
||||
if (BuildCraftCore.loadDefaultRecipes) {
|
||||
loadRecipes();
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.api.bptblocks.BptBlockInventory;
|
||||
import buildcraft.api.bptblocks.BptBlockRotateMeta;
|
||||
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(TileIntegrationTable.class, "net.minecraft.src.buildcraft.factory.TileIntegrationTable");
|
||||
|
||||
new BptBlockRotateMeta(laserBlock, new int[]{2, 5, 3, 4}, true);
|
||||
new BptBlockInventory(assemblyTableBlock);
|
||||
BlueprintManager.registerSchematicClass(laserBlock, BptBlockRotateMeta.class, new int[]{2, 5, 3, 4}, true);
|
||||
BlueprintManager.registerSchematicClass(assemblyTableBlock, BptBlockInventory.class);
|
||||
|
||||
if (BuildCraftCore.loadDefaultRecipes) {
|
||||
loadRecipes();
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraftforge.common.config.Configuration;
|
|||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.GateExpansions;
|
||||
|
@ -429,7 +430,7 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
|
||||
TransportProxy.proxy.registerTileEntities();
|
||||
|
||||
new BptBlockPipe(genericPipeBlock);
|
||||
BlueprintManager.registerSchematicClass(genericPipeBlock, BptBlockPipe.class);
|
||||
|
||||
new BptPipeIron(pipeItemsIron);
|
||||
new BptPipeIron(pipeFluidsIron);
|
||||
|
|
|
@ -8,23 +8,54 @@
|
|||
*/
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class BlueprintManager {
|
||||
|
||||
private static final HashMap <Block, BptBlock> bptBlockRegistry = new HashMap<Block, BptBlock>();
|
||||
|
||||
public static void registerBptBlock (Block block, BptBlock bptBlock) {
|
||||
bptBlockRegistry.put(block, bptBlock);
|
||||
private static class SchematicConstructor {
|
||||
Class clas;
|
||||
Object [] params;
|
||||
}
|
||||
|
||||
public static BptBlock getBptBlock (Block block) {
|
||||
if (!bptBlockRegistry.containsKey(block)) {
|
||||
registerBptBlock(block, new BptBlock(block));
|
||||
private static final HashMap <Block, SchematicConstructor> schematicClasses =
|
||||
new HashMap<Block, SchematicConstructor>();
|
||||
|
||||
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
146
common/buildcraft/api/blueprints/BptBlock.java
Normal file → Executable file
|
@ -16,7 +16,11 @@ import net.minecraft.block.BlockContainer;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
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
|
||||
|
@ -53,24 +57,72 @@ import net.minecraft.tileentity.TileEntity;
|
|||
*/
|
||||
public class BptBlock {
|
||||
|
||||
public final Block block;
|
||||
@NetworkData
|
||||
public Block block = null;
|
||||
|
||||
public BptBlock(Block block) {
|
||||
this.block = block;
|
||||
BlueprintManager.registerBptBlock(block, this);
|
||||
@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();
|
||||
|
||||
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
|
||||
* requirements are met, they will be removed all at once from the builder,
|
||||
* before calling buildBlock.
|
||||
*/
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if (slot.block != null) {
|
||||
if (slot.storedRequirements.size() != 0) {
|
||||
requirements.addAll(slot.storedRequirements);
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if (block != null) {
|
||||
if (storedRequirements.size() != 0) {
|
||||
requirements.addAll(storedRequirements);
|
||||
} 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
|
||||
* 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();
|
||||
if (stack.isItemStackDamageable()) {
|
||||
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
|
||||
* subprogram is permissive and doesn't take into account metadata.
|
||||
*/
|
||||
public boolean isValid(BptSlotInfo slot, 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);
|
||||
public boolean isValid(IBptContext context) {
|
||||
return block == context.world().getBlock(x, y, z) && meta == context.world().getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
public void buildBlock(IBptContext context) {
|
||||
// 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);
|
||||
|
||||
if (slot.block instanceof BlockContainer) {
|
||||
TileEntity tile = context.world().getTileEntity(slot.x, slot.y, slot.z);
|
||||
if (block instanceof BlockContainer) {
|
||||
TileEntity tile = context.world().getTileEntity(x, y, z);
|
||||
|
||||
slot.cpt.setInteger("x", slot.x);
|
||||
slot.cpt.setInteger("y", slot.y);
|
||||
slot.cpt.setInteger("z", slot.z);
|
||||
cpt.setInteger("x", x);
|
||||
cpt.setInteger("y", y);
|
||||
cpt.setInteger("z", z);
|
||||
|
||||
if (tile != null) {
|
||||
tile.readFromNBT(slot.cpt);
|
||||
tile.readFromNBT(cpt);
|
||||
}
|
||||
|
||||
// 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
|
||||
* will not be asked on such a block, and building will not be called.
|
||||
*/
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
public boolean ignoreBuilding() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -188,21 +240,21 @@ public class BptBlock {
|
|||
* By default, if the block is a BlockContainer, tile information will be to
|
||||
* save / load the block.
|
||||
*/
|
||||
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) {
|
||||
if (slot.block instanceof BlockContainer) {
|
||||
public void initializeFromWorld(IBptContext context, int x, int y, int z) {
|
||||
if (block instanceof BlockContainer) {
|
||||
TileEntity tile = context.world().getTileEntity(x, y, z);
|
||||
|
||||
if (tile != null) {
|
||||
tile.writeToNBT(slot.cpt);
|
||||
tile.writeToNBT(cpt);
|
||||
}
|
||||
}
|
||||
|
||||
if (slot.block != null) {
|
||||
ArrayList<ItemStack> req = slot.block.getDrops(context.world(), x,
|
||||
if (block != null) {
|
||||
ArrayList<ItemStack> req = block.getDrops(context.world(), x,
|
||||
y, z, context.world().getBlockMetadata(x, y, z), 0);
|
||||
|
||||
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 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) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.nbt.NBTTagList;
|
|||
|
||||
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);
|
||||
|
||||
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()];
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
|
@ -37,7 +37,7 @@ public class BptBlockUtils {
|
|||
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);
|
||||
|
||||
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");
|
||||
|
||||
if (list == null)
|
||||
if (list == null) {
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
ItemStack stacks[] = new ItemStack[list.tagCount()];
|
||||
|
||||
|
@ -64,14 +65,12 @@ public class BptBlockUtils {
|
|||
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();
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
for (ItemStack stack : stacks) {
|
||||
NBTTagCompound cpt = new NBTTagCompound();
|
||||
nbttaglist.appendTag(cpt);
|
||||
ItemStack stack = stacks[i];
|
||||
|
||||
if (stack != null && stack.stackSize != 0) {
|
||||
stack.writeToNBT(cpt);
|
||||
//context.storeId(stack.itemID);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,59 +10,53 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockBed extends BptBlock {
|
||||
|
||||
public BptBlockBed(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if ((slot.meta & 8) == 0) {
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if ((meta & 8) == 0) {
|
||||
requirements.add(new ItemStack(Items.bed));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int orientation = (slot.meta & 7);
|
||||
int others = slot.meta - orientation;
|
||||
public void rotateLeft(IBptContext context) {
|
||||
int orientation = (meta & 7);
|
||||
int others = meta - orientation;
|
||||
|
||||
switch (orientation) {
|
||||
case 0:
|
||||
slot.meta = 1 + others;
|
||||
meta = 1 + others;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2 + others;
|
||||
meta = 2 + others;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3 + others;
|
||||
meta = 3 + others;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0 + others;
|
||||
meta = 0 + others;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
if ((slot.meta & 8) != 0) {
|
||||
public void buildBlock(IBptContext context) {
|
||||
if ((meta & 8) != 0) {
|
||||
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 z2 = slot.z;
|
||||
int x2 = x;
|
||||
int z2 = z;
|
||||
|
||||
switch (slot.meta) {
|
||||
switch (meta) {
|
||||
case 0:
|
||||
z2++;
|
||||
break;
|
||||
|
@ -77,11 +71,11 @@ public class BptBlockBed extends BptBlock {
|
|||
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
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return (slot.meta & 8) != 0;
|
||||
public boolean ignoreBuilding() {
|
||||
return (meta & 8) != 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,24 +10,20 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockCustomStack extends BptBlock {
|
||||
|
||||
final ItemStack customStack;
|
||||
|
||||
public BptBlockCustomStack(Block block, ItemStack customStack) {
|
||||
super(block);
|
||||
|
||||
public BptBlockCustomStack(ItemStack customStack) {
|
||||
this.customStack = customStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(customStack.copy());
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -14,28 +14,23 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockDirt extends BptBlock {
|
||||
|
||||
public BptBlockDirt(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, Blocks.dirt, slot.meta,1);
|
||||
public void buildBlock(IBptContext context) {
|
||||
context.world().setBlock(x, y, z, Blocks.dirt, meta, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
Block block = context.world().getBlock(slot.x, slot.y, slot.z);
|
||||
public boolean isValid(IBptContext context) {
|
||||
Block block = context.world().getBlock(x, y, z);
|
||||
|
||||
return block == Blocks.dirt || block == Blocks.grass || block == Blocks.farmland;
|
||||
}
|
||||
|
|
|
@ -10,62 +10,58 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockDoor extends BptBlock {
|
||||
|
||||
final ItemStack stack;
|
||||
|
||||
public BptBlockDoor(Block block, ItemStack stack) {
|
||||
super(block);
|
||||
|
||||
public BptBlockDoor(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if ((slot.meta & 8) == 0) {
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if ((meta & 8) == 0) {
|
||||
requirements.add(stack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int orientation = (slot.meta & 3);
|
||||
int others = slot.meta - orientation;
|
||||
public void rotateLeft(IBptContext context) {
|
||||
int orientation = (meta & 3);
|
||||
int others = meta - orientation;
|
||||
|
||||
switch (orientation) {
|
||||
case 0:
|
||||
slot.meta = 1 + others;
|
||||
meta = 1 + others;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2 + others;
|
||||
meta = 2 + others;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3 + others;
|
||||
meta = 3 + others;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0 + others;
|
||||
meta = 0 + others;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return (slot.meta & 8) != 0;
|
||||
public boolean ignoreBuilding() {
|
||||
return (meta & 8) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1);
|
||||
context.world().setBlock(slot.x, slot.y + 1, slot.z, slot.block, slot.meta + 8,1);
|
||||
public void buildBlock(IBptContext context) {
|
||||
context.world().setBlock(x, y, z, block, meta, 3);
|
||||
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(slot.x, slot.y, slot.z, slot.meta,1);
|
||||
context.world().setBlockMetadataWithNotify(x, y + 1, z, meta + 8, 3);
|
||||
context.world().setBlockMetadataWithNotify(x, y, z, meta, 3);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,52 +10,48 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockFluid extends BptBlock {
|
||||
|
||||
private final ItemStack bucketStack;
|
||||
|
||||
public BptBlockFluid(Block block, ItemStack bucketStack) {
|
||||
super(block);
|
||||
|
||||
public BptBlockFluid(ItemStack bucketStack) {
|
||||
this.bucketStack = bucketStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if (slot.meta == 0) {
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if (meta == 0) {
|
||||
requirements.add(bucketStack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
if (slot.meta == 0) {
|
||||
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z) && context.world().getBlockMetadata(slot.x, slot.y, slot.z) == 0;
|
||||
public boolean isValid(IBptContext context) {
|
||||
if (meta == 0) {
|
||||
return block == context.world().getBlock(x, y, z) && context.world().getBlockMetadata(x, y, z) == 0;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
public void rotateLeft(IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return slot.meta != 0;
|
||||
public boolean ignoreBuilding() {
|
||||
return meta != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
if (slot.meta == 0) {
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, 0,1);
|
||||
public void buildBlock(IBptContext context) {
|
||||
if (meta == 0) {
|
||||
context.world().setBlock(x, y, z, block, 0,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,35 +10,29 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockIgnore extends BptBlock {
|
||||
|
||||
public BptBlockIgnore(Block block) {
|
||||
super(block);
|
||||
@Override
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(block, 0, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.block, 0, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
public boolean isValid(IBptContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
public void rotateLeft(IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
public boolean ignoreBuilding() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,25 +10,19 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockIgnoreMeta extends BptBlock {
|
||||
|
||||
public BptBlockIgnoreMeta(Block block) {
|
||||
super(block);
|
||||
@Override
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z);
|
||||
public boolean isValid(IBptContext context) {
|
||||
return block == context.world().getBlock(x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,24 +8,17 @@
|
|||
*/
|
||||
package buildcraft.api.bptblocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockInventory extends BptBlock {
|
||||
|
||||
public BptBlockInventory(Block block) {
|
||||
super(block);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
super.buildBlock(slot, context);
|
||||
public void buildBlock(IBptContext 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) {
|
||||
inv.setInventorySlotContents(i, null);
|
||||
|
|
|
@ -10,29 +10,23 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockLever extends BptBlockWallSide {
|
||||
|
||||
public BptBlockLever(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int status = slot.meta - (slot.meta & 7);
|
||||
public void rotateLeft(IBptContext context) {
|
||||
int status = meta - (meta & 7);
|
||||
|
||||
slot.meta -= status;
|
||||
super.rotateLeft(slot, context);
|
||||
slot.meta += status;
|
||||
meta -= status;
|
||||
super.rotateLeft(context);
|
||||
meta += status;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,21 +8,19 @@
|
|||
*/
|
||||
package buildcraft.api.bptblocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockPiston extends BptBlockRotateMeta {
|
||||
|
||||
public BptBlockPiston(Block block) {
|
||||
super(block, new int[] { 2, 5, 3, 4 }, true);
|
||||
public BptBlockPiston() {
|
||||
super(new int[] { 2, 5, 3, 4 }, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
int meta = slot.meta & 7;
|
||||
public void buildBlock(IBptContext context) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,42 +10,36 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockPumpkin extends BptBlock {
|
||||
|
||||
public BptBlockPumpkin(Block block) {
|
||||
super(block);
|
||||
@Override
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
public boolean isValid(IBptContext context) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
switch (slot.meta) {
|
||||
public void rotateLeft(IBptContext context) {
|
||||
switch (meta) {
|
||||
case 0:
|
||||
slot.meta = 1;
|
||||
meta = 1;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2;
|
||||
meta = 2;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3;
|
||||
meta = 3;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0;
|
||||
meta = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,40 +10,34 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockRedstoneRepeater extends BptBlock {
|
||||
|
||||
public BptBlockRedstoneRepeater(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int step = slot.meta - (slot.meta & 3);
|
||||
public void rotateLeft(IBptContext context) {
|
||||
int step = meta - (meta & 3);
|
||||
|
||||
switch (slot.meta - step) {
|
||||
switch (meta - step) {
|
||||
case 0:
|
||||
slot.meta = 1 + step;
|
||||
meta = 1 + step;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2 + step;
|
||||
meta = 2 + step;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3 + step;
|
||||
meta = 3 + step;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0 + step;
|
||||
meta = 0 + step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,24 +8,21 @@
|
|||
*/
|
||||
package buildcraft.api.bptblocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
@Deprecated
|
||||
public class BptBlockRotateInventory extends BptBlockRotateMeta {
|
||||
|
||||
public BptBlockRotateInventory(Block block, int[] rotations, boolean rotateForward) {
|
||||
super(block, rotations, rotateForward);
|
||||
public BptBlockRotateInventory(int[] rotations, boolean rotateForward) {
|
||||
super(rotations, rotateForward);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
super.buildBlock(slot, context);
|
||||
public void buildBlock(IBptContext 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) {
|
||||
inv.setInventorySlotContents(i, null);
|
||||
|
|
|
@ -10,10 +10,8 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockRotateMeta extends BptBlock {
|
||||
|
@ -23,17 +21,15 @@ public class BptBlockRotateMeta extends BptBlock {
|
|||
|
||||
int infoMask = 0;
|
||||
|
||||
public BptBlockRotateMeta(Block block, int[] rotations, boolean rotateForward) {
|
||||
super(block);
|
||||
|
||||
public BptBlockRotateMeta(int[] rotations, boolean rotateForward) {
|
||||
rot = rotations;
|
||||
|
||||
for (int i = 0; i < rot.length; ++i) {
|
||||
if (rot[i] < 4) {
|
||||
for (int element : rot) {
|
||||
if (element < 4) {
|
||||
infoMask = (infoMask < 3 ? 3 : infoMask);
|
||||
} else if (rot[i] < 8) {
|
||||
} else if (element < 8) {
|
||||
infoMask = (infoMask < 7 ? 7 : infoMask);
|
||||
} else if (rot[i] < 16) {
|
||||
} else if (element < 16) {
|
||||
infoMask = (infoMask < 15 ? 15 : infoMask);
|
||||
}
|
||||
}
|
||||
|
@ -42,19 +38,19 @@ public class BptBlockRotateMeta extends BptBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.block == context.world().getBlock(slot.x, slot.y, slot.z);
|
||||
public boolean isValid(IBptContext context) {
|
||||
return block == context.world().getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int pos = slot.meta & infoMask;
|
||||
int others = slot.meta - pos;
|
||||
public void rotateLeft(IBptContext context) {
|
||||
int pos = meta & infoMask;
|
||||
int others = meta - pos;
|
||||
|
||||
if (rotateForward) {
|
||||
if (pos == rot[0]) {
|
||||
|
@ -78,7 +74,7 @@ public class BptBlockRotateMeta extends BptBlock {
|
|||
}
|
||||
}
|
||||
|
||||
slot.meta = pos + others;
|
||||
meta = pos + others;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,40 +10,36 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockSign extends BptBlock {
|
||||
|
||||
boolean isWall;
|
||||
|
||||
public BptBlockSign(Block block, boolean isWall) {
|
||||
super(block);
|
||||
|
||||
public BptBlockSign(boolean isWall) {
|
||||
this.isWall = isWall;
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
public void rotateLeft(IBptContext context) {
|
||||
if (!isWall) {
|
||||
double angle = ((slot.meta) * 360.0) / 16.0;
|
||||
double angle = ((meta) * 360.0) / 16.0;
|
||||
angle += 90.0;
|
||||
if (angle >= 360) {
|
||||
angle -= 360;
|
||||
}
|
||||
slot.meta = (int) (angle / 360.0 * 16.0);
|
||||
meta = (int) (angle / 360.0 * 16.0);
|
||||
} else {
|
||||
slot.meta = ForgeDirection.values()[slot.meta].getRotation(ForgeDirection.UP).ordinal();
|
||||
meta = ForgeDirection.values()[meta].getRotation(ForgeDirection.UP).ordinal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,42 +10,36 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockStairs extends BptBlock {
|
||||
|
||||
public BptBlockStairs(Block block) {
|
||||
super(block);
|
||||
@Override
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
public boolean isValid(IBptContext context) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
switch (slot.meta) {
|
||||
public void rotateLeft(IBptContext context) {
|
||||
switch (meta) {
|
||||
case 0:
|
||||
slot.meta = 2;
|
||||
meta = 2;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 3;
|
||||
meta = 3;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 1;
|
||||
meta = 1;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0;
|
||||
meta = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,42 +10,36 @@ package buildcraft.api.bptblocks;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockWallSide extends BptBlock {
|
||||
|
||||
public BptBlockWallSide(Block block) {
|
||||
super(block);
|
||||
@Override
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.block, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
public void rotateLeft(IBptContext context) {
|
||||
final int XPos = 2;
|
||||
final int XNeg = 1;
|
||||
final int ZPos = 4;
|
||||
final int ZNeg = 3;
|
||||
|
||||
switch (slot.meta) {
|
||||
switch (meta) {
|
||||
case XPos:
|
||||
slot.meta = ZPos;
|
||||
meta = ZPos;
|
||||
break;
|
||||
case ZNeg:
|
||||
slot.meta = XPos;
|
||||
meta = XPos;
|
||||
break;
|
||||
case XNeg:
|
||||
slot.meta = ZNeg;
|
||||
meta = ZNeg;
|
||||
break;
|
||||
case ZPos:
|
||||
slot.meta = XNeg;
|
||||
meta = XNeg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
@ -38,7 +39,6 @@ import buildcraft.core.blueprints.BlueprintBase;
|
|||
import buildcraft.core.blueprints.BptBuilderBase;
|
||||
import buildcraft.core.blueprints.BptBuilderBlueprint;
|
||||
import buildcraft.core.blueprints.BptContext;
|
||||
import buildcraft.core.blueprints.BptSlot;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
@ -637,7 +637,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory,
|
|||
|
||||
public void debugForceBlueprintCompletion () {
|
||||
if (bluePrintBuilder != null) {
|
||||
BptSlot slot = bluePrintBuilder.getNextBlock(worldObj, this);
|
||||
BptBlock slot = bluePrintBuilder.getNextBlock(worldObj, this);
|
||||
|
||||
if (slot != null) {
|
||||
slot.buildBlock(bluePrintBuilder.context);
|
||||
|
|
|
@ -12,7 +12,7 @@ import buildcraft.api.builder.BlockHandler;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public final class BlockSchematic extends Schematic {
|
||||
public final class BlockSchematic extends SchematicOld {
|
||||
|
||||
public static BlockSchematic create(NBTTagCompound nbt) {
|
||||
return null;
|
||||
|
|
|
@ -33,7 +33,7 @@ public class BlueprintBuilder implements IAreaProvider {
|
|||
this.y = y - blueprint.anchorY;
|
||||
this.z = translateZ(z, -blueprint.anchorX, -blueprint.anchorZ);
|
||||
builders = new ArrayList<SchematicBuilder>(blueprint.schematicSequence.size());
|
||||
for (Schematic schematic : blueprint.schematicSequence) {
|
||||
for (SchematicOld schematic : blueprint.schematicSequence) {
|
||||
BlockHandler handler = schematic.getHandler();
|
||||
if (handler != null) {
|
||||
builders.add(new SchematicBuilder(schematic, handler));
|
||||
|
@ -107,11 +107,11 @@ public class BlueprintBuilder implements IAreaProvider {
|
|||
|
||||
public class SchematicBuilder {
|
||||
|
||||
public final Schematic schematic;
|
||||
public final SchematicOld schematic;
|
||||
public final BlockHandler handler;
|
||||
private boolean complete;
|
||||
|
||||
private SchematicBuilder(Schematic schematic, BlockHandler handler) {
|
||||
private SchematicBuilder(SchematicOld schematic, BlockHandler handler) {
|
||||
this.schematic = schematic;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import buildcraft.api.builder.BlockHandler;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public final class ItemSchematic extends Schematic {
|
||||
public final class ItemSchematic extends SchematicOld {
|
||||
|
||||
public static ItemSchematic create(NBTTagCompound nbt) {
|
||||
return null;
|
||||
|
|
|
@ -11,7 +11,7 @@ package buildcraft.builders.blueprints;
|
|||
import buildcraft.api.builder.BlockHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public final class MaskSchematic extends Schematic {
|
||||
public final class MaskSchematic extends SchematicOld {
|
||||
|
||||
private static MaskHandler handler = new MaskHandler();
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ public class SchematicBlueprint {
|
|||
public BlueprintMeta meta;
|
||||
|
||||
@NetworkData
|
||||
public Schematic[][][] schematics;
|
||||
public SchematicOld[][][] schematics;
|
||||
|
||||
// TODO: Save this somewhere, this is the sequence in which blocks are
|
||||
// ordered to be build
|
||||
public ArrayList<Schematic> schematicSequence = new ArrayList<Schematic>();
|
||||
public ArrayList<SchematicOld> schematicSequence = new ArrayList<SchematicOld>();
|
||||
|
||||
@NetworkData
|
||||
public int sizeX, sizeY, sizeZ;
|
||||
|
@ -72,7 +72,7 @@ public class SchematicBlueprint {
|
|||
this.sizeY = sizeY;
|
||||
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) {
|
||||
|
@ -82,7 +82,7 @@ public class SchematicBlueprint {
|
|||
this.sizeY = sizeY;
|
||||
this.sizeZ = sizeZ;
|
||||
|
||||
schematics = new Schematic[sizeX][sizeY][sizeZ];
|
||||
schematics = new SchematicOld[sizeX][sizeY][sizeZ];
|
||||
}
|
||||
|
||||
protected SchematicBlueprint(BlueprintMeta meta, NBTTagCompound nbt) {
|
||||
|
@ -100,7 +100,7 @@ public class SchematicBlueprint {
|
|||
|
||||
for (int i = 0; i < blockList.tagCount(); 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;
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class SchematicBlueprint {
|
|||
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.y = y;
|
||||
schematic.z = z;
|
||||
|
@ -151,7 +151,7 @@ public class SchematicBlueprint {
|
|||
BlockHandler handler = BlockHandler.get(block);
|
||||
try {
|
||||
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);
|
||||
setSchematic(x, y, z, schematic);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public class SchematicBlueprint {
|
|||
BlockHandler handler = BlockHandler.get(item.getItem());
|
||||
try {
|
||||
if (handler.canSaveToSchematic(item)) {
|
||||
Schematic schematic = ItemSchematic.create(item.getItem());
|
||||
SchematicOld schematic = ItemSchematic.create(item.getItem());
|
||||
handler.saveToSchematic(item, schematic.data);
|
||||
setSchematic(x, y, z, schematic);
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class SchematicBlueprint {
|
|||
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];
|
||||
}
|
||||
|
||||
|
@ -209,8 +209,8 @@ public class SchematicBlueprint {
|
|||
*
|
||||
* @return List<BlockScematic>
|
||||
*/
|
||||
public LinkedList<Schematic> getBuildList() {
|
||||
LinkedList<Schematic> list = new LinkedList<Schematic>();
|
||||
public LinkedList<SchematicOld> getBuildList() {
|
||||
LinkedList<SchematicOld> list = new LinkedList<SchematicOld>();
|
||||
|
||||
for (int y = 0; y < sizeY; y++) {
|
||||
for (int x = 0; x < sizeX; x++) {
|
||||
|
@ -228,7 +228,7 @@ public class SchematicBlueprint {
|
|||
if (costs != null)
|
||||
return costs;
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
for (Schematic schematic : getBuildList()) {
|
||||
for (SchematicOld schematic : getBuildList()) {
|
||||
BlockHandler handler = BlockHandler.get(schematic.id);
|
||||
List<ItemStack> requirements = handler.getCostForSchematic(schematic.data);
|
||||
for (ItemStack newStack : requirements) {
|
||||
|
|
|
@ -12,7 +12,7 @@ import buildcraft.api.builder.BlockHandler;
|
|||
import buildcraft.core.network.NetworkData;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class Schematic {
|
||||
public abstract class SchematicOld {
|
||||
|
||||
@NetworkData
|
||||
public int id;
|
||||
|
@ -32,11 +32,11 @@ public abstract class Schematic {
|
|||
/**
|
||||
* Only to be class by the serializer
|
||||
*/
|
||||
public Schematic() {
|
||||
public SchematicOld() {
|
||||
|
||||
}
|
||||
|
||||
protected Schematic(int id) {
|
||||
protected SchematicOld(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -56,9 +56,9 @@ public abstract class Schematic {
|
|||
data = nbt.getCompoundTag("data");
|
||||
}
|
||||
|
||||
public static Schematic createSchematicFromNBT(NBTTagCompound nbt) {
|
||||
public static SchematicOld createSchematicFromNBT(NBTTagCompound nbt) {
|
||||
String schematicType = nbt.getString("schematicType");
|
||||
Schematic schematic;
|
||||
SchematicOld schematic;
|
||||
if (schematicType.equals("block")) {
|
||||
schematic = BlockSchematic.create(nbt);
|
||||
} else if (schematicType.equals("item")) {
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -8,12 +8,14 @@
|
|||
*/
|
||||
package buildcraft.core.blueprints;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
import buildcraft.core.IBptContributor;
|
||||
import buildcraft.core.utils.BCLog;
|
||||
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) {
|
||||
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.y = (int) (y - context.surroundingBox().pMin().y);
|
||||
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);
|
||||
|
||||
if (slot.block instanceof BlockContainer) {
|
||||
TileEntity tile = anchorTile.getWorldObj().getTileEntity(x, y, z);
|
||||
|
||||
if (tile != null && tile instanceof IBptContributor) {
|
||||
IBptContributor contributor = (IBptContributor) tile;
|
||||
|
||||
contributor.saveToBluePrint(anchorTile, this, slot);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -91,7 +89,10 @@ public class Blueprint extends BlueprintBase {
|
|||
for (int z = 0; z < sizeZ; ++z) {
|
||||
NBTTagCompound cpt = nbtContents.getCompoundTagAt(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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ package buildcraft.core.blueprints;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.MappingRegistry;
|
||||
import buildcraft.builders.blueprints.BlueprintId;
|
||||
import buildcraft.core.Box;
|
||||
|
@ -21,7 +23,7 @@ import buildcraft.core.utils.BCLog;
|
|||
public abstract class BlueprintBase {
|
||||
|
||||
@NetworkData
|
||||
public BptSlot contents[][][];
|
||||
public BptBlock contents[][][];
|
||||
|
||||
@NetworkData
|
||||
public int anchorX, anchorY, anchorZ;
|
||||
|
@ -45,7 +47,7 @@ public abstract class BlueprintBase {
|
|||
}
|
||||
|
||||
public BlueprintBase(int sizeX, int sizeY, int sizeZ) {
|
||||
contents = new BptSlot[sizeX][sizeY][sizeZ];
|
||||
contents = new BptBlock[sizeX][sizeY][sizeZ];
|
||||
|
||||
this.sizeX = sizeX;
|
||||
this.sizeY = sizeY;
|
||||
|
@ -58,7 +60,7 @@ public abstract class BlueprintBase {
|
|||
|
||||
public void setBlock(int x, int y, int z, Block block) {
|
||||
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].y = y;
|
||||
contents[x][y][z].z = z;
|
||||
|
@ -68,7 +70,7 @@ public abstract class BlueprintBase {
|
|||
}
|
||||
|
||||
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 y = 0; y < sizeY; ++y) {
|
||||
|
@ -159,7 +161,7 @@ public abstract class BlueprintBase {
|
|||
|
||||
author = nbt.getString("author");
|
||||
|
||||
contents = new BptSlot [sizeX][sizeY][sizeZ];
|
||||
contents = new BptBlock [sizeX][sizeY][sizeZ];
|
||||
|
||||
try {
|
||||
loadContents (nbt);
|
||||
|
@ -231,7 +233,7 @@ public abstract class BlueprintBase {
|
|||
res.id = id;
|
||||
res.author = author;
|
||||
|
||||
res.contents = new BptSlot[sizeX][sizeY][sizeZ];
|
||||
res.contents = new BptBlock[sizeX][sizeY][sizeZ];
|
||||
|
||||
res.mapping = mapping.clone ();
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ package buildcraft.core.blueprints;
|
|||
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.core.IAreaProvider;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.IBuilderInventory;
|
||||
|
@ -34,7 +35,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
|||
context = bluePrint.getContext(world, box);
|
||||
}
|
||||
|
||||
public abstract BptSlot getNextBlock(World world, IBuilderInventory inv);
|
||||
public abstract BptBlock getNextBlock(World world, IBuilderInventory inv);
|
||||
|
||||
@Override
|
||||
public int xMin() {
|
||||
|
|
|
@ -18,19 +18,20 @@ import java.util.Map.Entry;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings.GameType;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptBlock.Mode;
|
||||
import buildcraft.api.core.StackKey;
|
||||
import buildcraft.core.IBuilderInventory;
|
||||
import buildcraft.core.blueprints.BptSlot.Mode;
|
||||
import buildcraft.core.utils.BCLog;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
|
||||
public class BptBuilderBlueprint extends BptBuilderBase {
|
||||
|
||||
LinkedList<BptSlot> clearList = new LinkedList<BptSlot>();
|
||||
LinkedList<BptSlot> primaryList = new LinkedList<BptSlot>();
|
||||
LinkedList<BptSlot> secondaryList = new LinkedList<BptSlot>();
|
||||
LinkedList<BptBlock> clearList = new LinkedList<BptBlock>();
|
||||
LinkedList<BptBlock> primaryList = new LinkedList<BptBlock>();
|
||||
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> ();
|
||||
|
||||
|
@ -44,12 +45,12 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
int yCoord = j + y - bluePrint.anchorY;
|
||||
int zCoord = k + z - bluePrint.anchorZ;
|
||||
|
||||
BptSlot slot = bluePrint.contents[i][j][k];
|
||||
BptBlock slot = bluePrint.contents[i][j][k];
|
||||
|
||||
if (slot != null) {
|
||||
slot = slot.clone();
|
||||
} else {
|
||||
slot = new BptSlot();
|
||||
slot = new BptBlock();
|
||||
slot.meta = 0;
|
||||
slot.block = null;
|
||||
}
|
||||
|
@ -73,12 +74,12 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
int yCoord = j + y - bluePrint.anchorY;
|
||||
int zCoord = k + z - bluePrint.anchorZ;
|
||||
|
||||
BptSlot slot = bluePrint.contents[i][j][k];
|
||||
BptBlock slot = bluePrint.contents[i][j][k];
|
||||
|
||||
if (slot != null) {
|
||||
slot = slot.clone();
|
||||
} else {
|
||||
slot = new BptSlot();
|
||||
slot = new BptBlock();
|
||||
slot.meta = 0;
|
||||
slot.block = null;
|
||||
}
|
||||
|
@ -116,9 +117,9 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BptSlot getNextBlock(World world, IBuilderInventory inv) {
|
||||
public BptBlock getNextBlock(World world, IBuilderInventory inv) {
|
||||
if (clearList.size() != 0) {
|
||||
BptSlot slot = internalGetNextBlock(world, inv, clearList);
|
||||
BptBlock slot = internalGetNextBlock(world, inv, clearList);
|
||||
checkDone();
|
||||
|
||||
if (slot != null) {
|
||||
|
@ -127,7 +128,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
}
|
||||
|
||||
if (primaryList.size() != 0) {
|
||||
BptSlot slot = internalGetNextBlock(world, inv, primaryList);
|
||||
BptBlock slot = internalGetNextBlock(world, inv, primaryList);
|
||||
checkDone();
|
||||
|
||||
if (slot != null) {
|
||||
|
@ -136,7 +137,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
}
|
||||
|
||||
if (secondaryList.size() != 0) {
|
||||
BptSlot slot = internalGetNextBlock(world, inv, secondaryList);
|
||||
BptBlock slot = internalGetNextBlock(world, inv, secondaryList);
|
||||
checkDone();
|
||||
|
||||
if (slot != null) {
|
||||
|
@ -149,13 +150,13 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
return null;
|
||||
}
|
||||
|
||||
public BptSlot internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<BptSlot> list) {
|
||||
LinkedList<BptSlot> failSlots = new LinkedList<BptSlot>();
|
||||
public BptBlock internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<BptBlock> list) {
|
||||
LinkedList<BptBlock> failSlots = new LinkedList<BptBlock>();
|
||||
|
||||
BptSlot result = null;
|
||||
BptBlock result = null;
|
||||
|
||||
while (list.size() > 0) {
|
||||
BptSlot slot = list.removeFirst();
|
||||
BptBlock slot = list.removeFirst();
|
||||
|
||||
boolean getNext = false;
|
||||
|
||||
|
@ -168,7 +169,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
getNext = false;
|
||||
}
|
||||
|
||||
if (getNext)
|
||||
if (getNext) {
|
||||
if (slot.mode == Mode.ClearIfInvalid) {
|
||||
if (!BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)) {
|
||||
result = slot;
|
||||
|
@ -188,6 +189,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
} else {
|
||||
failSlots.add(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list.addAll(failSlots);
|
||||
|
@ -195,7 +197,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
return result;
|
||||
}
|
||||
|
||||
public boolean checkRequirements(IBuilderInventory inv, BptSlot slot) {
|
||||
public boolean checkRequirements(IBuilderInventory inv, BptBlock slot) {
|
||||
if (slot.block == null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -204,10 +206,11 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
LinkedList<ItemStack> tmpInv = new LinkedList<ItemStack>();
|
||||
|
||||
try {
|
||||
for (ItemStack stk : slot.getRequirements(context))
|
||||
for (ItemStack stk : slot.getRequirements(context)) {
|
||||
if (stk != null) {
|
||||
tmpReq.add(stk.copy());
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Defensive code against errors in implementers
|
||||
t.printStackTrace();
|
||||
|
@ -255,7 +258,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void useRequirements(IBuilderInventory inv, BptSlot slot) {
|
||||
public void useRequirements(IBuilderInventory inv, BptBlock slot) {
|
||||
if (slot.block == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -263,10 +266,11 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
LinkedList<ItemStack> tmpReq = new LinkedList<ItemStack>();
|
||||
|
||||
try {
|
||||
for (ItemStack stk : slot.getRequirements(context))
|
||||
for (ItemStack stk : slot.getRequirements(context)) {
|
||||
if (stk != null) {
|
||||
tmpReq.add(stk.copy());
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Defensive code against errors in implementers
|
||||
t.printStackTrace();
|
||||
|
@ -314,8 +318,9 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
}*/
|
||||
}
|
||||
|
||||
if (reqStk.stackSize != 0)
|
||||
if (reqStk.stackSize != 0) {
|
||||
return;
|
||||
}
|
||||
if (smallStack) {
|
||||
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> ();
|
||||
|
||||
for (BptSlot slot : primaryList) {
|
||||
for (BptBlock slot : primaryList) {
|
||||
|
||||
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);
|
||||
|
||||
for (ItemStack stack : stacks) {
|
||||
|
@ -409,7 +414,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
|
||||
@Override
|
||||
public void postProcessing(World world) {
|
||||
for (BptSlot s : postProcessingList) {
|
||||
for (BptBlock s : postProcessingList) {
|
||||
try {
|
||||
s.postProcessing(context);
|
||||
} catch (Throwable t) {
|
||||
|
|
|
@ -8,16 +8,17 @@
|
|||
*/
|
||||
package buildcraft.core.blueprints;
|
||||
|
||||
import buildcraft.core.IBuilderInventory;
|
||||
import buildcraft.core.blueprints.BptSlot.Mode;
|
||||
import java.util.LinkedList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
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 {
|
||||
|
||||
LinkedList<BptSlot> clearList = new LinkedList<BptSlot>();
|
||||
LinkedList<BptSlot> buildList = new LinkedList<BptSlot>();
|
||||
LinkedList<BptBlock> clearList = new LinkedList<BptBlock>();
|
||||
LinkedList<BptBlock> buildList = new LinkedList<BptBlock>();
|
||||
|
||||
public BptBuilderTemplate(BlueprintBase bluePrint, World world, int x, int y, int z) {
|
||||
super(bluePrint, world, x, y, z);
|
||||
|
@ -29,10 +30,10 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
|||
int yCoord = j + y - bluePrint.anchorY;
|
||||
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) {
|
||||
slot = new BptSlot();
|
||||
slot = new BptBlock();
|
||||
slot.meta = 0;
|
||||
slot.block = null;
|
||||
slot.x = xCoord;
|
||||
|
@ -54,12 +55,12 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
|||
int yCoord = j + y - bluePrint.anchorY;
|
||||
int zCoord = k + z - bluePrint.anchorZ;
|
||||
|
||||
BptSlot slot = bluePrint.contents[i][j][k];
|
||||
BptBlock slot = bluePrint.contents[i][j][k];
|
||||
|
||||
if (slot != null) {
|
||||
slot = slot.clone();
|
||||
} else {
|
||||
slot = new BptSlot();
|
||||
slot = new BptBlock();
|
||||
slot.meta = 0;
|
||||
slot.block = null;
|
||||
}
|
||||
|
@ -87,25 +88,27 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BptSlot getNextBlock(World world, IBuilderInventory inv) {
|
||||
public BptBlock getNextBlock(World world, IBuilderInventory inv) {
|
||||
if (clearList.size() != 0) {
|
||||
BptSlot slot = internalGetNextBlock(world, inv, clearList);
|
||||
BptBlock slot = internalGetNextBlock(world, inv, clearList);
|
||||
checkDone();
|
||||
|
||||
if (slot != null)
|
||||
if (slot != null) {
|
||||
return slot;
|
||||
else
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (buildList.size() != 0) {
|
||||
BptSlot slot = internalGetNextBlock(world, inv, buildList);
|
||||
BptBlock slot = internalGetNextBlock(world, inv, buildList);
|
||||
checkDone();
|
||||
|
||||
if (slot != null)
|
||||
if (slot != null) {
|
||||
return slot;
|
||||
else
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
checkDone();
|
||||
|
@ -113,11 +116,11 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
|||
return null;
|
||||
}
|
||||
|
||||
public BptSlot internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<BptSlot> list) {
|
||||
BptSlot result = null;
|
||||
public BptBlock internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<BptBlock> list) {
|
||||
BptBlock result = null;
|
||||
|
||||
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.
|
||||
/*if (slot.blockId == world.getBlockId(slot.x, slot.y, slot.z)) {
|
||||
|
|
|
@ -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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -8,41 +8,35 @@
|
|||
*/
|
||||
package buildcraft.energy;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockEngine extends BptBlock {
|
||||
|
||||
public BptBlockEngine(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int o = slot.cpt.getInteger("orientation");
|
||||
public void rotateLeft(IBptContext context) {
|
||||
int o = cpt.getInteger("orientation");
|
||||
|
||||
o = ForgeDirection.values()[o].getRotation(ForgeDirection.DOWN).ordinal();
|
||||
|
||||
slot.cpt.setInteger("orientation", o);
|
||||
cpt.setInteger("orientation", o);
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
bptSlot.cpt.setInteger("orientation", engine.orientation.ordinal());
|
||||
cpt.setInteger("orientation", engine.orientation.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1);
|
||||
public void buildBlock(IBptContext context) {
|
||||
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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,41 +10,35 @@ package buildcraft.factory;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptBlockUtils;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockAutoWorkbench extends BptBlock {
|
||||
|
||||
public BptBlockAutoWorkbench(Block block) {
|
||||
super(block);
|
||||
@Override
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
super.addRequirements(context, requirements);
|
||||
|
||||
BptBlockUtils.requestInventoryContents(this, context, requirements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
super.addRequirements(slot, context, requirements);
|
||||
|
||||
BptBlockUtils.requestInventoryContents(slot, context, requirements);
|
||||
}
|
||||
|
||||
@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) {
|
||||
IInventory inventory = (IInventory) context.world().getTileEntity(x, y, z);
|
||||
|
||||
BptBlockUtils.initializeInventoryContents(bptSlot, context, inventory);
|
||||
BptBlockUtils.initializeInventoryContents(this, context, inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
super.buildBlock(slot, context);
|
||||
public void buildBlock(IBptContext 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,20 +10,14 @@ package buildcraft.factory;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockFrame extends BptBlock {
|
||||
|
||||
public BptBlockFrame(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,25 +8,19 @@
|
|||
*/
|
||||
package buildcraft.factory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockRefinery extends BptBlock {
|
||||
|
||||
public BptBlockRefinery(Block block) {
|
||||
super(block);
|
||||
@Override
|
||||
public void rotateLeft(IBptContext context) {
|
||||
meta = ForgeDirection.values()[meta].getRotation(ForgeDirection.DOWN).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
slot.meta = ForgeDirection.values()[slot.meta].getRotation(ForgeDirection.DOWN).ordinal();
|
||||
}
|
||||
|
||||
@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) {
|
||||
TileRefinery refinery = (TileRefinery) context.world().getTileEntity(x, y, z);
|
||||
|
||||
// slot.cpt.setInteger("filter0", refinery.getFilter(0));
|
||||
|
@ -34,21 +28,21 @@ public class BptBlockRefinery extends BptBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
super.buildBlock(slot, context);
|
||||
public void buildBlock(IBptContext 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 filter1 = slot.cpt.getInteger("filter1");
|
||||
int filter0 = cpt.getInteger("filter0");
|
||||
int filter1 = cpt.getInteger("filter1");
|
||||
int filterMeta0 = 0;
|
||||
int filterMeta1 = 0;
|
||||
|
||||
if (slot.cpt.hasKey("filterMeta0")) {
|
||||
filterMeta0 = slot.cpt.getInteger("filterMeta0");
|
||||
if (cpt.hasKey("filterMeta0")) {
|
||||
filterMeta0 = cpt.getInteger("filterMeta0");
|
||||
}
|
||||
if (slot.cpt.hasKey("filterMeta1")) {
|
||||
filterMeta1 = slot.cpt.getInteger("filterMeta1");
|
||||
if (cpt.hasKey("filterMeta1")) {
|
||||
filterMeta1 = cpt.getInteger("filterMeta1");
|
||||
}
|
||||
|
||||
// refinery.setFilter(0, filter0, filterMeta0);
|
||||
|
|
|
@ -8,25 +8,19 @@
|
|||
*/
|
||||
package buildcraft.factory;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockTank extends BptBlock {
|
||||
|
||||
public BptBlockTank(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@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
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1);
|
||||
public void buildBlock(IBptContext context) {
|
||||
context.world().setBlock(x, y, z, block, meta, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,12 +10,10 @@ package buildcraft.transport.blueprints;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.Pipe;
|
||||
|
@ -23,84 +21,80 @@ import buildcraft.transport.TileGenericPipe.SideProperties;
|
|||
|
||||
public class BptBlockPipe extends BptBlock {
|
||||
|
||||
public BptBlockPipe(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
Item pipeItem = context.getMappingRegistry().getItemForId (slot.cpt.getInteger("pipeId"));
|
||||
public void addRequirements(IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
Item pipeItem = context.getMappingRegistry().getItemForId (cpt.getInteger("pipeId"));
|
||||
|
||||
requirements.add(new ItemStack(pipeItem));
|
||||
|
||||
requirements.addAll(slot.storedRequirements);
|
||||
requirements.addAll(storedRequirements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
Pipe pipe = BlockGenericPipe.getPipe(context.world(), slot.x, slot.y, slot.z);
|
||||
public boolean isValid(IBptContext context) {
|
||||
Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z);
|
||||
|
||||
if (BlockGenericPipe.isValid(pipe)) {
|
||||
return pipe.item == context.getMappingRegistry().getItemForId(
|
||||
slot.cpt.getInteger("pipeId"));
|
||||
cpt.getInteger("pipeId"));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
public void rotateLeft(IBptContext context) {
|
||||
SideProperties props = new SideProperties ();
|
||||
|
||||
props.readFromNBT(slot.cpt);
|
||||
props.readFromNBT(cpt);
|
||||
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)) {
|
||||
BptPipeExtension.get(pipeItem).rotateLeft(slot, context);
|
||||
BptPipeExtension.get(pipeItem).rotateLeft(this, context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
slot.cpt.setInteger("x", slot.x);
|
||||
slot.cpt.setInteger("y", slot.y);
|
||||
slot.cpt.setInteger("z", slot.z);
|
||||
slot.cpt.setInteger(
|
||||
public void buildBlock(IBptContext context) {
|
||||
cpt.setInteger("x", x);
|
||||
cpt.setInteger("y", y);
|
||||
cpt.setInteger("z", z);
|
||||
cpt.setInteger(
|
||||
"pipeId",
|
||||
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);
|
||||
tile.readFromNBT(slot.cpt);
|
||||
TileEntity tile = context.world().getTileEntity(x, y, z);
|
||||
tile.readFromNBT(cpt);
|
||||
}
|
||||
|
||||
@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);
|
||||
Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z);
|
||||
|
||||
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
|
||||
slot.cpt.setInteger("pipeId", context.getMappingRegistry()
|
||||
cpt.setInteger("pipeId", context.getMappingRegistry()
|
||||
.getIdForItem(pipe.item));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessing(BptSlotInfo slot, IBptContext context) {
|
||||
Item pipeItem = context.getMappingRegistry().getItemForId(slot.cpt.getInteger("pipeId"));
|
||||
public void postProcessing(IBptContext context) {
|
||||
Item pipeItem = context.getMappingRegistry().getItemForId(cpt.getInteger("pipeId"));
|
||||
|
||||
if (BptPipeExtension.contains(pipeItem)) {
|
||||
BptPipeExtension.get(pipeItem).postProcessing(slot, context);
|
||||
BptPipeExtension.get(pipeItem).postProcessing(this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ package buildcraft.transport.blueprints;
|
|||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class BptItemPipeFilters extends BptPipeExtension {
|
|||
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
public void rotateLeft(BptBlock slot, IBptContext context) {
|
||||
SimpleInventory inv = new SimpleInventory(54, "Filters", 1);
|
||||
SimpleInventory newInv = new SimpleInventory(54, "Filters", 1);
|
||||
inv.readFromNBT(slot.cpt);
|
||||
|
|
|
@ -3,7 +3,7 @@ package buildcraft.transport.blueprints;
|
|||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptPipeExtension {
|
||||
|
@ -14,11 +14,11 @@ public class BptPipeExtension {
|
|||
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) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ package buildcraft.transport.blueprints;
|
|||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptPipeIron extends BptPipeExtension {
|
||||
|
@ -20,7 +20,7 @@ public class BptPipeIron extends BptPipeExtension {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
public void rotateLeft(BptBlock slot, IBptContext context) {
|
||||
int orientation = slot.meta & 7;
|
||||
int others = slot.meta - orientation;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ package buildcraft.transport.blueprints;
|
|||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptPipeWooden extends BptPipeExtension {
|
||||
|
@ -20,7 +20,7 @@ public class BptPipeWooden extends BptPipeExtension {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
public void rotateLeft(BptBlock slot, IBptContext context) {
|
||||
int orientation = slot.meta & 7;
|
||||
int others = slot.meta - orientation;
|
||||
|
||||
|
|
Loading…
Reference in a new issue