diff options
13 files changed, 660 insertions, 330 deletions
diff --git a/src/Java/gtPlusPlus/core/block/machine/DecayablesChest.java b/src/Java/gtPlusPlus/core/block/machine/DecayablesChest.java index efd6f88885..15d330defc 100644 --- a/src/Java/gtPlusPlus/core/block/machine/DecayablesChest.java +++ b/src/Java/gtPlusPlus/core/block/machine/DecayablesChest.java @@ -52,6 +52,8 @@ public class DecayablesChest extends BlockContainer implements ITileTooltip super(Material.iron); this.setBlockName("blockDecayablesChest"); this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(5f); + this.setResistance(1f); GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockDecayablesChest"); LanguageRegistry.addName(this, "Lead Lined Box"); this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); diff --git a/src/Java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java b/src/Java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java index e6129317c6..8e0b1b48ce 100644 --- a/src/Java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java +++ b/src/Java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java @@ -86,6 +86,7 @@ public class ItemEntityGiantEgg extends EntityItem { ItemStack g = this.getEntityItem(); NBTUtils.setInteger(g, "mTicksExisted", this.age); NBTUtils.setInteger(g, "lifespan", this.lifespan); + NBTUtils.setBoolean(g, "playerHeld", false); this.setEntityItemStack(g); Logger.INFO("Writing age to NBT of stored stack item."); } @@ -93,6 +94,7 @@ public class ItemEntityGiantEgg extends EntityItem { ItemStack g = ItemUtils.getSimpleStack(ModItems.itemBigEgg); NBTUtils.setInteger(g, "mTicksExisted", this.age); NBTUtils.setInteger(g, "lifespan", this.lifespan); + NBTUtils.setBoolean(g, "playerHeld", false); this.setEntityItemStack(g); Logger.INFO("Writing age to NBT of new stack item."); diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java index 4616ab0aa0..0c31b999cd 100644 --- a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java +++ b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java @@ -797,7 +797,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri } // Handle no stored fluid first if (aStoredFluid == null) { - Logger.WARNING("Pump is empty, filling with tank fluids."); + Logger.INFO("Pump is empty, filling with tank fluids."); FluidStack toConsume; int amountToConsume = 0; if (resource.amount >= aCapacity) { @@ -811,32 +811,32 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return amountToConsume; } } else { - Logger.WARNING("Pump is Partially full, filling with tank fluids."); + Logger.INFO("Pump is Partially full, filling with tank fluids."); if (aStoredFluid.isFluidEqual(resource)) { - Logger.WARNING("Found matching fluids."); + Logger.INFO("Found matching fluids."); int aSpaceLeft = (aCapacity - aStoredAmount); - Logger.WARNING( + Logger.INFO( "Capacity: " + aCapacity + " | Stored: " + aStoredAmount + " | Space left: " + aSpaceLeft); FluidStack toConsume; int amountToConsume = 0; if (resource.amount >= aSpaceLeft) { amountToConsume = aSpaceLeft; - Logger.WARNING("More or equal fluid amount to pump container space."); + Logger.INFO("More or equal fluid amount to pump container space."); } else { amountToConsume = resource.amount; - Logger.WARNING("Less fluid than container space"); + Logger.INFO("Less fluid than container space"); } - Logger.WARNING("Amount to consume: " + amountToConsume); + Logger.INFO("Amount to consume: " + amountToConsume); toConsume = FluidUtils.getFluidStack(resource, (aStoredAmount + amountToConsume)); if (toConsume != null && amountToConsume > 0) { - Logger.WARNING("Storing Fluid"); + Logger.INFO("Storing Fluid"); storeFluid(container, toConsume); return amountToConsume; } else { - Logger.WARNING("Not storing fluid"); + Logger.INFO("Not storing fluid"); } } else { - Logger.WARNING("Fluids did not match."); + Logger.INFO("Fluids did not match."); } } } @@ -943,7 +943,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri } if (!canUse(aStack, removal) && aTier > 0) { PlayerUtils.messagePlayer(aPlayer, "Not enough power."); - Logger.WARNING("No Power"); + Logger.INFO("No Power"); return false; } @@ -990,12 +990,12 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri public boolean drainIFluidTank(TileEntity tTileEntity, ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ) { if (tTileEntity == null) { - Logger.WARNING("Invalid Tile, somehow."); + Logger.INFO("Invalid Tile, somehow."); return false; } if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { if (this.getFluid(aStack) == null || (this.getFluid(aStack) != null && this.getFluid(aStack).amount < this.getCapacity(aStack))) { - Logger.WARNING("Trying to find Stored Fluid - Behaviour Class."); + Logger.INFO("Trying to find Stored Fluid - Behaviour Class."); FluidStack aStored = getStoredFluidOfVanillaTank(tTileEntity); if (aStored != null) { int mAmountInserted = fill(aStack, aStored); @@ -1007,22 +1007,22 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri newStackRemainingInTank = FluidUtils.getFluidStack(aStored, (aStored.amount - mAmountInserted)); } boolean b = setStoredFluidOfVanillaTank(tTileEntity, newStackRemainingInTank); - Logger.WARNING("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); - Logger.WARNING("Returning " + b + " - drainTankVanilla."); + Logger.INFO("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); + Logger.INFO("Returning " + b + " - drainTankVanilla."); if (b) { PlayerUtils.messagePlayer(aPlayer, "Drained "+mAmountInserted+"L of "+aStored.getLocalizedName()+"."); } return b; } } else { - Logger.WARNING("Found no valid Fluidstack - drainTankVanilla."); + Logger.INFO("Found no valid Fluidstack - drainTankVanilla."); } } else { - Logger.WARNING("Pump is full."); + Logger.INFO("Pump is full."); } } - Logger.WARNING("Could not drain vanilla tank."); + Logger.INFO("Could not drain vanilla tank."); return false; } @@ -1036,16 +1036,16 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return false; } if ((tTileEntity instanceof IGregTechTileEntity)) { - Logger.WARNING("Right Clicking on GT Tile - drainTankGT."); + Logger.INFO("Right Clicking on GT Tile - drainTankGT."); if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) { - Logger.WARNING("Returning False - Behaviour Class. Timer < 50"); + Logger.INFO("Returning False - Behaviour Class. Timer < 50"); return false; } else if ((!aWorld.isRemote) && (!((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer))) { - Logger.WARNING("Returning True - drainTankGT. NotUsable()"); + Logger.INFO("Returning True - drainTankGT. NotUsable()"); return true; } else { if (this.getFluid(aStack) == null || (this.getFluid(aStack) != null && this.getFluid(aStack).amount < this.getCapacity(aStack))) { - Logger.WARNING("Trying to find Stored Fluid - drainTankGT."); + Logger.INFO("Trying to find Stored Fluid - drainTankGT."); FluidStack aStored = getStoredFluidOfGTMachine((IGregTechTileEntity) tTileEntity); if (aStored != null) { int mAmountInserted = fill(aStack, aStored); @@ -1057,23 +1057,23 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri newStackRemainingInTank = FluidUtils.getFluidStack(aStored, (aStored.amount - mAmountInserted)); } boolean b = setStoredFluidOfGTMachine((IGregTechTileEntity) tTileEntity, newStackRemainingInTank); - Logger.WARNING("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); - Logger.WARNING("Returning " + b + " - drainTankGT."); + Logger.INFO("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); + Logger.INFO("Returning " + b + " - drainTankGT."); if (b) { PlayerUtils.messagePlayer(aPlayer, "Drained "+mAmountInserted+"L of "+aStored.getLocalizedName()+"."); } return b; } } else { - Logger.WARNING("Found no valid Fluidstack - drainTankGT."); + Logger.INFO("Found no valid Fluidstack - drainTankGT."); } } else { - Logger.WARNING("Pump is full."); + Logger.INFO("Pump is full."); } } } - Logger.WARNING("Could not drain GT tank."); + Logger.INFO("Could not drain GT tank."); return false; } @@ -1097,7 +1097,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri public FluidStack getStoredFluidOfVanillaTank(IFluidTank aTileEntity) { FluidStack f = aTileEntity.getFluid(); - Logger.WARNING("Returning Fluid stack from tile. Found: " + Logger.INFO("Returning Fluid stack from tile. Found: " + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); return f; } @@ -1119,14 +1119,14 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri } public boolean setStoredFluidOfVanillaTank(TileEntity aTileEntity, FluidStack aSetFluid) { - Logger.WARNING("Trying to clear Tile's tank. - Behaviour Class. [1]"); + Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [1]"); if (aTileEntity == null) { return false; } else if ((aTileEntity instanceof IFluidTank || aTileEntity instanceof IFluidHandler)) { if (aTileEntity instanceof IFluidTank) { - Logger.WARNING("Tile Was instanceof IFluidTank."); + Logger.INFO("Tile Was instanceof IFluidTank."); FluidStack f = ((IFluidTank) aTileEntity).getFluid(); if (aSetFluid == null) { aSetFluid = f; @@ -1141,10 +1141,10 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri } if (newStack.isFluidEqual(aSetFluid) && newStack.amount == aSetFluid.amount) { - Logger.WARNING("Removed fluid from vanilla IFluidTank successfully."); + Logger.INFO("Removed fluid from vanilla IFluidTank successfully."); return true; } else { - Logger.WARNING("Failed trying to remove fluid from vanilla IFluidTank."); + Logger.INFO("Failed trying to remove fluid from vanilla IFluidTank."); return false; } } @@ -1152,7 +1152,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri //Rewrite Fluid handling for Vanilla type tanks if (!IFluidHandler.class.isInstance(aTileEntity)) { - Logger.WARNING("Tile Was not an instance of IFluidHandler."); + Logger.INFO("Tile Was not an instance of IFluidHandler."); return false; } @@ -1163,37 +1163,37 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri if (a1 != null) { if (a1[0] != null) { aTankContents = a1[0].fluid; - Logger.WARNING("Found Fluid in Tank. "+aTankContents.getLocalizedName()+" - "+aTankContents.amount); + Logger.INFO("Found Fluid in Tank. "+aTankContents.getLocalizedName()+" - "+aTankContents.amount); } } if (aSetFluid == null) { - Logger.WARNING("Setting fluid to tank contents, as we're going to empty it totally."); + Logger.INFO("Setting fluid to tank contents, as we're going to empty it totally."); aSetFluid = aTankContents.copy(); } else { - Logger.WARNING("Setting fluid to tank contents, as we're going to empty it totally."); + Logger.INFO("Setting fluid to tank contents, as we're going to empty it totally."); } - Logger.WARNING("Tile Was instance of IFluidHandler. Trying to Drain "+aSetFluid.getLocalizedName()+" - "+aSetFluid.amount); + Logger.INFO("Tile Was instance of IFluidHandler. Trying to Drain "+aSetFluid.getLocalizedName()+" - "+aSetFluid.amount); if (a1 == null || aTankContents == null) { - Logger.WARNING("Tank is empty."); + Logger.INFO("Tank is empty."); return false; } //Found some Fluid in the tank else { FluidStack aDrainedStack = aTank.drain(ForgeDirection.UNKNOWN, aSetFluid, true); if (aDrainedStack.isFluidStackIdentical(aSetFluid)) { - Logger.WARNING("Drained!"); + Logger.INFO("Drained!"); return true; } else { - Logger.WARNING("Partially Drained! This is probably an error."); + Logger.INFO("Partially Drained! This is probably an error."); return true; } } } } else { - Logger.WARNING("Bad Tank Tile to drain."); + Logger.INFO("Bad Tank Tile to drain."); return false; } @@ -1213,7 +1213,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return null; } if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicTank) { - Logger.WARNING("Tile Was Instanceof BasicTank."); + Logger.INFO("Tile Was Instanceof BasicTank."); return getStoredFluidOfGTMachine((GT_MetaTileEntity_BasicTank) aMetaTileEntity); } else { return null; @@ -1224,38 +1224,27 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri FluidStack f = aTileEntity.mFluid; //Let's see if this machine has output fluid too - if (f == null) { - Logger.WARNING("Could not find any input fluid, checking output if possible."); - if (aTileEntity instanceof GT_MetaTileEntity_BasicMachine) { - GT_MetaTileEntity_BasicMachine g = (GT_MetaTileEntity_BasicMachine) aTileEntity; - Logger.WARNING("Tile is a Basic Machine of some sort - "+g.mNEIName); - if (g != null) { - f = g.mOutputFluid; - if (f != null) { - Logger.WARNING("Found output fluid! "+f.getLocalizedName()); - } - else { - Logger.WARNING("Did not find anything!"); - f = g.getFluid(); - if (f != null) { - Logger.WARNING("Found fluid! "+f.getLocalizedName()); - } - else { - Logger.WARNING("Did not find anything!"); - f = g.getFluid(); - } - } - } - } - } + /* + * if (f == null) { + * Logger.INFO("Could not find any input fluid, checking output if possible."); + * if (aTileEntity instanceof GT_MetaTileEntity_BasicMachine) { + * GT_MetaTileEntity_BasicMachine g = (GT_MetaTileEntity_BasicMachine) + * aTileEntity; + * Logger.INFO("Tile is a Basic Machine of some sort - "+g.mNEIName); if (g != + * null) { f = g.mOutputFluid; if (f != null) { + * Logger.INFO("Found output fluid! "+f.getLocalizedName()); } else { + * Logger.INFO("Did not find anything!"); f = g.getFluid(); if (f != null) { + * Logger.INFO("Found fluid! "+f.getLocalizedName()); } else { + * Logger.INFO("Did not find anything!"); f = g.getFluid(); } } } } } + */ - Logger.WARNING("Returning Fluid stack from tile. Found: " + Logger.INFO("Returning Fluid stack from tile. Found: " + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); return f; } public boolean setStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity, FluidStack aSetFluid) { - Logger.WARNING("Trying to clear Tile's tank. - Behaviour Class. [1]"); + Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [1]"); if (aTileEntity == null) { return false; } @@ -1264,7 +1253,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return false; } if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicTank) { - Logger.WARNING("Trying to clear Tile's tank. - Behaviour Class. [2]"); + Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [2]"); return setStoredFluidOfGTMachine((GT_MetaTileEntity_BasicTank) aMetaTileEntity, aSetFluid); } else { return false; @@ -1275,16 +1264,16 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri try { //Try Handle Outputs First - if (aTileEntity.setDrainableStack(aSetFluid) != null) { - return true; - } + /* + * if (aTileEntity.setDrainableStack(aSetFluid) != null) { return true; } + */ aTileEntity.mFluid = aSetFluid; boolean b = aTileEntity.mFluid == aSetFluid; - Logger.WARNING("Trying to set Tile's tank. - Behaviour Class. [3] " + b); + Logger.INFO("Trying to set Tile's tank. - Behaviour Class. [3] " + b); return b; } catch (Throwable t) { - Logger.WARNING("Trying to clear Tile's tank. FAILED - Behaviour Class. [x]"); + Logger.INFO("Trying to clear Tile's tank. FAILED - Behaviour Class. [x]"); return false; } } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index e9c1da024c..bfd50e0ce1 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -931,6 +931,7 @@ public class RECIPES_Machines { } if (CORE.ConfigSwitches.enableMachine_Pollution && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + RecipeUtils.addShapedGregtechRecipe( "plateCarbon", "plateCarbon", "plateCarbon", "dustCarbon", "dustCarbon", "dustCarbon", @@ -961,7 +962,7 @@ public class RECIPES_Machines { RecipeUtils.addShapedGregtechRecipe( CI.component_Plate[6], ItemList.Casing_Grate.get(1), CI.component_Plate[6], CI.component_Plate[6], aTieredFluidRegulator, CI.component_Plate[6], - CI.getTieredCircuit(5), ItemList.Hatch_Input_IV.get(1), CI.getTieredCircuit(5), + CI.getTieredCircuit(4), ItemList.Hatch_Input_IV.get(1), CI.getTieredCircuit(4), GregtechItemList.Hatch_Air_Intake.get(1)); //ULV diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index ca334fe0d3..dffb438e4a 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -484,10 +484,13 @@ public class CI { public static void init() { //Set Explosives try { - ItemList PowerderBarrel = gtPlusPlus.core.util.Utils.getValueOfItemList("Block_Powderbarrel", null); + ItemList PowerderBarrel = Utils.getValueOfItemList("Block_Powderbarrel", null); if (PowerderBarrel != null){ explosivePowderKeg = PowerderBarrel.get(1).copy(); } + else { + explosivePowderKeg = ItemUtils.getSimpleStack(Items.gunpowder).copy(); + } } catch (java.lang.IllegalArgumentException Y) { explosivePowderKeg = ItemUtils.getSimpleStack(Items.gunpowder).copy(); } diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 3b3ba88e88..bb1d9064e8 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -928,24 +928,19 @@ public class Utils { return false; } - public static ItemList getValueOfItemList(String string, ItemList aOther) { - try { - Method method = ItemList.class.getDeclaredMethod("values"); - Object obj = method.invoke(null); - String y = Arrays.toString((Object[]) obj); - String[] aCurrentItemsInList = y.split(","); - boolean found = false; - for (String g : aCurrentItemsInList) { - if (g.equals(string)) { - found = true; - break; + public static ItemList getValueOfItemList(String string, ItemList aOther) { + ItemList[] aListValues = ItemList.class.getEnumConstants(); + for (ItemList aItem : aListValues) { + if (aItem != null) { + if (aItem.name().equals(string) || aItem.name().toLowerCase().equals(string.toLowerCase())) { + return aItem; } } - if (found) { - return ItemList.valueOf(string); - } } - catch (Throwable t) {} + Logger.INFO("Tried to obtain '"+string+"' from the GT ItemList, however it does not exist."); + if (aOther != null) { + Logger.INFO("Using fallback option instead - "+aOther.name()); + } return aOther; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java index 51bedaf64b..ef68436f21 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java @@ -1,6 +1,9 @@ package gtPlusPlus.core.util.minecraft; +import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.objects.Logger; +import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; import ic2.api.item.ISpecialElectricItem; @@ -33,8 +36,16 @@ public class EnergyUtils { return 0 != GT_ModHandler.chargeElectricItem(aStack, aEnergyToInsert, aTier, true, false); } - public static boolean discharge(ItemStack aStack, int aEnergyToInsert, int aTier) { - return 0 != GT_ModHandler.dischargeElectricItem(aStack, -aEnergyToInsert, aTier, true, false, true); + public static boolean discharge(ItemStack aStack, int aEnergyToDrain, int aTier) { + if (isElectricItem(aStack)) { + int tTier = ((IElectricItem) aStack.getItem()).getTier(aStack); + int aDischargeValue = GT_ModHandler.dischargeElectricItem(aStack, aEnergyToDrain, tTier, true, false, false); + Logger.INFO("Trying to drain "+aDischargeValue); + return aDischargeValue > 0; + } + else { + return false; + } } public static long getMaxStorage(ItemStack aStack) { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java index 8f12d20494..aaa81a0057 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java @@ -17,10 +17,14 @@ public class InventoryUtils { public static void dropInventoryItems(World world, int x, int y, int z, Block block) { TileEntity tileentity = world.getTileEntity(x, y, z); - if (tileentity != null && tileentity instanceof IInventory - && ((IInventory) tileentity).getSizeInventory() > 0) { - for (int i1 = 0; i1 < ((IInventory) tileentity).getSizeInventory(); ++i1) { - ItemStack itemstack = ((IInventory) tileentity).getStackInSlot(i1); + if (tileentity != null && tileentity instanceof IInventory && ((IInventory) tileentity).getSizeInventory() > 0) { + + IInventory aTileInv = (IInventory) tileentity; + int aMinSlot = 0; + int aMaxSlot = aTileInv.getSizeInventory()-1; + + for (int i1 = aMinSlot; i1 < aMaxSlot; ++i1) { + ItemStack itemstack = aTileInv.getStackInSlot(i1); if (itemstack != null) { float f = mRandom.nextFloat() * 0.8F + 0.1F; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java index 8c7413f5b9..4394aa0f04 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BusPatch.java @@ -1,26 +1,6 @@ package gtPlusPlus.preloader.asm.transformers; -import static org.objectweb.asm.Opcodes.AASTORE; -import static org.objectweb.asm.Opcodes.ACC_PUBLIC; -import static org.objectweb.asm.Opcodes.ACONST_NULL; -import static org.objectweb.asm.Opcodes.ALOAD; -import static org.objectweb.asm.Opcodes.ANEWARRAY; -import static org.objectweb.asm.Opcodes.ASM5; -import static org.objectweb.asm.Opcodes.DUP; -import static org.objectweb.asm.Opcodes.F_FULL; -import static org.objectweb.asm.Opcodes.GOTO; -import static org.objectweb.asm.Opcodes.ICONST_0; -import static org.objectweb.asm.Opcodes.ICONST_1; -import static org.objectweb.asm.Opcodes.ICONST_2; -import static org.objectweb.asm.Opcodes.IF_ICMPLT; -import static org.objectweb.asm.Opcodes.ILOAD; -import static org.objectweb.asm.Opcodes.INTEGER; -import static org.objectweb.asm.Opcodes.INVOKESPECIAL; -import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; -import static org.objectweb.asm.Opcodes.NEW; -import static org.objectweb.asm.Opcodes.PUTFIELD; -import static org.objectweb.asm.Opcodes.RETURN; -import static org.objectweb.asm.Opcodes.UNINITIALIZED_THIS; +import static org.objectweb.asm.Opcodes.*; import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; @@ -37,7 +17,7 @@ public class ClassTransformer_GT_BusPatch { public static final String aSuperOutput = "gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_SuperBus_Output"; public static final String aInput = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus"; public static final String aOutput = "gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus"; - + private final boolean isValid; private final ClassReader reader; private final ClassWriter writer; @@ -52,7 +32,7 @@ public class ClassTransformer_GT_BusPatch { aTempReader = new ClassReader(basicClass); aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); - aTempReader.accept(new localClassVisitor(aTempWriter), 0); + aTempReader.accept(new localClassVisitor(aTempWriter, aClassName), 0); if (aTempReader != null && aTempWriter != null) { isValid = true; @@ -83,85 +63,168 @@ public class ClassTransformer_GT_BusPatch { public ClassWriter getWriter() { return writer; } - - + + public boolean injectMethod(String aClassName) { boolean didInject = false; MethodVisitor mv; ClassWriter cw = getWriter(); + int aConID = 1; //GT_MetaTileEntity_Hatch_InputBus //Constructor if (aClassName.equals(aInput)){ - mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(19, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitVarInsn(ALOAD, 2); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ILOAD, 4); - mv.visitVarInsn(ILOAD, 5); - mv.visitInsn(ICONST_2); - mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); - mv.visitInsn(DUP); - mv.visitInsn(ICONST_0); - mv.visitLdcInsn("Item Input for Multiblocks"); - mv.visitInsn(AASTORE); - mv.visitInsn(DUP); - mv.visitInsn(ICONST_1); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(20, l1); - mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); - mv.visitInsn(DUP); - mv.visitLdcInsn("Capacity: "); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); - mv.visitVarInsn(ILOAD, 5); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); - mv.visitLdcInsn(" stack"); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); - mv.visitVarInsn(ILOAD, 5); - mv.visitInsn(ICONST_2); - Label l2 = new Label(); - mv.visitJumpInsn(IF_ICMPLT, l2); - mv.visitLdcInsn("s"); - Label l3 = new Label(); - mv.visitJumpInsn(GOTO, l3); - mv.visitLabel(l2); - mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 10, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder"}); - mv.visitLdcInsn(""); - mv.visitLabel(l3); - mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 11, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder", "java/lang/String"}); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); - mv.visitInsn(AASTORE); - mv.visitInsn(ICONST_0); - mv.visitTypeInsn(ANEWARRAY, "gregtech/api/interfaces/ITexture"); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;[Lgregtech/api/interfaces/ITexture;)V", false); - Label l4 = new Label(); - mv.visitLabel(l4); - mv.visitLineNumber(16, l4); - mv.visitVarInsn(ALOAD, 0); - mv.visitInsn(ACONST_NULL); - mv.visitFieldInsn(PUTFIELD, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); - Label l5 = new Label(); - mv.visitLabel(l5); - mv.visitLineNumber(21, l5); - mv.visitInsn(RETURN); - Label l6 = new Label(); - mv.visitLabel(l6); - mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus;", null, l0, l6, 0); - mv.visitLocalVariable("aID", "I", null, l0, l6, 1); - mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l6, 2); - mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l6, 3); - mv.visitLocalVariable("aTier", "I", null, l0, l6, 4); - mv.visitLocalVariable("aSlots", "I", null, l0, l6, 5); - mv.visitMaxs(12, 6); - mv.visitEnd(); + + //Constructor 1 + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(19, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ILOAD, 4); + mv.visitVarInsn(ILOAD, 5); + mv.visitInsn(ICONST_2); + mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); + mv.visitInsn(DUP); + mv.visitInsn(ICONST_0); + mv.visitLdcInsn("Item Input for Multiblocks"); + mv.visitInsn(AASTORE); + mv.visitInsn(DUP); + mv.visitInsn(ICONST_1); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(20, l1); + mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); + mv.visitInsn(DUP); + mv.visitLdcInsn("Capacity: "); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); + mv.visitLdcInsn(" stack"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitInsn(ICONST_2); + Label l2 = new Label(); + mv.visitJumpInsn(IF_ICMPLT, l2); + mv.visitLdcInsn("s"); + Label l3 = new Label(); + mv.visitJumpInsn(GOTO, l3); + mv.visitLabel(l2); + mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 10, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder"}); + mv.visitLdcInsn(""); + mv.visitLabel(l3); + mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 11, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder", "java/lang/String"}); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); + mv.visitInsn(AASTORE); + mv.visitInsn(ICONST_0); + mv.visitTypeInsn(ANEWARRAY, "gregtech/api/interfaces/ITexture"); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;[Lgregtech/api/interfaces/ITexture;)V", false); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(16, l4); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitFieldInsn(PUTFIELD, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(21, l5); + mv.visitInsn(RETURN); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus;", null, l0, l6, 0); + mv.visitLocalVariable("aID", "I", null, l0, l6, 1); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l6, 2); + mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l6, 3); + mv.visitLocalVariable("aTier", "I", null, l0, l6, 4); + mv.visitLocalVariable("aSlots", "I", null, l0, l6, 5); + mv.visitMaxs(12, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + + //Constructor 2 + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(29, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitVarInsn(ALOAD, 5); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(16, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitFieldInsn(PUTFIELD, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(30, l2); + mv.visitInsn(RETURN); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus;", null, l0, l3, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l3, 2); + mv.visitLocalVariable("aSlots", "I", null, l0, l3, 3); + mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l3, 4); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 5); + mv.visitMaxs(6, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + + //Third constructor with String[] for GT 5.09 + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(33, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitVarInsn(ALOAD, 5); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(16, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitFieldInsn(PUTFIELD, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(34, l2); + mv.visitInsn(RETURN); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus;", null, l0, l3, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l3, 2); + mv.visitLocalVariable("aSlots", "I", null, l0, l3, 3); + mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l3, 4); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 5); + mv.visitMaxs(6, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + + + didInject = true; } @@ -169,68 +232,131 @@ public class ClassTransformer_GT_BusPatch { //GT_MetaTileEntity_Hatch_OutputBus //Constructor if (aClassName.equals(aOutput)){ - mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(16, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitVarInsn(ALOAD, 2); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ILOAD, 4); - mv.visitVarInsn(ILOAD, 5); - mv.visitInsn(ICONST_2); - mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); - mv.visitInsn(DUP); - mv.visitInsn(ICONST_0); - mv.visitLdcInsn("Item Output for Multiblocks"); - mv.visitInsn(AASTORE); - mv.visitInsn(DUP); - mv.visitInsn(ICONST_1); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(17, l1); - mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); - mv.visitInsn(DUP); - mv.visitLdcInsn("Capacity: "); - mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); - mv.visitVarInsn(ILOAD, 5); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); - mv.visitLdcInsn(" stack"); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); - mv.visitVarInsn(ILOAD, 5); - mv.visitInsn(ICONST_2); - Label l2 = new Label(); - mv.visitJumpInsn(IF_ICMPLT, l2); - mv.visitLdcInsn("s"); - Label l3 = new Label(); - mv.visitJumpInsn(GOTO, l3); - mv.visitLabel(l2); - mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 10, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder"}); - mv.visitLdcInsn(""); - mv.visitLabel(l3); - mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 11, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder", "java/lang/String"}); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); - mv.visitInsn(AASTORE); - mv.visitInsn(ICONST_0); - mv.visitTypeInsn(ANEWARRAY, "gregtech/api/interfaces/ITexture"); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;[Lgregtech/api/interfaces/ITexture;)V", false); - Label l4 = new Label(); - mv.visitLabel(l4); - mv.visitLineNumber(18, l4); - mv.visitInsn(RETURN); - Label l5 = new Label(); - mv.visitLabel(l5); - mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus;", null, l0, l5, 0); - mv.visitLocalVariable("aID", "I", null, l0, l5, 1); - mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l5, 2); - mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l5, 3); - mv.visitLocalVariable("aTier", "I", null, l0, l5, 4); - mv.visitLocalVariable("aSlots", "I", null, l0, l5, 5); - mv.visitMaxs(12, 6); - mv.visitEnd(); + + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(16, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ILOAD, 4); + mv.visitVarInsn(ILOAD, 5); + mv.visitInsn(ICONST_2); + mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); + mv.visitInsn(DUP); + mv.visitInsn(ICONST_0); + mv.visitLdcInsn("Item Output for Multiblocks"); + mv.visitInsn(AASTORE); + mv.visitInsn(DUP); + mv.visitInsn(ICONST_1); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(17, l1); + mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); + mv.visitInsn(DUP); + mv.visitLdcInsn("Capacity: "); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); + mv.visitLdcInsn(" stack"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitInsn(ICONST_2); + Label l2 = new Label(); + mv.visitJumpInsn(IF_ICMPLT, l2); + mv.visitLdcInsn("s"); + Label l3 = new Label(); + mv.visitJumpInsn(GOTO, l3); + mv.visitLabel(l2); + mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 10, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder"}); + mv.visitLdcInsn(""); + mv.visitLabel(l3); + mv.visitFrame(F_FULL, 6, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER}, 11, new Object[] {UNINITIALIZED_THIS, INTEGER, "java/lang/String", "java/lang/String", INTEGER, INTEGER, "[Ljava/lang/String;", "[Ljava/lang/String;", INTEGER, "java/lang/StringBuilder", "java/lang/String"}); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); + mv.visitInsn(AASTORE); + mv.visitInsn(ICONST_0); + mv.visitTypeInsn(ANEWARRAY, "gregtech/api/interfaces/ITexture"); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(ILjava/lang/String;Ljava/lang/String;II[Ljava/lang/String;[Lgregtech/api/interfaces/ITexture;)V", false); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(18, l4); + mv.visitInsn(RETURN); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus;", null, l0, l5, 0); + mv.visitLocalVariable("aID", "I", null, l0, l5, 1); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l5, 2); + mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l5, 3); + mv.visitLocalVariable("aTier", "I", null, l0, l5, 4); + mv.visitLocalVariable("aSlots", "I", null, l0, l5, 5); + mv.visitMaxs(12, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(26, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitVarInsn(ALOAD, 5); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(27, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus;", null, l0, l2, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l2, 2); + mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3); + mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l2, 4); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5); + mv.visitMaxs(6, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(30, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitVarInsn(ALOAD, 5); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch", "<init>", "(Ljava/lang/String;II[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(31, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus;", null, l0, l2, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l2, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l2, 2); + mv.visitLocalVariable("aSlots", "I", null, l0, l2, 3); + mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l2, 4); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l2, 5); + mv.visitMaxs(6, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + didInject = true; } @@ -238,97 +364,264 @@ public class ClassTransformer_GT_BusPatch { //GT_MetaTileEntity_SuperBus_Input //Constructor if (aClassName.equals(aSuperInput)){ - mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(27, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitVarInsn(ALOAD, 2); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ILOAD, 4); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "<init>", "(ILjava/lang/String;Ljava/lang/String;I)V", false); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(20, l1); - mv.visitVarInsn(ALOAD, 0); - mv.visitInsn(ACONST_NULL); - mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); - Label l2 = new Label(); - mv.visitLabel(l2); - mv.visitLineNumber(28, l2); - mv.visitInsn(RETURN); - Label l3 = new Label(); - mv.visitLabel(l3); - mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input;", null, l0, l3, 0); - mv.visitLocalVariable("aID", "I", null, l0, l3, 1); - mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 2); - mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l3, 3); - mv.visitLocalVariable("aTier", "I", null, l0, l3, 4); - mv.visitLocalVariable("aSlots", "I", null, l0, l3, 5); - mv.visitMaxs(5, 6); - mv.visitEnd(); + + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(27, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ILOAD, 4); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "<init>", "(ILjava/lang/String;Ljava/lang/String;I)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(20, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(28, l2); + mv.visitInsn(RETURN); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input;", null, l0, l3, 0); + mv.visitLocalVariable("aID", "I", null, l0, l3, 1); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 2); + mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l3, 3); + mv.visitLocalVariable("aTier", "I", null, l0, l3, 4); + mv.visitLocalVariable("aSlots", "I", null, l0, l3, 5); + mv.visitMaxs(5, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;ILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(27, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "getSlots", "(I)I", false); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(20, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(28, l2); + mv.visitInsn(RETURN); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input;", null, l0, l3, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l3, 2); + mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l3, 3); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 4); + mv.visitMaxs(6, 5); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;I[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(31, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "getSlots", "(I)I", false); + mv.visitVarInsn(ALOAD, 3); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(20, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(32, l2); + mv.visitInsn(RETURN); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input;", null, l0, l3, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l3, 2); + mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l3, 3); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 4); + mv.visitMaxs(6, 5); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + + didInject = true; } - + //GT_MetaTileEntity_SuperBus_Output //Constructor if (aClassName.equals(aSuperOutput)){ - mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); - mv.visitCode(); - Label l0 = new Label(); - mv.visitLabel(l0); - mv.visitLineNumber(25, l0); - mv.visitVarInsn(ALOAD, 0); - mv.visitVarInsn(ILOAD, 1); - mv.visitVarInsn(ALOAD, 2); - mv.visitVarInsn(ALOAD, 3); - mv.visitVarInsn(ILOAD, 4); - mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus", "<init>", "(ILjava/lang/String;Ljava/lang/String;I)V", false); - Label l1 = new Label(); - mv.visitLabel(l1); - mv.visitLineNumber(18, l1); - mv.visitVarInsn(ALOAD, 0); - mv.visitInsn(ACONST_NULL); - mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); - Label l2 = new Label(); - mv.visitLabel(l2); - mv.visitLineNumber(26, l2); - mv.visitInsn(RETURN); - Label l3 = new Label(); - mv.visitLabel(l3); - mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output;", null, l0, l3, 0); - mv.visitLocalVariable("aID", "I", null, l0, l3, 1); - mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 2); - mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l3, 3); - mv.visitLocalVariable("aTier", "I", null, l0, l3, 4); - mv.visitLocalVariable("aSlots", "I", null, l0, l3, 5); - mv.visitMaxs(5, 6); - mv.visitEnd(); + + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(ILjava/lang/String;Ljava/lang/String;II)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(25, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ILOAD, 4); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus", "<init>", "(ILjava/lang/String;Ljava/lang/String;I)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(18, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(26, l2); + mv.visitInsn(RETURN); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output;", null, l0, l3, 0); + mv.visitLocalVariable("aID", "I", null, l0, l3, 1); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 2); + mv.visitLocalVariable("aNameRegional", "Ljava/lang/String;", null, l0, l3, 3); + mv.visitLocalVariable("aTier", "I", null, l0, l3, 4); + mv.visitLocalVariable("aSlots", "I", null, l0, l3, 5); + mv.visitMaxs(5, 6); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;ILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(25, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "getSlots", "(I)I", false); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(18, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(26, l2); + mv.visitInsn(RETURN); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output;", null, l0, l3, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l3, 2); + mv.visitLocalVariable("aDescription", "Ljava/lang/String;", null, l0, l3, 3); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 4); + mv.visitMaxs(6, 5); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/lang/String;I[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(29, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "getSlots", "(I)I", false); + mv.visitVarInsn(ALOAD, 3); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKESPECIAL, "gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus", "<init>", "(Ljava/lang/String;IILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(18, l1); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitFieldInsn(PUTFIELD, "gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output", "mRecipeMap", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(30, l2); + mv.visitInsn(RETURN); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLocalVariable("this", "LgtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output;", null, l0, l3, 0); + mv.visitLocalVariable("aName", "Ljava/lang/String;", null, l0, l3, 1); + mv.visitLocalVariable("aTier", "I", null, l0, l3, 2); + mv.visitLocalVariable("aDescription", "[Ljava/lang/String;", null, l0, l3, 3); + mv.visitLocalVariable("aTextures", "[[[Lgregtech/api/interfaces/ITexture;", null, l0, l3, 4); + mv.visitMaxs(6, 5); + mv.visitEnd(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Injection new constructor "+(aConID++)); + } + didInject = true; } - FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Method injection complete."); - return didInject; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Method injection complete. Successful? "+didInject); + return didInject; } - + public final class localClassVisitor extends ClassVisitor { - public localClassVisitor(ClassVisitor cv) { + private final String mClassName; + + public localClassVisitor(ClassVisitor cv, String aClassName) { super(ASM5, cv); + mClassName = aClassName; } @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor methodVisitor; - methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + if ((mClassName.equals(aSuperInput) || mClassName.equals(aSuperOutput)) && access == ACC_PUBLIC && name.equals("<init>") && (desc.equals("(Ljava/lang/String;ILjava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V") || desc.equals("(Ljava/lang/String;I[Ljava/lang/String;[[[Lgregtech/api/interfaces/ITexture;)V"))) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Found Constructor, "+"'"+access+"', "+"'"+name+"', "+"'"+desc+"', "+"'"+signature+"'"); + methodVisitor = null; + } + else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + if (methodVisitor == null) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Bus Patch", Level.INFO, "Removed Constructor with descriptor '"+desc+"' from "+mClassName); + } return methodVisitor; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java index d6906c7b67..e0844bb071 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java @@ -129,7 +129,7 @@ public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_In String[] aDesc = new String[] { "Item Input for Multiblocks", "This bus has no GUI, but can have items extracted", - ""+this.getSlots(this.mTier)+" Slots", + ""+getSlots(this.mTier)+" Slots", }; return aDesc; } @@ -164,7 +164,7 @@ public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_In } if (aNames == null || aNames.length <= 0) { - PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) is Empty. Total Slots: "+this.getSlots(this.mTier)); + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) is Empty. Total Slots: "+getSlots(this.mTier)); return; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java index 4fac3d36d8..3afa3312b1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java @@ -96,7 +96,7 @@ public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_O String[] aDesc = new String[] { "Item Output for Multiblocks", "This bus has no GUI", - ""+this.getSlots(this.mTier)+" Slots", + ""+getSlots(this.mTier)+" Slots", }; return aDesc; } @@ -130,7 +130,7 @@ public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_O } if (aNames == null || aNames.length <= 0) { - PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) is Empty. Total Slots: "+this.getSlots(this.mTier)); + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) is Empty. Total Slots: "+getSlots(this.mTier)); return; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 9fb9e3514e..5791cfbf73 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; import java.util.concurrent.ScheduledExecutorService; import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; @@ -291,23 +292,27 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); if (EU.getCharge(invItem) >= tVoltage) { - if (EU.discharge(invItem, (int) tVoltage, tTier)) { + Logger.WARNING("Can drain."); + if (EU.discharge(invItem, (int) tVoltage, -1)) { + Logger.WARNING("Drained Power."); + didElectricDamage = true; } else { + Logger.WARNING("Failed when draining Power."); this.getBaseMetaTileEntity().disableWorking(); } - didElectricDamage = true; } } } + Logger.WARNING("Drained Power? "+didElectricDamage); - //Logger.INFO("dmg: "+aDmg+" | max: "+aDmgMax); - if (!didElectricDamage) { + if (!didElectricDamage && invItem.getItem() instanceof GT_MetaGenerated_Tool) { long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); long aDmgMax = GT_MetaGenerated_Tool.getToolMaxDamage(invItem); - if (aDmg < aDmgMax && invItem.isItemStackDamageable()) { + if (aDmg < aDmgMax && GT_MetaGenerated_Tool.getPrimaryMaterial(invItem) != Materials._NULL) { + Logger.WARNING("dmg: "+aDmg+" | max: "+aDmgMax); GT_MetaGenerated_Tool.setToolDamage(invItem, aDmg+getDamageToComponent(invItem)); } else if (aDmg >= aDmgMax) { diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index 9ce7e83082..1ddcef9c74 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -2871,4 +2871,29 @@ item.itemRotorWhiteMetal.name=White Metal Rotor item.itemGearWhiteMetal.name=White Metal Gear item.itemCellWhiteMetal.name=White Metal Cell tile.Block of White Metal.name=Block of White Metal -tile.White Metal Frame Box.name=White Metal Frame Box
\ No newline at end of file +tile.White Metal Frame Box.name=White Metal Frame Box + +//Added 29/04/2019 +tile.OreRunite.name=Runite Ore +item.crushedRunite.name=Crushed Runite Ore +item.crushedCentrifugedRunite.name=Centrifuged Crushed Runite Ore +item.crushedPurifiedRunite.name=Purified Crushed Runite Ore +item.dustImpureRunite.name=Impure Runite Dust +item.dustPureRunite.name=Purified Runite Dust + +tile.OreAncientGranite.name=Ancient Granite Ore +item.crushedAncientGranite.name=Crushed Ancient Granite Ore +item.crushedCentrifugedAncientGranite.name=Centrifuged Crushed Ancient Granite Ore +item.crushedPurifiedAncientGranite.name=Purified Crushed Ancient Granite Ore +item.dustImpureAncientGranite.name=Impure Ancient Granite Dust +item.dustPureAncientGranite.name=Purified Ancient Granite Dust + +item.itemIngotRhugnor.name=Rhugnor Ingot +item.itemDustRhugnor.name=Rhugnor Dust +item.itemDustTinyRhugnor.name=Tiny Pile of Rhugnor Dust +item.itemDustSmallRhugnor.name=Small Pile of Rhugnor Dust +item.itemNuggetRhugnor.name=Rhugnor Nugget +item.itemPlateRhugnor.name=Rhugnor Plate +item.itemPlateDoubleRhugnor.name=Double Rhugnor Plate +item.itemCellRhugnor.name=Rhugnor Cell +tile.Block of Rhugnor.name=Block of Rhugnor
\ No newline at end of file |