diff options
4 files changed, 66 insertions, 22 deletions
diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 261ff54e2f..5cd6c6f8aa 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -6,7 +6,11 @@ import static gtPlusPlus.core.lib.CORE.configSwitches.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.lang.reflect.Field; import java.util.Collection; +import java.util.HashSet; + +import org.apache.commons.lang3.reflect.FieldUtils; import cpw.mods.fml.common.*; import cpw.mods.fml.common.Mod.EventHandler; @@ -14,6 +18,7 @@ import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; @@ -216,7 +221,7 @@ public class GTplusplus implements ActionListener { } // ~ - ReflectionUtils.becauseIWorkHard(); + //ReflectionUtils.becauseIWorkHard(); //Make Burnables burnable if (!CORE.burnables.isEmpty()){ @@ -245,18 +250,9 @@ public class GTplusplus implements ActionListener { event.registerServerCommand(new CommandMath()); if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && CORE.configSwitches.enableOldGTcircuits){ - try { - if (ReflectionUtils.getField(GT_Recipe_Map.class, "sCircuitAssemblerRecipes") != null){ - ReflectionUtils.setDefault(GT_Recipe_Map.class, "sCircuitAssemblerRecipes", null); - if (ReflectionUtils.getField(GT_Recipe_Map.class, "sCircuitAssemblerRecipes") == null){ - Utils.LOG_INFO("[Circuit Fix 2] Removed all recipes from circuit assembler recipe map."); - } - } - } - catch (Exception e) { - Utils.LOG_INFO("Failed removing circuit assembler recipe map."); - } + } + removeCircuitRecipeMap(); } @Mod.EventHandler @@ -284,4 +280,44 @@ public class GTplusplus implements ActionListener { } } + + private static boolean removeCircuitRecipeMap(){ + try { + + Utils.LOG_INFO("DEBUG[1]:"+GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes").hashCode()); + ReflectionUtils.setFinalStatic(GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes"), new GT_Recipe_Map(new HashSet<GT_Recipe>(0), "gt.recipe.removed", "Removed", null, GT_Values.RES_PATH_GUI + "basicmachines/Default", 0, 0, 0, 0, 0, GT_Values.E, 0, GT_Values.E, true, false)); + Utils.LOG_INFO("DEBUG[2]:"+GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes").hashCode()); + + Field jaffar = GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes"); + Utils.LOG_INFO("DEBUG[3]:"+jaffar.hashCode()); + FieldUtils.removeFinalModifier(jaffar, true); + Utils.LOG_INFO("DEBUG[4]:"+jaffar.hashCode()); + jaffar.set(null, null); + Utils.LOG_INFO("DEBUG[5]:"+jaffar.hashCode()); + + //GT_Recipe_Map.sCircuitAssemblerRecipes. + + //for (fieldType R : value){ + + //} + + /*if (ReflectionUtils.getField(GT_Recipe_Map.class, "sCircuitAssemblerRecipes") != null){ + ReflectionUtils.setDefault(GT_Recipe_Map.class, "sCircuitAssemblerRecipes", null); + if (ReflectionUtils.getField(GT_Recipe_Map.class, "sCircuitAssemblerRecipes") == null){ + Utils.LOG_INFO("[Circuit Fix 2] Removed all recipes from circuit assembler recipe map."); + //Object sArray = Reflectionutils. gregtech.api.util.GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes; + //for (int x : ) + + + + + } + }*/ + } + catch (Exception e) { + Utils.LOG_INFO("Failed removing circuit assembler recipe map."); + return false; + } + return true; + } } diff --git a/src/Java/gtPlusPlus/core/container/Container_Workbench.java b/src/Java/gtPlusPlus/core/container/Container_Workbench.java index fd16aa4e67..59000f1b59 100644 --- a/src/Java/gtPlusPlus/core/container/Container_Workbench.java +++ b/src/Java/gtPlusPlus/core/container/Container_Workbench.java @@ -23,7 +23,7 @@ public class Container_Workbench extends Container { public final InventoryWorkbenchChest inventoryChest; public final InventoryWorkbenchTools inventoryTool; public final InventoryWorkbenchHoloSlots inventoryHolo; - public final InventoryWorkbenchHoloCrafting inventoryCrafting; + //public final InventoryWorkbenchHoloCrafting inventoryCrafting; private final World worldObj; private final int posX; @@ -84,7 +84,7 @@ public class Container_Workbench extends Container { this.inventoryChest = tile.inventoryChest; this.inventoryTool = tile.inventoryTool; this.inventoryHolo = tile.inventoryHolo; - this.inventoryCrafting = tile.inventoryCrafting; + //this.inventoryCrafting = tile.inventoryCrafting; int var6; int var7; @@ -262,7 +262,7 @@ public class Container_Workbench extends Container { private void updateCraftingMatrix() { for (int i = 0; i < this.craftMatrix.getSizeInventory(); i++) { - this.craftMatrix.setInventorySlotContents(i, this.tile_entity.inventoryCrafting.getStackInSlot(i)); + //this.craftMatrix.setInventorySlotContents(i, this.tile_entity.inventoryCrafting.getStackInSlot(i)); } } @@ -280,7 +280,7 @@ public class Container_Workbench extends Container { private void saveCraftingMatrix() { for (int i = 0; i < this.craftMatrix.getSizeInventory(); i++) { - this.tile_entity.inventoryCrafting.setInventorySlotContents(i, this.craftMatrix.getStackInSlot(i)); + //this.tile_entity.inventoryCrafting.setInventorySlotContents(i, this.craftMatrix.getStackInSlot(i)); } } diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java index eac2724aa0..0657b6d886 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityWorkbench.java @@ -23,7 +23,7 @@ public class TileEntityWorkbench extends TileEntity implements INetworkDataProvi public InventoryWorkbenchChest inventoryChest; public InventoryWorkbenchTools inventoryTool; public InventoryWorkbenchHoloSlots inventoryHolo; - public InventoryWorkbenchHoloCrafting inventoryCrafting; + //public InventoryWorkbenchHoloCrafting inventoryCrafting; public IInventory inventoryCraftResult = new InventoryCraftResult(); @@ -31,7 +31,7 @@ public class TileEntityWorkbench extends TileEntity implements INetworkDataProvi this.inventoryTool = new InventoryWorkbenchTools();//number of slots - without product slot this.inventoryChest = new InventoryWorkbenchChest();//number of slots - without product slot this.inventoryHolo = new InventoryWorkbenchHoloSlots(); - this.inventoryCrafting = new InventoryWorkbenchHoloCrafting(); + //this.inventoryCrafting = new InventoryWorkbenchHoloCrafting(); this.canUpdate(); } @@ -59,14 +59,14 @@ public class TileEntityWorkbench extends TileEntity implements INetworkDataProvi // Write Crafting Matrix to NBT final NBTTagList craftingTag = new NBTTagList(); - for (int currentIndex = 0; currentIndex < this.inventoryCrafting.getSizeInventory(); ++currentIndex) { + /*for (int currentIndex = 0; currentIndex < this.inventoryCrafting.getSizeInventory(); ++currentIndex) { if (this.inventoryCrafting.getStackInSlot(currentIndex) != null) { final NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); this.inventoryCrafting.getStackInSlot(currentIndex).writeToNBT(tagCompound); craftingTag.appendTag(tagCompound); } - } + }*/ nbt.setTag("CraftingMatrix", craftingTag); // Write craftingResult to NBT @@ -90,14 +90,14 @@ public class TileEntityWorkbench extends TileEntity implements INetworkDataProvi // Read in the Crafting Matrix from NBT final NBTTagList craftingTag = nbt.getTagList("CraftingMatrix", 10); - this.inventoryCrafting = new InventoryWorkbenchHoloCrafting(); //TODO: magic number + /*this.inventoryCrafting = new InventoryWorkbenchHoloCrafting(); //TODO: magic number for (int i = 0; i < craftingTag.tagCount(); ++i) { final NBTTagCompound tagCompound = craftingTag.getCompoundTagAt(i); final byte slot = tagCompound.getByte("Slot"); if ((slot >= 0) && (slot < this.inventoryCrafting.getSizeInventory())) { this.inventoryCrafting.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(tagCompound)); } - } + }*/ // Read craftingResult from NBT diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index ba48892112..05b85cfff6 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -136,4 +136,12 @@ public class ReflectionUtils { modifierField.setInt(nameField, modifiers); } + public static void setFinalStatic(Field field, Object newValue) throws Exception { + field.setAccessible(true); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); + field.set(null, newValue); + } + } |