From 131f3c2572b8b3886268920027b2f7ea1e87ff4b Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Tue, 16 Dec 2014 17:33:10 +0800 Subject: [PATCH 1/2] Added IMC support for defining if a block or tile entity should be connected to by insulated redstone conduits --- ReleaseNotes.txt | 7 +- src/main/java/crazypants/enderio/EnderIO.java | 3 + src/main/java/crazypants/enderio/api/IMC.java | 9 ++ .../redstone/InsulatedRedstoneConduit.java | 85 +++++++++++++------ 4 files changed, 78 insertions(+), 26 deletions(-) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 12e56de5..f7161bf0 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -4,12 +4,15 @@ Version 2.2.4 Changes - #1413 Added support for Dense Ores in SAG Mill and Alloy Furnace -- #1209 Add API interface to allow forced connection of redstone conduits - #1029 Add lock buttons to farm seed slots +API +- #1209 Add API interface to allow forced connection of redstone conduits +- Added IMC support for defining if a block or tile entity should be connected to by insulated redstone conduits + Bugs - #1409 Energy conduit and capacitor interaction bug -- #1412 Nullpointer Exception in console +- #1412 Null pointer Exception in console - #1421 Capacitor bank wont pull energy from a dim. transceiver - #1423 Crash using 'show range' button in aversion / attractor obelisk - Fixed infinite power bug diff --git a/src/main/java/crazypants/enderio/EnderIO.java b/src/main/java/crazypants/enderio/EnderIO.java index 62f4cf6a..629781f0 100644 --- a/src/main/java/crazypants/enderio/EnderIO.java +++ b/src/main/java/crazypants/enderio/EnderIO.java @@ -53,6 +53,7 @@ import crazypants.enderio.conduit.liquid.ItemLiquidConduit; import crazypants.enderio.conduit.me.ItemMEConduit; import crazypants.enderio.conduit.power.ItemPowerConduit; import crazypants.enderio.conduit.redstone.ConduitBundledRedstoneProvider; +import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit; import crazypants.enderio.conduit.redstone.ItemRedstoneConduit; import crazypants.enderio.config.Config; import crazypants.enderio.enchantment.Enchantments; @@ -675,6 +676,8 @@ public class EnderIO { FluidFuelRegister.instance.addFuel(msg.getNBTValue()); } else if(IMC.FLUID_COOLANT_ADD.equals(key)) { FluidFuelRegister.instance.addCoolant(msg.getNBTValue()); + } else if(IMC.REDSTONE_CONNECTABLE_ADD.equals(key)) { + InsulatedRedstoneConduit.addConnectableBlock(msg.getNBTValue()); } } else if(msg.isItemStackMessage()) { if(IMC.PAINTER_WHITELIST_ADD.equals(key)) { diff --git a/src/main/java/crazypants/enderio/api/IMC.java b/src/main/java/crazypants/enderio/api/IMC.java index 5648a5d3..e28afd21 100644 --- a/src/main/java/crazypants/enderio/api/IMC.java +++ b/src/main/java/crazypants/enderio/api/IMC.java @@ -1,5 +1,6 @@ package crazypants.enderio.api; +import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit; import crazypants.enderio.fluid.FluidFuelRegister; import crazypants.enderio.item.ItemSoulVessel; import crazypants.enderio.machine.alloy.AlloyRecipeManager; @@ -121,6 +122,14 @@ public final class IMC { */ public static final String TELEPORT_BLACKLIST_ADD = "teleport:blacklist:add"; + /** + * Key for an NBT message to register a block or tile entity as connectable to + * insulated redstone conduits. Calls + * {@link InsulatedRedstoneConduit#addConnectableBlock(net.minecraft.nbt.NBTTagCompound)} + * with the NBT value of the message. + */ + public static final String REDSTONE_CONNECTABLE_ADD = "redstone:connectable:add"; + private IMC() { } diff --git a/src/main/java/crazypants/enderio/conduit/redstone/InsulatedRedstoneConduit.java b/src/main/java/crazypants/enderio/conduit/redstone/InsulatedRedstoneConduit.java index 43b81db5..f736f9a1 100644 --- a/src/main/java/crazypants/enderio/conduit/redstone/InsulatedRedstoneConduit.java +++ b/src/main/java/crazypants/enderio/conduit/redstone/InsulatedRedstoneConduit.java @@ -24,6 +24,7 @@ import cofh.api.tileentity.IRedstoneControl; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import crazypants.enderio.EnderIO; +import crazypants.enderio.Log; import crazypants.enderio.api.redstone.IRedstoneConnectable; import crazypants.enderio.conduit.ConduitUtil; import crazypants.enderio.conduit.ConnectionMode; @@ -32,8 +33,6 @@ import crazypants.enderio.conduit.RaytraceResult; import crazypants.enderio.conduit.geom.CollidableCache.CacheKey; import crazypants.enderio.conduit.geom.CollidableComponent; import crazypants.enderio.conduit.geom.ConduitGeometryUtil; -import crazypants.enderio.machine.AbstractMachineEntity; -import crazypants.enderio.machine.RedstoneControlMode; import crazypants.enderio.tool.ToolUtil; import crazypants.render.BoundingBox; import crazypants.render.IconUtil; @@ -63,13 +62,71 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula }); } - private static List VANILLA_CONECTABLES = Arrays.asList(Blocks.redstone_lamp, Blocks.redstone_torch, Blocks.redstone_wire, Blocks.redstone_block, + private static final List CONECTABLE_BLOCKS = Arrays.asList(Blocks.redstone_lamp, Blocks.redstone_torch, Blocks.redstone_wire, Blocks.redstone_block, Blocks.dispenser, Blocks.lever, Blocks.wooden_button, Blocks.stone_button, Blocks.wooden_pressure_plate, Blocks.stone_pressure_plate, Blocks.dropper, Blocks.daylight_detector, Blocks.command_block, Blocks.golden_rail, Blocks.trapped_chest); private static Map, Boolean> CONNECTABLE_CLASSES = null; + public static void addConnectableBlock(NBTTagCompound nbt) { + if(nbt == null) { + Log.warn("InsulatedRedstoneConduit: An attempt was made to register a redstone connectable using a null NBT"); + return; + } + boolean connectable = true; + if(nbt.hasKey("isConnectable")) { + connectable = nbt.getBoolean("isConnectable"); + } + String className = nbt.getString("className"); + addConnectableInterface(className, connectable); + } + + public static void addConnectableBlock(Block block) { + if(block == null) { + Log.warn("InsulatedRedstoneConduit: An attempt was made to register a redstone connectable using a null Block"); + return; + } + CONECTABLE_BLOCKS.add(block); + } + + public static void addConnectableInterface(String className, boolean connectable) { + try { + Class clz = Class.forName(className); + addConnectableInterface(clz, connectable); + } catch (Exception e) { + Log.warn("InsulatedRedstoneConduit: An attempt was made to register " + className + " as connectable but it could not be loaded"); + } + } + + public static void addConnectableInterface(Class clazz, boolean connectable) { + if(clazz == null) { + Log.warn("InsulatedRedstoneConduit: An attempt was made to register a null class as a connectable"); + return; + } + getConnectableInterfaces().put(clazz, connectable); + } + + private static Map, Boolean> getConnectableInterfaces() { + if(CONNECTABLE_CLASSES == null) { + CONNECTABLE_CLASSES = new HashMap, Boolean>(); + CONNECTABLE_CLASSES.put(IRedstoneControl.class, false); + try { + Class conInterface = Class.forName("powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection"); + CONNECTABLE_CLASSES.put(conInterface, false); + } catch (Throwable e) { + //NO-OP + } + try { + Class ccInterface = Class.forName("dan200.computercraft.shared.computer.blocks.IComputerTile"); + CONNECTABLE_CLASSES.put(ccInterface, true); + } catch (Throwable e) { + //NO-OP + } + } + return CONNECTABLE_CLASSES; + } + private Map forcedConnections = new HashMap(); private Map signalColors = new HashMap(); @@ -290,7 +347,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula return false; } - if(VANILLA_CONECTABLES.contains(block)) { + if(CONECTABLE_BLOCKS.contains(block)) { return true; } @@ -312,26 +369,6 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula return false; } - private static Map, Boolean> getConnectableInterfaces() { - if(CONNECTABLE_CLASSES == null) { - CONNECTABLE_CLASSES = new HashMap, Boolean>(); - CONNECTABLE_CLASSES.put(IRedstoneControl.class, false); - try{ - Class conInterface = Class.forName("powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection"); - CONNECTABLE_CLASSES.put(conInterface, false); - } catch(Throwable e) { - //NO-OP - } - try{ - Class ccInterface = Class.forName("dan200.computercraft.shared.computer.blocks.IComputerTile"); - CONNECTABLE_CLASSES.put(ccInterface, true); - } catch(Throwable e) { - //NO-OP - } - } - return CONNECTABLE_CLASSES; - } - @Override public boolean isSpecialConnection(ForgeDirection dir){ BlockCoord loc = getLocation().getLocation(dir); From 94eda5f5c180a729fe0f1ce2c45cb2e6861ef8ca Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Tue, 16 Dec 2014 17:35:13 +0800 Subject: [PATCH 2/2] Release 2.2.4 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 695f4bb0..8722be9f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ forge_version=10.13.0.1208 mod_version=2.2.4 #Comment out this line to get rid of the appendix -mod_appendix=beta +#mod_appendix=beta buildcraft_version=6.1.5 waila_version=1.5.6a_1.7.10