From 1df2209f25a2d0499dda90344ddb436722f26a9a Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Thu, 7 Nov 2013 16:59:37 -0500 Subject: [PATCH 1/4] Use proper obfuscation --- common/mekanism/client/gui/GuiElement.java | 18 ++++++++---------- common/mekanism/common/ObfuscatedNames.java | 4 ++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/common/mekanism/client/gui/GuiElement.java b/common/mekanism/client/gui/GuiElement.java index 5d4b3cf27..c94bf2400 100644 --- a/common/mekanism/client/gui/GuiElement.java +++ b/common/mekanism/client/gui/GuiElement.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.lang.reflect.Field; import java.lang.reflect.Method; +import mekanism.common.ObfuscatedNames; +import mekanism.common.util.MekanismUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -33,7 +35,7 @@ public abstract class GuiElement protected void displayTooltip(String s, int xAxis, int yAxis) { try { - Method m = GuiContainer.class.getDeclaredMethod("drawCreativeTabHoveringText", String.class, Integer.TYPE, Integer.TYPE); + Method m = MekanismUtils.getPrivateMethod(GuiContainer.class, ObfuscatedNames.GuiContainer_drawCreativeTabHoveringText, String.class, Integer.TYPE, Integer.TYPE); m.setAccessible(true); m.invoke(guiObj, s, xAxis, yAxis); } catch(Exception e) {} @@ -44,9 +46,8 @@ public abstract class GuiElement if(guiObj instanceof GuiContainer) { try { - Field f = GuiContainer.class.getDeclaredField("xSize"); - f.setAccessible(true); - f.set(guiObj, ((Integer)f.get(guiObj))+xSize); + int size = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize); + MekanismUtils.setPrivateValue(guiObj, size+xSize, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize); } catch(Exception e) {} } } @@ -56,9 +57,8 @@ public abstract class GuiElement if(guiObj instanceof GuiContainer) { try { - Field f = GuiContainer.class.getDeclaredField("ySize"); - f.setAccessible(true); - f.set(guiObj, ((Integer)f.get(guiObj))+ySize); + int size = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize); + MekanismUtils.setPrivateValue(guiObj, size+ySize, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize); } catch(Exception e) {} } } @@ -66,9 +66,7 @@ public abstract class GuiElement protected FontRenderer getFontRenderer() { try { - Field f = GuiScreen.class.getDeclaredField("fontRenderer"); - f.setAccessible(true); - return (FontRenderer)f.get(guiObj); + return (FontRenderer)MekanismUtils.getPrivateValue(guiObj, GuiScreen.class, ObfuscatedNames.GuiScreen_fontRenderer); } catch(Exception e) {} return null; diff --git a/common/mekanism/common/ObfuscatedNames.java b/common/mekanism/common/ObfuscatedNames.java index af6eeb1a9..6fb3a2524 100644 --- a/common/mekanism/common/ObfuscatedNames.java +++ b/common/mekanism/common/ObfuscatedNames.java @@ -7,4 +7,8 @@ public final class ObfuscatedNames public static String[] AbstractClientPlayer_downloadImageCape = new String[] {"downloadImageCape", "field_110315_c", "c"}; public static String[] AbstractClientPlayer_locationCape = new String[] {"locationCape", "field_110313_e", "e"}; public static String[] AbstractClientPlayer_getDownloadImage = new String[] {"getDownloadImage", "func_110301_a", "a"}; + public static String[] GuiContainer_drawCreativeTabHoveringText = new String[] {"drawCreativeTabHoveringText", "func_74190_a", "a"}; + public static String[] GuiContainer_xSize = new String[] {"xSize", "field_74194_b", "c"}; + public static String[] GuiContainer_ySize = new String[] {"ySize", "field_74195_c", "d"}; + public static String[] GuiScreen_fontRenderer = new String[] {"fontRenderer", "field_73886_k", "o"}; } \ No newline at end of file From 9fdcb13faafa87f04323a5bbe70c763a9cc7ccc0 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Thu, 7 Nov 2013 19:15:58 -0500 Subject: [PATCH 2/4] Gas Tank recipe shows up in NEI --- common/mekanism/common/util/MekanismUtils.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/mekanism/common/util/MekanismUtils.java b/common/mekanism/common/util/MekanismUtils.java index 23fc7b898..751217b6b 100644 --- a/common/mekanism/common/util/MekanismUtils.java +++ b/common/mekanism/common/util/MekanismUtils.java @@ -23,7 +23,6 @@ import mekanism.common.IModule; import mekanism.common.IRedstoneControl; import mekanism.common.IRedstoneControl.RedstoneControl; import mekanism.common.Mekanism; -import mekanism.common.MekanismHooks; import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; import mekanism.common.Teleporter; @@ -32,6 +31,7 @@ import mekanism.common.Tier.FactoryTier; import mekanism.common.Version; import mekanism.common.inventory.container.ContainerElectricChest; import mekanism.common.item.ItemBlockEnergyCube; +import mekanism.common.item.ItemBlockGasTank; import mekanism.common.network.PacketElectricChest; import mekanism.common.network.PacketElectricChest.ElectricChestPacketType; import mekanism.common.tileentity.TileEntityBoundingBlock; @@ -357,6 +357,16 @@ public final class MekanismUtils return itemstack; } + /** + * Retrieves an empty Gas Tank. + * @return empty gas tank + */ + public static ItemStack getEmptyGasTank() + { + ItemStack itemstack = ((ItemBlockGasTank)new ItemStack(Mekanism.GasTank).getItem()).getEmptyItem(); + return itemstack; + } + /** * Retrieves a Factory with a defined tier and recipe type. * @param tier - tier to add to the Factory From 7053f4a30ae95d29a052a30357d4edcac0606f57 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Thu, 7 Nov 2013 19:17:24 -0500 Subject: [PATCH 3/4] Whoops! --- common/mekanism/common/Mekanism.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 14dc65307..bb2508c45 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -319,7 +319,7 @@ public class Mekanism CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(AtomicDisassembler.getUnchargedItem(), new Object[] { "AEA", "ACA", " O ", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('E'), EnergyTablet.getUnchargedItem(), Character.valueOf('C'), AtomicCore, Character.valueOf('O'), "ingotRefinedObsidian" })); - CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(GasTank), new Object[] { + CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(MekanismUtils.getEmptyGasTank(), new Object[] { "PPP", "PDP", "PPP", Character.valueOf('P'), "ingotOsmium", Character.valueOf('D'), "dustIron" })); CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), new Object[] { From 1aec33d8ec281c942c2266a8c81958f459dac4a4 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Thu, 7 Nov 2013 21:27:12 -0500 Subject: [PATCH 4/4] Added configuration option to turn off strict input colors --- common/mekanism/api/IEjector.java | 4 ++++ .../mekanism/client/gui/GuiConfiguration.java | 20 ++++++++++++++---- .../mekanism/common/TileComponentEjector.java | 18 ++++++++++++++++ .../network/PacketConfigurationUpdate.java | 6 +++++- .../transporter/TransporterPathfinder.java | 5 +++++ .../common/util/TransporterUtils.java | 2 +- .../assets/mekanism/gui/GuiConfiguration.png | Bin 4486 -> 4694 bytes 7 files changed, 49 insertions(+), 6 deletions(-) diff --git a/common/mekanism/api/IEjector.java b/common/mekanism/api/IEjector.java index 6ab97a2bb..9a95e34af 100644 --- a/common/mekanism/api/IEjector.java +++ b/common/mekanism/api/IEjector.java @@ -17,4 +17,8 @@ public interface IEjector public boolean isEjecting(); public void setEjecting(boolean eject); + + public boolean hasStrictInput(); + + public void setStrictInput(boolean strict); } diff --git a/common/mekanism/client/gui/GuiConfiguration.java b/common/mekanism/client/gui/GuiConfiguration.java index b81302ff5..4c6c9dde0 100644 --- a/common/mekanism/client/gui/GuiConfiguration.java +++ b/common/mekanism/client/gui/GuiConfiguration.java @@ -78,6 +78,14 @@ public class GuiConfiguration extends GuiMekanism drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 14, 14, 14, 14); } + if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35) + { + drawTexturedModalRect(guiWidth + 156, guiHeight + 21, 176 + 42, 0, 14, 14); + } + else { + drawTexturedModalRect(guiWidth + 156, guiHeight + 21, 176 + 42, 14, 14, 14); + } + if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 28, 0, 14, 14); @@ -142,13 +150,11 @@ public class GuiConfiguration extends GuiMekanism int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - String ejecting = configurable.getEjector().isEjecting() ? "On" : "Off"; fontRenderer.drawString("Configuration", 60, 5, 0x404040); - fontRenderer.drawString("Eject: " + ejecting, 53, 17, 0x00CD00); + fontRenderer.drawString("Eject: " + (configurable.getEjector().isEjecting() ? "On" : "Off"), 53, 17, 0x00CD00); - fontRenderer.drawString("Input", 32, 81, 0x787878); + fontRenderer.drawString("Input (" + (configurable.getEjector().hasStrictInput() ? "On" : "Off") + ")", 18, 81, 0x787878); fontRenderer.drawString("Output", 72, 68, 0x787878); fontRenderer.drawString("Slots", 122, 81, 0x787878); @@ -241,6 +247,12 @@ public class GuiConfiguration extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.EJECT, Object3D.get(tile))); } + if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.STRICT_INPUT, Object3D.get(tile))); + } + if(xAxis >= 80 && xAxis <= 96 && yAxis >= 49 && yAxis <= 65) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); diff --git a/common/mekanism/common/TileComponentEjector.java b/common/mekanism/common/TileComponentEjector.java index 96b0635ea..b3a2cc5b7 100644 --- a/common/mekanism/common/TileComponentEjector.java +++ b/common/mekanism/common/TileComponentEjector.java @@ -24,6 +24,8 @@ public class TileComponentEjector implements ITileComponent, IEjector { public TileEntityContainerBlock tileEntity; + public boolean strictInput; + public boolean ejecting; public EnumColor outputColor; @@ -137,6 +139,18 @@ public class TileComponentEjector implements ITileComponent, IEjector ejecting = eject; } + @Override + public boolean hasStrictInput() + { + return strictInput; + } + + @Override + public void setStrictInput(boolean strict) + { + strictInput = strict; + } + @Override public void setOutputColor(EnumColor color) { @@ -168,6 +182,7 @@ public class TileComponentEjector implements ITileComponent, IEjector public void read(NBTTagCompound nbtTags) { ejecting = nbtTags.getBoolean("ejecting"); + strictInput = nbtTags.getBoolean("strictInput"); if(nbtTags.hasKey("ejectColor")) { @@ -200,6 +215,7 @@ public class TileComponentEjector implements ITileComponent, IEjector public void read(ByteArrayDataInput dataStream) { ejecting = dataStream.readBoolean(); + strictInput = dataStream.readBoolean(); int c = dataStream.readInt(); @@ -229,6 +245,7 @@ public class TileComponentEjector implements ITileComponent, IEjector public void write(NBTTagCompound nbtTags) { nbtTags.setBoolean("ejecting", ejecting); + nbtTags.setBoolean("strictInput", strictInput); if(outputColor != null) { @@ -256,6 +273,7 @@ public class TileComponentEjector implements ITileComponent, IEjector public void write(ArrayList data) { data.add(ejecting); + data.add(strictInput); if(outputColor != null) { diff --git a/common/mekanism/common/network/PacketConfigurationUpdate.java b/common/mekanism/common/network/PacketConfigurationUpdate.java index 780681730..451d929cf 100644 --- a/common/mekanism/common/network/PacketConfigurationUpdate.java +++ b/common/mekanism/common/network/PacketConfigurationUpdate.java @@ -87,6 +87,10 @@ public class PacketConfigurationUpdate implements IMekanismPacket ForgeDirection side = ForgeDirection.getOrientation(inputSide); config.getEjector().setInputColor(side, TransporterUtils.increment(config.getEjector().getInputColor(side))); } + else if(packetType == ConfigurationPacket.STRICT_INPUT) + { + config.getEjector().setStrictInput(!config.getEjector().hasStrictInput()); + } } } @@ -114,6 +118,6 @@ public class PacketConfigurationUpdate implements IMekanismPacket public static enum ConfigurationPacket { - EJECT, SIDE_DATA, EJECT_COLOR, INPUT_COLOR + EJECT, SIDE_DATA, EJECT_COLOR, INPUT_COLOR, STRICT_INPUT } } diff --git a/common/mekanism/common/transporter/TransporterPathfinder.java b/common/mekanism/common/transporter/TransporterPathfinder.java index e68807e49..9aecb4b31 100644 --- a/common/mekanism/common/transporter/TransporterPathfinder.java +++ b/common/mekanism/common/transporter/TransporterPathfinder.java @@ -211,6 +211,11 @@ public final class TransporterPathfinder { closest = destinations.get(0); } + + if(closest == null) + { + return null; + } return closest.path; } diff --git a/common/mekanism/common/util/TransporterUtils.java b/common/mekanism/common/util/TransporterUtils.java index 7b86ec867..48c8addda 100644 --- a/common/mekanism/common/util/TransporterUtils.java +++ b/common/mekanism/common/util/TransporterUtils.java @@ -174,7 +174,7 @@ public final class TransporterUtils int tileSide = config.getOrientation(); EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); - if(configColor != null && configColor != color) + if(config.getEjector().hasStrictInput() && configColor != null && configColor != color) { return false; } diff --git a/resources/assets/mekanism/gui/GuiConfiguration.png b/resources/assets/mekanism/gui/GuiConfiguration.png index fcef873192a974e3dea2f0ac8916ce7482bcfa66..1d6f943537434104577b72ae9e8cdb4af1100ac5 100644 GIT binary patch delta 2907 zcmbuBX*ApU8po5rP+C_}7246n+ETS#N=XqN9jf+qXe^hOwnS^MEq|$QgwjQ|W6RW( z+G{I{gdx(YHmF8Rh)(QMQA>g(9<7{0x|ee05yipmOE zv|D*WxHX+i2ro^0J-$0wzjAOj!X~kze0%%(mq{ys`tN7lJ9qgJl+xYr116cM@v_u< zJHTjbJ*nyn0QlBnbW3pj#S$%f2|?jCk}juXg@m{I!ekmK!{LO)skBxwd`DauT~Ec~ z>b{Im=qf7@M7kXp31-U1o1Q<7!?;eXmj0&NZJU3sbG5&xQ4$zA_UiR(AIzJ$%C=Q2oKtPPTPNy)+<*T9!yQUe17 zN`HSsgZxOkzpBz^Zz)K+Zd7(km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