Moved vanilla schematics in a non-API class

(this will allows fixes on minor versions).
Implemented portal support, for #1508.
This commit is contained in:
SpaceToad 2014-03-16 21:05:35 +01:00
parent a1a114feb0
commit 3aeb961a31
26 changed files with 83 additions and 62 deletions

View file

@ -21,23 +21,6 @@ import buildcraft.api.blueprints.SchematicRegistry;
import buildcraft.api.filler.FillerManager; import buildcraft.api.filler.FillerManager;
import buildcraft.api.filler.IFillerPattern; import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.ActionManager;
import buildcraft.api.schematics.SchematicBed;
import buildcraft.api.schematics.SchematicCustomStack;
import buildcraft.api.schematics.SchematicDirt;
import buildcraft.api.schematics.SchematicDoor;
import buildcraft.api.schematics.SchematicFluid;
import buildcraft.api.schematics.SchematicIgnore;
import buildcraft.api.schematics.SchematicIgnoreMeta;
import buildcraft.api.schematics.SchematicInventory;
import buildcraft.api.schematics.SchematicLever;
import buildcraft.api.schematics.SchematicPiston;
import buildcraft.api.schematics.SchematicPumpkin;
import buildcraft.api.schematics.SchematicRedstoneRepeater;
import buildcraft.api.schematics.SchematicRotateInventory;
import buildcraft.api.schematics.SchematicRotateMeta;
import buildcraft.api.schematics.SchematicSign;
import buildcraft.api.schematics.SchematicStairs;
import buildcraft.api.schematics.SchematicWallSide;
import buildcraft.builders.BlockArchitect; import buildcraft.builders.BlockArchitect;
import buildcraft.builders.BlockBlueprintLibrary; import buildcraft.builders.BlockBlueprintLibrary;
import buildcraft.builders.BlockBuilder; import buildcraft.builders.BlockBuilder;
@ -66,6 +49,24 @@ import buildcraft.builders.filler.pattern.PatternFlatten;
import buildcraft.builders.filler.pattern.PatternHorizon; import buildcraft.builders.filler.pattern.PatternHorizon;
import buildcraft.builders.filler.pattern.PatternPyramid; import buildcraft.builders.filler.pattern.PatternPyramid;
import buildcraft.builders.filler.pattern.PatternStairs; import buildcraft.builders.filler.pattern.PatternStairs;
import buildcraft.builders.schematics.SchematicBed;
import buildcraft.builders.schematics.SchematicCustomStack;
import buildcraft.builders.schematics.SchematicDirt;
import buildcraft.builders.schematics.SchematicDoor;
import buildcraft.builders.schematics.SchematicFluid;
import buildcraft.builders.schematics.SchematicIgnore;
import buildcraft.builders.schematics.SchematicIgnoreMeta;
import buildcraft.builders.schematics.SchematicInventory;
import buildcraft.builders.schematics.SchematicLever;
import buildcraft.builders.schematics.SchematicPiston;
import buildcraft.builders.schematics.SchematicPortal;
import buildcraft.builders.schematics.SchematicPumpkin;
import buildcraft.builders.schematics.SchematicRedstoneRepeater;
import buildcraft.builders.schematics.SchematicRotateInventory;
import buildcraft.builders.schematics.SchematicRotateMeta;
import buildcraft.builders.schematics.SchematicSign;
import buildcraft.builders.schematics.SchematicStairs;
import buildcraft.builders.schematics.SchematicWallSide;
import buildcraft.builders.triggers.ActionFiller; import buildcraft.builders.triggers.ActionFiller;
import buildcraft.builders.triggers.BuildersActionProvider; import buildcraft.builders.triggers.BuildersActionProvider;
import buildcraft.builders.urbanism.BlockUrbanist; import buildcraft.builders.urbanism.BlockUrbanist;
@ -197,7 +198,6 @@ public class BuildCraftBuilders extends BuildCraftMod {
SchematicRegistry.registerSchematicClass(Blocks.lit_pumpkin, SchematicPumpkin.class); SchematicRegistry.registerSchematicClass(Blocks.lit_pumpkin, SchematicPumpkin.class);
SchematicRegistry.registerSchematicClass(Blocks.oak_stairs, SchematicStairs.class); SchematicRegistry.registerSchematicClass(Blocks.oak_stairs, SchematicStairs.class);
SchematicRegistry.registerSchematicClass(Blocks.stone_stairs, SchematicStairs.class); SchematicRegistry.registerSchematicClass(Blocks.stone_stairs, SchematicStairs.class);
SchematicRegistry.registerSchematicClass(Blocks.brick_stairs, SchematicStairs.class); SchematicRegistry.registerSchematicClass(Blocks.brick_stairs, SchematicStairs.class);
@ -219,6 +219,8 @@ public class BuildCraftBuilders extends BuildCraftMod {
SchematicRegistry.registerSchematicClass(Blocks.wall_sign, SchematicSign.class, true); SchematicRegistry.registerSchematicClass(Blocks.wall_sign, SchematicSign.class, true);
SchematicRegistry.registerSchematicClass(Blocks.standing_sign, SchematicSign.class, false); SchematicRegistry.registerSchematicClass(Blocks.standing_sign, SchematicSign.class, false);
SchematicRegistry.registerSchematicClass(Blocks.portal, SchematicPortal.class);
// BUILDCRAFT BLOCKS // BUILDCRAFT BLOCKS
SchematicRegistry.registerSchematicClass(architectBlock, SchematicRotateInventory.class, new int[]{2, 5, 3, 4}, true); SchematicRegistry.registerSchematicClass(architectBlock, SchematicRotateInventory.class, new int[]{2, 5, 3, 4}, true);

View file

@ -17,9 +17,9 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.blueprints.SchematicRegistry;
import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.api.recipes.BuildcraftRecipes;
import buildcraft.api.schematics.SchematicInventory;
import buildcraft.api.schematics.SchematicRotateMeta;
import buildcraft.api.transport.PipeWire; import buildcraft.api.transport.PipeWire;
import buildcraft.builders.schematics.SchematicInventory;
import buildcraft.builders.schematics.SchematicRotateMeta;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms; import buildcraft.core.InterModComms;
import buildcraft.core.Version; import buildcraft.core.Version;

View file

@ -170,7 +170,7 @@ public class Schematic {
* blocks. This may be useful to adjust variable depending on surrounding * blocks. This may be useful to adjust variable depending on surrounding
* blocks that may not be there already at initial building. * blocks that may not be there already at initial building.
*/ */
public void postProcessing(IBuilderContext context) { public void postProcessing(IBuilderContext context, int x, int y, int z) {
} }
@ -181,5 +181,4 @@ public class Schematic {
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) { public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
} }
} }

View file

@ -172,16 +172,6 @@ public class SchematicBlock extends Schematic {
} }
} }
/**
* Called on a block when the blueprint has finished to place all the
* blocks. This may be useful to adjust variable depending on surrounding
* blocks that may not be there already at initial building.
*/
@Override
public void postProcessing(IBuilderContext context) {
}
@Override @Override
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) { public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
nbt.setInteger("blockId", registry.getIdForBlock(block)); nbt.setInteger("blockId", registry.getIdForBlock(block));

View file

@ -1,3 +0,0 @@
@API(apiVersion="1.0",owner="BuildCraftAPI|blueprints",provides="BuildCraftAPI|bptblocks")
package buildcraft.api.schematics;
import cpw.mods.fml.common.API;

View file

@ -679,6 +679,9 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IM
slot.schematic.writeToWorld(bluePrintBuilder.context, slot.x, slot.schematic.writeToWorld(bluePrintBuilder.context, slot.x,
slot.y, slot.z); slot.y, slot.z);
} }
} else {
bluePrintBuilder.postProcessing(worldObj);
bluePrintBuilder = null;
} }
if (bluePrintBuilder instanceof BptBuilderBlueprint) { if (bluePrintBuilder instanceof BptBuilderBlueprint) {

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.IBuilderContext;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.IBuilderContext;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.IBuilderContext;

View file

@ -0,0 +1,33 @@
/**
* 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.builders.schematics;
import java.util.LinkedList;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicBlock;
public class SchematicPortal extends SchematicBlock {
@Override
public void addRequirements(IBuilderContext context, LinkedList<ItemStack> requirements) {
}
@Override
public void writeToWorld(IBuilderContext context, int x, int y, int z) {
}
@Override
public void postProcessing(IBuilderContext context, int x, int y, int z) {
context.world().setBlock(x, y, z, Blocks.portal);
}
}

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.IBuilderContext;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
package buildcraft.api.schematics; package buildcraft.builders.schematics;
import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.IBuilderContext;
import buildcraft.api.blueprints.SchematicBlock; import buildcraft.api.blueprints.SchematicBlock;

View file

@ -33,8 +33,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
LinkedList<SchematicToBuild> clearList = new LinkedList<SchematicToBuild>(); LinkedList<SchematicToBuild> clearList = new LinkedList<SchematicToBuild>();
LinkedList<SchematicToBuild> primaryList = new LinkedList<SchematicToBuild>(); LinkedList<SchematicToBuild> primaryList = new LinkedList<SchematicToBuild>();
LinkedList<SchematicToBuild> secondaryList = new LinkedList<SchematicToBuild>(); LinkedList<SchematicToBuild> secondaryList = new LinkedList<SchematicToBuild>();
LinkedList<SchematicToBuild> postProcessing = new LinkedList<SchematicToBuild>();
LinkedList<SchematicToBuild> postProcessingList = new LinkedList<SchematicToBuild>();
public LinkedList <ItemStack> neededItems = new LinkedList <ItemStack> (); public LinkedList <ItemStack> neededItems = new LinkedList <ItemStack> ();
@ -96,10 +95,6 @@ public class BptBuilderBlueprint extends BptBuilderBase {
} else { } else {
secondaryList.add(b); secondaryList.add(b);
} }
if (slot.block != null) {
postProcessingList.add(b);
}
} }
} }
} }
@ -133,6 +128,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
checkDone(); checkDone();
if (slot != null) { if (slot != null) {
postProcessing.add(slot);
return slot; return slot;
} }
} }
@ -142,6 +138,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
checkDone(); checkDone();
if (slot != null) { if (slot != null) {
postProcessing.add(slot);
return slot; return slot;
} }
} }
@ -151,7 +148,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
return null; return null;
} }
public SchematicToBuild internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<SchematicToBuild> list) { private SchematicToBuild internalGetNextBlock(World world, IBuilderInventory inv, LinkedList<SchematicToBuild> list) {
LinkedList<SchematicToBuild> failSlots = new LinkedList<SchematicToBuild>(); LinkedList<SchematicToBuild> failSlots = new LinkedList<SchematicToBuild>();
SchematicToBuild result = null; SchematicToBuild result = null;
@ -442,9 +439,9 @@ public class BptBuilderBlueprint extends BptBuilderBase {
@Override @Override
public void postProcessing(World world) { public void postProcessing(World world) {
for (SchematicToBuild s : postProcessingList) { for (SchematicToBuild s : postProcessing) {
try { try {
s.schematic.postProcessing(context); s.schematic.postProcessing(context, s.x, s.y, s.z);
} catch (Throwable t) { } catch (Throwable t) {
// Defensive code against errors in implementers // Defensive code against errors in implementers
t.printStackTrace(); t.printStackTrace();

View file

@ -85,7 +85,7 @@ public class SchematicPipe extends SchematicTile {
} }
@Override @Override
public void postProcessing(IBuilderContext context) { public void postProcessing(IBuilderContext context, int x, int y, int z) {
Item pipeItem = context.getMappingRegistry().getItemForId(cpt.getInteger("pipeId")); Item pipeItem = context.getMappingRegistry().getItemForId(cpt.getInteger("pipeId"));
if (BptPipeExtension.contains(pipeItem)) { if (BptPipeExtension.contains(pipeItem)) {