diff --git a/common/buildcraft/builders/HeuristicBlockDetection.java b/common/buildcraft/builders/HeuristicBlockDetection.java index 8c4439cc..c79b822c 100644 --- a/common/buildcraft/builders/HeuristicBlockDetection.java +++ b/common/buildcraft/builders/HeuristicBlockDetection.java @@ -27,7 +27,7 @@ public final class HeuristicBlockDetection { public static void start() { // Initialize craftableBlockList - for (Object or : CraftingManager.getInstance().getRecipeList()) { + /* for (Object or : CraftingManager.getInstance().getRecipeList()) { if (or instanceof IRecipe) { IRecipe recipe = ((IRecipe) or); if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() != null && @@ -39,7 +39,7 @@ public final class HeuristicBlockDetection { } } } - } + } */ // Register fluids for (Fluid f : FluidRegistry.getRegisteredFluids().values()) { @@ -64,20 +64,6 @@ public final class HeuristicBlockDetection { boolean creativeOnly = false; - if (!canCraft(block, meta)) { - - // Does it drop a different block type? - try { - if (block.getItemDropped(meta, null, 0) != Item.getItemFromBlock(block)) { - creativeOnly = true; - } - } catch (NullPointerException e) { - // The "null" for Random in getItemDropped stops blocks - // depending on an RNG for deciding the dropped item - // from being autodetected. - } - } - try { if (creativeOnly) { SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlockCreative.class); diff --git a/common/buildcraft/core/blueprints/Blueprint.java b/common/buildcraft/core/blueprints/Blueprint.java index eaf5a57e..0c8a6d4f 100644 --- a/common/buildcraft/core/blueprints/Blueprint.java +++ b/common/buildcraft/core/blueprints/Blueprint.java @@ -211,26 +211,28 @@ public class Blueprint extends BlueprintBase { if (block != null) { contents[x][y][z] = SchematicRegistry.INSTANCE.createSchematicBlock(block, cpt.getInteger("blockMeta")); - contents[x][y][z].readSchematicFromNBT(cpt, mapping); - - if (!contents[x][y][z].doNotUse()) { - contents[x][y][z].idsToWorld(mapping); - - switch (contents[x][y][z].getBuildingPermission()) { - case ALL: - break; - case CREATIVE_ONLY: - if (buildingPermission == BuildingPermission.ALL) { - buildingPermission = BuildingPermission.CREATIVE_ONLY; + if (contents[x][y][z] != null) { + contents[x][y][z].readSchematicFromNBT(cpt, mapping); + + if (!contents[x][y][z].doNotUse()) { + contents[x][y][z].idsToWorld(mapping); + + switch (contents[x][y][z].getBuildingPermission()) { + case ALL: + break; + case CREATIVE_ONLY: + if (buildingPermission == BuildingPermission.ALL) { + buildingPermission = BuildingPermission.CREATIVE_ONLY; + } + break; + case NONE: + buildingPermission = BuildingPermission.NONE; + break; } - break; - case NONE: - buildingPermission = BuildingPermission.NONE; - break; + } else { + contents[x][y][z] = null; + isComplete = false; } - } else { - contents[x][y][z] = null; - isComplete = false; } } else { contents[x][y][z] = null; diff --git a/common/buildcraft/core/statements/StatementParameterDirection.java b/common/buildcraft/core/statements/StatementParameterDirection.java index 5642ea13..bf4bdfa2 100644 --- a/common/buildcraft/core/statements/StatementParameterDirection.java +++ b/common/buildcraft/core/statements/StatementParameterDirection.java @@ -14,17 +14,20 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.NetworkData; +import buildcraft.api.gates.IGate; import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.transport.IPipe; import buildcraft.core.utils.StringUtils; +import buildcraft.transport.TileGenericPipe; public class StatementParameterDirection implements IStatementParameter { - @NetworkData + @NetworkData public ForgeDirection direction = ForgeDirection.UNKNOWN; - private IIcon[] icons; + private static IIcon[] icons; public StatementParameterDirection() { @@ -45,11 +48,11 @@ public class StatementParameterDirection implements IStatementParameter { } @Override - public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) { - if (source instanceof IPipe) { + public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) { + if (source.getTile() instanceof TileGenericPipe) { do { direction = ForgeDirection.getOrientation((direction.ordinal() + (mouseButton > 0 ? -1 : 1)) % 6); - } while (!((IPipe) source).getTile().isPipeConnected(direction)); + } while (((TileGenericPipe) source.getTile()).isPipeConnected(direction)); } } diff --git a/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java b/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java index fcda94e7..6e47666e 100644 --- a/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java +++ b/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java @@ -6,6 +6,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import buildcraft.api.core.NetworkData; import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; import buildcraft.core.utils.StringUtils; @@ -14,7 +15,7 @@ public class StatementParameterRedstoneGateSideOnly implements @NetworkData public boolean isOn = false; - private IIcon icon; + private static IIcon icon; public StatementParameterRedstoneGateSideOnly() { @@ -35,7 +36,7 @@ public class StatementParameterRedstoneGateSideOnly implements } @Override - public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) { + public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) { isOn = !isOn; } diff --git a/common/buildcraft/transport/gates/ItemGate.java b/common/buildcraft/transport/gates/ItemGate.java index 6bc4c4ee..5ad779f8 100755 --- a/common/buildcraft/transport/gates/ItemGate.java +++ b/common/buildcraft/transport/gates/ItemGate.java @@ -396,9 +396,7 @@ public class ItemGate extends ItemBuildCraft { for (IGateExpansion expansion : GateExpansions.getExpansions()) { expansion.registerItemOverlay(iconRegister); } - - for (IStatement statement : StatementManager.statements.values()) { - statement.registerIcons(iconRegister); - } + + StatementManager.registerIcons(iconRegister); } } diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index d654466d..dfd66895 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -465,7 +465,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { } if (param != null) { - param.onClick(pipe.container, statement.getStatement(), mc.thePlayer.inventory.getItemStack(), k); + param.onClick(gate, statement.getStatement(), mc.thePlayer.inventory.getItemStack(), k); paramSlot.setParameter(param, true); } } diff --git a/common/buildcraft/transport/schematics/SchematicPipe.java b/common/buildcraft/transport/schematics/SchematicPipe.java index ae483b60..9a8d1663 100644 --- a/common/buildcraft/transport/schematics/SchematicPipe.java +++ b/common/buildcraft/transport/schematics/SchematicPipe.java @@ -22,6 +22,7 @@ import buildcraft.api.blueprints.MappingNotFoundException; import buildcraft.api.blueprints.MappingRegistry; import buildcraft.api.blueprints.SchematicTile; import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.StatementManager; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.Gate; @@ -100,6 +101,30 @@ public class SchematicPipe extends SchematicTile { a = a.rotateLeft(); gateNBT.setString("action[" + i + "]", a.getUniqueTag()); } + + for (int j = 0; j < Gate.MAX_PARAMETERS; ++j) { + if (gateNBT.hasKey("triggerParameters[" + i + "][" + j + "]")) { + NBTTagCompound cpt = gateNBT.getCompoundTag("triggerParameters[" + i + "][" + j + "]"); + IStatementParameter parameter = StatementManager.createParameter(cpt.getString("kind")); + parameter.readFromNBT(cpt); + + parameter = parameter.rotateLeft(); + + parameter.writeToNBT(cpt); + gateNBT.setTag("triggerParameters[" + i + "][" + j + "]", cpt); + } + + if (gateNBT.hasKey("actionParameters[" + i + "][" + j + "]")) { + NBTTagCompound cpt = gateNBT.getCompoundTag("actionParameters[" + i + "][" + j + "]"); + IStatementParameter parameter = StatementManager.createParameter(cpt.getString("kind")); + parameter.readFromNBT(cpt); + + parameter = parameter.rotateLeft(); + + parameter.writeToNBT(cpt); + gateNBT.setTag("actionParameters[" + i + "][" + j + "]", cpt); + } + } } if (gateNBT.hasKey("direction")) { diff --git a/common/buildcraft/transport/statements/ActionParameterSignal.java b/common/buildcraft/transport/statements/ActionParameterSignal.java index 87be3f7b..13b390d2 100644 --- a/common/buildcraft/transport/statements/ActionParameterSignal.java +++ b/common/buildcraft/transport/statements/ActionParameterSignal.java @@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import buildcraft.api.core.NetworkData; import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.transport.PipeWire; import buildcraft.core.utils.StringUtils; @@ -24,7 +25,7 @@ public class ActionParameterSignal implements IStatementParameter { @NetworkData public PipeWire color = null; - private IIcon[] icons; + private static IIcon[] icons; public ActionParameterSignal() { @@ -40,7 +41,7 @@ public class ActionParameterSignal implements IStatementParameter { } @Override - public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) { + public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) { if (color == null) { color = mouseButton == 0 ? PipeWire.RED : PipeWire.YELLOW; } else if (color == (mouseButton == 0 ? PipeWire.YELLOW : PipeWire.RED)) { diff --git a/common/buildcraft/transport/statements/ActionValve.java b/common/buildcraft/transport/statements/ActionValve.java index bd26ab3b..a446839f 100644 --- a/common/buildcraft/transport/statements/ActionValve.java +++ b/common/buildcraft/transport/statements/ActionValve.java @@ -71,13 +71,7 @@ public class ActionValve extends BCStatement implements IActionInternal { @Override public IStatementParameter createParameter(int index) { - IStatementParameter param = null; - - if (index == 0) { - param = new StatementParameterDirection(); - } - - return param; + return new StatementParameterDirection(); } @Override diff --git a/common/buildcraft/transport/statements/TriggerParameterSignal.java b/common/buildcraft/transport/statements/TriggerParameterSignal.java index c923cf7e..65ac11f2 100644 --- a/common/buildcraft/transport/statements/TriggerParameterSignal.java +++ b/common/buildcraft/transport/statements/TriggerParameterSignal.java @@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import buildcraft.api.core.NetworkData; import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.transport.PipeWire; import buildcraft.core.utils.StringUtils; @@ -28,7 +29,7 @@ public class TriggerParameterSignal implements IStatementParameter { @NetworkData public PipeWire color = null; - private IIcon[] icons; + private static IIcon[] icons; public TriggerParameterSignal() { @@ -51,7 +52,7 @@ public class TriggerParameterSignal implements IStatementParameter { } @Override - public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) { + public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) { if (mouseButton == 0) { if (color == null) { active = true;