add builder support for most of the blocks in the factory module, fixes #2430

This commit is contained in:
Hea3veN 2015-02-04 23:48:18 -03:00
parent 2f2b2f638e
commit 76e01f1005
4 changed files with 92 additions and 3 deletions

View file

@ -324,6 +324,7 @@ public class BuildCraftBuilders extends BuildCraftMod {
schemes.registerSchematicBlock(Blocks.furnace, SchematicRotateMeta.class, new int[]{2, 5, 3, 4}, true);
schemes.registerSchematicBlock(Blocks.lit_furnace, SchematicRotateMeta.class, new int[]{2, 5, 3, 4}, true);
schemes.registerSchematicBlock(Blocks.chest, SchematicRotateMeta.class, new int[]{2, 5, 3, 4}, true);
schemes.registerSchematicBlock(Blocks.trapped_chest, SchematicRotateMeta.class, new int[]{2, 5, 3, 4}, true);
schemes.registerSchematicBlock(Blocks.dispenser, SchematicRotateMeta.class, new int[]{2, 5, 3, 4}, true);
schemes.registerSchematicBlock(Blocks.dropper, SchematicRotateMeta.class, new int[]{2, 5, 3, 4}, true);

View file

@ -37,6 +37,7 @@ import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import buildcraft.api.blueprints.BuilderAPI;
import buildcraft.api.blueprints.SchematicTile;
import buildcraft.builders.schematics.SchematicIgnoreMeta;
import buildcraft.compat.CompatHooks;
import buildcraft.core.DefaultProps;
@ -68,9 +69,10 @@ import buildcraft.factory.TileQuarry;
import buildcraft.factory.TileRefinery;
import buildcraft.factory.TileTank;
import buildcraft.factory.network.PacketHandlerFactory;
import buildcraft.factory.schematics.SchematicAutoWorkbench;
import buildcraft.factory.schematics.SchematicPump;
import buildcraft.factory.schematics.SchematicRefinery;
import buildcraft.factory.schematics.SchematicTank;
import buildcraft.factory.schematics.SchematicTileIgnoreState;
@Mod(name = "BuildCraft Factory", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Factory", dependencies = DefaultProps.DEPENDENCY_CORE)
public class BuildCraftFactory extends BuildCraftMod {
@ -160,9 +162,13 @@ public class BuildCraftFactory extends BuildCraftMod {
FactoryProxy.proxy.initializeTileEntities();
BuilderAPI.schematicRegistry.registerSchematicBlock(refineryBlock, SchematicRefinery.class);
BuilderAPI.schematicRegistry.registerSchematicBlock(tankBlock, SchematicTank.class);
BuilderAPI.schematicRegistry.registerSchematicBlock(tankBlock, SchematicTileIgnoreState.class);
BuilderAPI.schematicRegistry.registerSchematicBlock(frameBlock, SchematicIgnoreMeta.class);
BuilderAPI.schematicRegistry.registerSchematicBlock(pumpBlock, SchematicPump.class);
BuilderAPI.schematicRegistry.registerSchematicBlock(miningWellBlock, SchematicTileIgnoreState.class);
BuilderAPI.schematicRegistry.registerSchematicBlock(floodGateBlock, SchematicTileIgnoreState.class);
BuilderAPI.schematicRegistry.registerSchematicBlock(autoWorkbenchBlock, SchematicAutoWorkbench.class);
BuilderAPI.schematicRegistry.registerSchematicBlock(hopperBlock, SchematicTile.class);
if (BuildCraftCore.loadDefaultRecipes) {
loadRecipes();

View file

@ -0,0 +1,82 @@
/**
* 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.factory.schematics;
import java.util.ArrayList;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftFactory;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicTile;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.core.JavaTools;
import buildcraft.core.inventory.InventoryIterator;
import buildcraft.factory.TileAutoWorkbench;
public class SchematicAutoWorkbench extends SchematicTile {
@Override
public void storeRequirements(IBuilderContext context, int x, int y, int z) {
TileAutoWorkbench autoWb = getTile(context, x, y, z);
if (autoWb != null) {
ArrayList<ItemStack> rqs = new ArrayList<ItemStack>();
rqs.add(new ItemStack(BuildCraftFactory.autoWorkbenchBlock));
for (IInvSlot slot : InventoryIterator.getIterable(autoWb.craftMatrix, ForgeDirection.UP)) {
ItemStack stack = slot.getStackInSlot();
if (stack != null) {
stack = stack.copy();
stack.stackSize = 1;
rqs.add(stack);
}
}
storedRequirements = JavaTools.concat(storedRequirements, rqs
.toArray(new ItemStack[rqs.size()]));
}
}
@Override
public void initializeFromObjectAt(IBuilderContext context, int x, int y, int z) {
super.initializeFromObjectAt(context, x, y, z);
tileNBT.removeTag("Items");
}
@Override
public void placeInWorld(IBuilderContext context, int x, int y, int z, LinkedList<ItemStack> stacks) {
super.placeInWorld(context, x, y, z, stacks);
TileAutoWorkbench autoWb = getTile(context, x, y, z);
if (autoWb != null) {
for (IInvSlot slot : InventoryIterator.getIterable(autoWb.craftMatrix, ForgeDirection.UP)) {
ItemStack stack = slot.getStackInSlot();
if (stack != null) {
stack.stackSize = 1;
}
}
}
}
@Override
public BuildingStage getBuildStage() {
return BuildingStage.STANDALONE;
}
private TileAutoWorkbench getTile(IBuilderContext context, int x, int y, int z) {
TileEntity tile = context.world().getTileEntity(x, y, z);
if (tile != null && tile instanceof TileAutoWorkbench) {
return (TileAutoWorkbench) tile;
}
return null;
}
}

View file

@ -15,7 +15,7 @@ import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicTile;
public class SchematicTank extends SchematicTile {
public class SchematicTileIgnoreState extends SchematicTile {
@Override
public void getRequirementsForPlacement(IBuilderContext context, LinkedList<ItemStack> requirements) {