From bdd646dbdde45821f176f4746c93f047b94b2f20 Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Wed, 30 Apr 2014 20:44:21 +0200 Subject: [PATCH] fixed behavior of redstone in blueprints, fix #1651 --- common/buildcraft/BuildCraftBuilders.java | 3 +- .../schematics/SchematicRedstoneWire.java | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 common/buildcraft/builders/schematics/SchematicRedstoneWire.java diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index f3aa03d5..288bd4b6 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -86,6 +86,7 @@ import buildcraft.builders.schematics.SchematicPortal; import buildcraft.builders.schematics.SchematicPumpkin; import buildcraft.builders.schematics.SchematicRail; import buildcraft.builders.schematics.SchematicRedstoneDiode; +import buildcraft.builders.schematics.SchematicRedstoneWire; import buildcraft.builders.schematics.SchematicRotateMeta; import buildcraft.builders.schematics.SchematicSeeds; import buildcraft.builders.schematics.SchematicSign; @@ -224,7 +225,7 @@ public class BuildCraftBuilders extends BuildCraftMod { SchematicRegistry.registerSchematicBlock(Blocks.gravel, SchematicGravel.class); - SchematicRegistry.registerSchematicBlock(Blocks.redstone_wire, SchematicCustomStack.class, new ItemStack(Items.redstone)); + SchematicRegistry.registerSchematicBlock(Blocks.redstone_wire, SchematicRedstoneWire.class, new ItemStack(Items.redstone)); SchematicRegistry.registerSchematicBlock(Blocks.cake, SchematicCustomStack.class, new ItemStack(Items.cake)); SchematicRegistry.registerSchematicBlock(Blocks.pumpkin_stem, SchematicCustomStack.class, new ItemStack(Items.pumpkin_seeds)); SchematicRegistry.registerSchematicBlock(Blocks.melon_stem, SchematicCustomStack.class, new ItemStack(Items.melon_seeds)); diff --git a/common/buildcraft/builders/schematics/SchematicRedstoneWire.java b/common/buildcraft/builders/schematics/SchematicRedstoneWire.java new file mode 100755 index 00000000..d6e77c75 --- /dev/null +++ b/common/buildcraft/builders/schematics/SchematicRedstoneWire.java @@ -0,0 +1,40 @@ +/** + * 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.item.ItemStack; +import buildcraft.api.blueprints.IBuilderContext; +import buildcraft.api.blueprints.SchematicBlock; + +public class SchematicRedstoneWire extends SchematicBlock { + + final ItemStack customStack; + + public SchematicRedstoneWire(ItemStack customStack) { + this.customStack = customStack; + } + + @Override + public void addRequirements(IBuilderContext context, LinkedList requirements) { + requirements.add(customStack.copy()); + } + + @Override + public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList stacks) { + context.world().setBlock(x, y, z, block, 0, 3); + } + + @Override + public boolean isAlreadyBuilt(IBuilderContext context, int x, int y, int z) { + return block == context.world().getBlock(x, y, z); + } + +}