From f18c0e23ce7602f66bb2cf50216d51413147034b Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 5 Feb 2019 05:50:54 +0000 Subject: + Added recipes for ULV generators. + Added recipes for New batteries and their components. (To be use in the charger packs). % Mildly adjusted Circuit programmer recipe. % Adjusted Plasma hatch to be output only. $ Fixed bad tooltips on material blocks/frames. $ Fixed Lang formatting issue. --- .../xmod/gregtech/api/enums/GregtechItemList.java | 9 +++++++-- .../GT_MetaTileEntity_Hatch_Plasma.java | 3 ++- .../common/items/MetaGeneratedGregtechItems.java | 22 ++++++++++++++++------ .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 17 ++++++++++++++++- 4 files changed, 41 insertions(+), 10 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index c228364149..f377a2da3d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -84,8 +84,13 @@ public enum GregtechItemList implements GregtechItemContainer { //Computer Cube Gregtech_Computer_Cube, - //Custom Batteries (Unused) - Battery_Gem_1, Battery_Gem_2, Battery_Gem_3, + //Casings for batteries + Battery_Casing_Gem_1, Battery_Casing_Gem_2, + Battery_Casing_Gem_3, Battery_Casing_Gem_4, + + //Custom Batteries + Battery_Gem_1, Battery_Gem_2, + Battery_Gem_3, Battery_Gem_4, //Compressed Fusion MK3 Compressed_Fusion_Reactor, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java index aeae474fb7..30c1bc2b29 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -9,6 +9,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -19,7 +20,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Input { +public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Output { public final AutoMap mFluidsToUse = new AutoMap(); public final int mFluidCapacity; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index 7f426f8abb..5f255069bf 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -169,12 +169,12 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { * Power Gems */ - GregtechItemList.Battery_Gem_1.set(this.addItem(tLastID = 66, "Fission Power Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 24L), getTcAspectStack(TC_Aspects.POTENTIA, 16L)})); - this.setElectricStats(32000 + tLastID, 32000000L, GT_Values.V[5], 5L, -3L, false); - GregtechItemList.Battery_Gem_2.set(this.addItem(tLastID = 68, "Fusion Power Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.METALLUM, 32L), getTcAspectStack(TC_Aspects.POTENTIA, 32L)})); - this.setElectricStats(32000 + tLastID, 750000000L, GT_Values.V[6], 6L, -3L, false); - GregtechItemList.Battery_Gem_3.set(this.addItem(tLastID = 70, "Portable Neutron Star", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 32L), getTcAspectStack(TC_Aspects.METALLUM, 48L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); - this.setElectricStats(32000 + tLastID, 64000000000L, GT_Values.V[7], 7L, -3L, false); + GregtechItemList.Battery_Gem_1.set(this.addItem(tLastID = 66, "Proton Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 24L), getTcAspectStack(TC_Aspects.POTENTIA, 16L)})); + this.setElectricStats(32000 + tLastID, 32000000L, GT_Values.V[6], 6L, -3L, false); + GregtechItemList.Battery_Gem_2.set(this.addItem(tLastID = 68, "Electron Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.METALLUM, 32L), getTcAspectStack(TC_Aspects.POTENTIA, 32L)})); + this.setElectricStats(32000 + tLastID, 750000000L, GT_Values.V[7], 7L, -3L, false); + GregtechItemList.Battery_Gem_3.set(this.addItem(tLastID = 70, "Quark Entanglement", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 32L), getTcAspectStack(TC_Aspects.METALLUM, 48L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); + this.setElectricStats(32000 + tLastID, 64000000000L, GT_Values.V[8], 8L, -3L, false); //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_1.get(1), "batteryFutureBasic"); //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_2.get(1), "batteryFutureGood"); //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_3.get(1), "batteryFutureAdvanced"); @@ -294,6 +294,16 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { GregtechItemList.Carbyne_Sheet_Finished.set(this.addItem(104, "Carbyne Composite Panel", "Nanotubes which contain LAC, arranged side by side and compressed further", new Object[0])); GregtechItemList.Laser_Lens_Special.set(this.addItem(105, "Quantum Anomaly", "Probably should shoot it with lasers", new Object[0])); + GregtechItemList.Battery_Casing_Gem_1.set(this.addItem(106, "Containment Unit I", "Used in crafting", new Object[0])); + GregtechItemList.Battery_Casing_Gem_2.set(this.addItem(107, "Containment Unit II", "Used in crafting", new Object[0])); + GregtechItemList.Battery_Casing_Gem_3.set(this.addItem(108, "Advanced Containment Unit", "Used in crafting", new Object[0])); + GregtechItemList.Battery_Casing_Gem_4.set(this.addItem(109, "Exotic Containment Unit", "Used in crafting", new Object[0])); + + GregtechItemList.Battery_Gem_4.set(this.addItem(tLastID = 110, "Graviton Anomaly", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 64L), getTcAspectStack(TC_Aspects.METALLUM, 64L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); + this.setElectricStats(32000 + tLastID, (64000000000L*16), GT_Values.V[9], 9L, -3L, false); + + + } private boolean registerComponents_ULV(){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index ace4876639..8f3e49d7b7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -750,7 +750,22 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { return CORE.RA.addComponentMakerRecipe(aInputs, aInputFluid, aOutput1, aDuration, aEUt); } - public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) { + public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs_OLD, ItemStack aOutput, int aDuration, int aEUt) { + + FluidStack[] aFluidInputs = new FluidStack[4]; + if (aFluidInputs_OLD != null) { + int aC = 0; + for (FluidStack s : aFluidInputs) { + if (aC > 3) { + break; + } + if (s != null) { + aFluidInputs[aC++] = s; + } + } + } + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { if (aInputs.length < 6 && aFluidInputs.length < 2) { ItemStack[] aInputStack = new ItemStack[] {aResearchItem, aInputs[0], aInputs[1], aInputs[2], aInputs[3], aInputs[4]}; -- cgit From 5507b8c0e7b2117a33dfb1fedbd14b3c30f6a01b Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 5 Feb 2019 20:02:33 +0000 Subject: + Added recipe for Nano Healer. + Added recipe for Strange Dust. + Added recipe for Slow Builders Ring. + Added recipes for Charge Packs. + Added recipes to make obtaining Zirconium a little earlier. + Added packager recipes for all ore materials. + Added lathe recipes for all materials -> rods. Closes #411. + Added way to process Silicon Carbide into Synthetic Graphite. Closes #407. + Added proper achievement localization for all new AL recipes. + Added more INIT_PHASE's. - Removed ways to obtain Trinium dust in GTNH. (Leave handling to GT instead). % Adjusted recipes for Cyclotron and Casings, it's now assembled instead of shape crafted. % Adjusted circuits used in lower tier dehydrator recipes for consistency. Closes #364. % Adjusted a few materials having '-' in their name within en_US.lang. % Adjusted power capacity of the Gem Batteries. % Adjusted tiering for Large Auto-Assembler, it has been reduced by one. % Adjusted composition of Pikyonium to now require Yttrium, instead of the rare Ytterbium. % Adjusted composition of DEEP_EARTH_REACTOR_FUEL_DEPOSIT to be slightly more balanced. % Adjusted smelting point of Zirconium Carbide. $ Fixed an NPE in GeneralTooltipEventHandler.java. $ Fixed weird invisible recipes. Closes #304. $ Confirmed Large Mixer is now working correctly. Closes #366. (Closed in previous commit https://github.com/draknyte1/GTplusplus/commit/918d763dabd82d47db739a1b0a51c01f0803adc0). $ Confirmed Matter Fabricator is now working correctly. Closes #360. + Auto Doors. Closes #338. (Closed in previous commit https://github.com/draknyte1/GTplusplus/commit/22c6a05a8a3a00294bcb8890a1e2a0fdc9196de8). % Changed Energy Buffer Recipes. Closes #52. (Closed in previous commit https://github.com/draknyte1/GTplusplus/commit/499411aa21ac4a742b6d51ef3ce9c4046d0a22c1). $ Invalid Recipe. Closes #241. (Closed in unknown, previous commit). --- src/Java/gtPlusPlus/GTplusplus.java | 6 +- .../handler/events/GeneralTooltipEventHandler.java | 11 +- .../core/item/base/rods/BaseItemRod.java | 30 +- .../core/item/base/screws/BaseItemScrew.java | 4 +- src/Java/gtPlusPlus/core/material/ALLOY.java | 6 +- src/Java/gtPlusPlus/core/material/ORES.java | 16 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 174 +++++++++++- .../gtPlusPlus/core/recipe/RECIPES_General.java | 183 ++++++------ .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 306 ++++++++++++--------- .../common/items/MetaGeneratedGregtechItems.java | 6 +- .../gregtech/loaders/RecipeGen_DustGeneration.java | 4 +- .../xmod/gregtech/loaders/RecipeGen_Ore.java | 9 + .../gregtech/loaders/RecipeGen_ShapedCrafting.java | 7 +- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 28 +- .../registration/gregtech/GregtechDehydrator.java | 6 +- src/resources/assets/gregtech/lang/en_US.lang | 91 ++++-- src/resources/assets/miscutils/lang/en_US.lang | 74 ++--- 17 files changed, 627 insertions(+), 334 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 79a3bee7ba..1c4789c28b 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -74,7 +74,9 @@ public class GTplusplus implements ActionListener { SUPER(null), PRE_INIT(SUPER), INIT(PRE_INIT), - POST_INIT(INIT); + POST_INIT(INIT), + SERVER_START(POST_INIT), + STARTED(SERVER_START); protected boolean mIsPhaseActive = false; private final INIT_PHASE mPrev; @@ -226,6 +228,7 @@ public class GTplusplus implements ActionListener { @EventHandler public synchronized void serverStarting(final FMLServerStartingEvent event) { + INIT_PHASE.SERVER_START.setPhaseActive(true); mChunkLoading.serverStarting(event); event.registerServerCommand(new CommandMath()); event.registerServerCommand(new CommandDebugChunks()); @@ -259,6 +262,7 @@ public class GTplusplus implements ActionListener { */ @Mod.EventHandler public void onLoadComplete(FMLLoadCompleteEvent event) { + INIT_PHASE.STARTED.setPhaseActive(true); proxy.onLoadComplete(event); generateGregtechRecipeMaps(); } diff --git a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java index 6c940371b3..6d09f65f3f 100644 --- a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java @@ -7,6 +7,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import gregtech.api.enums.ItemList; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -22,8 +24,13 @@ public class GeneralTooltipEventHandler { @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event){ + + if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED) { + return; + } + if (CORE.ConfigSwitches.chanceToDropFluoriteOre > 0) { - if (!BlockEventHandler.blockLimestone.isEmpty()) { + if (BlockEventHandler.blockLimestone != null && !BlockEventHandler.blockLimestone.isEmpty()) { for (ItemStack h : BlockEventHandler.blockLimestone) { if (h != null && Block.getBlockFromItem(h.getItem()) == Block.getBlockFromItem(event.itemStack.getItem())) { if (ItemUtils.getModId(h) != null && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { @@ -32,7 +39,7 @@ public class GeneralTooltipEventHandler { } } } - if (!BlockEventHandler.oreLimestone.isEmpty()) { + if (BlockEventHandler.oreLimestone != null && !BlockEventHandler.oreLimestone.isEmpty()) { for (ItemStack h : BlockEventHandler.oreLimestone) { if (h != null && Block.getBlockFromItem(h.getItem()) == Block.getBlockFromItem(event.itemStack.getItem())) { if (ItemUtils.getModId(h) != null && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java index b6a5dff2ac..eaa0905c93 100644 --- a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java @@ -14,22 +14,36 @@ public class BaseItemRod extends BaseItemComponent{ public BaseItemRod(final Material material) { super(material, BaseItemComponent.ComponentTypes.ROD); this.addExtruderRecipe(); + this.addLatheRecipe(); } private void addExtruderRecipe(){ Logger.WARNING("Adding cutter recipe for "+this.materialName+" Rods"); - final ItemStack stackStick = this.componentMaterial.getRod(1); final ItemStack stackBolt = this.componentMaterial.getBolt(4); - + if (ItemUtils.checkForInvalidItems(new ItemStack[] {stackStick, stackBolt})) - GT_Values.RA.addCutterRecipe( - stackStick, - stackBolt, - null, - (int) Math.max(this.componentMaterial.getMass() * 2L, 1L), - 4); + GT_Values.RA.addCutterRecipe( + stackStick, + stackBolt, + null, + (int) Math.max(this.componentMaterial.getMass() * 2L, 1L), + 4); + } + + + private void addLatheRecipe(){ + Logger.WARNING("Adding recipe for "+this.materialName+" Rod"); + ItemStack boltStack = this.componentMaterial.getIngot(1); + if (ItemUtils.checkForInvalidItems(boltStack)){ + GT_Values.RA.addLatheRecipe( + boltStack, + ItemUtils.getSimpleStack(this), + null, + (int) Math.max(this.componentMaterial.getMass() / 8L, 1L), + 4); + } } } diff --git a/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java index af74c1d535..29e525ed10 100644 --- a/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java +++ b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java @@ -18,8 +18,8 @@ public class BaseItemScrew extends BaseItemComponent{ private void addLatheRecipe(){ Logger.WARNING("Adding recipe for "+this.materialName+" Screws"); - final ItemStack boltStack = ItemUtils.getItemStackOfAmountFromOreDict(this.unlocalName.replace("itemScrew", "bolt"), 1); - if (null != boltStack){ + ItemStack boltStack = this.componentMaterial.getBolt(1); + if (ItemUtils.checkForInvalidItems(boltStack)){ GT_Values.RA.addLatheRecipe( boltStack, ItemUtils.getSimpleStack(this), diff --git a/src/Java/gtPlusPlus/core/material/ALLOY.java b/src/Java/gtPlusPlus/core/material/ALLOY.java index c7397962ad..4edd36c51f 100644 --- a/src/Java/gtPlusPlus/core/material/ALLOY.java +++ b/src/Java/gtPlusPlus/core/material/ALLOY.java @@ -524,11 +524,11 @@ public final class ALLOY { "Zirconium Carbide", //Material Name MaterialState.SOLID, //State new short[]{222, 202, 180, 0}, //Material Colour - 1855, //Melting Point in C + 1555, //Melting Point in C -1, -1, -1, - true, //Uses Blast furnace? + false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 50), @@ -787,7 +787,7 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().CERIUM, 6), new MaterialStack(ELEMENT.getInstance().ANTIMONY, 4), new MaterialStack(ELEMENT.getInstance().PLATINUM, 4), - new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), new MaterialStack(ALLOY.TUNGSTENSTEEL, 8) }); diff --git a/src/Java/gtPlusPlus/core/material/ORES.java b/src/Java/gtPlusPlus/core/material/ORES.java index a8b86a142c..801e4924b3 100644 --- a/src/Java/gtPlusPlus/core/material/ORES.java +++ b/src/Java/gtPlusPlus/core/material/ORES.java @@ -807,15 +807,15 @@ public final class ORES { -1, 4, //Radiation new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().RADON, 3), - new MaterialStack(ELEMENT.getInstance().RADIUM, 2), + new MaterialStack(ELEMENT.getInstance().RADON, 2), + new MaterialStack(ELEMENT.getInstance().RADIUM, 1), new MaterialStack(ELEMENT.getInstance().URANIUM235, 1), - new MaterialStack(ELEMENT.getInstance().URANIUM238, 13), - new MaterialStack(ELEMENT.getInstance().THORIUM, 28), - new MaterialStack(ELEMENT.getInstance().THORIUM232, 5), - new MaterialStack(FLUORCAPHITE, 4), - new MaterialStack(SAMARSKITE_Y, 6), - new MaterialStack(TITANITE, 2) + new MaterialStack(ELEMENT.getInstance().URANIUM238, 10), + new MaterialStack(ELEMENT.getInstance().THORIUM, 25), + new MaterialStack(ELEMENT.getInstance().THORIUM232, 4), + new MaterialStack(FLUORCAPHITE, 6), + new MaterialStack(SAMARSKITE_Y, 8), + new MaterialStack(TITANITE, 4) }); diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 72781e3e7f..9d34aa371d 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -22,6 +22,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.ORES; import gtPlusPlus.core.material.Particle; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.material.nuclear.NUCLIDE; @@ -122,6 +123,18 @@ public class RECIPES_GREGTECH { private static void assemblyLineRecipes() { + + + ItemStack[] aCoilWire = new ItemStack[] { + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 0, GTNH ? 64 : 32), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 1, GTNH ? 48 : 16), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 2, GTNH ? 32 : 8), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 3, GTNH ? 16 : 4), + }; + + + + //Containment Casings CORE.RA.addAssemblylineRecipe( ItemList.Field_Generator_IV.get(1), @@ -139,7 +152,8 @@ public class RECIPES_GREGTECH { CI.getTieredComponent(OrePrefixes.circuit, 5, GTNH ? 64 : 32), CI.getTieredComponent(OrePrefixes.circuit, 6, GTNH ? 32 : 16), CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 8), - GregtechItemList.Laser_Lens_Special.get(1) + GregtechItemList.Laser_Lens_Special.get(1), + aCoilWire[3] }, new FluidStack[] { ALLOY.NITINOL_60.getFluid(144 * 9 * (GTNH ? 4 : 2)), @@ -191,6 +205,7 @@ public class RECIPES_GREGTECH { CI.getTieredComponent(OrePrefixes.pipeHuge, 5, GTNH ? 16 : 4), CI.getTieredComponent(OrePrefixes.cableGt08, 7, GTNH ? 32 : 16), CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 8 : 4), + aCoilWire[2] }, new FluidStack[] { CI.getTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), @@ -230,6 +245,7 @@ public class RECIPES_GREGTECH { CI.getTieredComponent(OrePrefixes.circuit, j-2, GTNH ? 16 : 8), CI.getTieredComponent(OrePrefixes.cableGt08, j+1, GTNH ? 32 : 16), CI.getTieredComponent(OrePrefixes.gearGt, j-1, GTNH ? 8 : 4), + aCoilWire[aCasingSlot] }, new FluidStack[] { CI.getTieredFluid(j, 144 * 3 * (GTNH ? 16 : 8)), @@ -285,6 +301,93 @@ public class RECIPES_GREGTECH { } + //Nano Healer + CORE.RA.addAssemblylineRecipe( + ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1), + 20 * 60 * 10, + new ItemStack[] { + ItemUtils.getSimpleStack(aGemCasings[2], GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.plate, 8, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.cableGt02, 7, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 6 : 3), + CI.getTieredComponent(OrePrefixes.screw, 7, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, 5, GTNH ? 24 : 12), + CI.getTieredComponent(OrePrefixes.frameGt, 4, GTNH ? 12 : 6), + aCoilWire[3] + }, + new FluidStack[] { + CI.getTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(6, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + + }, + ItemUtils.getItemStack("miscutils:personalHealingDevice", 1), + 20 * 60 * 30 * (GTNH ? 2 : 1), + (int) GT_Values.V[7]); + + + + //Charge Pack LuV-UV + + ItemStack[] aChargeResearch = new ItemStack[] { + ItemUtils.getItemStack("miscutils:item.itemBufferCore7", 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack1, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack2, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack3, 1), + }; + + ItemStack[] aChargeOutputs = new ItemStack[] { + ItemUtils.getSimpleStack(ModItems.itemChargePack1, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack2, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack3, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack4, 1), + }; + + ItemStack[] aBufferCoreInputs = new ItemStack[] { + ItemUtils.getItemStack("miscutils:item.itemBufferCore7", GTNH ? 8 : 4), + ItemUtils.getItemStack("miscutils:item.itemBufferCore8", GTNH ? 8 : 4), + ItemUtils.getItemStack("miscutils:item.itemBufferCore9", GTNH ? 8 : 4), + ItemUtils.getItemStack("miscutils:item.itemBufferCore10", GTNH ? 8 : 4), + }; + + int aCurrSlot = 0; + for (int h = 6; h < 10; h++) { + CORE.RA.addAssemblylineRecipe( + aChargeResearch[aCurrSlot], + 20 * 60 * 10 * (aCurrSlot + 1), + new ItemStack[] { + ItemUtils.getSimpleStack( + aGemBatteries[aCurrSlot], GTNH ? 4 : 2), + aBufferCoreInputs[aCurrSlot], + aCoilWire[aCurrSlot], + CI.getTieredComponent(OrePrefixes.plate, h, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.plate, h-1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, h, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.circuit, h-1, GTNH ? 32 : 8), + CI.getTieredComponent(OrePrefixes.cableGt12, h-1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.screw, h, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, h-2, GTNH ? 32 : 16), + CI.getElectricMotor(h, GTNH ? 8 : 4), + CI.getFieldGenerator(h-1, 2), + CI.getRobotArm(h-2, GTNH ? 4 : 2), + }, + new FluidStack[] { + CI.getTieredFluid(h, 144 * 18 * (GTNH ? 8 : 4)), + CI.getTertiaryTieredFluid(h-1, 144 * 18 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(h-1, 144 * 18 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(h-2, 144 * 18 * (GTNH ? 8 : 4)), + }, + aChargeOutputs[aCurrSlot], + 20 * 60 * 30 * (GTNH ? 2 : 1) * (aCurrSlot+1), + (int) GT_Values.V[h]); + aCurrSlot++; + } + + + + @@ -1454,11 +1557,33 @@ public class RECIPES_GREGTECH { } private static void blastFurnaceRecipes() { + + //public boolean addBlastRecipe( + //ItemStack aInput1, ItemStack aInput2, + //FluidStack aFluidInput, FluidStack aFluidOutput, + //ItemStack aOutput1, ItemStack aOutput2, + //int aDuration, int aEUt, int aLevel) + GT_Values.RA.addBlastRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumFluoride", 2), ItemUtils.getItemStackOfAmountFromOreDict("dustBerylliumFluoride", 1), GT_Values.NF, GT_Values.NF, ItemUtils.getItemStackOfAmountFromOreDict("dustLi2BeF4", 3), null, 60 * 20, 2000, 3000); GT_Values.RA.addBlastRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustZrCl4", 1), null, GT_Values.NF, GT_Values.NF, ItemUtils.getItemStackOfAmountFromOreDict("dustCookedZrCl4", 1), null, 60 * 20, 340, 300); + + + //Synthetic Graphite + GT_Values.RA.addBlastRecipe( + CI.getNumberedCircuit(22), + ALLOY.SILICON_CARBIDE.getDust(16), + ELEMENT.getInstance().NITROGEN.getFluid(4000), + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustGraphite", 8), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallSilicon", 8), + 60 * 20, + MaterialUtils.getVoltageForTier(GTNH ? 5 : 4), + 4500); + + } private static void autoclaveRecipes() { @@ -1817,6 +1942,30 @@ public class RECIPES_GREGTECH { 15000); + //Create Strange Dust + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + ELEMENT.getInstance().PLUTONIUM238.getDust(1), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + }, + FluidUtils.getWildcardFluidStack("ender", 1000), + new ItemStack[] { + ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT.getDust(1) + }, + null, + new int[] { 2500 }, + 20 * 60 * 15, + (int) GT_Values.V[7], + 15000); + + @@ -1891,7 +2040,23 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustSmallRutile", 1), ItemUtils.getItemStackOfAmountFromOreDict("nuggetZirconium", 1), new int[] { 10000, 2500, 4000 }, 20 * 20, 24); + // Zircon + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedMagnetite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustMagnetite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallZircon", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyZircon", 1), new int[] { 10000, 1250, 2500 }, + 20 * 20, 24); + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedCassiterite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustCassiterite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallZircon", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyZircon", 1), new int[] { 10000, 1250, 2500 }, + 20 * 20, 24); + + + if (!GTNH) { // Trinium GT_Values.RA.addElectromagneticSeparatorRecipe( ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedNaquadah", 1), @@ -1914,7 +2079,12 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustWulfenite", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), new int[] { 10000, 3000, 3000 }, - 20 * 20, 24); + 20 * 20, 24); + } + + + + } private static void advancedMixerRecipes() { diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 976cf20703..500333a7a2 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -16,6 +16,7 @@ import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; @@ -159,27 +160,27 @@ public class RECIPES_General { } } - + //Shaped Crafting for ULV Material Dusts //Potin if (RecipeUtils.addShapelessGregtechRecipe(new Object[] {"dustLead", "dustBronze", "dustTin", - "dustLead", "dustBronze"}, ALLOY.POTIN.getDust(5))){ + "dustLead", "dustBronze"}, ALLOY.POTIN.getDust(5))){ Logger.INFO("Added shapeless recipe for Potin Dust."); } //Tumbaga if (RecipeUtils.addShapelessGregtechRecipe(new Object[] {"dustRoseGold", "dustGold", "dustGold", "dustGold", "dustCopper", "dustCopper"}, ALLOY.TUMBAGA.getDust(10))){ - Logger.INFO("Added shapeless recipe for Tumbaga Dust."); - } - - - - - - - - - + Logger.INFO("Added shapeless recipe for Tumbaga Dust."); + } + + + + + + + + + //Mining Explosive Logger.RECIPE("[Inspection] Explosives"); if (RecipeUtils.recipeBuilder( @@ -268,7 +269,19 @@ public class RECIPES_General { ItemUtils.getSimpleStack(ModBlocks.blockNet, 2))){ Logger.INFO("Added a recipe for Nets."); } - + + // Slow Builders Ring + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(Blocks.ice, 8), + ItemUtils.getSimpleStack(ModBlocks.blockNet, 8), ItemUtils.getSimpleStack(Blocks.vine, 8), + ALLOY.TUMBAGA.getRing(1), }, + FluidUtils.getWater(1000), // Fluid + ItemUtils.getItemStack("miscutils:SlowBuildingRing", 1), // Output + 20 * 30, // Dur + 16); // Eu + + + } @@ -300,8 +313,8 @@ public class RECIPES_General { input, input, input, input, input, input, output)){ - Logger.INFO("Added a recipe for Compressed Obsidian ["+r+"]"); - } + Logger.INFO("Added a recipe for Compressed Obsidian ["+r+"]"); + } if (RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{output}, ItemUtils.getSimpleStack(input, 9))){ Logger.INFO("Added a shapeless recipe for Compressed Obsidian ["+r+"]"); @@ -310,52 +323,52 @@ public class RECIPES_General { } return true; } - + private static void addHandPumpRecipes() { if (RecipeUtils.recipeBuilder( CI.electricPump_LV, "circuitBasic", null, "ringBrass", CI.electricMotor_LV, "circuitBasic", "plateSteel", "plateSteel", "rodBrass", ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1))) - Logger.INFO("Added recipe for Hand Pump I - true"); + Logger.INFO("Added recipe for Hand Pump I - true"); if (RecipeUtils.recipeBuilder( CI.electricPump_MV, "circuitAdvanced", null, "ringMagnalium", CI.electricMotor_MV, "circuitAdvanced", "plateAluminium", "plateAluminium", "rodMagnalium", ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1))) - Logger.INFO("Added recipe for Hand Pump II - true"); + Logger.INFO("Added recipe for Hand Pump II - true"); if (RecipeUtils.recipeBuilder( CI.electricPump_HV, "circuitData", null, "ringChrome", CI.electricMotor_HV, "circuitData", "plateStainlessSteel", "plateStainlessSteel", "rodChrome", ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1))) - Logger.INFO("Added recipe for Hand Pump III - true"); + Logger.INFO("Added recipe for Hand Pump III - true"); if (RecipeUtils.recipeBuilder( CI.electricPump_EV, "circuitElite", null, "ringTitanium", CI.electricMotor_EV, "circuitElite", "plateTungstenSteel", "plateTungstenSteel", "rodTitanium", ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1))) - Logger.INFO("Added recipe for Hand Pump IV - true"); - - - + Logger.INFO("Added recipe for Hand Pump IV - true"); + + + GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1000, 1), 30, 30); GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1001, 1), 120, 120); GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1002, 1), 480, 480); GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1003, 1), 1820, 1820); - - + + } - + private static void migratedRecipes() { - + RecipeUtils.generateMortarRecipe(ItemUtils.getSimpleStack(ModItems.itemPlateRawMeat), ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1)); - + generateWireRecipes(ELEMENT.getInstance().ZIRCONIUM); generateWireRecipes(ALLOY.HG1223); generateWireRecipes(ALLOY.LEAGRISIUM); generateWireRecipes(ALLOY.TRINIUM_TITANIUM); - + GT_Materials[] g = new GT_Materials[] { GT_Materials.Staballoy, GT_Materials.Tantalloy60, @@ -368,7 +381,7 @@ public class RECIPES_General { GT_Materials.Inconel792, GT_Materials.HastelloyX, GT_Materials.TriniumNaquadahCarbonite, - + }; for (GT_Materials e : g) { if (e == GT_Materials.Void) { @@ -379,16 +392,16 @@ public class RECIPES_General { int tVoltageMultiplier = (e.mBlastFurnaceTemp >= 2800) ? 64 : 16; generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); } - + Materials[] h = new Materials[] { Materials.Europium, Materials.Tungsten, Materials.DarkSteel, Materials.Clay, Materials.Lead, - + }; - + for (Materials e : h) { if (e == Materials.DarkSteel) { if (!LoadedMods.EnderIO) { @@ -398,13 +411,13 @@ public class RECIPES_General { int tVoltageMultiplier = (e.mBlastFurnaceTemp >= 2800) ? 64 : 16; generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); } - + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[4], "rotorGtStainlessSteel", CI.component_Plate[4], - CI.getTieredCircuitOreDictName(3), CI.machineHull_HV, CI.getTieredCircuitOreDictName(3), - CI.component_Plate[4], CI.electricPump_HV, CI.component_Plate[4], - GregtechItemList.Hatch_Air_Intake.get(1L, new Object[0])); + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[4], "rotorGtStainlessSteel", CI.component_Plate[4], + CI.getTieredCircuitOreDictName(3), CI.machineHull_HV, CI.getTieredCircuitOreDictName(3), + CI.component_Plate[4], CI.electricPump_HV, CI.component_Plate[4], + GregtechItemList.Hatch_Air_Intake.get(1L, new Object[0])); RecipeUtils.addShapedGregtechRecipe(CI.component_Plate[6], ALLOY.MARAGING250.getGear(1), CI.component_Plate[6], CI.getTieredCircuitOreDictName(4), GregtechItemList.Casing_AdvancedVacuum.get(1), @@ -420,55 +433,55 @@ public class RECIPES_General { CI.getTieredCircuitOreDictName(7), GregtechItemList.Casing_Naq_Reactor_A.get(1), CI.getTieredCircuitOreDictName(7), CI.component_Plate[9], ItemList.Hatch_Input_ZPM.get(1), CI.component_Plate[8], GregtechItemList.Hatch_Input_Naquadah.get(1L, new Object[0])); - + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_LV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_MV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_HV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_HV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_HV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_EV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_EV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_EV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_IV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_IV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_IV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LuV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LuV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_LuV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_ZPM.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_ZPM.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_ZPM.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_UV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_UV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_UV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MAX.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MAX.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_MAX.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_LV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_MV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_HV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_HV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_HV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_EV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_EV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_EV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_IV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_IV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_IV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LuV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LuV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_LuV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_ZPM.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_ZPM.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_ZPM.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_UV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_UV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_UV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MAX.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MAX.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_MAX.get(1) }); } - - - - - - - - - - + + + + + + + + + + } - - - - - - - + + + + + + + } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 5b2a8c1300..e7577071c6 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -288,71 +288,71 @@ public class RECIPES_Machines { //Computer Cube CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - ItemUtils.getSimpleStack(CI.getDataOrb(), 4 * (GTNH ? 2 : 1)), - ItemList.Cover_Screen.get(4), - CI.machineHull_IV, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 2) + ItemUtils.getSimpleStack(CI.getDataOrb(), 4 * (GTNH ? 2 : 1)), + ItemList.Cover_Screen.get(4), + CI.machineHull_IV, + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 2) }, ELEMENT.getInstance().TANTALUM.getFluid(144 * 16), GregtechItemList.Gregtech_Computer_Cube.get(1), 60 * 20 * 3, 8000); - + //Circuit programmer CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - ItemUtils.getSimpleStack(CI.robotArm_LV, 4 * (GTNH ? 2 : 1)), - ItemList.Cover_Controller.get(1, CI.electricMotor_MV), - CI.machineHull_MV, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(1), 2), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(2), 2) + ItemUtils.getSimpleStack(CI.robotArm_LV, 4 * (GTNH ? 2 : 1)), + ItemList.Cover_Controller.get(1, CI.electricMotor_MV), + CI.machineHull_MV, + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(1), 2), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(2), 2) }, ELEMENT.getInstance().IRON.getFluid(144 * 4), ItemUtils.getSimpleStack(ModBlocks.blockCircuitProgrammer), 60 * 10 * 1, 30); - + //Lead Lined Chest CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - CI.machineHull_LV, - ItemUtils.getItemStackOfAmountFromOreDict("plateRubber", 32), - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 9), - ItemUtils.getSimpleStack(Blocks.chest) + CI.machineHull_LV, + ItemUtils.getItemStackOfAmountFromOreDict("plateRubber", 32), + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 9), + ItemUtils.getSimpleStack(Blocks.chest) }, ELEMENT.getInstance().LEAD.getFluid(144 * 16), ItemUtils.getSimpleStack(ModBlocks.blockDecayablesChest), 60 * 10 * 3, 60); - + //RTG CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - ItemUtils.getItemStackWithMeta(true, "IC2:blockGenerator:6", "IC2-RTG", 6, 1), - ALLOY.NITINOL_60.getPlate(GTNH ? 32 : 8), - ALLOY.MARAGING350.getGear(GTNH ? 16 : 4), - ItemUtils.getSimpleStack(GTNH ? CI.fieldGenerator_IV : CI.fieldGenerator_EV, 8 ), - ItemUtils.getItemStackOfAmountFromOreDict("wireFinePlatinum", GTNH ? 64 : 32), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 7 : 6), GTNH ? 5 : 4) + ItemUtils.getItemStackWithMeta(true, "IC2:blockGenerator:6", "IC2-RTG", 6, 1), + ALLOY.NITINOL_60.getPlate(GTNH ? 32 : 8), + ALLOY.MARAGING350.getGear(GTNH ? 16 : 4), + ItemUtils.getSimpleStack(GTNH ? CI.fieldGenerator_IV : CI.fieldGenerator_EV, 8 ), + ItemUtils.getItemStackOfAmountFromOreDict("wireFinePlatinum", GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 7 : 6), GTNH ? 5 : 4) }, ALLOY.NIOBIUM_CARBIDE.getFluid(144 * 16), GregtechItemList.RTG.get(1), 60 * 20 * 10, 8000); - + // Super Jukebox CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - CI.machineHull_LV, - ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 4), - ItemUtils.getItemStackOfAmountFromOreDict("plateTumbaga", 8), - ItemUtils.getSimpleStack(Blocks.jukebox) + CI.machineHull_LV, + ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 4), + ItemUtils.getItemStackOfAmountFromOreDict("plateTumbaga", 8), + ItemUtils.getSimpleStack(Blocks.jukebox) }, ELEMENT.getInstance().COPPER.getFluid(144 * 2), ItemUtils.getSimpleStack(ModBlocks.blockCustomJukebox), 20 * 30, 30); - + //Basic Steam Turbine RecipeUtils.addShapedGregtechRecipe( @@ -367,7 +367,7 @@ public class RECIPES_Machines { ALLOY.TUMBAGA.getRotor(1), CI.machineCasing_ULV, ALLOY.TUMBAGA.getRotor(1), CI.getElectricMotor(0, 1), "cableGt01RedAlloy", CI.getElectricMotor(0, 1), GregtechItemList.Generator_Gas_Turbine_ULV.get(1)); - + //Basic Combustion Turbine RecipeUtils.addShapedGregtechRecipe( CI.getElectricPiston(0, 1), "circuitPrimitive", CI.getElectricPiston(0, 1), @@ -375,7 +375,7 @@ public class RECIPES_Machines { ALLOY.TUMBAGA.getGear(1), "cableGt01RedAlloy", ALLOY.TUMBAGA.getGear(1), GregtechItemList.Generator_Diesel_ULV.get(1)); - + //Steam Condenser if (CORE.ConfigSwitches.enableMachine_SteamConverter ){ @@ -794,7 +794,7 @@ public class RECIPES_Machines { "plankWood", "frameGtTumbaga", "plankWood", "plankWood", "plankWood", "plankWood", RECIPE_TreeFarmFrame); - */} + */} if (CORE.ConfigSwitches.enableMachine_Tesseracts){ //Tesseracts @@ -858,7 +858,7 @@ public class RECIPES_Machines { //Air Intake Hatch - + ItemList FluidRegulator_IV = Utils.getValueOfItemList("FluidRegulator_IV", ItemList.Pump_IV); ItemStack aTieredFluidRegulator = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? FluidRegulator_IV.get(1) : ItemList.Pump_IV.get(1); @@ -1066,28 +1066,60 @@ public class RECIPES_Machines { RECIPE_CyclotronController = GregtechItemList.COMET_Cyclotron.get(1); RECIPE_CyclotronOuterCasing = GregtechItemList.Casing_Cyclotron_External.get(Casing_Amount); RECIPE_CyclotronInnerCoil = GregtechItemList.Casing_Cyclotron_Coil.get(1); + + //Outer Casing + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemList.Casing_FrostProof.get(1), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 0, GTNH ? 8 : 4), + ALLOY.INCOLOY_DS.getPlate(GTNH ? 16 : 8), + ALLOY.INCONEL_690.getScrew(GTNH ? 32 : 16), + ALLOY.EGLIN_STEEL.getLongRod(GTNH ? 16 : 4), + CI.getElectricPiston(3, GTNH ? 4 : 2) + }, + ALLOY.ZIRCONIUM_CARBIDE.getFluid(144 * 8), //Input Fluid + RECIPE_CyclotronOuterCasing, + 30 * 20 * 2, + MaterialUtils.getVoltageForTier(4)); + + + //Inner Coil + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemList.Casing_Coil_Nichrome.get(1), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 1, GTNH ? 32 : 8), + ALLOY.INCOLOY_MA956.getPlate(GTNH ? 16 : 8), + ALLOY.TANTALLOY_61.getBolt(GTNH ? 32 : 16), + ALLOY.INCOLOY_020.getScrew(GTNH ? 64 : 32), + CI.getFieldGenerator(4, GTNH ? 2 : 1) + }, + ALLOY.HG1223.getFluid(144 * 5), //Input Fluid + RECIPE_CyclotronInnerCoil, + 60 * 20 * 2, + MaterialUtils.getVoltageForTier(5)); + + + //Controller + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.machineHull_IV, + ItemUtils.getSimpleStack(RECIPE_CyclotronInnerCoil, GTNH ? 4 : 2), + ALLOY.INCOLOY_020.getPlate(GTNH ? 16 : 8), + ALLOY.TANTALLOY_61.getGear(GTNH ? 4 : 2), + ALLOY.INCOLOY_MA956.getScrew(GTNH ? 64 : 16), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 6 : 5), GTNH ? 8 : 16) + }, + ALLOY.INCOLOY_020.getFluid(144 * 9), //Input Fluid + RECIPE_CyclotronController, + 60 * 20 * 5, + MaterialUtils.getVoltageForTier(5)); + + + + + - GT_Values.RA.addAssemblerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloyMA956", 8), - ItemUtils.getItemStackOfAmountFromOreDict("frameGtIncoloy020", 1), - FluidUtils.getFluidStack("molten.hg1223", 32), - RECIPE_CyclotronOuterCasing, - 30 * 20, - 500); - - GT_Values.RA.addAssemblerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloyDS", 16), - ItemList.Field_Generator_HV.get(1), - FluidUtils.getFluidStack("molten.hg1223", 144), - RECIPE_CyclotronInnerCoil, - 90 * 20, - 1000); - RecipeUtils.recipeBuilder( - "plateIncoloy020", CI.getTieredCircuit(6), "plateIncoloy020", - RECIPE_CyclotronInnerCoil, CI.machineHull_IV, RECIPE_CyclotronInnerCoil, - "plateIncoloy020", "gearGtIncoloyMA956", "plateIncoloy020", - RECIPE_CyclotronController); } if (CORE.ConfigSwitches.enableMultiblock_PowerSubstation){ @@ -1139,43 +1171,43 @@ public class RECIPES_Machines { ItemStack aCoreBlock = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? ItemList.valueOf("Block_IridiumTungstensteel").get(1, ItemUtils.getItemStackOfAmountFromOreDict("blockOsmiridium", 1)) - : ItemUtils.getItemStackOfAmountFromOreDict("blockOsmiridium", 1); - - aCoreBlock.stackSize = GTNH ? 2 : 1; - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), GTNH ? 2 : 1), - aCoreBlock, - CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 16), - CI.getTieredComponent(OrePrefixes.screw, GTNH ? 6 : 5, 32), - CI.getTieredComponent(OrePrefixes.bolt, GTNH ? 6 : 5, 12), - CI.getTieredComponent(OrePrefixes.plate, GTNH ? 7 : 6, 8), }, - CI.getTertiaryTieredFluid(6, 144 * (GTNH ? 12 : 4)), - GregtechItemList.Casing_Autocrafter.get(Casing_Amount), 20 * 60 * 2, - MaterialUtils.getVoltageForTier(GTNH ? 7 : 6)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - GregtechItemList.Casing_Refinery_Structural.get(4), - ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, GTNH ? 2 : 1), - CI.getTieredComponent(OrePrefixes.cableGt08, GTNH ? 7 : 6, GTNH ? 32 : 16), - CI.getEmitter(GTNH ? 7 : 5, 2), - CI.getSensor(GTNH ? 7 : 5, 2), - GregtechItemList.Gregtech_Computer_Cube.get(1), + : ItemUtils.getItemStackOfAmountFromOreDict("blockOsmiridium", 1); + + aCoreBlock.stackSize = GTNH ? 2 : 1; + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), GTNH ? 2 : 1), + aCoreBlock, + CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 16), + CI.getTieredComponent(OrePrefixes.screw, GTNH ? 6 : 5, 32), + CI.getTieredComponent(OrePrefixes.bolt, GTNH ? 6 : 5, 12), + CI.getTieredComponent(OrePrefixes.plate, GTNH ? 7 : 6, 8), }, + CI.getTertiaryTieredFluid(6, 144 * (GTNH ? 12 : 4)), + GregtechItemList.Casing_Autocrafter.get(Casing_Amount), 20 * 60 * 2, + MaterialUtils.getVoltageForTier(GTNH ? 6 : 5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + GregtechItemList.Casing_Refinery_Structural.get(4), + ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, GTNH ? 2 : 1), + CI.getTieredComponent(OrePrefixes.cableGt08, GTNH ? 7 : 6, GTNH ? 32 : 16), + CI.getEmitter(GTNH ? 6 : 5, 2), + CI.getSensor(GTNH ? 6 : 5, 2), + GregtechItemList.Gregtech_Computer_Cube.get(1), }, - CI.getTieredFluid(7, 144 * (GTNH ? 32 : 8)), GregtechItemList.GT4_Multi_Crafter.get(1), - 20 * 60 * 5, MaterialUtils.getVoltageForTier(GTNH ? 7 : 6)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), Casing_Amount), - CI.getEmitter(GTNH ? 5 : 4, GTNH ? 4 : 2), CI.getRobotArm(GTNH ? 5 : 4, GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 8), - CI.getTieredComponent(OrePrefixes.screw, GTNH ? 4 : 3, 8), - CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 16 : 4), }, - CI.getAlternativeTieredFluid(5, 144 * 4), ItemUtils.getSimpleStack(ModBlocks.blockProjectTable), - 20 * 30 * 3, MaterialUtils.getVoltageForTier(GTNH ? 5 : 4)); + CI.getTieredFluid(7, 144 * (GTNH ? 32 : 8)), GregtechItemList.GT4_Multi_Crafter.get(1), + 20 * 60 * 5, MaterialUtils.getVoltageForTier(GTNH ? 6 : 5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), Casing_Amount), + CI.getEmitter(GTNH ? 5 : 4, GTNH ? 4 : 2), CI.getRobotArm(GTNH ? 5 : 4, GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 8), + CI.getTieredComponent(OrePrefixes.screw, GTNH ? 4 : 3, 8), + CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 16 : 4), }, + CI.getAlternativeTieredFluid(5, 144 * 4), ItemUtils.getSimpleStack(ModBlocks.blockProjectTable), + 20 * 30 * 3, MaterialUtils.getVoltageForTier(GTNH ? 5 : 4)); } @@ -1373,7 +1405,7 @@ public class RECIPES_Machines { ItemUtils.getSimpleStack((GTNH ? CI.fieldGenerator_MAX : CI.fieldGenerator_ZPM), 5), ItemList.Energy_LapotronicOrb2.get(1 * (GTNH ? 64 : 8)), GTNH ? GregtechItemList.Compressed_Fusion_Reactor.get(1) : ItemList.FusionComputer_UV.get(1), - GregtechItemList.Casing_Fusion_Internal.get(1) + GregtechItemList.Casing_Fusion_Internal.get(1) }, new FluidStack[] { ALLOY.PIKYONIUM.getFluid(32 * 144 * (GTNH ? 2 : 1)), @@ -1429,10 +1461,10 @@ public class RECIPES_Machines { (int) GT_Values.V[7]); - - + + ItemStack aDrillController = Utils.getValueOfItemList("OreDrill4", ItemList.Hull_UV).get(1); - + //Drilling Platform CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1446,7 +1478,7 @@ public class RECIPES_Machines { GregtechItemList.BedrockMiner_MKI.get(1), (int) GT_Values.V[5], (int) GT_Values.V[7]); - + //Drilling Platform Casings CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1499,8 +1531,8 @@ public class RECIPES_Machines { ItemUtils.getSimpleStack(Dimension_Everglades.blockPortalFrame, 2), 45 * 20 * 1 * (6), MaterialUtils.getVoltageForTier(6)); - - + + //Player Doors ItemStack[] aDoorInputs = new ItemStack[] { ItemUtils.getSimpleStack(Blocks.log2), @@ -1516,7 +1548,7 @@ public class RECIPES_Machines { ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Ice), ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Cactus), }; - + for (int y = 0; y < aDoorInputs.length; y++) { CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1532,18 +1564,18 @@ public class RECIPES_Machines { 100, MaterialUtils.getVoltageForTier(1)); } - - - + + + Logger.INFO("Done loading recipes for the Various machine blocks."); } - - + + private static void controlCores() { - + Material[] aMat_A = new Material[] { ALLOY.POTIN, ALLOY.ZIRCONIUM_CARBIDE, @@ -1568,19 +1600,19 @@ public class RECIPES_Machines { ALLOY.ZERON_100, ALLOY.CINOBITE }; - + Item aBaseCore = ModItems.itemControlCore; ItemStack[] aInputPrevTier = new ItemStack[] { GTNH ? ItemUtils.getItemStack("miscutils:item.itemBufferCore3", 1) : ItemUtils.getItemStack("miscutils:item.itemBufferCore2", 1), - ItemUtils.simpleMetaStack(aBaseCore, 0, 1), - ItemUtils.simpleMetaStack(aBaseCore, 1, 1), - ItemUtils.simpleMetaStack(aBaseCore, 2, 1), - ItemUtils.simpleMetaStack(aBaseCore, 3, 1), - ItemUtils.simpleMetaStack(aBaseCore, 4, 1), - ItemUtils.simpleMetaStack(aBaseCore, 5, 1), - ItemUtils.simpleMetaStack(aBaseCore, 6, 1), - ItemUtils.simpleMetaStack(aBaseCore, 7, 1), - ItemUtils.simpleMetaStack(aBaseCore, 8, 1), + ItemUtils.simpleMetaStack(aBaseCore, 0, 1), + ItemUtils.simpleMetaStack(aBaseCore, 1, 1), + ItemUtils.simpleMetaStack(aBaseCore, 2, 1), + ItemUtils.simpleMetaStack(aBaseCore, 3, 1), + ItemUtils.simpleMetaStack(aBaseCore, 4, 1), + ItemUtils.simpleMetaStack(aBaseCore, 5, 1), + ItemUtils.simpleMetaStack(aBaseCore, 6, 1), + ItemUtils.simpleMetaStack(aBaseCore, 7, 1), + ItemUtils.simpleMetaStack(aBaseCore, 8, 1), }; ItemStack[] aOutput = new ItemStack[] { ItemUtils.simpleMetaStack(aBaseCore, 0, 1), @@ -1593,9 +1625,9 @@ public class RECIPES_Machines { ItemUtils.simpleMetaStack(aBaseCore, 7, 1), ItemUtils.simpleMetaStack(aBaseCore, 8, 1), ItemUtils.simpleMetaStack(aBaseCore, 9, 1), - + }; - + CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { CI.machineHull_HV, @@ -1609,8 +1641,8 @@ public class RECIPES_Machines { GregtechItemList.Hatch_Control_Core.get(1), 60 * 20 * 5, MaterialUtils.getVoltageForTier(3)); - - + + for (int i = 0; i < 10; i++) { boolean aDub = i >= 5; @@ -1618,7 +1650,7 @@ public class RECIPES_Machines { ItemStack aGearStack = aMat_B[i].getGear(GTNH ? 8 : 4 * (aDub ? 2 : 1)); ItemStack aRodStack = aMat_A[i].getLongRod(GTNH ? 32 : 16 * (aDub ? 2 : 1)); ItemStack aScrewStack = aMat_B[i].getScrew(32 * (aDub ? 2 : 1)); - + if (!ItemUtils.checkForInvalidItems(aPlateStack)) { aPlateStack = aMat_A[i].getPlate((GTNH ? 16 : 8) * (aDub ? 2 : 1) * 2); if (!ItemUtils.checkForInvalidItems(aPlateStack)) { @@ -1637,7 +1669,7 @@ public class RECIPES_Machines { if (!ItemUtils.checkForInvalidItems(aScrewStack)) { aScrewStack = aMat_A[i].getScrew(32 * (aDub ? 2 : 1)); } - + CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { aInputPrevTier[i], @@ -1653,9 +1685,9 @@ public class RECIPES_Machines { MaterialUtils.getVoltageForTier(i)); } } - + private static void energyCores() { - + //Simpler Recipes for normal Players, Force assembly crafting in GTNH if (!GTNH) { //Buffer Core @@ -1762,15 +1794,15 @@ public class RECIPES_Machines { CI.circuitTier9, RECIPE_BufferCore_MAX, CI.circuitTier9, RECIPE_Buffer_MAX);*/ } - + ItemStack[] aBufferOutput = new ItemStack[] { RECIPE_Buffer_ULV, RECIPE_Buffer_LV, RECIPE_Buffer_MV, RECIPE_Buffer_HV, RECIPE_Buffer_EV, RECIPE_Buffer_IV, RECIPE_Buffer_LuV, RECIPE_Buffer_ZPM, RECIPE_Buffer_UV, RECIPE_Buffer_MAX }; - - - + + + ItemStack[] aOutput = new ItemStack[] { ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"1", 1), ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"2", 1), @@ -1783,11 +1815,11 @@ public class RECIPES_Machines { ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"9", 1), ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"10", 1) }; - + int aCostMultiplier = GTNH ? 4 : 1; - + for (int i = 0; i < 10; i++) { - + ItemStack aPrevTier = (i == 0 ? CI.getTieredMachineHull(GTNH ? 2 : 1) : aOutput[i-1]); aPrevTier.stackSize = GTNH ? 2 : 1; int aTier = (i + 1); @@ -1804,7 +1836,7 @@ public class RECIPES_Machines { aOutput[i], 45 * 10 * 1 * (aTier), MaterialUtils.getVoltageForTier(i)); - + //Energy Buffer CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1819,14 +1851,14 @@ public class RECIPES_Machines { aBufferOutput[i], 45 * 20 * 1 * (aTier), MaterialUtils.getVoltageForTier(i)); - + } - - - + + + } - + private static void wirelessChargers() { ItemStack[] aChargers = new ItemStack[] { @@ -1840,10 +1872,10 @@ public class RECIPES_Machines { GregtechItemList.Charger_ZPM.get(1), GregtechItemList.Charger_UV.get(1), GregtechItemList.Charger_MAX.get(1) - }; - + }; + int aCostMultiplier = GTNH ? 2 : 1; - + for (int i = 0; i < 10; i++) { if (i == 0) { continue; @@ -1863,7 +1895,7 @@ public class RECIPES_Machines { aChargers[i], 45 * 10 * 1 * (aTier), MaterialUtils.getVoltageForTier(i)); - + } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index 5f255069bf..411171a766 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -170,11 +170,11 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { */ GregtechItemList.Battery_Gem_1.set(this.addItem(tLastID = 66, "Proton Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 24L), getTcAspectStack(TC_Aspects.POTENTIA, 16L)})); - this.setElectricStats(32000 + tLastID, 32000000L, GT_Values.V[6], 6L, -3L, false); + this.setElectricStats(32000 + tLastID, GT_Values.V[6] * 20 * 300 / 4, GT_Values.V[6], 6L, -3L, false); GregtechItemList.Battery_Gem_2.set(this.addItem(tLastID = 68, "Electron Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.METALLUM, 32L), getTcAspectStack(TC_Aspects.POTENTIA, 32L)})); - this.setElectricStats(32000 + tLastID, 750000000L, GT_Values.V[7], 7L, -3L, false); + this.setElectricStats(32000 + tLastID, GT_Values.V[7] * 20 * 300 / 4, GT_Values.V[7], 7L, -3L, false); GregtechItemList.Battery_Gem_3.set(this.addItem(tLastID = 70, "Quark Entanglement", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 32L), getTcAspectStack(TC_Aspects.METALLUM, 48L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); - this.setElectricStats(32000 + tLastID, 64000000000L, GT_Values.V[8], 8L, -3L, false); + this.setElectricStats(32000 + tLastID, GT_Values.V[8] * 20 * 300 / 4, GT_Values.V[8], 8L, -3L, false); //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_1.get(1), "batteryFutureBasic"); //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_2.get(1), "batteryFutureGood"); //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_3.get(1), "batteryFutureAdvanced"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java index 1932f30969..ecdc3af1db 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java @@ -221,14 +221,14 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base { } //Add Shapeless recipe for low tier alloys. - if (tVoltageMultiplier <= 30){ + /*if (tVoltageMultiplier <= 30){ if (RecipeUtils.addShapedGregtechRecipe(inputStacks, outputStacks)){ Logger.WARNING("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Success"); } else { Logger.WARNING("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Failed"); } - } + }*/ } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java index ddba6b5bf0..66775f7872 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -163,6 +163,15 @@ public class RecipeGen_Ore extends RecipeGen_Base { ItemStack matDustA = getDust(bonusA); ItemStack matDustB = getDust(bonusB); + /** + * Package + */ + //Allow ore dusts to be packaged + if (ItemUtils.checkForInvalidItems(material.getSmallDust(1)) && ItemUtils.checkForInvalidItems(material.getTinyDust(1))) { + RecipeGen_DustGeneration.generatePackagerRecipes(material); + } + + /** * Macerate */ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java index 79615d8457..3249e0101d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java @@ -3,18 +3,15 @@ package gtPlusPlus.xmod.gregtech.loaders; import java.util.HashSet; import java.util.Set; -import net.minecraft.item.ItemStack; - import gregtech.api.util.GT_ModHandler; - import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import net.minecraft.item.ItemStack; public class RecipeGen_ShapedCrafting extends RecipeGen_Base { @@ -35,7 +32,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { private void generateRecipes(final Material material){ Logger.WARNING("Generating Shaped Crafting recipes for "+material.getLocalizedName()); //TODO - + if (!CORE.GTNH) { //Nuggets if (ItemUtils.checkForInvalidItems(material.getNugget(1)) && ItemUtils.checkForInvalidItems(material.getIngot(1))) diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index 8f3e49d7b7..da8b4e4ff1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -15,6 +15,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.MaterialGenerator; @@ -752,24 +753,25 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs_OLD, ItemStack aOutput, int aDuration, int aEUt) { - FluidStack[] aFluidInputs = new FluidStack[4]; - if (aFluidInputs_OLD != null) { - int aC = 0; - for (FluidStack s : aFluidInputs) { - if (aC > 3) { - break; - } - if (s != null) { - aFluidInputs[aC++] = s; - } + FluidStack[] aFluidInputs = new FluidStack[4]; + AutoMap aNewFluidMap = new AutoMap(); + if (aFluidInputs_OLD.length > 4) { + for (FluidStack s : aFluidInputs_OLD) { + aNewFluidMap.put(s); } + for (int i = 0; i < 4; i++) { + aFluidInputs[i] = aNewFluidMap.get(i); + } + } + else { + aFluidInputs = aFluidInputs_OLD; } if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { if (aInputs.length < 6 && aFluidInputs.length < 2) { ItemStack[] aInputStack = new ItemStack[] {aResearchItem, aInputs[0], aInputs[1], aInputs[2], aInputs[3], aInputs[4]}; - return CORE.RA.addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); } return false; } @@ -789,7 +791,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (aInputs.length < 6 && aFluidInputs.length < 2) { ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], aInputs[2], aInputs[3], aInputs[4] }; - return CORE.RA.addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); } return false; @@ -798,7 +800,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (aInputs.length < 6 && aFluidInputs.length < 2) { ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], aInputs[2], aInputs[3], aInputs[4] }; - return CORE.RA.addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); } return false; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java index a3a04a44da..54ab6d45bb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java @@ -105,7 +105,7 @@ public class GregtechDehydrator { | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('P'), ItemList.Robot_Arm_MV, Character.valueOf('E'), OrePrefixes.wireFine.get(Materials.RedAlloy), Character.valueOf('C'), - OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('W'), + OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Copper), Character.valueOf('G'), OrePrefixes.gearGt.get(Materials.Steel) }); GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Dehydrator_HV.get(1L, new Object[0]), @@ -113,7 +113,7 @@ public class GregtechDehydrator { | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('P'), ItemList.Robot_Arm_HV, Character.valueOf('E'), OrePrefixes.wireFine.get(Materials.Electrum), Character.valueOf('C'), - OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), + OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Silver), Character.valueOf('G'), ALLOY.POTIN.getGear(1) }); @@ -123,7 +123,7 @@ public class GregtechDehydrator { | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('P'), ItemList.Robot_Arm_EV, Character.valueOf('E'), coilT1, Character.valueOf('C'), - OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), + OrePrefixes.circuit.get(Materials.Data), Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Aluminium), Character.valueOf('G'), ALLOY.TUMBAGA.getGear(1) }); diff --git a/src/resources/assets/gregtech/lang/en_US.lang b/src/resources/assets/gregtech/lang/en_US.lang index 9e954f5500..56479c2029 100644 --- a/src/resources/assets/gregtech/lang/en_US.lang +++ b/src/resources/assets/gregtech/lang/en_US.lang @@ -32,28 +32,85 @@ GTPP.info.hidden=Hidden +//Tooltips for the Charger Packs +GTPP.battpack.tooltip.1=Worn as a Belt within Baubles +GTPP.battpack.tooltip.2=Drains +GTPP.battpack.tooltip.3=to charge worn armour +GTPP.battpack.tooltip.4=Also charges items on the hotbar + +//Tooltips for the Personal Healing Bauble +GTPP.nanohealer.tooltip.1=Worn as a Necklace within Baubles +GTPP.nanohealer.tooltip.2=Drains 1638400EU per operation +GTPP.nanohealer.tooltip.3=Can restore HP, Hunger and Saturation +GTPP.nanohealer.tooltip.4=WILL NOT PREVENT DEATH +GTPP.nanohealer.tooltip.5=Shift+RMB to toggle notifications +GTPP.nanohealer.hidden=Hiding Info? + + //Achievements -achievement.gt.blockmachines.fusioncomputer.tier.09=Fusion Computer Mark IV -achievement.gt.blockmachines.fusioncomputer.tier.09.desc=Pickup this item to see the recipe in NEI +//4/2/19 +achievement.gt.blockmachines.fusioncomputer.tier.09=Fusion Computer Mark IV achievement.gtplusplus.blockcasings.3.12=Fusion Casing MK III -achievement.gtplusplus.blockcasings.3.12.desc=Pickup this item to see the recipe in NEI - achievement.gtplusplus.blockcasings.3.13=Advanced Magnetic Containment! -achievement.gtplusplus.blockcasings.3.13.desc=Pickup this item to see the recipe in NEI - achievement.gtplusplus.blockcasings.3.15=Quantum Containment! -achievement.gtplusplus.blockcasings.3.15.desc=Pickup this item to see the recipe in NEI - +achievement.gt.blockmachines.fusioncomputer.tier.09.desc=[AL] Pickup this item to see the recipe in NEI +achievement.gtplusplus.blockcasings.3.12.desc=[AL] Pickup this item to see the recipe in NEI +achievement.gtplusplus.blockcasings.3.13.desc=[AL] Pickup this item to see the recipe in NEI +achievement.gtplusplus.blockcasings.3.15.desc=[AL] Pickup this item to see the recipe in NEI achievement.gt.blockmachines.gtplusplus.fusion.single=Alternative Fusion -achievement.gt.blockmachines.gtplusplus.fusion.single.desc=Pickup this item to see the recipe in NEI - achievement.gt.blockmachines.gtplusplus.tank.plasma=Plasma Storage -achievement.gt.blockmachines.gtplusplus.tank.plasma.desc=Pickup this item to see the recipe in NEI +achievement.gt.blockmachines.gtplusplus.fusion.single.desc=[AL] Pickup this item to see the recipe in NEI +achievement.gt.blockmachines.gtplusplus.tank.plasma.desc=[AL] Pickup this item to see the recipe in NEI + + +//5/2/19 +achievement.MU-metaitem.01.32106=Junior Physicist +achievement.MU-metaitem.01.32107=Graduate Physicist +achievement.MU-metaitem.01.32108=Scholarly Physicist +achievement.MU-metaitem.01.32109=Master Physicist +achievement.MU-metaitem.01.32106.desc=[AL] Pickup this item to see the recipe in NEI +achievement.MU-metaitem.01.32107.desc=[AL] Pickup this item to see the recipe in NEI +achievement.MU-metaitem.01.32108.desc=[AL] Pickup this item to see the recipe in NEI +achievement.MU-metaitem.01.32109.desc=[AL] Pickup this item to see the recipe in NEI +achievement.MU-metaitem.01.32066=Proton Containment +achievement.MU-metaitem.01.32068=Electron Containment +achievement.MU-metaitem.01.32070=Quark Containment +achievement.MU-metaitem.01.32110=Graviton Containment +achievement.MU-metaitem.01.32066.desc=[AL] Pickup this item to see the recipe in NEI +achievement.MU-metaitem.01.32068.desc=[AL] Pickup this item to see the recipe in NEI +achievement.MU-metaitem.01.32070.desc=[AL] Pickup this item to see the recipe in NEI +achievement.MU-metaitem.01.32110.desc=[AL] Pickup this item to see the recipe in NEI +achievement.item.personalHealingDevice=Food is for chumps +achievement.item.personalHealingDevice.desc=[AL] You have upgraded to the nano, the future is yours +achievement.item.GTPP.BattPack.06.name=Charge Pack Mk I +achievement.item.GTPP.BattPack.07.name=Charge Pack Mk II +achievement.item.GTPP.BattPack.08.name=Charge Pack Mk III +achievement.item.GTPP.BattPack.09.name=Charge Pack Mk IV +achievement.item.GTPP.BattPack.06.name.desc=[AL] Pickup this item to see the recipe in NEI +achievement.item.GTPP.BattPack.07.name.desc=[AL] Pickup this item to see the recipe in NEI +achievement.item.GTPP.BattPack.08.name.desc=[AL] Pickup this item to see the recipe in NEI +achievement.item.GTPP.BattPack.09.name.desc=[AL] Pickup this item to see the recipe in NEI + + + + + + + + + + + + + + + + @@ -63,18 +120,6 @@ achievement.gt.blockmachines.gtplusplus.tank.plasma.desc=Pickup this item to see -//Tooltips for the Charger Packs -GTPP.battpack.tooltip.1=Worn as a Belt within Baubles -GTPP.battpack.tooltip.2=Drains -GTPP.battpack.tooltip.3=to charge worn armour -GTPP.battpack.tooltip.4=Also charges items on the hotbar -//Tooltips for the Personal Healing Bauble -GTPP.nanohealer.tooltip.1=Worn as a Necklace within Baubles -GTPP.nanohealer.tooltip.2=Drains 1638400EU per operation -GTPP.nanohealer.tooltip.3=Can restore HP, Hunger and Saturation -GTPP.nanohealer.tooltip.4=WILL NOT PREVENT DEATH -GTPP.nanohealer.tooltip.5=Shift+RMB to toggle notifications -GTPP.nanohealer.hidden=Hiding Info? diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index 92870c6a08..d5e0f165c1 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -549,34 +549,34 @@ item.itemNuggetUranium233.name=Uranium 233 Nugget item.itemPlateUranium233.name=Uranium 233 Plate item.itemRodUranium233.name=Uranium 233 Rod item.itemRodLongUranium233.name=Long Uranium 233 Rod -item.itemIngotPlutonium238.name=Plutonium-238 Ingot -item.itemDustPlutonium238.name=Plutonium-238 Dust -item.itemDustTinyPlutonium238.name=Tiny Pile of Plutonium-238 Dust -item.itemDustSmallPlutonium238.name=Small Pile of Plutonium-238 Dust -item.itemNuggetPlutonium238.name=Plutonium-238 Nugget -item.itemPlatePlutonium238.name=Plutonium-238 Plate -item.itemPlateDoublePlutonium238.name=Double Plutonium-238 Plate -item.itemIngotStrontium90.name=Strontium-90 Ingot -item.itemDustStrontium90.name=Strontium-90 Dust -item.itemDustTinyStrontium90.name=Tiny Pile of Strontium-90 Dust -item.itemDustSmallStrontium90.name=Small Pile of Strontium-90 Dust -item.itemNuggetStrontium90.name=Strontium-90 Nugget -item.itemPlateStrontium90.name=Strontium-90 Plate -item.itemPlateDoubleStrontium90.name=Double Strontium-90 Plate -item.itemIngotPolonium210.name=Polonium-210 Ingot -item.itemDustPolonium210.name=Polonium-210 Dust -item.itemDustTinyPolonium210.name=Tiny Pile of Polonium-210 Dust -item.itemDustSmallPolonium210.name=Small Pile of Polonium-210 Dust -item.itemNuggetPolonium210.name=Polonium-210 Nugget -item.itemPlatePolonium210.name=Polonium-210 Plate -item.itemPlateDoublePolonium210.name=Double Polonium-210 Plate -item.itemIngotAmericium241.name=Americium-241 Ingot -item.itemDustAmericium241.name=Americium-241 Dust -item.itemDustTinyAmericium241.name=Tiny Pile of Americium-241 Dust -item.itemDustSmallAmericium241.name=Small Pile of Americium-241 Dust -item.itemNuggetAmericium241.name=Americium-241 Nugget -item.itemPlateAmericium241.name=Americium-241 Plate -item.itemPlateDoubleAmericium241.name=Double Americium-241 Plate +item.itemIngotPlutonium238.name=Plutonium 238 Ingot +item.itemDustPlutonium238.name=Plutonium 238 Dust +item.itemDustTinyPlutonium238.name=Tiny Pile of Plutonium 238 Dust +item.itemDustSmallPlutonium238.name=Small Pile of Plutonium 238 Dust +item.itemNuggetPlutonium238.name=Plutonium 238 Nugget +item.itemPlatePlutonium238.name=Plutonium 238 Plate +item.itemPlateDoublePlutonium238.name=Double Plutonium 238 Plate +item.itemIngotStrontium90.name=Strontium 90 Ingot +item.itemDustStrontium90.name=Strontium 90 Dust +item.itemDustTinyStrontium90.name=Tiny Pile of Strontium 90 Dust +item.itemDustSmallStrontium90.name=Small Pile of Strontium 90 Dust +item.itemNuggetStrontium90.name=Strontium 90 Nugget +item.itemPlateStrontium90.name=Strontium 90 Plate +item.itemPlateDoubleStrontium90.name=Double Strontium 90 Plate +item.itemIngotPolonium210.name=Polonium 210 Ingot +item.itemDustPolonium210.name=Polonium 210 Dust +item.itemDustTinyPolonium210.name=Tiny Pile of Polonium 210 Dust +item.itemDustSmallPolonium210.name=Small Pile of Polonium 210 Dust +item.itemNuggetPolonium210.name=Polonium 210 Nugget +item.itemPlatePolonium210.name=Polonium 210 Plate +item.itemPlateDoublePolonium210.name=Double Polonium 210 Plate +item.itemIngotAmericium241.name=Americium 241 Ingot +item.itemDustAmericium241.name=Americium 241 Dust +item.itemDustTinyAmericium241.name=Tiny Pile of Americium 241 Dust +item.itemDustSmallAmericium241.name=Small Pile of Americium 241 Dust +item.itemNuggetAmericium241.name=Americium 241 Nugget +item.itemPlateAmericium241.name=Americium 241 Plate +item.itemPlateDoubleAmericium241.name=Double Americium 241 Plate item.itemIngotSiliconCarbide.name=Silicon Carbide Ingot item.itemDustSiliconCarbide.name=Silicon Carbide Dust item.itemDustTinySiliconCarbide.name=Tiny Pile of Silicon Carbide Dust @@ -1803,10 +1803,10 @@ tile.Block of Fermium.name=Block of Fermium tile.Block of Thorium 232.name=Block of Thorium 232 tile.Block of Uranium 232.name=Block of Uranium 232 tile.Block of Uranium 233.name=Block of Uranium 233 -tile.Block of Plutonium-238.name=Block of Plutonium-238 -tile.Block of Strontium-90.name=Block of Strontium-90 -tile.Block of Polonium-210.name=Block of Polonium-210 -tile.Block of Americium-241.name=Block of Americium-241 +tile.Block of Plutonium-238.name=Block of Plutonium 238 +tile.Block of Strontium-90.name=Block of Strontium 90 +tile.Block of Polonium-210.name=Block of Polonium 210 +tile.Block of r.name=Block of Americium 241 tile.Block of Silicon Carbide.name=Block of Silicon Carbide tile.Silicon Carbide Frame Box.name=Silicon Carbide Frame Box tile.Block of Zirconium Carbide.name=Block of Zirconium Carbide @@ -1949,7 +1949,7 @@ tile.blockDarkWorldPortalFrame.name=Containment Frame //Added 1/4/18 -tile.Block of Plutonium-239.name=Block of Uranium-239 +tile.Block of Plutonium-239.name=Block of Plutonium-239 tile.Fluorite Ore [Old].name=Fluorite Ore [Deprecated] tile.blockMiningPipeFake.name=Strengthened Mining Pipe tile.blockMiningHeadFake.name=Bedrock Drill @@ -1973,10 +1973,10 @@ item.itemDustTinyPromethium.name=Tiny Pile of Promethium item.itemDustPromethium.name=Promethium Dust tile.Block of Promethium.name=Block of Promethium -item.itemCellAmericium241.name=Americium-241 Cell -item.itemCellPolonium210.name=Polonium-210 Cell -item.itemCellStrontium90.name=Strontium-90 Cell -item.itemCellPlutonium238.name=Plutonium-238 Cell +item.itemCellAmericium241.name=Americium 241 Cell +item.itemCellPolonium210.name=Polonium 210 Cell +item.itemCellStrontium90.name=Strontium 90 Cell +item.itemCellPlutonium238.name=Plutonium 238 Cell entity.MiningCharge.name=Mining Charge entity.throwablePotionSulfuric.name=Flask of Sulfuric Acid -- cgit From d10055e3283721cc624ec53e72411e295fd5fb4c Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 6 Feb 2019 02:46:31 +0000 Subject: $ Hopefully fixed a crash concerning Assembly Line recipes. $ Fixed amount of fluid ender used within a Cyclotron recipe. --- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 2 +- .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 30 ++++++++++++++++++ .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 36 ++++++++++++++++------ 3 files changed, 58 insertions(+), 10 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 9d34aa371d..6f4e8870d7 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -1955,7 +1955,7 @@ public class RECIPES_GREGTECH { Particle.getBaseParticle(Particle.UNKNOWN), Particle.getBaseParticle(Particle.UNKNOWN), }, - FluidUtils.getWildcardFluidStack("ender", 1000), + FluidUtils.getFluidStack(FluidUtils.getWildcardFluidStack("ender", 1000), 1000), new ItemStack[] { ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT.getDust(1) }, diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index a5cf9527a9..6fa58804dd 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -35,6 +35,7 @@ import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -1012,4 +1013,33 @@ public class ItemUtils { } + public static String getItemName(ItemStack aStack) { + if (aStack == null) { + return "ERROR - Empty Stack"; + } + String aDisplay = null; + try { + aDisplay = ("" + StatCollector + .translateToLocal(aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) + .trim(); + if (aStack.hasTagCompound()) { + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.hasKey("Name", 8)) { + aDisplay = nbttagcompound.getString("Name"); + } + } + } + } catch (Throwable t) { + + } + if (aDisplay == null || aDisplay.length() <= 0) { + aDisplay = aStack.getUnlocalizedName() + ":" + aStack.getItemDamage(); + } else { + aDisplay += " | Meta: " + aStack.getItemDamage(); + } + return aDisplay; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index da8b4e4ff1..4be0378699 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -12,6 +12,7 @@ import gregtech.api.enums.Materials; import gregtech.api.interfaces.internal.IGT_RecipeAdder; import gregtech.api.util.CustomRecipeMap; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; @@ -783,7 +784,12 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (mAssemblyLine != null) { try { if (!tryAddTecTechScannerRecipe(aResearchItem, aInputs, aFluidInputs, aOutput, aDuration, aEUt)) { - Logger.INFO("Failed to generate TecTech recipe for "+aResearchItem.getDisplayName()+", please report this to Alkalus."); + try { + Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus."); + } + catch (Throwable t) { + + } } return (boolean) mAssemblyLine.invoke(GT_Values.RA, aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt); @@ -820,10 +826,13 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (mScannerTT != null) { try { - return (boolean) mScannerTT.invoke(null, aResearchItem, compMax, compSec, - (assEUt/2), 16, aInputs, aFluidInputs, aOutput, assDuration, assEUt); + boolean aResult = (boolean) mScannerTT.invoke(null, aResearchItem, compMax, compSec, + (assEUt/2), 16, aInputs, aFluidInputs, aOutput, assDuration, assEUt); + Logger.INFO("Added TecTech Scanner Recipe for "+ItemUtils.getItemName(aResearchItem)+"? "+aResult); + return aResult; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.INFO("Failed to generate TecTech recipe for "+aResearchItem.getDisplayName()+", please report this to Alkalus. [Severe]"); + Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus. [Severe]"); e.printStackTrace(); } } @@ -1058,11 +1067,20 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { return true; } - - - - - + + + + + + + + + + + + + + } -- cgit From 5187791fd11da1e36f7e1c533bc46f7841772330 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 7 Feb 2019 07:03:08 +0000 Subject: + Added new achievements page for Assembly Line Recipes. + Added custom safety checks to Assembly Line Recipe/Achievement handling via ASM. + Added a safe way to get the unlocal names of items. - Removed 'Press e' Achievement when in Dev. (Thank, Fucking, God) $ Fixed a mild error concerning localization of Americium-241 Blocks. --- src/Java/gtPlusPlus/GTplusplus.java | 5 - src/Java/gtPlusPlus/core/common/CommonProxy.java | 5 + .../handler/StopAnnoyingFuckingAchievements.java | 24 + .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 17 + .../ClassTransformer_GT_Achievements.java | 1896 ++++++++++++++++++++ .../transformers/ClassTransformer_GT_Client.java | 571 ++++++ .../Preloader_Transformer_Handler.java | 31 +- .../xmod/gregtech/common/Meta_GT_Proxy.java | 25 +- .../xmod/gregtech/common/StaticFields59.java | 2 + .../gregtech/loaders/misc/AssLineAchievements.java | 159 ++ src/resources/assets/miscutils/lang/en_US.lang | 2 +- 11 files changed, 2711 insertions(+), 26 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 1c4789c28b..2e3133c343 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -221,11 +221,6 @@ public class GTplusplus implements ActionListener { Logger.INFO("Finally, we are finished. Have some cripsy bacon as a reward."); } - @EventHandler - public void load(FMLInitializationEvent event) { - - } - @EventHandler public synchronized void serverStarting(final FMLServerStartingEvent event) { INIT_PHASE.SERVER_START.setPhaseActive(true); diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 9176dcc720..140019f73b 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -23,6 +23,7 @@ import gtPlusPlus.core.handler.BurnableFuelHandler; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.COMPAT_IntermodStaging; import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.handler.StopAnnoyingFuckingAchievements; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.handler.events.GeneralTooltipEventHandler; import gtPlusPlus.core.handler.events.PickaxeBlockBreakEventHandler; @@ -130,6 +131,10 @@ public class CommonProxy { Utils.registerEvent(new HandlerTooltip_EIO()); // Handles Custom Tooltips for GC Utils.registerEvent(new HandlerTooltip_GC()); + + if (CORE.DEVENV) { + Utils.registerEvent(new StopAnnoyingFuckingAchievements()); + } // Register Chunkloader ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, ChunkManager.getInstance()); diff --git a/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java new file mode 100644 index 0000000000..b10e67aeaf --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java @@ -0,0 +1,24 @@ +package gtPlusPlus.core.handler; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.stats.AchievementList; +import net.minecraftforge.event.entity.player.AchievementEvent; + +public class StopAnnoyingFuckingAchievements { + + /** + * Stops me getting fireworks every fucking time I open my inventory upon first loading a dev client. + * @param event + */ + @SubscribeEvent + public void FUCK_OFF(AchievementEvent event) { + if (event.achievement.equals(AchievementList.openInventory)) { + if (MathUtils.randInt(0, 10) >= 9) + PlayerUtils.messagePlayer(event.entityPlayer, "Bang! Nah, Just joking, there's no fireworks. :)"); + event.setCanceled(true); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 6fa58804dd..2522ba56da 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -1042,4 +1042,21 @@ public class ItemUtils { return aDisplay; } + public static String getUnlocalizedItemName(ItemStack aStack) { + if (aStack == null) { + return "ERROR.Empty.Stack"; + } + String aDisplay = null; + try { + aDisplay = (aStack.getUnlocalizedName()).trim(); + + } catch (Throwable t) { + aDisplay = aStack.getItem().getUnlocalizedName(); + } + if (aDisplay == null || aDisplay.length() <= 0) { + aDisplay = aStack.getItem().getUnlocalizedNameInefficiently(aStack); + } + return aDisplay; + } + } diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java new file mode 100644 index 0000000000..2b9729a8a3 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java @@ -0,0 +1,1896 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import net.minecraftforge.common.MinecraftForge; + +public class ClassTransformer_GT_Achievements { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + private static boolean mDidRemoveAssLineRecipeAdder = false; + + public ClassTransformer_GT_Achievements(byte[] basicClass) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + + aTempReader.accept(new MethodAdaptor(aTempWriter), 0); + + if (mDidRemoveAssLineRecipeAdder) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching GT .09"); + injectMethod(aTempWriter); + patchOnItemPickup09(aTempWriter); + } + else { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching GT .08"); + patchOnItemPickup08(aTempWriter); + } + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Valid? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "registerAssAchievement" + "."); + + /** + * Inject new, safer code + */ + + + /*mv = cw.visitMethod(ACC_PUBLIC, "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", null, null); + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable"); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(291, l3); + mv.visitVarInsn(ALOAD, 1); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(292, l5); + mv.visitLdcInsn("Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(293, l6); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l4); + mv.visitLineNumber(295, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + Label l7 = new Label(); + mv.visitJumpInsn(IFNONNULL, l7); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(296, l8); + mv.visitLdcInsn("Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(297, l9); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l7); + mv.visitLineNumber(299, l7); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + mv.visitLabel(l0); + mv.visitLineNumber(301, l0); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l1); + mv.visitLineNumber(302, l1); + Label l10 = new Label(); + mv.visitJumpInsn(GOTO, l10); + mv.visitLabel(l2); + mv.visitLineNumber(303, l2); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", TOP, "net/minecraft/item/ItemStack"}, 1, new Object[] {"java/lang/Throwable"}); + mv.visitVarInsn(ASTORE, 4); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(304, l11); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/ItemUtils", "getUnlocalizedItemName", "(Lnet/minecraft/item/ItemStack;)Ljava/lang/String;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l10); + mv.visitLineNumber(306, l10); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", "java/lang/String", "net/minecraft/item/ItemStack"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/loaders/misc/GT_Achievements", "achievementList", "Ljava/util/concurrent/ConcurrentHashMap;"); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/concurrent/ConcurrentHashMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false); + Label l12 = new Label(); + mv.visitJumpInsn(IFNONNULL, l12); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLineNumber(307, l13); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitFieldInsn(PUTSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(308, l14); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitIntInsn(BIPUSH, 11); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IREM); + mv.visitInsn(IADD); + mv.visitInsn(INEG); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IDIV); + mv.visitIntInsn(BIPUSH, 8); + mv.visitInsn(ISUB); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/stats/AchievementList", "openInventory", "Lnet/minecraft/stats/Achievement;"); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "registerAchievement", "(Ljava/lang/String;IILnet/minecraft/item/ItemStack;Lnet/minecraft/stats/Achievement;Z)Lnet/minecraft/stats/Achievement;", false); + mv.visitInsn(ARETURN); + mv.visitLabel(l12); + mv.visitLineNumber(310, l12); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l3, l15, 0); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l3, l15, 1); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l1, l2, 2); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l10, l15, 2); + mv.visitLocalVariable("aStack", "Lnet/minecraft/item/ItemStack;", null, l0, l15, 3); + mv.visitLocalVariable("t", "Ljava/lang/Throwable;", null, l11, l10, 4); + mv.visitMaxs(7, 5); + mv.visitEnd();*/ + + //Lets just static call my replacement function + mv = cw.visitMethod(ACC_PUBLIC, "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(291, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements", "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", false); + mv.visitInsn(ARETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l1, 0); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l0, l1, 1); + mv.visitMaxs(1, 2); + mv.visitEnd(); + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + + public boolean patchOnItemPickup08(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "onItemPickup" + "."); + + AnnotationVisitor av0; + mv = cw.visitMethod(ACC_PUBLIC, "onItemPickup", "(Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;)V", null, null); + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(418, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "entityPlayer", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitVarInsn(ASTORE, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(419, l1); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "item", "Lnet/minecraft/entity/item/EntityItem;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/item/EntityItem", "getEntityItem", "()Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(420, l2); + mv.visitVarInsn(ALOAD, 2); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + mv.visitVarInsn(ALOAD, 3); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + mv.visitLabel(l3); + mv.visitLineNumber(421, l3); + mv.visitFrame(F_APPEND,2, new Object[] {"net/minecraft/entity/player/EntityPlayer", "net/minecraft/item/ItemStack"}, 0, null); + mv.visitInsn(RETURN); + mv.visitLabel(l4); + mv.visitLineNumber(424, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gregtech/api/util/GT_OreDictUnificator", "getItemData", "(Lnet/minecraft/item/ItemStack;)Lgregtech/api/objects/ItemData;", false); + mv.visitVarInsn(ASTORE, 4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(425, l5); + mv.visitVarInsn(ALOAD, 4); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(426, l7); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "dust", "Lgregtech/api/enums/OrePrefixes;"); + Label l8 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(427, l9); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Lutetium", "Lgregtech/api/enums/Materials;"); + Label l10 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l10); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(428, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newmetal"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l10); + mv.visitLineNumber(430, l10); + mv.visitFrame(F_APPEND,1, new Object[] {"gregtech/api/objects/ItemData"}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("cleandust"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(431, l12); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l8); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "ore", "Lgregtech/api/enums/OrePrefixes;"); + Label l13 = new Label(); + mv.visitJumpInsn(IF_ACMPEQ, l13); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreBlackgranite", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPEQ, l13); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreEndstone", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPEQ, l13); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(432, l14); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreNetherrack", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPEQ, l13); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreRedgranite", "Lgregtech/api/enums/OrePrefixes;"); + Label l15 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l15); + mv.visitLabel(l13); + mv.visitLineNumber(433, l13); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ISTORE, 5); + Label l16 = new Label(); + mv.visitLabel(l16); + Label l17 = new Label(); + mv.visitJumpInsn(GOTO, l17); + Label l18 = new Label(); + mv.visitLabel(l18); + mv.visitLineNumber(434, l18); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/enums/Materials", "name", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(435, l19); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "AnyIron", "Lgregtech/api/enums/Materials;"); + Label l20 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l20); + Label l21 = new Label(); + mv.visitLabel(l21); + mv.visitLineNumber(436, l21); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("iron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l20); + mv.visitLineNumber(433, l20); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitIincInsn(5, 1); + mv.visitLabel(l17); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 5); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "size", "()I", false); + mv.visitJumpInsn(IF_ICMPLT, l18); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(439, l22); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l15); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushed", "Lgregtech/api/enums/OrePrefixes;"); + Label l23 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l23); + Label l24 = new Label(); + mv.visitLabel(l24); + mv.visitLineNumber(440, l24); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("crushed"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(441, l25); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l23); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedPurified", "Lgregtech/api/enums/OrePrefixes;"); + Label l26 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l26); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(442, l27); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("washing"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLineNumber(443, l28); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l26); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedCentrifuged", "Lgregtech/api/enums/OrePrefixes;"); + Label l29 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l29); + Label l30 = new Label(); + mv.visitLabel(l30); + mv.visitLineNumber(444, l30); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("spinit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l31 = new Label(); + mv.visitLabel(l31); + mv.visitLineNumber(445, l31); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l29); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Steel", "Lgregtech/api/enums/Materials;"); + Label l32 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l32); + Label l33 = new Label(); + mv.visitLabel(l33); + mv.visitLineNumber(446, l33); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "ingot", "Lgregtech/api/enums/OrePrefixes;"); + Label l34 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l34); + mv.visitVarInsn(ALOAD, 3); + mv.visitFieldInsn(GETFIELD, "net/minecraft/item/ItemStack", "stackSize", "I"); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getMaxStackSize", "()I", false); + mv.visitJumpInsn(IF_ICMPNE, l34); + Label l35 = new Label(); + mv.visitLabel(l35); + mv.visitLineNumber(447, l35); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l36 = new Label(); + mv.visitLabel(l36); + mv.visitLineNumber(448, l36); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l34); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "nugget", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + mv.visitLdcInsn("Thaumcraft"); + mv.visitMethodInsn(INVOKESTATIC, "cpw/mods/fml/common/Loader", "isModLoaded", "(Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l37 = new Label(); + mv.visitLabel(l37); + mv.visitLineNumber(449, l37); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/player/EntityPlayer", "getDisplayName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("GT_IRON_TO_STEEL"); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/api/ThaumcraftApiHelper", "isResearchComplete", "(Ljava/lang/String;Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l38 = new Label(); + mv.visitLabel(l38); + mv.visitLineNumber(450, l38); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l39 = new Label(); + mv.visitLabel(l39); + mv.visitLineNumber(453, l39); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l32); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "circuit", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Advanced", "Lgregtech/api/enums/Materials;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + Label l40 = new Label(); + mv.visitLabel(l40); + mv.visitLineNumber(454, l40); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("stepforward"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l6); + mv.visitLineNumber(457, l6); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false); + Label l41 = new Label(); + mv.visitJumpInsn(IFEQ, l41); + Label l42 = new Label(); + mv.visitLabel(l42); + mv.visitLineNumber(458, l42); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32500"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l43 = new Label(); + mv.visitJumpInsn(IFEQ, l43); + Label l44 = new Label(); + mv.visitLabel(l44); + mv.visitLineNumber(459, l44); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestlead"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l45 = new Label(); + mv.visitLabel(l45); + mv.visitLineNumber(460, l45); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l43); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32501"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l46 = new Label(); + mv.visitJumpInsn(IFEQ, l46); + Label l47 = new Label(); + mv.visitLabel(l47); + mv.visitLineNumber(461, l47); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestsilver"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l48 = new Label(); + mv.visitLabel(l48); + mv.visitLineNumber(462, l48); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l46); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32503"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l49 = new Label(); + mv.visitJumpInsn(IFEQ, l49); + Label l50 = new Label(); + mv.visitLabel(l50); + mv.visitLineNumber(463, l50); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestiron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l51 = new Label(); + mv.visitLabel(l51); + mv.visitLineNumber(464, l51); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l49); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32504"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l52 = new Label(); + mv.visitJumpInsn(IFEQ, l52); + Label l53 = new Label(); + mv.visitLabel(l53); + mv.visitLineNumber(465, l53); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestgold"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l54 = new Label(); + mv.visitLabel(l54); + mv.visitLineNumber(466, l54); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l52); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32530"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l55 = new Label(); + mv.visitJumpInsn(IFEQ, l55); + Label l56 = new Label(); + mv.visitLabel(l56); + mv.visitLineNumber(467, l56); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestcopper"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l57 = new Label(); + mv.visitLabel(l57); + mv.visitLineNumber(468, l57); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l55); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32540"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l58 = new Label(); + mv.visitJumpInsn(IFEQ, l58); + Label l59 = new Label(); + mv.visitLabel(l59); + mv.visitLineNumber(469, l59); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havesttin"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l60 = new Label(); + mv.visitLabel(l60); + mv.visitLineNumber(470, l60); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l58); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32510"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l61 = new Label(); + mv.visitJumpInsn(IFEQ, l61); + Label l62 = new Label(); + mv.visitLabel(l62); + mv.visitLineNumber(471, l62); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestoil"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l63 = new Label(); + mv.visitLabel(l63); + mv.visitLineNumber(472, l63); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l61); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32511"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l64 = new Label(); + mv.visitJumpInsn(IFEQ, l64); + Label l65 = new Label(); + mv.visitLabel(l65); + mv.visitLineNumber(473, l65); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestemeralds"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l66 = new Label(); + mv.visitLabel(l66); + mv.visitLineNumber(474, l66); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l64); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32706"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l67 = new Label(); + mv.visitJumpInsn(IFEQ, l67); + Label l68 = new Label(); + mv.visitLabel(l68); + mv.visitLineNumber(475, l68); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("energyflow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l69 = new Label(); + mv.visitLabel(l69); + mv.visitLineNumber(476, l69); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l67); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32702"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l70 = new Label(); + mv.visitJumpInsn(IFEQ, l70); + Label l71 = new Label(); + mv.visitLabel(l71); + mv.visitLineNumber(477, l71); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("bettercircuits"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l72 = new Label(); + mv.visitLabel(l72); + mv.visitLineNumber(478, l72); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l70); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32707"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l73 = new Label(); + mv.visitJumpInsn(IFEQ, l73); + Label l74 = new Label(); + mv.visitLabel(l74); + mv.visitLineNumber(479, l74); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("datasaving"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l75 = new Label(); + mv.visitLabel(l75); + mv.visitLineNumber(480, l75); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l73); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32597"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l76 = new Label(); + mv.visitJumpInsn(IFEQ, l76); + Label l77 = new Label(); + mv.visitLabel(l77); + mv.visitLineNumber(481, l77); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("orbs"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l78 = new Label(); + mv.visitLabel(l78); + mv.visitLineNumber(482, l78); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l76); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32599"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l79 = new Label(); + mv.visitJumpInsn(IFEQ, l79); + Label l80 = new Label(); + mv.visitLabel(l80); + mv.visitLineNumber(483, l80); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("thatspower"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l81 = new Label(); + mv.visitLabel(l81); + mv.visitLineNumber(484, l81); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l79); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32598"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l82 = new Label(); + mv.visitJumpInsn(IFEQ, l82); + Label l83 = new Label(); + mv.visitLabel(l83); + mv.visitLineNumber(485, l83); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("luck"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l84 = new Label(); + mv.visitLabel(l84); + mv.visitLineNumber(486, l84); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l82); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32749"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l85 = new Label(); + mv.visitJumpInsn(IFEQ, l85); + Label l86 = new Label(); + mv.visitLabel(l86); + mv.visitLineNumber(487, l86); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("closeit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l87 = new Label(); + mv.visitLabel(l87); + mv.visitLineNumber(488, l87); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l85); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32730"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l88 = new Label(); + mv.visitJumpInsn(IFEQ, l88); + Label l89 = new Label(); + mv.visitLabel(l89); + mv.visitLineNumber(489, l89); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("manipulation"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l90 = new Label(); + mv.visitLabel(l90); + mv.visitLineNumber(490, l90); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l88); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32729"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l91 = new Label(); + mv.visitJumpInsn(IFEQ, l91); + Label l92 = new Label(); + mv.visitLabel(l92); + mv.visitLineNumber(491, l92); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("filterregulate"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l93 = new Label(); + mv.visitLabel(l93); + mv.visitLineNumber(492, l93); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l91); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32605"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l94 = new Label(); + mv.visitJumpInsn(IFEQ, l94); + Label l95 = new Label(); + mv.visitLabel(l95); + mv.visitLineNumber(493, l95); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("whatnow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l96 = new Label(); + mv.visitLabel(l96); + mv.visitLineNumber(494, l96); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l94); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.Thoriumcell"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + mv.visitJumpInsn(IFEQ, l41); + Label l97 = new Label(); + mv.visitLabel(l97); + mv.visitLineNumber(495, l97); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newfuel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l41); + mv.visitLineNumber(498, l41); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(RETURN); + Label l98 = new Label(); + mv.visitLabel(l98); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l98, 0); + mv.visitLocalVariable("event", "Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;", null, l0, l98, 1); + mv.visitLocalVariable("player", "Lnet/minecraft/entity/player/EntityPlayer;", null, l1, l98, 2); + mv.visitLocalVariable("stack", "Lnet/minecraft/item/ItemStack;", null, l2, l98, 3); + mv.visitLocalVariable("data", "Lgregtech/api/objects/ItemData;", null, l5, l98, 4); + mv.visitLocalVariable("i", "I", null, l16, l22, 5); + mv.visitMaxs(4, 6); + mv.visitEnd(); + + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + public boolean patchOnItemPickup09(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "onItemPickup" + "."); + + /** + * Inject new, safer code + */ + AnnotationVisitor av0; + mv = cw.visitMethod(ACC_PUBLIC, "onItemPickup", "(Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;)V", null, null); + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(546, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "entityPlayer", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitVarInsn(ASTORE, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(547, l1); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "item", "Lnet/minecraft/entity/item/EntityItem;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/item/EntityItem", "getEntityItem", "()Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(548, l2); + mv.visitVarInsn(ALOAD, 2); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + mv.visitVarInsn(ALOAD, 3); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + mv.visitLabel(l3); + mv.visitLineNumber(549, l3); + mv.visitFrame(F_APPEND,2, new Object[] {"net/minecraft/entity/player/EntityPlayer", "net/minecraft/item/ItemStack"}, 0, null); + mv.visitInsn(RETURN); + mv.visitLabel(l4); + mv.visitLineNumber(551, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gregtech/api/util/GT_OreDictUnificator", "getItemData", "(Lnet/minecraft/item/ItemStack;)Lgregtech/api/objects/ItemData;", false); + mv.visitVarInsn(ASTORE, 4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(552, l5); + mv.visitVarInsn(ALOAD, 4); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IFNULL, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(553, l7); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "dust", "Lgregtech/api/enums/OrePrefixes;"); + Label l8 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(554, l9); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Lutetium", "Lgregtech/api/enums/Materials;"); + Label l10 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l10); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(555, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newmetal"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l10); + mv.visitLineNumber(557, l10); + mv.visitFrame(F_APPEND,1, new Object[] {"gregtech/api/objects/ItemData"}, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Gunpowder", "Lgregtech/api/enums/Materials;"); + mv.visitJumpInsn(IF_ACMPEQ, l6); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(558, l12); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("cleandust"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLineNumber(560, l13); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l8); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/enums/OrePrefixes", "name", "()Ljava/lang/String;", false); + mv.visitLdcInsn("ore"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false); + Label l14 = new Label(); + mv.visitJumpInsn(IFEQ, l14); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(561, l15); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "size", "()I", false); + mv.visitVarInsn(ISTORE, 5); + Label l16 = new Label(); + mv.visitLabel(l16); + mv.visitLineNumber(562, l16); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ISTORE, 6); + Label l17 = new Label(); + mv.visitLabel(l17); + Label l18 = new Label(); + mv.visitJumpInsn(GOTO, l18); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(563, l19); + mv.visitFrame(F_APPEND,2, new Object[] {INTEGER, INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/enums/Materials", "mName", "Ljava/lang/String;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l20 = new Label(); + mv.visitLabel(l20); + mv.visitLineNumber(564, l20); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Iron", "Lgregtech/api/enums/Materials;"); + Label l21 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l21); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(565, l22); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("iron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l21); + mv.visitLineNumber(567, l21); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Copper", "Lgregtech/api/enums/Materials;"); + Label l23 = new Label(); + mv.visitJumpInsn(IF_ACMPEQ, l23); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Tin", "Lgregtech/api/enums/Materials;"); + Label l24 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l24); + mv.visitLabel(l23); + mv.visitLineNumber(568, l23); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "entityPlayer", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitLdcInsn("mineOre"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l24); + mv.visitLineNumber(562, l24); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitIincInsn(6, 1); + mv.visitLabel(l18); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 6); + mv.visitVarInsn(ILOAD, 5); + mv.visitJumpInsn(IF_ICMPLT, l19); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(572, l25); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l14); + mv.visitFrame(F_CHOP,2, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushed", "Lgregtech/api/enums/OrePrefixes;"); + Label l26 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l26); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(573, l27); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("crushed"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLineNumber(574, l28); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l26); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedPurified", "Lgregtech/api/enums/OrePrefixes;"); + Label l29 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l29); + Label l30 = new Label(); + mv.visitLabel(l30); + mv.visitLineNumber(575, l30); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("washing"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l31 = new Label(); + mv.visitLabel(l31); + mv.visitLineNumber(576, l31); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l29); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedCentrifuged", "Lgregtech/api/enums/OrePrefixes;"); + Label l32 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l32); + Label l33 = new Label(); + mv.visitLabel(l33); + mv.visitLineNumber(577, l33); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("spinit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l34 = new Label(); + mv.visitLabel(l34); + mv.visitLineNumber(578, l34); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l32); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Steel", "Lgregtech/api/enums/Materials;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + Label l35 = new Label(); + mv.visitLabel(l35); + mv.visitLineNumber(579, l35); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "ingot", "Lgregtech/api/enums/OrePrefixes;"); + Label l36 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l36); + mv.visitVarInsn(ALOAD, 3); + mv.visitFieldInsn(GETFIELD, "net/minecraft/item/ItemStack", "stackSize", "I"); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getMaxStackSize", "()I", false); + mv.visitJumpInsn(IF_ICMPNE, l36); + Label l37 = new Label(); + mv.visitLabel(l37); + mv.visitLineNumber(580, l37); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l38 = new Label(); + mv.visitLabel(l38); + mv.visitLineNumber(581, l38); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l36); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "nugget", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + mv.visitLdcInsn("Thaumcraft"); + mv.visitMethodInsn(INVOKESTATIC, "cpw/mods/fml/common/Loader", "isModLoaded", "(Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/player/EntityPlayer", "getDisplayName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("GT_IRON_TO_STEEL"); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/api/ThaumcraftApiHelper", "isResearchComplete", "(Ljava/lang/String;Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l39 = new Label(); + mv.visitLabel(l39); + mv.visitLineNumber(582, l39); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l6); + mv.visitLineNumber(589, l6); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false); + Label l40 = new Label(); + mv.visitJumpInsn(IFEQ, l40); + Label l41 = new Label(); + mv.visitLabel(l41); + mv.visitLineNumber(590, l41); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32500"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l42 = new Label(); + mv.visitJumpInsn(IFEQ, l42); + Label l43 = new Label(); + mv.visitLabel(l43); + mv.visitLineNumber(591, l43); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestlead"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l44 = new Label(); + mv.visitLabel(l44); + mv.visitLineNumber(592, l44); + Label l45 = new Label(); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l42); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32501"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l46 = new Label(); + mv.visitJumpInsn(IFEQ, l46); + Label l47 = new Label(); + mv.visitLabel(l47); + mv.visitLineNumber(593, l47); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestsilver"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l48 = new Label(); + mv.visitLabel(l48); + mv.visitLineNumber(594, l48); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l46); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32503"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l49 = new Label(); + mv.visitJumpInsn(IFEQ, l49); + Label l50 = new Label(); + mv.visitLabel(l50); + mv.visitLineNumber(595, l50); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestiron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l51 = new Label(); + mv.visitLabel(l51); + mv.visitLineNumber(596, l51); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l49); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32504"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l52 = new Label(); + mv.visitJumpInsn(IFEQ, l52); + Label l53 = new Label(); + mv.visitLabel(l53); + mv.visitLineNumber(597, l53); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestgold"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l54 = new Label(); + mv.visitLabel(l54); + mv.visitLineNumber(598, l54); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l52); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32530"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l55 = new Label(); + mv.visitJumpInsn(IFEQ, l55); + Label l56 = new Label(); + mv.visitLabel(l56); + mv.visitLineNumber(599, l56); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestcopper"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l57 = new Label(); + mv.visitLabel(l57); + mv.visitLineNumber(600, l57); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l55); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32540"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l58 = new Label(); + mv.visitJumpInsn(IFEQ, l58); + Label l59 = new Label(); + mv.visitLabel(l59); + mv.visitLineNumber(601, l59); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havesttin"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l60 = new Label(); + mv.visitLabel(l60); + mv.visitLineNumber(602, l60); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l58); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32510"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l61 = new Label(); + mv.visitJumpInsn(IFEQ, l61); + Label l62 = new Label(); + mv.visitLabel(l62); + mv.visitLineNumber(603, l62); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestoil"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l63 = new Label(); + mv.visitLabel(l63); + mv.visitLineNumber(604, l63); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l61); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32511"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l64 = new Label(); + mv.visitJumpInsn(IFEQ, l64); + Label l65 = new Label(); + mv.visitLabel(l65); + mv.visitLineNumber(605, l65); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestemeralds"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l66 = new Label(); + mv.visitLabel(l66); + mv.visitLineNumber(606, l66); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l64); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32082"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l67 = new Label(); + mv.visitJumpInsn(IFEQ, l67); + Label l68 = new Label(); + mv.visitLabel(l68); + mv.visitLineNumber(607, l68); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("energyflow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l69 = new Label(); + mv.visitLabel(l69); + mv.visitLineNumber(608, l69); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l67); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32702"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l70 = new Label(); + mv.visitJumpInsn(IFEQ, l70); + Label l71 = new Label(); + mv.visitLabel(l71); + mv.visitLineNumber(609, l71); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("bettercircuits"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l72 = new Label(); + mv.visitLabel(l72); + mv.visitLineNumber(610, l72); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l70); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32707"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l73 = new Label(); + mv.visitJumpInsn(IFEQ, l73); + Label l74 = new Label(); + mv.visitLabel(l74); + mv.visitLineNumber(611, l74); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("datasaving"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l75 = new Label(); + mv.visitLabel(l75); + mv.visitLineNumber(612, l75); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l73); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32597"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l76 = new Label(); + mv.visitJumpInsn(IFEQ, l76); + Label l77 = new Label(); + mv.visitLabel(l77); + mv.visitLineNumber(613, l77); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("orbs"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l78 = new Label(); + mv.visitLabel(l78); + mv.visitLineNumber(614, l78); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l76); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32599"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l79 = new Label(); + mv.visitJumpInsn(IFEQ, l79); + Label l80 = new Label(); + mv.visitLabel(l80); + mv.visitLineNumber(615, l80); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("thatspower"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l81 = new Label(); + mv.visitLabel(l81); + mv.visitLineNumber(616, l81); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l79); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32598"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l82 = new Label(); + mv.visitJumpInsn(IFEQ, l82); + Label l83 = new Label(); + mv.visitLabel(l83); + mv.visitLineNumber(617, l83); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("luck"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l84 = new Label(); + mv.visitLabel(l84); + mv.visitLineNumber(618, l84); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l82); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32749"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l85 = new Label(); + mv.visitJumpInsn(IFEQ, l85); + Label l86 = new Label(); + mv.visitLabel(l86); + mv.visitLineNumber(619, l86); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("closeit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l87 = new Label(); + mv.visitLabel(l87); + mv.visitLineNumber(620, l87); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l85); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32730"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l88 = new Label(); + mv.visitJumpInsn(IFEQ, l88); + Label l89 = new Label(); + mv.visitLabel(l89); + mv.visitLineNumber(621, l89); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("manipulation"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l90 = new Label(); + mv.visitLabel(l90); + mv.visitLineNumber(622, l90); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l88); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32729"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l91 = new Label(); + mv.visitJumpInsn(IFEQ, l91); + Label l92 = new Label(); + mv.visitLabel(l92); + mv.visitLineNumber(623, l92); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("filterregulate"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l93 = new Label(); + mv.visitLabel(l93); + mv.visitLineNumber(624, l93); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l91); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32605"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l94 = new Label(); + mv.visitJumpInsn(IFEQ, l94); + Label l95 = new Label(); + mv.visitLabel(l95); + mv.visitLineNumber(625, l95); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("whatnow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l96 = new Label(); + mv.visitLabel(l96); + mv.visitLineNumber(626, l96); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l94); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32736"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l97 = new Label(); + mv.visitJumpInsn(IFEQ, l97); + Label l98 = new Label(); + mv.visitLabel(l98); + mv.visitLineNumber(627, l98); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("zpmage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l99 = new Label(); + mv.visitLabel(l99); + mv.visitLineNumber(628, l99); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l97); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32737"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l100 = new Label(); + mv.visitJumpInsn(IFEQ, l100); + Label l101 = new Label(); + mv.visitLabel(l101); + mv.visitLineNumber(629, l101); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("uvage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l102 = new Label(); + mv.visitLabel(l102); + mv.visitLineNumber(630, l102); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l100); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32030"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l103 = new Label(); + mv.visitJumpInsn(IFEQ, l103); + Label l104 = new Label(); + mv.visitLabel(l104); + mv.visitLineNumber(631, l104); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtmonosilicon"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l105 = new Label(); + mv.visitLabel(l105); + mv.visitLineNumber(632, l105); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l103); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32036"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l106 = new Label(); + mv.visitJumpInsn(IFEQ, l106); + Label l107 = new Label(); + mv.visitLabel(l107); + mv.visitLineNumber(633, l107); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtlogicwafer"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l108 = new Label(); + mv.visitLabel(l108); + mv.visitLineNumber(634, l108); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l106); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32701"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l109 = new Label(); + mv.visitJumpInsn(IFEQ, l109); + Label l110 = new Label(); + mv.visitLabel(l110); + mv.visitLineNumber(635, l110); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtlogiccircuit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l111 = new Label(); + mv.visitLabel(l111); + mv.visitLineNumber(636, l111); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l109); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32085"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l112 = new Label(); + mv.visitJumpInsn(IFEQ, l112); + Label l113 = new Label(); + mv.visitLabel(l113); + mv.visitLineNumber(637, l113); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtquantumprocessor"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l114 = new Label(); + mv.visitLabel(l114); + mv.visitLineNumber(638, l114); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l112); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32089"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l115 = new Label(); + mv.visitJumpInsn(IFEQ, l115); + Label l116 = new Label(); + mv.visitLabel(l116); + mv.visitLineNumber(639, l116); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtcrystalprocessor"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l117 = new Label(); + mv.visitLabel(l117); + mv.visitLineNumber(640, l117); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l115); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32092"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l118 = new Label(); + mv.visitJumpInsn(IFEQ, l118); + Label l119 = new Label(); + mv.visitLabel(l119); + mv.visitLineNumber(641, l119); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtwetware"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l120 = new Label(); + mv.visitLabel(l120); + mv.visitLineNumber(642, l120); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l118); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32095"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l121 = new Label(); + mv.visitJumpInsn(IFEQ, l121); + Label l122 = new Label(); + mv.visitLabel(l122); + mv.visitLineNumber(643, l122); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtwetmain"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l123 = new Label(); + mv.visitLabel(l123); + mv.visitLineNumber(644, l123); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l121); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32736"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l124 = new Label(); + mv.visitJumpInsn(IFEQ, l124); + Label l125 = new Label(); + mv.visitLabel(l125); + mv.visitLineNumber(645, l125); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("zpmage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l126 = new Label(); + mv.visitLabel(l126); + mv.visitLineNumber(646, l126); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l124); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32737"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + mv.visitJumpInsn(IFEQ, l45); + Label l127 = new Label(); + mv.visitLabel(l127); + mv.visitLineNumber(647, l127); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("uvage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l128 = new Label(); + mv.visitLabel(l128); + mv.visitLineNumber(649, l128); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l40); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.Thoriumcell"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l129 = new Label(); + mv.visitJumpInsn(IFEQ, l129); + Label l130 = new Label(); + mv.visitLabel(l130); + mv.visitLineNumber(650, l130); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newfuel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l131 = new Label(); + mv.visitLabel(l131); + mv.visitLineNumber(651, l131); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l129); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumBodyarmor", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + Label l132 = new Label(); + mv.visitJumpInsn(IF_ACMPEQ, l132); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumBoots", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitJumpInsn(IF_ACMPEQ, l132); + Label l133 = new Label(); + mv.visitLabel(l133); + mv.visitLineNumber(652, l133); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumHelmet", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitJumpInsn(IF_ACMPEQ, l132); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumLeggings", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + Label l134 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l134); + mv.visitLabel(l132); + mv.visitLineNumber(653, l132); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("buildQArmor"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l135 = new Label(); + mv.visitLabel(l135); + mv.visitLineNumber(654, l135); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l134); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("ic2.itemPartCircuitAdv"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + mv.visitJumpInsn(IFEQ, l45); + Label l136 = new Label(); + mv.visitLabel(l136); + mv.visitLineNumber(655, l136); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("stepforward"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l45); + mv.visitLineNumber(657, l45); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(RETURN); + Label l137 = new Label(); + mv.visitLabel(l137); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l137, 0); + mv.visitLocalVariable("event", "Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;", null, l0, l137, 1); + mv.visitLocalVariable("player", "Lnet/minecraft/entity/player/EntityPlayer;", null, l1, l137, 2); + mv.visitLocalVariable("stack", "Lnet/minecraft/item/ItemStack;", null, l2, l137, 3); + mv.visitLocalVariable("data", "Lgregtech/api/objects/ItemData;", null, l5, l137, 4); + mv.visitLocalVariable("data_getAllMaterialStacks_sS", "I", null, l16, l25, 5); + mv.visitLocalVariable("i", "I", null, l17, l25, 6); + mv.visitMaxs(4, 7); + mv.visitEnd(); + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + + + + + + + public class MethodAdaptor extends ClassVisitor { + + public MethodAdaptor(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("registerAssAchievement") || name.equals("onItemPickup")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, + "Found method " + name + ", removing."); + methodVisitor = null; + if (name.equals("registerAssAchievement")) { + mDidRemoveAssLineRecipeAdder = true; + } + } else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java new file mode 100644 index 0000000000..c5b12eb248 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java @@ -0,0 +1,571 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ASM5; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.objectweb.asm.Opcodes.RETURN; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.UUID; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.common.reflect.ClassPath; +import com.google.common.reflect.ClassPath.ClassInfo; + +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_PlayedSound; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.loaders.misc.AssLineAchievements; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatFileWriter; + +public class ClassTransformer_GT_Client { + + private final boolean valid; + private final ClassReader read; + private final ClassWriter write; + private boolean mModern; + private byte[] mTooledClass; + + public ClassTransformer_GT_Client(byte[] basicClass) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + + /** + * Let's just read the GT archive for some info + */ + mModern = findAssemblyLineClass(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Found Assembly Line? "+mModern+"."); + if (mModern) { + aTempReader.accept(new MethodAdaptor2(aTempWriter), 0); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching Client handling of Assembly Line recipe visibility for GT 5.09"); + injectMethod(aTempWriter); + if (aTempReader != null && aTempWriter != null) { + valid = true; + mTooledClass = aTempWriter.toByteArray(); + } + else { + valid = false; + } + } + else { + mTooledClass = basicClass; + valid = true; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Valid? "+valid+"."); + read = aTempReader; + write = aTempWriter; + } + + public boolean isValidTransformer() { + return valid; + } + + public ClassReader getReader() { + return read; + } + + public ClassWriter getWriter() { + return write; + } + + public boolean findAssemblyLineClass() { + ClassLoader cl = getClass().getClassLoader(); + try { + Set classesInPackage = ClassPath.from(cl).getTopLevelClassesRecursive("gregtech"); + if (classesInPackage != null && classesInPackage.size() > 0) { + for (ClassInfo x : classesInPackage) { + if (x.getResourceName().contains("GT_MetaTileEntity_AssemblyLine")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, + "Patchable class | " + x.getResourceName()); + return true; + } + } + } + } catch (IOException e) { + } + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Failed to find Gregtech classes using prefered method, using backup."); + + cl = ClassLoader.getSystemClassLoader(); + ImmutableMap g = getClassPathEntries(cl); + File aGregtech = null; + if (g.size() > 0) { + for (int i = 0; i < g.size(); i++) { + String aName; + try { + File aF = g.keySet().asList().get(i); + aName = aF.getName(); + if (aName != null && aName.length() > 0) { + if (aName.toLowerCase().contains("gregtech")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patchable class | "+aName); + aGregtech = aF; + } + } + } + catch (Throwable t) {} + } + } + + if (aGregtech != null) { + try { + File file = aGregtech; + FileInputStream fis = new FileInputStream(file); + JarInputStream jis = new JarInputStream(fis); + System.out.println(jis.markSupported()); + JarEntry je; + while((je=jis.getNextJarEntry())!=null){ + if (je.getName().contains("GT_MetaTileEntity_AssemblyLine")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patchable class | "+je.getName()); + return true; + } + } + jis.close(); + return true; + } catch (IOException e1) { + } + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Failed to find Gregtech classes using backup method, probably using GT 5.08"); + + return false; + } + + static ImmutableMap getClassPathEntries(ClassLoader classloader) { + LinkedHashMap entries = Maps.newLinkedHashMap(); + // Search parent first, since it's the order ClassLoader#loadClass() uses. + ClassLoader parent = classloader.getParent(); + if (parent != null) { + entries.putAll(getClassPathEntries(parent)); + } + if (classloader instanceof URLClassLoader) { + URLClassLoader urlClassLoader = (URLClassLoader) classloader; + for (URL entry : urlClassLoader.getURLs()) { + if (entry.getProtocol().equals("file")) { + File file = new File(entry.getFile()); + if (!entries.containsKey(file)) { + entries.put(file, classloader); + } + } + } + } + return ImmutableMap.copyOf(entries); + } + + public boolean injectMethod(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "onPlayerTickEventClient" + "."); + + /** + * Inject new, safer code + */ + + AnnotationVisitor av0; + + + /** + * Full Patch ASM - Original Idea, now second to static injection of a custom handler. + */ + + /*mv = cw.visitMethod(ACC_PUBLIC, "onPlayerTickEventClient", "(Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;)V", null, null); + { + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + } + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception"); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(370, l3); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "side", "Lcpw/mods/fml/relauncher/Side;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "cpw/mods/fml/relauncher/Side", "isClient", "()Z", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFEQ, l4); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "phase", "Lcpw/mods/fml/common/gameevent/TickEvent$Phase;"); + mv.visitFieldInsn(GETSTATIC, "cpw/mods/fml/common/gameevent/TickEvent$Phase", "END", "Lcpw/mods/fml/common/gameevent/TickEvent$Phase;"); + mv.visitJumpInsn(IF_ACMPNE, l4); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "player", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", "isDead", "Z"); + mv.visitJumpInsn(IFNE, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(371, l5); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + mv.visitInsn(LCONST_1); + mv.visitInsn(LADD); + mv.visitFieldInsn(PUTFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(372, l6); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + mv.visitLdcInsn(new Long(100L)); + mv.visitInsn(LCMP); + Label l7 = new Label(); + mv.visitJumpInsn(IFLT, l7); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(373, l8); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(LCONST_0); + mv.visitFieldInsn(PUTFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(374, l9); + mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/Minecraft", "getMinecraft", "()Lnet/minecraft/client/Minecraft;", false); + mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", "thePlayer", "Lnet/minecraft/client/entity/EntityClientPlayerMP;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/client/entity/EntityClientPlayerMP", "getStatFileWriter", "()Lnet/minecraft/stats/StatFileWriter;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l0); + mv.visitLineNumber(376, l0); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Recipe$GT_Recipe_Map", "sAssemblylineVisualRecipes", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/util/GT_Recipe$GT_Recipe_Map", "mRecipeList", "Ljava/util/Collection;"); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "iterator", "()Ljava/util/Iterator;", true); + mv.visitVarInsn(ASTORE, 4); + Label l10 = new Label(); + mv.visitJumpInsn(GOTO, l10); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/util/GT_Recipe"); + mv.visitVarInsn(ASTORE, 3); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(377, l12); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements", "getAchievement", "(Ljava/lang/String;)Lnet/minecraft/stats/Achievement;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/stats/StatFileWriter", "hasAchievementUnlocked", "(Lnet/minecraft/stats/Achievement;)Z", false); + Label l13 = new Label(); + mv.visitJumpInsn(IFEQ, l13); + mv.visitInsn(ICONST_0); + Label l14 = new Label(); + mv.visitJumpInsn(GOTO, l14); + mv.visitLabel(l13); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", "gregtech/api/util/GT_Recipe", "java/util/Iterator"}, 1, new Object[] {"gregtech/api/util/GT_Recipe"}); + mv.visitInsn(ICONST_1); + mv.visitLabel(l14); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", "gregtech/api/util/GT_Recipe", "java/util/Iterator"}, 2, new Object[] {"gregtech/api/util/GT_Recipe", INTEGER}); + mv.visitFieldInsn(PUTFIELD, "gregtech/api/util/GT_Recipe", "mHidden", "Z"); + mv.visitLabel(l10); + mv.visitLineNumber(376, l10); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); + mv.visitJumpInsn(IFNE, l11); + mv.visitLabel(l1); + mv.visitLineNumber(379, l1); + mv.visitJumpInsn(GOTO, l7); + mv.visitLabel(l2); + mv.visitFrame(F_FULL, 3, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter"}, 1, new Object[] {"java/lang/Exception"}); + mv.visitVarInsn(ASTORE, 3); + mv.visitLabel(l7); + mv.visitLineNumber(381, l7); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitTypeInsn(NEW, "java/util/ArrayList"); + mv.visitInsn(DUP); + mv.visitMethodInsn(INVOKESPECIAL, "java/util/ArrayList", "", "()V", false); + mv.visitVarInsn(ASTORE, 2); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(382, l15); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Utility", "sPlayedSoundMap", "Ljava/util/Map;"); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "entrySet", "()Ljava/util/Set;", true); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Set", "iterator", "()Ljava/util/Iterator;", true); + mv.visitVarInsn(ASTORE, 4); + Label l16 = new Label(); + mv.visitJumpInsn(GOTO, l16); + Label l17 = new Label(); + mv.visitLabel(l17); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "java/util/ArrayList", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "java/util/Map$Entry"); + mv.visitVarInsn(ASTORE, 3); + Label l18 = new Label(); + mv.visitLabel(l18); + mv.visitLineNumber(383, l18); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false); + Label l19 = new Label(); + mv.visitJumpInsn(IFGE, l19); + Label l20 = new Label(); + mv.visitLabel(l20); + mv.visitLineNumber(384, l20); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getKey", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/util/GT_PlayedSound"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "add", "(Ljava/lang/Object;)Z", false); + mv.visitInsn(POP); + Label l21 = new Label(); + mv.visitLabel(l21); + mv.visitLineNumber(385, l21); + mv.visitJumpInsn(GOTO, l16); + mv.visitLabel(l19); + mv.visitLineNumber(386, l19); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "java/util/ArrayList", "java/util/Map$Entry", "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false); + mv.visitInsn(ICONST_1); + mv.visitInsn(ISUB); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "setValue", "(Ljava/lang/Object;)Ljava/lang/Object;", true); + mv.visitInsn(POP); + mv.visitLabel(l16); + mv.visitLineNumber(382, l16); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "java/util/ArrayList", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); + mv.visitJumpInsn(IFNE, l17); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(390, l22); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "iterator", "()Ljava/util/Iterator;", false); + mv.visitVarInsn(ASTORE, 4); + Label l23 = new Label(); + mv.visitLabel(l23); + Label l24 = new Label(); + mv.visitJumpInsn(GOTO, l24); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(391, l25); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/util/GT_PlayedSound"); + mv.visitVarInsn(ASTORE, 3); + Label l26 = new Label(); + mv.visitLabel(l26); + mv.visitLineNumber(390, l26); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Utility", "sPlayedSoundMap", "Ljava/util/Map;"); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "remove", "(Ljava/lang/Object;)Ljava/lang/Object;", true); + mv.visitInsn(POP); + mv.visitLabel(l24); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); + mv.visitJumpInsn(IFNE, l25); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(393, l27); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/GregTech_API", "mServerStarted", "Z"); + mv.visitJumpInsn(IFNE, l4); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLineNumber(394, l28); + mv.visitInsn(ICONST_1); + mv.visitFieldInsn(PUTSTATIC, "gregtech/api/GregTech_API", "mServerStarted", "Z"); + mv.visitLabel(l4); + mv.visitLineNumber(397, l4); + mv.visitFrame(F_FULL, 2, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent"}, 0, new Object[] {}); + mv.visitInsn(RETURN); + Label l29 = new Label(); + mv.visitLabel(l29); + mv.visitLocalVariable("this", "Lgregtech/common/GT_Client;", null, l3, l29, 0); + mv.visitLocalVariable("aEvent", "Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;", null, l3, l29, 1); + mv.visitLocalVariable("sfw", "Lnet/minecraft/stats/StatFileWriter;", null, l0, l7, 2); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l12, l10, 3); + mv.visitLocalVariable("tList", "Ljava/util/ArrayList;", "Ljava/util/ArrayList;", l15, l4, 2); + mv.visitLocalVariable("tEntry", "Ljava/util/Map$Entry;", "Ljava/util/Map$Entry;", l18, l16, 3); + mv.visitLocalVariable("tKey", "Lgregtech/api/util/GT_PlayedSound;", null, l26, l24, 3); + mv.visitLocalVariable("i", "Ljava/util/Iterator;", "Ljava/util/Iterator;", l23, l27, 4); + mv.visitMaxs(5, 5); + mv.visitEnd();*/ + + /** + * Static invocation of custom handler instead + */ + + + mv = cw.visitMethod(ACC_PUBLIC, "onPlayerTickEventClient", "(Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;)V", null, null); + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(371, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client", "onPlayerTickEventClient", "(Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(372, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lgregtech/common/GT_Client;", null, l0, l2, 0); + mv.visitLocalVariable("aEvent", "Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;", null, l0, l2, 1); + mv.visitMaxs(1, 2); + mv.visitEnd(); + + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + + } + + public class MethodAdaptor2 extends ClassVisitor { + + public MethodAdaptor2(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("onPlayerTickEventClient")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, + "Found method " + name + ", removing."); + methodVisitor = null; + } else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + + public byte[] getByteArray() { + if (mTooledClass != null) { + return mTooledClass; + } + return getWriter().toByteArray(); + } + + + private static final Map aTimeMap = new HashMap(); + + + public static void onPlayerTickEventClient(PlayerTickEvent aEvent) { + if (aEvent.side.isClient() && aEvent.phase == Phase.END && !aEvent.player.isDead) { + long aTime = 0; + if (aTimeMap.get(aEvent.player.getUniqueID()) == null) { + aTimeMap.put(aEvent.player.getUniqueID(), 0l); + } + else { + aTime = aTimeMap.get(aEvent.player.getUniqueID()) + 1; + aTimeMap.put(aEvent.player.getUniqueID(), aTime); + } + if (aTime >= 100L) { + aTimeMap.put(aEvent.player.getUniqueID(), 0l); + /** + * Remove original handling + */ + if (StaticFields59.mAssLineVisualMapNEI != null) { + StatFileWriter tList = Minecraft.getMinecraft().thePlayer.getStatFileWriter(); + GT_Recipe_Map aAssLineNei; + try { + aAssLineNei = (GT_Recipe_Map) StaticFields59.mAssLineVisualMapNEI.get(null); + for (GT_Recipe aFakeAssLineRecipe : aAssLineNei.mRecipeList) { + String aSafeUnlocalName; + if (aFakeAssLineRecipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + continue; + } + ItemStack aStack = aFakeAssLineRecipe.getOutput(0); + try { + aSafeUnlocalName = aStack.getUnlocalizedName(); + } catch (Throwable t) { + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + } + aFakeAssLineRecipe.mHidden = !tList.hasAchievementUnlocked(AssLineAchievements.getAchievement(aSafeUnlocalName)); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + } + + Iterator tKey; + ArrayList arg5 = new ArrayList(); + tKey = GT_Utility.sPlayedSoundMap.entrySet().iterator(); + + while (tKey.hasNext()) { + Entry arg7 = (Entry) tKey.next(); + if (((Integer) arg7.getValue()).intValue() < 0) { + arg5.add(arg7.getKey()); + } else { + arg7.setValue(Integer.valueOf(((Integer) arg7.getValue()).intValue() - 1)); + } + } + + Iterator arg8 = arg5.iterator(); + + while (arg8.hasNext()) { + GT_PlayedSound arg6 = (GT_PlayedSound) arg8.next(); + GT_Utility.sPlayedSoundMap.remove(arg6); + } + + if (!GregTech_API.mServerStarted) { + GregTech_API.mServerStarted = true; + } + } + } + + + + + + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index c47984a530..7e2e6e72fc 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -2,7 +2,6 @@ package gtPlusPlus.preloader.asm.transformers; import java.io.File; import java.io.IOException; -import java.util.Random; import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; @@ -11,14 +10,10 @@ import org.objectweb.asm.ClassWriter; import cpw.mods.fml.relauncher.CoreModManager; import cpw.mods.fml.relauncher.FMLRelaunchLog; import cpw.mods.fml.relauncher.ReflectionHelper; -import galaxyspace.SolarSystem.core.configs.GSConfigDimensions; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraft.launchwrapper.Launch; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.preloader.asm.transformers.Preloader_ClassTransformer.OreDictionaryVisitor; +import net.minecraft.launchwrapper.IClassTransformer; +import net.minecraft.launchwrapper.Launch; @SuppressWarnings("static-access") public class Preloader_Transformer_Handler implements IClassTransformer { @@ -118,6 +113,28 @@ public class Preloader_Transformer_Handler implements IClassTransformer { } } + + + + + + /** + * Gregtech ASM Patches + */ + + //Try patch achievements + if (transformedName.equals("gregtech.loaders.misc.GT_Achievements")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_Achievements(basicClass).getWriter().toByteArray(); + } + if (transformedName.equals("gregtech.common.GT_Client")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_Client(basicClass).getByteArray(); + } + + + + //Patching Meta Tile Tooltips if (transformedName.equals("gregtech.common.blocks.GT_Item_Machines") && mConfig.enableGtTooltipFix) { FMLRelaunchLog.log("[GT++ ASM] Gregtech Tooltip Patch", Level.INFO, "Transforming %s", transformedName); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 0556a7f4fe..2549144a2a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -15,26 +15,15 @@ import java.util.TimerTask; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.fluids.FluidStack; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Proxy; -import gregtech.common.blocks.GT_Block_Machines; -import gregtech.common.render.GT_Renderer_Block; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.ObjMap; @@ -44,8 +33,15 @@ import gtPlusPlus.core.util.reflect.ProxyFinder; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.BaseCustomPower_MTE; -import gtPlusPlus.xmod.gregtech.common.blocks.GTPP_Block_Machines; -import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; +import gtPlusPlus.xmod.gregtech.loaders.misc.AssLineAchievements; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; public class Meta_GT_Proxy { @@ -64,6 +60,8 @@ public class Meta_GT_Proxy { private static Class sBaseMetaTileEntityClass; private static Class sBaseMetaTileEntityClass2; + public static AssLineAchievements mAssemblyAchievements; + public static final Map mCustomGregtechMetaTooltips = new LinkedHashMap(); @@ -97,6 +95,7 @@ public class Meta_GT_Proxy { } public void init() { + mAssemblyAchievements = new AssLineAchievements(); scheduleCoverMapCleaner(); setValidHeatingCoilMetas(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index c1db39b132..9068bf2ec1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -33,6 +33,7 @@ public class StaticFields59 { public static final Field mMultiblockChemicalRecipes; public static final Field mDescriptionArray; public static final Field mCasingTexturePages; + public static final Field mAssLineVisualMapNEI; public static final Method mCalculatePollutionReduction; public static final Method mAddFurnaceRecipe; @@ -49,6 +50,7 @@ public class StaticFields59 { mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); mDescriptionArray = getField(GT_MetaTileEntity_TieredMachineBlock.class, "mDescriptionArray"); mCasingTexturePages = getField(BlockIcons.class, "casingTexturePages"); + mAssLineVisualMapNEI = getField(GT_Recipe_Map.class, "sAssemblylineVisualRecipes"); mCalculatePollutionReduction = getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", int.class); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java new file mode 100644 index 0000000000..368332b64b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java @@ -0,0 +1,159 @@ +package gtPlusPlus.xmod.gregtech.loaders.misc; + +import java.util.concurrent.ConcurrentHashMap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatBase; +import net.minecraftforge.common.AchievementPage; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; + +public class AssLineAchievements { + + public static int assReg = -1; + public static ConcurrentHashMap mAchievementMap; + public static ConcurrentHashMap mIssuedAchievementMap; + public static int adjX = 5; + public static int adjY = 9; + private static boolean active = true; + + public AssLineAchievements() { + Logger.INFO(active ? "Loading custom achievement page for Assembly Line recipes." + : "Achievements are disabled."); + Utils.registerEvent(this); + } + + private static boolean ready = false; + private static int recipeTotal = 0; + private static int recipeCount = 0; + private static void init() { + if (!ready) { + active = GT_Mod.gregtechproxy.mAchievements; + try { + recipeTotal = ((GT_Recipe.GT_Recipe_Map) StaticFields59.mAssLineVisualMapNEI.get(null)).mRecipeList.size(); + } catch (IllegalArgumentException | IllegalAccessException e) { + recipeTotal = 0; + } + mAchievementMap = new ConcurrentHashMap(); + mIssuedAchievementMap = new ConcurrentHashMap(); + } + + } + + public static void registerAchievements() { + if (active && mAchievementMap.size() > 0) { + AchievementPage.registerAchievementPage(new AchievementPage("GT Assembly Line", + (Achievement[]) mAchievementMap.values().toArray(new Achievement[mAchievementMap.size()]))); + } + else if (active) { + Logger.INFO("Unable to register custom achievement page for Assembly Line recipes."); + } + } + + public static Achievement registerAssAchievement(GT_Recipe recipe) { + init(); + String aSafeUnlocalName; + // Debugging + if (recipe == null) { + Logger.INFO( + "Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + return null; + } + if (recipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + return null; + } + ItemStack aStack = recipe.getOutput(0); + try { + aSafeUnlocalName = aStack.getUnlocalizedName(); + } catch (Throwable t) { + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + } + + Achievement aYouDidSomethingInGT; + if (mAchievementMap.get(aSafeUnlocalName) == null) { + assReg++; + recipeCount++; + aYouDidSomethingInGT = registerAchievement(aSafeUnlocalName, -(11 + assReg % 5), ((assReg) / 5) - 8, + recipe.getOutput(0), AchievementList.openInventory, false); + } + else { + aYouDidSomethingInGT = null; + } + if (recipeCount >= recipeTotal) { + Logger.INFO("Critical mass achieved, releasing toxic Assembly Line recipes into new reservoir. ["+recipeCount+"]"); + registerAchievements(); + } + + return aYouDidSomethingInGT; + } + + public static Achievement registerAchievement(String textId, int x, int y, ItemStack icon, + Achievement requirement, boolean special) { + if (!GT_Mod.gregtechproxy.mAchievements) { + return null; + } + Achievement achievement = new Achievement(textId, textId, adjX + x, adjY + y, icon, requirement); + if (special) { + achievement.setSpecial(); + } + achievement.registerStat(); + if (GT_Values.D2) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + mAchievementMap.put(textId, achievement); + return achievement; + } + + public static void issueAchievement(EntityPlayer entityplayer, String textId) { + if (entityplayer == null || !GT_Mod.gregtechproxy.mAchievements) { + return; + } + entityplayer.triggerAchievement((StatBase) mAchievementMap.get(textId)); + } + + public static Achievement getAchievement(String textId) { + if (mAchievementMap.containsKey(textId)) { + return (Achievement) mAchievementMap.get(textId); + } + return null; + } + + @SubscribeEvent + public void onItemPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack stack = event.item.getEntityItem(); + if (player == null || stack == null) { + return; + } + Logger.INFO("Trying to check for achievements"); + // Debug scanner unlocks all AL recipes in creative + if (player.capabilities.isCreativeMode && stack.getUnlocalizedName().equals("gt.metaitem.01.32761")) { + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { + issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); + recipe.mHidden = false; + } + } + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { + if (recipe.getOutput(0).getUnlocalizedName().equals(stack.getUnlocalizedName())) { + issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); + recipe.mHidden = false; + } + } + } + +} diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index d5e0f165c1..5fa8aebf8e 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -1806,7 +1806,7 @@ tile.Block of Uranium 233.name=Block of Uranium 233 tile.Block of Plutonium-238.name=Block of Plutonium 238 tile.Block of Strontium-90.name=Block of Strontium 90 tile.Block of Polonium-210.name=Block of Polonium 210 -tile.Block of r.name=Block of Americium 241 +tile.Block of Americium-241.name=Block of Americium 241 tile.Block of Silicon Carbide.name=Block of Silicon Carbide tile.Silicon Carbide Frame Box.name=Silicon Carbide Frame Box tile.Block of Zirconium Carbide.name=Block of Zirconium Carbide -- cgit From 0410038d093905b77e5cf943afe02291dd4eef0c Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 7 Feb 2019 07:35:18 +0000 Subject: $ More improvements to GT++ Assembly Line handling. $ More safety and logging into Assembly Line ASM. --- .../transformers/ClassTransformer_GT_Client.java | 12 ++++++++- .../xmod/gregtech/common/Meta_GT_Proxy.java | 3 +-- .../gregtech/loaders/misc/AssLineAchievements.java | 31 ++++++++++++++++------ 3 files changed, 35 insertions(+), 11 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java index c5b12eb248..eb33366401 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java @@ -529,7 +529,17 @@ public class ClassTransformer_GT_Client { } catch (Throwable t) { aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); } - aFakeAssLineRecipe.mHidden = !tList.hasAchievementUnlocked(AssLineAchievements.getAchievement(aSafeUnlocalName)); + boolean aHidden = true; + try { + aHidden = tList.hasAchievementUnlocked(AssLineAchievements.getAchievement(aSafeUnlocalName)); + Logger.INFO("Found achievement for "+aSafeUnlocalName); + } + catch (NullPointerException rrr) { + aHidden = true; + //Logger.INFO("Exception handling achievement for "+aSafeUnlocalName); + //rrr.printStackTrace(); + } + aFakeAssLineRecipe.mHidden = !aHidden; } } catch (IllegalArgumentException | IllegalAccessException e) { } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 2549144a2a..055c1aa27d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -95,13 +95,12 @@ public class Meta_GT_Proxy { } public void init() { - mAssemblyAchievements = new AssLineAchievements(); scheduleCoverMapCleaner(); setValidHeatingCoilMetas(); } public void postInit() { - + mAssemblyAchievements = new AssLineAchievements(); } public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java index 368332b64b..d41079f40d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java @@ -4,11 +4,10 @@ import java.util.concurrent.ConcurrentHashMap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.GT_Mod; -import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.common.StaticFields59; @@ -94,7 +93,7 @@ public class AssLineAchievements { aYouDidSomethingInGT = null; } if (recipeCount >= recipeTotal) { - Logger.INFO("Critical mass achieved, releasing toxic Assembly Line recipes into new reservoir. ["+recipeCount+"]"); + Logger.INFO("Critical mass achieved. ["+recipeCount+"]"); registerAchievements(); } @@ -111,7 +110,7 @@ public class AssLineAchievements { achievement.setSpecial(); } achievement.registerStat(); - if (GT_Values.D2) { + if (CORE.DEVENV) { GT_Log.out.println("achievement." + textId + "="); GT_Log.out.println("achievement." + textId + ".desc="); } @@ -123,11 +122,13 @@ public class AssLineAchievements { if (entityplayer == null || !GT_Mod.gregtechproxy.mAchievements) { return; } - entityplayer.triggerAchievement((StatBase) mAchievementMap.get(textId)); + + entityplayer.triggerAchievement((StatBase) getAchievement(textId)); } public static Achievement getAchievement(String textId) { if (mAchievementMap.containsKey(textId)) { + Logger.INFO("Found Achivement: "+textId); return (Achievement) mAchievementMap.get(textId); } return null; @@ -137,21 +138,35 @@ public class AssLineAchievements { public void onItemPickup(EntityItemPickupEvent event) { EntityPlayer player = event.entityPlayer; ItemStack stack = event.item.getEntityItem(); + String aPickupUnlocalSafe = ItemUtils.getUnlocalizedItemName(stack); if (player == null || stack == null) { return; } Logger.INFO("Trying to check for achievements"); // Debug scanner unlocks all AL recipes in creative - if (player.capabilities.isCreativeMode && stack.getUnlocalizedName().equals("gt.metaitem.01.32761")) { + if (player.capabilities.isCreativeMode && aPickupUnlocalSafe.equals("gt.metaitem.01.32761")) { for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); recipe.mHidden = false; } } for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { - if (recipe.getOutput(0).getUnlocalizedName().equals(stack.getUnlocalizedName())) { - issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); + + String aSafeUnlocalName; + if (recipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + continue; + } + ItemStack aStack = recipe.getOutput(0); + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + if (aSafeUnlocalName.equals(aPickupUnlocalSafe)) { + issueAchievement(player, aSafeUnlocalName); recipe.mHidden = false; + Logger.INFO("FOUND: " + aSafeUnlocalName + " | " + aPickupUnlocalSafe); + } + else { + //Logger.INFO(aSafeUnlocalName + " | " + aPickupUnlocalSafe); } } } -- cgit From a7cf24d87bbe776018ffe0c5bb9a8436151ffad6 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 7 Feb 2019 09:09:36 +0000 Subject: $ Backwards compatibility. --- src/Java/gtPlusPlus/core/util/Utils.java | 11 ++++- .../api/metatileentity/BaseCustomTileEntity.java | 3 +- .../custom/power/GTPP_MTE_BasicMachine.java | 20 ++------ ...GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java | 2 +- .../GT_MetaTileEntity_SuperBus_Input.java | 4 +- .../GT_MetaTileEntity_SuperBus_Output.java | 4 +- .../xmod/gregtech/common/StaticFields59.java | 54 +++++++++++++++------- .../GregtechMetaAtmosphericReconditioner.java | 4 +- .../GregtechMetaTileEntityGeneratorArray.java | 5 +- .../gregtech/loaders/misc/AssLineAchievements.java | 9 +++- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 2 +- 11 files changed, 72 insertions(+), 46 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index eef768e799..81e2e94154 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -46,6 +46,7 @@ import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; @@ -791,6 +792,12 @@ public class Utils { if (GT_Mod.VERSION == 509){ Class clazz; try { + + if (LoadedMods.BeyondRealityCore) { + //Safely assume it's Beyond Reality running .28-pre (If it's not, tough shit really?) + return new Pair(9, 28); + } + clazz = (Class) Class.forName("gregtech.GT_Mod"); Field mSubversion = ReflectionUtils.getField(clazz, "SUBVERSION"); if (mSubversion != null){ @@ -802,7 +809,9 @@ public class Utils { } } } - catch (Throwable t){} + catch (Throwable t){ + + } } //5.08.33 else if (GT_Mod.VERSION == 508){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java index 47e4a7ae53..e637365c1e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -12,6 +12,7 @@ import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import ic2.api.Direction; import net.minecraft.item.ItemStack; @@ -88,7 +89,7 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { } } - GT_Pollution.addPollution(this, 100000); + PollutionUtils.addPollution(this, 100000); this.mMetaTileEntity.doExplosion(aAmount); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java index b0dc635aee..19ba932a02 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java @@ -361,17 +361,7 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; - if(!GT_Mod.gregtechproxy.mForceFreeFace) { - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - for(byte i=0;i < 6; i++){ - if(aBaseMetaTileEntity.getAirAtSide(i)){ - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - } - GT_Utility.sendChatToPlayer(aPlayer,"No free Side!"); + aBaseMetaTileEntity.openGUI(aPlayer); return true; } @@ -461,7 +451,8 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } if (mProgresstime > 5) mStuttering = false; XSTR aXSTR = new XSTR(); - if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + //Dumb April Fools Shit + // if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); } else { if (!mStuttering) { stutterProcess(); @@ -726,7 +717,7 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { mAllowInputFromOutputSide = !mAllowInputFromOutputSide; - GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? trans("095","Input from Output Side allowed") : trans("096","Input from Output Side forbidden")); + GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? "Input from Output Side allowed" : "Input from Output Side forbidden"); } } @@ -790,9 +781,6 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); if (tRecipe == null) return DID_NOT_FIND_RECIPE; - if (GT_Mod.gregtechproxy.mLowGravProcessing && tRecipe.mSpecialValue == -100 && - !isValidForLowGravity(tRecipe,getBaseMetaTileEntity().getWorld().provider.dimensionId)) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; if (!canOutput(tRecipe)) { mOutputBlocked++; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java index d5180ef4e1..18665538d0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java @@ -27,7 +27,7 @@ public class GT_MetaTileEntity_BasicMachine_GTPP_Recipe extends GT_MetaTileEntit GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { - super(aName, aTier, aDescription, aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, + super(aName, aTier, aDescription[0], aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, aGUIParameterB, aTextures, aGUIName, aNEIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect); } 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 96df4dbfd0..5e41af86af 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 @@ -28,7 +28,7 @@ public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_In } public GT_MetaTileEntity_SuperBus_Input(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); + super(aName, aTier, aDescription[0], aTextures); } /** @@ -65,7 +65,7 @@ public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_In } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperBus_Input(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + return new GT_MetaTileEntity_SuperBus_Input(this.mName, this.mTier, this.mDescription, this.mTextures); } public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { 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 d09b71ee35..4fac3d36d8 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 @@ -26,7 +26,7 @@ public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_O } public GT_MetaTileEntity_SuperBus_Output(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); + super(aName, aTier, aDescription[0], aTextures); } /** @@ -43,7 +43,7 @@ public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_O } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperBus_Output(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + return new GT_MetaTileEntity_SuperBus_Output(this.mName, this.mTier, this.mDescription, this.mTextures); } public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index 9068bf2ec1..63581af16c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -5,7 +5,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -34,6 +33,7 @@ public class StaticFields59 { public static final Field mDescriptionArray; public static final Field mCasingTexturePages; public static final Field mAssLineVisualMapNEI; + public static final GT_Recipe_Map sAssemblylineVisualRecipes; public static final Method mCalculatePollutionReduction; public static final Method mAddFurnaceRecipe; @@ -44,29 +44,51 @@ public class StaticFields59 { //OrePrefixes static { + Logger.INFO("[SH] Creating Static Helper for various fields which require reflective access."); mGtBlockCasings5 = getField(GregTech_API.class, "sBlockCasings5"); + Logger.INFO("[SH] Got Field: sBlockCasings5"); mPreventableComponents = getField(OrePrefixes.class, "mPreventableComponents"); + Logger.INFO("[SH] Got Field: mPreventableComponents"); mDisabledItems = getField(OrePrefixes.class, "mDisabledItems"); - mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); + Logger.INFO("[SH] Got Field: mDisabledItems"); mDescriptionArray = getField(GT_MetaTileEntity_TieredMachineBlock.class, "mDescriptionArray"); + Logger.INFO("[SH] Got Field: mDescriptionArray"); mCasingTexturePages = getField(BlockIcons.class, "casingTexturePages"); + Logger.INFO("[SH] Got Field: casingTexturePages"); + mAssLineVisualMapNEI = getField(GT_Recipe_Map.class, "sAssemblylineVisualRecipes"); - - mCalculatePollutionReduction = getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", int.class); - - Logger.INFO("Initializing a recipe handler for different versions of Gregtech 5."); - //Yep... - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - Logger.INFO("Selecting GT 5.7/5.8 Recipe Set"); - mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class); + Logger.INFO("[SH] Got Field: mAssLineVisualMapNEI"); + GT_Recipe_Map aTemp; + if (mAssLineVisualMapNEI != null) { + try { + aTemp = (GT_Recipe_Map) mAssLineVisualMapNEI.get(null); + Logger.INFO("[SH] Got Field: sAssemblylineVisualRecipes"); + } catch (IllegalArgumentException | IllegalAccessException e) { + aTemp = null; + } + } else { + aTemp = null; } - else { - Logger.INFO("Selecting GT 5.9 Recipe Set"); - mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class, boolean.class); + + sAssemblylineVisualRecipes = aTemp; + mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); + Logger.INFO("[SH] Got Field: sMultiblockChemicalRecipes"); + + mCalculatePollutionReduction = getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", + int.class); + Logger.INFO("[SH] Got Method: calculatePollutionReduction"); + + // Yep... + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, + ItemStack.class); + Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); + } else { + mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, + ItemStack.class, boolean.class); + Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); } - - - + } public static synchronized final Block getBlockCasings5() { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index eb6a9bfcd3..c364fe5e9e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -229,7 +229,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi //I stole this code reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); Logger.WARNING("reduction[2]:"+reduction); - reduction = GT_Utility.safeInt(((long)reduction/100)*this.mOptimalAirFlow); + reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); Logger.WARNING("reduction[3]:"+reduction); mPollutionReduction = reduction; @@ -683,7 +683,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); - reduction = GT_Utility.safeInt(((long)reduction/100)*this.mOptimalAirFlow); + reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); aTooltipSuper.put("Maximum pollution removed per second: "+reduction); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java index 8446737017..23ca94e54d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java @@ -22,6 +22,7 @@ import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; import gregtech.common.GT_Pollution; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; @@ -401,7 +402,7 @@ public class GregtechMetaTileEntityGeneratorArray extends GregtechMeta_MultiBloc if (this.addOutput(tEmptyContainer1)) { aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); this.depleteInput(a); - GT_Pollution.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); } } } @@ -418,7 +419,7 @@ public class GregtechMetaTileEntityGeneratorArray extends GregtechMeta_MultiBloc (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); if (tFluidAmountToUse > 0L && aBaseMetaTileEntity .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { - GT_Pollution.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); mFluid.amount = (int) ((long) mFluid.amount - tFluidAmountToUse * (long) tEmptyContainer); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java index d41079f40d..4e02dabc5b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java @@ -142,15 +142,20 @@ public class AssLineAchievements { if (player == null || stack == null) { return; } + + if (StaticFields59.sAssemblylineVisualRecipes == null) { + return; + } + Logger.INFO("Trying to check for achievements"); // Debug scanner unlocks all AL recipes in creative if (player.capabilities.isCreativeMode && aPickupUnlocalSafe.equals("gt.metaitem.01.32761")) { - for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { + for (GT_Recipe recipe : StaticFields59.sAssemblylineVisualRecipes.mRecipeList) { issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); recipe.mHidden = false; } } - for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { + for (GT_Recipe recipe : StaticFields59.sAssemblylineVisualRecipes.mRecipeList) { String aSafeUnlocalName; if (recipe.getOutput(0) == null) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index 4be0378699..001edf3ab9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -877,7 +877,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addMultiblockChemicalRecipe(ItemStack[] itemStacks, FluidStack[] fluidStacks, FluidStack[] fluidStacks2, ItemStack[] outputs, int time, int eu) { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || mLargeChemReactor == null) { return false; } try { -- cgit From eac99971c9b4693d4e918038f38e6a9856d87d4e Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Feb 2019 14:11:53 +0000 Subject: - Removed parent achievement from Assembly Line recipes. - Temporarily disabled custom achievement handler. $ Dirty fix for Assembly Line recipe handling. $ Fixed my own achievement handler never setting it's state properly. --- .../ClassTransformer_GT_Achievements_CrashFix.java | 249 +++++++++++++++++++++ .../Preloader_Transformer_Handler.java | 6 +- .../xmod/gregtech/common/Meta_GT_Proxy.java | 2 +- .../gregtech/loaders/misc/AssLineAchievements.java | 3 +- 4 files changed, 255 insertions(+), 5 deletions(-) create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java new file mode 100644 index 0000000000..b9ef955d53 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java @@ -0,0 +1,249 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class ClassTransformer_GT_Achievements_CrashFix { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + private static boolean mDidRemoveAssLineRecipeAdder = false; + + public ClassTransformer_GT_Achievements_CrashFix(byte[] basicClass) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + + aTempReader.accept(new MethodAdaptor(aTempWriter), 0); + + if (mDidRemoveAssLineRecipeAdder) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching GT .09"); + injectMethod(aTempWriter); + } + else { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patch not required, skipping."); + } + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Valid? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "registerAssAchievement" + "."); + + /** + * Inject new, safer code + */ + + + mv = cw.visitMethod(ACC_PUBLIC, "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", null, null); + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable"); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(293, l3); + mv.visitVarInsn(ALOAD, 1); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(295, l5); + mv.visitLdcInsn("Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(294, l6); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(296, l7); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l4); + mv.visitLineNumber(298, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + Label l8 = new Label(); + mv.visitJumpInsn(IFNONNULL, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(300, l9); + mv.visitLdcInsn("Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(299, l10); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(301, l11); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l8); + mv.visitLineNumber(303, l8); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + mv.visitLabel(l0); + mv.visitLineNumber(305, l0); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l1); + mv.visitLineNumber(306, l1); + Label l12 = new Label(); + mv.visitJumpInsn(GOTO, l12); + mv.visitLabel(l2); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", TOP, "net/minecraft/item/ItemStack"}, 1, new Object[] {"java/lang/Throwable"}); + mv.visitVarInsn(ASTORE, 4); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLineNumber(307, l13); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/ItemUtils", "getUnlocalizedItemName", "(Lnet/minecraft/item/ItemStack;)Ljava/lang/String;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l12); + mv.visitLineNumber(311, l12); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", "java/lang/String", "net/minecraft/item/ItemStack"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/loaders/misc/GT_Achievements", "achievementList", "Ljava/util/concurrent/ConcurrentHashMap;"); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/concurrent/ConcurrentHashMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false); + Label l14 = new Label(); + mv.visitJumpInsn(IFNONNULL, l14); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(312, l15); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitFieldInsn(PUTSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + Label l16 = new Label(); + mv.visitLabel(l16); + mv.visitLineNumber(313, l16); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitIntInsn(BIPUSH, 11); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IREM); + mv.visitInsn(IADD); + mv.visitInsn(INEG); + Label l17 = new Label(); + mv.visitLabel(l17); + mv.visitLineNumber(314, l17); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IDIV); + mv.visitIntInsn(BIPUSH, 8); + mv.visitInsn(ISUB); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitLdcInsn("NO_REQUIREMENT"); + mv.visitInsn(ICONST_0); + Label l18 = new Label(); + mv.visitLabel(l18); + mv.visitLineNumber(313, l18); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "registerAchievement", "(Ljava/lang/String;IILnet/minecraft/item/ItemStack;Ljava/lang/String;Z)Lnet/minecraft/stats/Achievement;", false); + mv.visitVarInsn(ASTORE, 4); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(315, l19); + Label l20 = new Label(); + mv.visitJumpInsn(GOTO, l20); + mv.visitLabel(l14); + mv.visitLineNumber(317, l14); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(ACONST_NULL); + mv.visitVarInsn(ASTORE, 4); + mv.visitLabel(l20); + mv.visitLineNumber(319, l20); + mv.visitFrame(F_APPEND,1, new Object[] {"net/minecraft/stats/Achievement"}, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitInsn(ARETURN); + Label l21 = new Label(); + mv.visitLabel(l21); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l3, l21, 0); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l3, l21, 1); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l1, l2, 2); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l12, l21, 2); + mv.visitLocalVariable("aStack", "Lnet/minecraft/item/ItemStack;", null, l0, l21, 3); + mv.visitLocalVariable("t", "Ljava/lang/Throwable;", null, l13, l12, 4); + mv.visitLocalVariable("aYouDidSomethingInGT", "Lnet/minecraft/stats/Achievement;", null, l19, l14, 4); + mv.visitLocalVariable("aYouDidSomethingInGT", "Lnet/minecraft/stats/Achievement;", null, l20, l21, 4); + mv.visitMaxs(7, 5); + mv.visitEnd(); + + + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + + public class MethodAdaptor extends ClassVisitor { + + public MethodAdaptor(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("registerAssAchievement")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Found method " + name + ", removing."); + methodVisitor = null; + mDidRemoveAssLineRecipeAdder = true; + } else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index 7e2e6e72fc..8c8b37eaab 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -125,12 +125,12 @@ public class Preloader_Transformer_Handler implements IClassTransformer { //Try patch achievements if (transformedName.equals("gregtech.loaders.misc.GT_Achievements")) { FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); - return new ClassTransformer_GT_Achievements(basicClass).getWriter().toByteArray(); + return new ClassTransformer_GT_Achievements_CrashFix(basicClass).getWriter().toByteArray(); } - if (transformedName.equals("gregtech.common.GT_Client")) { + /*if (transformedName.equals("gregtech.common.GT_Client")) { FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); return new ClassTransformer_GT_Client(basicClass).getByteArray(); - } + }*/ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 055c1aa27d..0db8e94614 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -100,7 +100,7 @@ public class Meta_GT_Proxy { } public void postInit() { - mAssemblyAchievements = new AssLineAchievements(); + //mAssemblyAchievements = new AssLineAchievements(); } public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java index 4e02dabc5b..351a4cc546 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java @@ -46,7 +46,8 @@ public class AssLineAchievements { recipeTotal = 0; } mAchievementMap = new ConcurrentHashMap(); - mIssuedAchievementMap = new ConcurrentHashMap(); + mIssuedAchievementMap = new ConcurrentHashMap(); + ready = true; } } -- cgit From dc5119af80c7b78a33e495743584750f61692fcc Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Feb 2019 16:36:51 +0000 Subject: + Added lots of custom achievements. --- .../core/handler/AchievementHandler.java | 394 +++++++++++++++++++++ .../xmod/gregtech/common/Meta_GT_Proxy.java | 5 +- 2 files changed, 397 insertions(+), 2 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/handler/AchievementHandler.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java new file mode 100644 index 0000000000..9fcdfa557c --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java @@ -0,0 +1,394 @@ +package gtPlusPlus.core.handler; + +import java.util.concurrent.ConcurrentHashMap; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemSmeltedEvent; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Log; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.StatBase; +import net.minecraftforge.common.AchievementPage; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; + +public class AchievementHandler { + + public ConcurrentHashMap achievementList = new ConcurrentHashMap(); + public ConcurrentHashMap issuedAchievements = new ConcurrentHashMap(); + + public int adjX = 5; + public int adjY = 9; + + private static final String aBaseAchievementName = "gtpp.start"; + + public AchievementHandler() { + + //register first + this.registerAchievement(aBaseAchievementName, 0, 0, GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, Materials.Neutronium, Materials.Osmium, null), "", true); + + //Useful Info + this.registerAchievement("hatch.control", -2, -2, GregtechItemList.Hatch_Control_Core.get(1), aBaseAchievementName, false); + this.registerAchievement("hatch.dynamo.buffered", 2, -2, GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1), aBaseAchievementName, false); + //First multi anyone really needs + this.registerAchievement("multi.abs", -4, -2, GregtechItemList.Industrial_AlloyBlastSmelter.get(1), "hatch.control", true); + + //Material Advancement + this.registerAchievement("dust.potin", 0, 2, ALLOY.POTIN.getDust(1), aBaseAchievementName, false); + this.registerAchievement("dust.eglin", 0, 4, ALLOY.EGLIN_STEEL.getDust(1), "dust.potin", false); + this.registerAchievement("dust.staballoy", 0, 6, ALLOY.STABALLOY.getDust(1), "dust.eglin", false); + this.registerAchievement("dust.quantum", 0, 8, ALLOY.QUANTUM.getDust(1), "dust.staballoy", true); + this.registerAchievement("dust.hypogen", 0, 10, ELEMENT.STANDALONE.HYPOGEN.getDust(1), "dust.quantum", true); + + + //Blocks + this.registerAchievement("block.fishtrap", -2, 2, ItemUtils.getSimpleStack(ModBlocks.blockFishTrap), "dust.potin", false); + this.registerAchievement("block.withercage", -2, 4, ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard), "dust.eglin", false); + + + //Machines (-10/-8/-6) + this.registerAchievement("rtg", -16, -10, GregtechItemList.RTG.get(1), aBaseAchievementName, false); + this.registerAchievement("dehydrate", -15, -10, GregtechItemList.GT_Dehydrator_HV.get(1), aBaseAchievementName, false); + this.registerAchievement("semifluid", -14, -10, GregtechItemList.Generator_SemiFluid_HV.get(1), aBaseAchievementName, false); + this.registerAchievement("earlywasher", -13, -10, GregtechItemList.SimpleDustWasher.get(1), aBaseAchievementName, false); + this.registerAchievement("advancedsteam", -12, -10, GregtechItemList.Boiler_Advanced_MV.get(1), aBaseAchievementName, false); + this.registerAchievement("pollutionremoval", -11, -10, GregtechItemList.Pollution_Cleaner_IV.get(1), aBaseAchievementName, false); + this.registerAchievement("hiampxform", -10, -10, GregtechItemList.Transformer_HA_HV_MV.get(1), aBaseAchievementName, false); + + + //Multis (-4/-2/0) + this.registerAchievement("multi.pss", -16, -7, GregtechItemList.PowerSubStation.get(1), "multi.abs", false); + this.registerAchievement("multi.cyclo", -15, -7, GregtechItemList.COMET_Cyclotron.get(1), "multi.abs", false); + this.registerAchievement("multi.sifter", -14, -7, GregtechItemList.Industrial_Sifter.get(1), "dust.eglin", false); + this.registerAchievement("multi.cokeoven", -13, -7, GregtechItemList.Industrial_CokeOven.get(1), "multi.abs", false); + this.registerAchievement("multi.boiler.thermal", -12, -7, GregtechItemList.GT4_Thermal_Boiler.get(1), "multi.abs", false); + this.registerAchievement("multi.zhuhai", -11, -7, GregtechItemList.Industrial_FishingPond.get(1), aBaseAchievementName, false); + //this.registerAchievement("rtg", -4, -4, GregtechItemList.RTG.get(1), aBaseAchievementName, false); + + //Casings + this.registerAchievement("casing.abs", 2, -10, GregtechItemList.Casing_Coil_BlastSmelter.get(1), aBaseAchievementName, false); + this.registerAchievement("casing.cyclotron.coil", 3, -10, GregtechItemList.Casing_Cyclotron_Coil.get(1), aBaseAchievementName, false); + this.registerAchievement("casing.multiuse", 4, -10, GregtechItemList.Casing_Multi_Use.get(1), aBaseAchievementName, false); + this.registerAchievement("casing.containment", 5, -10, GregtechItemList.Casing_Containment.get(1), aBaseAchievementName, false); + + + + + + + + + //Radioactive + this.registerAchievement("decay.neptunium238", 11, 8, ItemUtils.getSimpleStack(ModItems.dustNeptunium238), "multi.cyclo", false); + this.registerAchievement("decay.radium226", 12, 8, ItemUtils.getSimpleStack(ModItems.dustRadium226), "multi.cyclo", false); + this.registerAchievement("decay.molybdenum99", 13, 8, ItemUtils.getSimpleStack(ModItems.dustMolybdenum99), "multi.cyclo", false); + this.registerAchievement("decay.technetium99m", 14, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99M), "multi.cyclo", true); + this.registerAchievement("decay.technetium99", 15, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99), "multi.cyclo", true); + + + + + + + + + + + + + AchievementPage.registerAchievementPage( + new AchievementPage("GT++", (Achievement[]) ((Achievement[]) this.achievementList.values() + .toArray(new Achievement[this.achievementList.size()])))); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + + + } + + public Achievement registerAchievement(String textId, int x, int y, ItemStack icon, Achievement requirement, + boolean special) { + Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, requirement); + if (special) { + achievement.setSpecial(); + } + + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + + this.achievementList.put(textId, achievement); + return achievement; + } + + public Achievement registerAchievement(String textId, int x, int y, ItemStack icon, String requirement, + boolean special) { + Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, + this.getAchievement(requirement)); + if (special) { + achievement.setSpecial(); + } + + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + + this.achievementList.put(textId, achievement); + return achievement; + } + + public void issueAchievement(EntityPlayer entityplayer, String textId) { + if (entityplayer != null) { + entityplayer.triggerAchievement((StatBase) this.achievementList.get(textId)); + } + } + + public Achievement getAchievement(String textId) { + return this.achievementList.containsKey(textId) ? (Achievement) this.achievementList.get(textId) : null; + } + + + /** + * A generic handler that will give an achievement for an item. + * Useful to only write this once, then call it from all handlers. + * @param aStack - The Itemstack to check for achievements. + * @param aPlayer - The player to unlock for. + */ + private void handleAchivement(ItemStack aStack, EntityPlayer aPlayer) { + + if (aPlayer != null && aStack != null) { + /* + * Copy this to all events because I am lazy - Alk 2019 + */ + + //Safe name + String aUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + + + boolean isValid = false; + //Check if valid name // mod + if (ItemUtils.getModId(aStack).equals(CORE.MODID) || ItemUtils.getModId(aStack).equalsIgnoreCase("gregtech")) { + isValid = true; + } + if (!isValid) { + return; + } + + //Should unlock base achievement from *ANY* GT++ item. (Too lazy to special case GT machineBlocks though) + if (ItemUtils.getModId(aStack).equals(CORE.MODID)) { + this.issueAchievement(aPlayer, aBaseAchievementName); + } + + + /** + * Misc Blocks + */ + + if (aUnlocalName.equalsIgnoreCase("blockFishTrap")) { + this.issueAchievement(aPlayer, "block.fishtrap"); + } + if (aUnlocalName.equalsIgnoreCase("blockBlackGate")) { + this.issueAchievement(aPlayer, "block.withercage"); + } + + + /** + * Decayables + */ + if (aUnlocalName.equalsIgnoreCase("dustNeptunium238")) { + this.issueAchievement(aPlayer, "decay.neptunium238"); + } + else if (aUnlocalName.equalsIgnoreCase("dustRadium226")) { + this.issueAchievement(aPlayer, "decay.radium226"); + } + else if (aUnlocalName.equalsIgnoreCase("dustMolybdenum99")) { + this.issueAchievement(aPlayer, "decay.molybdenum99"); + } + else if (aUnlocalName.equalsIgnoreCase("dustTechnetium99M")) { + this.issueAchievement(aPlayer, "decay.technetium99m"); + } + else if (aUnlocalName.equalsIgnoreCase("dustTechnetium99")) { + this.issueAchievement(aPlayer, "decay.technetium99"); + } + + /** + * Random Materials worthy of Achievements + */ + else if (aUnlocalName.equalsIgnoreCase("itemDustPotin")) { + this.issueAchievement(aPlayer, "dust.potin"); + } + else if (aUnlocalName.equalsIgnoreCase("itemDustEglinSteel")) { + this.issueAchievement(aPlayer, "dust.eglin"); + } + else if (aUnlocalName.equalsIgnoreCase("itemDustStaballoy")) { + this.issueAchievement(aPlayer, "dust.staballoy"); + } + else if (aUnlocalName.equalsIgnoreCase("itemDustQuantum")) { + this.issueAchievement(aPlayer, "dust.quantum"); + } + else if (aUnlocalName.equalsIgnoreCase("itemDustHypogen")) { + this.issueAchievement(aPlayer, "dust.hypogen"); + } + + + + /** + * Machines + */ + + else if (aUnlocalName.startsWith("gt.blockmachines.")) { + + //Readability + String aStartsWith = "gt.blockmachines."; + + /** + * Single Blocks + */ + + //RTG + if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.rtg")) { + this.issueAchievement(aPlayer, "rtg"); + } + //Dehydrator + else if (aUnlocalName.startsWith(aStartsWith + "machine.dehydrator.tier.")) { + this.issueAchievement(aPlayer, "dehydrate"); + } + //SemiFluids + else if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.semifluid.tier.")) { + this.issueAchievement(aPlayer, "semifluid"); + } + //Simple Washer + else if (aUnlocalName.startsWith(aStartsWith + "simplewasher.01.tier.")) { + this.issueAchievement(aPlayer, "earlywasher"); + } + //Advanced Boilers + else if (aUnlocalName.startsWith(aStartsWith + "electricboiler.")) { + this.issueAchievement(aPlayer, "advancedsteam"); + } + //Scrubers + else if (aUnlocalName.startsWith(aStartsWith + "pollutioncleaner.01.tier.")) { + this.issueAchievement(aPlayer, "pollutionremoval"); + } + //High-amp xformers + else if (aUnlocalName.startsWith(aStartsWith + "transformer.ha.tier.")) { + this.issueAchievement(aPlayer, "hiampxform"); + } + //Buffered Dynamos + else if (aUnlocalName.startsWith(aStartsWith + "hatch.dynamo.buffer.tier.")) { + this.issueAchievement(aPlayer, "hatch.dynamo.buffered"); + } + //Control Core Hatch + else if (aUnlocalName.startsWith(aStartsWith + "hatch.control.adv")) { + this.issueAchievement(aPlayer, "hatch.control"); + } + + + + /** + * Multis + */ + + //ABS + else if (aUnlocalName.equals(aStartsWith + "industrialsalloyamelter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.abs"); + } + //PSS + else if (aUnlocalName.equals(aStartsWith + "substation.01.input.single")) { + this.issueAchievement(aPlayer, "multi.pss"); + } + //Cyclotron + else if (aUnlocalName.startsWith(aStartsWith + "cyclotron.tier.single")) { + this.issueAchievement(aPlayer, "multi.cyclo"); + } + //Sifter + else if (aUnlocalName.equals(aStartsWith + "industrialsifter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.sifter"); + } + //Coke Oven + else if (aUnlocalName.equals(aStartsWith + "industrialcokeoven.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.cokeoven"); + } + //Thermal Boiler + else if (aUnlocalName.equals(aStartsWith + "gtplusplus.thermal.boiler")) { + this.issueAchievement(aPlayer, "multi.boiler.thermal"); + } + //Zhuhai + else if (aUnlocalName.equals(aStartsWith + "industrial.fishpond.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.zhuhai"); + } + + } + + /** + * Casings + */ + + else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.14")) { + this.issueAchievement(aPlayer, "casing.abs"); + } + + else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.2.9")) { + this.issueAchievement(aPlayer, "casing.cyclotron.coil"); + } + + else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.3.2")) { + this.issueAchievement(aPlayer, "casing.multiuse"); + } + else if (aUnlocalName.equalsIgnoreCase("gtplusplus.blockcasings.3.15")) { + this.issueAchievement(aPlayer, "casing.containment"); + } + } + } + + + + + /* + * Handle achievements for all vanilla types of obtianment. + */ + + + + @SubscribeEvent + public void onCrafting(ItemCraftedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.crafting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onSmelting(ItemSmeltedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.smelting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onItemPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack stack = event.item.getEntityItem(); + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 0db8e94614..5eee77e065 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -28,6 +28,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.ObjMap; import gtPlusPlus.api.objects.minecraft.FormattedTooltipString; +import gtPlusPlus.core.handler.AchievementHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ProxyFinder; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -60,7 +61,7 @@ public class Meta_GT_Proxy { private static Class sBaseMetaTileEntityClass; private static Class sBaseMetaTileEntityClass2; - public static AssLineAchievements mAssemblyAchievements; + public static AchievementHandler mAssemblyAchievements; public static final Map mCustomGregtechMetaTooltips = new LinkedHashMap(); @@ -100,7 +101,7 @@ public class Meta_GT_Proxy { } public void postInit() { - //mAssemblyAchievements = new AssLineAchievements(); + mAssemblyAchievements = new AchievementHandler(); } public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { -- cgit From fbe73a2de925d012dddfa46b13e745028ce40679 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Feb 2019 18:50:58 +0000 Subject: + Added Tags to tooltips, which can be used to control base tooltips inherited from parents. % Mild update to tooltips of a few multis. % Adjusted Large Arc Furnace casing texture. % Renamed the 3 Factory Grade multis. --- src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 47 ++++++++++++-- .../base/GregtechMeta_MultiBlockBase.java | 75 +++++++++++++++++----- .../common/blocks/GregtechMetaCasingBlocks4.java | 4 +- .../machines/multi/misc/GMTE_AmazonPackager.java | 10 ++- ...regtechMetaTileEntity_IndustrialArcFurnace.java | 18 +++--- ...techMetaTileEntity_IndustrialVacuumFreezer.java | 26 ++++---- .../advanced/GregtechMetaTileEntity_Adv_EBF.java | 23 +++---- .../GregtechMetaTileEntity_Adv_Implosion.java | 15 ++--- .../GregtechIndustrialCryogenicFreezer.java | 8 +-- 9 files changed, 146 insertions(+), 80 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index ca231dbd63..d5e016bbf8 100644 --- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -47,6 +47,10 @@ public class AutoMap implements Iterable, Cloneable, Serializable { return set(object); } + public synchronized V add(V object){ + return set(object); + } + public synchronized V set(V object){ if (object == null) { return null; @@ -90,15 +94,19 @@ public class AutoMap implements Iterable, Cloneable, Serializable { return true; } + private final Class getMapType() { + Class g = mInternalMap.get(0).getClass(); + return g; + } + public synchronized V[] toArray() { - Collection col = this.mInternalMap.values(); - V[] val = (V[]) new Object[col.size()]; - int counter = 0; - for (V i : col) { - val[counter] = i; - counter++; + /*Collection col = this.mInternalMap.values(); + List abcList = new ArrayList(); + for (V g : col) { + abcList.add(g); } - return val; + return (V[]) abcList.toArray();*/ + return (V[]) new AutoArray(this).getGenericArray(); } public synchronized final int getInternalID() { @@ -106,10 +114,35 @@ public class AutoMap implements Iterable, Cloneable, Serializable { } public synchronized final boolean remove(V value) { + value.getClass(); if (this.mInternalMap.containsValue(value)) { return this.mInternalMap.remove(mInternalNameMap.get(""+value.hashCode()), value); } return false; } + + private class AutoArray { + + private final V[] arr; + public final int length; + + public AutoArray(AutoMap aMap) { + this.arr = (V[]) java.lang.reflect.Array.newInstance(aMap.getMapType(), aMap.size()); + this.length = aMap.size(); + } + private V get(int i) { + return arr[i]; + } + private void set(int i, V e) { + arr[i] = e; + } + protected V[] getGenericArray() { + return arr; + } + @Override + public String toString() { + return Arrays.toString(arr); + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 04c1cf34cc..2427815295 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -39,6 +39,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; @@ -265,6 +266,10 @@ GT_MetaTileEntity_MultiBlockBase { private final String aRequiresCoreModule = "1x Core Module"; private final String aRequiresMaint = "1x Maintanence Hatch";*/ + public final static String TAG_HIDE_HATCHES = "TAG_HIDE_HATCHES"; + public final static String TAG_HIDE_POLLUTION = "TAG_HIDE_POLLUTION"; + public final static String TAG_HIDE_MACHINE_TYPE = "TAG_HIDE_MACHINE_TYPE"; + @Override public final String[] getDescription() { /*if (aCachedToolTip != null) { @@ -287,22 +292,62 @@ GT_MetaTileEntity_MultiBlockBase { String aRequiresCoreModule = "1x Core Module"; String aRequiresMaint = "1x Maintanence Hatch"; - String[] x = getTooltip(); - //Add Stock Tooltip to bottom of list - String[] z; - if (getPollutionPerTick(null) > 0) { - z = new String[] { - aRequiresMaint, - aRequiresCoreModule, - aRequiresMuffler, - getPollutionTooltip(), - getMachineTooltip()}; + String[] x = getTooltip(); + + //Filter List, toggle switches, rebuild map without flags + boolean showHatches = true; + boolean showMachineType = true; + boolean showPollution = getPollutionPerTick(null) > 0; + AutoMap aTempMap = new AutoMap(); + for (int ee = 0; ee < x.length; ee++) { + String hh = x[ee]; + if (hh.equals(TAG_HIDE_HATCHES)) { + showHatches = false; + } + else if (hh.equals(TAG_HIDE_POLLUTION)) { + showPollution = false; + } + else if (hh.equals(TAG_HIDE_MACHINE_TYPE)) { + showMachineType = false; + } + else { + aTempMap.put(x[ee]); + } } - else { - z = new String[] { - aRequiresMaint, - aRequiresCoreModule, - getMachineTooltip(),}; + //Rebuild + x = new String[aTempMap.size()]; + for (int ee = 0; ee < x.length; ee++) { + x[ee] = aTempMap.get(ee); + } + + + //Assemble ordered map for misc tooltips + AutoMap aOrderedMap = new AutoMap(); + if (showHatches) { + aOrderedMap.put(aRequiresMaint); + aOrderedMap.put(aRequiresCoreModule); + if (showPollution) { + aOrderedMap.put(aRequiresMuffler); + } + } + + if (showMachineType) { + aOrderedMap.put(getMachineTooltip()); + } + + if (showPollution) { + aOrderedMap.put(getPollutionTooltip()); + } + + + + + + //Add Stock Tooltip to bottom of list + String[] z; + z = new String[aOrderedMap.size()]; + for (int ee = 0; ee < z.length; ee++) { + z[ee] = aOrderedMap.get(ee); } int a2, a3; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java index b3366df96b..54323d8c2e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java @@ -86,8 +86,8 @@ extends GregtechMetaCasingBlocksAbstract { case 2: return TexturesGtBlock.TEXTURE_ORGANIC_PANEL_A_GLOWING.getIcon(); //Coke Oven Casing Tier 2 - case 3: - return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + case 3: + return TexturesGtBlock.TEXTURE_METAL_PANEL_A.getIcon(); //Material Press Casings case 4: return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java index 6515589905..eca02d290e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java @@ -70,13 +70,11 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { "Only uses 75% of the eu/t normally required", "Processes five items per voltage tier", "Size: 3x3x3 (Hollow)", + "Supply Depot. Casings (10 at least!)", "Controller (front centered)", - "1x Input Bus (anywhere)", - "1x Output Bus (anywhere)", - "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", - "1x Muffler (anywhere)", - "Supply Depot. Casings for the rest (10 at least!)" + "1x Input Bus", + "1x Output Bus", + "1x Energy Hatch", }; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java index d90b88e4d8..c549cf9216 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java @@ -65,15 +65,13 @@ extends GregtechMeta_MultiBlockBase { "Size: nx3xn [WxHxL] (Hollow)", "n can be 3, 5 or 7", "Max Size required to process Plasma recipes", + mCasingName+"s (10 at least!)", "Controller (top centered)", - "1x Input Bus (anywhere)", - "1x Output Bus (anywhere)", - "1x Input Hatch (anywhere)", - "1x Output Hatch (anywhere)", - "1x Energy Hatch (anywhere)", - "1x Muffler Hatch (anywhere)", - "1x Maintenance Hatch (Back Center)", - mCasingName+"s for the rest", + "1x Input Bus", + "1x Output Bus", + "1x Input Hatch", + "1x Output Hatch", + "1x Energy Hatch", }; } @@ -85,10 +83,10 @@ extends GregtechMeta_MultiBlockBase { @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { if (aSide == 0 || aSide == 1) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.getIndexFromPage(2, 1)], + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[mCasingTextureID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.getIndexFromPage(2, 1)]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[mCasingTextureID]}; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java index 7472b71a95..064dc8372b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; import static gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes; import static gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes_GT; +import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; @@ -28,6 +29,7 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta public static int CASING_TEXTURE_ID; public static String mCryoFuelName = "Gelid Cryotheum"; public static String mCasingName = "Advanced Cryogenic Casing"; + public static String mHatchName = "Cryotheum Hatch"; public static FluidStack mFuelStack; public GregtechMetaTileEntity_IndustrialVacuumFreezer(final int aID, final String aName, final String aNameRegional) { @@ -36,6 +38,7 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); mCryoFuelName = mFuelStack.getLocalizedName(); mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 10); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); } public GregtechMetaTileEntity_IndustrialVacuumFreezer(final String aName) { @@ -44,6 +47,7 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); mCryoFuelName = mFuelStack.getLocalizedName(); mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 10); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); } public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { @@ -63,21 +67,19 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta if (mCryoFuelName.toLowerCase().contains(".")) { mCryoFuelName = FluidUtils.getFluidStack("cryotheum", 1).getLocalizedName(); } + if (mHatchName.toLowerCase().contains(".name")) { + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); + } return new String[]{ - "Controller Block for the Advanced Cryogenic Freezer", - "Super cools hot ingots and cells", - "Processes four Vacuum Freezer Recipes at 200% speed", + "Factory Grade Advanced Vacuum Freezer", + "Speed: 200% | Eu Usage: 100% | Parallel: 4", "Consumes 1L of "+mCryoFuelName+"/t during operation", - "Size(WxHxD): 3x3x3 (Hollow)", - mCasingName+"s for the rest (10 at least!)", - "Controller (Front centered)", - "1x Input Bus", - "1x Output Bus", - "1x Input Hatch", - "1x Output Hatch (optional)", - "1x Energy Hatch", - }; + "Constructed exactly the same as a normal Vacuum Freezer", + "Use "+mCasingName+"s (10 at least!)", + "1x " + mHatchName + " (Required)", + "TAG_HIDE_HATCHES" + }; } public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index e4f984ee18..f10350eaee 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -103,21 +103,14 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 968); } - return new String[] { "Controller Block for the Advanced Electric Blast Furnace", - "120% faster than using an equal tier EBF", "Only uses 90% of the eu/t normally required", - "Processes upto 8 recipes at once", - "Consumes 10L of " + mHotFuelName + "/s during operation", - "Each 900K over the min. Heat Capacity grants 5% speedup (multiplicatively)", - "Each 1800K over the min. Heat Capacity allows for one upgraded overclock", - "Upgraded overclocks reduce recipe time to 25% and increase EU/t to 400%", - "Size(WxHxD): 3x4x3 (Hollow), Controller (Front middle bottom)", - "16x Heating Coils (Two middle Layers, hollow)", - "1x " + mHatchName, - "1x Input Hatch/Bus", - "1x Output Hatch/Bus (Bottom Layer)", - "1x Output Hatch to recover CO2/CO/SO2 (optional, any top layer casing),", - " Recovery scales with Muffler Hatch tier", mCasingName + "s for the rest", - "1x Energy Hatch", + return new String[] { + "Factory Grade Advanced Blast Furnace", + "Speed: 120% | Eu Usage: 90% | Parallel: 8", + "Consumes 10L of " + mHotFuelName + " per second during operation", + "Constructed exactly the same as a normal EBF", + "Use "+mCasingName+"s (10 at least!)", + "1x " + mHatchName + " (Required)", + "TAG_HIDE_HATCHES" }; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java index 8abf506e55..7dfdbf75d6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java @@ -47,15 +47,12 @@ extends GregtechMeta_MultiBlockBase { if (mCasingName.contains("gt.blockcasings")) { mCasingName = ItemList.Casing_RobustTungstenSteel.get(1).getDisplayName(); } - return new String[]{ - "Controller Block for the Advanced Implosion Compressor", - "Processes upto ((Tier/2)+1) recipes at once", - "Size(WxHxD): 3x3x3 (Hollow)", - mCasingName+"s (10 at least!)", - "Controller (Front centered)", - "1x Input Bus", - "1x Output Bus", - "1x Energy Hatch", + return new String[]{ + "Factory Grade Advanced Implosion Compressor", + "Speed: 100% | Eu Usage: 100% | Parallel: ((Tier/2)+1)", + "Constructed exactly the same as a normal Implosion Compressor", + "Use "+mCasingName+"s (10 at least!)", + "TAG_HIDE_HATCHES" }; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCryogenicFreezer.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCryogenicFreezer.java index 213b6f0ccb..65f3e41911 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCryogenicFreezer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCryogenicFreezer.java @@ -17,10 +17,10 @@ public class GregtechIndustrialCryogenicFreezer { private static void run1() { Logger.INFO("Gregtech 5 Content | Registering Advanced GT Multiblock replacements."); - GregtechItemList.Machine_Adv_BlastFurnace.set(new GregtechMetaTileEntity_Adv_EBF(963, "multimachine.adv.blastfurnace", "[Factory Grade] Adv. EBF").getStackForm(1L)); - GregtechItemList.Machine_Adv_ImplosionCompressor.set(new GregtechMetaTileEntity_Adv_Implosion(964, "multimachine.adv.implosioncompressor", "[Factory Grade] Adv. Implosion Compressor").getStackForm(1L)); - GregtechItemList.Industrial_Cryogenic_Freezer.set(new GregtechMetaTileEntity_IndustrialVacuumFreezer(910, "multimachine.adv.industrialfreezer", "[Factory Grade] Cryogenic Freezer").getStackForm(1L)); - GregtechItemList.FusionComputer_UV2.set(new GregtechMetaTileEntity_Adv_Fusion_MK4(965, "fusioncomputer.tier.09", "FusionTek MK IV").getStackForm(1L)); + GregtechItemList.Machine_Adv_BlastFurnace.set(new GregtechMetaTileEntity_Adv_EBF(963, "multimachine.adv.blastfurnace", "Volcanus").getStackForm(1L)); + GregtechItemList.Machine_Adv_ImplosionCompressor.set(new GregtechMetaTileEntity_Adv_Implosion(964, "multimachine.adv.implosioncompressor", "Density^2").getStackForm(1L)); + GregtechItemList.Industrial_Cryogenic_Freezer.set(new GregtechMetaTileEntity_IndustrialVacuumFreezer(910, "multimachine.adv.industrialfreezer", "Cryogenic Freezer").getStackForm(1L)); + GregtechItemList.FusionComputer_UV2.set(new GregtechMetaTileEntity_Adv_Fusion_MK4(965, "fusioncomputer.tier.09", "FusionTech MK IV").getStackForm(1L)); } } -- cgit From 1f48c6da89afb649c3b73674cb3c0664fa322a09 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Feb 2019 20:03:07 +0000 Subject: + Added recipes for the Large Arc Furnace and Casings. - Disabled power output on Alternative Fusion. % Made the AutoMap implement Collection and Queue. $ Fixed energy buffers return bad inventory name. --- src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 139 +++++++++++++++------ .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 50 ++++++-- src/Java/gtPlusPlus/core/recipe/common/CI.java | 35 +++++- src/Java/gtPlusPlus/core/util/math/MathUtils.java | 11 ++ .../production/GregtechMTE_MiniFusionPlant.java | 7 +- .../storage/GregtechMetaEnergyBuffer.java | 3 +- .../gregtech/GregtechEnergyBuffer.java | 22 ++-- 7 files changed, 204 insertions(+), 63 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index d5e016bbf8..4663229514 100644 --- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -3,7 +3,7 @@ package gtPlusPlus.api.objects.data; import java.io.Serializable; import java.util.*; -public class AutoMap implements Iterable, Cloneable, Serializable { +public class AutoMap implements Iterable, Cloneable, Serializable, Collection, Queue { /** * The Internal Map @@ -47,8 +47,8 @@ public class AutoMap implements Iterable, Cloneable, Serializable { return set(object); } - public synchronized V add(V object){ - return set(object); + public synchronized boolean add(V object){ + return set(object) != null; } public synchronized V set(V object){ @@ -87,62 +87,129 @@ public class AutoMap implements Iterable, Cloneable, Serializable { return mInternalMap.isEmpty(); } - public synchronized boolean clear(){ + public synchronized void clear(){ this.mInternalID = 0; this.mInternalMap.clear(); this.mInternalNameMap.clear(); - return true; - } - - private final Class getMapType() { - Class g = mInternalMap.get(0).getClass(); - return g; + return; } + @SuppressWarnings("unchecked") public synchronized V[] toArray() { - /*Collection col = this.mInternalMap.values(); + Collection col = this.mInternalMap.values(); List abcList = new ArrayList(); for (V g : col) { abcList.add(g); } - return (V[]) abcList.toArray();*/ - return (V[]) new AutoArray(this).getGenericArray(); + return (V[]) abcList.toArray(); + //return (V[]) new AutoArray(this).getGenericArray(); } public synchronized final int getInternalID() { return mInternalID; - } + } - public synchronized final boolean remove(V value) { + public synchronized final boolean remove(Object value) { value.getClass(); if (this.mInternalMap.containsValue(value)) { return this.mInternalMap.remove(mInternalNameMap.get(""+value.hashCode()), value); } return false; - } - - private class AutoArray { - - private final V[] arr; - public final int length; - - public AutoArray(AutoMap aMap) { - this.arr = (V[]) java.lang.reflect.Array.newInstance(aMap.getMapType(), aMap.size()); - this.length = aMap.size(); - } - private V get(int i) { - return arr[i]; - } - private void set(int i, V e) { - arr[i] = e; + } + + @Override + public boolean contains(Object o) { + for (V g : this.mInternalMap.values()) { + if (g.equals(o)) { + return true; + } } - protected V[] getGenericArray() { - return arr; + return false; + } + + @SuppressWarnings("unchecked") + @Override + public V[] toArray(V[] a) { + return (V[]) toArray(); + } + + @Override + public boolean containsAll(Collection c) { + boolean aTrue = true; + for (Object g : c) { + if (!this.contains(g)) { + aTrue = false; + } + } + return aTrue; + } + + @Override + public boolean addAll(Collection c) { + boolean aTrue = true; + for (V g : c) { + if (!this.add(g)) { + aTrue = false; + } + } + return aTrue; + } + + @Override + public boolean removeAll(Collection c) { + boolean aTrue = true; + for (Object g : c) { + if (!this.remove(g)) { + aTrue = false; + } + } + return aTrue; + } + + @Override + public boolean retainAll(Collection c) { + AutoMap aTempAllocation = new AutoMap(); + boolean aTrue = false; + aTempAllocation = this; + aTempAllocation.removeAll(c); + aTrue = this.removeAll(aTempAllocation); + aTempAllocation.clear(); + return aTrue; + } + + @Override + public boolean offer(V e) { + return add(e); + } + + @Override + public V remove() { + V y = this.get(0); + if (remove(y)) + return y; + else + return null; + } + + @Override + public V poll() { + if (this.mInternalMap.isEmpty()) { + return null; } - @Override - public String toString() { - return Arrays.toString(arr); + return remove(); + } + + @Override + public V element() { + if (this.mInternalMap.isEmpty()) { + return null; } + return this.get(0); + } + + @Override + public V peek() { + return element(); } } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index e7577071c6..a7c0655f89 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -207,10 +207,20 @@ public class RECIPES_Machines { } private static void run(){ + + //Determines Casing Recipe Output + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !GTNH){ + Casing_Amount=2; + } + else { + Casing_Amount=1; + } + initModItems(); controlCores(); energyCores(); wirelessChargers(); + largeArcFurnace(); } private static void initModItems(){ @@ -276,15 +286,7 @@ public class RECIPES_Machines { private static void runModRecipes(){ if (LoadedMods.Gregtech){ - //Determines Casing Recipe Output - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !GTNH){ - Casing_Amount=2; - } - else { - Casing_Amount=1; - } - - + //Computer Cube CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1898,4 +1900,34 @@ public class RECIPES_Machines { } } + + private static void largeArcFurnace() { + int aCostMultiplier = GTNH ? 2 : 1; + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getTieredMachineHull(-1, 1 * aCostMultiplier), + CI.getEmitter(2, 2 * aCostMultiplier), + CI.getElectricPiston(4, 2 * aCostMultiplier), + CI.getSensor(4, 1 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.plate, 5, 4 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.pipeSmall, 4, 1 * aCostMultiplier), + }, + CI.getAlternativeTieredFluid(5, (144 * 2 * 4)), //Input Fluid + GregtechItemList.Casing_Industrial_Arc_Furnace.get(Casing_Amount), + 20 * 10 * 1 * (6), + MaterialUtils.getVoltageForTier(5)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + GregtechItemList.Casing_Industrial_Arc_Furnace.get(Casing_Amount), + CI.getFieldGenerator(4, 2 * aCostMultiplier), + CI.getRobotArm(5, 4 * aCostMultiplier), + CI.getEnergyCore(4, 2 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.plate, 6, 8 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.circuit, 5, 8 * aCostMultiplier), + }, + CI.getAlternativeTieredFluid(6, (144 * 4 * 5)), //Input Fluid + GregtechItemList.Industrial_Arc_Furnace.get(1), + 60 * 20 * 8, + MaterialUtils.getVoltageForTier(6)); + } } diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index b473b30c3c..28fa12ac1a 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -13,6 +13,7 @@ import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.recipe.LOADER_Machine_Components; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.eio.material.MaterialEIO; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -628,6 +629,38 @@ public class CI { return a; } + public static ItemStack getEnergyCore(int aTier, int aAmount) { + ItemStack[] aOutput = new ItemStack[] { + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"1", 1), + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"2", 1), + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"3", 1), + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"4", 1), + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"5", 1), + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"6", 1), + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"7", 1), + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"8", 1), + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"9", 1), + ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"10", 1) + }; + return ItemUtils.getSimpleStack(aOutput[MathUtils.balance(aTier, 0, 9)], aAmount); + } + + public static ItemStack getPlate(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.plate, aTier, aAmount); + } + + public static ItemStack getGear(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.gearGt, aTier, aAmount); + } + + public static ItemStack getIngot(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.ingot, aTier, aAmount); + } + + public static ItemStack getBolt(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.bolt, aTier, aAmount); + } + public static ItemStack getTieredComponent(OrePrefixes aPrefix, int aTier, int aAmount) { aTier = Math.max(0, aTier); @@ -1144,7 +1177,7 @@ public class CI { aType = CI.machineHull_MAX; } else { - aType = CI.machineHull_LV; + aType = GregtechItemList.Casing_Multi_Use.get(1, CI.machineHull_MV); } return ItemUtils.getSimpleStack(aType, aSize); } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 40ac23a1b8..030099cff1 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -681,4 +681,15 @@ public class MathUtils { return i; } + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - An Integer which will be between the bounds, or a boundary value. + */ + public static int balance(int aInput, int aMin, int aMax) { + return Math.max(Math.min(aInput, aMax), aMin); + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java index 6ec95ff16b..8925caf480 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java @@ -130,19 +130,18 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { //"Input voltage can be changed within the GUI", "Place Input/Output Hatches on sides and bottom", "Power can only be inserted into the back", - "Power can only be extracted from the top", + //e"Power can only be extracted from the top", + TAG_HIDE_HATCHES }; } @Override public int getMaxParallelRecipes() { - // TODO Auto-generated method stub return 1; } @Override public int getEuDiscountForParallelism() { - // TODO Auto-generated method stub return 0; } @@ -317,7 +316,7 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { @Override public boolean isEnetOutput() { - return true; + return false; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java index 1d2fad941b..b77529220f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java @@ -294,7 +294,6 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { cur = String.format(fmt, cur); return new String[] { - this.getLocalName(), cur+" EU stored", max+" EU capacity"}; } @@ -345,7 +344,7 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { @Override public String getInventoryName() { - return null; + return super.getInventoryName(); } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java index 7b87cd0f24..e07837c2ba 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java @@ -41,20 +41,20 @@ public class GregtechEnergyBuffer //Energy Buffers - GregtechItemList.Energy_Buffer_1by1_ULV.set(new GregtechMetaEnergyBuffer(770, "energybuffer.01.tier.00", "Ultra Low Voltage Energy Buffer", 0, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_LV.set(new GregtechMetaEnergyBuffer(771, "energybuffer.01.tier.01", "Low Voltage Energy Buffer", 1, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_MV.set(new GregtechMetaEnergyBuffer(772, "energybuffer.01.tier.02", "Medium Voltage Energy Buffer", 2, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_HV.set(new GregtechMetaEnergyBuffer(773, "energybuffer.01.tier.03", "High Voltage Energy Buffer", 3, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_EV.set(new GregtechMetaEnergyBuffer(774, "energybuffer.01.tier.04", "Extreme Voltage Energy Buffer", 4, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_IV.set(new GregtechMetaEnergyBuffer(775, "energybuffer.01.tier.05", "Insane Voltage Energy Buffer", 5, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_LuV.set(new GregtechMetaEnergyBuffer(776, "energybuffer.01.tier.06", "Ludicrous Voltage Energy Buffer", 6, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_ZPM.set(new GregtechMetaEnergyBuffer(777, "energybuffer.01.tier.07", "ZPM Voltage Energy Buffer", 7, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_UV.set(new GregtechMetaEnergyBuffer(778, "energybuffer.01.tier.08", "Ultimate Voltage Energy Buffer", 8, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_MAX.set(new GregtechMetaEnergyBuffer(779, "energybuffer.01.tier.09", "MAX Voltage Energy Buffer", 9, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_ULV.set(new GregtechMetaEnergyBuffer(770, "energybuffer.tier.00", "Ultra Low Voltage Energy Buffer", 0, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_LV.set(new GregtechMetaEnergyBuffer(771, "energybuffer.tier.01", "Low Voltage Energy Buffer", 1, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_MV.set(new GregtechMetaEnergyBuffer(772, "energybuffer.tier.02", "Medium Voltage Energy Buffer", 2, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_HV.set(new GregtechMetaEnergyBuffer(773, "energybuffer.tier.03", "High Voltage Energy Buffer", 3, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_EV.set(new GregtechMetaEnergyBuffer(774, "energybuffer.tier.04", "Extreme Voltage Energy Buffer", 4, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_IV.set(new GregtechMetaEnergyBuffer(775, "energybuffer.tier.05", "Insane Voltage Energy Buffer", 5, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_LuV.set(new GregtechMetaEnergyBuffer(776, "energybuffer.tier.06", "Ludicrous Voltage Energy Buffer", 6, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_ZPM.set(new GregtechMetaEnergyBuffer(777, "energybuffer.tier.07", "ZPM Voltage Energy Buffer", 7, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_UV.set(new GregtechMetaEnergyBuffer(778, "energybuffer.tier.08", "Ultimate Voltage Energy Buffer", 8, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_MAX.set(new GregtechMetaEnergyBuffer(779, "energybuffer.tier.09", "MAX Voltage Energy Buffer", 9, "", 1).getStackForm(1L)); // Creative Buffer Has Special ID GregtechItemList.Energy_Buffer_CREATIVE .set(new GregtechMetaCreativeEnergyBuffer(750, - "energybuffer.01.tier.xx", + "energybuffer.tier.xx", "512V Creative Energy Buffer", 3, "", 0) .getStackForm(1L)); -- cgit From b69f9b956c139fc1d6fd8ef787203da63695a82c Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 15 Feb 2019 20:29:58 +0000 Subject: % Adjusted documentation of MTE info within Transformer. $ Added more ASM to fix GT. MetaTileEntities can now be set in an invalid way without crashing the server/client. They now just invalidate and log to GT_LOG. $ Fixed a few NPE's thrown during startup by machines checking/creating invalid BlockPos. --- build.gradle | 4 +- .../ClassTransformer_GT_BaseMetaTileEntity.java | 158 ++++++++++ ...ransformer_GT_BlockMachines_MetaPipeEntity.java | 43 ++- .../ClassTransformer_GT_Packet_TileEntity.java | 319 +++++++++++++++++++++ .../Preloader_Transformer_Handler.java | 15 +- .../base/GregtechMeta_MultiBlockBase.java | 23 +- .../basic/GregtechMetaWirelessCharger.java | 16 +- 7 files changed, 550 insertions(+), 28 deletions(-) create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BaseMetaTileEntity.java create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Packet_TileEntity.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/build.gradle b/build.gradle index c1bd06d5f3..6a8c606908 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ configurations { dependencies { compile fileTree(dir: 'libs', include: '*.jar') - testCompile 'junit:junit:4.12' + //testCompile 'junit:junit:4.12' //fatJar files('libs/Segment-2.1.1.jar') } @@ -57,7 +57,7 @@ javadoc.options.encoding = 'UTF-8' //Jar Info archivesBaseName = "GT-PlusPlus" -version = "1.7.02.75" +version = "1.7.02.88-debug" minecraft.version = "1.7.10-10.13.4.1614-1.7.10" minecraft { diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BaseMetaTileEntity.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BaseMetaTileEntity.java new file mode 100644 index 0000000000..da5859eb55 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BaseMetaTileEntity.java @@ -0,0 +1,158 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class ClassTransformer_GT_BaseMetaTileEntity { + + //The qualified name of the class we plan to transform. + //gregtech/common/blocks/GT_Block_Machines + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + + public ClassTransformer_GT_BaseMetaTileEntity(byte[] basicClass) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Attempting to make setMetaTileEntity(IMetaTileEntity) safer."); + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + aTempReader.accept(new localClassVisitor(aTempWriter), 0); + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Valid patch? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + + + if (reader != null && writer != null) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Attempting Method Injection."); + injectMethod("setMetaTileEntity"); + } + + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(String aMethodName) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Injecting "+aMethodName+"."); + if (aMethodName.equals("setMetaTileEntity")) { + + mv = getWriter().visitMethod(ACC_PUBLIC, "setMetaTileEntity", "(Lgregtech/api/interfaces/metatileentity/IMetaTileEntity;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable"); + mv.visitLabel(l0); + mv.visitLineNumber(1568, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/metatileentity/MetaTileEntity"); + mv.visitFieldInsn(PUTFIELD, "gregtech/api/metatileentity/BaseMetaTileEntity", "mMetaTileEntity", "Lgregtech/api/metatileentity/MetaTileEntity;"); + mv.visitLabel(l1); + mv.visitLineNumber(1569, l1); + Label l3 = new Label(); + mv.visitJumpInsn(GOTO, l3); + mv.visitLabel(l2); + mv.visitLineNumber(1570, l2); + mv.visitFrame(F_SAME1, 0, null, 1, new Object[] {"java/lang/Throwable"}); + mv.visitVarInsn(ASTORE, 2); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(1571, l4); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("[BMTE] Bad Tile Entity set in world, your game would have crashed if not for me!"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(1572, l5); + mv.visitVarInsn(ALOAD, 1); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(1573, l7); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); + mv.visitInsn(DUP); + mv.visitLdcInsn("Tile was of type: "); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "", "(Ljava/lang/String;)V", false); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEINTERFACE, "gregtech/api/interfaces/metatileentity/IMetaTileEntity", "getInventoryName", "()Ljava/lang/String;", true); + 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.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + mv.visitLabel(l6); + mv.visitLineNumber(1574, l6); + mv.visitFrame(F_APPEND,1, new Object[] {"java/lang/Throwable"}, 0, null); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Throwable", "printStackTrace", "()V", false); + mv.visitLabel(l3); + mv.visitLineNumber(1576, l3); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitInsn(RETURN); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/BaseMetaTileEntity;", null, l0, l8, 0); + mv.visitLocalVariable("aMetaTileEntity", "Lgregtech/api/interfaces/metatileentity/IMetaTileEntity;", null, l0, l8, 1); + mv.visitLocalVariable("t", "Ljava/lang/Throwable;", null, l4, l3, 2); + mv.visitMaxs(4, 3); + mv.visitEnd(); + + didInject = true; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + public final class localClassVisitor extends ClassVisitor { + + public localClassVisitor(ClassVisitor cv) { + super(ASM5, cv); + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("setMetaTileEntity")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Found method "+name+", removing."); + methodVisitor = null; + } + else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java index 85300c043c..e86d1e4a12 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java @@ -19,7 +19,9 @@ import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -45,6 +47,9 @@ public class ClassTransformer_GT_BlockMachines_MetaPipeEntity { return "wrench"; } + /* + * Used to patch the method in Fluid pipes, Frame Boxes and Item Pipes + */ /** * This determines the BaseMetaTileEntity belonging to this MetaTileEntity by using the Meta ID of the Block itself. *

@@ -68,15 +73,20 @@ public class ClassTransformer_GT_BlockMachines_MetaPipeEntity { *

* == Reserved For Alkalus (Was previously used to allow axes on wooden blocks, but that's fucking stupid.) *

- * 12 = BaseMetaTileEntity, Wrench lvl 0 to dismantle - * 13 = BaseMetaTileEntity, Wrench lvl 1 to dismantle + * 12 = BaseCustomPower_MTE, Wrench lvl 0 to dismantle + * 13 = BaseCustomTileEntity, Wrench lvl 1 to dismantle *

- * 14 = BaseMetaTileEntity, Wrench lvl 2 to dismantle - * 15 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + * 14 = BaseCustomTileEntity, Wrench lvl 2 to dismantle + * 15 = BaseCustomTileEntity, Wrench lvl 3 to dismantle */ public static byte getTileEntityBaseType(Materials mMaterial) { - //FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Attempting to call getTileEntityBaseType."); - return (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + byte mMetaID; + //Modified code that should never return 12-15 for Wooden items. + //mMetaID = (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + //Original Code for debug purposes + mMetaID = mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 4 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + //FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Attempting to call getTileEntityBaseType. Using Meta: "+mMetaID); + return mMetaID; } @@ -104,14 +114,14 @@ public class ClassTransformer_GT_BlockMachines_MetaPipeEntity { *

* == Reserved For Alkalus (Was previously used to allow axes on wooden blocks, but that's fucking stupid.) *

- * 12 = BaseMetaTileEntity, Wrench lvl 2 to dismantle - * 13 = BaseMetaTileEntity, Wrench lvl 2 to dismantle + * 12 = BaseCustomPower_MTE, Wrench lvl 2 to dismantle + * 13 = BaseCustomTileEntity, Wrench lvl 2 to dismantle *

- * 14 = BaseMetaTileEntity, Wrench lvl 3 to dismantle - * 15 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + * 14 = BaseCustomTileEntity, Wrench lvl 3 to dismantle + * 15 = BaseCustomTileEntity, Wrench lvl 3 to dismantle */ public static TileEntity createTileEntity(World aWorld, int aMeta) { - //Logger.INFO("Creating Tile Entity with Meta of "+aMeta); + Logger.INFO("Creating Tile Entity with Meta of "+aMeta); if (aMeta < 4) { return GregTech_API.constructBaseMetaTileEntity(); } else if (aMeta < 12) { @@ -121,12 +131,21 @@ public class ClassTransformer_GT_BlockMachines_MetaPipeEntity { try { return Meta_GT_Proxy.constructCustomGregtechMetaTileEntityByMeta(aMeta); } - catch (ClassCastException c) { + catch (Throwable c) { //Returns a pipe entity, once this returns, it should correct itself and no longer error in future. return new BaseMetaPipeEntity(); } } } + + public static TileEntity createTileEntity_Original(World aWorld, int aMeta) { + // Logger.INFO("Creating Tile Entity with Meta of "+aMeta); + if (aMeta < 4) { + return GregTech_API.constructBaseMetaTileEntity(); + } else { + return new BaseMetaPipeEntity(); + } + } int mMode; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Packet_TileEntity.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Packet_TileEntity.java new file mode 100644 index 0000000000..1f281ce492 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Packet_TileEntity.java @@ -0,0 +1,319 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class ClassTransformer_GT_Packet_TileEntity { + + //The qualified name of the class we plan to transform. + //gregtech/common/blocks/GT_Block_Machines + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + + public ClassTransformer_GT_Packet_TileEntity(byte[] basicClass, boolean obfuscated) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Attempting to make GT Packets safer."); + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + aTempReader.accept(new localClassVisitor(aTempWriter), 0); + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Valid patch? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + + + if (reader != null && writer != null) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Attempting Method Injection."); + injectMethod("process", obfuscated); + } + + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(String aMethodName, boolean obfuscated) { + MethodVisitor mv; + boolean didInject = false; + String aGetTile = obfuscated ? "func_147438_o" : "getTileEntity"; + + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Injecting "+aMethodName+"."); + if (aMethodName.equals("process")) { + mv = getWriter().visitMethod(ACC_PUBLIC, "process", "(Lnet/minecraft/world/IBlockAccess;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable"); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(93, l3); + mv.visitVarInsn(ALOAD, 1); + Label l4 = new Label(); + mv.visitJumpInsn(IFNULL, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(94, l5); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mX", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mY", "S"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mZ", "I"); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/world/IBlockAccess", ""+aGetTile+"", "(III)Lnet/minecraft/tileentity/TileEntity;", true); + mv.visitVarInsn(ASTORE, 2); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(95, l6); + mv.visitVarInsn(ALOAD, 2); + mv.visitJumpInsn(IFNULL, l4); + mv.visitLabel(l0); + mv.visitLineNumber(97, l0); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(INSTANCEOF, "gregtech/api/metatileentity/BaseMetaTileEntity"); + Label l7 = new Label(); + mv.visitJumpInsn(IFEQ, l7); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(98, l8); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/metatileentity/BaseMetaTileEntity"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mID", "S"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC0", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC1", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC2", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC3", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC4", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC5", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mTexture", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mTexturePage", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mUpdate", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mRedstone", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mColor", "B"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/metatileentity/BaseMetaTileEntity", "receiveMetaTileEntityData", "(SIIIIIIBBBBB)V", false); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(99, l9); + mv.visitJumpInsn(GOTO, l4); + mv.visitLabel(l7); + mv.visitLineNumber(101, l7); + mv.visitFrame(F_APPEND,1, new Object[] {"net/minecraft/tileentity/TileEntity"}, 0, null); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(INSTANCEOF, "gregtech/api/metatileentity/BaseMetaPipeEntity"); + mv.visitJumpInsn(IFEQ, l4); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(102, l10); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/metatileentity/BaseMetaPipeEntity"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mID", "S"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC0", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC1", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC2", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC3", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC4", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC5", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mTexture", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mUpdate", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mRedstone", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mColor", "B"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/metatileentity/BaseMetaPipeEntity", "receiveMetaTileEntityData", "(SIIIIIIBBBB)V", false); + mv.visitLabel(l1); + mv.visitLineNumber(104, l1); + mv.visitJumpInsn(GOTO, l4); + mv.visitLabel(l2); + mv.visitLineNumber(105, l2); + mv.visitFrame(F_SAME1, 0, null, 1, new Object[] {"java/lang/Throwable"}); + mv.visitVarInsn(ASTORE, 3); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(106, l11); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); + mv.visitInsn(DUP); + mv.visitLdcInsn("[GTPTE] Bad Tile Entity set in world, your game would have crashed if not for me! Was Null? "); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "", "(Ljava/lang/String;)V", false); + mv.visitVarInsn(ALOAD, 2); + Label l12 = new Label(); + mv.visitJumpInsn(IFNONNULL, l12); + mv.visitInsn(ICONST_1); + Label l13 = new Label(); + mv.visitJumpInsn(GOTO, l13); + mv.visitLabel(l12); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/api/net/GT_Packet_TileEntity", "net/minecraft/world/IBlockAccess", "net/minecraft/tileentity/TileEntity", "java/lang/Throwable"}, 2, new Object[] {"java/io/PrintStream", "java/lang/StringBuilder"}); + mv.visitInsn(ICONST_0); + mv.visitLabel(l13); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/api/net/GT_Packet_TileEntity", "net/minecraft/world/IBlockAccess", "net/minecraft/tileentity/TileEntity", "java/lang/Throwable"}, 3, new Object[] {"java/io/PrintStream", "java/lang/StringBuilder", INTEGER}); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Z)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(107, l14); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); + mv.visitInsn(DUP); + mv.visitLdcInsn("Tile location ["); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "", "(Ljava/lang/String;)V", false); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mX", "I"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); + mv.visitLdcInsn("]["); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mY", "S"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); + mv.visitLdcInsn("]["); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mZ", "I"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); + mv.visitLdcInsn("]"); + 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.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(108, l15); + mv.visitVarInsn(ALOAD, 2); + Label l16 = new Label(); + mv.visitJumpInsn(IFNULL, l16); + Label l17 = new Label(); + mv.visitLabel(l17); + mv.visitLineNumber(109, l17); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(INSTANCEOF, "gregtech/api/metatileentity/BaseMetaPipeEntity"); + Label l18 = new Label(); + mv.visitJumpInsn(IFEQ, l18); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(110, l19); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("Type: Pipe"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l20 = new Label(); + mv.visitLabel(l20); + mv.visitLineNumber(111, l20); + mv.visitJumpInsn(GOTO, l16); + mv.visitLabel(l18); + mv.visitLineNumber(112, l18); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(INSTANCEOF, "gregtech/api/metatileentity/BaseMetaTileEntity"); + Label l21 = new Label(); + mv.visitJumpInsn(IFEQ, l21); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(113, l22); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("Type: Machine"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l23 = new Label(); + mv.visitLabel(l23); + mv.visitLineNumber(114, l23); + mv.visitJumpInsn(GOTO, l16); + mv.visitLabel(l21); + mv.visitLineNumber(116, l21); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("Type: Non-GT (Could be GT++/TT/BW)"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + mv.visitLabel(l16); + mv.visitLineNumber(119, l16); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Throwable", "printStackTrace", "()V", false); + mv.visitLabel(l4); + mv.visitLineNumber(123, l4); + mv.visitFrame(F_CHOP,2, null, 0, null); + mv.visitInsn(RETURN); + Label l24 = new Label(); + mv.visitLabel(l24); + mv.visitLocalVariable("this", "Lgregtech/api/net/GT_Packet_TileEntity;", null, l3, l24, 0); + mv.visitLocalVariable("aWorld", "Lnet/minecraft/world/IBlockAccess;", null, l3, l24, 1); + mv.visitLocalVariable("tTileEntity", "Lnet/minecraft/tileentity/TileEntity;", null, l6, l4, 2); + mv.visitLocalVariable("t", "Ljava/lang/Throwable;", null, l11, l4, 3); + mv.visitMaxs(13, 4); + mv.visitEnd(); + + + didInject = true; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + public final class localClassVisitor extends ClassVisitor { + + public localClassVisitor(ClassVisitor cv) { + super(ASM5, cv); + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("process")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Found method "+name+", removing."); + methodVisitor = null; + } + else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index e7014de089..0cb25d259b 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -131,6 +131,17 @@ public class Preloader_Transformer_Handler implements IClassTransformer { FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); return new ClassTransformer_GT_Client(basicClass).getByteArray(); }*/ + + //Make GT packets safer, fill them with debug info. + if (transformedName.equals("gregtech.api.net.GT_Packet_TileEntity")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_Packet_TileEntity(basicClass, obfuscated).getWriter().toByteArray(); + } + //Make the setting of GT Tiles safer, so as not to crash the client. + if (transformedName.equals("gregtech.api.metatileentity.BaseMetaTileEntity")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_BaseMetaTileEntity(basicClass).getWriter().toByteArray(); + } @@ -182,12 +193,10 @@ public class Preloader_Transformer_Handler implements IClassTransformer { //Fix IC2 Shit for (String y : aIC2ClassNames) { if (transformedName.equals(y)) { - //Fix GT NBT Persistency issue FMLRelaunchLog.log("[GT++ ASM] IC2 getHarvestTool Patch", Level.INFO, "Transforming %s", transformedName); return new ClassTransformer_IC2_GetHarvestTool(basicClass, probablyShouldBeFalse, transformedName).getWriter().toByteArray(); } - } - + } return basicClass; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 2427815295..b55157e763 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -38,6 +38,8 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; @@ -904,10 +906,15 @@ GT_MetaTileEntity_MultiBlockBase { public boolean addToMachineListInternal(ArrayList aList, final IMetaTileEntity aTileEntity, - final int aBaseCasingIndex) { + final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } if (aList.isEmpty()) { if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { - log("Adding " + aTileEntity.getInventoryName() + " at " + new BlockPos(aTileEntity.getBaseMetaTileEntity()).getLocationString()); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Adding " + aTileEntity.getInventoryName() + " at " + new BlockPos(aTileEntity.getBaseMetaTileEntity()).getLocationString()); + } updateTexture(aTileEntity, aBaseCasingIndex); return aList.add((E) aTileEntity); } @@ -920,13 +927,17 @@ GT_MetaTileEntity_MultiBlockBase { BlockPos aPos = new BlockPos(b); if (b != null && aPos != null) { if (aCurPos.equals(aPos)) { - log("Found Duplicate "+b.getInventoryName()+" at " + aPos.getLocationString()); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Found Duplicate "+b.getInventoryName()+" at " + aPos.getLocationString()); + } return false; } } } if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { - log("Adding " + aCur.getInventoryName() + " at " + aCurPos.getLocationString()); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Adding " + aCur.getInventoryName() + " at " + aCurPos.getLocationString()); + } updateTexture(aTileEntity, aBaseCasingIndex); return aList.add((E) aTileEntity); } @@ -1607,7 +1618,9 @@ GT_MetaTileEntity_MultiBlockBase { } else if (aFoundBlock != aExpectedBlock) { log("A1 - Found: "+aFoundBlock.getLocalizedName()+":"+aFoundMeta+", Expected: "+aExpectedBlock.getLocalizedName()+":"+aExpectedMeta); - log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); + } return false; } else if (aFoundMeta != aExpectedMeta) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 25c14a68e7..f2e3b3c3c0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -17,7 +17,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.EntityUtils; @@ -457,7 +456,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } } - public BlockPos getTileEntityPosition(){ + public BlockPos getTileEntityPosition(){ return new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld()); } @@ -533,10 +532,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { @Override public void onServerStart() { mWirelessChargingMap.clear(); - mLocalChargingMap.clear(); - if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ - mHasBeenMapped = true; - } + mLocalChargingMap.clear(); super.onServerStart(); } @@ -552,4 +548,12 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { super.doExplosion(aExplosionPower); } + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ + mHasBeenMapped = true; + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } + } \ No newline at end of file -- cgit From 1c20e21e7678f9a546fff9bf873c80c35a841cf8 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sat, 16 Feb 2019 04:37:28 +0000 Subject: $ Fixed issue where items collected may cause an NPE to be thrown by GT's assembly line recipe handler. Recipe map is now cleaned up, removing any invalid recipes and logging them during the process. --- src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 84 +++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 6903305f9d..6edc47badf 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -12,18 +12,23 @@ import gregtech.api.interfaces.IToolStats; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.Recipe_GT; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.australia.gen.gt.WorldGen_GT_Australia; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.OldCircuitHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.ConfigSwitches; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.everglades.gen.gt.WorldGen_GT; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; import gtPlusPlus.xmod.gregtech.api.world.GTPP_Worldgen; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.loaders.*; @@ -104,6 +109,7 @@ public class HANDLER_GT { public static void onLoadComplete(FMLLoadCompleteEvent event) { removeCrudeTurbineRotors(); + cleanAssemblyLineRecipeMap(); } private static int removeCrudeTurbineRotors() { @@ -165,5 +171,83 @@ public class HANDLER_GT { return aRemoved; } + + /** + * Should clean out any invalid Assembly Line recipes, if the map actually exists. + * Prevents NPE's being thrown by GT's AL handler. (Fucking Annoying) + * @return - Amount of Recipes removed, which were invalid in some way. + */ + private static int cleanAssemblyLineRecipeMap() { + GT_Recipe_Map g = StaticFields59.sAssemblylineVisualRecipes; + if (g == null) { + return 0; + } + else { + AutoMap aNewMap = new AutoMap(); + AutoMap aBadRecipeTempMap = new AutoMap(); + for (GT_Recipe r : g.mRecipeList) { + if (r != null) { + if (r.mOutputs == null || r.mOutputs.length == 0 || r.mOutputs[0] == null) { + aBadRecipeTempMap.put(r.copy()); + continue; + } + else { + aNewMap.put(r.copy()); + } + } + } + if (aNewMap.size() > 0) { + g.mRecipeList.clear(); + for (GT_Recipe i : aNewMap) { + g.add(i); + } + } + if (aBadRecipeTempMap.size() > 0) { + Logger.INFO("Found "+aBadRecipeTempMap.size()+" bad Assembly Line Recipes, attempting to dump all data about them."); + Logger.INFO("This data should be given to the mod author for the recipe in question."); + for (GT_Recipe i : aBadRecipeTempMap) { + if (i == null) { + Logger.INFO("Found NULL recipe. Impossible to determine who added this one. Please Report to Alkalus on Github."); + } + else { + if (i.mOutputs == null || i.mOutputs.length == 0 || i.mOutputs[0] == null) { + Logger.INFO("Found recipe with NULL output array, this will cause some issues. Attempting to determine other info about recipe."); + if (i.mInputs != null && i.mInputs.length > 0) { + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(i.mInputs)); + } + else { + Logger.INFO("Recipe had no valid inputs."); + } + Logger.INFO("Time: "+i.mDuration); + Logger.INFO("EU/T: "+i.mEUt); + Logger.INFO("Special: "+i.mSpecialValue); + } + else { + Logger.INFO("Found bad recipe, Attempting to determine other info."); + if (i.mInputs != null && i.mInputs.length > 0) { + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(i.mInputs)); + } + else { + Logger.INFO("Recipe had no valid inputs."); + } + if (i.mOutputs != null && i.mOutputs.length > 0) { + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(i.mOutputs)); + } + else { + Logger.INFO("Recipe had no valid outputs."); + } + Logger.INFO("Time: "+i.mDuration); + Logger.INFO("EU/T: "+i.mEUt); + Logger.INFO("Special: "+i.mSpecialValue); + } + } + } + } + else { + Logger.INFO("No bad Assembly Line recipes found, this is great news!"); + } + return aBadRecipeTempMap.size(); + } + } } -- cgit From 4f435ae75b176a9d90c7afa6b1ff40e9ba9c286a Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 28 Feb 2019 20:06:01 +0000 Subject: + Added a new debug tool. + Added support for Crops++. + Added Custom Crops & framework to support more in future. + Added basic support for all GT++ Materials within Tinkers Construct. [WIP] + Moderately bad attempt at generating custom Plasma Cooling recipes in the Adv. Vacuum Freezer. [WIP #424] % Reworked logic for Material.java handling Durability, Tool Quality & Harvest Level. % Adjusted frequency of structural checks on the Cyclotron, Now 100x less frequent. % Cleaned up ReflectionUtils.java and made all getters cache their results, for much faster access. % Attempted to adjust logic of FFPP, but I probably broke it. [WIP] % Moved static array of Element Names from IonParticles.java -> ELEMENT.java. $ Greatly improved reflective performance across the mod. --- src/Java/gregtech/api/util/FishPondFakeRecipe.java | 4 +- src/Java/gtPlusPlus/GTplusplus.java | 14 + .../gen/gt/WorldGen_GT_Australia_Ore_Layer.java | 2 +- .../gtPlusPlus/core/block/base/BlockBaseOre.java | 4 +- .../core/block/machine/Machine_ProjectTable.java | 30 +- .../core/block/machine/Machine_Workbench.java | 30 +- .../core/client/renderer/RenderGiantChicken.java | 2 +- src/Java/gtPlusPlus/core/common/CommonProxy.java | 6 +- .../entity/monster/EntityStaballoyConstruct.java | 17 +- .../gtPlusPlus/core/gui/item/GuiBaseGrindle.java | 2 +- .../core/gui/machine/GUI_ScrollTest.java | 7 +- .../core/handler/COMPAT_IntermodStaging.java | 13 +- src/Java/gtPlusPlus/core/item/ModItems.java | 9 +- .../core/item/chemistry/IonParticles.java | 11 +- .../core/item/general/books/ItemBaseBook.java | 5 +- .../item/general/capture/ItemEntityCatcher.java | 13 +- .../core/item/tool/misc/DebugScanner.java | 98 +++++ src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- src/Java/gtPlusPlus/core/lib/LoadedMods.java | 6 + src/Java/gtPlusPlus/core/material/ELEMENT.java | 6 +- src/Java/gtPlusPlus/core/material/Material.java | 30 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 2 + src/Java/gtPlusPlus/core/slots/SlotToolBox.java | 18 +- src/Java/gtPlusPlus/core/util/Utils.java | 2 +- .../gtPlusPlus/core/util/minecraft/FoodUtils.java | 2 +- .../core/util/minecraft/MaterialUtils.java | 2 +- .../core/util/minecraft/MiningUtils.java | 22 +- .../util/minecraft/gregtech/PollutionUtils.java | 26 +- .../core/util/reflect/ClientProxyFinder.java | 32 -- .../gtPlusPlus/core/util/reflect/ProxyFinder.java | 4 +- .../core/util/reflect/ReflectionUtils.java | 438 ++++++++++++++------- .../everglades/gen/gt/WorldGen_GT_Ore_Layer.java | 2 +- .../gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java | 2 +- .../villagers/entity/EntityBaseVillager.java | 62 +-- .../villagers/entity/EntityNativeAustralian.java | 61 +-- .../villagers/tile/TileEntityGenericSpawner.java | 2 +- .../gtPlusPlus/preloader/Preloader_GT_OreDict.java | 41 +- .../transformers/Preloader_ClassTransformer2.java | 6 +- .../xmod/bartcrops/HANDLER_CropsPlusPlus.java | 21 + .../xmod/bartcrops/LoaderOfTheCrops.java | 109 +++++ .../bartcrops/abstracts/BaseAestheticCrop.java | 37 ++ .../xmod/bartcrops/abstracts/BaseCrop.java | 56 +++ .../bartcrops/abstracts/BaseHarvestableCrop.java | 69 ++++ .../gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java | 56 +++ .../xmod/eio/handler/HandlerTooltip_EIO.java | 8 +- src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java | 8 +- .../forestry/bees/custom/GTPP_Bee_Definition.java | 2 +- .../xmod/forestry/bees/custom/GTPP_Bees.java | 2 +- .../galacticraft/handler/HandlerTooltip_GC.java | 5 +- .../core/world/gen/ChunkProviderGalactic.java | 46 ++- .../xmod/galacticraft/util/GalacticUtils.java | 10 +- .../GT_MetaTileEntity_Hatch_Naquadah.java | 2 +- .../GT_MetaTileEntity_Hatch_Plasma.java | 10 +- .../base/GregtechMeta_MultiBlockBase.java | 18 +- .../xmod/gregtech/api/objects/MultiblockLayer.java | 10 +- .../api/util/GregtechOreDictUnificator.java | 3 - .../xmod/gregtech/common/Meta_GT_Proxy.java | 125 +++++- .../xmod/gregtech/common/StaticFields59.java | 6 +- .../gregtech/common/helpers/ChargingHelper.java | 9 +- .../gregtech/common/helpers/TreeFarmHelper.java | 4 +- .../common/items/MetaGeneratedGregtechItems.java | 2 +- .../multi/production/GT4Entity_AutoCrafter.java | 2 +- .../GregtechMetaTileEntity_Cyclotron.java | 10 +- ...egtechMetaTileEntity_IndustrialFishingPond.java | 2 +- .../GregtechMetaTileEntity_Refinery.java | 67 ++-- .../xmod/gregtech/loaders/GT_Material_Loader.java | 17 +- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 5 +- .../gregtech/GregtechNitroDieselFix.java | 5 +- .../xmod/growthcraft/fishtrap/FishTrapHandler.java | 5 +- .../xmod/sc2/modules/ModuleExoticSeeds.java | 4 +- .../xmod/thaumcraft/HANDLER_Thaumcraft.java | 5 +- .../gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java | 4 +- .../xmod/tinkers/material/BaseTinkersMaterial.java | 200 ++++++++++ .../gtPlusPlus/xmod/tinkers/util/TinkersUtils.java | 66 +++- src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java | 21 +- .../vswe/stevescarts/ModuleData/GppModuleData.java | 2 +- 76 files changed, 1470 insertions(+), 598 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java delete mode 100644 src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java create mode 100644 src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java create mode 100644 src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gregtech/api/util/FishPondFakeRecipe.java b/src/Java/gregtech/api/util/FishPondFakeRecipe.java index 9e0a65a6cc..5d74329135 100644 --- a/src/Java/gregtech/api/util/FishPondFakeRecipe.java +++ b/src/Java/gregtech/api/util/FishPondFakeRecipe.java @@ -27,7 +27,7 @@ public class FishPondFakeRecipe { junk = (ArrayList) ReflectionUtils.getField(FishingHooks.class, "junk").get(null); treasure = (ArrayList) ReflectionUtils.getField(FishingHooks.class, "treasure").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { Logger.INFO("Error generating Fish Pond Recipes. [1]"); e.printStackTrace(); } @@ -46,7 +46,7 @@ public class FishPondFakeRecipe { ItemStack t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b").get(u); addNewFishPondLoot(mType, new ItemStack[]{t}, new int[] {10000}); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e1) { + catch (IllegalArgumentException | IllegalAccessException e1) { Logger.INFO("Error generating Fish Pond Recipes. [2]"); e1.printStackTrace(); } diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 2e3133c343..5c3d5fb801 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -301,6 +301,9 @@ public class GTplusplus implements ActionListener { if (CORE.RA.addMultiblockCentrifugeRecipe(x.mInputs, x.mFluidInputs, x.mFluidOutputs, x.mOutputs, x.mChances, x.mDuration, x.mEUt, x.mSpecialValue)) { mValidCount[0]++; } + else { + mInvalidCount[0]++; + } } else { Logger.INFO("[Recipe] Error generating Large Centrifuge recipe."); @@ -329,6 +332,9 @@ public class GTplusplus implements ActionListener { if (CORE.RA.addMultiblockElectrolyzerRecipe(x.mInputs, x.mFluidInputs, x.mFluidOutputs, x.mOutputs, x.mChances, x.mDuration, x.mEUt, x.mSpecialValue)) { mValidCount[1]++; } + else { + mInvalidCount[1]++; + } } else { Logger.INFO("[Recipe] Error generating Large Electrolyzer recipe."); @@ -370,11 +376,19 @@ public class GTplusplus implements ActionListener { mValidCount[2]++; } } + else { + mInvalidCount[2]++; + } } else { mInvalidCount[2]++; } } + + //Redo plasma recipes in Adv. Vac. + //Meta_GT_Proxy.generatePlasmaRecipesForAdvVacFreezer(); + + String[] machineName = new String[] {"Centrifuge", "Electrolyzer", "Vacuum Freezer"}; for (int i=0;i<3;i++) { Logger.INFO("[Recipe] Generated "+mValidCount[i]+" recipes for the Industrial "+machineName[i]+". The original machine can process "+mOriginalCount[i]+" recipes, meaning "+mInvalidCount[i]+" are invalid for this Multiblock's processing in some way."); diff --git a/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java index bbaa7ef008..a5e5f8b245 100644 --- a/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java +++ b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java @@ -72,7 +72,7 @@ extends WorldGen_GT_Australia { Field temp = ReflectionUtils.getField(GregTech_API.class, "sBlockStones"); tempBlock = temp.get(null); } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} mStoneTypes = (Block) tempBlock; } else { diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index 4d7478dbdd..e1bc3462be 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -113,7 +113,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { hiddenTextureArray = new IIconContainer[6]; } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { hiddenTextureArray = new IIconContainer[6]; } } @@ -216,7 +216,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { hiddenTextureArray = new IIconContainer[6]; } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { hiddenTextureArray = new IIconContainer[6]; } } diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java index eecc379290..fdb6b1a0a8 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java @@ -133,34 +133,24 @@ public class Machine_ProjectTable extends BlockContainer implements ITileTooltip } @Optional.Method(modid = "EnderIO") - private static boolean checkEnderIOWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { Class wrenchClass; - try { - wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; } @Optional.Method(modid = "Buildcraft") - private static boolean checkBuildcraftWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { Class wrenchClass; - try { - wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 675aeaaf2b..5c08612042 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -121,34 +121,24 @@ public class Machine_Workbench extends BlockContainer } @Optional.Method(modid = "EnderIO") - private static boolean checkEnderIOWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { Class wrenchClass; - try { - wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; } @Optional.Method(modid = "Buildcraft") - private static boolean checkBuildcraftWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { Class wrenchClass; - try { - wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java b/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java index 59621ef830..bc00db7ed1 100644 --- a/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java @@ -21,7 +21,7 @@ public class RenderGiantChicken extends RenderChicken { try { mChicken = (ResourceLocation) ReflectionUtils.getField(RenderGiantChicken.class, "chickenTextures").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { mChicken = new ResourceLocation("textures/entity/chicken.png"); } chickenTexturesEx = mChicken; diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 140019f73b..03b643abdb 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -82,7 +82,7 @@ public class CommonProxy { ModBlocks.init(); CI.preInit(); - COMPAT_IntermodStaging.preInit(); + COMPAT_IntermodStaging.preInit(e); BookHandler.run(); // Registration of entities and renderers Logger.INFO("[Proxy] Calling Entity registrator."); @@ -152,7 +152,7 @@ public class CommonProxy { // Compat Handling COMPAT_HANDLER.registerMyModsOreDictEntries(); COMPAT_HANDLER.intermodOreDictionarySupport(); - COMPAT_IntermodStaging.init(); + COMPAT_IntermodStaging.init(e); } public void postInit(final FMLPostInitializationEvent e) { @@ -170,7 +170,7 @@ public class CommonProxy { COMPAT_HANDLER.RemoveRecipesFromOtherMods(); COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); - COMPAT_IntermodStaging.postInit(); + COMPAT_IntermodStaging.postInit(e); COMPAT_HANDLER.runQueuedRecipes(); } diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java index bdc239b9ce..f6f397f59e 100644 --- a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java +++ b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java @@ -363,18 +363,15 @@ public class EntityStaballoyConstruct extends EntityIronGolem { } //Get a private field from a super class if it exists. - try { - if (mFirstUpdateField == null) { - mFirstUpdateField = ReflectionUtils.getField(Class.forName("net.minecraft.entity.Entity"), "firstUpdate"); - } - if (mFirstUpdateField != null && mReflectFirstUpdate == true){ - try { - this.mReflectFirstUpdate = (boolean) mFirstUpdateField.get(this); - } - catch (IllegalArgumentException | IllegalAccessException e) {} + if (mFirstUpdateField == null) { + mFirstUpdateField = ReflectionUtils.getField(this.getClass(), "firstUpdate"); + } + if (mFirstUpdateField != null && mReflectFirstUpdate == true){ + try { + this.mReflectFirstUpdate = (boolean) mFirstUpdateField.get(this); } + catch (IllegalArgumentException | IllegalAccessException e) {} } - catch (NoSuchFieldException | ClassNotFoundException e) {} } super.onEntityUpdate(); } diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java index f4669bfe35..ed347e8d30 100644 --- a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java +++ b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java @@ -331,7 +331,7 @@ public class GuiBaseGrindle extends GuiContainer { try { r = (ResourceLocation) ReflectionUtils.getField(GuiScreenBook.class, "bookGuiTextures").get(null); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { r = new ResourceLocation("textures/gui/book.png"); } mBookTexture = r; diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java index 7a3a01b27c..8a1f7c3fe9 100644 --- a/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java @@ -16,6 +16,7 @@ import com.google.common.collect.Lists; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiOptionButton; import net.minecraft.client.gui.GuiResourcePackAvailable; @@ -145,9 +146,9 @@ public class GUI_ScrollTest extends GuiScreen try { - Class oclass = Class.forName("java.awt.Desktop"); - Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); - oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()}); + Class oclass = ReflectionUtils.getClass("java.awt.Desktop"); + Object object = ReflectionUtils.getMethod(oclass, "getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + ReflectionUtils.getMethod(oclass, "browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()}); } catch (Throwable throwable) { diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index 79a2d2a6c0..0f689325a3 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -1,6 +1,10 @@ package gtPlusPlus.core.handler; +import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gtPlusPlus.xmod.bartcrops.HANDLER_CropsPlusPlus; import gtPlusPlus.xmod.bop.HANDLER_BiomesOPlenty; import gtPlusPlus.xmod.computronics.HANDLER_Computronics; import gtPlusPlus.xmod.forestry.HANDLER_FR; @@ -15,7 +19,7 @@ import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; public class COMPAT_IntermodStaging { - public static void preInit(){ + public static void preInit(FMLPreInitializationEvent preinit){ HANDLER_GT.preInit(); HANDLER_GC.preInit(); HANDLER_TF.preInit(); @@ -28,9 +32,10 @@ public class COMPAT_IntermodStaging { HANDLER_Tinkers.preInit(); HANDLER_SC2.preInit(); HANDLER_GalactiCraft.preInit(); + HANDLER_CropsPlusPlus.preInit(preinit); } - public static void init(){ + public static void init(FMLInitializationEvent init){ HANDLER_GT.init(); HANDLER_GC.init(); HANDLER_TF.init(); @@ -43,9 +48,10 @@ public class COMPAT_IntermodStaging { HANDLER_Tinkers.init(); HANDLER_SC2.init(); HANDLER_GalactiCraft.init(); + HANDLER_CropsPlusPlus.init(init); } - public static void postInit(){ + public static void postInit(FMLPostInitializationEvent postinit){ HANDLER_GT.postInit(); HANDLER_GC.postInit(); HANDLER_TF.postInit(); @@ -58,6 +64,7 @@ public class COMPAT_IntermodStaging { HANDLER_Tinkers.postInit(); HANDLER_SC2.postInit(); HANDLER_GalactiCraft.postInit(); + HANDLER_CropsPlusPlus.postInit(postinit); } public static void onLoadComplete(FMLLoadCompleteEvent event) { diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 8d7db4f40a..17aaf5e106 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -61,6 +61,7 @@ import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.materials.DustDecayable; +import gtPlusPlus.core.item.tool.misc.DebugScanner; import gtPlusPlus.core.item.tool.misc.GregtechPump; import gtPlusPlus.core.item.tool.misc.SandstoneHammer; import gtPlusPlus.core.item.tool.misc.box.AutoLunchBox; @@ -87,6 +88,7 @@ import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.debug.DEBUG_INIT; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.everglades.GTplusplus_Everglades; import gtPlusPlus.xmod.eio.material.MaterialEIO; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; @@ -328,6 +330,8 @@ public final class ModItems { public static BatteryPackBaseBauble itemChargePack3; public static BatteryPackBaseBauble itemChargePack4; + public static Item itemDebugScanner; + static { Logger.INFO("Items!"); //Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon. @@ -336,6 +340,9 @@ public final class ModItems { } public static final void init(){ + + itemDebugScanner = new DebugScanner().setTextureName(CORE.MODID + ":itemStickyRubber"); + itemAlkalusDisk = new BaseItemDamageable("itemAlkalusDisk", AddToCreativeTab.tabMisc, 1, 0, "Unknown Use", EnumRarity.rare, EnumChatFormatting.AQUA, false, null); itemBigEgg = new ItemGiantEgg("itemBigEgg", "Ginourmous Chicken Egg", tabMisc, 64, 0, "I had best try disassemble this.. for science!", "fuelLargeChickenEgg", 5000, 0).setTextureName(CORE.MODID + ":itemBigEgg"); itemGenericToken = new ItemGenericToken(); @@ -1002,7 +1009,7 @@ public final class ModItems { //Baubles Mod Test try { - final Class baublesTest = Class.forName("baubles.api.IBauble"); + final Class baublesTest = ReflectionUtils.getClass("baubles.api.IBauble"); if (baublesTest != null){ COMPAT_Baubles.run(); } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java b/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java index 517a698e80..e08a509436 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java @@ -6,6 +6,7 @@ import java.util.List; import gregtech.api.enums.Materials; import gtPlusPlus.core.item.base.misc.BaseItemParticle; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.util.Utils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -22,18 +23,16 @@ public class IonParticles extends BaseItemParticle { public IonParticles() { - super("Ion", aElements.length, EnumRarity.rare); + super("Ion", ELEMENT.NAMES.length, EnumRarity.rare); } - private static final String[] aElements = new String[]{"Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; - - public static IIcon[] overlays = new IIcon[aElements.length]; + public static IIcon[] overlays = new IIcon[ELEMENT.NAMES.length]; public static IIcon baseTexture; static { //Generate Ions int key = 0; - for (String s : aElements) { + for (String s : ELEMENT.NAMES) { //Map names to Meta NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key); MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase())); @@ -62,7 +61,7 @@ public class IonParticles extends BaseItemParticle { @Override public String getUnlocalizedName(final ItemStack itemStack) { - return "item.particle.ion" + "." + aElements[itemStack.getItemDamage()]; + return "item.particle.ion" + "." + ELEMENT.NAMES[itemStack.getItemDamage()]; } private static boolean createNBT(ItemStack rStack){ diff --git a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java index 7f6a52f135..2f49ac1287 100644 --- a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java +++ b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java @@ -27,6 +27,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class ItemBaseBook extends ItemWritableBook{ @@ -113,11 +114,11 @@ public class ItemBaseBook extends ItemWritableBook{ if (player.worldObj.isRemote){ try { - Class clazz = Class.forName("net.minecraft.client.gui.GuiScreenBook"); + Class clazz = ReflectionUtils.getClass("net.minecraft.client.gui.GuiScreenBook"); Constructor ctor = clazz.getConstructor(EntityPlayer.class, ItemStack.class, boolean.class); Object object = ctor.newInstance(new Object[] { player, bookstack, false }); Minecraft.getMinecraft().displayGuiScreen((GuiScreen) object); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java index 592b68d06a..a95fab4b6c 100644 --- a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java +++ b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java @@ -21,6 +21,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class ItemEntityCatcher extends Item implements IEntityCatcher { @@ -117,14 +118,10 @@ public class ItemEntityCatcher extends Item implements IEntityCatcher { } Class mEntityClass; String mClassName; - mClassName = NBTUtils.getString(aStack,"mClassName"); - try { - mEntityClass = (Class) Class.forName(mClassName); - if (mEntityClass != null) { - return mEntityClass; - } - } - catch (ClassNotFoundException e) { + mClassName = NBTUtils.getString(aStack, "mClassName"); + mEntityClass = (Class) ReflectionUtils.getClass(mClassName); + if (mEntityClass != null) { + return mEntityClass; } return null; } diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java new file mode 100644 index 0000000000..bc252c95a9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java @@ -0,0 +1,98 @@ +package gtPlusPlus.core.item.tool.misc; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class DebugScanner extends CoreItem { + + public DebugScanner() { + super("gtpp.debug.scanner", AddToCreativeTab.tabTools, 1, 0, + new String[] { + "Used to obtain information from GT/GT++ content", + "Right Click to use", + }, + EnumRarity.epic); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int p_77648_4_, + int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + // TODO Auto-generated method stub + return super.onItemUse(aStack, aPlayer, aWorld, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_8_, + p_77648_9_, p_77648_10_); + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + // TODO Auto-generated method stub + return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); + } + + @Override + public float getDigSpeed(ItemStack itemstack, Block block, int metadata) { + return 0f; + } + + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + if (entity != null && player != null) { + PlayerUtils.messagePlayer(player, "Entity ID: "+entity.getEntityId()); + PlayerUtils.messagePlayer(player, "UUID: "+entity.getUniqueID()); + PlayerUtils.messagePlayer(player, "Invulnerable? "+entity.isEntityInvulnerable()); + PlayerUtils.messagePlayer(player, "Invisible? "+entity.isInvisible()); + PlayerUtils.messagePlayer(player, "Age: "+entity.ticksExisted); + + if (entity instanceof EntityLiving) { + EntityLiving g = (EntityLiving) entity; + PlayerUtils.messagePlayer(player, "Health: "+g.getHealth()+"/"+g.getMaxHealth()); + PlayerUtils.messagePlayer(player, "On ground? "+g.onGround); + PlayerUtils.messagePlayer(player, "Can Loot? "+g.canPickUpLoot()); + PlayerUtils.messagePlayer(player, "Child? "+g.isChild()); + if (entity instanceof EntityPlayer) { + EntityPlayer y = (EntityPlayer) entity; + PlayerUtils.messagePlayer(player, "Experience: "+y.experience); + PlayerUtils.messagePlayer(player, "Name: "+y.getCommandSenderName()); + } + + } + + } + return true; + } + + @Override + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { + return false; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } + + @Override + public int getHarvestLevel(ItemStack stack, String toolClass) { + return 0; + } + + + +} diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index c7d09b959d..1f82e1cd17 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -52,7 +52,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.7.02.24"; + public static final String VERSION = "1.7.02.89-debug"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index e749885dd6..5a2b75337b 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -54,6 +54,7 @@ public class LoadedMods { public static boolean StevesCarts = false; public static boolean Witchery = false; public static boolean Waila = false; + public static boolean CropsPlusPlus = false; //Barts Crop Mod @@ -96,6 +97,11 @@ public class LoadedMods { Logger.INFO("Components enabled for: PlayerAPI"); totalMods++; } + if (Loader.isModLoaded("berriespp")) { + CropsPlusPlus = true; + Logger.INFO("Components enabled for: Crops++"); + totalMods++; + } if (Loader.isModLoaded("TConstruct")){ TiCon = true; Logger.INFO("Components enabled for: Tinkers Construct"); diff --git a/src/Java/gtPlusPlus/core/material/ELEMENT.java b/src/Java/gtPlusPlus/core/material/ELEMENT.java index 99bc37444e..62e1163a39 100644 --- a/src/Java/gtPlusPlus/core/material/ELEMENT.java +++ b/src/Java/gtPlusPlus/core/material/ELEMENT.java @@ -11,6 +11,8 @@ import gtPlusPlus.core.util.minecraft.MaterialUtils; public final class ELEMENT { + public static final String[] NAMES = new String[]{"Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; + //First 50 Elements public final Material HYDROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Hydrogen); public final Material HELIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Helium); @@ -148,8 +150,8 @@ public final class ELEMENT { public final Material AMERICIUM241 = new Material("Americium-241", MaterialState.SOLID, TextureSets.NUCLEAR.get(), Materials.Americium.mDurability, Materials.Americium.mRGBa, Materials.Americium.mMeltingPoint, Materials.Americium.mBlastFurnaceTemp, 95, 146, false, StringUtils.superscript("241Am"), 2, false);//Not a GT Inherited Material public final Material MAGIC = MaterialUtils.generateMaterialFromGtENUM(Materials.Magic, new short[] {10, 185, 140}); - public final Material THAUMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thaumium); - + public final Material THAUMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thaumium); + static { Logger.MATERIALS("Initialising Base Elements."); } diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 03e50aa7dd..d996bed128 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -1,6 +1,7 @@ package gtPlusPlus.core.material; import static gregtech.api.enums.GT_Values.M; +import static gtPlusPlus.core.util.math.MathUtils.safeCast_LongToInt; import java.util.ArrayList; import java.util.HashMap; @@ -317,28 +318,13 @@ public class Material { this.vDurability = durability; } else { - if (inputs != null){ - long durabilityTemp = 0; - int counterTemp = 0; - for (final MaterialStack m : inputs){ - if (m.getStackMaterial() != null){ - if (m.getStackMaterial().vDurability != 0){ - durabilityTemp = (durabilityTemp+m.getStackMaterial().vDurability); - counterTemp++; - - } - } + long aTempDura = 0; + for (MaterialStack g : this.getComposites()) { + if (g != null) { + aTempDura += safeCast_LongToInt(g.getStackMaterial().getMass() * 2000); } - if ((durabilityTemp != 0) && (counterTemp != 0)){ - this.vDurability = (durabilityTemp/counterTemp); - } - else { - this.vDurability = 8196; - } - } - else { - this.vDurability = 0; } + this.vDurability = aTempDura > 0 ? aTempDura : (this.getComposites().isEmpty() ? 51200 : 32000 * this.getComposites().size()); } if ((this.vDurability >= 0) && (this.vDurability < 64000)){ @@ -362,8 +348,8 @@ public class Material { this.vHarvestLevel = 4; } else { - this.vToolQuality = 0; - this.vHarvestLevel = 0; + this.vToolQuality = 1; + this.vHarvestLevel = 1; } //Sets the Rad level diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 6f4e8870d7..6210f9726c 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -1607,6 +1607,8 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("plateMeatRaw", 1)); GT_ModHandler.addCompressionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 9), ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1)); + + CORE.RA.addCompressorRecipe(ItemList.FusionComputer_UV.get(9), GregtechItemList.Compressed_Fusion_Reactor.get(1), (int) GT_Values.V[7], (int) GT_Values.V[8]); } private static void macerationRecipes() { diff --git a/src/Java/gtPlusPlus/core/slots/SlotToolBox.java b/src/Java/gtPlusPlus/core/slots/SlotToolBox.java index c6d025fd21..87967b75b5 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotToolBox.java +++ b/src/Java/gtPlusPlus/core/slots/SlotToolBox.java @@ -18,34 +18,34 @@ public class SlotToolBox extends SlotGtTool { Class temp; //IHL Pumps - temp = ReflectionUtils.getClassByName("ihl.handpump.IHLHandPump"); + temp = ReflectionUtils.getClass("ihl.handpump.IHLHandPump"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //IC2 Electrics - temp = ReflectionUtils.getClassByName("ic2.api.item.IElectricItem"); + temp = ReflectionUtils.getClass("ic2.api.item.IElectricItem"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //IC2 Boxables - temp = ReflectionUtils.getClassByName(" ic2.api.item.IBoxable"); + temp = ReflectionUtils.getClass(" ic2.api.item.IBoxable"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //Tinkers Tools - temp = ReflectionUtils.getClassByName("tconstruct.library.tools.Weapon"); + temp = ReflectionUtils.getClass("tconstruct.library.tools.Weapon"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //BattleGear Weapons - temp = ReflectionUtils.getClassByName("mods.battlegear2.api.weapons.IBattlegearWeapon"); + temp = ReflectionUtils.getClass("mods.battlegear2.api.weapons.IBattlegearWeapon"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -55,7 +55,7 @@ public class SlotToolBox extends SlotGtTool { //OpenMods String[] OpenModsContent = new String[] {"openblocks.common.item.ItemDevNull", "openblocks.common.item.ItemHangGlider", "openblocks.common.item.ItemWrench", "openblocks.common.item.ItemSleepingBag"}; for (String t : OpenModsContent) { - temp = ReflectionUtils.getClassByName(t); + temp = ReflectionUtils.getClass(t); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -63,7 +63,7 @@ public class SlotToolBox extends SlotGtTool { } //GC Wrench - temp = ReflectionUtils.getClassByName("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); + temp = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -72,7 +72,7 @@ public class SlotToolBox extends SlotGtTool { //EIO String[] EioContent = new String[] {"crazypants.enderio.api.tool.ITool", "crazypants.enderio.item.ItemMagnet", "crazypants.enderio.item.ItemConduitProbe"}; for (String t : EioContent) { - temp = ReflectionUtils.getClassByName(t); + temp = ReflectionUtils.getClass(t); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -80,7 +80,7 @@ public class SlotToolBox extends SlotGtTool { } //Forestry - temp = ReflectionUtils.getClassByName("forestry.core.items.ItemForestryTool"); + temp = ReflectionUtils.getClass("forestry.core.items.ItemForestryTool"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 81e2e94154..7d1d42abf0 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -798,7 +798,7 @@ public class Utils { return new Pair(9, 28); } - clazz = (Class) Class.forName("gregtech.GT_Mod"); + clazz = (Class) ReflectionUtils.getClass("gregtech.GT_Mod"); Field mSubversion = ReflectionUtils.getField(clazz, "SUBVERSION"); if (mSubversion != null){ int mSub = 0; diff --git a/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java index a1c2bf6104..9f5d4f36ca 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java @@ -13,7 +13,7 @@ public class FoodUtils { public static final Class IEdibleClass; static { - IEdibleClass = ReflectionUtils.getClassByName("squeek.applecore.api.food.IEdible"); + IEdibleClass = ReflectionUtils.getClass("squeek.applecore.api.food.IEdible"); } public static boolean isFood(ItemStack food) { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 45d21a3016..842b8eecb2 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -322,7 +322,7 @@ public class MaterialUtils { mName = (String) ReflectionUtils.getField(Materials.class, "mName").get(mat); } } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java index e7ced98f5a..080b5665a3 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java @@ -152,7 +152,7 @@ public class MiningUtils { try { aTextWorldGen = (String) ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "aTextWorldgen").get(h); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { aTextWorldGen = h.mWorldGenName; } @@ -180,27 +180,27 @@ public class MiningUtils { boolean aEndAsteroids; try { - if (Class.forName("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null && mMoonID == -99) { - mMoonID = ReflectionUtils.getField(Class.forName("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), "idDimensionMoon").getInt(null); + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null && mMoonID == -99) { + mMoonID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), "idDimensionMoon").getInt(null); } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} //Gets Mars ID try { - if (Class.forName("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null && mMarsID == -99) { - mMarsID = ReflectionUtils.getField(Class.forName("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), "dimensionIDMars").getInt(null); + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null && mMarsID == -99) { + mMarsID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), "dimensionIDMars").getInt(null); } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} //Get Comets ID try { - if (Class.forName("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") != null && mCometsID == -99) { - mCometsID = ReflectionUtils.getField(Class.forName("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), "dimensionIDAsteroids").getInt(null); + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") != null && mCometsID == -99) { + mCometsID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), "dimensionIDAsteroids").getInt(null); } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} //Clear Cache Ores_Overworld.clear(); @@ -215,7 +215,7 @@ public class MiningUtils { try { aEndAsteroids = ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "mEndAsteroid").getBoolean(x); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { aEndAsteroids = false; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java index dde785cee6..aeeb4ae5be 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java @@ -39,7 +39,7 @@ public class PollutionUtils { return mPollution.getBoolean(GT_Pollution); } } - } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { } return false; } @@ -53,16 +53,16 @@ public class PollutionUtils { if (mAddPollution != null) { mAddPollution.invoke(null, te, pollutionValue); } - Class GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("addPollution", IGregTechTileEntity.class, int.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "addPollution", IGregTechTileEntity.class, int.class); if (addPollution != null) { mAddPollution = addPollution; addPollution.invoke(null, te, pollutionValue); return true; } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return false; @@ -92,16 +92,16 @@ public class PollutionUtils { mAddPollution2.invoke(null, aChunk, pollutionValue); return true; } - Class GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("addPollution", Chunk.class, int.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "addPollution", Chunk.class, int.class); if (addPollution != null) { mAddPollution2 = addPollution; mAddPollution2.invoke(null, aChunk, pollutionValue); return true; } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return false; @@ -128,15 +128,15 @@ public class PollutionUtils { if (mGetPollution != null) { mGetPollution.invoke(null, te); } - Class GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("getPollution", IGregTechTileEntity.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "getPollution", IGregTechTileEntity.class); if (addPollution != null) { mGetPollution = addPollution; return (int) addPollution.invoke(null, te); } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return 0; @@ -151,15 +151,15 @@ public class PollutionUtils { if (mGetPollution2 != null) { mGetPollution2.invoke(null, te); } - Class GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("getPollution", Chunk.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "getPollution", Chunk.class); if (addPollution != null) { mGetPollution2 = addPollution; return (int) addPollution.invoke(null, te); } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return 0; diff --git a/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java deleted file mode 100644 index 99a9bf2fa9..0000000000 --- a/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java +++ /dev/null @@ -1,32 +0,0 @@ -package gtPlusPlus.core.util.reflect; - -import java.lang.reflect.Field; - -import cpw.mods.fml.common.SidedProxy; - -public class ClientProxyFinder { - - public static Object getInstance(final Object modInstance) throws ReflectiveOperationException { - for(final Field field : modInstance.getClass().getDeclaredFields()) { - if(field.isAnnotationPresent(SidedProxy.class)) { - final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); - final Object fieldValue = field.get(modInstance); - try { - final Class clientSideClass = Class.forName(sidedProxy.clientSide()); - if(clientSideClass.isAssignableFrom(fieldValue.getClass())) { - final Object clientProxy = clientSideClass.cast(fieldValue); - //do what you want with client proxy instance - return clientProxy; - } - - } catch (final NoClassDefFoundError err) { - //its server side - return null; - } - break; - } - } - return null; - } - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java index 85599e4695..d22fafb37b 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java @@ -12,7 +12,7 @@ public class ProxyFinder { final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); final Object fieldValue = field.get(modInstance); try { - final Class serverSideClass = Class.forName(sidedProxy.serverSide()); + final Class serverSideClass = ReflectionUtils.getClass(sidedProxy.serverSide()); if(serverSideClass.isAssignableFrom(fieldValue.getClass())) { final Object serverProxy = serverSideClass.cast(fieldValue); //do what you want with server proxy instance @@ -35,7 +35,7 @@ public class ProxyFinder { final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); final Object fieldValue = field.get(modInstance); try { - final Class clientSideClass = Class.forName(sidedProxy.clientSide()); + final Class clientSideClass = ReflectionUtils.getClass(sidedProxy.clientSide()); if(clientSideClass.isAssignableFrom(fieldValue.getClass())) { final Object clientProxy = clientSideClass.cast(fieldValue); //do what you want with client proxy instance diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index dee9d76a4c..4ade8b1096 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -1,110 +1,216 @@ package gtPlusPlus.core.util.reflect; import java.io.IOException; -import java.lang.reflect.*; -import java.net.URL; -import java.util.HashSet; -import java.util.Scanner; - -import org.apache.commons.lang3.reflect.FieldUtils; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.LinkedHashMap; +import java.util.Map; import com.google.common.reflect.ClassPath; -import net.minecraft.client.Minecraft; - -import gregtech.GT_Mod; -import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; public class ReflectionUtils { - public static Field getField(final Class clazz, final String fieldName) throws NoSuchFieldException { - try { - Field k = clazz.getDeclaredField(fieldName); - makeAccessible(k); - //Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); - return k; - } catch (final NoSuchFieldException e) { - final Class superClass = clazz.getSuperclass(); - if (superClass == null) { - //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+"."); - throw e; - } - //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+". Trying super class."); - return getField(superClass, fieldName); + public static Map mCachedClasses = new LinkedHashMap(); + public static Map mCachedMethods = new LinkedHashMap(); + public static Map mCachedFields = new LinkedHashMap(); + + private static class CachedMethod { + + private final boolean STATIC; + private final Method METHOD; + + public CachedMethod(Method aMethod, boolean isStatic) { + METHOD = aMethod; + STATIC = isStatic; + } + + public Method get() { + return METHOD; + } + + public boolean type() { + return STATIC; } + } - public static void makeAccessible(final Field field) { - if (!Modifier.isPublic(field.getModifiers()) || - !Modifier.isPublic(field.getDeclaringClass().getModifiers())) - { - field.setAccessible(true); + private static class CachedField { + + private final boolean STATIC; + private final Field FIELD; + + public CachedField(Field aField, boolean isStatic) { + FIELD = aField; + STATIC = isStatic; + } + + public Field get() { + return FIELD; + } + + public boolean type() { + return STATIC; } + } - //Some Reflection utils - http://stackoverflow.com/questions/14374878/using-reflection-to-set-an-object-property - @SuppressWarnings("unchecked") - public static V getField(final Object object, final String fieldName) { - Class clazz = object.getClass(); - while (clazz != null) { - try { - final Field field = clazz.getDeclaredField(fieldName); - field.setAccessible(true); - return (V) field.get(object); - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("getField("+object.toString()+", "+fieldName+") failed."); - clazz = clazz.getSuperclass(); - } catch (final Exception e) { - Logger.REFLECTION("getField("+object.toString()+", "+fieldName+") failed."); - throw new IllegalStateException(e); + private static boolean cacheClass(Class aClass) { + if (aClass == null) { + return false; + } + Class y = mCachedClasses.get(aClass.getCanonicalName()); + if (y == null) { + mCachedClasses.put(aClass.getCanonicalName(), aClass); + return true; + } + return false; + } + + private static boolean cacheMethod(Method aMethod) { + if (aMethod == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aMethod.getModifiers()); + CachedMethod y = mCachedMethods.get(aMethod.getName()+"."+aMethod.getParameterTypes().toString()); + if (y == null) { + mCachedMethods.put(aMethod.getName()+"."+aMethod.getParameterTypes().toString(), new CachedMethod(aMethod, isStatic)); + return true; + } + return false; + } + + private static boolean cacheField(Field aField) { + if (aField == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aField.getModifiers()); + CachedField y = mCachedFields.get(aField.getName()); + if (y == null) { + mCachedFields.put(aField.getName(), new CachedField(aField, isStatic)); + return true; + } + return false; + } + + + /** + * Returns a cached {@link Class} object. + * @param aClassCanonicalName - The canonical name of the underlying class. + * @return - Valid, {@link Class} object, or {@link null}. + */ + public static Class getClass(String aClassCanonicalName) { + Class y = mCachedClasses.get(aClassCanonicalName); + if (y == null) { + y = getClass_Internal(aClassCanonicalName); + if (y != null) { + cacheClass(y); } } - return null; + return y; } - public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { - Class clazz = object.getClass(); - while (clazz != null) { + + /** + * Returns a cached {@link Method} object. + * @param aClass - Class containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @param aTypes - Varags Class Types for {@link Method}'s constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { + String aMethodKey = aTypes.toString(); + CachedMethod y = mCachedMethods.get(aMethodName + "." + aMethodKey); + if (y == null) { + Method u = getMethod_Internal(aClass, aMethodKey, aTypes); + if (u != null) { + cacheMethod(u); + return u; + } else { + return null; + } + } else { + return y.get(); + } + } + + + + /** + * Returns a cached {@link Field} object. + * @param aClass - Class containing the Method. + * @param aFieldName - Field name in {@link String} form. + * @return - Valid, non-final, {@link Field} object, or {@link null}. + */ + public static Field getField(final Class aClass, final String aFieldName) { + CachedField y = mCachedFields.get(aFieldName); + if (y == null) { + Field u; try { - final Field field = getField(clazz, fieldName); - if (field != null) { - setValue(object, field, fieldValue); - return true; + u = getField_Internal(aClass, aFieldName); + if (u != null) { + cacheField(u); + return u; } - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); - clazz = clazz.getSuperclass(); - } catch (final Exception e) { - Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); - throw new IllegalStateException(e); + } catch (NoSuchFieldException e) { } + return null; + + } else { + return y.get(); } - return false; } - - public static boolean becauseIWorkHard(){ - /* TODO: fix this stuff \u002a\u002f\u0066\u0069\u006e\u0061\u006c\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u003b\u0009\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u0043\u006c\u0069\u0065\u006e\u0074\u0050\u0072\u006f\u0078\u0079\u0046\u0069\u006e\u0064\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0047\u0054\u005f\u004d\u006f\u0064\u002e\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0029\u003b\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u0076\u0065\u004f\u0070\u0065\u0072\u0061\u0074\u0069\u006f\u006e\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0031\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u006f\u0062\u0074\u0061\u0069\u006e\u0065\u0064\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u006f\u0066\u0020\u0061\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0055\u0052\u004c\u0028\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002e\u006f\u0076\u0065\u0072\u006d\u0069\u006e\u0064\u0064\u006c\u0031\u002e\u0063\u006f\u006d\u002f\u0063\u006f\u006d\u002f\u0067\u0072\u0065\u0067\u006f\u0072\u0069\u0075\u0073\u0074\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002f\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0072\u006c\u0069\u0073\u0074\u002e\u0074\u0078\u0074\u0022\u0029\u002e\u006f\u0070\u0065\u006e\u0053\u0074\u0072\u0065\u0061\u006d\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0054\u0072\u0079\u0069\u006e\u0067\u0020\u0074\u006f\u0020\u0062\u0075\u0069\u006c\u0064\u0020\u0061\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0068\u0061\u0073\u004e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0074\u004e\u0061\u006d\u0065\u0020\u003d\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u006e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u003b\u000a\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u004d\u0079\u0073\u0065\u006c\u0066\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u0074\u0068\u0065\u0020\u0063\u0061\u0070\u0065\u0064\u0020\u0074\u0065\u0073\u0074\u0020\u0068\u0065\u0072\u006f\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0043\u004f\u0052\u0045\u002e\u0044\u0045\u0056\u0045\u004e\u0056\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0020\u003d\u0020\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u002e\u0067\u0065\u0074\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u0028\u0029\u002e\u0067\u0065\u0074\u0053\u0065\u0073\u0073\u0069\u006f\u006e\u0028\u0029\u002e\u0067\u0065\u0074\u0055\u0073\u0065\u0072\u006e\u0061\u006d\u0065\u0028\u0029\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u006f\u0075\u006e\u0064\u0020\u0022\u002b\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0074\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0061\u0064\u0064\u0069\u006e\u0067\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0069\u006e\u0020\u0063\u0075\u0072\u0072\u0065\u006e\u0074\u0020\u0065\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0063\u006c\u006f\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0067\u0065\u0074\u0074\u0069\u006e\u0067\u0020\u0074\u0068\u0065\u0020\u0077\u0065\u0062\u0020\u006c\u0069\u0073\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u0009\u0009\u000a\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0046\u0069\u0065\u006c\u0064\u0055\u0074\u0069\u006c\u0073\u002e\u0077\u0072\u0069\u0074\u0065\u0046\u0069\u0065\u006c\u0064\u0028\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u002c\u0020\u0022\u006d\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0022\u002c\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002c\u0020\u0074\u0072\u0075\u0065\u0029\u003b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064\u0020\u0068\u0061\u0073\u0068\u0073\u0065\u0074\u0020\u0062\u0061\u0063\u006b\u0020\u0069\u006e\u0074\u006f\u0020\u0074\u0068\u0065\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u002e\u0022\u0029\u003b\u0020\u0020\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0074\u0072\u0075\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u006f\u006e\u0020\u0069\u006e\u0074\u006f\u0020\u0061\u0063\u0074\u0069\u0076\u0065\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u002f\u002a */ + + /** + * Returns a cached {@link Field} object. + * @param aInstance - {@link Object} to get the field instance from. + * @param aFieldName - Field name in {@link String} form. + * @return - Valid, non-final, {@link Field} object, or {@link null}. + */ + public static T getField(final Object aInstance, final String aFieldName) { + try { + return (T) getField(aInstance.getClass(), aFieldName).get(aInstance); + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } } + + + + /* + * Utility Functions + */ + public static boolean doesClassExist(final String classname) { - boolean exists = true; - try { - // Load any class that should be present if driver's available - Class.forName(classname); - } catch (final ClassNotFoundException e) { - // Driver is not available - exists = false; + return isClassPresent(classname); + } + + public static void makeFieldAccessible(final Field field) { + if (!Modifier.isPublic(field.getModifiers()) || + !Modifier.isPublic(field.getDeclaringClass().getModifiers())) + { + field.setAccessible(true); + } + } + + public static void makeMethodAccessible(final Method field) { + if (!Modifier.isPublic(field.getModifiers()) || + !Modifier.isPublic(field.getDeclaringClass().getModifiers())) + { + field.setAccessible(true); } - return exists; } /** * Get the method name for a depth in call stack.
* Utility function * @param depth depth in the call stack (0 means current method, 1 means call method, ...) - * @return method name + * @return Method name */ public static String getMethodName(final int depth) { final StackTraceElement[] ste = new Throwable().getStackTrace(); @@ -114,42 +220,60 @@ public class ReflectionUtils { /** - * Allows to change the state of an immutable instance. Huh?!? + * + * @param aPackageName - The full {@link Package} name in {@link String} form. + * @return - {@link Boolean} object. True if loaded > 0 classes. */ - public static void setFieldValue(Class clazz, String fieldName, Object newValue) throws Exception { - Field nameField = getField(clazz, fieldName); - setValue(clazz, nameField, newValue); - } + public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { + ClassLoader classLoader = ReflectionUtils.class.getClassLoader(); + int loaded = 0; + try { + ClassPath path = ClassPath.from(classLoader); + for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { + Class clazz = Class.forName(info.getName(), true, classLoader); + if (clazz != null) { + loaded++; + Logger.INFO("Found "+clazz.getCanonicalName()+". ["+loaded+"]"); + } + } + } catch (ClassNotFoundException | IOException e) { - /** - * Allows to change the state of final statics. Huh?!? - */ - public static void setDefault(Class clazz, String fieldName, Object newValue) throws Exception { - Field staticField = clazz.getDeclaredField(fieldName); - setValue(null, staticField, newValue); + } + + return loaded > 0; } + - /** - * - * Set the value of a field reflectively. - */ - protected static void setValue(Object owner, Field field, Object value) throws Exception { - makeModifiable(field); - field.set(owner, value); + public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { + Class clazz = object.getClass(); + while (clazz != null) { + try { + final Field field = getField(clazz, fieldName); + if (field != null) { + setFieldValue_Internal(object, field, fieldValue); + return true; + } + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); + clazz = clazz.getSuperclass(); + } catch (final Exception e) { + Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); + throw new IllegalStateException(e); + } + } + return false; } + /** - * Force the field to be modifiable and accessible. + * Allows to change the state of an immutable instance. Huh?!? */ - protected static void makeModifiable(Field nameField) throws Exception { - nameField.setAccessible(true); - int modifiers = nameField.getModifiers(); - Field modifierField = nameField.getClass().getDeclaredField("modifiers"); - modifiers = modifiers & ~Modifier.FINAL; - modifierField.setAccessible(true); - modifierField.setInt(nameField, modifiers); + public static void setFinalFieldValue(Class clazz, String fieldName, Object newValue) throws Exception { + Field nameField = getField(clazz, fieldName); + setFieldValue_Internal(clazz, nameField, newValue); } + @Deprecated public static void setFinalStatic(Field field, Object newValue) throws Exception { field.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); @@ -257,14 +381,55 @@ public class ReflectionUtils { Logger.REFLECTION("Invoke failed or did something wrong."); return null; } + + + + + + + + + + + + + + + + + + + + /* - * @ if (isPresent("com.optionaldependency.DependencyClass")) { // This - * block will never execute when the dependency is not present // There is + * Internal Magic that probably should not get exposed. + */ + + + private static Field getField_Internal(final Class clazz, final String fieldName) throws NoSuchFieldException { + try { + Field k = clazz.getDeclaredField(fieldName); + makeFieldAccessible(k); + //Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); + return k; + } catch (final NoSuchFieldException e) { + final Class superClass = clazz.getSuperclass(); + if (superClass == null) { + //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+"."); + throw e; + } + //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+". Trying super class."); + return getField_Internal(superClass, fieldName); + } + } + + /** + * if (isPresent("com.optionaldependency.DependencyClass")) || + * This block will never execute when the dependency is not present. There is * therefore no more risk of code throwing NoClassDefFoundException. - * executeCodeLinkingToDependency(); } */ - public static boolean isPresent(final String className) { + private static boolean isClassPresent(final String className) { try { Class.forName(className); return true; @@ -274,7 +439,6 @@ public class ReflectionUtils { } } - @SuppressWarnings("rawtypes") @Deprecated public static Method getMethodViaReflection(final Class lookupClass, final String methodName, final boolean invoke) throws Exception { @@ -287,14 +451,7 @@ public class ReflectionUtils { return m; } - /** - * Removes final modifier & returns a {@link Method} object. - * @param aClass - Class containing the Method. - * @param aMethodName - Method's name in {@link String} form. - * @param aTypes - Varags Class Types for {@link Method}'s constructor. - * @return - Valid, non-final, {@link Method} object. - */ - public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { + private static Method getMethod_Internal(Class aClass, String aMethodName, Class... aTypes) { Method m = null; try { m = aClass.getDeclaredMethod(aMethodName, aTypes); @@ -308,10 +465,15 @@ public class ReflectionUtils { } } catch (Throwable t) { + try { + m = getMethodRecursively(aClass, aMethodName); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } } return m; } - + public static Method getMethodRecursively(final Class clazz, final String fieldName) throws NoSuchMethodException { try { Method k = clazz.getDeclaredMethod(fieldName); @@ -322,21 +484,11 @@ public class ReflectionUtils { if (superClass == null) { throw e; } - return getMethod(superClass, fieldName); - } - } - - public static void makeMethodAccessible(final Method field) { - if (!Modifier.isPublic(field.getModifiers()) || - !Modifier.isPublic(field.getDeclaringClass().getModifiers())) - { - field.setAccessible(true); + return getMethod_Internal(superClass, fieldName); } - } - - + } - public static Class getNonPublicClass(final String className) { + private static Class getNonPublicClass(final String className) { Class c = null; try { c = Class.forName(className); @@ -377,7 +529,7 @@ public class ReflectionUtils { return null; } - public static Class getClassByName(String string) { + private static Class getClass_Internal(String string) { if (ReflectionUtils.doesClassExist(string)) { try { return Class.forName(string); @@ -389,23 +541,25 @@ public class ReflectionUtils { return null; } - public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { - ClassLoader classLoader = GTplusplus.class.getClassLoader(); - int loaded = 0; - try { - ClassPath path = ClassPath.from(classLoader); - for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { - Class clazz = Class.forName(info.getName(), true, classLoader); - if (clazz != null) { - loaded++; - Logger.INFO("Found "+clazz.getCanonicalName()+". ["+loaded+"]"); - } - } - } catch (ClassNotFoundException | IOException e) { - - } + /** + * + * Set the value of a field reflectively. + */ + private static void setFieldValue_Internal(Object owner, Field field, Object value) throws Exception { + makeModifiable(field); + field.set(owner, value); + } - return loaded > 0; + /** + * Force the field to be modifiable and accessible. + */ + private static void makeModifiable(Field nameField) throws Exception { + nameField.setAccessible(true); + int modifiers = nameField.getModifiers(); + Field modifierField = nameField.getClass().getDeclaredField("modifiers"); + modifiers = modifiers & ~Modifier.FINAL; + modifierField.setAccessible(true); + modifierField.setInt(nameField, modifiers); } diff --git a/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java b/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java index fe4897fd0d..140098ee06 100644 --- a/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java +++ b/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java @@ -72,7 +72,7 @@ extends WorldGen_GT { Field temp = ReflectionUtils.getField(GregTech_API.class, "sBlockStones"); tempBlock = temp.get(null); } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} mStoneTypes = (Block) tempBlock; } else { diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java index 88b6914ad2..6612ab703f 100644 --- a/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java +++ b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java @@ -842,7 +842,7 @@ extends TemplateRecipeHandler { if (sFields[u] == null) { if (u==0) { for (Field f : GT_OreDictUnificator.class.getDeclaredFields()) { - ReflectionUtils.makeAccessible(f); + ReflectionUtils.makeFieldAccessible(f); if (f.getName().equalsIgnoreCase("sUnificationTable")) { hasLooked = true; } diff --git a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java index 98e6d7ae1a..4dc5a15b4b 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java +++ b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java @@ -169,15 +169,10 @@ public class EntityBaseVillager extends EntityVillager { */ protected float getField_82191_bN() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); try { - v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); - try { - return v82191 != null ? v82191.getFloat(this) : 0f; - } catch (IllegalArgumentException | IllegalAccessException e) { - return 0f; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getFloat(this) : 0f; + } catch (IllegalArgumentException | IllegalAccessException e) { return 0f; } } @@ -190,15 +185,10 @@ public class EntityBaseVillager extends EntityVillager { } protected boolean getNeedsInitilization() { - Field v82191; + Field v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); try { - v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); - try { - return v82191 != null ? v82191.getBoolean(this) : false; - } catch (IllegalArgumentException | IllegalAccessException e) { - return false; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getBoolean(this) : false; + } catch (IllegalArgumentException | IllegalAccessException e) { return false; } } @@ -213,20 +203,16 @@ public class EntityBaseVillager extends EntityVillager { protected MerchantRecipeList getBuyingList() { Field v82191; MerchantRecipeList o; + v82191 = ReflectionUtils.getField(getClass(), "buyingList"); try { - v82191 = ReflectionUtils.getField(getClass(), "buyingList"); - try { - o = (MerchantRecipeList) v82191.get(this); - Logger.WARNING("Is BuyingList Valid? "+(v82191 != null)); - return v82191 != null ? o : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - return null; - } - } catch (NoSuchFieldException e1) { - e1.printStackTrace(); + o = (MerchantRecipeList) v82191.get(this); + Logger.WARNING("Is BuyingList Valid? " + (v82191 != null)); + return v82191 != null ? o : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); return null; } + } protected void setBuyingList(MerchantRecipeList f) { @@ -238,29 +224,19 @@ public class EntityBaseVillager extends EntityVillager { } protected Village getVillageObject() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "villageObj"); try { - v82191 = ReflectionUtils.getField(getClass(), "villageObj"); - try { - return v82191 != null ? (Village) v82191.get(this) : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (Village) v82191.get(this) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { return null; } } protected String getLastBuyingPlayer() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); try { - v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); - try { - return v82191 != null ? (String) v82191.get(this) : ""; - } catch (IllegalArgumentException | IllegalAccessException e) { - return ""; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (String) v82191.get(this) : ""; + } catch (IllegalArgumentException | IllegalAccessException e) { return ""; } } diff --git a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java index 6e7234297e..967647cff6 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java +++ b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java @@ -157,15 +157,10 @@ public class EntityNativeAustralian extends EntityVillager { */ protected float getField_82191_bN() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); try { - v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); - try { - return v82191 != null ? v82191.getFloat(this) : 0f; - } catch (IllegalArgumentException | IllegalAccessException e) { - return 0f; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getFloat(this) : 0f; + } catch (IllegalArgumentException | IllegalAccessException e) { return 0f; } } @@ -178,15 +173,10 @@ public class EntityNativeAustralian extends EntityVillager { } protected boolean getNeedsInitilization() { - Field v82191; + Field v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); try { - v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); - try { - return v82191 != null ? v82191.getBoolean(this) : false; - } catch (IllegalArgumentException | IllegalAccessException e) { - return false; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getBoolean(this) : false; + } catch (IllegalArgumentException | IllegalAccessException e) { return false; } } @@ -201,18 +191,13 @@ public class EntityNativeAustralian extends EntityVillager { protected MerchantRecipeList getBuyingList() { Field v82191; MerchantRecipeList o; + v82191 = ReflectionUtils.getField(getClass(), "buyingList"); try { - v82191 = ReflectionUtils.getField(getClass(), "buyingList"); - try { - o = (MerchantRecipeList) v82191.get(this); - Logger.WARNING("Is BuyingList Valid? "+(v82191 != null)); - return v82191 != null ? o : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - return null; - } - } catch (NoSuchFieldException e1) { - e1.printStackTrace(); + o = (MerchantRecipeList) v82191.get(this); + Logger.WARNING("Is BuyingList Valid? " + (v82191 != null)); + return v82191 != null ? o : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); return null; } } @@ -226,29 +211,19 @@ public class EntityNativeAustralian extends EntityVillager { } protected Village getVillageObject() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "villageObj"); try { - v82191 = ReflectionUtils.getField(getClass(), "villageObj"); - try { - return v82191 != null ? (Village) v82191.get(this) : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (Village) v82191.get(this) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { return null; } } protected String getLastBuyingPlayer() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); try { - v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); - try { - return v82191 != null ? (String) v82191.get(this) : ""; - } catch (IllegalArgumentException | IllegalAccessException e) { - return ""; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (String) v82191.get(this) : ""; + } catch (IllegalArgumentException | IllegalAccessException e) { return ""; } } diff --git a/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java b/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java index 232b6b6e87..45b8c9941b 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java +++ b/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java @@ -221,7 +221,7 @@ public class TileEntityGenericSpawner extends TileEntityMobSpawner { } } }*/ - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } return false; diff --git a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java index 2dcbe46056..8e7001903d 100644 --- a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java +++ b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java @@ -11,6 +11,7 @@ import gregtech.common.items.GT_MetaGenerated_Item_01; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class Preloader_GT_OreDict { @@ -33,9 +34,8 @@ public class Preloader_GT_OreDict { } } else { - try { - if (Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03") != null) { // 6/11/12/14/16/20/30-57/69-73/79-96 - final Class MetaItem03 = Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03"); + if (ReflectionUtils.doesClassExist("gregtech.common.items.GT_MetaGenerated_Item_03")) { // 6/11/12/14/16/20/30-57/69-73/79-96 + final Class MetaItem03 = ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03"); if (isInstanceOf(MetaItem03, bannedItem.getItem())) { if ((damageValue == 6) || (damageValue == 7) || (damageValue == 11) || (damageValue == 12) || (damageValue == 14) || (damageValue == 16) || (damageValue == 20) || (damageValue == 21) || (damageValue == 22)) { @@ -52,9 +52,6 @@ public class Preloader_GT_OreDict { } } } - } - catch (final ClassNotFoundException e) { - } } } } @@ -62,8 +59,8 @@ public class Preloader_GT_OreDict { //Mekanism Support - Let's not make Mek Osmium useful in GT anymore. if ((((bannedItem != null) && !LoadedMods.RedTech && (ItemUtils.getModId(bannedItem).toLowerCase().equals("mekanism"))) || (LoadedMods.Mekanism)) && !LoadedMods.RedTech){ //Circuits - if (Class.forName("mekanism.common.item.ItemControlCircuit") != null) { - final Class MekCircuit = Class.forName("mekanism.common.item.ItemControlCircuit"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemControlCircuit")) { + final Class MekCircuit = ReflectionUtils.getClass("mekanism.common.item.ItemControlCircuit"); if (isInstanceOf(MekCircuit, bannedItem.getItem())) { for (int r=0;r<4;r++){ if (bannedItem.getItemDamage() == r){ @@ -74,8 +71,8 @@ public class Preloader_GT_OreDict { } } //Ingots - if (Class.forName("mekanism.common.item.ItemIngot") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemIngot"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemIngot")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemIngot"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 1){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -84,8 +81,8 @@ public class Preloader_GT_OreDict { } } //Dirty Dust - if (Class.forName("mekanism.common.item.ItemDirtyDust") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemDirtyDust"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemDirtyDust")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemDirtyDust"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -94,8 +91,8 @@ public class Preloader_GT_OreDict { } } //Dust - if (Class.forName("mekanism.common.item.ItemDust") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemDust"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemDust")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemDust"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -104,8 +101,8 @@ public class Preloader_GT_OreDict { } } //Crystal - if (Class.forName("mekanism.common.item.ItemCrystal") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemCrystal"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemCrystal")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemCrystal"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -114,8 +111,8 @@ public class Preloader_GT_OreDict { } } //Shard - if (Class.forName("mekanism.common.item.ItemShard") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemShard"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemShard")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemShard"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -124,8 +121,8 @@ public class Preloader_GT_OreDict { } } //Clump - if (Class.forName("mekanism.common.item.ItemClump") != null) { - final Class MekIngot = Class.forName("mekanism.common.item.ItemClump"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemClump")) { + final Class MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemClump"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -134,8 +131,8 @@ public class Preloader_GT_OreDict { } } //Ores - if (Class.forName("mekanism.common.item.ItemBlockOre") != null) { - final Class MekOre = Class.forName("mekanism.common.item.ItemBlockOre"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemBlockOre")) { + final Class MekOre = ReflectionUtils.getClass("mekanism.common.item.ItemBlockOre"); if (isInstanceOf(MekOre, bannedItem.getItem()) || (bannedItem == ItemUtils.simpleMetaStack("Mekanism:OreBlock", 0, 1))) { if (bannedItem.getItemDamage() == 0){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java index 402a510a79..390289d162 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java @@ -204,7 +204,7 @@ public class Preloader_ClassTransformer2 { } return new ArrayList(Arrays.asList(rStack)); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException a){ + catch (IllegalArgumentException | IllegalAccessException a){ Logger.REFLECTION("getDropsHack2"); a.printStackTrace(); } @@ -242,7 +242,7 @@ public class Preloader_ClassTransformer2 { Logger.INFO("Set NBT Tag Value to map."); } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } @@ -360,7 +360,7 @@ public class Preloader_ClassTransformer2 { Logger.INFO("Returning Invalid NBT data"); } } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException a){ + catch (IllegalArgumentException | IllegalAccessException a){ Logger.REFLECTION("getDropsHack2"); a.printStackTrace(); } diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java b/src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java new file mode 100644 index 0000000000..ce7d919431 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.bartcrops; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class HANDLER_CropsPlusPlus { + + public static void preInit(FMLPreInitializationEvent preinit) { + LoaderOfTheCrops.load(preinit); + } + + public static void init(FMLInitializationEvent init) { + //registerItems(); + } + + public static void postInit(FMLPostInitializationEvent postinit) { + LoaderOfTheCrops.register(); + LoaderOfTheCrops.registerBaseSeed(); + } +} diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java b/src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java new file mode 100644 index 0000000000..48813310d2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java @@ -0,0 +1,109 @@ +package gtPlusPlus.xmod.bartcrops; + +import java.util.ArrayList; +import java.util.List; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.bartcrops.crops.Crop_Hemp; +import ic2.api.crops.CropCard; +import ic2.api.crops.Crops; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Mostly borrowed from the Crops++ Crop Loader. + * @author Alkalus + */ + +public class LoaderOfTheCrops { + + private static List mHasCropObj = new ArrayList(); + private CropCard mCropObj; + private ItemStack mBaseSeed; + private static List mCropList = cropLoader(); + + public LoaderOfTheCrops(CropCard cropObj) { + this.mCropObj = cropObj; + } + + public LoaderOfTheCrops(CropCard cropObj, ItemStack baseseed) { + this.mCropObj = cropObj; + this.mBaseSeed = baseseed; + } + + public static CropCard cropUnpackerCC(LoaderOfTheCrops inp) { + return inp.mCropObj; + } + + private static ItemStack cropUnpackerCG(LoaderOfTheCrops inp) { + return inp.mBaseSeed; + } + + private static LoaderOfTheCrops cropHelper(CropCard cropObj) { + return new LoaderOfTheCrops(cropObj, ItemUtils.getItemStackOfAmountFromOreDict("crop" + cropObj.name(), 0)); + } + + public static final List cropLoader() { + List p = new ArrayList(); + + p.add(new LoaderOfTheCrops(new Crop_Hemp(), new ItemStack(Item.getItemById(111), 3))); + + return p; + } + + private static final List cropObjs() { + List p = new ArrayList(); + + for (int i = 0; i < mCropList.size(); ++i) { + p.add(cropUnpackerCC((LoaderOfTheCrops) mCropList.get(i))); + } + + return p; + } + + private static final List setBaseSeed() { + List p = new ArrayList(); + + for (int i = 0; i < mCropList.size(); ++i) { + p.add(cropUnpackerCG((LoaderOfTheCrops) mCropList.get(i))); + } + + return p; + } + + private static final List setnames() { + List s = new ArrayList(); + + for (int i = 0; i < mCropList.size(); ++i) { + s.add(((CropCard) cropObjs().get(i)).name()); + } + + return s; + } + + public static void load(FMLPreInitializationEvent preinit) { + for (int i = 0; i < mCropList.size(); ++i) { + mHasCropObj.add(true); + } + } + + public static void register() { + for (int i = 0; i < mCropList.size(); ++i) { + if ((Boolean) mHasCropObj.get(i) && cropObjs().get(i) != null) { + Crops.instance.registerCrop((CropCard) cropObjs().get(i)); + } + } + } + + public static void registerBaseSeed() { + List baseseed = new ArrayList(setBaseSeed()); + + for (int i = 0; i < mCropList.size(); ++i) { + if (baseseed.get(i) != null && cropObjs().get(i) != null) { + Crops.instance.registerBaseSeed((ItemStack) baseseed.get(i), (CropCard) cropObjs().get(i), 1, 1, 1, 1); + } + } + + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java new file mode 100644 index 0000000000..cddce7beb4 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java @@ -0,0 +1,37 @@ +package gtPlusPlus.xmod.bartcrops.abstracts; + +import gtPlusPlus.core.lib.CORE; +import ic2.api.crops.ICropTile; + +public abstract class BaseAestheticCrop extends BaseHarvestableCrop { + + public int tier() { + return 1; + } + + public int stat(int n) { + switch (n) { + case 0 : + return 0; + case 1 : + return 0; + case 2 : + return 0; + case 3 : + return 4; + case 4 : + return 0; + default : + return 0; + } + } + + public int growthDuration(ICropTile crop) { + return CORE.DEBUG ? 1 : 225; + } + + public byte getSizeAfterHarvest(ICropTile crop) { + return 1; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java new file mode 100644 index 0000000000..ca2a044564 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java @@ -0,0 +1,56 @@ +package gtPlusPlus.xmod.bartcrops.abstracts; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import ic2.api.crops.CropCard; +import ic2.api.crops.ICropTile; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import speiger.src.crops.api.ICropCardInfo; + +public abstract class BaseCrop extends CropCard implements ICropCardInfo { + @SideOnly(Side.CLIENT) + public void registerSprites(IIconRegister iconRegister) { + this.textures = new IIcon[this.maxSize()]; + + for (int i = 1; i <= this.textures.length; ++i) { + this.textures[i - 1] = iconRegister.registerIcon(CORE.MODID+":crop/blockCrop." + this.name() + "." + i); + } + + } + + public float dropGainChance() { + return (float) (Math.pow(0.95D, (double) ((float) this.tier())) * (double) 1f); + } + + public boolean canCross(ICropTile crop) { + return crop.getSize() == this.maxSize(); + } + + public int getrootslength(ICropTile crop) { + return 3; + } + + public String discoveredBy() { + return "Alkalus"; + } + + public String owner() { + return "Gtplusplus"; + } + + public List getCropInformation() { + List ret = new ArrayList(); + ret.add(this.attributes().toString()); + return ret; + } + + public ItemStack getDisplayItem(CropCard card) { + return ItemUtils.getItemStackOfAmountFromOreDict("crop" + this.name(), 0); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java new file mode 100644 index 0000000000..fee6cf654c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java @@ -0,0 +1,69 @@ +package gtPlusPlus.xmod.bartcrops.abstracts; + +import gtPlusPlus.core.lib.CORE; +import ic2.api.crops.ICropTile; + +public abstract class BaseHarvestableCrop extends BaseCrop { + + public int tier() { + return 2; + } + + public int stat(int n) { + switch (n) { + case 0 : + return 0; + case 1 : + return 4; + case 2 : + return 0; + case 3 : + return 4; + case 4 : + return 0; + default : + return 0; + } + } + + public boolean canGrow(ICropTile crop) { + return crop.getSize() < 3; + } + + public int getOptimalHavestSize(ICropTile crop) { + return 3; + } + + public boolean canBeHarvested(ICropTile crop) { + return crop.getSize() == 3; + } + + public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) { + return (int) ((double) humidity * 1.2D + (double) nutrients * 0.9D + (double) air * 0.9D); + } + + public int growthDuration(ICropTile crop) { + short r; + if (CORE.DEBUG) { + r = 1; + } else if (crop.getSize() == 2) { + r = 200; + } else { + r = 700; + } + + return r; + } + + public byte getSizeAfterHarvest(ICropTile crop) { + return 2; + } + + public int maxSize() { + return 3; + } + + public String discoveredBy() { + return "Alkalus"; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java b/src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java new file mode 100644 index 0000000000..a921182d66 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java @@ -0,0 +1,56 @@ +package gtPlusPlus.xmod.bartcrops.crops; + +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.bartcrops.abstracts.BaseAestheticCrop; +import ic2.api.crops.ICropTile; +import net.minecraft.item.ItemStack; + +public class Crop_Hemp extends BaseAestheticCrop { + + public int tier() { + return 2; + } + + public String name() { + return "Hemp"; + } + + public String discoveredBy() { + return "Alkalus"; + } + + public int growthDuration(ICropTile crop) { + int ret = 550; + + /*if (crop.isBlockBelow(Blocks.dirt) || crop.isBlockBelow(Blocks.flowing_water)) { + ret = 225; + }*/ + + if (CORE.DEBUG) { + ret = 1; + } + + return ret; + } + + public String[] attributes() { + return new String[]{"Green", "Soil", "Orange"}; + } + + public ItemStack getGain(ICropTile crop) { + + ItemStack ret = this.getDisplayItem(); + if (MathUtils.randInt(0, 10) > 8) { + ret = ItemUtils.getSimpleStack(ModItems.itemRope, MathUtils.randInt(1, 3)); + } + + return ret; + } + + public ItemStack getDisplayItem() { + return ItemUtils.getSimpleStack(ModItems.itemRope, 0); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java index 6d50f64e6d..5b3210d58a 100644 --- a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java +++ b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java @@ -12,6 +12,7 @@ import gregtech.api.enums.Materials; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.eio.material.MaterialEIO; import net.minecraftforge.event.entity.player.ItemTooltipEvent; @@ -30,11 +31,10 @@ public class HandlerTooltip_EIO { //If it is, reflect in. if (mIngot == null){ try { - oMainClass = Class.forName("crazypants.enderio.EnderIO"); - oIngotClass = Class.forName("crazypants.enderio.material.ItemAlloy"); + oMainClass = ReflectionUtils.getClass("crazypants.enderio.EnderIO"); + oIngotClass = ReflectionUtils.getClass("crazypants.enderio.material.ItemAlloy"); if (oMainClass != null && oIngotClass != null){ - Field oAlloyField = oMainClass.getDeclaredField("itemAlloy"); - oAlloyField.setAccessible(true); + Field oAlloyField = ReflectionUtils.getField(oMainClass, "itemAlloy"); Object oAlloy = oAlloyField.get(oMainClass); if (oAlloy != null){ if (oIngotClass.isInstance(oAlloy) || Item.class.isInstance(oAlloy)){ diff --git a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java index 1343bdc8af..05d00b06d9 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java +++ b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java @@ -45,14 +45,14 @@ public class HANDLER_FR { if (LoadedMods.Forestry){ Class oClass; try { - oClass = Class.forName("forestry.core.proxy.ProxyCommon"); + oClass = ReflectionUtils.getClass("forestry.core.proxy.ProxyCommon"); Object oProxy = ReflectionUtils.getField(oClass, "common"); - if (oProxy != null && oClass.isInstance(oProxy)){ - Method mParticles = oClass.getDeclaredMethod("addBlockDestroyEffects", World.class, int.class, int.class, int.class, Block.class, int.class); + if (oProxy != null && oClass.isInstance(oProxy)){ + Method mParticles = ReflectionUtils.getMethod(oClass, "addBlockDestroyEffects", World.class, int.class, int.class, int.class, Block.class, int.class); mParticles.invoke(oProxy, world, x, y, z, block, 0); } } - catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java index d842c37fcd..b36508f6aa 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java @@ -864,7 +864,7 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { Enum gtBeeEnumObject = Enum.valueOf(gtBeeTypes, name); Field gtBeesField = FieldUtils.getDeclaredField(gtBeeTypes, "species", true); gtBeesField.setAccessible(true); - ReflectionUtils.makeAccessible(gtBeesField); + ReflectionUtils.makeFieldAccessible(gtBeesField); Object beeType = gtBeesField.get(gtBeeEnumObject); return (IAlleleBeeSpecies) beeType; } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java index 29ece40c3d..bb360d5a87 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java @@ -141,7 +141,7 @@ public class GTPP_Bees { Class gtCombEnumClass = Class.forName("gregtech.common.items.CombType"); Field gtCombs = FieldUtils.getDeclaredField(gtBees, "combs", true); gtCombs.setAccessible(true); - ReflectionUtils.makeAccessible(gtCombs); + ReflectionUtils.makeFieldAccessible(gtCombs); Enum gtCombTypeSlag = Enum.valueOf(gtCombEnumClass, "SLAG"); Enum gtCombTypeStone = Enum.valueOf(gtCombEnumClass, "STONE"); Object oCombObject = gtCombs.get(null); diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java index 9075666b8b..58331c4300 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java @@ -8,6 +8,7 @@ import net.minecraft.item.Item; import gtPlusPlus.core.item.chemistry.RocketFuels; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.asm.AsmConfig; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fluids.Fluid; @@ -21,11 +22,11 @@ public class HandlerTooltip_GC { @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { - if (LoadedMods.GalacticraftCore) { + if (LoadedMods.GalacticraftCore && AsmConfig.enableGcFuelChanges) { if (mBlock == null) { try { - Class GCBlocks = Class.forName("micdoodle8.mods.galacticraft.core.blocks.GCBlocks"); + Class GCBlocks = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.GCBlocks"); if (GCBlocks != null) { oMainClass = GCBlocks; diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java b/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java index 3b9633b21d..aafa9ef9a1 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java @@ -4,12 +4,11 @@ import java.util.List; import com.google.common.collect.Lists; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import micdoodle8.mods.galacticraft.api.prefab.core.BlockMetaPair; import micdoodle8.mods.galacticraft.api.prefab.world.gen.BiomeDecoratorSpace; import micdoodle8.mods.galacticraft.api.prefab.world.gen.MapGenBaseMeta; -import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedCreeper; -import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSkeleton; -import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSpider; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -46,20 +45,37 @@ public abstract class ChunkProviderGalactic extends ChunkProviderGalaxyLakes { } protected SpawnListEntry[] getMonsters() { - SpawnListEntry skele = new SpawnListEntry(EntityEvolvedSkeleton.class, 100, 4, 4); - SpawnListEntry creeper = new SpawnListEntry(EntityEvolvedCreeper.class, 100, 4, 4); - SpawnListEntry spider = new SpawnListEntry(EntityEvolvedSpider.class, 100, 4, 4); + + Class aSkele = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSkeleton"); + Class aCreeper = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.entities.EntityEvolvedCreeper"); + Class aSpider = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSpider"); + Class aEnderman = ReflectionUtils.getClass("galaxyspace.SolarSystem.planets.pluto.entities.EntityEvolvedEnderman"); + + SpawnListEntry skele; + SpawnListEntry creeper; + SpawnListEntry spider; + SpawnListEntry enderman; - Class aEnderman; - try { - aEnderman = Class.forName("galaxyspace.SolarSystem.planets.pluto.entities.EntityEvolvedEnderman"); - if (aEnderman != null) { - SpawnListEntry enderman = new SpawnListEntry(aEnderman, 100, 4, 4); - return new SpawnListEntry[] { skele, creeper, spider, enderman }; - } - } catch (ClassNotFoundException e) {} + AutoMap aMobs = new AutoMap(); - return new SpawnListEntry[] { skele, creeper, spider }; + if (aSkele != null) { + skele = new SpawnListEntry(aSkele, 100, 4, 4); + aMobs.put(skele); + } + if (aCreeper != null) { + creeper = new SpawnListEntry(aCreeper, 100, 4, 4); + aMobs.put(creeper); + } + if (aSpider != null) { + spider = new SpawnListEntry(aSpider, 100, 4, 4); + aMobs.put(spider); + } + if (aEnderman != null) { + enderman = new SpawnListEntry(aEnderman, 100, 4, 4); + aMobs.put(enderman); + } + + return aMobs.toArray(); } public void onPopulate(IChunkProvider arg0, int arg1, int arg2) { diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java b/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java index 94dc2d0cc0..f237aed335 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java @@ -26,11 +26,11 @@ public class GalacticUtils { Class a1, a2, a3, a4, a5; Method m1, m2, m3; try { - a1 = Class.forName("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket"); - a2 = Class.forName("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad"); - a3 = Class.forName("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler"); - a4 = Class.forName("micdoodle8.mods.galacticraft.api.entity.IDockable"); - a5 = Class.forName("micdoodle8.mods.galacticraft.api.entity.IFuelable"); + a1 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket"); + a2 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad"); + a3 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler"); + a4 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IDockable"); + a5 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IFuelable"); m1 = ReflectionUtils.getMethod(a1, "getRocketTier"); m2 = ReflectionUtils.getMethod(a2, "getDockedEntity"); m3 = ReflectionUtils.getMethod(a3, "getDockedEntity"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java index 2b7f44be59..0d4d8b6cdd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java @@ -184,7 +184,7 @@ public class GT_MetaTileEntity_Hatch_Naquadah extends GT_MetaTileEntity_Hatch_In a2 = F2.getByte(this); } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException n) {} + catch (IllegalArgumentException | IllegalAccessException n) {} int textureIndex = a1 | a2 << 7; byte texturePointer = (byte) (a1 & 127); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java index 30c1bc2b29..bed80d8d13 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -50,11 +50,9 @@ public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Outp //Get all Plasmas, but the easiest way to do this is to just ask the Fluid Registry what exists and filter through them lazily. Field fluidNameCache; - try { - fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); - } catch (NoSuchFieldException e) { - fluidNameCache = null; - } + + fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); + AutoMap mValidPlasmaNameCache = new AutoMap(); if (fluidNameCache != null) { try { @@ -199,7 +197,7 @@ public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Outp a2 = F2.getByte(this); } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException n) {} + catch (IllegalArgumentException | IllegalAccessException n) {} int textureIndex = a1 | a2 << 7; byte texturePointer = (byte) (a1 & 127); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index b55157e763..7103c81980 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -482,9 +482,9 @@ GT_MetaTileEntity_MultiBlockBase { public void log(String s) { boolean isDebugLogging = CORE.DEBUG; - boolean reset = false; + boolean reset = true; if (aLogger == null || reset) { - if (isDebugLogging) { + if (true) { try { aLogger = Logger.class.getMethod("INFO", String.class); } catch (NoSuchMethodException | SecurityException e) {} @@ -1141,7 +1141,8 @@ GT_MetaTileEntity_MultiBlockBase { if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input){ ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = null; - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = aMap; + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = aMap; + log("Remapped Input Hatch to "+aMap.mNEIName); } else { ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = null; @@ -1173,7 +1174,6 @@ GT_MetaTileEntity_MultiBlockBase { * Enable Texture Casing Support if found in GT 5.09 */ - @SuppressWarnings("deprecation") public boolean updateTexture(final IGregTechTileEntity aTileEntity, int aCasingID){ final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) { @@ -1194,7 +1194,7 @@ GT_MetaTileEntity_MultiBlockBase { if (aMetaTileEntity == null) { return false; } - Method mProper = Class.forName("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch").getDeclaredMethod("updateTexture", int.class); + Method mProper = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); if (mProper != null){ if (GT_MetaTileEntity_Hatch.class.isInstance(aMetaTileEntity)){ mProper.setAccessible(true); @@ -1202,7 +1202,6 @@ GT_MetaTileEntity_MultiBlockBase { log("Good Method Call for updateTexture."); return true; } - } else { log("Bad Method Call for updateTexture."); @@ -1223,7 +1222,7 @@ GT_MetaTileEntity_MultiBlockBase { log("updateTexture returning false. 1"); return false; } - catch (NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { log("updateTexture returning false."); log("updateTexture returning false. 2"); e.printStackTrace(); @@ -1277,15 +1276,12 @@ GT_MetaTileEntity_MultiBlockBase { @SuppressWarnings("rawtypes") public boolean isThisHatchMultiDynamo(Object aMetaTileEntity){ Class mDynamoClass; - try { - mDynamoClass = Class.forName("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); + mDynamoClass = ReflectionUtils.getClass("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); if (mDynamoClass != null){ if (mDynamoClass.isInstance(aMetaTileEntity)){ return true; } } - } - catch (ClassNotFoundException e) {} return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java index 88b4c7bc99..c5554a6679 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java @@ -17,6 +17,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.init.Blocks; @@ -124,10 +125,11 @@ public class MultiblockLayer { GT_MetaTileEntity_Hatch.class }; } - else { - try { + else { + Class aDataHatch = ReflectionUtils.getClass("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess"); + if (aDataHatch != null) { aHatchTypeClass = new Class[] { - Class.forName("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess"), + aDataHatch, GT_MetaTileEntity_Hatch_Dynamo.class, GT_MetaTileEntity_Hatch_Energy.class, GT_MetaTileEntity_Hatch_Input.class, @@ -138,7 +140,7 @@ public class MultiblockLayer { GT_MetaTileEntity_Hatch_OutputBus.class, GT_MetaTileEntity_Hatch.class }; - } catch (ClassNotFoundException e) { + } else { aHatchTypeClass = new Class[] { GT_MetaTileEntity_Hatch_Dynamo.class, GT_MetaTileEntity_Hatch_Energy.class, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java index d5327a6a99..3e0084139e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java @@ -38,12 +38,9 @@ public class GregtechOreDictUnificator { private static boolean mRunThroughTheList = true; static { - try { if (ReflectionUtils.getField(GT_OreDictUnificator.class, "sUnificationTable") == null) { GregTech_API.sItemStackMappings.add(sUnificationTable); } - } - catch (NoSuchFieldException e) {} } /** diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 5eee77e065..6b4bab9e26 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -5,6 +5,7 @@ import static gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow.mOverfl import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -18,11 +19,16 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; import gregtech.common.GT_Proxy; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -30,6 +36,9 @@ import gtPlusPlus.api.objects.data.ObjMap; import gtPlusPlus.api.objects.minecraft.FormattedTooltipString; import gtPlusPlus.core.handler.AchievementHandler; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.reflect.ProxyFinder; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; @@ -104,6 +113,120 @@ public class Meta_GT_Proxy { mAssemblyAchievements = new AchievementHandler(); } + public static boolean generatePlasmaRecipesForAdvVacFreezer() { + + AutoMap aFreezerMapRebaked = new AutoMap(); + AutoMap aRemovedRecipes = new AutoMap(); + + //Find recipes containing Plasma and map them + for (Recipe_GT y : Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList) { + if (y.mFluidInputs.length > 0) { + for (FluidStack r : y.mFluidInputs) { + if (r.getUnlocalizedName().toLowerCase().contains("plasma")) { + aRemovedRecipes.put(y); + continue; + } + } + aFreezerMapRebaked.put(y); + } + } + + AutoMap aNewRecipes = new AutoMap(); + int aAtomicMass = 0; + int aAtomicTier = 0; + + final FluidStack NULL_PLASMA = Materials._NULL.getPlasma(1); + + for (String s : ELEMENT.NAMES) { + + aAtomicMass++; + aAtomicTier = (aAtomicMass/30)+1; + FluidStack aMoltenFluid = null; + FluidStack aPlasma = null; + + //Try Get Material via Gregtech + Materials aGregMaterial = MaterialUtils.getMaterial(s); + if (aGregMaterial != null) { + aMoltenFluid = aGregMaterial.getMolten(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getFluid(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getGas(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getSolid(1); + } + } + } + aPlasma = aGregMaterial.getPlasma(100); + } + + //Just wildcard values + if (aMoltenFluid == null || aPlasma == null) { + if (aMoltenFluid == null) { + aMoltenFluid = FluidUtils.getWildcardFluidStack(s, 1); + } + if (aPlasma == null) { + aPlasma = FluidUtils.getFluidStack("plasma."+s.toLowerCase(), 1); + } + } + + //Skip this material + if (aMoltenFluid == null || aPlasma == null || aPlasma.isFluidEqual(NULL_PLASMA)) { + Logger.INFO("Could not generate Advanced Vacuum Freezer recipe. Cooling "+s+" plasma. Molten Form Exists? "+(aMoltenFluid != null)+" | Plasma Exists? "+(aPlasma != null)); + continue; + } + else { + //Build a new plasma recipe + int aTotalTickTime = (20 * 1 + (aAtomicMass)); + Recipe_GT aTempRecipe = new Recipe_GT(true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {10000}, + new FluidStack[] { + aPlasma, + FluidUtils.getFluidStack("cryotheum", aTotalTickTime) + }, + new FluidStack[] { + aMoltenFluid + }, + aTotalTickTime, + (int) GT_Values.V[4+aAtomicTier], + aAtomicMass); + + //Add it to the map if it's valid + if (aTempRecipe != null) { + aNewRecipes.put(aTempRecipe); + } + } + + } + + + //Add the new recipes to the map we will rebake over the original + for (Recipe_GT w : aNewRecipes) { + aFreezerMapRebaked.put(w); + } + + //Best not touch the original map if we don't have a valid map to override it with. + if (aFreezerMapRebaked.size() > 0) { + + int aOriginalCount = Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.size(); + + //Empty the original map + Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.clear(); + + //Rebake the real map + for (Recipe_GT w : aFreezerMapRebaked) { + Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.add(w); + } + + return Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.size() >= aOriginalCount; + } + + return false; + } + public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { if (aMeta == 12) { return Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower(); @@ -279,7 +402,7 @@ public class Meta_GT_Proxy { if (proxyGT != null && proxyGT instanceof GT_Proxy) { try { return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } return null; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index 63581af16c..1604cc5acd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -108,11 +108,7 @@ public class StaticFields59 { } public static Field getField(Class a, String b) { - try { - return ReflectionUtils.getField(a, b); - } catch (NoSuchFieldException e) { - return null; - } + return ReflectionUtils.getField(a, b); } public static Method getMethod(Class a, String b, Class... params) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 0178bac4da..bda75be793 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -23,6 +23,7 @@ import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; import ic2.api.info.Info; import ic2.api.item.ElectricItem; @@ -291,12 +292,11 @@ public class ChargingHelper { } //Try get charge direct from NBT for GT and IC2 stacks - try { Logger.WARNING("3"); if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 - || Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03").isInstance(mTemp.getItem()) + || ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03").isInstance(mTemp.getItem()) || mTemp.getItem().getClass().getName().toLowerCase().equals(("gregtech.common.items.GT_MetaGenerated_Tool_01").toLowerCase())){ if (!NBTUtils.hasKey(mTemp, "GT.ItemCharge")){ if (!mTemp.getDisplayName().toLowerCase().contains("battery")){ @@ -314,10 +314,7 @@ public class ChargingHelper { } else if (mTemp.getItem() instanceof IElectricItem){ mitemCurrentCharge = NBTUtils.getLong(mTemp, "charge"); - } - } catch (ClassNotFoundException e) { - - } + } double mVoltageIncrease; if (mItemEuTLimit >= mVoltage){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 2bfb07ff4a..3c60ae664e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -321,14 +321,12 @@ public class TreeFarmHelper { return blockHumus; } else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ - try { - final Class humusClass = Class.forName("forestry.core.blocks.BlockSoil"); + final Class humusClass = ReflectionUtils.getClass("forestry.core.blocks.BlockSoil"); final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); if (humusClass != null){ blockHumus = Block.getBlockFromItem(humusStack.getItem()); return Block.getBlockFromItem(humusStack.getItem()); } - } catch (final ClassNotFoundException e) {} } return null; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index 411171a766..6b061c3704 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -285,7 +285,7 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { //Fusion Reactor MK4 Singularity GregtechItemList.Compressed_Fusion_Reactor.set(this.addItem(100, "Hypervisor Matrix (Fusion)", "A memory unit containing an RI (Restricted Intelligence)", new Object[0])); - CORE.RA.addCompressorRecipe(ItemList.FusionComputer_UV.get(9), GregtechItemList.Compressed_Fusion_Reactor.get(1), (int) GT_Values.V[7], (int) GT_Values.V[8]); + //NanoTubes GregtechItemList.NanoTube_Base_Substrate.set(this.addItem(101, "Silicon Base Substrate", "Used in the production of Carbon Nanotubes", new Object[0])); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java index 759378013c..c31a7c0758 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java @@ -221,7 +221,7 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { return r; } } - } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java index 1623e7cb54..de5d731dd5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java @@ -410,9 +410,13 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas //Time Counter this.mTotalRunTime++; - onRunningTick(null); + onRunningTick(null); - if (mRunningOnLoad && checkMultiblock(aBaseMetaTileEntity, mInventory[1])) { + boolean aFormCheck = (aTick % 100 == 0 ? checkMultiblock(aBaseMetaTileEntity, mInventory[1]) : true); + + + + if (mRunningOnLoad && aFormCheck) { this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); checkRecipe(mInventory[1]); } @@ -429,7 +433,7 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas mDischargeHatches.clear(); mControlCoreBus.clear(); mMultiDynamoHatches.clear(); - mMachine = checkMultiblock(aBaseMetaTileEntity, mInventory[1]); + mMachine = aFormCheck; } if (mStartUpCheck < 0) { if (mMachine) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java index b1e433e276..fc0cb85bac 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -459,7 +459,7 @@ public class GregtechMetaTileEntity_IndustrialFishingPond extends GregtechMeta_M ItemStack k = ItemUtils.getSimpleStack(t, 1); reflectiveFishMap.put(y, k); return t; - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } return null; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java index 1a19bc7b96..e6fecf5d18 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java @@ -1,23 +1,25 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import java.util.HashSet; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.CustomRecipeMap; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase { @@ -69,42 +71,30 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase @Override public String getCustomGUIResourceName() { - return "LFTR"; + return "MatterFabricator"; } + private static final GT_Recipe_Map mGregTypeRecipeMap = new GT_Recipe_Map(new HashSet(), "internal.recipe.fissionfuel", "Fission Fuel Processing", null, RES_PATH_GUI + "basicmachines/FissionFuel", 0, 0, 0, 4, 1, E, 1, E, true, true); + @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList tFluidList = getStoredFluids(); - int tFluidList_sS=tFluidList.size(); - for (int i = 0; i < tFluidList_sS - 1; i++) { - for (int j = i + 1; j < tFluidList_sS; j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); tFluidList_sS=tFluidList.size(); - } else { - tFluidList.remove(i--); tFluidList_sS=tFluidList.size(); - break; - } - } - } - } - if (tFluidList.size() > 1) { - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); - GT_Recipe tRecipe = CustomRecipeMap.sFissionFuelProcessing.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, GT_Values.V[4], tFluids, new ItemStack[]{}); - if (tRecipe == null) { - this.mLastRecipe = null; - return false; - } - if (tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[]{})) { - this.mLastRecipe = tRecipe; - this.mEUt = this.mLastRecipe.mEUt; - this.mMaxProgresstime = this.mLastRecipe.mDuration; - this.mEfficiencyIncrease = 10000; - this.mOutputFluids = this.mLastRecipe.mFluidOutputs; - return true; - } - } - return false; + public GT_Recipe_Map getRecipeMap() { + if (mGregTypeRecipeMap.mRecipeList.size() <= 0) { + for (GT_Recipe g : CustomRecipeMap.sFissionFuelProcessing.mRecipeList) { + mGregTypeRecipeMap.mRecipeList.add(g); + } + } + return mGregTypeRecipeMap; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + //this.resetRecipeMapForAllInputHatches(); + for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { + g.mRecipeMap = null; + } + boolean ab = super.checkRecipeGeneric(); + Logger.INFO("Did Recipe? "+ab); + return ab; } @Override @@ -261,7 +251,8 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase Logger.INFO("Your Muffler must be AT LEAST ZPM tier or higher."); } } - Logger.INFO("Fission Fuel Production Plant Formed."); + Logger.INFO("Fission Fuel Production Plant Formed. "+mGregTypeRecipeMap.mRecipeList.size()); + this.resetRecipeMapForAllInputHatches(this.getRecipeMap()); return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java index 68f78503e8..4c8707e5e8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java @@ -38,8 +38,7 @@ public class GT_Material_Loader { instance = this; //Try Reflectively add ourselves to the GT loader. - try { - Class mInterface = Class.forName("gregtech.api.interfaces.IMaterialHandler"); + Class mInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && mInterface != null){ //Make this class Dynamically implement IMaterialHandler @@ -49,7 +48,7 @@ public class GT_Material_Loader { new MaterialHandler(getInstance())); } - if (ReflectionUtils.invoke(Materials.class, "add", new Class[]{Class.forName("gregtech.api.interfaces.IMaterialHandler")}, new Object[]{mProxyObject})){ + if (ReflectionUtils.invoke(Materials.class, "add", new Class[]{ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler")}, new Object[]{mProxyObject})){ Logger.REFLECTION("Successfully invoked add, on the proxied object implementing IMaterialHandler."); @@ -65,9 +64,7 @@ public class GT_Material_Loader { else { Logger.REFLECTION("Failed to invoke add, on the proxied object implementing IMaterialHandler."); } - } - } - catch (ClassNotFoundException e) {} + } //Materials.add(this); //Stupid shit running twice, I don't think so. @@ -139,12 +136,12 @@ public class GT_Material_Loader { return false; } try { - Method enableComponent = Class.forName("gregtech.api.enums.OrePrefixes").getDeclaredMethod("enableComponent", Materials.class); + Method enableComponent = ReflectionUtils.getClass("gregtech.api.enums.OrePrefixes").getDeclaredMethod("enableComponent", Materials.class); enableComponent.invoke(prefix, mMaterial); Logger.DEBUG_MATERIALS("Enabled "+prefix.name()+" for "+mMaterial.mDefaultLocalName+"."); return true; } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException error) { + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException error) { Logger.DEBUG_MATERIALS("Failed to enabled "+prefix.name()+" for "+mMaterial.mDefaultLocalName+". Caught "+error.getCause().toString()+"."); error.printStackTrace(); } @@ -228,7 +225,7 @@ public class GT_Material_Loader { //Loading the class at runtime public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { - Class someInterface = Class.forName("gregtech.api.interfaces.IMaterialHandler"); + Class someInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); Object instance = Proxy.newProxyInstance(someInterface.getClassLoader(), new Class[]{someInterface}, new InvocationHandler() { @Override @@ -274,7 +271,7 @@ public class GT_Material_Loader { public static void init(){ - Class someInterface = Class.forName("gregtech.api.interfaces.IMaterialHandler"); + Class someInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); GT_Material_Loader original = GT_Material_Loader.instance; MaterialHandler handler = new MaterialHandler(original); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index 001edf3ab9..b4f7347b52 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -696,8 +696,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { Method T = null; if (LoadedMods.TecTech) { - try { - Class TTRecipeAdder = Class.forName("com.github.technus.tectech.recipe.TT_recipeAdder"); + Class TTRecipeAdder = ReflectionUtils.getClass("com.github.technus.tectech.recipe.TT_recipeAdder"); if (TTRecipeAdder != null) { Method ttTest = ReflectionUtils.getMethod(TTRecipeAdder, "addResearchableAssemblylineRecipe", ItemStack.class, int.class, int.class, int.class, int.class, Object[].class, @@ -706,8 +705,6 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { T = ttTest; } } - } catch (ClassNotFoundException e) { - } } else { T = null; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java index f924e5233d..6095413150 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java @@ -22,6 +22,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraftforge.fluids.FluidStack; public class GregtechNitroDieselFix { @@ -34,7 +35,7 @@ public class GregtechNitroDieselFix { int mSub = Utils.getGregtechSubVersion(); if (mSub != 0){ if (mSub >= 30){ - Class mb = Class.forName("gregtech.api.enums.MaterialBuilder"); + Class mb = ReflectionUtils.getClass("gregtech.api.enums.MaterialBuilder"); Object df = mb.getConstructor(int.class, TextureSet.class, String.class).newInstance(975, TextureSet.SET_FLUID, "Nitro-Diesel [Old]"); if (mb.isInstance(df)){ @@ -158,7 +159,7 @@ public class GregtechNitroDieselFix { } } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { Logger.INFO("[Nitro] ================ Error ================"); e.printStackTrace(); Logger.INFO("[Nitro] ================ Error ================"); diff --git a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java index 5410b0f619..5a9dc748ca 100644 --- a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java +++ b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java @@ -11,6 +11,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.item.ItemStack; public class FishTrapHandler { @@ -31,14 +32,14 @@ public class FishTrapHandler { private final static Object setFishTrapRegistry(){ Class mFishingRegistryClass; try { - mFishingRegistryClass = Class.forName("growthcraft.api.fishtrap.FishTrapRegistry"); + mFishingRegistryClass = ReflectionUtils.getClass("growthcraft.api.fishtrap.FishTrapRegistry"); final Method mFishingRegistryMethod = mFishingRegistryClass.getDeclaredMethod("getInstance"); mFishingRegistry = mFishingRegistryMethod.invoke(null); if (mFishingRegistry != null){ return mFishingRegistry; } } - catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return null; } diff --git a/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java b/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java index 617c4ddd8a..dfaec8b703 100644 --- a/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java +++ b/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java @@ -87,11 +87,11 @@ public class ModuleExoticSeeds extends ModuleAddon implements ICropModule { else { if (mForestryHumusBlockClass == null || mForestryHumusBlock == null) { try { - mForestryHumusBlockClass = Class.forName("forestry.plugins.PluginCore"); + mForestryHumusBlockClass = ReflectionUtils.getClass("forestry.plugins.PluginCore"); Field blocks = ReflectionUtils.getField(mForestryHumusBlockClass, "blocks"); if (blocks != null) { Object blockRegistryCoreObject = blocks.get(null); - mForestryBlockRegistryCoreClass = Class.forName("forestry.core.blocks.BlockRegistryCore"); + mForestryBlockRegistryCoreClass = ReflectionUtils.getClass("forestry.core.blocks.BlockRegistryCore"); if (mForestryBlockRegistryCoreClass != null && blockRegistryCoreObject != null) { Field soil = ReflectionUtils.getField(mForestryBlockRegistryCoreClass, "soil"); if (soil != null) { diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java index 558b134ea9..be3b23531c 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java @@ -37,10 +37,9 @@ public class HANDLER_Thaumcraft { public static void init(){ if (LoadedMods.Thaumcraft){ try { - mResearchNotes = (Item) ReflectionUtils.getField(Class.forName("thaumcraft.common.config.ConfigItems"), "itemResearchNotes").get(null); + mResearchNotes = (Item) ReflectionUtils.getField(ReflectionUtils.getClass("thaumcraft.common.config.ConfigItems"), "itemResearchNotes").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException - | ClassNotFoundException e) { + catch (IllegalArgumentException | IllegalAccessException e) { mResearchNotes = Items.paper; } } diff --git a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java index 501fe6579a..a6260d4246 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java @@ -33,7 +33,7 @@ public class HANDLER_Tinkers { public static final void postInit() { if (LoadedMods.TiCon) { - Class aTinkersSmeltery = ReflectionUtils.getClassByName("tconstruct.smeltery.TinkerSmeltery"); + Class aTinkersSmeltery = ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery"); AutoMap aTweakedFluids = new AutoMap(); if (aTinkersSmeltery != null) { try { @@ -84,7 +84,7 @@ public class HANDLER_Tinkers { } } } - } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } } diff --git a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java new file mode 100644 index 0000000000..a2ab894f53 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java @@ -0,0 +1,200 @@ +package gtPlusPlus.xmod.tinkers.material; + +import static gtPlusPlus.core.util.math.MathUtils.safeCast_LongToInt; + +import java.util.HashMap; + +import cpw.mods.fml.common.event.FMLInterModComms; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.FluidType; +import tconstruct.library.crafting.Smeltery; +import tconstruct.library.tools.ToolMaterial; +import tconstruct.smeltery.TinkerSmeltery; + +public class BaseTinkersMaterial { + + private static HashMap aInternalMaterialIdMap = new HashMap(); + private static int aNextFreeID = 440; + private final String mUnlocalName; + public final String mLocalName; + private final int aID; + + public BaseTinkersMaterial(Material aMaterial) { + mLocalName = Utils.sanitizeString(aMaterial.getLocalizedName()); + mUnlocalName = "material.gtpp."+Utils.sanitizeString(mLocalName); + aID = aNextFreeID++; + aInternalMaterialIdMap.put(mUnlocalName, aID); + + + int id = aID; + if (id > 0) { + + ToolMaterial mat = new ToolMaterial(mLocalName, mUnlocalName, 4, 100, 700, 2, + 0.6F, 4, 0.0F, EnumChatFormatting.WHITE.toString(), 16777215); + + TConstructRegistry.addtoolMaterial(id, mat); + TConstructRegistry.addDefaultToolPartMaterial(id); + TConstructRegistry.addBowMaterial(id, calcBowDrawSpeed(aMaterial), 1.0F); + TConstructRegistry.addArrowMaterial(id, calcProjectileMass(aMaterial), calcProjectileFragility(aMaterial)); + + NBTTagCompound tag = new NBTTagCompound(); + tag.setInteger("Id", id); + tag.setString("Name", mLocalName); + tag.setString("localizationString", mUnlocalName); + tag.setInteger("Durability", calcDurability(aMaterial)); // 97 + tag.setInteger("MiningSpeed", calcMiningSpeed(aMaterial)); // 150 + tag.setInteger("HarvestLevel", calcHarvestLevel(aMaterial)); // 1 + tag.setInteger("Attack", calcAttack(aMaterial)); // 0 + tag.setFloat("HandleModifier", calcHandleModifier(aMaterial)); // 1.0f + tag.setInteger("Reinforced", calcReinforced(aMaterial)); // 0 + tag.setFloat("Bow_ProjectileSpeed", calcBowProjectileSpeed(aMaterial)); // 3.0f + tag.setInteger("Bow_DrawSpeed", calcBowDrawSpeed(aMaterial)); // 18 + tag.setFloat("Projectile_Mass", calcProjectileMass(aMaterial)); // 0.69f + tag.setFloat("Projectile_Fragility", calcProjectileFragility(aMaterial)); // 0.2f + tag.setString("Style", calcStyle(aMaterial)); + tag.setInteger("Color", calcColour(aMaterial)); + FMLInterModComms.sendMessage("TConstruct", "addMaterial", tag); + + + generateRecipes(aMaterial); + + + ItemStack itemstack = aMaterial.getIngot(1); + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + NBTTagCompound item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + tag.setInteger("Value", 2); // What is value for? + FMLInterModComms.sendMessage("TConstruct", "addPartBuilderMaterial", tag); + + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + tag.setInteger("Value", 2); // What is value for? + item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + + FMLInterModComms.sendMessage("TConstruct", "addMaterialItem", tag); + + + } + + + + + + + + } + + public String getUnlocalName() { + return mUnlocalName; + } + + + private static int calcDurability(Material aMaterial) { + return safeCast_LongToInt(aMaterial.vDurability); + } + + private static int calcMiningSpeed(Material aMaterial) { + return (aMaterial.vHarvestLevel * 2)+aMaterial.vTier; + } + + private static int calcHarvestLevel(Material aMaterial) { + return aMaterial.vHarvestLevel; + } + + private static int calcAttack(Material aMaterial) { + return aMaterial.vHarvestLevel+aMaterial.vTier+aMaterial.vRadiationLevel; + } + + private static float calcHandleModifier(Material aMaterial) { + return 1f; + } + + private static int calcReinforced(Material aMaterial) { + return aMaterial.getMeltingPointC()/3600; + } + + private static int calcBowProjectileSpeed(Material aMaterial) { + return aMaterial.vHarvestLevel+2; + } + + private static int calcBowDrawSpeed(Material aMaterial) { + return aMaterial.vHarvestLevel+8; + } + + private static float calcProjectileMass(Material aMaterial) { + return (aMaterial.getMeltingPointC()/1800)*0.1f; + } + + private static float calcProjectileFragility(Material aMaterial) { + return 0f; + } + + private static String calcStyle(Material aMaterial) { + String aReturn = "" + EnumChatFormatting.WHITE; + int aTemp = aMaterial.getMeltingPointC(); + if (aTemp < 3600) { + aReturn = "" + EnumChatFormatting.WHITE; + } + else if (aTemp >= 3600) { + aReturn = "" + EnumChatFormatting.YELLOW; + } + else if (aTemp >= (3600*2)) { + aReturn = "" + EnumChatFormatting.GREEN; + } + else if (aTemp >= (3600*3)) { + aReturn = "" + EnumChatFormatting.RED; + } + else if (aTemp >= (3600*4)) { + aReturn = "" + EnumChatFormatting.DARK_RED; + } + else { + aReturn = "" + EnumChatFormatting.GOLD; + } + return aReturn; + } + + private static int calcColour(Material aMaterial) { + return aMaterial.getRgbAsHex(); + } + + private boolean generateRecipes(Material aMaterial) { + + //Smeltery.addMelting(new ItemStack(ExtraUtils.unstableIngot, 1, 0), ExtraUtils.decorative1, 5, 850, aMaterial.getFluid(72)); + + + + FluidType.registerFluidType(mLocalName, aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(0).getFluid(), true); + + Smeltery.addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)); + Smeltery.addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); + + if (aMaterial.getMeltingPointC() <= 3600) { + ItemStack ingotcast = new ItemStack(TinkerSmeltery.metalPattern, 1, 0); + TConstructRegistry.getBasinCasting().addCastingRecipe(aMaterial.getBlock(1), + aMaterial.getFluid(144*9), (ItemStack) null, true, 100); + TConstructRegistry.getTableCasting().addCastingRecipe(aMaterial.getIngot(1), + aMaterial.getFluid(144), ingotcast, false, 50); + } + + + return true; + } + + + + + + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java index aed5b46e0a..10eb93b4d7 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java @@ -1,9 +1,16 @@ package gtPlusPlus.xmod.tinkers.util; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.FluidType; +import tconstruct.library.crafting.Smeltery; +import tconstruct.smeltery.TinkerSmeltery; public class TinkersUtils { @@ -17,16 +24,13 @@ public class TinkersUtils { else { if (mSmelteryInstance == null || mSmelteryClassInstance == null) { if (mSmelteryClassInstance == null) { - try { - mSmelteryClassInstance = Class.forName("tconstruct.library.crafting.Smeltery"); - } - catch (ClassNotFoundException e) {} + mSmelteryClassInstance = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery"); } if (mSmelteryClassInstance != null) { try { mSmelteryInstance = ReflectionUtils.getField(mSmelteryClassInstance, "instance").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { } } } @@ -40,9 +44,8 @@ public class TinkersUtils { public static final boolean isTiConFirstInOD() { if (LoadedMods.TiCon) { try { - return (boolean) ReflectionUtils.getField(Class.forName("PHConstruct"), "tconComesFirst").get(null); - } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | ClassNotFoundException e) { + return (boolean) ReflectionUtils.getField(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst").get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { } } return false; @@ -51,8 +54,8 @@ public class TinkersUtils { public static final boolean stopTiconLoadingFirst() { if (isTiConFirstInOD()) { try { - ReflectionUtils.setFieldValue(Class.forName("PHConstruct"), "tconComesFirst", false); - if ((boolean) ReflectionUtils.getField(Class.forName("PHConstruct"), "tconComesFirst").get(null) == false) { + ReflectionUtils.setFinalFieldValue(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst", false); + if ((boolean) ReflectionUtils.getField(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst").get(null) == false) { return true; } //Did not work, let's see where TiCon uses this and prevent it. @@ -95,5 +98,48 @@ public class TinkersUtils { public static int getFuelDuration (Fluid fluid){ return (int) ReflectionUtils.invokeNonBool(getSmelteryInstance(), "getFuelDuration", new Class[] {Fluid.class}, new Object[] {fluid}); } + + public static boolean registerFluidType(String name, Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart) { + + + + //FluidType.registerFluidType(mLocalName, aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(0).getFluid(), true); + return false; + } + + public static boolean addMelting(Material aMaterial) { + Smeltery.addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)); + Smeltery.addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); + return false; + } + + public static boolean addBasinRecipe(Material aMaterial) { + TConstructRegistry.getBasinCasting().addCastingRecipe(aMaterial.getBlock(1), + aMaterial.getFluid(144*9), (ItemStack) null, true, 100); + return false; + } + + public static boolean addCastingTableRecipe(Material aMaterial) { + ItemStack ingotcast = new ItemStack(TinkerSmeltery.metalPattern, 1, 0); + TConstructRegistry.getTableCasting().addCastingRecipe(aMaterial.getIngot(1), aMaterial.getFluid(144), ingotcast, false, 50); + return false; + } + + + + + + + + + + + + + + + + + } diff --git a/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java b/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java index b28ccdaa9b..9e5efb452c 100644 --- a/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java +++ b/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java @@ -67,20 +67,17 @@ public class WitchUtils { } } - public static Field getField(String aClassName, String aFieldName) { - Class c; - try { - c = Class.forName(aClassName); - if (c != null) { - Field f = ReflectionUtils.getField(c, aFieldName); - if (f != null) { - return f; - } - } - } catch (ClassNotFoundException | NoSuchFieldException e) { + public static Field getField(String aClassName, String aFieldName) { + Class c; + c = ReflectionUtils.getClass(aClassName); + if (c != null) { + Field f = ReflectionUtils.getField(c, aFieldName); + if (f != null) { + return f; + } } return null; - } + } public static boolean isEqual(final GameProfile a, final GameProfile b) { return a != null && b != null && a.getId() != null && b.getId() != null && a.getId().equals(b.getId()); diff --git a/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java b/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java index 0b605fb8c1..eb8a8f319f 100644 --- a/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java +++ b/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java @@ -41,7 +41,7 @@ public class GppModuleData extends ModuleData { validModules.put(ID_ExoticSeedAddon, true); - } catch (NoSuchFieldException | IllegalAccessException e) { + } catch (IllegalAccessException e) { e.printStackTrace(); } } -- cgit From aaf21d2dc6c41b282641d5f57e9ff1e4d65a12d6 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 28 Feb 2019 20:23:34 +0000 Subject: + Uploaded missing Hemp crop textures. % Adjusted crafting recipe for Tumbaga when hand-crafted. Closes #433. $ Fixed A2 Spam. Closes #432. --- src/Java/gtPlusPlus/core/item/ModItems.java | 9 +++++++-- src/Java/gtPlusPlus/core/recipe/RECIPES_General.java | 15 +++++++++++++-- .../base/GregtechMeta_MultiBlockBase.java | 7 ++++++- .../xmod/gregtech/common/render/GTPP_CapeRenderer.java | 12 ++++++------ .../miscutils/textures/blocks/crop/blockCrop.Hemp.1.png | Bin 0 -> 220 bytes .../miscutils/textures/blocks/crop/blockCrop.Hemp.2.png | Bin 0 -> 399 bytes .../miscutils/textures/blocks/crop/blockCrop.Hemp.3.png | Bin 0 -> 572 bytes .../miscutils/textures/blocks/crop/blockCrop.Hemp.4.png | Bin 0 -> 534 bytes .../miscutils/textures/blocks/crop/blockCrop.Hemp.5.png | Bin 0 -> 661 bytes 9 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.1.png create mode 100644 src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.2.png create mode 100644 src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.3.png create mode 100644 src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.4.png create mode 100644 src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.5.png (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 17aaf5e106..912e3ff30d 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -219,6 +219,8 @@ public final class ModItems { public static Item dustCalciumCarbonate; public static Item dustLi2CO3CaOH2; public static Item dustLi2BeF4; + + public static Item dustTumbagaMix; public static Item dustAer; public static Item dustIgnis; @@ -696,7 +698,8 @@ public final class ModItems { GT_OreDictUnificator.registerOre("pelletZirconium", new ItemStack(itemZirconiumChlorideCinterPellet)); //Zirconium Chloride dustZrCl4 = ItemUtils.generateSpecialUseDusts("ZrCl4", "ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf - dustCookedZrCl4 = ItemUtils.generateSpecialUseDusts("CookedZrCl4", "Cooked ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf + dustCookedZrCl4 = ItemUtils.generateSpecialUseDusts("CookedZrCl4", "Cooked ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf + //Zirconium Tetrafluoride /*GT_OreDictUnificator.registerOre("cellZrF4", ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1)); GT_OreDictUnificator.registerOre("dustZrF4", ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1));*/ @@ -837,7 +840,9 @@ public final class ModItems { if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null) && CORE.ConfigSwitches.enableCustom_Pipes){ itemDoublePlateEuropium = new BaseItemPlateDouble(ELEMENT.getInstance().EUROPIUM); } - + + //Tumbaga Mix (For Simple Crafting) + dustTumbagaMix = ItemUtils.generateSpecialUseDusts("MixTumbaga", "Tumbaga Mix", "Au2Cu", Utils.rgbtoHexValue(255, 150, 80))[0]; /* * Decayable Materials diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 500333a7a2..c2fd4adc41 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -162,14 +162,25 @@ public class RECIPES_General { //Shaped Crafting for ULV Material Dusts + //Potin if (RecipeUtils.addShapelessGregtechRecipe(new Object[] {"dustLead", "dustBronze", "dustTin", "dustLead", "dustBronze"}, ALLOY.POTIN.getDust(5))){ Logger.INFO("Added shapeless recipe for Potin Dust."); } + //Tumbaga - if (RecipeUtils.addShapelessGregtechRecipe(new Object[] {"dustRoseGold", "dustGold", "dustGold", - "dustGold", "dustCopper", "dustCopper"}, ALLOY.TUMBAGA.getDust(10))){ + if (RecipeUtils.addShapelessGregtechRecipe(new Object[] { + "dustGold", "dustGold", "dustCopper"}, ItemUtils.getSimpleStack(ModItems.dustTumbagaMix))){ + Logger.INFO("Added shapeless recipe for Tumbaga Mix."); + } + if (RecipeUtils.addShapelessGregtechRecipe(new Object[] { + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + "dustCopper" + }, + ALLOY.TUMBAGA.getDust(10))){ Logger.INFO("Added shapeless recipe for Tumbaga Dust."); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 7103c81980..7ae0c6b246 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -483,8 +483,13 @@ GT_MetaTileEntity_MultiBlockBase { public void log(String s) { boolean isDebugLogging = CORE.DEBUG; boolean reset = true; + + if (!isDebugLogging) { + return; + } + if (aLogger == null || reset) { - if (true) { + if (isDebugLogging) { try { aLogger = Logger.class.getMethod("INFO", String.class); } catch (NoSuchMethodException | SecurityException e) {} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java index 22ce41282f..7dd376759a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -82,14 +82,14 @@ public class GTPP_CapeRenderer extends RenderPlayer { AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; if (!ConfigSwitches.enableCustomCapes) { aEvent.setCanceled(true); - Logger.INFO("A1"); + Logger.WARNING("A1"); return; } if (hasResourceChecked) { if (!hasCape && !CORE.DEVENV) { aEvent.setCanceled(true); - Logger.INFO("A2"); + Logger.WARNING("A2"); return; } } @@ -141,7 +141,7 @@ public class GTPP_CapeRenderer extends RenderPlayer { if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { aEvent.setCanceled(true); - Logger.INFO("A3"); + Logger.WARNING("A3"); return; } @@ -209,7 +209,7 @@ public class GTPP_CapeRenderer extends RenderPlayer { Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g); if (profile != null) { - Logger.INFO("[Capes++] Found for UUID check: " + profile.getName() + "."); + Logger.WARNING("[Capes++] Found for UUID check: " + profile.getName() + "."); return profile.getName(); } } else { @@ -218,7 +218,7 @@ public class GTPP_CapeRenderer extends RenderPlayer { Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g); if (profile != null) { - Logger.INFO("[Capes++] Found for UUID check 2: " + profile.getName() + "."); + Logger.WARNING("[Capes++] Found for UUID check 2: " + profile.getName() + "."); return profile.getName(); } } @@ -230,7 +230,7 @@ public class GTPP_CapeRenderer extends RenderPlayer { Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(name); if (profile != null) { - Logger.INFO("[Capes++] Found for name check: " + profile.getName() + "."); + Logger.WARNING("[Capes++] Found for name check: " + profile.getName() + "."); return profile.getName(); } } diff --git a/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.1.png b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.1.png new file mode 100644 index 0000000000..8c5f1ec338 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.1.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.2.png b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.2.png new file mode 100644 index 0000000000..75ff7b2558 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.2.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.3.png b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.3.png new file mode 100644 index 0000000000..edcfc53edd Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.3.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.4.png b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.4.png new file mode 100644 index 0000000000..8176e98807 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.4.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.5.png b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.5.png new file mode 100644 index 0000000000..0737748bb9 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/crop/blockCrop.Hemp.5.png differ -- cgit From 5ffa0957e9d936ec999ee5157be771ff4b315aac Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 28 Feb 2019 23:49:40 +0000 Subject: + Enabled Tinkers compat for GT++ Materials. $ Migrated lots of TiCon code to be reflective. $ Upload missing class ItemDummyResearch.java. --- .../core/item/crafting/ItemDummyResearch.java | 111 +++++++ src/Java/gtPlusPlus/core/material/Material.java | 8 + .../gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java | 10 +- .../xmod/tinkers/material/BaseTinkersMaterial.java | 185 ++++++------ .../gtPlusPlus/xmod/tinkers/util/TinkersUtils.java | 330 ++++++++++++++++++--- 5 files changed, 516 insertions(+), 128 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java b/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java new file mode 100644 index 0000000000..1c28f99ff8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java @@ -0,0 +1,111 @@ +package gtPlusPlus.core.item.crafting; + +import java.util.LinkedHashMap; +import java.util.Map; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.general.ItemGenericToken; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +public class ItemDummyResearch extends ItemGenericToken { + + public static enum ASSEMBLY_LINE_RESEARCH { + + + RESEARCH_1_CONTAINMENT("Containment Fields", "Advanced scientific study"), + RESEARCH_2_BASIC_CHEM("Basic Chemistry", "Time to start at the beginning"), + RESEARCH_3_ADV_CHEM("Advanced Chemistry", "Best learn more than chemical equations"), + RESEARCH_4_BASIC_PHYSICS("Basic Physics", "Fundamental laws of motion"), + RESEARCH_5_ADV_PHYSICS("Advanced Physics", "Advanced knowledge!"), + RESEARCH_6_BASIC_METALLURGY("Basic Metallurgy", "Information about material smelting"), + RESEARCH_7_ADV_METALLURGY("Advanced Metallurgy", "Advanced Material Sciences!"); + + + + + + + + + + + + + + + + + + + private String mName; + private String mDesc; + + private ASSEMBLY_LINE_RESEARCH(String aName, String aDesc) { + mName = aName; + mDesc = aDesc; + ModItems.itemDummyResearch.register(mName, mDesc); + } + + } + + + + + + + + + + + private static Map mInternalNameToIdMap = new LinkedHashMap(); + + public static ItemStack getResearchStack(ASSEMBLY_LINE_RESEARCH aResearchName, int aStacksize) { + Integer aMeta = mInternalNameToIdMap.get(Utils.sanitizeString(aResearchName.mName)); + if (aMeta == null) { + aMeta = 0; + } + return ItemUtils.simpleMetaStack(ModItems.itemDummyResearch, aMeta, aStacksize); + } + + private int aID = 0; + public ItemDummyResearch() { + super("dummyResearch", "Research", new String[] {"This object requires some further study"}, "research"); + + + + } + + /** + * + * @param aResearchType - What is the research for? + * @param aDescriptThe - tooltip for this research + * @return - Did we register a custom research item? + */ + public boolean register(String aResearchType, String aDescript) { + int aNewID = aID++; + mInternalNameToIdMap.put(Utils.sanitizeString(aResearchType), aNewID); + return register(aNewID, "Research on "+aResearchType, 1, aDescript); + } + + @Override + public boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { + return register(id, aLocalName, 1, new String[] {aDescript, EnumChatFormatting.DARK_GRAY+"Used to further your knowledge"}, EnumRarity.common, EnumChatFormatting.LIGHT_PURPLE); + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(final IIconRegister aIconRegister) { + for (int i = 0, j = mLocalNames.size(); i < j; i++) { + mIcons.put(i, aIconRegister.registerIcon(CORE.MODID + ":" + "research" + "/" + "note")); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index d996bed128..f0a2eb7152 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -15,6 +15,7 @@ import gregtech.api.enums.TextureSet; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.item.base.cell.BaseItemCell; +import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.data.StringUtils; @@ -23,6 +24,7 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; +import gtPlusPlus.xmod.tinkers.material.BaseTinkersMaterial; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -77,6 +79,8 @@ public class Material { public int vHarvestLevel; private GTPP_Aspects[] vAspects; + + public BaseTinkersMaterial vTiConHandler; public static AutoMap invalidMaterials = new AutoMap(); @@ -492,6 +496,10 @@ public class Material { } this.textureSet = setTextureSet(set, vTier); + + if (LoadedMods.TiCon) { + this.vTiConHandler = new BaseTinkersMaterial(this); + } Logger.MATERIALS("Creating a Material instance for "+materialName); Logger.MATERIALS("Formula: "+this.vChemicalFormula + " Smallest Stack: "+this.smallestStackSizeWhenProcessing+" Smallest Ratio:"+ratio); diff --git a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java index a6260d4246..9ba10fc40e 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java @@ -6,6 +6,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.tinkers.material.BaseTinkersMaterial; import gtPlusPlus.xmod.tinkers.util.TinkersUtils; import net.minecraft.block.Block; import net.minecraftforge.fluids.Fluid; @@ -13,6 +14,8 @@ import net.minecraftforge.fluids.FluidRegistry; public class HANDLER_Tinkers { + public static AutoMap mTinkerMaterials = new AutoMap(); + public static final void preInit() { if (LoadedMods.TiCon) { @@ -31,8 +34,13 @@ public class HANDLER_Tinkers { } } - public static final void postInit() { + public static final void postInit() { if (LoadedMods.TiCon) { + + for (BaseTinkersMaterial y : mTinkerMaterials) { + y.generate(); + } + Class aTinkersSmeltery = ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery"); AutoMap aTweakedFluids = new AutoMap(); if (aTinkersSmeltery != null) { diff --git a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java index a2ab894f53..0730f5baba 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java @@ -5,98 +5,38 @@ import static gtPlusPlus.core.util.math.MathUtils.safeCast_LongToInt; import java.util.HashMap; import cpw.mods.fml.common.event.FMLInterModComms; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; +import gtPlusPlus.xmod.tinkers.util.TinkersUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; -import tconstruct.library.TConstructRegistry; -import tconstruct.library.crafting.FluidType; -import tconstruct.library.crafting.Smeltery; -import tconstruct.library.tools.ToolMaterial; -import tconstruct.smeltery.TinkerSmeltery; public class BaseTinkersMaterial { private static HashMap aInternalMaterialIdMap = new HashMap(); private static int aNextFreeID = 440; - private final String mUnlocalName; + public final String mLocalName; - private final int aID; + + private final String mUnlocalName; + private final int mID; + private final Material mMaterial; public BaseTinkersMaterial(Material aMaterial) { mLocalName = Utils.sanitizeString(aMaterial.getLocalizedName()); mUnlocalName = "material.gtpp."+Utils.sanitizeString(mLocalName); - aID = aNextFreeID++; - aInternalMaterialIdMap.put(mUnlocalName, aID); - - - int id = aID; - if (id > 0) { - - ToolMaterial mat = new ToolMaterial(mLocalName, mUnlocalName, 4, 100, 700, 2, - 0.6F, 4, 0.0F, EnumChatFormatting.WHITE.toString(), 16777215); - - TConstructRegistry.addtoolMaterial(id, mat); - TConstructRegistry.addDefaultToolPartMaterial(id); - TConstructRegistry.addBowMaterial(id, calcBowDrawSpeed(aMaterial), 1.0F); - TConstructRegistry.addArrowMaterial(id, calcProjectileMass(aMaterial), calcProjectileFragility(aMaterial)); - - NBTTagCompound tag = new NBTTagCompound(); - tag.setInteger("Id", id); - tag.setString("Name", mLocalName); - tag.setString("localizationString", mUnlocalName); - tag.setInteger("Durability", calcDurability(aMaterial)); // 97 - tag.setInteger("MiningSpeed", calcMiningSpeed(aMaterial)); // 150 - tag.setInteger("HarvestLevel", calcHarvestLevel(aMaterial)); // 1 - tag.setInteger("Attack", calcAttack(aMaterial)); // 0 - tag.setFloat("HandleModifier", calcHandleModifier(aMaterial)); // 1.0f - tag.setInteger("Reinforced", calcReinforced(aMaterial)); // 0 - tag.setFloat("Bow_ProjectileSpeed", calcBowProjectileSpeed(aMaterial)); // 3.0f - tag.setInteger("Bow_DrawSpeed", calcBowDrawSpeed(aMaterial)); // 18 - tag.setFloat("Projectile_Mass", calcProjectileMass(aMaterial)); // 0.69f - tag.setFloat("Projectile_Fragility", calcProjectileFragility(aMaterial)); // 0.2f - tag.setString("Style", calcStyle(aMaterial)); - tag.setInteger("Color", calcColour(aMaterial)); - FMLInterModComms.sendMessage("TConstruct", "addMaterial", tag); - - - generateRecipes(aMaterial); - - - ItemStack itemstack = aMaterial.getIngot(1); - tag = new NBTTagCompound(); - tag.setInteger("MaterialId", id); - NBTTagCompound item = new NBTTagCompound(); - itemstack.writeToNBT(item); - tag.setTag("Item", item); - tag.setInteger("Value", 2); // What is value for? - FMLInterModComms.sendMessage("TConstruct", "addPartBuilderMaterial", tag); - - tag = new NBTTagCompound(); - tag.setInteger("MaterialId", id); - tag.setInteger("Value", 2); // What is value for? - item = new NBTTagCompound(); - itemstack.writeToNBT(item); - tag.setTag("Item", item); - - FMLInterModComms.sendMessage("TConstruct", "addMaterialItem", tag); - - - } - - - - - - - + mMaterial = aMaterial; + mID = aNextFreeID++; + aInternalMaterialIdMap.put(mUnlocalName, mID); + HANDLER_Tinkers.mTinkerMaterials.put(this); } public String getUnlocalName() { return mUnlocalName; - } - + } private static int calcDurability(Material aMaterial) { return safeCast_LongToInt(aMaterial.vDurability); @@ -166,22 +106,95 @@ public class BaseTinkersMaterial { return aMaterial.getRgbAsHex(); } - private boolean generateRecipes(Material aMaterial) { - - //Smeltery.addMelting(new ItemStack(ExtraUtils.unstableIngot, 1, 0), ExtraUtils.decorative1, 5, 850, aMaterial.getFluid(72)); + public Object generateToolMaterial(Material aMaterial) { + int level, dura, speed, dmg, reinf, primColour; + float handle, stonebound; + level = calcHarvestLevel(aMaterial); + dura = calcDurability(aMaterial); + speed = calcMiningSpeed(aMaterial); + dmg = calcAttack(aMaterial); + reinf = calcReinforced(aMaterial); + primColour = calcColour(aMaterial); + handle = calcHandleModifier(aMaterial); + //stonebound = calcHarvestLevel(aMaterial); + stonebound = 0; + return TinkersUtils.generateToolMaterial(aMaterial.getLocalizedName(), aMaterial.getUnlocalizedName(), level, dura, speed, dmg, handle, reinf, stonebound, calcStyle(aMaterial), primColour); + } + public void generate() { + + Logger.INFO("Trying to generate TiCon Material: "+mLocalName); + int id = mID; + if (id > 0) { + + Object aTinkersCustomMaterial = generateToolMaterial(mMaterial); + Logger.INFO("Created TiCon Material: "+mLocalName); + + TinkersUtils.addToolMaterial(id, aTinkersCustomMaterial); + TinkersUtils.addDefaultToolPartMaterial(id); + TinkersUtils.addBowMaterial(id, calcBowDrawSpeed(mMaterial), 1.0F); + TinkersUtils.addArrowMaterial(id, calcProjectileMass(mMaterial), calcProjectileFragility(mMaterial)); + + NBTTagCompound tag = new NBTTagCompound(); + tag.setInteger("Id", id); + tag.setString("Name", mLocalName); + tag.setString("localizationString", mUnlocalName); + tag.setInteger("Durability", calcDurability(mMaterial)); // 97 + tag.setInteger("MiningSpeed", calcMiningSpeed(mMaterial)); // 150 + tag.setInteger("HarvestLevel", calcHarvestLevel(mMaterial)); // 1 + tag.setInteger("Attack", calcAttack(mMaterial)); // 0 + tag.setFloat("HandleModifier", calcHandleModifier(mMaterial)); // 1.0f + tag.setInteger("Reinforced", calcReinforced(mMaterial)); // 0 + tag.setFloat("Bow_ProjectileSpeed", calcBowProjectileSpeed(mMaterial)); // 3.0f + tag.setInteger("Bow_DrawSpeed", calcBowDrawSpeed(mMaterial)); // 18 + tag.setFloat("Projectile_Mass", calcProjectileMass(mMaterial)); // 0.69f + tag.setFloat("Projectile_Fragility", calcProjectileFragility(mMaterial)); // 0.2f + tag.setString("Style", calcStyle(mMaterial)); + tag.setInteger("Color", calcColour(mMaterial)); + + Logger.INFO("Sending IMC to TConstruct: addMaterial - "+mLocalName+"."); + FMLInterModComms.sendMessage("TConstruct", "addMaterial", tag); + + + generateRecipes(mMaterial); + + + ItemStack itemstack = mMaterial.getIngot(1); + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + NBTTagCompound item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + tag.setInteger("Value", 2); // What is value for? + + Logger.INFO("Sending IMC to TConstruct: addPartBuilderMaterial - "+mLocalName+"."); + FMLInterModComms.sendMessage("TConstruct", "addPartBuilderMaterial", tag); + + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + tag.setInteger("Value", 2); // What is value for? + item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + + Logger.INFO("Sending IMC to TConstruct: addMaterialItem - "+mLocalName+"."); + FMLInterModComms.sendMessage("TConstruct", "addMaterialItem", tag); + + + } - - FluidType.registerFluidType(mLocalName, aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(0).getFluid(), true); - - Smeltery.addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)); - Smeltery.addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); - + } + + private boolean generateRecipes(Material aMaterial) { + //Smeltery.addMelting(new ItemStack(ExtraUtils.unstableIngot, 1, 0), ExtraUtils.decorative1, 5, 850, aMaterial.getFluid(72)); + TinkersUtils.registerFluidType(mLocalName, aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(0).getFluid(), true); + TinkersUtils.addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)); + TinkersUtils.addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); if (aMaterial.getMeltingPointC() <= 3600) { - ItemStack ingotcast = new ItemStack(TinkerSmeltery.metalPattern, 1, 0); - TConstructRegistry.getBasinCasting().addCastingRecipe(aMaterial.getBlock(1), + ItemStack ingotcast = TinkersUtils.getPattern(1); + TinkersUtils.addBasinRecipe(aMaterial.getBlock(1), aMaterial.getFluid(144*9), (ItemStack) null, true, 100); - TConstructRegistry.getTableCasting().addCastingRecipe(aMaterial.getIngot(1), + TinkersUtils.addCastingTableRecipe(aMaterial.getIngot(1), aMaterial.getFluid(144), ingotcast, false, 50); } @@ -195,6 +208,4 @@ public class BaseTinkersMaterial { - - } diff --git a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java index 10eb93b4d7..b902e38a1e 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java @@ -1,44 +1,112 @@ package gtPlusPlus.xmod.tinkers.util; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.LinkedHashMap; + import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; -import tconstruct.library.TConstructRegistry; -import tconstruct.library.crafting.FluidType; -import tconstruct.library.crafting.Smeltery; -import tconstruct.smeltery.TinkerSmeltery; +import net.minecraftforge.fluids.FluidStack; public class TinkersUtils { private static Object mSmelteryInstance; private static Class mSmelteryClassInstance; + + private static Object mTinkersRegistryInstance; + private static Class mTinkersRegistryClass; + + private static final Class mToolMaterialClass; - public static Object getSmelteryInstance() { + private static final HashMap mMethodCache = new LinkedHashMap(); + + + static { + setRegistries(); + mToolMaterialClass = ReflectionUtils.getClass("tconstruct.library.tools.ToolMaterial"); + } + + + /** + * + * @param aSwitch - The Registry to return + */ + private static Object getTiConDataInstance(int aSwitch) { if (!LoadedMods.TiCon) { return null; } else { - if (mSmelteryInstance == null || mSmelteryClassInstance == null) { - if (mSmelteryClassInstance == null) { - mSmelteryClassInstance = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery"); - } - if (mSmelteryClassInstance != null) { - try { - mSmelteryInstance = ReflectionUtils.getField(mSmelteryClassInstance, "instance").get(null); + + if (mTinkersRegistryClass == null || mSmelteryClassInstance == null) { + setRegistries(); + } + + // getSmelteryInstance + if (aSwitch == 0) { + + //Set Smeltery Instance + if (mSmelteryInstance == null || mSmelteryClassInstance == null) { + if (mSmelteryClassInstance == null) { + mSmelteryClassInstance = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery"); } - catch (IllegalArgumentException | IllegalAccessException e) { + if (mSmelteryClassInstance != null) { + try { + mSmelteryInstance = ReflectionUtils.getField(mSmelteryClassInstance, "instance").get(null); + } + catch (IllegalArgumentException | IllegalAccessException e) { + } } } - } - } - if (mSmelteryInstance != null) { - return mSmelteryInstance; - } - return null; + + //Return Smeltery Instance + if (mSmelteryInstance != null) { + return mSmelteryInstance; + } + } + + // getTableCastingInstance || getBasinCastingInstance + else if (aSwitch == 1) { + if (mTinkersRegistryClass == null || mTinkersRegistryInstance == null) { + if (mTinkersRegistryClass == null) { + mTinkersRegistryClass = ReflectionUtils.getClass("tconstruct.library.TConstructRegistry"); + } + if (mTinkersRegistryClass != null) { + if (mTinkersRegistryInstance == null) { + try { + mTinkersRegistryInstance = ReflectionUtils.getField(mTinkersRegistryClass, "instance").get(null); + } + catch (IllegalArgumentException | IllegalAccessException e) { + } + } + } + } + + //Return Smeltery Instance + if (mTinkersRegistryInstance != null) { + return mTinkersRegistryInstance; + } + } + + return null; + } + } + + private static void setRegistries() { + if (mTinkersRegistryClass == null) { + mTinkersRegistryClass = ReflectionUtils.getClass("tconstruct.library.TConstructRegistry"); + } + if (mSmelteryClassInstance == null) { + mSmelteryClassInstance = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery"); + } } public static final boolean isTiConFirstInOD() { @@ -75,56 +143,100 @@ public class TinkersUtils { * @param duration How long one "portion" of liquid fuels the smeltery. Lava is 10. */ public static void addSmelteryFuel (Fluid fluid, int power, int duration){ - ReflectionUtils.invokeVoid(getSmelteryInstance(), "addSmelteryFuel", new Class[] {Fluid.class, int.class, int.class}, new Object[] {fluid, power, duration}); + ReflectionUtils.invokeVoid(getTiConDataInstance(0), "addSmelteryFuel", new Class[] {Fluid.class, int.class, int.class}, new Object[] {fluid, power, duration}); } /** * Returns true if the liquid is a valid smeltery fuel. */ public static boolean isSmelteryFuel (Fluid fluid){ - return ReflectionUtils.invoke(getSmelteryInstance(), "isSmelteryFuel", new Class[] {Fluid.class}, new Object[] {fluid}); + return ReflectionUtils.invoke(getTiConDataInstance(0), "isSmelteryFuel", new Class[] {Fluid.class}, new Object[] {fluid}); } /** * Returns the power of a smeltery fuel or 0 if it's not a fuel. */ public static int getFuelPower (Fluid fluid){ - return (int) ReflectionUtils.invokeNonBool(getSmelteryInstance(), "getFuelPower", new Class[] {Fluid.class}, new Object[] {fluid}); + return (int) ReflectionUtils.invokeNonBool(getTiConDataInstance(0), "getFuelPower", new Class[] {Fluid.class}, new Object[] {fluid}); } /** * Returns the duration of a smeltery fuel or 0 if it's not a fuel. */ public static int getFuelDuration (Fluid fluid){ - return (int) ReflectionUtils.invokeNonBool(getSmelteryInstance(), "getFuelDuration", new Class[] {Fluid.class}, new Object[] {fluid}); + return (int) ReflectionUtils.invokeNonBool(getTiConDataInstance(0), "getFuelDuration", new Class[] {Fluid.class}, new Object[] {fluid}); } + + + + + + public static boolean registerFluidType(String name, Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart) { - - - - //FluidType.registerFluidType(mLocalName, aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(0).getFluid(), true); - return false; + if (mMethodCache.get("registerFluidType") == null) { + Method m = ReflectionUtils.getMethod(ReflectionUtils.getClass("tconstruct.library.crafting.FluidType"), "registerFluidType", String.class, Block.class, int.class, int.class, Fluid.class, boolean.class); + mMethodCache.put("registerFluidType", m); + } + try { + mMethodCache.get("registerFluidType").invoke(null, name, block, meta, baseTemperature, fluid, isToolpart); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } } - public static boolean addMelting(Material aMaterial) { - Smeltery.addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)); - Smeltery.addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); - return false; + + + + + + + + public static boolean addBaseMeltingRecipes(Material aMaterial) { + return addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)) && + addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); } - public static boolean addBasinRecipe(Material aMaterial) { - TConstructRegistry.getBasinCasting().addCastingRecipe(aMaterial.getBlock(1), - aMaterial.getFluid(144*9), (ItemStack) null, true, 100); - return false; + public static boolean addMelting(ItemStack input, Block block, int metadata, int temperature, FluidStack liquid) { + if (mMethodCache.get("addMelting") == null) { + Method m = ReflectionUtils.getMethod(mSmelteryClassInstance, "addMelting", ItemStack.class, Block.class, int.class, int.class, FluidStack.class); + mMethodCache.put("addMelting", m); + } + try { + mMethodCache.get("addMelting").invoke(null, input, block, metadata, temperature, liquid); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } } - public static boolean addCastingTableRecipe(Material aMaterial) { - ItemStack ingotcast = new ItemStack(TinkerSmeltery.metalPattern, 1, 0); - TConstructRegistry.getTableCasting().addCastingRecipe(aMaterial.getIngot(1), aMaterial.getFluid(144), ingotcast, false, 50); - return false; + + + + + + + + + + + public static boolean addBaseBasinRecipes(Material aMaterial) { + return addBasinRecipe(aMaterial.getBlock(1), aMaterial.getFluid(144*9), (ItemStack) null, true, 100); } + public static boolean addBasinRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay) { + if (mMethodCache.get("addBasinRecipe") == null) { + Method m = ReflectionUtils.getMethod(ReflectionUtils.getClass("tconstruct.library.crafting.LiquidCasting"), "addCastingRecipe", ItemStack.class, FluidStack.class, ItemStack.class, boolean.class, int.class); + mMethodCache.put("addBasinRecipe", m); + } + try { + mMethodCache.get("addBasinRecipe").invoke(getCastingInstance(0), output, metal, cast, consume, delay); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } @@ -132,6 +244,24 @@ public class TinkersUtils { + public static boolean addBaseCastingRecipes(Material aMaterial) { + ItemStack ingotcast = getPattern(1); + return addCastingTableRecipe(aMaterial.getIngot(1), aMaterial.getFluid(144), ingotcast, false, 50); + } + + public static boolean addCastingTableRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay) { + if (mMethodCache.get("addCastingTableRecipe") == null) { + Method m = ReflectionUtils.getMethod(ReflectionUtils.getClass("tconstruct.library.crafting.LiquidCasting"), "addBasinRecipe", ItemStack.class, FluidStack.class, ItemStack.class, boolean.class, int.class); + mMethodCache.put("addCastingTableRecipe", m); + } + try { + mMethodCache.get("addCastingTableRecipe").invoke(getCastingInstance(1), output, metal, cast, consume, delay); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + @@ -139,7 +269,127 @@ public class TinkersUtils { + public static Object getCastingInstance(int aType) { + if (aType == 0) { + return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getTableCasting", new Class[] {}, new Object[] {}); + } + else if (aType == 1) { + return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getBasinCasting", new Class[] {}, new Object[] {}); + } + else { + return null; + } + } + + private static Item mTinkerMetalPattern; + public static ItemStack getPattern(int aType) { + if (mTinkerMetalPattern == null) { + Field m = ReflectionUtils.getField(ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery"), "metalPattern"); + if (m != null) { + try { + mTinkerMetalPattern = (Item) m.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + } + if (mTinkerMetalPattern != null) { + ItemStack ingotCast = new ItemStack(mTinkerMetalPattern, aType, 0); + return ingotCast; + } + return ItemUtils.getErrorStack(1, "Bad Tinkers Pattern"); + + + + + + + + } + /** + * Generates Tinkers {@link ToolMaterial}'s reflectively. + * @param name + * @param localizationString + * @param level + * @param durability + * @param speed + * @param damage + * @param handle + * @param reinforced + * @param stonebound + * @param style + * @param primaryColor + * @return + */ + public static Object generateToolMaterial(String name, String localizationString, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor) { + try { + Constructor constructor = mToolMaterialClass.getConstructor(String.class, String.class, int.class, int.class, int.class, int.class, float.class, int.class, float.class, String.class, int.class); + Object myObject = constructor.newInstance(name, localizationString, level, durability, speed, damage, handle, reinforced, stonebound, style, primaryColor); + return myObject; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + + + + + + + + + + + public static void addToolMaterial(int id, Object aToolMaterial) { + setRegistries(); + if (mMethodCache.get("addToolMaterial") == null) { + Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addToolMaterial", int.class, mToolMaterialClass); + mMethodCache.put("addToolMaterial", m); + } + try { + mMethodCache.get("addToolMaterial").invoke(mTinkersRegistryClass, id, aToolMaterial); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + + } + } + + public static void addDefaultToolPartMaterial(int id) { + setRegistries(); + if (mMethodCache.get("addDefaultToolPartMaterial") == null) { + Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addDefaultToolPartMaterial", int.class); + mMethodCache.put("addDefaultToolPartMaterial", m); + } + try { + mMethodCache.get("addDefaultToolPartMaterial").invoke(mTinkersRegistryClass, id); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + + public static void addBowMaterial(int id, int drawspeed, float maxSpeed) { + setRegistries(); + if (mMethodCache.get("addBowMaterial") == null) { + Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addBowMaterial", int.class, int.class, float.class); + mMethodCache.put("addBowMaterial", m); + } + try { + mMethodCache.get("addBowMaterial").invoke(mTinkersRegistryClass, id, drawspeed, maxSpeed); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + + public static void addArrowMaterial(int id, float mass, float fragility) { + setRegistries(); + if (mMethodCache.get("addArrowMaterial") == null) { + Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addArrowMaterial", int.class, float.class, float.class); + mMethodCache.put("addArrowMaterial", m); + } + try { + mMethodCache.get("addArrowMaterial").invoke(mTinkersRegistryClass, id, mass, fragility); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } } -- cgit From 35522722af5dddea144c841a71f4fa9087e68966 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 1 Mar 2019 03:00:51 +0000 Subject: % More work on TiCon Compat. --- src/Java/gtPlusPlus/core/material/Material.java | 10 ++- .../gtPlusPlus/core/util/data/StringUtils.java | 15 ++++ .../core/util/reflect/ReflectionUtils.java | 29 +++++-- .../xmod/tinkers/material/BaseTinkersMaterial.java | 93 ++++++++++++++-------- .../gtPlusPlus/xmod/tinkers/util/TinkersUtils.java | 27 +++++-- 5 files changed, 128 insertions(+), 46 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 01503a1fc5..ba572efe90 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -498,7 +498,9 @@ public class Material { this.textureSet = setTextureSet(set, vTier); if (LoadedMods.TiCon && this.materialState == MaterialState.SOLID) { - this.vTiConHandler = new BaseTinkersMaterial(this); + if (this.getProtons() >= 98 || this.getComposites().size() > 1 || this.getMeltingPointC() >= 3600) { + this.vTiConHandler = new BaseTinkersMaterial(this); + } } Logger.MATERIALS("Creating a Material instance for "+materialName); @@ -753,7 +755,11 @@ public class Material { } final public Block getBlock(){ - return Block.getBlockFromItem(getBlock(1).getItem()); + Block b = Block.getBlockFromItem(getBlock(1).getItem()); + if (b == null) { + Logger.INFO("[ERROR] Tried to get invalid block for "+this.getLocalizedName()+", returning debug block instead."); + } + return b != null ? b : Blocks.lit_furnace; } public final ItemStack getBlock(final int stacksize){ diff --git a/src/Java/gtPlusPlus/core/util/data/StringUtils.java b/src/Java/gtPlusPlus/core/util/data/StringUtils.java index e58b68665a..b64266b5d4 100644 --- a/src/Java/gtPlusPlus/core/util/data/StringUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/StringUtils.java @@ -116,4 +116,19 @@ public class StringUtils { String restLetters = data.substring(1).toLowerCase(); return firstLetter + restLetters; } + + public static String getDataStringFromArray(V[] parameterTypes) { + if (parameterTypes == null || parameterTypes.length == 0) { + return "empty/null"; + } + else { + String aData = ""; + for (V y : parameterTypes) { + if (y != null) { + aData += ", "+y.toString(); + } + } + return aData; + } + } } diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 372bf81fe9..88175b0a82 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -12,6 +12,7 @@ import java.util.Map; import com.google.common.reflect.ClassPath; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.data.StringUtils; public class ReflectionUtils { @@ -116,6 +117,19 @@ public class ReflectionUtils { } + + /** + * Returns a cached {@link Method} object. Wraps {@link #getMethod(Class, String, Class...)}. + * @param aObject - Object containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @param aTypes - Class Array of Types for {@link Method}'s constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Method getMethod(Object aObject, String aMethodName, Class[] aTypes) { + return getMethod(aObject.getClass(), aMethodName, aTypes); + } + + /** * Returns a cached {@link Method} object. * @param aClass - Class containing the Method. @@ -127,7 +141,7 @@ public class ReflectionUtils { String aMethodKey = aTypes.toString(); CachedMethod y = mCachedMethods.get(aMethodName + "." + aMethodKey); if (y == null) { - Method u = getMethod_Internal(aClass, aMethodKey, aTypes); + Method u = getMethod_Internal(aClass, aMethodName, aTypes); if (u != null) { Logger.REFLECTION("Caching Method: "+aMethodName + "." + aMethodKey); cacheMethod(u); @@ -457,6 +471,7 @@ public class ReflectionUtils { private static Method getMethod_Internal(Class aClass, String aMethodName, Class... aTypes) { Method m = null; try { + Logger.REFLECTION("Method: Internal Lookup: "+aMethodName); m = aClass.getDeclaredMethod(aMethodName, aTypes); if (m != null) { m.setAccessible(true); @@ -468,6 +483,7 @@ public class ReflectionUtils { } } catch (Throwable t) { + Logger.REFLECTION("Method: Internal Lookup Failed: "+aMethodName); try { m = getMethodRecursively(aClass, aMethodName); } catch (NoSuchMethodException e) { @@ -479,9 +495,10 @@ public class ReflectionUtils { return m; } - private static Method getMethodRecursively(final Class clazz, final String fieldName) throws NoSuchMethodException { + private static Method getMethodRecursively(final Class clazz, final String aMethodName) throws NoSuchMethodException { try { - Method k = clazz.getDeclaredMethod(fieldName); + Logger.REFLECTION("Method: Recursion Lookup: "+aMethodName); + Method k = clazz.getDeclaredMethod(aMethodName); makeMethodAccessible(k); return k; } catch (final NoSuchMethodException e) { @@ -489,7 +506,7 @@ public class ReflectionUtils { if (superClass == null || superClass == Object.class) { throw e; } - return getMethod_Internal(superClass, fieldName); + return getMethod_Internal(superClass, aMethodName); } } @@ -502,7 +519,7 @@ public class ReflectionUtils { Logger.INFO("Dumping all Methods."); for (Method method : methods) { - System.out.println(method.getName()); + System.out.println(method.getName()+" | "+StringUtils.getDataStringFromArray(method.getParameterTypes())); } Logger.INFO("Dumping all Fields."); for (Field f : fields) { @@ -510,7 +527,7 @@ public class ReflectionUtils { } Logger.INFO("Dumping all Constructors."); for (Constructor c : consts) { - System.out.println(c.getName()+" | "+c.getParameterCount()+" | "+c.getParameterTypes().toString()); + System.out.println(c.getName()+" | "+c.getParameterCount()+" | "+StringUtils.getDataStringFromArray(c.getParameterTypes())); } } diff --git a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java index 0730f5baba..19ff630a92 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java @@ -10,14 +10,18 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; import gtPlusPlus.xmod.tinkers.util.TinkersUtils; +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.Fluid; public class BaseTinkersMaterial { + + private static HashMap aInternalMaterialIdMap = new HashMap(); - private static int aNextFreeID = 440; + private static int aNextFreeID; public final String mLocalName; @@ -25,11 +29,16 @@ public class BaseTinkersMaterial { private final int mID; private final Material mMaterial; + static { + aNextFreeID = Short.MAX_VALUE+420; + } + public BaseTinkersMaterial(Material aMaterial) { mLocalName = Utils.sanitizeString(aMaterial.getLocalizedName()); mUnlocalName = "material.gtpp."+Utils.sanitizeString(mLocalName); mMaterial = aMaterial; mID = aNextFreeID++; + Logger.INFO("[TiCon] Assigning ID "+mID+" to "+mLocalName+"."); aInternalMaterialIdMap.put(mUnlocalName, mID); HANDLER_Tinkers.mTinkerMaterials.put(this); } @@ -123,12 +132,12 @@ public class BaseTinkersMaterial { public void generate() { - Logger.INFO("Trying to generate TiCon Material: "+mLocalName); + Logger.INFO("[TiCon] Trying to generate Material: "+mLocalName); int id = mID; if (id > 0) { Object aTinkersCustomMaterial = generateToolMaterial(mMaterial); - Logger.INFO("Created TiCon Material: "+mLocalName); + Logger.INFO("[TiCon] Created Material: "+mLocalName); TinkersUtils.addToolMaterial(id, aTinkersCustomMaterial); TinkersUtils.addDefaultToolPartMaterial(id); @@ -152,33 +161,34 @@ public class BaseTinkersMaterial { tag.setString("Style", calcStyle(mMaterial)); tag.setInteger("Color", calcColour(mMaterial)); - Logger.INFO("Sending IMC to TConstruct: addMaterial - "+mLocalName+"."); - FMLInterModComms.sendMessage("TConstruct", "addMaterial", tag); - - - generateRecipes(mMaterial); - - ItemStack itemstack = mMaterial.getIngot(1); - tag = new NBTTagCompound(); - tag.setInteger("MaterialId", id); - NBTTagCompound item = new NBTTagCompound(); - itemstack.writeToNBT(item); - tag.setTag("Item", item); - tag.setInteger("Value", 2); // What is value for? - - Logger.INFO("Sending IMC to TConstruct: addPartBuilderMaterial - "+mLocalName+"."); - FMLInterModComms.sendMessage("TConstruct", "addPartBuilderMaterial", tag); - - tag = new NBTTagCompound(); - tag.setInteger("MaterialId", id); - tag.setInteger("Value", 2); // What is value for? - item = new NBTTagCompound(); - itemstack.writeToNBT(item); - tag.setTag("Item", item); + boolean generate = generateRecipes(mMaterial); - Logger.INFO("Sending IMC to TConstruct: addMaterialItem - "+mLocalName+"."); - FMLInterModComms.sendMessage("TConstruct", "addMaterialItem", tag); + if (generate) { + Logger.INFO("[TiCon] Sending IMC: addMaterial - "+mLocalName+"."); + FMLInterModComms.sendMessage("TConstruct", "addMaterial", tag); + + ItemStack itemstack = mMaterial.getIngot(1); + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + NBTTagCompound item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + tag.setInteger("Value", 2); // What is value for? + + Logger.INFO("[TiCon] Sending IMC: addPartBuilderMaterial - "+mLocalName+"."); + FMLInterModComms.sendMessage("TConstruct", "addPartBuilderMaterial", tag); + + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + tag.setInteger("Value", 2); // What is value for? + item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + + Logger.INFO("[TiCon] Sending IMC: addMaterialItem - "+mLocalName+"."); + FMLInterModComms.sendMessage("TConstruct", "addMaterialItem", tag); + } } @@ -186,11 +196,30 @@ public class BaseTinkersMaterial { } private boolean generateRecipes(Material aMaterial) { + + Block aMatBlock; + Integer aMelt; + Fluid aFluid; + + try { + aMatBlock = aMaterial.getBlock(); + aMelt = aMaterial.getMeltingPointC(); + aFluid = aMaterial.getFluid(0).getFluid(); + } + catch (Throwable t) { + return false; + } + + if (aMatBlock == null || aMelt == null || aFluid == null) { + return false; + } + + //Smeltery.addMelting(new ItemStack(ExtraUtils.unstableIngot, 1, 0), ExtraUtils.decorative1, 5, 850, aMaterial.getFluid(72)); - TinkersUtils.registerFluidType(mLocalName, aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(0).getFluid(), true); - TinkersUtils.addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)); - TinkersUtils.addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); - if (aMaterial.getMeltingPointC() <= 3600) { + TinkersUtils.registerFluidType(mLocalName, aMatBlock, 0, aMelt, aFluid, true); + TinkersUtils.addMelting(aMaterial.getBlock(1), aMatBlock, 0, aMelt, aMaterial.getFluid(144*9)); + TinkersUtils.addMelting(aMaterial.getIngot(1), aMatBlock, 0, aMelt, aMaterial.getFluid(144)); + if (aMelt <= 3600) { ItemStack ingotcast = TinkersUtils.getPattern(1); TinkersUtils.addBasinRecipe(aMaterial.getBlock(1), aMaterial.getFluid(144*9), (ItemStack) null, true, 100); diff --git a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java index b902e38a1e..450111a113 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java @@ -251,7 +251,7 @@ public class TinkersUtils { public static boolean addCastingTableRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay) { if (mMethodCache.get("addCastingTableRecipe") == null) { - Method m = ReflectionUtils.getMethod(ReflectionUtils.getClass("tconstruct.library.crafting.LiquidCasting"), "addBasinRecipe", ItemStack.class, FluidStack.class, ItemStack.class, boolean.class, int.class); + Method m = ReflectionUtils.getMethod(ReflectionUtils.getClass("tconstruct.library.crafting.LiquidCasting"), "addCastingRecipe", ItemStack.class, FluidStack.class, ItemStack.class, boolean.class, int.class); mMethodCache.put("addCastingTableRecipe", m); } try { @@ -270,15 +270,30 @@ public class TinkersUtils { public static Object getCastingInstance(int aType) { + + + + Method m = null; if (aType == 0) { - return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getTableCasting", new Class[] {}, new Object[] {}); + m = ReflectionUtils.getMethod(getTiConDataInstance(1), "getTableCasting", new Class[] {}); + //return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getTableCasting", new Class[] {}, new Object[] {}); } else if (aType == 1) { - return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getBasinCasting", new Class[] {}, new Object[] {}); + m = ReflectionUtils.getMethod(getTiConDataInstance(1), "getBasinCasting", new Class[] {}); + //return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getBasinCasting", new Class[] {}, new Object[] {}); } else { - return null; - } + //return null; + } + + if (m != null) { + try { + return m.invoke(getTiConDataInstance(1), new Object[] {}); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + return null; } @@ -346,7 +361,7 @@ public class TinkersUtils { public static void addToolMaterial(int id, Object aToolMaterial) { setRegistries(); if (mMethodCache.get("addToolMaterial") == null) { - Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addToolMaterial", int.class, mToolMaterialClass); + Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addtoolMaterial", int.class, mToolMaterialClass); mMethodCache.put("addToolMaterial", m); } try { -- cgit From 9a0e88e397dc52476a0de92768c1022a3e53c9ed Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 1 Mar 2019 04:20:08 +0000 Subject: + Added casting recipes for all new materials (Hopefully). $ Fixed localization of new TiCon materials. $ Fixed bug where cached Fields/Methods may conflict, they're now stored with unique keys. --- .../core/util/reflect/ReflectionUtils.java | 20 +-- .../xmod/tinkers/material/BaseTinkersMaterial.java | 56 ++++-- .../gtPlusPlus/xmod/tinkers/util/TinkersUtils.java | 187 ++++++++++++++++++--- 3 files changed, 221 insertions(+), 42 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 88175b0a82..827ffbf5fb 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -72,27 +72,27 @@ public class ReflectionUtils { return false; } - private static boolean cacheMethod(Method aMethod) { + private static boolean cacheMethod(Class aClass, Method aMethod) { if (aMethod == null) { return false; } boolean isStatic = Modifier.isStatic(aMethod.getModifiers()); - CachedMethod y = mCachedMethods.get(aMethod.getName()+"."+aMethod.getParameterTypes().toString()); + CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethod.getName()+"."+aMethod.getParameterTypes().toString()); if (y == null) { - mCachedMethods.put(aMethod.getName()+"."+aMethod.getParameterTypes().toString(), new CachedMethod(aMethod, isStatic)); + mCachedMethods.put(aClass.getName()+"."+aMethod.getName()+"."+aMethod.getParameterTypes().toString(), new CachedMethod(aMethod, isStatic)); return true; } return false; } - private static boolean cacheField(Field aField) { + private static boolean cacheField(Class aClass, Field aField) { if (aField == null) { return false; } boolean isStatic = Modifier.isStatic(aField.getModifiers()); - CachedField y = mCachedFields.get(aField.getName()); + CachedField y = mCachedFields.get(aClass.getName()+"."+aField.getName()); if (y == null) { - mCachedFields.put(aField.getName(), new CachedField(aField, isStatic)); + mCachedFields.put(aClass.getName()+"."+aField.getName(), new CachedField(aField, isStatic)); return true; } return false; @@ -139,12 +139,12 @@ public class ReflectionUtils { */ public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { String aMethodKey = aTypes.toString(); - CachedMethod y = mCachedMethods.get(aMethodName + "." + aMethodKey); + CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethodName + "." + aMethodKey); if (y == null) { Method u = getMethod_Internal(aClass, aMethodName, aTypes); if (u != null) { Logger.REFLECTION("Caching Method: "+aMethodName + "." + aMethodKey); - cacheMethod(u); + cacheMethod(aClass, u); return u; } else { return null; @@ -163,14 +163,14 @@ public class ReflectionUtils { * @return - Valid, non-final, {@link Field} object, or {@link null}. */ public static Field getField(final Class aClass, final String aFieldName) { - CachedField y = mCachedFields.get(aFieldName); + CachedField y = mCachedFields.get(aClass.getName()+"."+aFieldName); if (y == null) { Field u; try { u = getField_Internal(aClass, aFieldName); if (u != null) { Logger.REFLECTION("Caching Field '"+aFieldName+"' from "+aClass.getCanonicalName()); - cacheField(u); + cacheField(aClass, u); return u; } } catch (NoSuchFieldException e) { diff --git a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java index 19ff630a92..0585eeafd8 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java @@ -34,7 +34,7 @@ public class BaseTinkersMaterial { } public BaseTinkersMaterial(Material aMaterial) { - mLocalName = Utils.sanitizeString(aMaterial.getLocalizedName()); + mLocalName = aMaterial.getLocalizedName(); mUnlocalName = "material.gtpp."+Utils.sanitizeString(mLocalName); mMaterial = aMaterial; mID = aNextFreeID++; @@ -136,18 +136,18 @@ public class BaseTinkersMaterial { int id = mID; if (id > 0) { - Object aTinkersCustomMaterial = generateToolMaterial(mMaterial); - Logger.INFO("[TiCon] Created Material: "+mLocalName); + //Object aTinkersCustomMaterial = generateToolMaterial(mMaterial); + //Logger.INFO("[TiCon] Created Material: "+mLocalName); - TinkersUtils.addToolMaterial(id, aTinkersCustomMaterial); - TinkersUtils.addDefaultToolPartMaterial(id); - TinkersUtils.addBowMaterial(id, calcBowDrawSpeed(mMaterial), 1.0F); - TinkersUtils.addArrowMaterial(id, calcProjectileMass(mMaterial), calcProjectileFragility(mMaterial)); + //TinkersUtils.addToolMaterial(id, aTinkersCustomMaterial); + //TinkersUtils.addDefaultToolPartMaterial(id); + //TinkersUtils.addBowMaterial(id, calcBowDrawSpeed(mMaterial), 1.0F); + //TinkersUtils.addArrowMaterial(id, calcProjectileMass(mMaterial), calcProjectileFragility(mMaterial)); NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("Id", id); - tag.setString("Name", mLocalName); - tag.setString("localizationString", mUnlocalName); + tag.setString("Name", mUnlocalName); + tag.setString("localizationString", mLocalName); tag.setInteger("Durability", calcDurability(mMaterial)); // 97 tag.setInteger("MiningSpeed", calcMiningSpeed(mMaterial)); // 150 tag.setInteger("HarvestLevel", calcHarvestLevel(mMaterial)); // 1 @@ -162,7 +162,7 @@ public class BaseTinkersMaterial { tag.setInteger("Color", calcColour(mMaterial)); - boolean generate = generateRecipes(mMaterial); + boolean generate = generateRecipes(mMaterial, id); if (generate) { Logger.INFO("[TiCon] Sending IMC: addMaterial - "+mLocalName+"."); @@ -195,7 +195,7 @@ public class BaseTinkersMaterial { } - private boolean generateRecipes(Material aMaterial) { + private boolean generateRecipes(Material aMaterial, int aID) { Block aMatBlock; Integer aMelt; @@ -226,6 +226,40 @@ public class BaseTinkersMaterial { TinkersUtils.addCastingTableRecipe(aMaterial.getIngot(1), aMaterial.getFluid(144), ingotcast, false, 50); } + + boolean extended = TinkersUtils.generateCastingRecipes(aMaterial, aID); + + + + + + + //TConstructRegistry.getBasinCasting().addCastingRecipe(new ItemStack(ExtraUtils.decorative1, 1, 5), new FluidStack(unstable, 1296), (ItemStack)null, true, 100); + + + + + + + + + + + + + + + + + + + + + + + + + return true; diff --git a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java index 450111a113..d8c773c014 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java @@ -4,8 +4,12 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; @@ -25,14 +29,34 @@ public class TinkersUtils { private static Object mTinkersRegistryInstance; private static Class mTinkersRegistryClass; - private static final Class mToolMaterialClass; - + private static final Class mToolMaterialClass; + + private static final Class mClass_IPattern; + private static final Class mClass_DynamicToolPart; + private static final Class mClass_FluidType; + private static final Class mClass_CastingRecipe; + + private static final Field mField_MoltenIronFluid; + + private static final Method mMethod_getFluidType; + private static final Method mMethod_getCastingRecipes; + private static final HashMap mMethodCache = new LinkedHashMap(); static { setRegistries(); mToolMaterialClass = ReflectionUtils.getClass("tconstruct.library.tools.ToolMaterial"); + mClass_IPattern = ReflectionUtils.getClass("tconstruct.library.util.IPattern"); + mClass_DynamicToolPart = ReflectionUtils.getClass("tconstruct.library.tools.DynamicToolPart"); + mClass_FluidType = ReflectionUtils.getClass("tconstruct.library.crafting.FluidType"); + mClass_CastingRecipe = ReflectionUtils.getClass("tconstruct.library.crafting.CastingRecipe"); + + mField_MoltenIronFluid = ReflectionUtils.getField(mSmelteryClassInstance, "moltenIronFluid"); + + mMethod_getFluidType = ReflectionUtils.getMethod(mClass_FluidType, "getFluidType", String.class); + mMethod_getCastingRecipes = ReflectionUtils.getMethod(getCastingInstance(0), "getCastingRecipes", new Class[] {}); + } @@ -40,9 +64,9 @@ public class TinkersUtils { * * @param aSwitch - The Registry to return */ - private static Object getTiConDataInstance(int aSwitch) { + private static void setTiConDataInstance() { if (!LoadedMods.TiCon) { - return null; + return; } else { @@ -51,7 +75,6 @@ public class TinkersUtils { } // getSmelteryInstance - if (aSwitch == 0) { //Set Smeltery Instance if (mSmelteryInstance == null || mSmelteryClassInstance == null) { @@ -69,12 +92,11 @@ public class TinkersUtils { //Return Smeltery Instance if (mSmelteryInstance != null) { - return mSmelteryInstance; + //return mSmelteryInstance; } - } + // getTableCastingInstance || getBasinCastingInstance - else if (aSwitch == 1) { if (mTinkersRegistryClass == null || mTinkersRegistryInstance == null) { if (mTinkersRegistryClass == null) { mTinkersRegistryClass = ReflectionUtils.getClass("tconstruct.library.TConstructRegistry"); @@ -92,11 +114,9 @@ public class TinkersUtils { //Return Smeltery Instance if (mTinkersRegistryInstance != null) { - return mTinkersRegistryInstance; - } - } + //return mTinkersRegistryInstance; + } - return null; } } @@ -143,28 +163,32 @@ public class TinkersUtils { * @param duration How long one "portion" of liquid fuels the smeltery. Lava is 10. */ public static void addSmelteryFuel (Fluid fluid, int power, int duration){ - ReflectionUtils.invokeVoid(getTiConDataInstance(0), "addSmelteryFuel", new Class[] {Fluid.class, int.class, int.class}, new Object[] {fluid, power, duration}); + setTiConDataInstance(); + ReflectionUtils.invokeVoid(mSmelteryInstance, "addSmelteryFuel", new Class[] {Fluid.class, int.class, int.class}, new Object[] {fluid, power, duration}); } /** * Returns true if the liquid is a valid smeltery fuel. */ public static boolean isSmelteryFuel (Fluid fluid){ - return ReflectionUtils.invoke(getTiConDataInstance(0), "isSmelteryFuel", new Class[] {Fluid.class}, new Object[] {fluid}); + setTiConDataInstance(); + return ReflectionUtils.invoke(mSmelteryInstance, "isSmelteryFuel", new Class[] {Fluid.class}, new Object[] {fluid}); } /** * Returns the power of a smeltery fuel or 0 if it's not a fuel. */ public static int getFuelPower (Fluid fluid){ - return (int) ReflectionUtils.invokeNonBool(getTiConDataInstance(0), "getFuelPower", new Class[] {Fluid.class}, new Object[] {fluid}); + setTiConDataInstance(); + return (int) ReflectionUtils.invokeNonBool(mSmelteryInstance, "getFuelPower", new Class[] {Fluid.class}, new Object[] {fluid}); } /** * Returns the duration of a smeltery fuel or 0 if it's not a fuel. */ public static int getFuelDuration (Fluid fluid){ - return (int) ReflectionUtils.invokeNonBool(getTiConDataInstance(0), "getFuelDuration", new Class[] {Fluid.class}, new Object[] {fluid}); + setTiConDataInstance(); + return (int) ReflectionUtils.invokeNonBool(mSmelteryInstance, "getFuelDuration", new Class[] {Fluid.class}, new Object[] {fluid}); } @@ -210,6 +234,19 @@ public class TinkersUtils { return false; } } + + public static boolean addMelting(Object type, ItemStack input, int temperatureDifference, int fluidAmount) { + if (mMethodCache.get("addMelting") == null) { + Method m = ReflectionUtils.getMethod(mSmelteryClassInstance, "addMelting", mClass_FluidType, ItemStack.class, int.class, int.class); + mMethodCache.put("addMelting", m); + } + try { + mMethodCache.get("addMelting").invoke(null, type, input, temperatureDifference, fluidAmount); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } @@ -268,18 +305,22 @@ public class TinkersUtils { - + /** + * 0 For Table, 1 For Basin. + * @param aType - Casting Type + * @return - The casting instance. + */ public static Object getCastingInstance(int aType) { - + setTiConDataInstance(); Method m = null; if (aType == 0) { - m = ReflectionUtils.getMethod(getTiConDataInstance(1), "getTableCasting", new Class[] {}); + m = ReflectionUtils.getMethod(mTinkersRegistryInstance, "getTableCasting", new Class[] {}); //return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getTableCasting", new Class[] {}, new Object[] {}); } else if (aType == 1) { - m = ReflectionUtils.getMethod(getTiConDataInstance(1), "getBasinCasting", new Class[] {}); + m = ReflectionUtils.getMethod(mTinkersRegistryInstance, "getBasinCasting", new Class[] {}); //return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getBasinCasting", new Class[] {}, new Object[] {}); } else { @@ -288,7 +329,7 @@ public class TinkersUtils { if (m != null) { try { - return m.invoke(getTiConDataInstance(1), new Object[] {}); + return m.invoke(mTinkersRegistryInstance, new Object[] {}); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } @@ -406,5 +447,109 @@ public class TinkersUtils { } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } + + public static List getTableCastingRecipes(){ + Object aCastingTableHandlerInstance = getCastingInstance(0); + List aTemp; + try { + aTemp = (List) mMethod_getCastingRecipes.invoke(aCastingTableHandlerInstance, new Object[] {}); + return aTemp; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return new ArrayList(); + } + + public static boolean generateCastingRecipes(Material aMaterial, int aID) { + + List newRecipies = new LinkedList(); + + if (true) { + Iterator i$ = getTableCastingRecipes().iterator(); + while (i$.hasNext()) { + CastingRecipeHandler recipe = new CastingRecipeHandler(i$.next()); + try { + if (recipe.valid && recipe.castingMetal.getFluid() == mField_MoltenIronFluid.get(null) && recipe.cast != null + && mClass_IPattern.isInstance(recipe.cast.getItem()) && mClass_DynamicToolPart.isInstance(recipe.getResult().getItem())) { + newRecipies.add(recipe); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + return false; + } + } + } + + if (true) { + Object ft; + try { + ft = mMethod_getFluidType.invoke(null, aMaterial.getLocalizedName()); + Iterator i$ = newRecipies.iterator(); + while (i$.hasNext()) { + CastingRecipeHandler recipe = new CastingRecipeHandler(i$.next()); + if (!recipe.valid){ + continue; + } + //CastingRecipe recipe = (CastingRecipe) i$.next(); + ItemStack output = recipe.getResult().copy(); + output.setItemDamage(aID); + FluidStack liquid2 = new FluidStack(aMaterial.getFluid(0).getFluid(), recipe.castingMetal.amount); + addCastingTableRecipe(output, liquid2, recipe.cast, recipe.consumeCast, recipe.coolTime); + addMelting(ft, output, 0, liquid2.amount / 2); + } + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + return false; + } + } + return true; + } + + private static class CastingRecipeHandler { + + public ItemStack output; + public FluidStack castingMetal; + public ItemStack cast; + public boolean consumeCast; + public int coolTime; + + public boolean valid; + + public CastingRecipeHandler(Object aCastingRecipe) { + if (mClass_CastingRecipe.isInstance(aCastingRecipe)) { + try { + Field aF_output = ReflectionUtils.getField(mClass_CastingRecipe, "output"); + Field aF_castingMetal = ReflectionUtils.getField(mClass_CastingRecipe, "castingMetal"); + Field aF_cast = ReflectionUtils.getField(mClass_CastingRecipe, "cast"); + Field aF_consumeCast = ReflectionUtils.getField(mClass_CastingRecipe, "consumeCast"); + Field aF_coolTime = ReflectionUtils.getField(mClass_CastingRecipe, "coolTime"); + + output = (ItemStack) aF_output.get(aCastingRecipe); + castingMetal = (FluidStack) aF_castingMetal.get(aCastingRecipe); + cast = (ItemStack) aF_cast.get(aCastingRecipe); + consumeCast = (boolean) aF_consumeCast.get(aCastingRecipe); + coolTime = (int) aF_coolTime.get(aCastingRecipe); + valid = true; + } + catch (Throwable t) { + t.printStackTrace(); + valid = false; + } + } + else { + valid = false; + } + } + + public boolean matches(FluidStack metal, ItemStack inputCast) { + return this.castingMetal.isFluidEqual(metal) && (this.cast != null && this.cast.getItemDamage() == 32767 + && inputCast.getItem() == this.cast.getItem() || ItemStack.areItemStacksEqual(this.cast, inputCast)); + } + + public ItemStack getResult() { + return this.output.copy(); + } + + } } -- cgit From b126379ca7e069c93c3b42a7e87e77c209a894c3 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 1 Mar 2019 05:15:22 +0000 Subject: $ Final fixes to TiCon reflective integration. Now to just tweak the added content and rebalance. $ Fixed hand mix Tumbaga recipe inconsistency. --- .../gtPlusPlus/core/recipe/RECIPES_General.java | 2 +- .../core/util/reflect/ReflectionUtils.java | 17 +- .../xmod/tinkers/material/BaseTinkersMaterial.java | 2 +- .../gtPlusPlus/xmod/tinkers/util/TinkersUtils.java | 171 +++++++++------------ 4 files changed, 83 insertions(+), 109 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index c2fd4adc41..54380306cc 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -178,7 +178,7 @@ public class RECIPES_General { ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), - "dustCopper" + "dustGold" }, ALLOY.TUMBAGA.getDust(10))){ Logger.INFO("Added shapeless recipe for Tumbaga Dust."); diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 827ffbf5fb..617728cdec 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -9,6 +9,8 @@ import java.lang.reflect.Modifier; import java.util.LinkedHashMap; import java.util.Map; +import org.apache.commons.lang3.ArrayUtils; + import com.google.common.reflect.ClassPath; import gtPlusPlus.api.objects.Logger; @@ -77,9 +79,9 @@ public class ReflectionUtils { return false; } boolean isStatic = Modifier.isStatic(aMethod.getModifiers()); - CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethod.getName()+"."+aMethod.getParameterTypes().toString()); + CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethod.getName()+"."+ArrayUtils.toString(aMethod.getParameterTypes())); if (y == null) { - mCachedMethods.put(aClass.getName()+"."+aMethod.getName()+"."+aMethod.getParameterTypes().toString(), new CachedMethod(aMethod, isStatic)); + mCachedMethods.put(aClass.getName()+"."+aMethod.getName()+"."+ArrayUtils.toString(aMethod.getParameterTypes()), new CachedMethod(aMethod, isStatic)); return true; } return false; @@ -138,7 +140,8 @@ public class ReflectionUtils { * @return - Valid, non-final, {@link Method} object, or {@link null}. */ public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { - String aMethodKey = aTypes.toString(); + String aMethodKey = ArrayUtils.toString(aTypes); + //Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethodName + "." + aMethodKey); if (y == null) { Method u = getMethod_Internal(aClass, aMethodName, aTypes); @@ -169,7 +172,7 @@ public class ReflectionUtils { try { u = getField_Internal(aClass, aFieldName); if (u != null) { - Logger.REFLECTION("Caching Field '"+aFieldName+"' from "+aClass.getCanonicalName()); + Logger.REFLECTION("Caching Field '"+aFieldName+"' from "+aClass.getName()); cacheField(aClass, u); return u; } @@ -426,16 +429,20 @@ public class ReflectionUtils { private static Field getField_Internal(final Class clazz, final String fieldName) throws NoSuchFieldException { try { + Logger.REFLECTION("Field: Internal Lookup: "+fieldName); Field k = clazz.getDeclaredField(fieldName); makeFieldAccessible(k); //Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); return k; } catch (final NoSuchFieldException e) { + Logger.REFLECTION("Field: Internal Lookup Failed: "+fieldName); final Class superClass = clazz.getSuperclass(); if (superClass == null) { + Logger.REFLECTION("Unable to find field '"+fieldName+"'"); //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+"."); throw e; } + Logger.REFLECTION("Method: Recursion Lookup: "+fieldName+" - Checking in "+superClass.getName()); //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+". Trying super class."); return getField_Internal(superClass, fieldName); } @@ -511,7 +518,7 @@ public class ReflectionUtils { } private static void dumpClassInfo(Class aClass) { - Logger.INFO("We ran into an error processing reflection in "+aClass.getCanonicalName()+", dumping all data for debugging."); + Logger.INFO("We ran into an error processing reflection in "+aClass.getName()+", dumping all data for debugging."); // Get the methods Method[] methods = aClass.getDeclaredMethods(); Field[] fields = aClass.getDeclaredFields(); diff --git a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java index 0585eeafd8..6f47909a01 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java @@ -30,7 +30,7 @@ public class BaseTinkersMaterial { private final Material mMaterial; static { - aNextFreeID = Short.MAX_VALUE+420; + aNextFreeID = (Short.MAX_VALUE/2)+420; } public BaseTinkersMaterial(Material aMaterial) { diff --git a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java index d8c773c014..f0c6d76b7c 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java @@ -11,6 +11,7 @@ import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; +import gregtech.api.enums.Materials; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -23,40 +24,41 @@ import net.minecraftforge.fluids.FluidStack; public class TinkersUtils { - private static Object mSmelteryInstance; - private static Class mSmelteryClassInstance; - - private static Object mTinkersRegistryInstance; - private static Class mTinkersRegistryClass; - - private static final Class mToolMaterialClass; - + private static final Class mClass_Smeltery; + private static final Class mClass_TConstructRegistry; + private static final Class mClass_ToolMaterial; private static final Class mClass_IPattern; private static final Class mClass_DynamicToolPart; private static final Class mClass_FluidType; private static final Class mClass_CastingRecipe; + private static final Class mClass_TinkerSmeltery; private static final Field mField_MoltenIronFluid; private static final Method mMethod_getFluidType; private static final Method mMethod_getCastingRecipes; + + private static Object mSmelteryInstance; + private static Object mTinkersRegistryInstance; private static final HashMap mMethodCache = new LinkedHashMap(); - static { - setRegistries(); - mToolMaterialClass = ReflectionUtils.getClass("tconstruct.library.tools.ToolMaterial"); + static { + mClass_Smeltery = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery"); + mClass_TConstructRegistry = ReflectionUtils.getClass("tconstruct.library.TConstructRegistry"); + + mClass_ToolMaterial = ReflectionUtils.getClass("tconstruct.library.tools.ToolMaterial"); mClass_IPattern = ReflectionUtils.getClass("tconstruct.library.util.IPattern"); mClass_DynamicToolPart = ReflectionUtils.getClass("tconstruct.library.tools.DynamicToolPart"); mClass_FluidType = ReflectionUtils.getClass("tconstruct.library.crafting.FluidType"); mClass_CastingRecipe = ReflectionUtils.getClass("tconstruct.library.crafting.CastingRecipe"); + mClass_TinkerSmeltery = ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery"); - mField_MoltenIronFluid = ReflectionUtils.getField(mSmelteryClassInstance, "moltenIronFluid"); + mField_MoltenIronFluid = ReflectionUtils.getField(mClass_TinkerSmeltery, "moltenIronFluid"); mMethod_getFluidType = ReflectionUtils.getMethod(mClass_FluidType, "getFluidType", String.class); - mMethod_getCastingRecipes = ReflectionUtils.getMethod(getCastingInstance(0), "getCastingRecipes", new Class[] {}); - + mMethod_getCastingRecipes = ReflectionUtils.getMethod(getCastingInstance(0), "getCastingRecipes", new Class[] {}); } @@ -67,65 +69,23 @@ public class TinkersUtils { private static void setTiConDataInstance() { if (!LoadedMods.TiCon) { return; - } - else { - - if (mTinkersRegistryClass == null || mSmelteryClassInstance == null) { - setRegistries(); - } - - // getSmelteryInstance - - //Set Smeltery Instance - if (mSmelteryInstance == null || mSmelteryClassInstance == null) { - if (mSmelteryClassInstance == null) { - mSmelteryClassInstance = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery"); + } else { + if (mSmelteryInstance == null) { + if (mClass_Smeltery != null) { + try { + mSmelteryInstance = ReflectionUtils.getField(mClass_Smeltery, "instance").get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { } - if (mSmelteryClassInstance != null) { - try { - mSmelteryInstance = ReflectionUtils.getField(mSmelteryClassInstance, "instance").get(null); - } - catch (IllegalArgumentException | IllegalAccessException e) { - } - } - } - - //Return Smeltery Instance - if (mSmelteryInstance != null) { - //return mSmelteryInstance; } - - - // getTableCastingInstance || getBasinCastingInstance - if (mTinkersRegistryClass == null || mTinkersRegistryInstance == null) { - if (mTinkersRegistryClass == null) { - mTinkersRegistryClass = ReflectionUtils.getClass("tconstruct.library.TConstructRegistry"); + } + if (mTinkersRegistryInstance == null) { + if (mClass_TConstructRegistry != null) { + try { + mTinkersRegistryInstance = ReflectionUtils.getField(mClass_TConstructRegistry, "instance").get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { } - if (mTinkersRegistryClass != null) { - if (mTinkersRegistryInstance == null) { - try { - mTinkersRegistryInstance = ReflectionUtils.getField(mTinkersRegistryClass, "instance").get(null); - } - catch (IllegalArgumentException | IllegalAccessException e) { - } - } - } } - - //Return Smeltery Instance - if (mTinkersRegistryInstance != null) { - //return mTinkersRegistryInstance; - } - - } - } - - private static void setRegistries() { - if (mTinkersRegistryClass == null) { - mTinkersRegistryClass = ReflectionUtils.getClass("tconstruct.library.TConstructRegistry"); - } - if (mSmelteryClassInstance == null) { - mSmelteryClassInstance = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery"); + } } } @@ -224,7 +184,7 @@ public class TinkersUtils { public static boolean addMelting(ItemStack input, Block block, int metadata, int temperature, FluidStack liquid) { if (mMethodCache.get("addMelting") == null) { - Method m = ReflectionUtils.getMethod(mSmelteryClassInstance, "addMelting", ItemStack.class, Block.class, int.class, int.class, FluidStack.class); + Method m = ReflectionUtils.getMethod(mClass_Smeltery, "addMelting", ItemStack.class, Block.class, int.class, int.class, FluidStack.class); mMethodCache.put("addMelting", m); } try { @@ -237,7 +197,7 @@ public class TinkersUtils { public static boolean addMelting(Object type, ItemStack input, int temperatureDifference, int fluidAmount) { if (mMethodCache.get("addMelting") == null) { - Method m = ReflectionUtils.getMethod(mSmelteryClassInstance, "addMelting", mClass_FluidType, ItemStack.class, int.class, int.class); + Method m = ReflectionUtils.getMethod(mClass_Smeltery, "addMelting", mClass_FluidType, ItemStack.class, int.class, int.class); mMethodCache.put("addMelting", m); } try { @@ -341,7 +301,7 @@ public class TinkersUtils { private static Item mTinkerMetalPattern; public static ItemStack getPattern(int aType) { if (mTinkerMetalPattern == null) { - Field m = ReflectionUtils.getField(ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery"), "metalPattern"); + Field m = ReflectionUtils.getField(mClass_TinkerSmeltery, "metalPattern"); if (m != null) { try { mTinkerMetalPattern = (Item) m.get(null); @@ -380,7 +340,7 @@ public class TinkersUtils { */ public static Object generateToolMaterial(String name, String localizationString, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor) { try { - Constructor constructor = mToolMaterialClass.getConstructor(String.class, String.class, int.class, int.class, int.class, int.class, float.class, int.class, float.class, String.class, int.class); + Constructor constructor = mClass_ToolMaterial.getConstructor(String.class, String.class, int.class, int.class, int.class, int.class, float.class, int.class, float.class, String.class, int.class); Object myObject = constructor.newInstance(name, localizationString, level, durability, speed, damage, handle, reinforced, stonebound, style, primaryColor); return myObject; } catch (Throwable t) { @@ -399,51 +359,47 @@ public class TinkersUtils { - public static void addToolMaterial(int id, Object aToolMaterial) { - setRegistries(); + public static void addToolMaterial(int id, Object aToolMaterial) { if (mMethodCache.get("addToolMaterial") == null) { - Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addtoolMaterial", int.class, mToolMaterialClass); + Method m = ReflectionUtils.getMethod(mClass_TConstructRegistry, "addtoolMaterial", int.class, mClass_ToolMaterial); mMethodCache.put("addToolMaterial", m); } try { - mMethodCache.get("addToolMaterial").invoke(mTinkersRegistryClass, id, aToolMaterial); + mMethodCache.get("addToolMaterial").invoke(mClass_TConstructRegistry, id, aToolMaterial); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } - public static void addDefaultToolPartMaterial(int id) { - setRegistries(); + public static void addDefaultToolPartMaterial(int id) { if (mMethodCache.get("addDefaultToolPartMaterial") == null) { - Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addDefaultToolPartMaterial", int.class); + Method m = ReflectionUtils.getMethod(mClass_TConstructRegistry, "addDefaultToolPartMaterial", int.class); mMethodCache.put("addDefaultToolPartMaterial", m); } try { - mMethodCache.get("addDefaultToolPartMaterial").invoke(mTinkersRegistryClass, id); + mMethodCache.get("addDefaultToolPartMaterial").invoke(mClass_TConstructRegistry, id); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } - public static void addBowMaterial(int id, int drawspeed, float maxSpeed) { - setRegistries(); + public static void addBowMaterial(int id, int drawspeed, float maxSpeed) { if (mMethodCache.get("addBowMaterial") == null) { - Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addBowMaterial", int.class, int.class, float.class); + Method m = ReflectionUtils.getMethod(mClass_TConstructRegistry, "addBowMaterial", int.class, int.class, float.class); mMethodCache.put("addBowMaterial", m); } try { - mMethodCache.get("addBowMaterial").invoke(mTinkersRegistryClass, id, drawspeed, maxSpeed); + mMethodCache.get("addBowMaterial").invoke(mClass_TConstructRegistry, id, drawspeed, maxSpeed); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } - public static void addArrowMaterial(int id, float mass, float fragility) { - setRegistries(); + public static void addArrowMaterial(int id, float mass, float fragility) { if (mMethodCache.get("addArrowMaterial") == null) { - Method m = ReflectionUtils.getMethod(mTinkersRegistryClass, "addArrowMaterial", int.class, float.class, float.class); + Method m = ReflectionUtils.getMethod(mClass_TConstructRegistry, "addArrowMaterial", int.class, float.class, float.class); mMethodCache.put("addArrowMaterial", m); } try { - mMethodCache.get("addArrowMaterial").invoke(mTinkersRegistryClass, id, mass, fragility); + mMethodCache.get("addArrowMaterial").invoke(mClass_TConstructRegistry, id, mass, fragility); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } @@ -464,29 +420,40 @@ public class TinkersUtils { List newRecipies = new LinkedList(); - if (true) { - Iterator i$ = getTableCastingRecipes().iterator(); - while (i$.hasNext()) { - CastingRecipeHandler recipe = new CastingRecipeHandler(i$.next()); + + Iterator iterator1 = getTableCastingRecipes().iterator(); + Fluid aMoltenIron = null; + if (aMoltenIron == null) { try { - if (recipe.valid && recipe.castingMetal.getFluid() == mField_MoltenIronFluid.get(null) && recipe.cast != null + aMoltenIron = (Fluid) mField_MoltenIronFluid.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + aMoltenIron = Materials.Iron.getMolten(0).getFluid(); + } + } + while (iterator1.hasNext()) { + CastingRecipeHandler recipe = new CastingRecipeHandler(iterator1.next()); + if (recipe == null || !recipe.valid) { + continue; + } + try { + if (recipe.castingMetal.getFluid() == aMoltenIron && recipe.cast != null && mClass_IPattern.isInstance(recipe.cast.getItem()) && mClass_DynamicToolPart.isInstance(recipe.getResult().getItem())) { newRecipies.add(recipe); } - } catch (IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalArgumentException e) { e.printStackTrace(); return false; } } - } - - if (true) { + + Object ft; try { ft = mMethod_getFluidType.invoke(null, aMaterial.getLocalizedName()); - Iterator i$ = newRecipies.iterator(); - while (i$.hasNext()) { - CastingRecipeHandler recipe = new CastingRecipeHandler(i$.next()); + Iterator iterator2 = newRecipies.iterator(); + while (iterator2.hasNext()) { + CastingRecipeHandler recipe = new CastingRecipeHandler(iterator2.next()); if (!recipe.valid){ continue; } @@ -501,7 +468,7 @@ public class TinkersUtils { e.printStackTrace(); return false; } - } + return true; } -- cgit From f8814f83fa9f34e6088e98bed0561ce6cb13842d Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 4 Mar 2019 16:09:00 +0000 Subject: - Disabled custom Tinkers Materials for the time being. % Reworking custom TC aspects. % Migrated lots of TC code to be reflective instead. --- .../xmod/thaumcraft/aspect/GTPP_AspectCompat.java | 76 ++----- .../xmod/thaumcraft/aspect/TC_Aspect.java | 243 +++++++++++++++++++++ .../gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java | 2 +- 3 files changed, 265 insertions(+), 56 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java index e3aeed75bd..96df6485f8 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java @@ -13,6 +13,8 @@ import gregtech.api.util.GT_LanguageManager; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import net.minecraft.block.Block; @@ -25,62 +27,26 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { public static volatile Method m = null; + private static HashMap mAspectCache = new LinkedHashMap(); + public GTPP_AspectCompat() { - // Standard Aspects - GTPP_Aspects.AER.mAspect = Aspect.AIR; - GTPP_Aspects.ALIENIS.mAspect = Aspect.ELDRITCH; - GTPP_Aspects.AQUA.mAspect = Aspect.WATER; - GTPP_Aspects.ARBOR.mAspect = Aspect.TREE; - GTPP_Aspects.AURAM.mAspect = Aspect.AURA; - GTPP_Aspects.BESTIA.mAspect = Aspect.BEAST; - GTPP_Aspects.COGNITIO.mAspect = Aspect.MIND; - GTPP_Aspects.CORPUS.mAspect = Aspect.FLESH; - GTPP_Aspects.EXANIMIS.mAspect = Aspect.UNDEAD; - GTPP_Aspects.FABRICO.mAspect = Aspect.CRAFT; - GTPP_Aspects.FAMES.mAspect = Aspect.HUNGER; - GTPP_Aspects.GELUM.mAspect = Aspect.COLD; - GTPP_Aspects.GRANUM.mAspect = Aspect.PLANT; - GTPP_Aspects.HERBA.mAspect = Aspect.PLANT; - GTPP_Aspects.HUMANUS.mAspect = Aspect.MAN; - GTPP_Aspects.IGNIS.mAspect = Aspect.FIRE; - GTPP_Aspects.INSTRUMENTUM.mAspect = Aspect.TOOL; - GTPP_Aspects.ITER.mAspect = Aspect.TRAVEL; - GTPP_Aspects.LIMUS.mAspect = Aspect.SLIME; - GTPP_Aspects.LUCRUM.mAspect = Aspect.GREED; - GTPP_Aspects.LUX.mAspect = Aspect.LIGHT; - GTPP_Aspects.MACHINA.mAspect = Aspect.MECHANISM; - GTPP_Aspects.MESSIS.mAspect = Aspect.CROP; - GTPP_Aspects.METALLUM.mAspect = Aspect.METAL; - GTPP_Aspects.METO.mAspect = Aspect.HARVEST; - GTPP_Aspects.MORTUUS.mAspect = Aspect.DEATH; - GTPP_Aspects.MOTUS.mAspect = Aspect.MOTION; - GTPP_Aspects.ORDO.mAspect = Aspect.ORDER; - GTPP_Aspects.PANNUS.mAspect = Aspect.CLOTH; - GTPP_Aspects.PERDITIO.mAspect = Aspect.ENTROPY; - GTPP_Aspects.PERFODIO.mAspect = Aspect.MINE; - GTPP_Aspects.PERMUTATIO.mAspect = Aspect.EXCHANGE; - GTPP_Aspects.POTENTIA.mAspect = Aspect.ENERGY; - GTPP_Aspects.PRAECANTATIO.mAspect = Aspect.MAGIC; - GTPP_Aspects.SANO.mAspect = Aspect.HEAL; - GTPP_Aspects.SENSUS.mAspect = Aspect.SENSES; - GTPP_Aspects.SPIRITUS.mAspect = Aspect.SOUL; - GTPP_Aspects.TELUM.mAspect = Aspect.WEAPON; - GTPP_Aspects.TERRA.mAspect = Aspect.EARTH; - GTPP_Aspects.TEMPESTAS.mAspect = Aspect.WEATHER; - GTPP_Aspects.TENEBRAE.mAspect = Aspect.DARKNESS; - GTPP_Aspects.TUTAMEN.mAspect = Aspect.ARMOR; - GTPP_Aspects.VACUOS.mAspect = Aspect.VOID; - GTPP_Aspects.VENENUM.mAspect = Aspect.POISON; - GTPP_Aspects.VICTUS.mAspect = Aspect.LIFE; - GTPP_Aspects.VINCULUM.mAspect = Aspect.TRAP; - GTPP_Aspects.VITIUM.mAspect = Aspect.TAINT; - GTPP_Aspects.VITREUS.mAspect = Aspect.CRYSTAL; - GTPP_Aspects.VOLATUS.mAspect = Aspect.FLIGHT; - GTPP_Aspects.STRONTIO.mAspect = (Aspect) TC_Aspects.STRONTIO.mAspect; - GTPP_Aspects.NEBRISUM.mAspect = (Aspect) TC_Aspects.NEBRISUM.mAspect; - GTPP_Aspects.ELECTRUM.mAspect = (Aspect) TC_Aspects.ELECTRUM.mAspect; - GTPP_Aspects.MAGNETO.mAspect = (Aspect) TC_Aspects.MAGNETO.mAspect; - GTPP_Aspects.RADIO.mAspect = (Aspect) TC_Aspects.RADIO.mAspect; + + + //Generate all existing Aspects as TC_Aspects + LinkedHashMap h = TC_Aspect.getVanillaAspectList(); + for (String g : h.keySet()) { + Object aBaseAspect = h.get(g); + if (aBaseAspect != null && TC_Aspect.isObjectAnAspect(aBaseAspect)) { + TC_Aspect aS = TC_Aspect.getAspect(g); + if (aS != null) { + mAspectCache.put(g, aS); + continue; + } + } + } + + + // Custom Aspects GTPP_Aspects.CUSTOM_1.mAspect = new Aspect("custom1", 15647411, new Aspect[]{Aspect.COLD, Aspect.FIRE}, diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java new file mode 100644 index 0000000000..b05b6f1e2b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java @@ -0,0 +1,243 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.LinkedHashMap; +import java.util.Map; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.util.ResourceLocation; + +/** + * Wrapper class for Thaumcraft Aspects. + * Used to avoid compile time dependencies. + * @author Alkalus + * + */ +public class TC_Aspect { + + private static Class mClass_Aspect; + private static Field mField_Aspects; + + private final String tag; + private final TC_Aspect[] components; + private final int color; + private String chatcolor; + private final ResourceLocation image; + private final int blend; + + private final Object mAspect; + + + + + /** + * Statically set the Class objects + */ + static { + mClass_Aspect = ReflectionUtils.getClass("thaumcraft.api.aspects.Aspect"); + } + + /** + * Gets the total aspect list from Thaumcraft, which should contain all other registered aspects. + * @return - A LinkedHashMap(String, Aspect); + */ + public static LinkedHashMap getVanillaAspectList() { + try { + if (mField_Aspects == null) { + mField_Aspects = ReflectionUtils.getField(mClass_Aspect, "aspects"); + } + return (LinkedHashMap) mField_Aspects.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + Logger.REFLECTION("Failed configuring TC Aspect compatibility."); + return new LinkedHashMap(); + } + } + + + + + + + + + + + + + + + /** + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param chatcolor + * @param blend + */ + public TC_Aspect(String tag, int color, String chatcolor, int blend) { + this(tag, color, (TC_Aspect[]) null, blend); + this.chatcolor = chatcolor; + } + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + */ + public TC_Aspect(String tag, int color, TC_Aspect[] components) { + this(tag, color, components, true, 1); + } + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + * @param blend + */ + public TC_Aspect(String tag, int color, TC_Aspect[] components, int blend) { + this(tag, color, components, true, blend); + } + + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + * @param image + * @param blend + */ + public TC_Aspect(String tag, int color, TC_Aspect[] components, boolean vanilla, int blend) { + this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), blend); + } + + + public TC_Aspect(String tag, int color, TC_Aspect[] components, ResourceLocation image, int blend) { + if (getAspectList().containsKey(tag)) { + throw new IllegalArgumentException(tag + " already registered!"); + } else { + this.tag = tag; + this.components = components; + this.color = color; + this.image = image; + this.blend = blend; + this.mAspect = this.generateTcAspect(); + } + } + + + + /** + * Generates a TC_Aspect from an object, presummed to be a TC Aspect. + * @param aBaseAspect - The TC Aspect to generate from. + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + public TC_Aspect(Object aBaseAspect) throws IllegalArgumentException, IllegalAccessException { + this((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(aBaseAspect), (int) ReflectionUtils.getField(mClass_Aspect, "color").get(aBaseAspect), generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), aBaseAspect), (ResourceLocation) ReflectionUtils.getField(mClass_Aspect, "image").get(aBaseAspect), (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect)); + Field aChatColour = ReflectionUtils.getField(mClass_Aspect, "chatcolor"); + chatcolor = (String) aChatColour.get(aBaseAspect); + } + + + /** + * Internal Map containing all the TC_Aspects. + */ + private static Map mInternalAspectCache = new LinkedHashMap(); + + /** + * Public getter for all TC_Aspects + * @param aAspectName - Aspect Name + * @return - A GT++ Aspect wrapper or null. (TC_Aspect) + */ + public static TC_Aspect getAspect(String aAspectName) { + TC_Aspect g = mInternalAspectCache.get(aAspectName); + if (g != null) { + return g; + } + else { + try { + TC_Aspect aTemp = new TC_Aspect(getAspectList().get(aAspectName)); + if (aTemp != null) { + mInternalAspectCache.put(aAspectName, aTemp); + return aTemp; + } + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + } + } + return null; + } + + public static Map getAspectList(){ + return mInternalAspectCache; + } + + + private static TC_Aspect[] generateAspectArrayInternal(Field aField, Object aInstance) { + //thaumcraft.api.aspects.Aspect.Aspect() + Object[] components; + TC_Aspect[] aAspectArray; + try { + components = (Object[]) aField.get(aInstance); + aAspectArray = new TC_Aspect[components.length]; + if (components.length > 0) { + int i = 0; + for (Object g : components) { + aAspectArray[i] = getAspect((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(g)); + i++; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + aAspectArray = new TC_Aspect[0]; + } + return aAspectArray; + } + + /** + * Tasty code to generate TC Aspects reflectively. + * @return + */ + public Object generateTcAspect() { + try { + //thaumcraft.api.aspects.Aspect.Aspect() + Object aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, 1); + if (components.length > 0) { + aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, components.length); + int i = 0; + for (TC_Aspect g : components) { + ((Object[]) aAspectArray)[i++] = g.mAspect; + } + } + Constructor constructor = mClass_Aspect.getConstructor(String.class, int.class, aAspectArray.getClass(), ResourceLocation.class, int.class); + Object myObject = constructor.newInstance(tag, color, aAspectArray, image, blend); + + //Set chat colour + if (chatcolor != null && chatcolor.length() > 0) { + Method setChatColour = ReflectionUtils.getMethod(mClass_Aspect, "setChatcolor", String.class); + if (setChatColour != null) { + setChatColour.invoke(myObject, chatcolor); + } + } + return myObject; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + public static boolean isObjectAnAspect(Object aAspect) { + return mClass_Aspect.isInstance(aAspect); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java index 9ba10fc40e..3b2bcba5dd 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java @@ -38,7 +38,7 @@ public class HANDLER_Tinkers { if (LoadedMods.TiCon) { for (BaseTinkersMaterial y : mTinkerMaterials) { - y.generate(); + //y.generate(); } Class aTinkersSmeltery = ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery"); -- cgit From 91371c9020ec10827653414d58dc7311b73ea686 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 4 Mar 2019 16:35:50 +0000 Subject: % More TC Work. --- .../xmod/thaumcraft/aspect/GTPP_AspectCompat.java | 106 +++++++++++++++++++-- .../xmod/thaumcraft/aspect/TC_Aspect.java | 52 +++++++--- 2 files changed, 137 insertions(+), 21 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java index 96df6485f8..c363cba459 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java @@ -29,10 +29,69 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { private static HashMap mAspectCache = new LinkedHashMap(); + + public static TC_Aspect ASPECT_BALANCE; + public static TC_Aspect ASPECT_LUST; + public static TC_Aspect ASPECT_STARBOUND; + public static TC_Aspect ASPECT_TOXIC; + public static TC_Aspect ASPECT_HEAVEN; + + +/* TC_Aspects.AER.mAspect = Aspect.AIR; + TC_Aspects.ALIENIS.mAspect = Aspect.ELDRITCH; + TC_Aspects.AQUA.mAspect = Aspect.WATER; + TC_Aspects.ARBOR.mAspect = Aspect.TREE; + TC_Aspects.AURAM.mAspect = Aspect.AURA; + TC_Aspects.BESTIA.mAspect = Aspect.BEAST; + TC_Aspects.COGNITIO.mAspect = Aspect.MIND; + TC_Aspects.CORPUS.mAspect = Aspect.FLESH; + TC_Aspects.EXANIMIS.mAspect = Aspect.UNDEAD; + TC_Aspects.FABRICO.mAspect = Aspect.CRAFT; + TC_Aspects.FAMES.mAspect = Aspect.HUNGER; + TC_Aspects.GELUM.mAspect = Aspect.COLD; + TC_Aspects.GRANUM.mAspect = Aspect.PLANT; + TC_Aspects.HERBA.mAspect = Aspect.PLANT; + TC_Aspects.HUMANUS.mAspect = Aspect.MAN; + TC_Aspects.IGNIS.mAspect = Aspect.FIRE; + TC_Aspects.INSTRUMENTUM.mAspect = Aspect.TOOL; + TC_Aspects.ITER.mAspect = Aspect.TRAVEL; + TC_Aspects.LIMUS.mAspect = Aspect.SLIME; + TC_Aspects.LUCRUM.mAspect = Aspect.GREED; + TC_Aspects.LUX.mAspect = Aspect.LIGHT; + TC_Aspects.MACHINA.mAspect = Aspect.MECHANISM; + TC_Aspects.MESSIS.mAspect = Aspect.CROP; + TC_Aspects.METALLUM.mAspect = Aspect.METAL; + TC_Aspects.METO.mAspect = Aspect.HARVEST; + TC_Aspects.MORTUUS.mAspect = Aspect.DEATH; + TC_Aspects.MOTUS.mAspect = Aspect.MOTION; + TC_Aspects.ORDO.mAspect = Aspect.ORDER; + TC_Aspects.PANNUS.mAspect = Aspect.CLOTH; + TC_Aspects.PERDITIO.mAspect = Aspect.ENTROPY; + TC_Aspects.PERFODIO.mAspect = Aspect.MINE; + TC_Aspects.PERMUTATIO.mAspect = Aspect.EXCHANGE; + TC_Aspects.POTENTIA.mAspect = Aspect.ENERGY; + TC_Aspects.PRAECANTATIO.mAspect = Aspect.MAGIC; + TC_Aspects.SANO.mAspect = Aspect.HEAL; + TC_Aspects.SENSUS.mAspect = Aspect.SENSES; + TC_Aspects.SPIRITUS.mAspect = Aspect.SOUL; + TC_Aspects.TELUM.mAspect = Aspect.WEAPON; + TC_Aspects.TERRA.mAspect = Aspect.EARTH; + TC_Aspects.TEMPESTAS.mAspect = Aspect.WEATHER; + TC_Aspects.TENEBRAE.mAspect = Aspect.DARKNESS; + TC_Aspects.TUTAMEN.mAspect = Aspect.ARMOR; + TC_Aspects.VACUOS.mAspect = Aspect.VOID; + TC_Aspects.VENENUM.mAspect = Aspect.POISON; + TC_Aspects.VICTUS.mAspect = Aspect.LIFE; + TC_Aspects.VINCULUM.mAspect = Aspect.TRAP; + TC_Aspects.VITIUM.mAspect = Aspect.TAINT; + TC_Aspects.VITREUS.mAspect = Aspect.CRYSTAL; + TC_Aspects.VOLATUS.mAspect = Aspect.FLIGHT;*/ + + public GTPP_AspectCompat() { - //Generate all existing Aspects as TC_Aspects + // Generate all existing Aspects as TC_Aspects LinkedHashMap h = TC_Aspect.getVanillaAspectList(); for (String g : h.keySet()) { Object aBaseAspect = h.get(g); @@ -49,22 +108,55 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { // Custom Aspects - GTPP_Aspects.CUSTOM_1.mAspect = new Aspect("custom1", 15647411, new Aspect[]{Aspect.COLD, Aspect.FIRE}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GTPP_Aspects.CUSTOM_2.mAspect = new Aspect("custom2", 15658622, new Aspect[]{Aspect.MAGIC, Aspect.SLIME}, + ASPECT_BALANCE = + new TC_Aspect( + "Purity", + 15647411, + new TC_Aspect[]{ + get(TC_Aspects.GELUM), + get(TC_Aspects.IGNIS) + }, + new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), + false, + 1); + ASPECT_LUST = + new TC_Aspect( + "Vengeance", + 15647411, + new TC_Aspect[]{ + get(TC_Aspects.CORPUS), + get(TC_Aspects.ORDO) + }, + new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.NEBRISUM.name() + ".png"), + false, + 1); + + + + + /*GTPP_Aspects.CUSTOM_2.mAspect = new Aspect("custom2", 15658622, new Aspect[]{Aspect.MAGIC, Aspect.SLIME}, new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); GTPP_Aspects.CUSTOM_3.mAspect = new Aspect("custom3", 12644078, new Aspect[]{Aspect.ENERGY, Aspect.ARMOR}, new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); GTPP_Aspects.CUSTOM_4.mAspect = new Aspect("custom4", 12632256, new Aspect[]{Aspect.METAL, Aspect.POISON}, new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); GTPP_Aspects.CUSTOM_5.mAspect = new Aspect("custom4", 12648384, new Aspect[]{Aspect.LIGHT, Aspect.SOUL}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GT_LanguageManager.addStringLocalization("tc.aspect.custom1", "Balance"); - GT_LanguageManager.addStringLocalization("tc.aspect.custom2", "Lust"); + new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1);*/ + GT_LanguageManager.addStringLocalization("tc.aspect.Purity", "Balance"); + GT_LanguageManager.addStringLocalization("tc.aspect.Vengeance", "Lust"); GT_LanguageManager.addStringLocalization("tc.aspect.custom3", "Starbound"); GT_LanguageManager.addStringLocalization("tc.aspect.custom4", "Toxic"); GT_LanguageManager.addStringLocalization("tc.aspect.custom5", "Heaven"); } + + private TC_Aspect get(TC_Aspects aGtObjects) { + try { + return TC_Aspect.generate(aGtObjects.mAspect); + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + return null; + } + } public static synchronized final AspectList getAspectList(final List aAspects) { AspectList o = null; diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java index b05b6f1e2b..5b84733dd1 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java @@ -58,6 +58,10 @@ public class TC_Aspect { } } + public static Object getVanillaAspectObject(String aAspectName) { + return getVanillaAspectList().get(aAspectName); + } + @@ -91,7 +95,7 @@ public class TC_Aspect { * @param components */ public TC_Aspect(String tag, int color, TC_Aspect[] components) { - this(tag, color, components, true, 1); + this(tag, color, components, false, 1); } /** @@ -103,7 +107,7 @@ public class TC_Aspect { * @param blend */ public TC_Aspect(String tag, int color, TC_Aspect[] components, int blend) { - this(tag, color, components, true, blend); + this(tag, color, components, false, blend); } @@ -117,20 +121,20 @@ public class TC_Aspect { * @param blend */ public TC_Aspect(String tag, int color, TC_Aspect[] components, boolean vanilla, int blend) { - this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), blend); + this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend); } - public TC_Aspect(String tag, int color, TC_Aspect[] components, ResourceLocation image, int blend) { - if (getAspectList().containsKey(tag)) { + public TC_Aspect(String tag, int color, TC_Aspect[] components, ResourceLocation image, boolean vanilla, int blend) { + if (getAspectList().containsKey(tag.toLowerCase())) { throw new IllegalArgumentException(tag + " already registered!"); } else { - this.tag = tag; + this.tag = tag.toLowerCase(); this.components = components; this.color = color; this.image = image; this.blend = blend; - this.mAspect = this.generateTcAspect(); + this.mAspect = vanilla ? getVanillaAspectObject(this.tag) : this.generateTcAspect(); } } @@ -139,13 +143,32 @@ public class TC_Aspect { /** * Generates a TC_Aspect from an object, presummed to be a TC Aspect. * @param aBaseAspect - The TC Aspect to generate from. + * @return * @throws IllegalArgumentException * @throws IllegalAccessException */ - public TC_Aspect(Object aBaseAspect) throws IllegalArgumentException, IllegalAccessException { - this((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(aBaseAspect), (int) ReflectionUtils.getField(mClass_Aspect, "color").get(aBaseAspect), generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), aBaseAspect), (ResourceLocation) ReflectionUtils.getField(mClass_Aspect, "image").get(aBaseAspect), (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect)); - Field aChatColour = ReflectionUtils.getField(mClass_Aspect, "chatcolor"); - chatcolor = (String) aChatColour.get(aBaseAspect); + @SuppressWarnings("unused") + public static TC_Aspect generate(Object aBaseAspect) throws IllegalArgumentException, IllegalAccessException { + String aTag = ((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(aBaseAspect)).toLowerCase(); + if (aTag != null && getAspectList().containsKey(aTag.toLowerCase())) { + return getAspect(aTag); + } else { + TC_Aspect aTemp = new TC_Aspect( + aTag, + (int) ReflectionUtils.getField(mClass_Aspect, "color").get(aBaseAspect), + generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), (aBaseAspect)), + (ResourceLocation) ReflectionUtils.getField(mClass_Aspect, "image").get(aBaseAspect), + true, + (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect) + ); + if (aTemp != null) { + aTemp.chatcolor = (String) ReflectionUtils.getField(mClass_Aspect, "chatcolor").get(aBaseAspect); + return aTemp; + } + else { + return null; + } + } } @@ -160,15 +183,16 @@ public class TC_Aspect { * @return - A GT++ Aspect wrapper or null. (TC_Aspect) */ public static TC_Aspect getAspect(String aAspectName) { - TC_Aspect g = mInternalAspectCache.get(aAspectName); + String aName = aAspectName.toLowerCase(); + TC_Aspect g = mInternalAspectCache.get(aName); if (g != null) { return g; } else { try { - TC_Aspect aTemp = new TC_Aspect(getAspectList().get(aAspectName)); + TC_Aspect aTemp = generate(getVanillaAspectList().get(aName)); if (aTemp != null) { - mInternalAspectCache.put(aAspectName, aTemp); + mInternalAspectCache.put(aName, aTemp); return aTemp; } } catch (IllegalArgumentException | IllegalAccessException e) { -- cgit From 8ead0095f30769b0c12d558953323d45a2790d6e Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 4 Mar 2019 18:10:39 +0000 Subject: + Added more Wrappers for TC. - Removed some obsolete classes. $ Rewrote more TC code to be reflective. --- .../xmod/thaumcraft/HANDLER_Thaumcraft.java | 32 +-- .../xmod/thaumcraft/aspect/GTPP_AspectCompat.java | 99 ++----- .../xmod/thaumcraft/aspect/GTPP_AspectStack.java | 13 + .../xmod/thaumcraft/aspect/GTPP_Aspects.java | 77 ------ .../xmod/thaumcraft/aspect/TC_Aspect.java | 267 ------------------ .../thaumcraft/aspect/TC_AspectList_Wrapper.java | 40 +++ .../xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java | 308 +++++++++++++++++++++ .../thaumcraft/aspect/TC_PageType_Wrapper.java | 17 ++ .../aspect/TC_ResearchCategories_Wrapper.java | 89 ++++++ .../aspect/TC_ResearchCategoryList_Wrapper.java | 21 ++ .../thaumcraft/aspect/TC_ResearchItem_Wrapper.java | 244 ++++++++++++++++ .../aspect/TC_ResearchNoteData_Wrapper.java | 10 + .../thaumcraft/aspect/TC_ResearchPage_Wrapper.java | 222 +++++++++++++++ .../objects/ResearchNoteDataWrapper.java | 25 -- .../xmod/thaumcraft/util/ThaumcraftUtils.java | 308 ++++++++++++++------- 15 files changed, 1215 insertions(+), 557 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/ResearchNoteDataWrapper.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java index be3b23531c..b02ba40392 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java @@ -3,31 +3,23 @@ package gtPlusPlus.xmod.thaumcraft; import java.util.Arrays; import java.util.List; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.internal.IThaumcraftCompat; -import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects.TC_AspectStack_Ex; +import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectCompat; +import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectStack; import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; public class HANDLER_Thaumcraft { - public static IThaumcraftCompat sThaumcraftCompat; + public static GTPP_AspectCompat sThaumcraftCompat; public static Item mResearchNotes; - public static final AutoMap> sItemsToGetAspects = new AutoMap>(); - - static { - sThaumcraftCompat = (IThaumcraftCompat) GT_Utility.callConstructor("gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectCompat", 0, null, GT_Values.D1, new Object[0]); - } + public static final AutoMap> sItemsToGetAspects = new AutoMap>(); public static void preInit(){ if (LoadedMods.Thaumcraft){ @@ -47,10 +39,16 @@ public class HANDLER_Thaumcraft { public static void postInit(){ if (LoadedMods.Thaumcraft){ + //Add Custom Aspects + + + //sThaumcraftCompat = (IThaumcraftCompat) GT_Utility.callConstructor("gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectCompat", 0, null, GT_Values.D1, new Object[0]); + sThaumcraftCompat = new GTPP_AspectCompat(); + if (!sItemsToGetAspects.isEmpty()) { - for (Pair j : sItemsToGetAspects) { + for (Pair j : sItemsToGetAspects) { if (j .getKey() != null && (j.getValue() != null && j.getValue().length > 0)) { - List list = Arrays.asList(j.getValue()); + List list = Arrays.asList(j.getValue()); if (ThaumcraftUtils.registerThaumcraftAspectsToItem(j.getKey(), list, true)) { Logger.WARNING("[Aspect] Successfully added Aspects to "+j.getKey().getDisplayName()+"."); } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java index c363cba459..ea4c97fbfc 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java @@ -1,40 +1,29 @@ package gtPlusPlus.xmod.thaumcraft.aspect; -import gregtech.common.GT_ThaumcraftCompat; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects.TC_AspectStack_Ex; -import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; - -import gregtech.api.enums.TC_Aspects; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; -import gregtech.api.interfaces.internal.IThaumcraftCompat; -import gregtech.api.util.GT_LanguageManager; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; +import gregtech.api.enums.TC_Aspects; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.GT_ThaumcraftCompat; +import gtPlusPlus.api.objects.Logger; import net.minecraft.util.ResourceLocation; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; -public class GTPP_AspectCompat implements IThaumcraftCompat { +public class GTPP_AspectCompat { public static volatile Method m = null; - private static HashMap mAspectCache = new LinkedHashMap(); + private static HashMap mAspectCache = new LinkedHashMap(); - public static TC_Aspect ASPECT_BALANCE; - public static TC_Aspect ASPECT_LUST; - public static TC_Aspect ASPECT_STARBOUND; - public static TC_Aspect ASPECT_TOXIC; - public static TC_Aspect ASPECT_HEAVEN; + public static TC_Aspect_Wrapper ASPECT_BALANCE; + public static TC_Aspect_Wrapper ASPECT_LUST; + public static TC_Aspect_Wrapper ASPECT_STARBOUND; + public static TC_Aspect_Wrapper ASPECT_TOXIC; + public static TC_Aspect_Wrapper ASPECT_HEAVEN; /* TC_Aspects.AER.mAspect = Aspect.AIR; @@ -92,11 +81,11 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { // Generate all existing Aspects as TC_Aspects - LinkedHashMap h = TC_Aspect.getVanillaAspectList(); + LinkedHashMap h = TC_Aspect_Wrapper.getVanillaAspectList(); for (String g : h.keySet()) { Object aBaseAspect = h.get(g); - if (aBaseAspect != null && TC_Aspect.isObjectAnAspect(aBaseAspect)) { - TC_Aspect aS = TC_Aspect.getAspect(g); + if (aBaseAspect != null && TC_Aspect_Wrapper.isObjectAnAspect(aBaseAspect)) { + TC_Aspect_Wrapper aS = TC_Aspect_Wrapper.getAspect(g); if (aS != null) { mAspectCache.put(g, aS); continue; @@ -109,10 +98,10 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { // Custom Aspects ASPECT_BALANCE = - new TC_Aspect( + new TC_Aspect_Wrapper( "Purity", 15647411, - new TC_Aspect[]{ + new TC_Aspect_Wrapper[]{ get(TC_Aspects.GELUM), get(TC_Aspects.IGNIS) }, @@ -120,10 +109,10 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { false, 1); ASPECT_LUST = - new TC_Aspect( + new TC_Aspect_Wrapper( "Vengeance", 15647411, - new TC_Aspect[]{ + new TC_Aspect_Wrapper[]{ get(TC_Aspects.CORPUS), get(TC_Aspects.ORDO) }, @@ -149,24 +138,24 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { GT_LanguageManager.addStringLocalization("tc.aspect.custom5", "Heaven"); } - private TC_Aspect get(TC_Aspects aGtObjects) { + private TC_Aspect_Wrapper get(TC_Aspects aGtObjects) { try { - return TC_Aspect.generate(aGtObjects.mAspect); - } catch (IllegalArgumentException | IllegalAccessException e) { + return TC_Aspect_Wrapper.generate(aGtObjects.mAspect); + } catch (IllegalArgumentException e) { e.printStackTrace(); return null; } } - public static synchronized final AspectList getAspectList(final List aAspects) { - AspectList o = null; + public static synchronized final TC_AspectList_Wrapper getTC_AspectList_Wrapper(final List aAspects) { + TC_AspectList_Wrapper o = null; try { if (m == null || (m != null && !m.isAccessible())) { - m = GT_ThaumcraftCompat.class.getDeclaredMethod("getAspectList", List.class); + m = GT_ThaumcraftCompat.class.getDeclaredMethod("getTC_AspectList_Wrapper", List.class); m.setAccessible(true); } if (m != null) { - o = (AspectList) m.invoke(null, aAspects); + o = (TC_AspectList_Wrapper) m.invoke(null, aAspects); } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { @@ -177,44 +166,6 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { } return o; } - - public static synchronized final AspectList getAspectList_Ex(final List aAspects) { - final AspectList rAspects = new AspectList(); - for (final TC_AspectStack_Ex tAspect : aAspects) { - rAspects.add((Aspect) tAspect.mAspect.mAspect, (int) tAspect.mAmount); - } - return rAspects; - } - - @Override - public boolean registerPortholeBlacklistedBlock(Block p0) { - return ThaumcraftUtils.registerPortholeBlacklistedBlock(p0); - } - - @Override - public boolean registerThaumcraftAspectsToItem(ItemStack p0, List p1, boolean p2) { - return ThaumcraftUtils.registerThaumcraftAspectsToItem(p0, ThaumcraftUtils.convertAspectStack(p1), p2); - } - - @Override - public boolean registerThaumcraftAspectsToItem(ItemStack p0, List p1, String p2) { - return ThaumcraftUtils.registerThaumcraftAspectsToItem(p0, ThaumcraftUtils.convertAspectStack(p1), p2); - } - - @Override - public Object addCrucibleRecipe(String p0, Object p1, ItemStack p2, List p3) { - return ThaumcraftUtils.addCrucibleRecipe(p0, p1, p2, ThaumcraftUtils.convertAspectStack(p3)); - } - @Override - public Object addInfusionRecipe(String p0, ItemStack p1, ItemStack[] p2, ItemStack p3, int p4, List p5) { - return ThaumcraftUtils.addInfusionRecipe(p0, p1, p2, p3, p4, ThaumcraftUtils.convertAspectStack(p5)); - } - - @Override - public Object addResearch(String p0, String p1, String p2, String[] p3, String p4, ItemStack p5, int p6, int p7, - int p8, int p9, List p10, ItemStack[] p11, Object[] p12) { - return ThaumcraftUtils.addResearch(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, ThaumcraftUtils.convertAspectStack(p10), p11, p12); - } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java new file mode 100644 index 0000000000..d7cfa7d326 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java @@ -0,0 +1,13 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +public class GTPP_AspectStack { + + public final TC_Aspect_Wrapper mAspect; + public final int mAmount; + + public GTPP_AspectStack(TC_Aspect_Wrapper aAspect, int aAmount) { + mAspect = aAspect; + mAmount= aAmount; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java deleted file mode 100644 index e1df0dabf5..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java +++ /dev/null @@ -1,77 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import java.util.List; - -import thaumcraft.api.aspects.Aspect; - -public enum GTPP_Aspects { - - //Standard TC and GT Aspects - AER(1), ALIENIS(20), AQUA(3), ARBOR(1), AURAM(16), BESTIA(6), - COGNITIO(2), CORPUS(2), ELECTRUM(24), EXANIMIS(32), FABRICO(2), - FAMES(2), GELUM(1), GRANUM(4), HERBA(2), HUMANUS(8), IGNIS(4), - INSTRUMENTUM(4), ITER(6), LIMUS(3), LUCRUM(32), LUX(4), MACHINA(16), - MAGNETO(24), MESSIS(3), METALLUM(8), METO(2), MORTUUS(16), MOTUS(4), - NEBRISUM(48), ORDO(8), PANNUS(6), PERDITIO(2), PERFODIO(4), - PERMUTATIO(12), POTENTIA(16), PRAECANTATIO(16), RADIO(48), - SANO(24), SENSUS(4), SPIRITUS(24), STRONTIO(64), TELUM(6), - TERRA(1), TEMPESTAS(64), TENEBRAE(24), TUTAMEN(12), VACUOS(6), - VENENUM(16), VICTUS(4), VINCULUM(16), VITIUM(48), VITREUS(3), VOLATUS(12), - - //Custom Aspects - CUSTOM_3(24), CUSTOM_4(24), CUSTOM_2(48), CUSTOM_5(48), CUSTOM_1(64); - - public Aspect mAspect; - public int mValue; - - private GTPP_Aspects(final int aValue) { - this.mValue = aValue; - } - - public static class TC_AspectStack_Ex { - public GTPP_Aspects mAspect; - public long mAmount; - - public TC_AspectStack_Ex(final GTPP_Aspects aAspect, final long aAmount) { - this.mAspect = aAspect; - this.mAmount = aAmount; - } - - public TC_AspectStack_Ex copy() { - return new TC_AspectStack_Ex(this.mAspect, this.mAmount); - } - - public TC_AspectStack_Ex copy(final long aAmount) { - return new TC_AspectStack_Ex(this.mAspect, aAmount); - } - - public List addToAspectList(final List aList) { - if (this.mAmount == 0L) { - return aList; - } - for (final TC_AspectStack_Ex tAspect : aList) { - if (tAspect.mAspect == this.mAspect) { - final TC_AspectStack_Ex tc_AspectStack = tAspect; - tc_AspectStack.mAmount += this.mAmount; - return aList; - } - } - aList.add(this.copy()); - return aList; - } - - public boolean removeFromAspectList(final List aList) { - for (final TC_AspectStack_Ex tAspect : aList) { - if (tAspect.mAspect == this.mAspect && tAspect.mAmount >= this.mAmount) { - final TC_AspectStack_Ex tc_AspectStack = tAspect; - tc_AspectStack.mAmount -= this.mAmount; - if (tAspect.mAmount == 0L) { - aList.remove(tAspect); - } - return true; - } - } - return false; - } - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java deleted file mode 100644 index 5b84733dd1..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java +++ /dev/null @@ -1,267 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.LinkedHashMap; -import java.util.Map; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import net.minecraft.util.ResourceLocation; - -/** - * Wrapper class for Thaumcraft Aspects. - * Used to avoid compile time dependencies. - * @author Alkalus - * - */ -public class TC_Aspect { - - private static Class mClass_Aspect; - private static Field mField_Aspects; - - private final String tag; - private final TC_Aspect[] components; - private final int color; - private String chatcolor; - private final ResourceLocation image; - private final int blend; - - private final Object mAspect; - - - - - /** - * Statically set the Class objects - */ - static { - mClass_Aspect = ReflectionUtils.getClass("thaumcraft.api.aspects.Aspect"); - } - - /** - * Gets the total aspect list from Thaumcraft, which should contain all other registered aspects. - * @return - A LinkedHashMap(String, Aspect); - */ - public static LinkedHashMap getVanillaAspectList() { - try { - if (mField_Aspects == null) { - mField_Aspects = ReflectionUtils.getField(mClass_Aspect, "aspects"); - } - return (LinkedHashMap) mField_Aspects.get(null); - } catch (IllegalArgumentException | IllegalAccessException e) { - Logger.REFLECTION("Failed configuring TC Aspect compatibility."); - return new LinkedHashMap(); - } - } - - public static Object getVanillaAspectObject(String aAspectName) { - return getVanillaAspectList().get(aAspectName); - } - - - - - - - - - - - - - - - /** - * Vanilla Aspect Constructor - * @param tag - Aspect Name - * @param color - * @param chatcolor - * @param blend - */ - public TC_Aspect(String tag, int color, String chatcolor, int blend) { - this(tag, color, (TC_Aspect[]) null, blend); - this.chatcolor = chatcolor; - } - - /** - * - * Vanilla Aspect Constructor - * @param tag - Aspect Name - * @param color - * @param components - */ - public TC_Aspect(String tag, int color, TC_Aspect[] components) { - this(tag, color, components, false, 1); - } - - /** - * - * Vanilla Aspect Constructor - * @param tag - Aspect Name - * @param color - * @param components - * @param blend - */ - public TC_Aspect(String tag, int color, TC_Aspect[] components, int blend) { - this(tag, color, components, false, blend); - } - - - /** - * - * Vanilla Aspect Constructor - * @param tag - Aspect Name - * @param color - * @param components - * @param image - * @param blend - */ - public TC_Aspect(String tag, int color, TC_Aspect[] components, boolean vanilla, int blend) { - this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend); - } - - - public TC_Aspect(String tag, int color, TC_Aspect[] components, ResourceLocation image, boolean vanilla, int blend) { - if (getAspectList().containsKey(tag.toLowerCase())) { - throw new IllegalArgumentException(tag + " already registered!"); - } else { - this.tag = tag.toLowerCase(); - this.components = components; - this.color = color; - this.image = image; - this.blend = blend; - this.mAspect = vanilla ? getVanillaAspectObject(this.tag) : this.generateTcAspect(); - } - } - - - - /** - * Generates a TC_Aspect from an object, presummed to be a TC Aspect. - * @param aBaseAspect - The TC Aspect to generate from. - * @return - * @throws IllegalArgumentException - * @throws IllegalAccessException - */ - @SuppressWarnings("unused") - public static TC_Aspect generate(Object aBaseAspect) throws IllegalArgumentException, IllegalAccessException { - String aTag = ((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(aBaseAspect)).toLowerCase(); - if (aTag != null && getAspectList().containsKey(aTag.toLowerCase())) { - return getAspect(aTag); - } else { - TC_Aspect aTemp = new TC_Aspect( - aTag, - (int) ReflectionUtils.getField(mClass_Aspect, "color").get(aBaseAspect), - generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), (aBaseAspect)), - (ResourceLocation) ReflectionUtils.getField(mClass_Aspect, "image").get(aBaseAspect), - true, - (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect) - ); - if (aTemp != null) { - aTemp.chatcolor = (String) ReflectionUtils.getField(mClass_Aspect, "chatcolor").get(aBaseAspect); - return aTemp; - } - else { - return null; - } - } - } - - - /** - * Internal Map containing all the TC_Aspects. - */ - private static Map mInternalAspectCache = new LinkedHashMap(); - - /** - * Public getter for all TC_Aspects - * @param aAspectName - Aspect Name - * @return - A GT++ Aspect wrapper or null. (TC_Aspect) - */ - public static TC_Aspect getAspect(String aAspectName) { - String aName = aAspectName.toLowerCase(); - TC_Aspect g = mInternalAspectCache.get(aName); - if (g != null) { - return g; - } - else { - try { - TC_Aspect aTemp = generate(getVanillaAspectList().get(aName)); - if (aTemp != null) { - mInternalAspectCache.put(aName, aTemp); - return aTemp; - } - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - } - } - return null; - } - - public static Map getAspectList(){ - return mInternalAspectCache; - } - - - private static TC_Aspect[] generateAspectArrayInternal(Field aField, Object aInstance) { - //thaumcraft.api.aspects.Aspect.Aspect() - Object[] components; - TC_Aspect[] aAspectArray; - try { - components = (Object[]) aField.get(aInstance); - aAspectArray = new TC_Aspect[components.length]; - if (components.length > 0) { - int i = 0; - for (Object g : components) { - aAspectArray[i] = getAspect((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(g)); - i++; - } - } - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - aAspectArray = new TC_Aspect[0]; - } - return aAspectArray; - } - - /** - * Tasty code to generate TC Aspects reflectively. - * @return - */ - public Object generateTcAspect() { - try { - //thaumcraft.api.aspects.Aspect.Aspect() - Object aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, 1); - if (components.length > 0) { - aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, components.length); - int i = 0; - for (TC_Aspect g : components) { - ((Object[]) aAspectArray)[i++] = g.mAspect; - } - } - Constructor constructor = mClass_Aspect.getConstructor(String.class, int.class, aAspectArray.getClass(), ResourceLocation.class, int.class); - Object myObject = constructor.newInstance(tag, color, aAspectArray, image, blend); - - //Set chat colour - if (chatcolor != null && chatcolor.length() > 0) { - Method setChatColour = ReflectionUtils.getMethod(mClass_Aspect, "setChatcolor", String.class); - if (setChatColour != null) { - setChatColour.invoke(myObject, chatcolor); - } - } - return myObject; - } catch (Throwable t) { - t.printStackTrace(); - return null; - } - } - - public static boolean isObjectAnAspect(Object aAspect) { - return mClass_Aspect.isInstance(aAspect); - } - -} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java new file mode 100644 index 0000000000..0a7f2d6a3c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java @@ -0,0 +1,40 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import net.minecraft.item.ItemStack; + +public class TC_AspectList_Wrapper { + + + //thaumcraft.api.aspects.Aspect; + //thaumcraft.api.aspects.AspectList; + + public TC_AspectList_Wrapper() { + + } + + public TC_AspectList_Wrapper(ItemStack stack) { + + } + + public TC_AspectList_Wrapper(Object invoke) { + // TODO Auto-generated constructor stub + } + + public int size() { + // TODO Auto-generated method stub + return 0; + } + + public Object getVanillaAspectList() { + // TODO Auto-generated method stub + return null; + } + + public void add(TC_Aspect_Wrapper mAspect, int mAmount) { + // TODO Auto-generated method stub + + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java new file mode 100644 index 0000000000..78c2a670bb --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java @@ -0,0 +1,308 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.LinkedHashMap; +import java.util.Map; + +import gregtech.api.enums.TC_Aspects; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.util.ResourceLocation; + +/** + * Wrapper class for Thaumcraft Aspects. + * Used to avoid compile time dependencies. + * @author Alkalus + * + */ +public class TC_Aspect_Wrapper { + + private static Class mClass_Aspect; + private static Field mField_Aspects; + + private final String tag; + private final TC_Aspect_Wrapper[] components; + private final int color; + private String chatcolor; + private final ResourceLocation image; + private final int blend; + + public final Object mAspect; + + /** + * May be null, but links back to the TC_Aspects class from GT for convinience. + */ + public final TC_Aspects mGtEnumField; + + + + + /** + * Statically set the Class objects + */ + static { + mClass_Aspect = ReflectionUtils.getClass("thaumcraft.api.aspects.Aspect"); + } + + /** + * Gets the total aspect list from Thaumcraft, which should contain all other registered aspects. + * @return - A LinkedHashMap(String, Aspect); + */ + public static LinkedHashMap getVanillaAspectList() { + try { + if (mField_Aspects == null) { + mField_Aspects = ReflectionUtils.getField(mClass_Aspect, "aspects"); + } + return (LinkedHashMap) mField_Aspects.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + Logger.REFLECTION("Failed configuring TC Aspect compatibility."); + return new LinkedHashMap(); + } + } + + public static Object getVanillaAspectObject(String aAspectName) { + return getVanillaAspectList().get(aAspectName); + } + + + + + + + + + + + + + + + /** + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param chatcolor + * @param blend + */ + public TC_Aspect_Wrapper(String tag, int color, String chatcolor, int blend) { + this(tag, color, (TC_Aspect_Wrapper[]) null, blend); + this.chatcolor = chatcolor; + } + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + */ + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components) { + this(tag, color, components, false, 1); + } + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + * @param blend + */ + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, int blend) { + this(tag, color, components, false, blend); + } + + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + * @param image + * @param blend + */ + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, boolean vanilla, int blend) { + this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend); + } + + + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, ResourceLocation image, boolean vanilla, int blend) { + if (getAspectList().containsKey(tag.toLowerCase())) { + throw new IllegalArgumentException(tag + " already registered!"); + } else { + this.tag = tag.toLowerCase(); + this.components = components; + this.color = color; + this.image = image; + this.blend = blend; + this.mAspect = vanilla ? getVanillaAspectObject(this.tag) : this.generateTcAspect(); + + //Set GT Type if exists + TC_Aspects y = null; + for (TC_Aspects e : TC_Aspects.values()) { + TC_Aspect_Wrapper g; + try { + g = generate(e.mAspect); + if (g != null) { + if (g.tag.equals(this.tag)) { + y = e; + break; + } + } + } catch (IllegalArgumentException e1) { + e1.printStackTrace(); + } + } + mGtEnumField = y; + + + Logger.INFO("[Thaumcraft++] Adding support for Aspect: "+tag); + } + } + + + + /** + * Generates a TC_Aspect from an object, presummed to be a TC Aspect. + * @param aBaseAspect - The TC Aspect to generate from. + * @return + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + @SuppressWarnings("unused") + public static TC_Aspect_Wrapper generate(Object aBaseAspect) { + try { + Field aTagF = ReflectionUtils.getField(mClass_Aspect, "tag"); + if (aTagF == null) { + return null; + } + String aTafB = (String) aTagF.get(aBaseAspect); + if (aTafB == null) { + return null; + } + String aTag = aTafB.toLowerCase(); + if (aTag != null && getAspectList().containsKey(aTag.toLowerCase())) { + return getAspect(aTag); + } else { + TC_Aspect_Wrapper aTemp = new TC_Aspect_Wrapper( + aTag, + (int) ReflectionUtils.getField(mClass_Aspect, "color").get(aBaseAspect), + generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), (aBaseAspect)), + (ResourceLocation) ReflectionUtils.getField(mClass_Aspect, "image").get(aBaseAspect), + true, + (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect) + ); + if (aTemp != null) { + aTemp.chatcolor = (String) ReflectionUtils.getField(mClass_Aspect, "chatcolor").get(aBaseAspect); + return aTemp; + } + else { + return null; + } + } + } + catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + + /** + * Internal Map containing all the TC_Aspects. + */ + private static Map mInternalAspectCache = new LinkedHashMap(); + + /** + * Public getter for all TC_Aspects + * @param aAspectName - Aspect Name + * @return - A GT++ Aspect wrapper or null. (TC_Aspect) + */ + public static TC_Aspect_Wrapper getAspect(String aAspectName) { + String aName = aAspectName.toLowerCase(); + TC_Aspect_Wrapper g = mInternalAspectCache.get(aName); + if (g != null) { + return g; + } + else { + try { + TC_Aspect_Wrapper aTemp = generate(getVanillaAspectList().get(aName)); + if (aTemp != null) { + mInternalAspectCache.put(aName, aTemp); + return aTemp; + } + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + } + return null; + } + + public static Map getAspectList(){ + return mInternalAspectCache; + } + + + private static TC_Aspect_Wrapper[] generateAspectArrayInternal(Field aField, Object aInstance) { + //thaumcraft.api.aspects.Aspect.Aspect() + Object[] components; + TC_Aspect_Wrapper[] aAspectArray; + try { + components = (Object[]) aField.get(aInstance); + aAspectArray = new TC_Aspect_Wrapper[components.length]; + if (components.length > 0) { + int i = 0; + for (Object g : components) { + aAspectArray[i] = getAspect((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(g)); + i++; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + aAspectArray = new TC_Aspect_Wrapper[0]; + } + return aAspectArray; + } + + /** + * Tasty code to generate TC Aspects reflectively. + * @return + */ + public Object generateTcAspect() { + try { + //thaumcraft.api.aspects.Aspect.Aspect() + Object aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, 1); + if (components.length > 0) { + aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, components.length); + int i = 0; + for (TC_Aspect_Wrapper g : components) { + ((Object[]) aAspectArray)[i++] = g.mAspect; + } + } + Constructor constructor = mClass_Aspect.getConstructor(String.class, int.class, aAspectArray.getClass(), ResourceLocation.class, int.class); + Object myObject = constructor.newInstance(tag, color, aAspectArray, image, blend); + + //Set chat colour + if (chatcolor != null && chatcolor.length() > 0) { + Method setChatColour = ReflectionUtils.getMethod(mClass_Aspect, "setChatcolor", String.class); + if (setChatColour != null) { + setChatColour.invoke(myObject, chatcolor); + } + } + return myObject; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + public static boolean isObjectAnAspect(Object aAspect) { + return mClass_Aspect.isInstance(aAspect); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java new file mode 100644 index 0000000000..5a608e290f --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java @@ -0,0 +1,17 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +public class TC_PageType_Wrapper { + + public static final TC_PageType_Wrapper TEXT = null; + public static final TC_PageType_Wrapper TEXT_CONCEALED = null; + public static final TC_PageType_Wrapper NORMAL_CRAFTING = null; + public static final TC_PageType_Wrapper ARCANE_CRAFTING = null; + public static final TC_PageType_Wrapper CRUCIBLE_CRAFTING = null; + public static final TC_PageType_Wrapper INFUSION_CRAFTING = null; + public static final TC_PageType_Wrapper COMPOUND_CRAFTING = null; + public static final TC_PageType_Wrapper SMELTING = null; + public static final TC_PageType_Wrapper INFUSION_ENCHANTMENT = null; + public static final TC_PageType_Wrapper IMAGE = null; + public static final TC_PageType_Wrapper ASPECTS = null; + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java new file mode 100644 index 0000000000..3392dbcff9 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java @@ -0,0 +1,89 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import cpw.mods.fml.common.FMLLog; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashMap; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.apache.logging.log4j.Level; + +public class TC_ResearchCategories_Wrapper { + + public static LinkedHashMap researchCategories = new LinkedHashMap(); + + public static TC_ResearchCategoryList_Wrapper getResearchList(String key) { + return (TC_ResearchCategoryList_Wrapper) researchCategories.get(key); + } + + public static String getCategoryName(String key) { + return StatCollector.translateToLocal("tc.research_category." + key); + } + + public static TC_ResearchItem_Wrapper getResearch(String key) { + Collection rc = researchCategories.values(); + Iterator i$ = rc.iterator(); + + while (i$.hasNext()) { + Object cat = i$.next(); + Collection rl = ((TC_ResearchCategoryList_Wrapper) cat).research.values(); + Iterator i$1 = rl.iterator(); + + while (i$1.hasNext()) { + Object ri = i$1.next(); + if (((TC_ResearchItem_Wrapper) ri).key.equals(key)) { + return (TC_ResearchItem_Wrapper) ri; + } + } + } + + return null; + } + + public static void registerCategory(String key, ResourceLocation icon, ResourceLocation background) { + if (getResearchList(key) == null) { + TC_ResearchCategoryList_Wrapper rl = new TC_ResearchCategoryList_Wrapper(icon, background); + researchCategories.put(key, rl); + } + + } + + public static void addResearch(TC_ResearchItem_Wrapper ri) { + TC_ResearchCategoryList_Wrapper rl = getResearchList(ri.category); + if (rl != null && !rl.research.containsKey(ri.key)) { + if (!ri.isVirtual()) { + Iterator i$ = rl.research.values().iterator(); + + while (i$.hasNext()) { + TC_ResearchItem_Wrapper rr = (TC_ResearchItem_Wrapper) i$.next(); + if (rr.displayColumn == ri.displayColumn && rr.displayRow == ri.displayRow) { + FMLLog.log(Level.FATAL, + "[Thaumcraft] Research [" + ri.getName() + + "] not added as it overlaps with existing research [" + rr.getName() + "]", + new Object[0]); + return; + } + } + } + + rl.research.put(ri.key, ri); + if (ri.displayColumn < rl.minDisplayColumn) { + rl.minDisplayColumn = ri.displayColumn; + } + + if (ri.displayRow < rl.minDisplayRow) { + rl.minDisplayRow = ri.displayRow; + } + + if (ri.displayColumn > rl.maxDisplayColumn) { + rl.maxDisplayColumn = ri.displayColumn; + } + + if (ri.displayRow > rl.maxDisplayRow) { + rl.maxDisplayRow = ri.displayRow; + } + } + + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java new file mode 100644 index 0000000000..4c9102648a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; + +public class TC_ResearchCategoryList_Wrapper { + public int minDisplayColumn; + public int minDisplayRow; + public int maxDisplayColumn; + public int maxDisplayRow; + public ResourceLocation icon; + public ResourceLocation background; + public Map research = new HashMap(); + + public TC_ResearchCategoryList_Wrapper(ResourceLocation icon, ResourceLocation background) { + this.icon = icon; + this.background = background; + } +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java new file mode 100644 index 0000000000..399ec5ad09 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java @@ -0,0 +1,244 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class TC_ResearchItem_Wrapper { + + public final String key; + public final String category; + public final TC_AspectList_Wrapper tags; + public String[] parents = null; + public String[] parentsHidden = null; + public String[] siblings = null; + public final int displayColumn; + public final int displayRow; + public final ItemStack icon_item; + public final ResourceLocation icon_resource; + private int complexity; + private boolean isSpecial; + private boolean isSecondary; + private boolean isRound; + private boolean isStub; + private boolean isVirtual; + private boolean isConcealed; + private boolean isHidden; + private boolean isLost; + private boolean isAutoUnlock; + private ItemStack[] itemTriggers; + private String[] entityTriggers; + private TC_Aspect_Wrapper[] aspectTriggers; + private Object[] pages = null; + + public TC_ResearchItem_Wrapper(String key, String category) { + this.key = key; + this.category = category; + this.tags = new TC_AspectList_Wrapper(); + this.icon_resource = null; + this.icon_item = null; + this.displayColumn = 0; + this.displayRow = 0; + this.setVirtual(); + } + + public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, + ResourceLocation icon) { + this.key = key; + this.category = category; + this.tags = tags; + this.icon_resource = icon; + this.icon_item = null; + this.displayColumn = col; + this.displayRow = row; + this.complexity = complex; + if (this.complexity < 1) { + this.complexity = 1; + } + + if (this.complexity > 3) { + this.complexity = 3; + } + + } + + public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, ItemStack icon) { + this.key = key; + this.category = category; + this.tags = tags; + this.icon_item = icon; + this.icon_resource = null; + this.displayColumn = col; + this.displayRow = row; + this.complexity = complex; + if (this.complexity < 1) { + this.complexity = 1; + } + + if (this.complexity > 3) { + this.complexity = 3; + } + + } + + public TC_ResearchItem_Wrapper setSpecial() { + this.isSpecial = true; + return this; + } + + public TC_ResearchItem_Wrapper setStub() { + this.isStub = true; + return this; + } + + public TC_ResearchItem_Wrapper setLost() { + this.isLost = true; + return this; + } + + public TC_ResearchItem_Wrapper setConcealed() { + this.isConcealed = true; + return this; + } + + public TC_ResearchItem_Wrapper setHidden() { + this.isHidden = true; + return this; + } + + public TC_ResearchItem_Wrapper setVirtual() { + this.isVirtual = true; + return this; + } + + public TC_ResearchItem_Wrapper setParents(String... par) { + this.parents = par; + return this; + } + + public TC_ResearchItem_Wrapper setParentsHidden(String... par) { + this.parentsHidden = par; + return this; + } + + public TC_ResearchItem_Wrapper setSiblings(String... sib) { + this.siblings = sib; + return this; + } + + public TC_ResearchItem_Wrapper setPages(Object... par) { + this.pages = par; + return this; + } + + public Object[] getPages() { + return this.pages; + } + + public TC_ResearchItem_Wrapper setItemTriggers(ItemStack... par) { + this.itemTriggers = par; + return this; + } + + public TC_ResearchItem_Wrapper setEntityTriggers(String... par) { + this.entityTriggers = par; + return this; + } + + public TC_ResearchItem_Wrapper setAspectTriggers(TC_Aspect_Wrapper... par) { + this.aspectTriggers = par; + return this; + } + + public ItemStack[] getItemTriggers() { + return this.itemTriggers; + } + + public String[] getEntityTriggers() { + return this.entityTriggers; + } + + public TC_Aspect_Wrapper[] getAspectTriggers() { + return this.aspectTriggers; + } + + public TC_ResearchItem_Wrapper registerResearchItem() { + ThaumcraftUtils.addResearch(this); + return this; + } + + public String getName() { + return StatCollector.translateToLocal("tc.research_name." + this.key); + } + + public String getText() { + return StatCollector.translateToLocal("tc.research_text." + this.key); + } + + public boolean isSpecial() { + return this.isSpecial; + } + + public boolean isStub() { + return this.isStub; + } + + public boolean isLost() { + return this.isLost; + } + + public boolean isConcealed() { + return this.isConcealed; + } + + public boolean isHidden() { + return this.isHidden; + } + + public boolean isVirtual() { + return this.isVirtual; + } + + public boolean isAutoUnlock() { + return this.isAutoUnlock; + } + + public TC_ResearchItem_Wrapper setAutoUnlock() { + this.isAutoUnlock = true; + return this; + } + + public boolean isRound() { + return this.isRound; + } + + public TC_ResearchItem_Wrapper setRound() { + this.isRound = true; + return this; + } + + public boolean isSecondary() { + return this.isSecondary; + } + + public TC_ResearchItem_Wrapper setSecondary() { + this.isSecondary = true; + return this; + } + + public int getComplexity() { + return this.complexity; + } + + public TC_ResearchItem_Wrapper setComplexity(int complexity) { + this.complexity = complexity; + return this; + } + + public TC_Aspect_Wrapper getResearchPrimaryTag() { + //TODO + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java new file mode 100644 index 0000000000..64f1ce088a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java @@ -0,0 +1,10 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +public class TC_ResearchNoteData_Wrapper { + + public Object getResearchNoteData() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java new file mode 100644 index 0000000000..256e9c19ed --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java @@ -0,0 +1,222 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import java.util.List; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class TC_ResearchPage_Wrapper { + public TC_PageType_Wrapper type; + public String text; + public String research; + public ResourceLocation image; + public TC_AspectList_Wrapper aspects; + public Object recipe; + public ItemStack recipeOutput; + + public TC_ResearchPage_Wrapper(String text) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.TEXT; + this.text = text; + } + + public TC_ResearchPage_Wrapper(String research, String text) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.TEXT_CONCEALED; + this.research = research; + this.text = text; + } + + public TC_ResearchPage_Wrapper(IRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(IRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(IArcaneRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(CrucibleRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(InfusionRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(List recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.COMPOUND_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(IArcaneRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(CrucibleRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(ItemStack input) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.SMELTING; + this.recipe = input; + this.recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); + } + + public TC_ResearchPage_Wrapper(InfusionRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; + this.recipe = recipe; + if (recipe.getRecipeOutput() instanceof ItemStack) { + this.recipeOutput = (ItemStack) recipe.getRecipeOutput(); + } else { + this.recipeOutput = recipe.getRecipeInput(); + } + + } + + public TC_ResearchPage_Wrapper(InfusionEnchantmentRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_ENCHANTMENT; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(ResourceLocation image, String caption) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.IMAGE; + this.image = image; + this.text = caption; + } + + public TC_ResearchPage_Wrapper(TC_AspectList_Wrapper as) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ASPECTS; + this.aspects = as; + } + + public String getTranslatedText() { + String ret = ""; + if (this.text != null) { + ret = StatCollector.translateToLocal(this.text); + if (ret.isEmpty()) { + ret = this.text; + } + } + + return ret; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ResearchNoteDataWrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ResearchNoteDataWrapper.java deleted file mode 100644 index 7ca5c117f0..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ResearchNoteDataWrapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.objects; - -import thaumcraft.common.lib.research.ResearchNoteData; - -public class ResearchNoteDataWrapper extends ResearchNoteData { - - public ResearchNoteDataWrapper() { - super(); - } - - public ResearchNoteDataWrapper(ResearchNoteData data) { - key = data.key; - color = data.color; - hexEntries = data.hexEntries; - hexes = data.hexes; - complete = data.complete; - copies = data.copies; - } - - public void completeResearch() { - this.complete = true; - } - - -} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java index 2f5400e5f2..6e275e9b67 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java @@ -1,8 +1,10 @@ package gtPlusPlus.xmod.thaumcraft.util; import static gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft.sItemsToGetAspects; -import static gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectCompat.getAspectList_Ex; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.*; import net.minecraft.block.Block; @@ -11,53 +13,50 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; - import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.enums.TC_Aspects; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects.TC_AspectStack_Ex; -import gtPlusPlus.xmod.thaumcraft.objects.ResearchNoteDataWrapper; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.ThaumcraftApiHelper; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; -import thaumcraft.api.crafting.*; -import thaumcraft.api.research.*; -import thaumcraft.common.lib.research.ResearchManager; -import thaumcraft.common.lib.research.ResearchNoteData; -import thaumcraft.common.lib.utils.HexUtils; +import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectStack; +import gtPlusPlus.xmod.thaumcraft.aspect.TC_Aspect_Wrapper; +import gtPlusPlus.xmod.thaumcraft.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchCategories_Wrapper; +import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchCategoryList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchItem_Wrapper; +import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchNoteData_Wrapper; +import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchPage_Wrapper; public class ThaumcraftUtils { - public static boolean addAspectToItem(ItemStack item, Aspect aspect, int amount) { - return addAspectToItem(item, getEnumAspect(aspect.getName()), amount); - } + + private static Class mClass_Aspect; + private static Field mField_Aspects; /*public static boolean addAspectToItem(ItemStack item, Aspect[] aspects, int amount) { return addAspectToItem(item, getEnumAspect(aspect.getName()), amount); }*/ - public static boolean addAspectToItem(ItemStack item, GTPP_Aspects aspect, int amount) { - return addAspectToItem(item, new GTPP_Aspects[] {aspect}, new Integer[] {amount}); + public static boolean addAspectToItem(ItemStack item, TC_Aspect_Wrapper aspect, int amount) { + return addAspectToItem(item, new TC_Aspect_Wrapper[] {aspect}, new Integer[] {amount}); } - public static boolean addAspectToItem(ItemStack item, GTPP_Aspects[] aspect, Integer[] amounts) { - TC_AspectStack_Ex[] aspects = new TC_AspectStack_Ex[aspect.length]; + public static boolean addAspectToItem(ItemStack item, TC_Aspect_Wrapper[] aspect, Integer[] amounts) { + GTPP_AspectStack[] aspects = new GTPP_AspectStack[aspect.length]; for (int g=0;g 0) { - aspects[g] = new TC_AspectStack_Ex(aspect[g], amounts[g]); + //aspects[g] = new GTPP_AspectStack(aspect[g], amounts[g]); } } - Pair k = new Pair(item, aspects); + Pair k = new Pair(item, aspects); int mSizeA = sItemsToGetAspects.size(); sItemsToGetAspects.put(k); if (sItemsToGetAspects.size() > mSizeA) { @@ -70,59 +69,51 @@ public class ThaumcraftUtils { } - public static Aspect getAspect(String name) { - GTPP_Aspects r = getAspectEnum(name); - return (r == null ? null : r.mAspect); + public static TC_Aspect_Wrapper getAspect(String name) { + return TC_Aspect_Wrapper.getAspect(name); } - public static GTPP_Aspects getEnumAspect(String name) { - GTPP_Aspects r = getAspectEnum(name); - return (r == null ? null : r); - } - - private static GTPP_Aspects getAspectEnum(String name) { - GTPP_Aspects h = null; - for (GTPP_Aspects f : GTPP_Aspects.values()) { - if (f.mAspect.getName().toLowerCase().contains(name.toLowerCase())) { - h = f; - } - } - return h; + public static TC_Aspects getEnumAspect(String name) { + TC_Aspect_Wrapper r = getAspect(name); + return r.mGtEnumField; } + + - public static Object addResearch(String aResearch, String aName, String aText, String[] aParentResearches, String aCategory, ItemStack aIcon, int aComplexity, int aType, int aX, int aY, List aAspects, ItemStack[] aResearchTriggers, Object[] aPages) { + public static Object addResearch(String aResearch, String aName, String aText, String[] aParentResearches, String aCategory, ItemStack aIcon, int aComplexity, int aType, int aX, int aY, List aAspects, ItemStack[] aResearchTriggers, Object[] aPages) { if (!GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.researches, aResearch, true)) { return null; } - ResearchCategoryList tCategory = ResearchCategories.getResearchList(aCategory); + TC_ResearchCategoryList_Wrapper tCategory = TC_ResearchCategories_Wrapper.getResearchList(aCategory); if (tCategory == null) { return null; } - for (Iterator i$ = tCategory.research.values().iterator(); i$.hasNext(); ) { - ResearchItem tResearch = (ResearchItem) i$.next(); + for (Iterator i$ = tCategory.research.values().iterator(); i$.hasNext(); ) { + TC_ResearchItem_Wrapper tResearch = (TC_ResearchItem_Wrapper) i$.next(); if ((tResearch.displayColumn == aX) && (tResearch.displayRow == aY)) { aX += (aX > 0 ? 5 : -5); aY += (aY > 0 ? 5 : -5); } } - ResearchItem rResearch = new ResearchItem(aResearch, aCategory, getAspectList_Ex(aAspects), aX, aY, aComplexity, aIcon); - ArrayList tPages = new ArrayList(aPages.length); + TC_ResearchItem_Wrapper rResearch = new TC_ResearchItem_Wrapper(aResearch, aCategory, getAspectList_Ex(aAspects), aX, aY, aComplexity, aIcon); + ArrayList tPages = new ArrayList(aPages.length); GT_LanguageManager.addStringLocalization("tc.research_name." + aResearch, aName); GT_LanguageManager.addStringLocalization("tc.research_text." + aResearch, "[GT++] " + aText); for (Object tPage : aPages) { if ((tPage instanceof String)) { - tPages.add(new ResearchPage((String) tPage)); + tPages.add(new TC_ResearchPage_Wrapper((String) tPage)); } else if ((tPage instanceof IRecipe)) { - tPages.add(new ResearchPage((IRecipe) tPage)); - } else if ((tPage instanceof IArcaneRecipe)) { - tPages.add(new ResearchPage((IArcaneRecipe) tPage)); + tPages.add(new TC_ResearchPage_Wrapper((IRecipe) tPage)); + } + /*else if ((tPage instanceof IArcaneRecipe)) { + tPages.add(new TC_ResearchPage_Wrapper((IArcaneRecipe) tPage)); } else if ((tPage instanceof CrucibleRecipe)) { - tPages.add(new ResearchPage((CrucibleRecipe) tPage)); + tPages.add(new TC_ResearchPage_Wrapper((CrucibleRecipe) tPage)); } else if ((tPage instanceof InfusionRecipe)) { - tPages.add(new ResearchPage((InfusionRecipe) tPage)); + tPages.add(new TC_ResearchPage_Wrapper((InfusionRecipe) tPage)); } else if ((tPage instanceof InfusionEnchantmentRecipe)) { - tPages.add(new ResearchPage((InfusionEnchantmentRecipe) tPage)); - } + tPages.add(new TC_ResearchPage_Wrapper((InfusionEnchantmentRecipe) tPage)); + }*/ } if ((aType & 0x40) != 0) { rResearch.setAutoUnlock(); @@ -161,58 +152,58 @@ public class ThaumcraftUtils { rResearch.setItemTriggers(aResearchTriggers); rResearch.setHidden(); } - rResearch.setPages((ResearchPage[]) tPages.toArray(new ResearchPage[tPages.size()])); + rResearch.setPages((TC_ResearchPage_Wrapper[]) tPages.toArray(new TC_ResearchPage_Wrapper[tPages.size()])); return rResearch.registerResearchItem(); } public static Object addCrucibleRecipe(final String aResearch, final Object aInput, final ItemStack aOutput, - final List aAspects) { + final List aAspects) { if (GT_Utility.isStringInvalid((Object) aResearch) || aInput == null || aOutput == null || aAspects == null || aAspects.isEmpty()) { return null; } - return ThaumcraftApi.addCrucibleRecipe(aResearch, GT_Utility.copy(new Object[]{aOutput}), + return addCrucibleRecipe(aResearch, GT_Utility.copy(new Object[]{aOutput}), (aInput instanceof ItemStack || aInput instanceof ArrayList) ? aInput : aInput.toString(), getAspectList_Ex(aAspects)); } public static Object addInfusionRecipe(final String aResearch, final ItemStack aMainInput, final ItemStack[] aSideInputs, - final ItemStack aOutput, final int aInstability, final List aAspects) { + final ItemStack aOutput, final int aInstability, final List aAspects) { if (GT_Utility.isStringInvalid((Object) aResearch) || aMainInput == null || aSideInputs == null || aOutput == null || aAspects == null || aAspects.isEmpty()) { return null; } - return ThaumcraftApi.addInfusionCraftingRecipe(aResearch, (Object) GT_Utility.copy(new Object[]{aOutput}), + return addInfusionCraftingRecipe(aResearch, (Object) GT_Utility.copy(new Object[]{aOutput}), aInstability, getAspectList_Ex(aAspects), aMainInput, aSideInputs); } public static boolean registerThaumcraftAspectsToItem(final ItemStack aExampleStack, - final List aAspects, final String aOreDict) { + final List aAspects, final String aOreDict) { if (aAspects.isEmpty()) { return false; } - ThaumcraftApi.registerObjectTag(aOreDict, getAspectList_Ex(aAspects)); + registerObjectTag(aOreDict, getAspectList_Ex(aAspects)); return true; } public static boolean registerThaumcraftAspectsToItem(final ItemStack aStack, - final List aAspects, final boolean aAdditive) { + final List aAspects, final boolean aAdditive) { try { if (aAspects.isEmpty()) { return false; } - AspectList h = getAspectList_Ex(aAspects); + TC_AspectList_Wrapper h = getAspectList_Ex(aAspects); if (aAdditive && (h != null && h.size() > 0)) { - ThaumcraftApi.registerComplexObjectTag(aStack, getAspectList_Ex(aAspects)); + registerComplexObjectTag(aStack, getAspectList_Ex(aAspects)); return true; } else { Logger.MATERIALS("[Aspect] Failed adding aspects to "+aStack.getDisplayName()+"."); } - final AspectList tAlreadyRegisteredAspects = ThaumcraftApiHelper.getObjectAspects(aStack); + final TC_AspectList_Wrapper tAlreadyRegisteredAspects = getObjectAspects(aStack); if (tAlreadyRegisteredAspects == null || tAlreadyRegisteredAspects.size() <= 0) { - ThaumcraftApi.registerObjectTag(aStack, getAspectList_Ex(aAspects)); + registerObjectTag(aStack, getAspectList_Ex(aAspects)); } return true; } @@ -222,44 +213,154 @@ public class ThaumcraftUtils { return false; } } + - public static boolean registerPortholeBlacklistedBlock(final Block aBlock) { - ThaumcraftApi.portableHoleBlackList.add(aBlock); - return true; + private static final Class mClass_ThaumcraftApi; + private static final Class mClass_ThaumcraftApiHelper; + private static final Class mClass_AspectList; + private static final Class mClass_ResearchManager; + private static final Method mMethod_registerObjectTag1; + private static final Method mMethod_registerObjectTag2; + private static final Method mMethod_registerComplexObjectTag; + private static final Method mMethod_addInfusionCraftingRecipe; + private static final Method mMethod_addCrucibleRecipe; + private static final Method mMethod_getObjectAspects; + private static final Method mMethod_updateData; + + private static final Field mField_PortholeBlacklist; + static { + /* + * Classes + */ + mClass_ThaumcraftApi = ReflectionUtils.getClass("thaumcraft.api.ThaumcraftApi"); + mClass_ThaumcraftApiHelper = ReflectionUtils.getClass("thaumcraft.api.ThaumcraftApiHelper"); + mClass_AspectList = ReflectionUtils.getClass("thaumcraft.api.aspects.AspectList"); + mClass_ResearchManager = ReflectionUtils.getClass("thaumcraft.common.lib.research.ResearchManager"); + + /* + * Methods + */ + mMethod_registerObjectTag1 = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "registerObjectTag", + ItemStack.class, mClass_AspectList); + + mMethod_registerObjectTag2 = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "registerObjectTag", String.class, + mClass_AspectList); + + mMethod_registerComplexObjectTag = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "registerComplexObjectTag", + ItemStack.class, mClass_AspectList); + + mMethod_addInfusionCraftingRecipe = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "addInfusionCraftingRecipe", + String.class, Object.class, int.class, mClass_AspectList, ItemStack.class, ItemStack[].class); + + mMethod_addCrucibleRecipe = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "addCrucibleRecipe", String.class, + ItemStack.class, Object.class, mClass_AspectList); + + mMethod_getObjectAspects = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "getObjectAspects", ItemStack.class); + mMethod_updateData = ReflectionUtils.getMethod(mClass_ResearchManager, "updateData", ItemStack.class, ReflectionUtils.getClass("thaumcraft.common.lib.research.ResearchNoteData")); + + /* + * Fields + */ + mField_PortholeBlacklist = ReflectionUtils.getField(mClass_ThaumcraftApi, "portableHoleBlackList"); + + } + + public static void registerObjectTag(ItemStack aStack, TC_AspectList_Wrapper aAspectList) { + try { + mMethod_registerObjectTag1.invoke(null, aStack, aAspectList.getVanillaAspectList()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } } - public static TC_AspectStack_Ex convertAspectStack(TC_AspectStack gtType) { - TC_AspectStack_Ex g = null; - if (gtType == null) { - return null; + public static void registerObjectTag(String aOreDict, TC_AspectList_Wrapper aAspectList) { + try { + mMethod_registerObjectTag2.invoke(null, aOreDict, aAspectList.getVanillaAspectList()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); } - else { - String oldName = gtType.mAspect.name().toLowerCase(); - long oldAmount = gtType.mAmount; - for (GTPP_Aspects r : GTPP_Aspects.values()) { - if (r.mAspect.getName().toLowerCase().contains(oldName)) { - g = new TC_AspectStack_Ex(r, oldAmount); - break; - } - } - } - return g; } + + public static void registerComplexObjectTag(ItemStack aStack, TC_AspectList_Wrapper aAspectList) { + try { + mMethod_registerComplexObjectTag.invoke(null, aStack, aAspectList.getVanillaAspectList()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + + public static TC_AspectList_Wrapper getObjectAspects(ItemStack aStack) { + try { + return new TC_AspectList_Wrapper(mMethod_getObjectAspects.invoke(null, aStack)); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + + + + public static Object addCrucibleRecipe(String aResearch, ItemStack copy, Object aOutput, + TC_AspectList_Wrapper aAspectList) { + try { + return mMethod_addCrucibleRecipe.invoke(null, aResearch, copy, aOutput, aAspectList); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + + public static Object addInfusionCraftingRecipe(String aResearch, Object copy, int aInstability, + TC_AspectList_Wrapper aAspectList, ItemStack aMainInput, ItemStack[] aSideInputs) { + try { + return mMethod_addInfusionCraftingRecipe.invoke(null, aResearch, copy, aInstability, aAspectList, aMainInput, aSideInputs); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + - public static List convertAspectStack(List p5) { - List list = new ArrayList(); - for (TC_AspectStack h : p5) { - list.add(convertAspectStack(h)); + public static boolean registerPortholeBlacklistedBlock(final Block aBlock) { + try { + ((ArrayList) mField_PortholeBlacklist.get(null)).add(aBlock); + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + return false; } - return list; + return true; } + - public static void updateResearchNote(ItemStack a, ResearchNoteData b) { - updateResearchNote(a, new ResearchNoteDataWrapper(b)); + public static String getTagFromAspectObject(Object aAspect) { + try { + Field aTagF = ReflectionUtils.getField(mClass_Aspect, "tag"); + if (aTagF == null) { + return null; + } + String aTafB = (String) aTagF.get(aAspect); + if (aTafB == null) { + return null; + } + String aTag = aTafB.toLowerCase(); + return aTag; + } catch (IllegalArgumentException | IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return "error"; + } } + - public static void updateResearchNote(ItemStack a, ResearchNoteDataWrapper b) { - ResearchManager.updateData(a, b); + public static void updateResearchNote(ItemStack a, TC_ResearchNoteData_Wrapper b) { + //updateData(a, b.getResearchNoteData()); + try { + mMethod_updateData.invoke(a, b.getResearchNoteData()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } public static boolean isItemResearchNotes(ItemStack aStack) { @@ -276,16 +377,16 @@ public class ThaumcraftUtils { return false; } - public static ResearchNoteDataWrapper gatherResults(ItemStack note) { - ResearchNoteDataWrapper research = null; + public static TC_ResearchNoteData_Wrapper gatherResults(ItemStack note) { + TC_ResearchNoteData_Wrapper research = null; if (isItemResearchNotes(note)) { - research = new ResearchNoteDataWrapper(ResearchManager.getData(note)); + research = new TC_ResearchNoteData_Wrapper(ResearchManager.getData(note)); } return research; } public static void placeAspectIntoResearchNote(ItemStack note, World aWorld, final int q, final int r, final Aspect aspect) { - ResearchNoteDataWrapper data = gatherResults(note); + TC_ResearchNoteData_Wrapper data = gatherResults(note); String mGTPP = CORE.gameProfile.getName(); EntityPlayer player = CORE.getFakePlayer(aWorld); @@ -325,4 +426,17 @@ public class ThaumcraftUtils { } } } + + public static synchronized final TC_AspectList_Wrapper getAspectList_Ex(final List aAspects) { + final TC_AspectList_Wrapper rAspects = new TC_AspectList_Wrapper(); + for (final GTPP_AspectStack tAspect : aAspects) { + rAspects.add(tAspect.mAspect, tAspect.mAmount); + } + return rAspects; + } + + public static void addResearch(TC_ResearchItem_Wrapper tc_ResearchItem_Wrapper) { + // TODO Auto-generated method stub + + } } -- cgit From af27ff015c4197bb5a6ddb7dd38769f8950a4ac9 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 4 Mar 2019 18:26:33 +0000 Subject: + Added more TC wrappers. --- .../aspect/TC_ResearchNoteData_Wrapper.java | 4 ++ .../thaumcraft/aspect/TC_ResearchPage_Wrapper.java | 19 +++--- .../wrapper/recipe/Base_Recipe_Wrapper.java | 10 +++ .../wrapper/recipe/TC_CrucibleRecipe_Wrapper.java | 19 ++++++ .../wrapper/recipe/TC_IArcaneRecipe_Wrapper.java | 19 ++++++ .../TC_InfusionEnchantmentRecipe_Wrapper.java | 19 ++++++ .../wrapper/recipe/TC_InfusionRecipe_Wrapper.java | 19 ++++++ .../xmod/thaumcraft/util/ThaumcraftUtils.java | 73 +++++++++++++--------- 8 files changed, 144 insertions(+), 38 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/Base_Recipe_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_CrucibleRecipe_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_IArcaneRecipe_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionEnchantmentRecipe_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionRecipe_Wrapper.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java index 64f1ce088a..dbec20cdb8 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java @@ -2,6 +2,10 @@ package gtPlusPlus.xmod.thaumcraft.aspect; public class TC_ResearchNoteData_Wrapper { + public TC_ResearchNoteData_Wrapper(Object researchNoteData) { + // TODO Auto-generated constructor stub + } + public Object getResearchNoteData() { // TODO Auto-generated method stub return null; diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java index 256e9c19ed..23d3a9f575 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java @@ -1,6 +1,11 @@ package gtPlusPlus.xmod.thaumcraft.aspect; import java.util.List; + +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_CrucibleRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_IArcaneRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionEnchantmentRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionRecipe_Wrapper; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.IRecipe; @@ -66,7 +71,7 @@ public class TC_ResearchPage_Wrapper { this.recipe = recipe; } - public TC_ResearchPage_Wrapper(IArcaneRecipe[] recipe) { + public TC_ResearchPage_Wrapper(TC_IArcaneRecipe_Wrapper[] recipe) { this.type = TC_PageType_Wrapper.TEXT; this.text = null; this.research = null; @@ -78,7 +83,7 @@ public class TC_ResearchPage_Wrapper { this.recipe = recipe; } - public TC_ResearchPage_Wrapper(CrucibleRecipe[] recipe) { + public TC_ResearchPage_Wrapper(TC_CrucibleRecipe_Wrapper[] recipe) { this.type = TC_PageType_Wrapper.TEXT; this.text = null; this.research = null; @@ -90,7 +95,7 @@ public class TC_ResearchPage_Wrapper { this.recipe = recipe; } - public TC_ResearchPage_Wrapper(InfusionRecipe[] recipe) { + public TC_ResearchPage_Wrapper(TC_InfusionRecipe_Wrapper[] recipe) { this.type = TC_PageType_Wrapper.TEXT; this.text = null; this.research = null; @@ -114,7 +119,7 @@ public class TC_ResearchPage_Wrapper { this.recipe = recipe; } - public TC_ResearchPage_Wrapper(IArcaneRecipe recipe) { + public TC_ResearchPage_Wrapper(TC_IArcaneRecipe_Wrapper recipe) { this.type = TC_PageType_Wrapper.TEXT; this.text = null; this.research = null; @@ -127,7 +132,7 @@ public class TC_ResearchPage_Wrapper { this.recipeOutput = recipe.getRecipeOutput(); } - public TC_ResearchPage_Wrapper(CrucibleRecipe recipe) { + public TC_ResearchPage_Wrapper(TC_CrucibleRecipe_Wrapper recipe) { this.type = TC_PageType_Wrapper.TEXT; this.text = null; this.research = null; @@ -153,7 +158,7 @@ public class TC_ResearchPage_Wrapper { this.recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); } - public TC_ResearchPage_Wrapper(InfusionRecipe recipe) { + public TC_ResearchPage_Wrapper(TC_InfusionRecipe_Wrapper recipe) { this.type = TC_PageType_Wrapper.TEXT; this.text = null; this.research = null; @@ -171,7 +176,7 @@ public class TC_ResearchPage_Wrapper { } - public TC_ResearchPage_Wrapper(InfusionEnchantmentRecipe recipe) { + public TC_ResearchPage_Wrapper(TC_InfusionEnchantmentRecipe_Wrapper recipe) { this.type = TC_PageType_Wrapper.TEXT; this.text = null; this.research = null; diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/Base_Recipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/Base_Recipe_Wrapper.java new file mode 100644 index 0000000000..914144445c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/Base_Recipe_Wrapper.java @@ -0,0 +1,10 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public interface Base_Recipe_Wrapper { + + public abstract ItemStack getRecipeOutput(); + + public abstract ItemStack getRecipeInput(); +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_CrucibleRecipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_CrucibleRecipe_Wrapper.java new file mode 100644 index 0000000000..8ee4e7011d --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_CrucibleRecipe_Wrapper.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public class TC_CrucibleRecipe_Wrapper implements Base_Recipe_Wrapper { + + @Override + public ItemStack getRecipeInput() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getRecipeOutput() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_IArcaneRecipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_IArcaneRecipe_Wrapper.java new file mode 100644 index 0000000000..fede079f7b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_IArcaneRecipe_Wrapper.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public class TC_IArcaneRecipe_Wrapper implements Base_Recipe_Wrapper { + + @Override + public ItemStack getRecipeInput() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getRecipeOutput() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionEnchantmentRecipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionEnchantmentRecipe_Wrapper.java new file mode 100644 index 0000000000..b52fa0e6a7 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionEnchantmentRecipe_Wrapper.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public class TC_InfusionEnchantmentRecipe_Wrapper implements Base_Recipe_Wrapper { + + @Override + public ItemStack getRecipeInput() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getRecipeOutput() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionRecipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionRecipe_Wrapper.java new file mode 100644 index 0000000000..a0c539f937 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionRecipe_Wrapper.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public class TC_InfusionRecipe_Wrapper implements Base_Recipe_Wrapper { + + @Override + public ItemStack getRecipeInput() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getRecipeOutput() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java index 6e275e9b67..c60a140819 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java @@ -5,34 +5,35 @@ import static gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft.sItemsToGetAspects; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.TC_Aspects; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft; import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectStack; -import gtPlusPlus.xmod.thaumcraft.aspect.TC_Aspect_Wrapper; import gtPlusPlus.xmod.thaumcraft.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.aspect.TC_Aspect_Wrapper; import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchCategories_Wrapper; import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchCategoryList_Wrapper; import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchItem_Wrapper; import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchNoteData_Wrapper; import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchPage_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_CrucibleRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_IArcaneRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionEnchantmentRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionRecipe_Wrapper; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; public class ThaumcraftUtils { @@ -40,10 +41,6 @@ public class ThaumcraftUtils { private static Class mClass_Aspect; private static Field mField_Aspects; - /*public static boolean addAspectToItem(ItemStack item, Aspect[] aspects, int amount) { - return addAspectToItem(item, getEnumAspect(aspect.getName()), amount); - }*/ - public static boolean addAspectToItem(ItemStack item, TC_Aspect_Wrapper aspect, int amount) { return addAspectToItem(item, new TC_Aspect_Wrapper[] {aspect}, new Integer[] {amount}); @@ -105,15 +102,15 @@ public class ThaumcraftUtils { } else if ((tPage instanceof IRecipe)) { tPages.add(new TC_ResearchPage_Wrapper((IRecipe) tPage)); } - /*else if ((tPage instanceof IArcaneRecipe)) { - tPages.add(new TC_ResearchPage_Wrapper((IArcaneRecipe) tPage)); - } else if ((tPage instanceof CrucibleRecipe)) { - tPages.add(new TC_ResearchPage_Wrapper((CrucibleRecipe) tPage)); - } else if ((tPage instanceof InfusionRecipe)) { - tPages.add(new TC_ResearchPage_Wrapper((InfusionRecipe) tPage)); - } else if ((tPage instanceof InfusionEnchantmentRecipe)) { - tPages.add(new TC_ResearchPage_Wrapper((InfusionEnchantmentRecipe) tPage)); - }*/ + else if ((tPage instanceof TC_IArcaneRecipe_Wrapper)) { + tPages.add(new TC_ResearchPage_Wrapper((TC_IArcaneRecipe_Wrapper) tPage)); + } else if ((tPage instanceof TC_CrucibleRecipe_Wrapper)) { + tPages.add(new TC_ResearchPage_Wrapper((TC_CrucibleRecipe_Wrapper) tPage)); + } else if ((tPage instanceof TC_InfusionRecipe_Wrapper)) { + tPages.add(new TC_ResearchPage_Wrapper((TC_InfusionRecipe_Wrapper) tPage)); + } else if ((tPage instanceof TC_InfusionEnchantmentRecipe_Wrapper)) { + tPages.add(new TC_ResearchPage_Wrapper((TC_InfusionEnchantmentRecipe_Wrapper) tPage)); + } } if ((aType & 0x40) != 0) { rResearch.setAutoUnlock(); @@ -226,6 +223,7 @@ public class ThaumcraftUtils { private static final Method mMethod_addCrucibleRecipe; private static final Method mMethod_getObjectAspects; private static final Method mMethod_updateData; + private static final Method mMethod_getData; private static final Field mField_PortholeBlacklist; static { @@ -255,8 +253,12 @@ public class ThaumcraftUtils { mMethod_addCrucibleRecipe = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "addCrucibleRecipe", String.class, ItemStack.class, Object.class, mClass_AspectList); - mMethod_getObjectAspects = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "getObjectAspects", ItemStack.class); + + mMethod_getObjectAspects = ReflectionUtils.getMethod(mClass_ThaumcraftApiHelper, "getObjectAspects", ItemStack.class); + + mMethod_updateData = ReflectionUtils.getMethod(mClass_ResearchManager, "updateData", ItemStack.class, ReflectionUtils.getClass("thaumcraft.common.lib.research.ResearchNoteData")); + mMethod_getData = ReflectionUtils.getMethod(mClass_ResearchManager, "getData", ItemStack.class); /* * Fields @@ -359,8 +361,17 @@ public class ThaumcraftUtils { mMethod_updateData.invoke(a, b.getResearchNoteData()); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); - } - + } + } + + public static Object getResearchNoteData(ItemStack a) { + //getData(a); + try { + return mMethod_getData.invoke(a); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; } public static boolean isItemResearchNotes(ItemStack aStack) { @@ -380,13 +391,13 @@ public class ThaumcraftUtils { public static TC_ResearchNoteData_Wrapper gatherResults(ItemStack note) { TC_ResearchNoteData_Wrapper research = null; if (isItemResearchNotes(note)) { - research = new TC_ResearchNoteData_Wrapper(ResearchManager.getData(note)); + research = new TC_ResearchNoteData_Wrapper(getResearchNoteData(note)); } return research; } - public static void placeAspectIntoResearchNote(ItemStack note, World aWorld, final int q, final int r, final Aspect aspect) { - TC_ResearchNoteData_Wrapper data = gatherResults(note); + public static void placeAspectIntoResearchNote(ItemStack note, World aWorld, final int q, final int r, final TC_Aspect_Wrapper aspect) { + /*TC_ResearchNoteData_Wrapper data = gatherResults(note); String mGTPP = CORE.gameProfile.getName(); EntityPlayer player = CORE.getFakePlayer(aWorld); @@ -416,7 +427,7 @@ public class ThaumcraftUtils { if (!aWorld.isRemote && ResearchManager.checkResearchCompletion(note, data, player.getCommandSenderName())) { note.setItemDamage(64); } - } + }*/ } public static void completeResearchNote(World aWorld, ItemStack aStack) { -- cgit From 94f842fa9223d1d0fa233266495a20a00eafa030 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 4 Mar 2019 21:05:08 +0000 Subject: % Final touches to TC aspects. The 5 custom ones added by GT++ now have names and proper handling. --- .../core/item/base/BaseItemComponent.java | 7 +- .../core/item/base/ore/BaseOreComponent.java | 7 +- src/Java/gtPlusPlus/core/material/Material.java | 4 +- .../core/util/reflect/ReflectionUtils.java | 9 + .../xmod/thaumcraft/HANDLER_Thaumcraft.java | 2 +- .../xmod/thaumcraft/aspect/GTPP_AspectCompat.java | 58 +++- .../xmod/thaumcraft/aspect/GTPP_AspectStack.java | 2 + .../thaumcraft/aspect/TC_AspectList_Wrapper.java | 40 --- .../xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java | 308 -------------------- .../thaumcraft/aspect/TC_PageType_Wrapper.java | 17 -- .../aspect/TC_ResearchCategories_Wrapper.java | 89 ------ .../aspect/TC_ResearchCategoryList_Wrapper.java | 21 -- .../thaumcraft/aspect/TC_ResearchItem_Wrapper.java | 244 ---------------- .../aspect/TC_ResearchNoteData_Wrapper.java | 14 - .../thaumcraft/aspect/TC_ResearchPage_Wrapper.java | 227 --------------- .../wrapper/aspect/TC_AspectList_Wrapper.java | 40 +++ .../objects/wrapper/aspect/TC_Aspect_Wrapper.java | 314 +++++++++++++++++++++ .../wrapper/research/TC_PageType_Wrapper.java | 17 ++ .../research/TC_ResearchCategories_Wrapper.java | 89 ++++++ .../research/TC_ResearchCategoryList_Wrapper.java | 21 ++ .../wrapper/research/TC_ResearchItem_Wrapper.java | 246 ++++++++++++++++ .../research/TC_ResearchNoteData_Wrapper.java | 14 + .../wrapper/research/TC_ResearchPage_Wrapper.java | 228 +++++++++++++++ .../xmod/thaumcraft/util/ThaumcraftUtils.java | 14 +- .../miscutils/textures/aspects/Sagrausten.png | Bin 0 -> 2997 bytes .../assets/miscutils/textures/aspects/Slusium.png | Bin 0 -> 697 bytes .../assets/miscutils/textures/aspects/Xablum.png | Bin 0 -> 563 bytes .../assets/miscutils/textures/aspects/Xenil.png | Bin 0 -> 1000 bytes .../assets/miscutils/textures/aspects/Zetralt.png | Bin 0 -> 1461 bytes 29 files changed, 1047 insertions(+), 985 deletions(-) delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java delete mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_AspectList_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_PageType_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategories_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategoryList_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchItem_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchNoteData_Wrapper.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchPage_Wrapper.java create mode 100644 src/resources/assets/miscutils/textures/aspects/Sagrausten.png create mode 100644 src/resources/assets/miscutils/textures/aspects/Slusium.png create mode 100644 src/resources/assets/miscutils/textures/aspects/Xablum.png create mode 100644 src/resources/assets/miscutils/textures/aspects/Xenil.png create mode 100644 src/resources/assets/miscutils/textures/aspects/Zetralt.png (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index 4dbb5851f2..522b7e900e 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -8,6 +8,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.TextureSet; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.Logger; @@ -21,7 +22,7 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -66,9 +67,9 @@ public class BaseItemComponent extends Item{ GT_OreDictUnificator.registerOre(componentType.getOreDictName()+material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); if (LoadedMods.Thaumcraft) { - ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.METALLUM, 1); + ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.METALLUM.mAspect), 1); if (componentMaterial.isRadioactive) { - ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.RADIO, 2); + ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.RADIO.mAspect), componentMaterial.vRadiationLevel); } } registerComponent(); diff --git a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java index 2b3f477c56..de47ed8225 100644 --- a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -16,6 +16,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TC_Aspects; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; @@ -26,7 +27,7 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; public class BaseOreComponent extends Item{ @@ -57,9 +58,9 @@ public class BaseOreComponent extends Item{ registerComponent(); GT_OreDictUnificator.registerOre(componentType.getComponent()+material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); if (LoadedMods.Thaumcraft) { - ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.METALLUM, 2); + ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.METALLUM.mAspect), 1); if (componentMaterial.isRadioactive) { - ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.RADIO, 4); + ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.RADIO.mAspect), componentMaterial.vRadiationLevel); } } diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index ba572efe90..58a7f68afe 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -23,7 +23,7 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; import gtPlusPlus.xmod.tinkers.material.BaseTinkersMaterial; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -78,7 +78,7 @@ public class Material { public int vToolQuality; public int vHarvestLevel; - private GTPP_Aspects[] vAspects; + private TC_Aspect_Wrapper[] vAspects; public BaseTinkersMaterial vTiConHandler; diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 617728cdec..722a4f3ff7 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -107,6 +107,9 @@ public class ReflectionUtils { * @return - Valid, {@link Class} object, or {@link null}. */ public static Class getClass(String aClassCanonicalName) { + if (aClassCanonicalName == null || aClassCanonicalName.length() <= 0) { + return null; + } Class y = mCachedClasses.get(aClassCanonicalName); if (y == null) { y = getClass_Internal(aClassCanonicalName); @@ -140,6 +143,9 @@ public class ReflectionUtils { * @return - Valid, non-final, {@link Method} object, or {@link null}. */ public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { + if (aClass == null || aMethodName == null || aMethodName.length() <= 0) { + return null; + } String aMethodKey = ArrayUtils.toString(aTypes); //Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethodName + "." + aMethodKey); @@ -166,6 +172,9 @@ public class ReflectionUtils { * @return - Valid, non-final, {@link Field} object, or {@link null}. */ public static Field getField(final Class aClass, final String aFieldName) { + if (aClass == null || aFieldName == null || aFieldName.length() <= 0) { + return null; + } CachedField y = mCachedFields.get(aClass.getName()+"."+aFieldName); if (y == null) { Field u; diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java index b02ba40392..35e608b0ca 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java @@ -45,7 +45,7 @@ public class HANDLER_Thaumcraft { //sThaumcraftCompat = (IThaumcraftCompat) GT_Utility.callConstructor("gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectCompat", 0, null, GT_Values.D1, new Object[0]); sThaumcraftCompat = new GTPP_AspectCompat(); - if (!sItemsToGetAspects.isEmpty()) { + if (!sItemsToGetAspects.isEmpty() && false) { for (Pair j : sItemsToGetAspects) { if (j .getKey() != null && (j.getValue() != null && j.getValue().length > 0)) { List list = Arrays.asList(j.getValue()); diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java index ea4c97fbfc..d5a19a91fc 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java @@ -10,6 +10,9 @@ import gregtech.api.enums.TC_Aspects; import gregtech.api.util.GT_LanguageManager; import gregtech.common.GT_ThaumcraftCompat; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; import net.minecraft.util.ResourceLocation; public class GTPP_AspectCompat { @@ -99,8 +102,8 @@ public class GTPP_AspectCompat { // Custom Aspects ASPECT_BALANCE = new TC_Aspect_Wrapper( - "Purity", - 15647411, + "Sagrausten", + Utils.rgbtoHexValue(125, 125, 125), new TC_Aspect_Wrapper[]{ get(TC_Aspects.GELUM), get(TC_Aspects.IGNIS) @@ -108,10 +111,11 @@ public class GTPP_AspectCompat { new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), false, 1); + ASPECT_LUST = new TC_Aspect_Wrapper( - "Vengeance", - 15647411, + "Slusium", + Utils.rgbtoHexValue(175, 125, 25), new TC_Aspect_Wrapper[]{ get(TC_Aspects.CORPUS), get(TC_Aspects.ORDO) @@ -119,6 +123,42 @@ public class GTPP_AspectCompat { new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.NEBRISUM.name() + ".png"), false, 1); + + ASPECT_STARBOUND = + new TC_Aspect_Wrapper( + "Xenil", + Utils.rgbtoHexValue(25, 25, 25), + new TC_Aspect_Wrapper[]{ + get(TC_Aspects.ALIENIS), + ASPECT_BALANCE + }, + new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.NEBRISUM.name() + ".png"), + false, + 1); + + ASPECT_TOXIC = + new TC_Aspect_Wrapper( + "Xablum", + Utils.rgbtoHexValue(25, 185, 25), + new TC_Aspect_Wrapper[]{ + get(TC_Aspects.CORPUS), + ASPECT_LUST + }, + new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.NEBRISUM.name() + ".png"), + false, + 1); + + ASPECT_HEAVEN = + new TC_Aspect_Wrapper( + "Zetralt", + Utils.rgbtoHexValue(225, 225, 225), + new TC_Aspect_Wrapper[]{ + get(TC_Aspects.COGNITIO), + ASPECT_BALANCE + }, + new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.NEBRISUM.name() + ".png"), + false, + 1); @@ -131,11 +171,11 @@ public class GTPP_AspectCompat { new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); GTPP_Aspects.CUSTOM_5.mAspect = new Aspect("custom4", 12648384, new Aspect[]{Aspect.LIGHT, Aspect.SOUL}, new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1);*/ - GT_LanguageManager.addStringLocalization("tc.aspect.Purity", "Balance"); - GT_LanguageManager.addStringLocalization("tc.aspect.Vengeance", "Lust"); - GT_LanguageManager.addStringLocalization("tc.aspect.custom3", "Starbound"); - GT_LanguageManager.addStringLocalization("tc.aspect.custom4", "Toxic"); - GT_LanguageManager.addStringLocalization("tc.aspect.custom5", "Heaven"); + GT_LanguageManager.addStringLocalization("tc.aspect.Sagrausten", "Balance"); + GT_LanguageManager.addStringLocalization("tc.aspect.Slusium", "Lust"); + GT_LanguageManager.addStringLocalization("tc.aspect.Xenil", "Starbound"); + GT_LanguageManager.addStringLocalization("tc.aspect.Xablum", "Toxic"); + GT_LanguageManager.addStringLocalization("tc.aspect.Zetralt", "Zetralt"); } private TC_Aspect_Wrapper get(TC_Aspects aGtObjects) { diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java index d7cfa7d326..23e9035f40 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java @@ -1,5 +1,7 @@ package gtPlusPlus.xmod.thaumcraft.aspect; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; + public class GTPP_AspectStack { public final TC_Aspect_Wrapper mAspect; diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java deleted file mode 100644 index 0a7f2d6a3c..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import net.minecraft.item.ItemStack; - -public class TC_AspectList_Wrapper { - - - //thaumcraft.api.aspects.Aspect; - //thaumcraft.api.aspects.AspectList; - - public TC_AspectList_Wrapper() { - - } - - public TC_AspectList_Wrapper(ItemStack stack) { - - } - - public TC_AspectList_Wrapper(Object invoke) { - // TODO Auto-generated constructor stub - } - - public int size() { - // TODO Auto-generated method stub - return 0; - } - - public Object getVanillaAspectList() { - // TODO Auto-generated method stub - return null; - } - - public void add(TC_Aspect_Wrapper mAspect, int mAmount) { - // TODO Auto-generated method stub - - } - - - -} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java deleted file mode 100644 index 78c2a670bb..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java +++ /dev/null @@ -1,308 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.LinkedHashMap; -import java.util.Map; - -import gregtech.api.enums.TC_Aspects; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import net.minecraft.util.ResourceLocation; - -/** - * Wrapper class for Thaumcraft Aspects. - * Used to avoid compile time dependencies. - * @author Alkalus - * - */ -public class TC_Aspect_Wrapper { - - private static Class mClass_Aspect; - private static Field mField_Aspects; - - private final String tag; - private final TC_Aspect_Wrapper[] components; - private final int color; - private String chatcolor; - private final ResourceLocation image; - private final int blend; - - public final Object mAspect; - - /** - * May be null, but links back to the TC_Aspects class from GT for convinience. - */ - public final TC_Aspects mGtEnumField; - - - - - /** - * Statically set the Class objects - */ - static { - mClass_Aspect = ReflectionUtils.getClass("thaumcraft.api.aspects.Aspect"); - } - - /** - * Gets the total aspect list from Thaumcraft, which should contain all other registered aspects. - * @return - A LinkedHashMap(String, Aspect); - */ - public static LinkedHashMap getVanillaAspectList() { - try { - if (mField_Aspects == null) { - mField_Aspects = ReflectionUtils.getField(mClass_Aspect, "aspects"); - } - return (LinkedHashMap) mField_Aspects.get(null); - } catch (IllegalArgumentException | IllegalAccessException e) { - Logger.REFLECTION("Failed configuring TC Aspect compatibility."); - return new LinkedHashMap(); - } - } - - public static Object getVanillaAspectObject(String aAspectName) { - return getVanillaAspectList().get(aAspectName); - } - - - - - - - - - - - - - - - /** - * Vanilla Aspect Constructor - * @param tag - Aspect Name - * @param color - * @param chatcolor - * @param blend - */ - public TC_Aspect_Wrapper(String tag, int color, String chatcolor, int blend) { - this(tag, color, (TC_Aspect_Wrapper[]) null, blend); - this.chatcolor = chatcolor; - } - - /** - * - * Vanilla Aspect Constructor - * @param tag - Aspect Name - * @param color - * @param components - */ - public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components) { - this(tag, color, components, false, 1); - } - - /** - * - * Vanilla Aspect Constructor - * @param tag - Aspect Name - * @param color - * @param components - * @param blend - */ - public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, int blend) { - this(tag, color, components, false, blend); - } - - - /** - * - * Vanilla Aspect Constructor - * @param tag - Aspect Name - * @param color - * @param components - * @param image - * @param blend - */ - public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, boolean vanilla, int blend) { - this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend); - } - - - public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, ResourceLocation image, boolean vanilla, int blend) { - if (getAspectList().containsKey(tag.toLowerCase())) { - throw new IllegalArgumentException(tag + " already registered!"); - } else { - this.tag = tag.toLowerCase(); - this.components = components; - this.color = color; - this.image = image; - this.blend = blend; - this.mAspect = vanilla ? getVanillaAspectObject(this.tag) : this.generateTcAspect(); - - //Set GT Type if exists - TC_Aspects y = null; - for (TC_Aspects e : TC_Aspects.values()) { - TC_Aspect_Wrapper g; - try { - g = generate(e.mAspect); - if (g != null) { - if (g.tag.equals(this.tag)) { - y = e; - break; - } - } - } catch (IllegalArgumentException e1) { - e1.printStackTrace(); - } - } - mGtEnumField = y; - - - Logger.INFO("[Thaumcraft++] Adding support for Aspect: "+tag); - } - } - - - - /** - * Generates a TC_Aspect from an object, presummed to be a TC Aspect. - * @param aBaseAspect - The TC Aspect to generate from. - * @return - * @throws IllegalArgumentException - * @throws IllegalAccessException - */ - @SuppressWarnings("unused") - public static TC_Aspect_Wrapper generate(Object aBaseAspect) { - try { - Field aTagF = ReflectionUtils.getField(mClass_Aspect, "tag"); - if (aTagF == null) { - return null; - } - String aTafB = (String) aTagF.get(aBaseAspect); - if (aTafB == null) { - return null; - } - String aTag = aTafB.toLowerCase(); - if (aTag != null && getAspectList().containsKey(aTag.toLowerCase())) { - return getAspect(aTag); - } else { - TC_Aspect_Wrapper aTemp = new TC_Aspect_Wrapper( - aTag, - (int) ReflectionUtils.getField(mClass_Aspect, "color").get(aBaseAspect), - generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), (aBaseAspect)), - (ResourceLocation) ReflectionUtils.getField(mClass_Aspect, "image").get(aBaseAspect), - true, - (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect) - ); - if (aTemp != null) { - aTemp.chatcolor = (String) ReflectionUtils.getField(mClass_Aspect, "chatcolor").get(aBaseAspect); - return aTemp; - } - else { - return null; - } - } - } - catch (Throwable t) { - t.printStackTrace(); - return null; - } - } - - - /** - * Internal Map containing all the TC_Aspects. - */ - private static Map mInternalAspectCache = new LinkedHashMap(); - - /** - * Public getter for all TC_Aspects - * @param aAspectName - Aspect Name - * @return - A GT++ Aspect wrapper or null. (TC_Aspect) - */ - public static TC_Aspect_Wrapper getAspect(String aAspectName) { - String aName = aAspectName.toLowerCase(); - TC_Aspect_Wrapper g = mInternalAspectCache.get(aName); - if (g != null) { - return g; - } - else { - try { - TC_Aspect_Wrapper aTemp = generate(getVanillaAspectList().get(aName)); - if (aTemp != null) { - mInternalAspectCache.put(aName, aTemp); - return aTemp; - } - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } - } - return null; - } - - public static Map getAspectList(){ - return mInternalAspectCache; - } - - - private static TC_Aspect_Wrapper[] generateAspectArrayInternal(Field aField, Object aInstance) { - //thaumcraft.api.aspects.Aspect.Aspect() - Object[] components; - TC_Aspect_Wrapper[] aAspectArray; - try { - components = (Object[]) aField.get(aInstance); - aAspectArray = new TC_Aspect_Wrapper[components.length]; - if (components.length > 0) { - int i = 0; - for (Object g : components) { - aAspectArray[i] = getAspect((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(g)); - i++; - } - } - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - aAspectArray = new TC_Aspect_Wrapper[0]; - } - return aAspectArray; - } - - /** - * Tasty code to generate TC Aspects reflectively. - * @return - */ - public Object generateTcAspect() { - try { - //thaumcraft.api.aspects.Aspect.Aspect() - Object aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, 1); - if (components.length > 0) { - aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, components.length); - int i = 0; - for (TC_Aspect_Wrapper g : components) { - ((Object[]) aAspectArray)[i++] = g.mAspect; - } - } - Constructor constructor = mClass_Aspect.getConstructor(String.class, int.class, aAspectArray.getClass(), ResourceLocation.class, int.class); - Object myObject = constructor.newInstance(tag, color, aAspectArray, image, blend); - - //Set chat colour - if (chatcolor != null && chatcolor.length() > 0) { - Method setChatColour = ReflectionUtils.getMethod(mClass_Aspect, "setChatcolor", String.class); - if (setChatColour != null) { - setChatColour.invoke(myObject, chatcolor); - } - } - return myObject; - } catch (Throwable t) { - t.printStackTrace(); - return null; - } - } - - public static boolean isObjectAnAspect(Object aAspect) { - return mClass_Aspect.isInstance(aAspect); - } - -} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java deleted file mode 100644 index 5a608e290f..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -public class TC_PageType_Wrapper { - - public static final TC_PageType_Wrapper TEXT = null; - public static final TC_PageType_Wrapper TEXT_CONCEALED = null; - public static final TC_PageType_Wrapper NORMAL_CRAFTING = null; - public static final TC_PageType_Wrapper ARCANE_CRAFTING = null; - public static final TC_PageType_Wrapper CRUCIBLE_CRAFTING = null; - public static final TC_PageType_Wrapper INFUSION_CRAFTING = null; - public static final TC_PageType_Wrapper COMPOUND_CRAFTING = null; - public static final TC_PageType_Wrapper SMELTING = null; - public static final TC_PageType_Wrapper INFUSION_ENCHANTMENT = null; - public static final TC_PageType_Wrapper IMAGE = null; - public static final TC_PageType_Wrapper ASPECTS = null; - -} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java deleted file mode 100644 index 3392dbcff9..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java +++ /dev/null @@ -1,89 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import cpw.mods.fml.common.FMLLog; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashMap; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import org.apache.logging.log4j.Level; - -public class TC_ResearchCategories_Wrapper { - - public static LinkedHashMap researchCategories = new LinkedHashMap(); - - public static TC_ResearchCategoryList_Wrapper getResearchList(String key) { - return (TC_ResearchCategoryList_Wrapper) researchCategories.get(key); - } - - public static String getCategoryName(String key) { - return StatCollector.translateToLocal("tc.research_category." + key); - } - - public static TC_ResearchItem_Wrapper getResearch(String key) { - Collection rc = researchCategories.values(); - Iterator i$ = rc.iterator(); - - while (i$.hasNext()) { - Object cat = i$.next(); - Collection rl = ((TC_ResearchCategoryList_Wrapper) cat).research.values(); - Iterator i$1 = rl.iterator(); - - while (i$1.hasNext()) { - Object ri = i$1.next(); - if (((TC_ResearchItem_Wrapper) ri).key.equals(key)) { - return (TC_ResearchItem_Wrapper) ri; - } - } - } - - return null; - } - - public static void registerCategory(String key, ResourceLocation icon, ResourceLocation background) { - if (getResearchList(key) == null) { - TC_ResearchCategoryList_Wrapper rl = new TC_ResearchCategoryList_Wrapper(icon, background); - researchCategories.put(key, rl); - } - - } - - public static void addResearch(TC_ResearchItem_Wrapper ri) { - TC_ResearchCategoryList_Wrapper rl = getResearchList(ri.category); - if (rl != null && !rl.research.containsKey(ri.key)) { - if (!ri.isVirtual()) { - Iterator i$ = rl.research.values().iterator(); - - while (i$.hasNext()) { - TC_ResearchItem_Wrapper rr = (TC_ResearchItem_Wrapper) i$.next(); - if (rr.displayColumn == ri.displayColumn && rr.displayRow == ri.displayRow) { - FMLLog.log(Level.FATAL, - "[Thaumcraft] Research [" + ri.getName() - + "] not added as it overlaps with existing research [" + rr.getName() + "]", - new Object[0]); - return; - } - } - } - - rl.research.put(ri.key, ri); - if (ri.displayColumn < rl.minDisplayColumn) { - rl.minDisplayColumn = ri.displayColumn; - } - - if (ri.displayRow < rl.minDisplayRow) { - rl.minDisplayRow = ri.displayRow; - } - - if (ri.displayColumn > rl.maxDisplayColumn) { - rl.maxDisplayColumn = ri.displayColumn; - } - - if (ri.displayRow > rl.maxDisplayRow) { - rl.maxDisplayRow = ri.displayRow; - } - } - - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java deleted file mode 100644 index 4c9102648a..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.util.ResourceLocation; - -public class TC_ResearchCategoryList_Wrapper { - public int minDisplayColumn; - public int minDisplayRow; - public int maxDisplayColumn; - public int maxDisplayRow; - public ResourceLocation icon; - public ResourceLocation background; - public Map research = new HashMap(); - - public TC_ResearchCategoryList_Wrapper(ResourceLocation icon, ResourceLocation background) { - this.icon = icon; - this.background = background; - } -} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java deleted file mode 100644 index 399ec5ad09..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java +++ /dev/null @@ -1,244 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -public class TC_ResearchItem_Wrapper { - - public final String key; - public final String category; - public final TC_AspectList_Wrapper tags; - public String[] parents = null; - public String[] parentsHidden = null; - public String[] siblings = null; - public final int displayColumn; - public final int displayRow; - public final ItemStack icon_item; - public final ResourceLocation icon_resource; - private int complexity; - private boolean isSpecial; - private boolean isSecondary; - private boolean isRound; - private boolean isStub; - private boolean isVirtual; - private boolean isConcealed; - private boolean isHidden; - private boolean isLost; - private boolean isAutoUnlock; - private ItemStack[] itemTriggers; - private String[] entityTriggers; - private TC_Aspect_Wrapper[] aspectTriggers; - private Object[] pages = null; - - public TC_ResearchItem_Wrapper(String key, String category) { - this.key = key; - this.category = category; - this.tags = new TC_AspectList_Wrapper(); - this.icon_resource = null; - this.icon_item = null; - this.displayColumn = 0; - this.displayRow = 0; - this.setVirtual(); - } - - public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, - ResourceLocation icon) { - this.key = key; - this.category = category; - this.tags = tags; - this.icon_resource = icon; - this.icon_item = null; - this.displayColumn = col; - this.displayRow = row; - this.complexity = complex; - if (this.complexity < 1) { - this.complexity = 1; - } - - if (this.complexity > 3) { - this.complexity = 3; - } - - } - - public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, ItemStack icon) { - this.key = key; - this.category = category; - this.tags = tags; - this.icon_item = icon; - this.icon_resource = null; - this.displayColumn = col; - this.displayRow = row; - this.complexity = complex; - if (this.complexity < 1) { - this.complexity = 1; - } - - if (this.complexity > 3) { - this.complexity = 3; - } - - } - - public TC_ResearchItem_Wrapper setSpecial() { - this.isSpecial = true; - return this; - } - - public TC_ResearchItem_Wrapper setStub() { - this.isStub = true; - return this; - } - - public TC_ResearchItem_Wrapper setLost() { - this.isLost = true; - return this; - } - - public TC_ResearchItem_Wrapper setConcealed() { - this.isConcealed = true; - return this; - } - - public TC_ResearchItem_Wrapper setHidden() { - this.isHidden = true; - return this; - } - - public TC_ResearchItem_Wrapper setVirtual() { - this.isVirtual = true; - return this; - } - - public TC_ResearchItem_Wrapper setParents(String... par) { - this.parents = par; - return this; - } - - public TC_ResearchItem_Wrapper setParentsHidden(String... par) { - this.parentsHidden = par; - return this; - } - - public TC_ResearchItem_Wrapper setSiblings(String... sib) { - this.siblings = sib; - return this; - } - - public TC_ResearchItem_Wrapper setPages(Object... par) { - this.pages = par; - return this; - } - - public Object[] getPages() { - return this.pages; - } - - public TC_ResearchItem_Wrapper setItemTriggers(ItemStack... par) { - this.itemTriggers = par; - return this; - } - - public TC_ResearchItem_Wrapper setEntityTriggers(String... par) { - this.entityTriggers = par; - return this; - } - - public TC_ResearchItem_Wrapper setAspectTriggers(TC_Aspect_Wrapper... par) { - this.aspectTriggers = par; - return this; - } - - public ItemStack[] getItemTriggers() { - return this.itemTriggers; - } - - public String[] getEntityTriggers() { - return this.entityTriggers; - } - - public TC_Aspect_Wrapper[] getAspectTriggers() { - return this.aspectTriggers; - } - - public TC_ResearchItem_Wrapper registerResearchItem() { - ThaumcraftUtils.addResearch(this); - return this; - } - - public String getName() { - return StatCollector.translateToLocal("tc.research_name." + this.key); - } - - public String getText() { - return StatCollector.translateToLocal("tc.research_text." + this.key); - } - - public boolean isSpecial() { - return this.isSpecial; - } - - public boolean isStub() { - return this.isStub; - } - - public boolean isLost() { - return this.isLost; - } - - public boolean isConcealed() { - return this.isConcealed; - } - - public boolean isHidden() { - return this.isHidden; - } - - public boolean isVirtual() { - return this.isVirtual; - } - - public boolean isAutoUnlock() { - return this.isAutoUnlock; - } - - public TC_ResearchItem_Wrapper setAutoUnlock() { - this.isAutoUnlock = true; - return this; - } - - public boolean isRound() { - return this.isRound; - } - - public TC_ResearchItem_Wrapper setRound() { - this.isRound = true; - return this; - } - - public boolean isSecondary() { - return this.isSecondary; - } - - public TC_ResearchItem_Wrapper setSecondary() { - this.isSecondary = true; - return this; - } - - public int getComplexity() { - return this.complexity; - } - - public TC_ResearchItem_Wrapper setComplexity(int complexity) { - this.complexity = complexity; - return this; - } - - public TC_Aspect_Wrapper getResearchPrimaryTag() { - //TODO - return null; - } - -} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java deleted file mode 100644 index dbec20cdb8..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -public class TC_ResearchNoteData_Wrapper { - - public TC_ResearchNoteData_Wrapper(Object researchNoteData) { - // TODO Auto-generated constructor stub - } - - public Object getResearchNoteData() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java deleted file mode 100644 index 23d3a9f575..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java +++ /dev/null @@ -1,227 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import java.util.List; - -import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_CrucibleRecipe_Wrapper; -import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_IArcaneRecipe_Wrapper; -import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionEnchantmentRecipe_Wrapper; -import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionRecipe_Wrapper; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FurnaceRecipes; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -public class TC_ResearchPage_Wrapper { - public TC_PageType_Wrapper type; - public String text; - public String research; - public ResourceLocation image; - public TC_AspectList_Wrapper aspects; - public Object recipe; - public ItemStack recipeOutput; - - public TC_ResearchPage_Wrapper(String text) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.TEXT; - this.text = text; - } - - public TC_ResearchPage_Wrapper(String research, String text) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.TEXT_CONCEALED; - this.research = research; - this.text = text; - } - - public TC_ResearchPage_Wrapper(IRecipe recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; - this.recipe = recipe; - this.recipeOutput = recipe.getRecipeOutput(); - } - - public TC_ResearchPage_Wrapper(IRecipe[] recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; - this.recipe = recipe; - } - - public TC_ResearchPage_Wrapper(TC_IArcaneRecipe_Wrapper[] recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; - this.recipe = recipe; - } - - public TC_ResearchPage_Wrapper(TC_CrucibleRecipe_Wrapper[] recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; - this.recipe = recipe; - } - - public TC_ResearchPage_Wrapper(TC_InfusionRecipe_Wrapper[] recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; - this.recipe = recipe; - } - - public TC_ResearchPage_Wrapper(List recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.COMPOUND_CRAFTING; - this.recipe = recipe; - } - - public TC_ResearchPage_Wrapper(TC_IArcaneRecipe_Wrapper recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; - this.recipe = recipe; - this.recipeOutput = recipe.getRecipeOutput(); - } - - public TC_ResearchPage_Wrapper(TC_CrucibleRecipe_Wrapper recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; - this.recipe = recipe; - this.recipeOutput = recipe.getRecipeOutput(); - } - - public TC_ResearchPage_Wrapper(ItemStack input) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.SMELTING; - this.recipe = input; - this.recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); - } - - public TC_ResearchPage_Wrapper(TC_InfusionRecipe_Wrapper recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; - this.recipe = recipe; - if (recipe.getRecipeOutput() instanceof ItemStack) { - this.recipeOutput = (ItemStack) recipe.getRecipeOutput(); - } else { - this.recipeOutput = recipe.getRecipeInput(); - } - - } - - public TC_ResearchPage_Wrapper(TC_InfusionEnchantmentRecipe_Wrapper recipe) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.INFUSION_ENCHANTMENT; - this.recipe = recipe; - } - - public TC_ResearchPage_Wrapper(ResourceLocation image, String caption) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.IMAGE; - this.image = image; - this.text = caption; - } - - public TC_ResearchPage_Wrapper(TC_AspectList_Wrapper as) { - this.type = TC_PageType_Wrapper.TEXT; - this.text = null; - this.research = null; - this.image = null; - this.aspects = null; - this.recipe = null; - this.recipeOutput = null; - this.type = TC_PageType_Wrapper.ASPECTS; - this.aspects = as; - } - - public String getTranslatedText() { - String ret = ""; - if (this.text != null) { - ret = StatCollector.translateToLocal(this.text); - if (ret.isEmpty()) { - ret = this.text; - } - } - - return ret; - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_AspectList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_AspectList_Wrapper.java new file mode 100644 index 0000000000..9df38ca384 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_AspectList_Wrapper.java @@ -0,0 +1,40 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect; + +import net.minecraft.item.ItemStack; + +public class TC_AspectList_Wrapper { + + + //thaumcraft.api.aspects.Aspect; + //thaumcraft.api.aspects.AspectList; + + public TC_AspectList_Wrapper() { + + } + + public TC_AspectList_Wrapper(ItemStack stack) { + + } + + public TC_AspectList_Wrapper(Object invoke) { + // TODO Auto-generated constructor stub + } + + public int size() { + // TODO Auto-generated method stub + return 0; + } + + public Object getVanillaAspectList() { + // TODO Auto-generated method stub + return null; + } + + public void add(TC_Aspect_Wrapper mAspect, int mAmount) { + // TODO Auto-generated method stub + + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java new file mode 100644 index 0000000000..ba448442d2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java @@ -0,0 +1,314 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect; + +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.LinkedHashMap; +import java.util.Map; + +import gregtech.api.enums.TC_Aspects; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.util.ResourceLocation; + +/** + * Wrapper class for Thaumcraft Aspects. + * Used to avoid compile time dependencies. + * @author Alkalus + * + */ +public class TC_Aspect_Wrapper { + + private static Class mClass_Aspect; + private static Field mField_Aspects; + + private final String tag; + private final TC_Aspect_Wrapper[] components; + private final int color; + private String chatcolor; + private final ResourceLocation image; + private final int blend; + + public final Object mAspect; + + /** + * May be null, but links back to the TC_Aspects class from GT for convinience. + */ + public final TC_Aspects mGtEnumField; + + + + + /** + * Statically set the Class objects + */ + static { + mClass_Aspect = ReflectionUtils.getClass("thaumcraft.api.aspects.Aspect"); + } + + /** + * Gets the total aspect list from Thaumcraft, which should contain all other registered aspects. + * @return - A LinkedHashMap(String, Aspect); + */ + public static LinkedHashMap getVanillaAspectList() { + try { + if (mField_Aspects == null) { + mField_Aspects = ReflectionUtils.getField(mClass_Aspect, "aspects"); + } + return (LinkedHashMap) mField_Aspects.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + Logger.REFLECTION("Failed configuring TC Aspect compatibility."); + return new LinkedHashMap(); + } + } + + public static Object getVanillaAspectObject(String aAspectName) { + return getVanillaAspectList().get(aAspectName); + } + + + + + + + + + + + + + + + /** + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param chatcolor + * @param blend + */ + public TC_Aspect_Wrapper(String tag, int color, String chatcolor, int blend) { + this(tag, color, (TC_Aspect_Wrapper[]) null, blend); + this.chatcolor = chatcolor; + } + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + */ + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components) { + this(tag, color, components, false, 1); + } + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + * @param blend + */ + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, int blend) { + this(tag, color, components, false, blend); + } + + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + * @param image + * @param blend + */ + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, boolean vanilla, int blend) { + this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend); + } + + + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, ResourceLocation image, boolean vanilla, int blend) { + if (getAspectList().containsKey(tag.toLowerCase())) { + this.tag = tag.toLowerCase(); + this.components = components; + this.color = color; + this.image = image; + this.blend = blend; + this.mAspect = null; + this.mGtEnumField = null; + } else { + this.tag = tag.toLowerCase(); + this.components = components; + this.color = color; + this.image = image; + this.blend = blend; + this.mAspect = vanilla ? getVanillaAspectObject(this.tag) : this.generateTcAspect(); + + //Set GT Type if exists + TC_Aspects y = null; + for (TC_Aspects e : TC_Aspects.values()) { + TC_Aspect_Wrapper g; + try { + String gtTag = ThaumcraftUtils.getTagFromAspectObject(e.mAspect); + if (gtTag != null) { + if (gtTag.equals(this.tag)) { + y = e; + break; + } + } + } catch (IllegalArgumentException e1) { + e1.printStackTrace(); + } + } + this.mGtEnumField = y; + mInternalAspectCache.put(this.tag, this); + Logger.INFO("[Thaumcraft++] Adding support for Aspect: "+tag); + } + } + + + + /** + * Generates a TC_Aspect from an object, presummed to be a TC Aspect. + * @param aBaseAspect - The TC Aspect to generate from. + * @return + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + @SuppressWarnings("unused") + public static TC_Aspect_Wrapper generate(Object aBaseAspect) { + try { + Field aTagF = ReflectionUtils.getField(mClass_Aspect, "tag"); + if (aTagF == null) { + return null; + } + String aTafB = (String) aTagF.get(aBaseAspect); + if (aTafB == null) { + return null; + } + String aTag = aTafB.toLowerCase(); + if (aTag != null && getAspectList().containsKey(aTag.toLowerCase())) { + return getAspect(aTag); + } else { + TC_Aspect_Wrapper aTemp = new TC_Aspect_Wrapper( + aTag, + (int) ReflectionUtils.getField(mClass_Aspect, "color").get(aBaseAspect), + generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), (aBaseAspect)), + (ResourceLocation) ReflectionUtils.getField(mClass_Aspect, "image").get(aBaseAspect), + true, + (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect) + ); + if (aTemp != null) { + aTemp.chatcolor = (String) ReflectionUtils.getField(mClass_Aspect, "chatcolor").get(aBaseAspect); + return aTemp; + } + else { + return null; + } + } + } + catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + + /** + * Internal Map containing all the TC_Aspects. + */ + private static Map mInternalAspectCache = new LinkedHashMap(); + + /** + * Public getter for all TC_Aspects + * @param aAspectName - Aspect Name + * @return - A GT++ Aspect wrapper or null. (TC_Aspect) + */ + public static TC_Aspect_Wrapper getAspect(String aAspectName) { + String aName = aAspectName.toLowerCase(); + TC_Aspect_Wrapper g = mInternalAspectCache.get(aName); + if (g != null) { + return g; + } + else { + try { + TC_Aspect_Wrapper aTemp = generate(getVanillaAspectList().get(aName)); + if (aTemp != null) { + mInternalAspectCache.put(aName, aTemp); + return aTemp; + } + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + } + return null; + } + + public static Map getAspectList(){ + return mInternalAspectCache; + } + + + private static TC_Aspect_Wrapper[] generateAspectArrayInternal(Field aField, Object aInstance) { + //thaumcraft.api.aspects.Aspect.Aspect() + Object[] components; + TC_Aspect_Wrapper[] aAspectArray; + try { + components = (Object[]) aField.get(aInstance); + aAspectArray = new TC_Aspect_Wrapper[components == null ? 0 : components.length]; + if (aAspectArray.length > 0) { + int i = 0; + for (Object g : components) { + aAspectArray[i] = getAspect((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(g)); + i++; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + aAspectArray = new TC_Aspect_Wrapper[0]; + } + return aAspectArray; + } + + /** + * Tasty code to generate TC Aspects reflectively. + * @return + */ + public Object generateTcAspect() { + try { + //thaumcraft.api.aspects.Aspect.Aspect() + Object aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, 1); + if (components.length > 0) { + aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, components.length); + int i = 0; + for (TC_Aspect_Wrapper g : components) { + ((Object[]) aAspectArray)[i++] = g.mAspect; + } + } + Constructor constructor = mClass_Aspect.getConstructor(String.class, int.class, aAspectArray.getClass(), ResourceLocation.class, int.class); + Object myObject = constructor.newInstance(tag, color, aAspectArray, image, blend); + + //Set chat colour + if (chatcolor != null && chatcolor.length() > 0) { + Method setChatColour = ReflectionUtils.getMethod(mClass_Aspect, "setChatcolor", String.class); + if (setChatColour != null) { + setChatColour.invoke(myObject, chatcolor); + } + } + return myObject; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + public static boolean isObjectAnAspect(Object aAspect) { + return mClass_Aspect.isInstance(aAspect); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_PageType_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_PageType_Wrapper.java new file mode 100644 index 0000000000..d6c7f66988 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_PageType_Wrapper.java @@ -0,0 +1,17 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +public class TC_PageType_Wrapper { + + public static final TC_PageType_Wrapper TEXT = null; + public static final TC_PageType_Wrapper TEXT_CONCEALED = null; + public static final TC_PageType_Wrapper NORMAL_CRAFTING = null; + public static final TC_PageType_Wrapper ARCANE_CRAFTING = null; + public static final TC_PageType_Wrapper CRUCIBLE_CRAFTING = null; + public static final TC_PageType_Wrapper INFUSION_CRAFTING = null; + public static final TC_PageType_Wrapper COMPOUND_CRAFTING = null; + public static final TC_PageType_Wrapper SMELTING = null; + public static final TC_PageType_Wrapper INFUSION_ENCHANTMENT = null; + public static final TC_PageType_Wrapper IMAGE = null; + public static final TC_PageType_Wrapper ASPECTS = null; + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategories_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategories_Wrapper.java new file mode 100644 index 0000000000..93869cb8d8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategories_Wrapper.java @@ -0,0 +1,89 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +import cpw.mods.fml.common.FMLLog; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashMap; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.apache.logging.log4j.Level; + +public class TC_ResearchCategories_Wrapper { + + public static LinkedHashMap researchCategories = new LinkedHashMap(); + + public static TC_ResearchCategoryList_Wrapper getResearchList(String key) { + return (TC_ResearchCategoryList_Wrapper) researchCategories.get(key); + } + + public static String getCategoryName(String key) { + return StatCollector.translateToLocal("tc.research_category." + key); + } + + public static TC_ResearchItem_Wrapper getResearch(String key) { + Collection rc = researchCategories.values(); + Iterator i$ = rc.iterator(); + + while (i$.hasNext()) { + Object cat = i$.next(); + Collection rl = ((TC_ResearchCategoryList_Wrapper) cat).research.values(); + Iterator i$1 = rl.iterator(); + + while (i$1.hasNext()) { + Object ri = i$1.next(); + if (((TC_ResearchItem_Wrapper) ri).key.equals(key)) { + return (TC_ResearchItem_Wrapper) ri; + } + } + } + + return null; + } + + public static void registerCategory(String key, ResourceLocation icon, ResourceLocation background) { + if (getResearchList(key) == null) { + TC_ResearchCategoryList_Wrapper rl = new TC_ResearchCategoryList_Wrapper(icon, background); + researchCategories.put(key, rl); + } + + } + + public static void addResearch(TC_ResearchItem_Wrapper ri) { + TC_ResearchCategoryList_Wrapper rl = getResearchList(ri.category); + if (rl != null && !rl.research.containsKey(ri.key)) { + if (!ri.isVirtual()) { + Iterator i$ = rl.research.values().iterator(); + + while (i$.hasNext()) { + TC_ResearchItem_Wrapper rr = (TC_ResearchItem_Wrapper) i$.next(); + if (rr.displayColumn == ri.displayColumn && rr.displayRow == ri.displayRow) { + FMLLog.log(Level.FATAL, + "[Thaumcraft] Research [" + ri.getName() + + "] not added as it overlaps with existing research [" + rr.getName() + "]", + new Object[0]); + return; + } + } + } + + rl.research.put(ri.key, ri); + if (ri.displayColumn < rl.minDisplayColumn) { + rl.minDisplayColumn = ri.displayColumn; + } + + if (ri.displayRow < rl.minDisplayRow) { + rl.minDisplayRow = ri.displayRow; + } + + if (ri.displayColumn > rl.maxDisplayColumn) { + rl.maxDisplayColumn = ri.displayColumn; + } + + if (ri.displayRow > rl.maxDisplayRow) { + rl.maxDisplayRow = ri.displayRow; + } + } + + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategoryList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategoryList_Wrapper.java new file mode 100644 index 0000000000..3e6f5b78f2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategoryList_Wrapper.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; + +public class TC_ResearchCategoryList_Wrapper { + public int minDisplayColumn; + public int minDisplayRow; + public int maxDisplayColumn; + public int maxDisplayRow; + public ResourceLocation icon; + public ResourceLocation background; + public Map research = new HashMap(); + + public TC_ResearchCategoryList_Wrapper(ResourceLocation icon, ResourceLocation background) { + this.icon = icon; + this.background = background; + } +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchItem_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchItem_Wrapper.java new file mode 100644 index 0000000000..6372cc0371 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchItem_Wrapper.java @@ -0,0 +1,246 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; +import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class TC_ResearchItem_Wrapper { + + public final String key; + public final String category; + public final TC_AspectList_Wrapper tags; + public String[] parents = null; + public String[] parentsHidden = null; + public String[] siblings = null; + public final int displayColumn; + public final int displayRow; + public final ItemStack icon_item; + public final ResourceLocation icon_resource; + private int complexity; + private boolean isSpecial; + private boolean isSecondary; + private boolean isRound; + private boolean isStub; + private boolean isVirtual; + private boolean isConcealed; + private boolean isHidden; + private boolean isLost; + private boolean isAutoUnlock; + private ItemStack[] itemTriggers; + private String[] entityTriggers; + private TC_Aspect_Wrapper[] aspectTriggers; + private Object[] pages = null; + + public TC_ResearchItem_Wrapper(String key, String category) { + this.key = key; + this.category = category; + this.tags = new TC_AspectList_Wrapper(); + this.icon_resource = null; + this.icon_item = null; + this.displayColumn = 0; + this.displayRow = 0; + this.setVirtual(); + } + + public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, + ResourceLocation icon) { + this.key = key; + this.category = category; + this.tags = tags; + this.icon_resource = icon; + this.icon_item = null; + this.displayColumn = col; + this.displayRow = row; + this.complexity = complex; + if (this.complexity < 1) { + this.complexity = 1; + } + + if (this.complexity > 3) { + this.complexity = 3; + } + + } + + public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, ItemStack icon) { + this.key = key; + this.category = category; + this.tags = tags; + this.icon_item = icon; + this.icon_resource = null; + this.displayColumn = col; + this.displayRow = row; + this.complexity = complex; + if (this.complexity < 1) { + this.complexity = 1; + } + + if (this.complexity > 3) { + this.complexity = 3; + } + + } + + public TC_ResearchItem_Wrapper setSpecial() { + this.isSpecial = true; + return this; + } + + public TC_ResearchItem_Wrapper setStub() { + this.isStub = true; + return this; + } + + public TC_ResearchItem_Wrapper setLost() { + this.isLost = true; + return this; + } + + public TC_ResearchItem_Wrapper setConcealed() { + this.isConcealed = true; + return this; + } + + public TC_ResearchItem_Wrapper setHidden() { + this.isHidden = true; + return this; + } + + public TC_ResearchItem_Wrapper setVirtual() { + this.isVirtual = true; + return this; + } + + public TC_ResearchItem_Wrapper setParents(String... par) { + this.parents = par; + return this; + } + + public TC_ResearchItem_Wrapper setParentsHidden(String... par) { + this.parentsHidden = par; + return this; + } + + public TC_ResearchItem_Wrapper setSiblings(String... sib) { + this.siblings = sib; + return this; + } + + public TC_ResearchItem_Wrapper setPages(Object... par) { + this.pages = par; + return this; + } + + public Object[] getPages() { + return this.pages; + } + + public TC_ResearchItem_Wrapper setItemTriggers(ItemStack... par) { + this.itemTriggers = par; + return this; + } + + public TC_ResearchItem_Wrapper setEntityTriggers(String... par) { + this.entityTriggers = par; + return this; + } + + public TC_ResearchItem_Wrapper setAspectTriggers(TC_Aspect_Wrapper... par) { + this.aspectTriggers = par; + return this; + } + + public ItemStack[] getItemTriggers() { + return this.itemTriggers; + } + + public String[] getEntityTriggers() { + return this.entityTriggers; + } + + public TC_Aspect_Wrapper[] getAspectTriggers() { + return this.aspectTriggers; + } + + public TC_ResearchItem_Wrapper registerResearchItem() { + ThaumcraftUtils.addResearch(this); + return this; + } + + public String getName() { + return StatCollector.translateToLocal("tc.research_name." + this.key); + } + + public String getText() { + return StatCollector.translateToLocal("tc.research_text." + this.key); + } + + public boolean isSpecial() { + return this.isSpecial; + } + + public boolean isStub() { + return this.isStub; + } + + public boolean isLost() { + return this.isLost; + } + + public boolean isConcealed() { + return this.isConcealed; + } + + public boolean isHidden() { + return this.isHidden; + } + + public boolean isVirtual() { + return this.isVirtual; + } + + public boolean isAutoUnlock() { + return this.isAutoUnlock; + } + + public TC_ResearchItem_Wrapper setAutoUnlock() { + this.isAutoUnlock = true; + return this; + } + + public boolean isRound() { + return this.isRound; + } + + public TC_ResearchItem_Wrapper setRound() { + this.isRound = true; + return this; + } + + public boolean isSecondary() { + return this.isSecondary; + } + + public TC_ResearchItem_Wrapper setSecondary() { + this.isSecondary = true; + return this; + } + + public int getComplexity() { + return this.complexity; + } + + public TC_ResearchItem_Wrapper setComplexity(int complexity) { + this.complexity = complexity; + return this; + } + + public TC_Aspect_Wrapper getResearchPrimaryTag() { + //TODO + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchNoteData_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchNoteData_Wrapper.java new file mode 100644 index 0000000000..5adf0150d9 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchNoteData_Wrapper.java @@ -0,0 +1,14 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +public class TC_ResearchNoteData_Wrapper { + + public TC_ResearchNoteData_Wrapper(Object researchNoteData) { + // TODO Auto-generated constructor stub + } + + public Object getResearchNoteData() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchPage_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchPage_Wrapper.java new file mode 100644 index 0000000000..998f37bf8c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchPage_Wrapper.java @@ -0,0 +1,228 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +import java.util.List; + +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_CrucibleRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_IArcaneRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionEnchantmentRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionRecipe_Wrapper; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class TC_ResearchPage_Wrapper { + public TC_PageType_Wrapper type; + public String text; + public String research; + public ResourceLocation image; + public TC_AspectList_Wrapper aspects; + public Object recipe; + public ItemStack recipeOutput; + + public TC_ResearchPage_Wrapper(String text) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.TEXT; + this.text = text; + } + + public TC_ResearchPage_Wrapper(String research, String text) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.TEXT_CONCEALED; + this.research = research; + this.text = text; + } + + public TC_ResearchPage_Wrapper(IRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(IRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(TC_IArcaneRecipe_Wrapper[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(TC_CrucibleRecipe_Wrapper[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(TC_InfusionRecipe_Wrapper[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(List recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.COMPOUND_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(TC_IArcaneRecipe_Wrapper recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(TC_CrucibleRecipe_Wrapper recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(ItemStack input) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.SMELTING; + this.recipe = input; + this.recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); + } + + public TC_ResearchPage_Wrapper(TC_InfusionRecipe_Wrapper recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; + this.recipe = recipe; + if (recipe.getRecipeOutput() instanceof ItemStack) { + this.recipeOutput = (ItemStack) recipe.getRecipeOutput(); + } else { + this.recipeOutput = recipe.getRecipeInput(); + } + + } + + public TC_ResearchPage_Wrapper(TC_InfusionEnchantmentRecipe_Wrapper recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_ENCHANTMENT; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(ResourceLocation image, String caption) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.IMAGE; + this.image = image; + this.text = caption; + } + + public TC_ResearchPage_Wrapper(TC_AspectList_Wrapper as) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ASPECTS; + this.aspects = as; + } + + public String getTranslatedText() { + String ret = ""; + if (this.text != null) { + ret = StatCollector.translateToLocal(this.text); + if (ret.isEmpty()) { + ret = this.text; + } + } + + return ret; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java index c60a140819..8beaa8df5e 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java @@ -19,17 +19,17 @@ import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft; import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectStack; -import gtPlusPlus.xmod.thaumcraft.aspect.TC_AspectList_Wrapper; -import gtPlusPlus.xmod.thaumcraft.aspect.TC_Aspect_Wrapper; -import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchCategories_Wrapper; -import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchCategoryList_Wrapper; -import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchItem_Wrapper; -import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchNoteData_Wrapper; -import gtPlusPlus.xmod.thaumcraft.aspect.TC_ResearchPage_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_CrucibleRecipe_Wrapper; import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_IArcaneRecipe_Wrapper; import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionEnchantmentRecipe_Wrapper; import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchCategories_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchCategoryList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchItem_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchNoteData_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchPage_Wrapper; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; diff --git a/src/resources/assets/miscutils/textures/aspects/Sagrausten.png b/src/resources/assets/miscutils/textures/aspects/Sagrausten.png new file mode 100644 index 0000000000..a2c461f94e Binary files /dev/null and b/src/resources/assets/miscutils/textures/aspects/Sagrausten.png differ diff --git a/src/resources/assets/miscutils/textures/aspects/Slusium.png b/src/resources/assets/miscutils/textures/aspects/Slusium.png new file mode 100644 index 0000000000..fd2c42414d Binary files /dev/null and b/src/resources/assets/miscutils/textures/aspects/Slusium.png differ diff --git a/src/resources/assets/miscutils/textures/aspects/Xablum.png b/src/resources/assets/miscutils/textures/aspects/Xablum.png new file mode 100644 index 0000000000..a19d64039a Binary files /dev/null and b/src/resources/assets/miscutils/textures/aspects/Xablum.png differ diff --git a/src/resources/assets/miscutils/textures/aspects/Xenil.png b/src/resources/assets/miscutils/textures/aspects/Xenil.png new file mode 100644 index 0000000000..e3b5ecda82 Binary files /dev/null and b/src/resources/assets/miscutils/textures/aspects/Xenil.png differ diff --git a/src/resources/assets/miscutils/textures/aspects/Zetralt.png b/src/resources/assets/miscutils/textures/aspects/Zetralt.png new file mode 100644 index 0000000000..001edf8ea3 Binary files /dev/null and b/src/resources/assets/miscutils/textures/aspects/Zetralt.png differ -- cgit From b78556a3e82ff893dcb4fbf3dc03e84aab208f01 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 4 Mar 2019 22:03:24 +0000 Subject: + Added some ASM to fix Aspect safety in TC. $ Minor fixes to the 5 custom TC4 Aspects. --- src/Java/gtPlusPlus/preloader/asm/AsmConfig.java | 10 ++ .../ClassTransformer_TC_ItemWispEssence.java | 187 +++++++++++++++++++++ .../Preloader_Transformer_Handler.java | 9 + .../xmod/thaumcraft/aspect/GTPP_AspectCompat.java | 45 ++--- .../objects/wrapper/aspect/TC_Aspect_Wrapper.java | 24 ++- 5 files changed, 235 insertions(+), 40 deletions(-) create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java index 01efcfb412..c29d8423d8 100644 --- a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java +++ b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java @@ -19,6 +19,7 @@ public class AsmConfig { public static boolean enableCofhPatch; public static boolean enableGcFuelChanges; public static boolean enableRcFlowFix; + public static boolean enableTcAspectSafety; public AsmConfig(File file) { if (!loaded) { @@ -91,6 +92,13 @@ public class AsmConfig { propOrder.add(prop.getName()); + //TC Aspect Safety + prop = config.get("general", "enableTcAspectSafety", true); + prop.comment = "Fixes small oversights in Thaumcraft 4."; + prop.setLanguageKey("gtpp.enableTcAspectSafety").setRequiresMcRestart(true); + enableTcAspectSafety = prop.getBoolean(true); + propOrder.add(prop.getName()); + config.setCategoryPropertyOrder("general", propOrder); config.setCategoryPropertyOrder("debug", propOrderDebug); @@ -104,6 +112,8 @@ public class AsmConfig { FMLLog.log(Level.INFO, "[GT++ ASM] Gt Tooltip Fix - Enabled: "+enableGtTooltipFix, new Object[0]); FMLLog.log(Level.INFO, "[GT++ ASM] COFH Patch - Enabled: "+enableCofhPatch, new Object[0]); FMLLog.log(Level.INFO, "[GT++ ASM] Gc Fuel Changes Patch - Enabled: "+enableGcFuelChanges, new Object[0]); + FMLLog.log(Level.INFO, "[GT++ ASM] Railcraft Fluid Flow Patch - Enabled: "+enableRcFlowFix, new Object[0]); + FMLLog.log(Level.INFO, "[GT++ ASM] Thaumcraft Aspect Safety Patch - Enabled: "+enableTcAspectSafety, new Object[0]); } catch (Exception var3) { FMLLog.log(Level.ERROR, var3, "GT++ ASM had a problem loading it's config", new Object[0]); diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java new file mode 100644 index 0000000000..6241cc81d4 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java @@ -0,0 +1,187 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class ClassTransformer_TC_ItemWispEssence { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + public ClassTransformer_TC_ItemWispEssence(byte[] basicClass, boolean obfuscated2) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + boolean obfuscated = false; + boolean a1 = false; + boolean a2 = false; + + if (a1) { + obfuscated = false; + } + else if (a2) { + obfuscated = true; + } + else { + //Fallback + obfuscated = false; + } + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Are we patching obfuscated methods? "+obfuscated); + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + aTempReader.accept(new AddAdapter(aTempWriter), 0); + + injectMethod("getAspects", aTempWriter, obfuscated); + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Valid? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(String aMethodName, ClassWriter cw, boolean obfuscated) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Injecting " + aMethodName + "."); + + + if (aMethodName.equals("getAspects")) { + mv = cw.visitMethod(ACC_PUBLIC, "getAspects", "(Lnet/minecraft/item/ItemStack;)Lthaumcraft/api/aspects/AspectList;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(141, l0); + mv.visitVarInsn(ALOAD, 1); + Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(142, l2); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l1); + mv.visitLineNumber(144, l1); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "hasTagCompound", "()Z", false); + Label l3 = new Label(); + mv.visitJumpInsn(IFEQ, l3); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(145, l4); + mv.visitTypeInsn(NEW, "thaumcraft/api/aspects/AspectList"); + mv.visitInsn(DUP); + mv.visitMethodInsn(INVOKESPECIAL, "thaumcraft/api/aspects/AspectList", "", "()V", false); + mv.visitVarInsn(ASTORE, 2); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(146, l5); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getTagCompound", "()Lnet/minecraft/nbt/NBTTagCompound;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "readFromNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V", false); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(147, l6); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "size", "()I", false); + Label l7 = new Label(); + mv.visitJumpInsn(IFLE, l7); + mv.visitVarInsn(ALOAD, 2); + Label l8 = new Label(); + mv.visitJumpInsn(GOTO, l8); + mv.visitLabel(l7); + mv.visitFrame(F_APPEND,1, new Object[] {"thaumcraft/api/aspects/AspectList"}, 0, null); + mv.visitInsn(ACONST_NULL); + mv.visitLabel(l8); + mv.visitFrame(F_SAME1, 0, null, 1, new Object[] {"thaumcraft/api/aspects/AspectList"}); + mv.visitInsn(ARETURN); + mv.visitLabel(l3); + mv.visitLineNumber(149, l3); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLocalVariable("this", "LgtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence;", null, l0, l9, 0); + mv.visitLocalVariable("itemstack", "Lnet/minecraft/item/ItemStack;", null, l0, l9, 1); + mv.visitLocalVariable("aspects", "Lthaumcraft/api/aspects/AspectList;", null, l5, l3, 2); + mv.visitMaxs(2, 3); + mv.visitEnd(); + didInject = true; + } + + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Method injection complete. "+(obfuscated ? "Obfuscated" : "Non-Obfuscated")); + return didInject; + } + + public class AddAdapter extends ClassVisitor { + + public AddAdapter(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + private final String[] aMethodsToStrip = new String[] {"getAspects"}; + + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + + MethodVisitor methodVisitor; + boolean found = false; + + for (String s : aMethodsToStrip) { + if (name.equals(s)) { + found = true; + break; + } + } + if (!found) { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + else { + methodVisitor = null; + } + + if (found) { + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, + "Found method " + name + ", removing."); + } + return methodVisitor; + } + + } + + + + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index 0cb25d259b..38fd1e0508 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -197,6 +197,15 @@ public class Preloader_Transformer_Handler implements IClassTransformer { return new ClassTransformer_IC2_GetHarvestTool(basicClass, probablyShouldBeFalse, transformedName).getWriter().toByteArray(); } } + + //Fix Thaumcraft Shit + //Patching ItemWispEssence to allow invalid item handling + if (transformedName.equals("thaumcraft.common.items.ItemWispEssence") && mConfig.enableTcAspectSafety) { + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_TC_ItemWispEssence(basicClass, obfuscated).getWriter().toByteArray(); + } + + return basicClass; } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java index d5a19a91fc..5ac85e38cd 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java @@ -7,9 +7,9 @@ import java.util.LinkedHashMap; import java.util.List; import gregtech.api.enums.TC_Aspects; -import gregtech.api.util.GT_LanguageManager; import gregtech.common.GT_ThaumcraftCompat; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_AspectList_Wrapper; import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; @@ -105,10 +105,10 @@ public class GTPP_AspectCompat { "Sagrausten", Utils.rgbtoHexValue(125, 125, 125), new TC_Aspect_Wrapper[]{ - get(TC_Aspects.GELUM), - get(TC_Aspects.IGNIS) + ASPECT_STARBOUND, + get(TC_Aspects.RADIO) }, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Sagrausten.png"), false, 1); @@ -117,10 +117,10 @@ public class GTPP_AspectCompat { "Slusium", Utils.rgbtoHexValue(175, 125, 25), new TC_Aspect_Wrapper[]{ - get(TC_Aspects.CORPUS), - get(TC_Aspects.ORDO) + ASPECT_BALANCE, + get(TC_Aspects.NEBRISUM) }, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.NEBRISUM.name() + ".png"), + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Slusium.png"), false, 1); @@ -129,10 +129,8 @@ public class GTPP_AspectCompat { "Xenil", Utils.rgbtoHexValue(25, 25, 25), new TC_Aspect_Wrapper[]{ - get(TC_Aspects.ALIENIS), - ASPECT_BALANCE }, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.NEBRISUM.name() + ".png"), + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Xenil.png"), false, 1); @@ -141,10 +139,10 @@ public class GTPP_AspectCompat { "Xablum", Utils.rgbtoHexValue(25, 185, 25), new TC_Aspect_Wrapper[]{ - get(TC_Aspects.CORPUS), + ASPECT_STARBOUND, ASPECT_LUST }, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.NEBRISUM.name() + ".png"), + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Xablum.png"), false, 1); @@ -153,29 +151,12 @@ public class GTPP_AspectCompat { "Zetralt", Utils.rgbtoHexValue(225, 225, 225), new TC_Aspect_Wrapper[]{ - get(TC_Aspects.COGNITIO), - ASPECT_BALANCE + get(TC_Aspects.AURAM), + ASPECT_TOXIC }, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.NEBRISUM.name() + ".png"), + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Zetralt.png"), false, 1); - - - - - /*GTPP_Aspects.CUSTOM_2.mAspect = new Aspect("custom2", 15658622, new Aspect[]{Aspect.MAGIC, Aspect.SLIME}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GTPP_Aspects.CUSTOM_3.mAspect = new Aspect("custom3", 12644078, new Aspect[]{Aspect.ENERGY, Aspect.ARMOR}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GTPP_Aspects.CUSTOM_4.mAspect = new Aspect("custom4", 12632256, new Aspect[]{Aspect.METAL, Aspect.POISON}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GTPP_Aspects.CUSTOM_5.mAspect = new Aspect("custom4", 12648384, new Aspect[]{Aspect.LIGHT, Aspect.SOUL}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1);*/ - GT_LanguageManager.addStringLocalization("tc.aspect.Sagrausten", "Balance"); - GT_LanguageManager.addStringLocalization("tc.aspect.Slusium", "Lust"); - GT_LanguageManager.addStringLocalization("tc.aspect.Xenil", "Starbound"); - GT_LanguageManager.addStringLocalization("tc.aspect.Xablum", "Toxic"); - GT_LanguageManager.addStringLocalization("tc.aspect.Zetralt", "Zetralt"); } private TC_Aspect_Wrapper get(TC_Aspects aGtObjects) { diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java index ba448442d2..4759a04158 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java @@ -131,28 +131,32 @@ public class TC_Aspect_Wrapper { this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend); } + private static int aInternalAspectIDAllocation = 0; - public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, ResourceLocation image, boolean vanilla, int blend) { + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, ResourceLocation image, boolean vanilla, int blend) { + if (components == null) { + components = new TC_Aspect_Wrapper[] {}; + } + String aTag = vanilla ? tag.toLowerCase() : "custom"+(aInternalAspectIDAllocation++); if (getAspectList().containsKey(tag.toLowerCase())) { - this.tag = tag.toLowerCase(); + this.tag = aTag; this.components = components; this.color = color; this.image = image; this.blend = blend; this.mAspect = null; this.mGtEnumField = null; - } else { - this.tag = tag.toLowerCase(); + } else { + this.tag = aTag; this.components = components; this.color = color; this.image = image; this.blend = blend; this.mAspect = vanilla ? getVanillaAspectObject(this.tag) : this.generateTcAspect(); - //Set GT Type if exists + // Set GT Type if exists TC_Aspects y = null; for (TC_Aspects e : TC_Aspects.values()) { - TC_Aspect_Wrapper g; try { String gtTag = ThaumcraftUtils.getTagFromAspectObject(e.mAspect); if (gtTag != null) { @@ -166,7 +170,11 @@ public class TC_Aspect_Wrapper { } } this.mGtEnumField = y; - mInternalAspectCache.put(this.tag, this); + mInternalAspectCache.put(this.tag, this); + // Double link custom Aspects, but internalise names using custom# instead + if (!vanilla) { + mInternalAspectCache.put(tag.toLowerCase(), this); + } Logger.INFO("[Thaumcraft++] Adding support for Aspect: "+tag); } } @@ -282,7 +290,7 @@ public class TC_Aspect_Wrapper { public Object generateTcAspect() { try { //thaumcraft.api.aspects.Aspect.Aspect() - Object aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, 1); + Object aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, 0); if (components.length > 0) { aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, components.length); int i = 0; -- cgit From a3ad39894856101326b5e6a9273d33a1ccaeb921 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 4 Mar 2019 22:20:17 +0000 Subject: $ More TC fixes. --- .../ClassTransformer_TC_ItemWispEssence.java | 138 +++++++++++++++++---- .../objects/wrapper/aspect/TC_Aspect_Wrapper.java | 1 + 2 files changed, 114 insertions(+), 25 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java index 6241cc81d4..993559115c 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java @@ -3,6 +3,7 @@ package gtPlusPlus.preloader.asm.transformers; import static org.objectweb.asm.Opcodes.*; import org.apache.logging.log4j.Level; +import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; @@ -10,6 +11,12 @@ import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.preloader.DevHelper; +import net.minecraft.item.ItemStack; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; public class ClassTransformer_TC_ItemWispEssence { @@ -19,37 +26,21 @@ public class ClassTransformer_TC_ItemWispEssence { public ClassTransformer_TC_ItemWispEssence(byte[] basicClass, boolean obfuscated2) { ClassReader aTempReader = null; - ClassWriter aTempWriter = null; - - boolean obfuscated = false; - boolean a1 = false; - boolean a2 = false; - - if (a1) { - obfuscated = false; - } - else if (a2) { - obfuscated = true; - } - else { - //Fallback - obfuscated = false; - } - FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Are we patching obfuscated methods? "+obfuscated); - + ClassWriter aTempWriter = null; + boolean obfuscated = obfuscated2; + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Are we patching obfuscated methods? "+obfuscated); + String aGetColour = obfuscated ? DevHelper.getSRG("getColorFromItemStack") : DevHelper.getForge("getColorFromItemStack"); aTempReader = new ClassReader(basicClass); aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); - aTempReader.accept(new AddAdapter(aTempWriter), 0); - + aTempReader.accept(new AddAdapter(aTempWriter, new String[] {"getAspects", aGetColour}), 0); injectMethod("getAspects", aTempWriter, obfuscated); - + injectMethod(aGetColour, aTempWriter, obfuscated); if (aTempReader != null && aTempWriter != null) { isValid = true; } else { isValid = false; - } - + } FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Valid? "+isValid+"."); reader = aTempReader; writer = aTempWriter; @@ -72,6 +63,7 @@ public class ClassTransformer_TC_ItemWispEssence { boolean didInject = false; FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Injecting " + aMethodName + "."); + String aGetColour = obfuscated ? DevHelper.getSRG("getColorFromItemStack") : DevHelper.getForge("getColorFromItemStack"); if (aMethodName.equals("getAspects")) { mv = cw.visitMethod(ACC_PUBLIC, "getAspects", "(Lnet/minecraft/item/ItemStack;)Lthaumcraft/api/aspects/AspectList;", null, null); @@ -138,6 +130,77 @@ public class ClassTransformer_TC_ItemWispEssence { mv.visitEnd(); didInject = true; } + else if (aMethodName.equals(aGetColour)) { + + //thaumcraft/common/items/ItemWispEssence + mv = cw.visitMethod(ACC_PUBLIC, aGetColour, "(Lnet/minecraft/item/ItemStack;I)I", null, null); + AnnotationVisitor av0; + { + av0 = mv.visitAnnotation("Lcpw/mods/fml/relauncher/SideOnly;", true); + av0.visitEnum("value", "Lcpw/mods/fml/relauncher/Side;", "CLIENT"); + av0.visitEnd(); + } + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(197, l0); + mv.visitVarInsn(ALOAD, 1); + Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(198, l2); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l1); + mv.visitLineNumber(200, l1); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/common/items/ItemWispEssence", "getAspects", "(Lnet/minecraft/item/ItemStack;)Lthaumcraft/api/aspects/AspectList;", false); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(201, l4); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/common/items/ItemWispEssence", "getAspects", "(Lnet/minecraft/item/ItemStack;)Lthaumcraft/api/aspects/AspectList;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "getAspects", "()[Lthaumcraft/api/aspects/Aspect;", false); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/Aspect", "getColor", "()I", false); + mv.visitInsn(IRETURN); + mv.visitLabel(l3); + mv.visitLineNumber(203, l3); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/System", "currentTimeMillis", "()J", false); + mv.visitLdcInsn(new Long(500L)); + mv.visitInsn(LDIV); + mv.visitFieldInsn(GETSTATIC, "thaumcraft/common/items/ItemWispEssence", "displayAspects", "[Lthaumcraft/api/aspects/Aspect;"); + mv.visitInsn(ARRAYLENGTH); + mv.visitInsn(I2L); + mv.visitInsn(LREM); + mv.visitInsn(L2I); + mv.visitVarInsn(ISTORE, 3); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(204, l5); + mv.visitFieldInsn(GETSTATIC, "thaumcraft/common/items/ItemWispEssence", "displayAspects", "[Lthaumcraft/api/aspects/Aspect;"); + mv.visitVarInsn(ILOAD, 3); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/Aspect", "getColor", "()I", false); + mv.visitInsn(IRETURN); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLocalVariable("this", "Lthaumcraft/common/items/ItemWispEssence;", null, l0, l6, 0); + mv.visitLocalVariable("stack", "Lnet/minecraft/item/ItemStack;", null, l0, l6, 1); + mv.visitLocalVariable("par2", "I", null, l0, l6, 2); + mv.visitLocalVariable("idx", "I", null, l5, l6, 3); + mv.visitMaxs(4, 4); + mv.visitEnd(); + didInject = true; + } FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Method injection complete. "+(obfuscated ? "Obfuscated" : "Non-Obfuscated")); return didInject; @@ -145,12 +208,13 @@ public class ClassTransformer_TC_ItemWispEssence { public class AddAdapter extends ClassVisitor { - public AddAdapter(ClassVisitor cv) { + public AddAdapter(ClassVisitor cv, String[] aMethods) { super(ASM5, cv); this.cv = cv; + this.aMethodsToStrip = aMethods; } - private final String[] aMethodsToStrip = new String[] {"getAspects"}; + private final String[] aMethodsToStrip; @Override @@ -180,6 +244,30 @@ public class ClassTransformer_TC_ItemWispEssence { } } + static Aspect[] displayAspects; + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int par2) { + if (stack == null) { + return 0; + } + if (this.getAspects(stack) != null) { + return this.getAspects(stack).getAspects()[0].getColor(); + } else { + int idx = (int) (System.currentTimeMillis() / 500L % (long) displayAspects.length); + return displayAspects[idx].getColor(); + } + } + + public AspectList getAspects(ItemStack itemstack) { + if (itemstack.hasTagCompound()) { + AspectList aspects = new AspectList(); + aspects.readFromNBT(itemstack.getTagCompound()); + return aspects.size() > 0 ? aspects : null; + } else { + return null; + } + } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java index 4759a04158..107df90256 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java @@ -295,6 +295,7 @@ public class TC_Aspect_Wrapper { aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, components.length); int i = 0; for (TC_Aspect_Wrapper g : components) { + if (g != null && g.mAspect != null) ((Object[]) aAspectArray)[i++] = g.mAspect; } } -- cgit From d5ae6aa30263d7da551ffa592e285b01aef95707 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 5 Mar 2019 00:09:50 +0000 Subject: $ More small fixes, Added Tooltips and Proper Localisation for TC4 Aspects. --- .../plugin/fixes/vanilla/VanillaBedHeightFix.java | 2 +- .../xmod/thaumcraft/aspect/GTPP_AspectCompat.java | 18 ++++++++---- .../objects/wrapper/aspect/TC_Aspect_Wrapper.java | 32 ++++++++++++---------- 3 files changed, 32 insertions(+), 20 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java b/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java index 25be6679ed..5f3b1d8abd 100644 --- a/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java +++ b/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java @@ -31,7 +31,7 @@ public class VanillaBedHeightFix implements IBugFix { } if (m != null) { mSleepInBedAt = m; - mParent.log("Registering Bed Heigh Fix."); + mParent.log("Registering Bed Height Fix."); Utils.registerEvent(this); } else { mSleepInBedAt = null; diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java index 5ac85e38cd..ee623f4a1e 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java @@ -7,6 +7,7 @@ import java.util.LinkedHashMap; import java.util.List; import gregtech.api.enums.TC_Aspects; +import gregtech.api.util.GT_LanguageManager; import gregtech.common.GT_ThaumcraftCompat; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; @@ -110,7 +111,8 @@ public class GTPP_AspectCompat { }, new ResourceLocation(CORE.MODID+":textures/aspects/" + "Sagrausten.png"), false, - 1); + 1, + "Ancient Knowledge"); ASPECT_LUST = new TC_Aspect_Wrapper( @@ -122,7 +124,8 @@ public class GTPP_AspectCompat { }, new ResourceLocation(CORE.MODID+":textures/aspects/" + "Slusium.png"), false, - 1); + 1, + "Warped Thoughts"); ASPECT_STARBOUND = new TC_Aspect_Wrapper( @@ -132,7 +135,8 @@ public class GTPP_AspectCompat { }, new ResourceLocation(CORE.MODID+":textures/aspects/" + "Xenil.png"), false, - 1); + 1, + "A beginning to something new"); ASPECT_TOXIC = new TC_Aspect_Wrapper( @@ -144,7 +148,8 @@ public class GTPP_AspectCompat { }, new ResourceLocation(CORE.MODID+":textures/aspects/" + "Xablum.png"), false, - 1); + 1, + "Insanity"); ASPECT_HEAVEN = new TC_Aspect_Wrapper( @@ -156,7 +161,10 @@ public class GTPP_AspectCompat { }, new ResourceLocation(CORE.MODID+":textures/aspects/" + "Zetralt.png"), false, - 1); + 1, + "Control, Respect, Glory"); + + } private TC_Aspect_Wrapper get(TC_Aspects aGtObjects) { diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java index 107df90256..fda0fd27c5 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java @@ -8,6 +8,7 @@ import java.util.LinkedHashMap; import java.util.Map; import gregtech.api.enums.TC_Aspects; +import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -89,8 +90,8 @@ public class TC_Aspect_Wrapper { * @param chatcolor * @param blend */ - public TC_Aspect_Wrapper(String tag, int color, String chatcolor, int blend) { - this(tag, color, (TC_Aspect_Wrapper[]) null, blend); + public TC_Aspect_Wrapper(String tag, int color, String chatcolor, int blend, String aTooltip) { + this(tag, color, (TC_Aspect_Wrapper[]) null, blend, aTooltip); this.chatcolor = chatcolor; } @@ -101,8 +102,8 @@ public class TC_Aspect_Wrapper { * @param color * @param components */ - public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components) { - this(tag, color, components, false, 1); + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, String aTooltip) { + this(tag, color, components, false, 1, aTooltip); } /** @@ -113,8 +114,8 @@ public class TC_Aspect_Wrapper { * @param components * @param blend */ - public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, int blend) { - this(tag, color, components, false, blend); + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, int blend, String aTooltip) { + this(tag, color, components, false, blend, aTooltip); } @@ -127,17 +128,18 @@ public class TC_Aspect_Wrapper { * @param image * @param blend */ - public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, boolean vanilla, int blend) { - this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend); + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, boolean vanilla, int blend, String aTooltip) { + this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend, aTooltip); } - private static int aInternalAspectIDAllocation = 0; + private static int aInternalAspectIDAllocation = 1; - public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, ResourceLocation image, boolean vanilla, int blend) { + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, ResourceLocation image, boolean vanilla, int blend, String aTooltip) { if (components == null) { components = new TC_Aspect_Wrapper[] {}; - } - String aTag = vanilla ? tag.toLowerCase() : "custom"+(aInternalAspectIDAllocation++); + } + //String aTag = vanilla ? tag.toLowerCase() : "custom"+(aInternalAspectIDAllocation++); + String aTag = tag.toLowerCase(); if (getAspectList().containsKey(tag.toLowerCase())) { this.tag = aTag; this.components = components; @@ -173,7 +175,8 @@ public class TC_Aspect_Wrapper { mInternalAspectCache.put(this.tag, this); // Double link custom Aspects, but internalise names using custom# instead if (!vanilla) { - mInternalAspectCache.put(tag.toLowerCase(), this); + mInternalAspectCache.put("custom"+(aInternalAspectIDAllocation++), this); + GT_LanguageManager.addStringLocalization("tc.aspect."+aTag, aTooltip); } Logger.INFO("[Thaumcraft++] Adding support for Aspect: "+tag); } @@ -209,7 +212,8 @@ public class TC_Aspect_Wrapper { generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), (aBaseAspect)), (ResourceLocation) ReflectionUtils.getField(mClass_Aspect, "image").get(aBaseAspect), true, - (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect) + (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect), + "" ); if (aTemp != null) { aTemp.chatcolor = (String) ReflectionUtils.getField(mClass_Aspect, "chatcolor").get(aBaseAspect); -- cgit From 5d4e240e87884247a303c581989c28917ca1ada4 Mon Sep 17 00:00:00 2001 From: Dream-Master Date: Wed, 6 Mar 2019 15:34:48 +0100 Subject: GTNH EBF change coil heat value --- .../multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index f10350eaee..ac362e2c40 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -223,10 +223,10 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase this.mHeatingCapacity = 9001; break; case 7: - this.mHeatingCapacity = 12001; + this.mHeatingCapacity = 9901; break; case 8: - this.mHeatingCapacity = 15001; + this.mHeatingCapacity = 10801; break; default: Logger.INFO("Heating Coils are bad."); -- cgit From 064c0dc0cfab1cc677dfffc4b3b56642017e412b Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 8 Mar 2019 03:14:13 +0000 Subject: + Added some AgriChem. (You can now use Raw waste as a fuel source) + Added OreDict names to vanilla items, as was done in Forge 1.8.9. + Added functions to allow other mods to add Semifluid Fuels. + Added functions to handle String data into StringUtils.java. % Renamed getItemStack -> getItemStackFromFQRN. $ Fixed handling of custom cells for fluids using '.' within their names. $ Fixed HF exploit. --- .../gregtech/api/util/SemiFluidFuelHandler.java | 48 ++- .../common/compat/COMPAT_CompactWindmills.java | 18 +- .../core/common/compat/COMPAT_ExtraUtils.java | 2 +- .../core/common/compat/COMPAT_OpenBlocks.java | 2 +- .../core/common/compat/COMPAT_Thaumcraft.java | 12 +- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 2 +- src/Java/gtPlusPlus/core/item/ModItems.java | 8 +- .../core/item/base/BaseItemComponent.java | 24 +- .../core/item/chemistry/AgriculturalChem.java | 439 +++++++++++++++++++++ src/Java/gtPlusPlus/core/item/init/ItemsFoods.java | 12 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 34 +- .../gtPlusPlus/core/recipe/RECIPES_General.java | 10 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 48 +-- src/Java/gtPlusPlus/core/recipe/common/CI.java | 20 +- .../gtPlusPlus/core/util/data/StringUtils.java | 40 ++ .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 12 +- .../core/util/minecraft/RecipeUtils.java | 2 +- .../plugin/fixes/vanilla/Core_VanillaFixes.java | 38 +- .../forestry/bees/recipe/FR_Gregtech_Recipes.java | 2 +- .../interfaces/internal/IGregtech_RecipeAdder.java | 4 +- .../GregtechMetaTileEntity_MassFabricator.java | 4 +- .../xmod/gregtech/loaders/RecipeGen_Ore.java | 8 +- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 11 + .../gregtech/GregtechIndustrialMassFabricator.java | 4 +- .../textures/blocks/TileEntities/sewer_sides.png | Bin 0 -> 375 bytes .../textures/blocks/TileEntities/sewer_top.png | Bin 0 -> 375 bytes 26 files changed, 700 insertions(+), 104 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_sides.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_top.png (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gregtech/api/util/SemiFluidFuelHandler.java b/src/Java/gregtech/api/util/SemiFluidFuelHandler.java index f1c56c4e95..1414b3beb3 100644 --- a/src/Java/gregtech/api/util/SemiFluidFuelHandler.java +++ b/src/Java/gregtech/api/util/SemiFluidFuelHandler.java @@ -13,12 +13,58 @@ import net.minecraftforge.fluids.FluidStack; public class SemiFluidFuelHandler { + + public static boolean addSemiFluidFuel(ItemStack aFuelItem, int aFuelValue) { + FluidStack p = FluidContainerRegistry.getFluidForFilledItem(aFuelItem); + if (p != null && aFuelValue > 0) { + return addSemiFluidFuel(p, aFuelValue); + } else { + Logger.INFO("Fuel value for " + aFuelItem.getDisplayName() + " is <= 0, ignoring."); + } + return false; + } + + + public static boolean addSemiFluidFuel(FluidStack aFuel, int aFuelValue) { + FluidStack p = aFuel; + if (p != null && aFuelValue > 0) { + GT_Recipe aRecipe = + new Recipe_GT(true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] { p }, + null, + 0, + 0, + aFuelValue); + if (aRecipe.mSpecialValue > 0) { + Logger.INFO("Added " + aRecipe.mFluidInputs[0].getLocalizedName() + " to the Semi-Fluid Generator fuel map. Fuel Produces "+(aRecipe.mSpecialValue*1000)+"EU per 1000L."); + sSemiFluidLiquidFuels.add(aRecipe); + return true; + } + } else { + Logger.INFO("Fuel value for " + p != null ? p.getLocalizedName() : "NULL Fluid" + " is <= 0, ignoring."); + } + return false; + } + + + + + + public static boolean generateFuels() { final FluidStack aCreosote = FluidUtils.getFluidStack("creosote", 1000); final FluidStack aHeavyFuel = FluidUtils.getFluidStack("liquid_heavy_fuel", 1000); final HashMap> aFoundFluidsFromItems = new HashMap>(); // Find Fluids From items - for (GT_Recipe g : gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDenseLiquidFuels.mRecipeList) { + for (final GT_Recipe r : gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDenseLiquidFuels.mRecipeList) { + + GT_Recipe g = r.copy(); + + if (g != null && g.mEnabled && g.mInputs.length > 0 && g.mInputs[0] != null) { for (ItemStack i : g.mInputs) { FluidStack f = FluidContainerRegistry.getFluidForFilledItem(i); diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java index a5d0768e72..cd5d36b653 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java @@ -40,17 +40,17 @@ public class COMPAT_CompactWindmills { public static ItemStack evWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 4, 1); //Compact Rotors - public static ItemStack rotor2 = ItemUtils.getItemStack("CompactWindmills:WOOL", 1); - public static ItemStack rotor1 = ItemUtils.getItemStack("CompactWindmills:WOOD", 1); - public static ItemStack rotor3 = ItemUtils.getItemStack("CompactWindmills:ALLOY", 1); - public static ItemStack rotor4 = ItemUtils.getItemStack("CompactWindmills:CARBON", 1); - public static ItemStack rotor5 = ItemUtils.getItemStack("CompactWindmills:IRIDIUM", 1); + public static ItemStack rotor2 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOL", 1); + public static ItemStack rotor1 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOD", 1); + public static ItemStack rotor3 = ItemUtils.getItemStackFromFQRN("CompactWindmills:ALLOY", 1); + public static ItemStack rotor4 = ItemUtils.getItemStackFromFQRN("CompactWindmills:CARBON", 1); + public static ItemStack rotor5 = ItemUtils.getItemStackFromFQRN("CompactWindmills:IRIDIUM", 1); //IC2 Rotors - public static ItemStack rotorIC1 = ItemUtils.getItemStack("IC2:itemwoodrotor", 1); - public static ItemStack rotorIC2 = ItemUtils.getItemStack("IC2:itemironrotor", 1); - public static ItemStack rotorIC3 = ItemUtils.getItemStack("IC2:itemsteelrotor", 1); - public static ItemStack rotorIC4 = ItemUtils.getItemStack("IC2:itemwcarbonrotor", 1); + public static ItemStack rotorIC1 = ItemUtils.getItemStackFromFQRN("IC2:itemwoodrotor", 1); + public static ItemStack rotorIC2 = ItemUtils.getItemStackFromFQRN("IC2:itemironrotor", 1); + public static ItemStack rotorIC3 = ItemUtils.getItemStackFromFQRN("IC2:itemsteelrotor", 1); + public static ItemStack rotorIC4 = ItemUtils.getItemStackFromFQRN("IC2:itemwcarbonrotor", 1); public static ItemStack rotorBlade1 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 7, 1); public static ItemStack rotorBlade2 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 8, 1); public static ItemStack rotorBlade3 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 10, 1); diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java index 45a70997e4..4d736e1362 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java @@ -10,7 +10,7 @@ import gtPlusPlus.core.util.minecraft.RecipeUtils; public class COMPAT_ExtraUtils { public static void OreDict(){ - RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(ItemUtils.getItem("ExtraUtilities:divisionSigil")); + RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(ItemUtils.getItemFromFQRN("ExtraUtilities:divisionSigil")); run(); } diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java index c7b90b780c..6381a6705e 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java @@ -13,7 +13,7 @@ public class COMPAT_OpenBlocks { private static final void run(){ - Item aGraveItem = ItemUtils.getItem("OpenBlocks:grave"); + Item aGraveItem = ItemUtils.getItemFromFQRN("OpenBlocks:grave"); if (aGraveItem == null) { return; } diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java index 6247face1d..b78c10c8ce 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java @@ -20,9 +20,9 @@ public class COMPAT_Thaumcraft { for(int i=0; i<=6; i++){ //Utils.LOG_INFO(""+i); ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "shardAny", "TC Shard "+i, i); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStack("Thaumcraft:ItemShard:"+i, 1)); + GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:"+i, 1)); ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "gemInfusedAnything", "TC Shard "+i, i); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStack("Thaumcraft:ItemShard:"+i, 1)); + GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:"+i, 1)); //System.out.println("TC Shard registration count is: "+i); } @@ -30,15 +30,15 @@ public class COMPAT_Thaumcraft { for(int i=0; i<=6; i++){ //Utils.LOG_INFO(""+i); ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "shardAny", "FM Shard "+i, i); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStack("ForbiddenMagic:NetherShard:"+i, 1)); + GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:"+i, 1)); ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "gemInfusedAnything", "FM Shard "+i, i); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStack("ForbiddenMagic:NetherShard:"+i, 1)); + GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:"+i, 1)); //System.out.println("TC Shard registration count is: "+i); } ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "shardAny", "FM Gluttony Shard", 0); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStack("ForbiddenMagic:GluttonyShard", 1)); + GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "gemInfusedAnything", "FM Gluttony Shard", 0); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStack("ForbiddenMagic:GluttonyShard", 1)); + GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); } } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index f6735de8e4..1af7c05d64 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -39,7 +39,7 @@ public class COMPAT_HANDLER { GT_OreDictUnificator.registerOre("craftingToolSandHammer", new ItemStack(ModItems.itemSandstoneHammer)); for(int i=1; i<=10; i++){ - GT_OreDictUnificator.registerOre("bufferCore_"+GT_Values.VN[i-1], new ItemStack(ItemUtils.getItem("miscutils:item.itemBufferCore"+i))); + GT_OreDictUnificator.registerOre("bufferCore_"+GT_Values.VN[i-1], new ItemStack(ItemUtils.getItemFromFQRN("miscutils:item.itemBufferCore"+i))); } } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 8057f6bbe1..2a7bae629e 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -32,6 +32,7 @@ import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; import gtPlusPlus.core.item.bauble.HealthBoostBauble; import gtPlusPlus.core.item.bauble.ModularBauble; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.item.chemistry.CoalTar; import gtPlusPlus.core.item.chemistry.IonParticles; import gtPlusPlus.core.item.chemistry.NuclearChem; @@ -366,7 +367,7 @@ public final class ModItems { //Some Simple forms of materials itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMachines).setTextureName(CORE.MODID + ":itemStickyRubber"); GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); - GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStack(CORE.MODID+":itemStickyRubber", 1)); + GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemStickyRubber", 1)); itemCoalCoke = new BaseItemBurnable("itemCoalCoke", "Coking Coal", tabMisc, 64, 0, "Used for metallurgy.", "fuelCoke", 3200, 0).setTextureName(CORE.MODID + ":itemCoalCoke"); @@ -884,7 +885,10 @@ public final class ModItems { //Nuclear Processing NuclearChem.run(); - + + //Farm Animal Fun + AgriculturalChem.run(); + //Only used for debugging. /*if (CORE.DEVENV) { new ConnectedBlockFinder(); diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index 522b7e900e..fd69c97ff5 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -18,6 +18,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -77,18 +78,33 @@ public class BaseItemComponent extends Item{ //For Cell Generation public BaseItemComponent(final String unlocalName, final String localName, final short[] RGBA) { + + // Handles .'s from fluid internal names. + String aFormattedNameForFluids; + if (unlocalName.contains(".")) { + if (StringUtils.characterCount(unlocalName, '.') > 1) { + aFormattedNameForFluids = StringUtils.splitAndUppercase(unlocalName, "."); + } + else { + aFormattedNameForFluids = unlocalName.replace(".", ""); + } + } + else { + aFormattedNameForFluids = unlocalName; + } + this.componentMaterial = null; - this.unlocalName = "itemCell"+unlocalName; + this.unlocalName = "itemCell"+aFormattedNameForFluids; this.materialName = localName; this.componentType = ComponentTypes.CELL; this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalName); + this.setUnlocalizedName(aFormattedNameForFluids); this.setMaxStackSize(64); this.componentColour = MathUtils.getRgbAsHex(RGBA); this.extraData = RGBA; this.setTextureName(CORE.MODID + ":" + "item"+ComponentTypes.CELL.COMPONENT_NAME); - GameRegistry.registerItem(this, unlocalName); - GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+unlocalName, ItemUtils.getSimpleStack(this)); + GameRegistry.registerItem(this, aFormattedNameForFluids); + GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+aFormattedNameForFluids, ItemUtils.getSimpleStack(this)); registerComponent(); } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java new file mode 100644 index 0000000000..bd8630da69 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -0,0 +1,439 @@ +package gtPlusPlus.core.item.chemistry; + +import java.util.ArrayList; + +import forestry.plugins.PluginCore; +import gregtech.api.enums.GT_Values; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +public class AgriculturalChem { + + + private static boolean aBOP; + private static boolean aTiCon; + + private static AutoMap mBloodFluids = new AutoMap(); + + + /** + * Fluids + */ + + //Poop Juice + public static Fluid PoopJuice; + //Manure Slurry + public static Fluid ManureSlurry; + //Fertile Manure Slurry + public static Fluid FertileManureSlurry; + //Blood + public static Fluid CustomBlood; + + + /** + * Items + */ + + //Manure Byproducts + public static Item dustManureByproducts; + //Organic Fertilizer + public static Item dustOrganicFertilizer; + //Dirt + public static Item dustDirt; + + + + + // Poop Juice + // vv - Centrifuge + // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny piles + // vv - Chem Reactor - Add Peat, Meat + // Organic Fertilizer + // vv - Dehydrate + // Fertilizer + + // Poop Juice + // vv - Mixer - Add Blood, Bone, Meat (1000L Poo, 200L Blood, x2 Bone, x3 Meat) + // Fertile Manure Slurry + // vv - Chem Reactor - Add Peat x1.5 + // Organic Fertilizer x3 + // vv - Dehydrate + // Fertilizer + + + + + + + + + + + + + + + + public static void run(){ + + aBOP = LoadedMods.BiomesOPlenty; + aTiCon = LoadedMods.TiCon; + + Logger.INFO("Adding Agrochemical content"); + + FluidStack aBlood; + if (aBOP) { + aBlood = FluidUtils.getFluidStack("hell_blood", 100); + if (aBlood != null) { + Logger.INFO("Found Biome's o Plenty, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(aBlood); + } + } + + if (aTiCon) { + aBlood = FluidUtils.getFluidStack("hell_blood", 100); + if (aBlood != null) { + Logger.INFO("Found Tinker's Construct, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(FluidUtils.getFluidStack("blood", 100)); + } + } + + // Handle Blood Internally, Create if required. + if (mBloodFluids.isEmpty() || CustomBlood == null) { + Logger.INFO("Did not find any existing Blood fluids. Trying to wildcard search the fluid registry, then generate our own if that fails."); + FluidStack aTempBlood = FluidUtils.getWildcardFluidStack("blood", 100); + if (aTempBlood != null) { + CustomBlood = aTempBlood.getFluid(); + } + else { + aTempBlood = FluidUtils.getWildcardFluidStack("hell_blood", 100); + if (aTempBlood == null) { + CustomBlood = FluidUtils.generateFluidNoPrefix("blood", "Blood", 32+175, new short[]{175, 25, 25, 100}, true); + } + else { + CustomBlood = aTempBlood.getFluid(); + } + } + Logger.INFO("Using "+CustomBlood.getName()); + mBloodFluids.put(FluidUtils.getFluidStack(CustomBlood, 100)); + } + + + + //Sewage + PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32+175, new short[]{100, 70, 30, 100}, null, null, 0, true); + + //Sewage + ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39+175, new short[]{75, 45, 15, 100}, null, null, 0, true); + + //Sewage + FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", 45+175, new short[]{65, 50, 15, 100}, null, null, 0, true); + + + + //Ca5(PO4)3(OH) + + + // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; + + // Basically Guano + dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; + + // Dirt Dust :) + dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + + + + + + + + + + createRecipes(); + } + + + + + + + private static AutoMap mMeats = new AutoMap(); + private static AutoMap mFish = new AutoMap(); + private static AutoMap mFruits = new AutoMap(); + private static AutoMap mVege = new AutoMap(); + private static AutoMap mNuts = new AutoMap(); + private static AutoMap mSeeds = new AutoMap(); + private static AutoMap mPeat = new AutoMap(); + private static AutoMap mBones = new AutoMap(); + private static AutoMap mBoneMeal = new AutoMap(); + + private static AutoMap mList_Master_Meats = new AutoMap(); + private static AutoMap mList_Master_FruitVege = new AutoMap(); + private static AutoMap mList_Master_Bones = new AutoMap(); + private static AutoMap mList_Master_Seeds = new AutoMap(); + + private static void processAllOreDict() { + processOreDict("listAllmeatraw", mMeats); + processOreDict("listAllfishraw", mFish); + processOreDict("listAllfruit", mFruits); + processOreDict("listAllVeggie", mVege); + processOreDict("listAllnut", mNuts); + processOreDict("listAllSeed", mSeeds); + processOreDict("brickPeat", mPeat); + processOreDict("bone", mBones); + processOreDict("dustBone", mBoneMeal); + //Just make a mega list, makes life easier. + if (!mMeats.isEmpty()) { + for (ItemStack g : mMeats) { + mList_Master_Meats.put(g); + } + } + if (!mFish.isEmpty()) { + for (ItemStack g : mFish) { + mList_Master_Meats.put(g); + } + } + if (!mFruits.isEmpty()) { + for (ItemStack g : mFruits) { + mList_Master_FruitVege.put(g); + } + } + if (!mVege.isEmpty()) { + for (ItemStack g : mVege) { + mList_Master_FruitVege.put(g); + } + } + if (!mNuts.isEmpty()) { + for (ItemStack g : mNuts) { + mList_Master_FruitVege.put(g); + } + } + if (!mSeeds.isEmpty()) { + for (ItemStack g : mSeeds) { + mList_Master_Seeds.put(g); + } + } + if (!mBoneMeal.isEmpty()) { + for (ItemStack g : mBoneMeal) { + mList_Master_Bones.put(g); + } + } + if (!mBones.isEmpty()) { + for (ItemStack g : mBones) { + mList_Master_Bones.put(g); + } + } + } + + private static void processOreDict(String aOreName, AutoMap aMap) { + ArrayList aTemp = OreDictionary.getOres(aOreName); + if (!aTemp.isEmpty()) { + for (ItemStack stack : aTemp) { + aMap.put(stack); + } + } + } + + + private static void createRecipes() { + + if (mBloodFluids.isEmpty()) { + Logger.INFO("Could not find, nor create Blood fluid. Unable to add recipes."); + return; + } + + // Organise OreDict + processAllOreDict(); + + // Slurry Production + addBasicSlurryRecipes(); + addAdvancedSlurryRecipes(); + + // Organic Fert. Production + addBasicOrganiseFertRecipes(); + addAdvancedOrganiseFertRecipes(); + + addMiscRecipes(); + } + + + private static void addBasicSlurryRecipes() { + + ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); + ItemStack aDirtDust = ItemUtils.getSimpleStack(dustDirt, 1); + + //Poop Juice to Basic Slurry + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(10), + null, + FluidUtils.getFluidStack(PoopJuice, 1000), //In Fluid + FluidUtils.getFluidStack(ManureSlurry, 250), //Out Fluid + aDirtDust, + aDirtDust, + aManureByprod, + aManureByprod, + aManureByprod, + aManureByprod, + new int[]{2000, 2000, 500, 500, 250, 250}, //Chances + 10*20, //Time + 30); //EU + + // More Efficient way to get byproducts, less Slurry + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + null, + FluidUtils.getFluidStack(PoopJuice, 1000), //In Fluid + FluidUtils.getFluidStack(ManureSlurry, 50), //Out Fluid + aDirtDust, + aDirtDust, + aManureByprod, + aManureByprod, + aManureByprod, + aManureByprod, + new int[]{4000, 3000, 1250, 1250, 675, 675}, //Chances + 20*20, //Time + 60); //EU + + } + + private static void addAdvancedSlurryRecipes() { + + ItemStack aCircuit = CI.getNumberedCircuit(10); + ItemStack aBone; + ItemStack aMeat; + ItemStack aEmptyCells = CI.emptyCells(2); + ItemStack aInputCells = ItemUtils.getItemStackOfAmountFromOreDict("cellRawWaste", 2); + FluidStack aOutput = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + + for (FluidStack aBloodStack : mBloodFluids) { + for (ItemStack aBoneStack : mList_Master_Bones) { + aBone = ItemUtils.getSimpleStack(aBoneStack, 2); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + // Poop Juice to Fertile Slurry + GT_Values.RA.addMixerRecipe(aCircuit, aBone, aMeat, aInputCells, + aBloodStack, // Input Fluid + aOutput, // Output Fluid + aEmptyCells, // Output Item + 20 * 8, // Time? + 60 // Eu? + ); + } + } + } + } + + private static void addBasicOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(ManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 3); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 20 * 20, 120); + } + + aPeat = ItemUtils.getSimpleStack(aPeatStack, 2); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 9); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 120); + } + } + } + + private static void addAdvancedOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 7); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 5); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 7); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 140); + } + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 12); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 5 * 20, 140); + } + } + } + + private static void addMiscRecipes() { + + ItemStack aDustOrganicFert = ItemUtils.getSimpleStack(dustOrganicFertilizer, 1); + ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); + + + //Dehydrate Organise Fert to Normal Fert. + + /** + * Forestry Support + */ + if (LoadedMods.Forestry) { + + Item aForestryFert = PluginCore.items.fertilizerCompound; + + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedCircuit(11), + ItemUtils.getSimpleStack(aDustOrganicFert, 4) + }, + null, + null, + new ItemStack[] {ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod}, + new int[] {10000, 2000, 2000}, + 20 * 20, + 240); + } + + /** + * IC2 Support + */ + if (LoadedMods.IndustrialCraft2) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedCircuit(12), + ItemUtils.getSimpleStack(aDustOrganicFert, 4) + }, + null, + null, + new ItemStack[] {ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 3), aManureByprod, aManureByprod}, + new int[] {10000, 2000, 2000}, + 20 * 20, + 240); + } + + + // Dirt Production + CORE.RA.addCompressorRecipe(ItemUtils.getSimpleStack(dustDirt, 9), ItemUtils.getSimpleStack(Blocks.dirt), 20 * 2, 8); + + // Add Fuel Usages + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(PoopJuice, 1000), 12000); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(ManureSlurry, 1000), 24000); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(FertileManureSlurry, 1000), 32000); + + + } +} diff --git a/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java index 77a06edac2..94ebb3ffcb 100644 --- a/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java +++ b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java @@ -21,24 +21,24 @@ public class ItemsFoods { //Raisin Bread ModItems.itemIngotRaisinBread = new BaseItemFood("itemIngotRaisinBread", "Raisin Bread", 3, 1.5f, false, new PotionEffect(Potion.weakness.id, 40, 1)).setAlwaysEdible(); - GT_OreDictUnificator.registerOre("foodRaisinBread", ItemUtils.getItemStack(CORE.MODID+":itemIngotRaisinBread", 1)); + GT_OreDictUnificator.registerOre("foodRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemIngotRaisinBread", 1)); //Hot Raisin Bread ModItems.itemHotIngotRaisinBread = new BaseItemHotFood("itemHotIngotRaisinBread", 1, 0.5f, "Raisin Bread", 120, ModItems.itemIngotRaisinBread); - GT_OreDictUnificator.registerOre("foodHotRaisinBread", ItemUtils.getItemStack(CORE.MODID+":itemHotIngotRaisinBread", 1)); + GT_OreDictUnificator.registerOre("foodHotRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotIngotRaisinBread", 1)); //Raisin Bread ModItems.itemFoodRaisinToast = new BaseItemFood("itemFoodRaisinToast", "Raisin Toast", 1, 0.5f, false).setAlwaysEdible(); - GT_OreDictUnificator.registerOre("foodRaisinToast", ItemUtils.getItemStack(CORE.MODID+":itemFoodRaisinToast", 1)); + GT_OreDictUnificator.registerOre("foodRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemFoodRaisinToast", 1)); //Hot Raisin Bread ModItems.itemHotFoodRaisinToast = new BaseItemHotFood("itemHotFoodRaisinToast", 1, 0.5f, "Raisin Toast", 20, ModItems.itemFoodRaisinToast); - GT_OreDictUnificator.registerOre("foodHotRaisinToast", ItemUtils.getItemStack(CORE.MODID+":itemHotFoodRaisinToast", 1)); + GT_OreDictUnificator.registerOre("foodHotRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotFoodRaisinToast", 1)); //Raisin Bread ModItems.itemFoodCurriedSausages = new BaseItemFood("itemFoodCurriedSausages", "Curried Sausages", 5, 2f, false); - GT_OreDictUnificator.registerOre("foodCurriedSausages", ItemUtils.getItemStack(CORE.MODID+":itemFoodCurriedSausages", 1)); + GT_OreDictUnificator.registerOre("foodCurriedSausages", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemFoodCurriedSausages", 1)); //Hot Raisin Bread ModItems.itemHotFoodCurriedSausages = new BaseItemHotFood("itemHotFoodCurriedSausages", 1, 0.5f, "Curried Sausages", 240, ModItems.itemFoodCurriedSausages); - GT_OreDictUnificator.registerOre("foodHotCurriedSausages", ItemUtils.getItemStack(CORE.MODID+":itemHotFoodCurriedSausages", 1)); + GT_OreDictUnificator.registerOre("foodHotCurriedSausages", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotFoodCurriedSausages", 1)); } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 37c7fef1db..7164bc20f7 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -326,7 +326,7 @@ public class RECIPES_GREGTECH { CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), }, - ItemUtils.getItemStack("miscutils:personalHealingDevice", 1), + ItemUtils.getItemStackFromFQRN("miscutils:personalHealingDevice", 1), 20 * 60 * 30 * (GTNH ? 2 : 1), (int) GT_Values.V[7]); @@ -335,7 +335,7 @@ public class RECIPES_GREGTECH { //Charge Pack LuV-UV ItemStack[] aChargeResearch = new ItemStack[] { - ItemUtils.getItemStack("miscutils:item.itemBufferCore7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1), ItemUtils.getSimpleStack(ModItems.itemChargePack1, 1), ItemUtils.getSimpleStack(ModItems.itemChargePack2, 1), ItemUtils.getSimpleStack(ModItems.itemChargePack3, 1), @@ -349,10 +349,10 @@ public class RECIPES_GREGTECH { }; ItemStack[] aBufferCoreInputs = new ItemStack[] { - ItemUtils.getItemStack("miscutils:item.itemBufferCore7", GTNH ? 8 : 4), - ItemUtils.getItemStack("miscutils:item.itemBufferCore8", GTNH ? 8 : 4), - ItemUtils.getItemStack("miscutils:item.itemBufferCore9", GTNH ? 8 : 4), - ItemUtils.getItemStack("miscutils:item.itemBufferCore10", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", GTNH ? 8 : 4), }; int aCurrSlot = 0; @@ -696,21 +696,29 @@ public class RECIPES_GREGTECH { GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("sulfuricacid", 250)); - // Hydrofluoric Acid - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), - ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - FluidUtils.getFluidStack("hydrofluoricacid", 250), null); - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 250)); + + // Hydrofluoric Acid + boolean addedGtExtraction = false; + // Try use Internal GT Fluid first if (Utils.getGregtechVersionAsInt() >= 50929) { // Hydrofluoric Acid GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250), null); - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + addedGtExtraction = GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250)); } + //Add a Fill recipe for GT++ Acid + GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), + ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + FluidUtils.getFluidStack("hydrofluoricacid", 125), null); + //Add an empty recipe, but only if we didn't for the standard GT HF. Prevents Fluid transformation exploits. + if (!addedGtExtraction) + GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 125)); + + } private static void cokeOvenRecipes() { diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 54380306cc..1c0f3f8a28 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -50,7 +50,7 @@ public class RECIPES_General { RECIPE_Obsidian = ItemUtils.getSimpleStack(Blocks.obsidian); RECIPE_CraftingTable = ItemUtils.getSimpleStack(Blocks.crafting_table); RECIPE_HydrogenDust = ItemUtils.getSimpleStack(ModItems.itemHydrogenBlob); - RECIPE_BasicCasingIC2 = ItemUtils.getItemStack("IC2:blockMachine", 1); + RECIPE_BasicCasingIC2 = ItemUtils.getItemStackFromFQRN("IC2:blockMachine", 1); OUTPUT_Workbench_Bronze = ItemUtils.getSimpleStack(ModBlocks.blockWorkbench); OUTPUT_Blueprint = ItemUtils.getSimpleStack(ModItems.itemBlueprintBase); run(); @@ -127,9 +127,9 @@ public class RECIPES_General { //Iron bars final ItemStack ironBars; if (CORE.GTNH) { - ironBars = ItemUtils.getItemStack("dreamcraft:item.SteelBars", 1); + ironBars = ItemUtils.getItemStackFromFQRN("dreamcraft:item.SteelBars", 1); } else { - ironBars = ItemUtils.getItemStack("minecraft:iron_bars", 1); + ironBars = ItemUtils.getItemStackFromFQRN("minecraft:iron_bars", 1); } //Fish Trap @@ -154,7 +154,7 @@ public class RECIPES_General { null, CI.craftingToolWrench, null, ironRecipe, ironRecipe, ironRecipe, ironRecipe, ironRecipe, ironRecipe, - ItemUtils.getItemStack("minecraft:iron_bars", 8))) { + ItemUtils.getItemStackFromFQRN("minecraft:iron_bars", 8))) { Logger.INFO("Re-added old GT recipe for Iron Bars."); } } @@ -287,7 +287,7 @@ public class RECIPES_General { ItemUtils.getSimpleStack(ModBlocks.blockNet, 8), ItemUtils.getSimpleStack(Blocks.vine, 8), ALLOY.TUMBAGA.getRing(1), }, FluidUtils.getWater(1000), // Fluid - ItemUtils.getItemStack("miscutils:SlowBuildingRing", 1), // Output + ItemUtils.getItemStackFromFQRN("miscutils:SlowBuildingRing", 1), // Output 20 * 30, // Dur 16); // Eu diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index a7c0655f89..91ceb30911 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -97,16 +97,16 @@ public class RECIPES_Machines { //Buffer Cores - public static ItemStack RECIPE_BufferCore_ULV = ItemUtils.getItemStack("miscutils:item.itemBufferCore1", 1); - public static ItemStack RECIPE_BufferCore_LV = ItemUtils.getItemStack("miscutils:item.itemBufferCore2", 1); - public static ItemStack RECIPE_BufferCore_MV = ItemUtils.getItemStack("miscutils:item.itemBufferCore3", 1); - public static ItemStack RECIPE_BufferCore_HV = ItemUtils.getItemStack("miscutils:item.itemBufferCore4", 1); - public static ItemStack RECIPE_BufferCore_EV = ItemUtils.getItemStack("miscutils:item.itemBufferCore5", 1); - public static ItemStack RECIPE_BufferCore_IV = ItemUtils.getItemStack("miscutils:item.itemBufferCore6", 1); - public static ItemStack RECIPE_BufferCore_LuV = ItemUtils.getItemStack("miscutils:item.itemBufferCore7", 1); - public static ItemStack RECIPE_BufferCore_ZPM = ItemUtils.getItemStack("miscutils:item.itemBufferCore8", 1); - public static ItemStack RECIPE_BufferCore_UV = ItemUtils.getItemStack("miscutils:item.itemBufferCore9", 1); - public static ItemStack RECIPE_BufferCore_MAX = ItemUtils.getItemStack("miscutils:item.itemBufferCore10", 1); + public static ItemStack RECIPE_BufferCore_ULV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore1", 1); + public static ItemStack RECIPE_BufferCore_LV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore2", 1); + public static ItemStack RECIPE_BufferCore_MV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore3", 1); + public static ItemStack RECIPE_BufferCore_HV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore4", 1); + public static ItemStack RECIPE_BufferCore_EV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore5", 1); + public static ItemStack RECIPE_BufferCore_IV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore6", 1); + public static ItemStack RECIPE_BufferCore_LuV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1); + public static ItemStack RECIPE_BufferCore_ZPM = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", 1); + public static ItemStack RECIPE_BufferCore_UV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", 1); + public static ItemStack RECIPE_BufferCore_MAX = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", 1); //Wire @@ -181,7 +181,7 @@ public class RECIPES_Machines { //Lava Boiler public static ItemStack boiler_Coal; - public static ItemStack blockBricks = ItemUtils.getItemStack("minecraft:brick_block", 1); + public static ItemStack blockBricks = ItemUtils.getItemStackFromFQRN("minecraft:brick_block", 1); //Batteries public static String batteryBasic = "batteryBasic"; @@ -990,7 +990,7 @@ public class RECIPES_Machines { "plateDoubleZeron100", CI.craftingToolHammer_Hard, "plateDoubleZeron100", RECIPE_LFTRInnerCasing); - ItemStack IC2HeatPlate = ItemUtils.getItemStack("IC2:reactorPlatingHeat", 1); + ItemStack IC2HeatPlate = ItemUtils.getItemStackFromFQRN("IC2:reactorPlatingHeat", 1); RecipeUtils.addShapedGregtechRecipe( "plateDoubleHastelloyN", IC2HeatPlate, "plateDoubleHastelloyN", IC2HeatPlate, "frameGtHastelloyC276", IC2HeatPlate, @@ -1605,7 +1605,7 @@ public class RECIPES_Machines { Item aBaseCore = ModItems.itemControlCore; ItemStack[] aInputPrevTier = new ItemStack[] { - GTNH ? ItemUtils.getItemStack("miscutils:item.itemBufferCore3", 1) : ItemUtils.getItemStack("miscutils:item.itemBufferCore2", 1), + GTNH ? ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore3", 1) : ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore2", 1), ItemUtils.simpleMetaStack(aBaseCore, 0, 1), ItemUtils.simpleMetaStack(aBaseCore, 1, 1), ItemUtils.simpleMetaStack(aBaseCore, 2, 1), @@ -1636,7 +1636,7 @@ public class RECIPES_Machines { aOutput[1], aMat_A[1].getGear(GTNH ? 4 : 2), aMat_B[2].getPlateDouble(GTNH ? 16 : 8), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+(GTNH ? "2" : "1"), GTNH ? 4 : 2), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+(GTNH ? "2" : "1"), GTNH ? 4 : 2), ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 3 : 2), GTNH ? 10 : 5) }, aMat_B[3].getFluid(144 * 8), //Input Fluid @@ -1806,16 +1806,16 @@ public class RECIPES_Machines { ItemStack[] aOutput = new ItemStack[] { - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"1", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"2", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"3", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"4", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"5", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"6", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"7", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"8", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"9", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"10", 1) + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"1", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"2", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"3", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"4", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"5", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"6", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"10", 1) }; int aCostMultiplier = GTNH ? 4 : 1; diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index 28fa12ac1a..42cb075400 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -631,16 +631,16 @@ public class CI { public static ItemStack getEnergyCore(int aTier, int aAmount) { ItemStack[] aOutput = new ItemStack[] { - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"1", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"2", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"3", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"4", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"5", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"6", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"7", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"8", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"9", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"10", 1) + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"1", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"2", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"3", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"4", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"5", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"6", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"10", 1) }; return ItemUtils.getSimpleStack(aOutput[MathUtils.balance(aTier, 0, 9)], aAmount); } diff --git a/src/Java/gtPlusPlus/core/util/data/StringUtils.java b/src/Java/gtPlusPlus/core/util/data/StringUtils.java index b64266b5d4..2821a0c1c9 100644 --- a/src/Java/gtPlusPlus/core/util/data/StringUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/StringUtils.java @@ -1,5 +1,7 @@ package gtPlusPlus.core.util.data; +import gtPlusPlus.api.objects.data.AutoMap; + public class StringUtils { public static String superscript(String str) { @@ -131,4 +133,42 @@ public class StringUtils { return aData; } } + + public static String splitAndUppercase(String aInput, String aDelim) { + String[] aSplit = aInput.split(aDelim); + if (aSplit == null || aSplit.length == 0) { + return aInput; + } + else { + AutoMap aTemp = new AutoMap(); + for (String s : aSplit) { + aTemp.put(firstLetterCaps(s)); + } + String aReturn = ""; + for (String s : aTemp) { + aReturn += s; + } + return aReturn; + } + } + + public static int characterCount(String aString, char aChar) { + return characterCount(aString, ""+aChar); + } + + public static int characterCount(String aString, String aChar) { + int aLength = aString.length(); + int aFound = 0; + if (aLength == 0 || !aString.contains(aChar)) { + return 0; + } + else { + for (int index = 0; index < aLength; index++) { + if (aString.substring(index, index+1).equals(aChar)) { + aFound++; + } + } + return aFound; + } + } } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 2522ba56da..50778e1285 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -124,7 +124,7 @@ public class ItemUtils { final int meta) { try { Item em = null; - final Item em1 = getItem(FQRN); + final Item em1 = getItemFromFQRN(FQRN); // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { em = em1; @@ -158,7 +158,7 @@ public class ItemUtils { if (MOD) { try { Item em = null; - final Item em1 = getItem(FQRN); + final Item em1 = getItemFromFQRN(FQRN); // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { if (null == em) { @@ -181,7 +181,7 @@ public class ItemUtils { public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize) { try { Item em = null; - final Item em1 = getItem(FQRN); + final Item em1 = getItemFromFQRN(FQRN); // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { if (null == em) { @@ -233,7 +233,7 @@ public class ItemUtils { ItemStack temp; if (fqrn.toLowerCase().contains(oreDict.toLowerCase())) { final String sanitizedName = fqrn.replace(oreDict, ""); - temp = ItemUtils.getItemStack(sanitizedName, stackSize); + temp = ItemUtils.getItemStackFromFQRN(sanitizedName, stackSize); return temp; } final String[] fqrnSplit = fqrn.split(":"); @@ -258,13 +258,13 @@ public class ItemUtils { return null; } - public static Item getItem(final String fqrn) // fqrn = fully qualified resource name + public static Item getItemFromFQRN(final String fqrn) // fqrn = fully qualified resource name { final String[] fqrnSplit = fqrn.split(":"); return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); } - public static ItemStack getItemStack(final String fqrn, final int Size) // fqrn = fully qualified resource name + public static ItemStack getItemStackFromFQRN(final String fqrn, final int Size) // fqrn = fully qualified resource name { final String[] fqrnSplit = fqrn.split(":"); return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index a5f5c778bf..664ab40e6f 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -212,7 +212,7 @@ public static int mInvalidID = 1; public static boolean removeCraftingRecipe(Object x){ if (null == x){return false;} if (x instanceof String){ - final Item R = ItemUtils.getItem((String) x); + final Item R = ItemUtils.getItemFromFQRN((String) x); if (R != null){ x = R; } diff --git a/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java b/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java index f6af6e6e5f..cf9676635d 100644 --- a/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java +++ b/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java @@ -1,7 +1,11 @@ package gtPlusPlus.plugin.fixes.vanilla; import gtPlusPlus.api.interfaces.IPlugin; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.plugin.manager.Core_Manager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; public class Core_VanillaFixes implements IPlugin { @@ -19,18 +23,18 @@ public class Core_VanillaFixes implements IPlugin { } @Override - public boolean preInit() { - return false; + public boolean preInit() { + return fixVanillaOD(); } @Override public boolean init() { - return false; + return true; } @Override public boolean postInit() { - return false; + return true; } @Override @@ -42,5 +46,31 @@ public class Core_VanillaFixes implements IPlugin { public String getPluginAbbreviation() { return "VFIX"; } + + private boolean fixVanillaOD() { + registerToOreDict(ItemUtils.getSimpleStack(Items.nether_wart), "cropNetherWart"); + registerToOreDict(ItemUtils.getSimpleStack(Items.reeds), "sugarcane"); + registerToOreDict(ItemUtils.getSimpleStack(Items.paper), "paper"); + registerToOreDict(ItemUtils.getSimpleStack(Items.ender_pearl), "enderpearl"); + registerToOreDict(ItemUtils.getSimpleStack(Items.bone), "bone"); + registerToOreDict(ItemUtils.getSimpleStack(Items.gunpowder), "gunpowder"); + registerToOreDict(ItemUtils.getSimpleStack(Items.string), "string"); + registerToOreDict(ItemUtils.getSimpleStack(Items.nether_star), "netherStar"); + registerToOreDict(ItemUtils.getSimpleStack(Items.leather), "leather"); + registerToOreDict(ItemUtils.getSimpleStack(Items.feather), "feather"); + registerToOreDict(ItemUtils.getSimpleStack(Items.egg), "egg"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.end_stone), "endstone"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.vine), "vine"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.cactus), "blockCactus"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.grass), "grass"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.obsidian), "obsidian"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.crafting_table), "workbench"); + return true; + } + + private void registerToOreDict(ItemStack aStack, String aString) { + mInstance.log("Registering "+aStack.getDisplayName()+" to OreDictionary under the tag '"+aString+"'. (Added to Forge in 1.8.9)"); + ItemUtils.addItemToOreDictionary(aStack, aString); + } } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java index 0bba3d1f84..7e011a808e 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java @@ -31,7 +31,7 @@ public class FR_Gregtech_Recipes { private static ItemStack hiveFrameClay = ItemUtils.getSimpleStack(FR_ItemRegistry.hiveFrameClay); private static ItemStack hiveFrameNova = ItemUtils.getSimpleStack(FR_ItemRegistry.hiveFrameNova); - private static ItemStack hiveFrameImpregnated = ItemUtils.getItemStack("Forestry:frameImpregnated", 1); + private static ItemStack hiveFrameImpregnated = ItemUtils.getItemStackFromFQRN("Forestry:frameImpregnated", 1); private static ItemStack blockSoulSand = new ItemStack(Blocks.soul_sand, 1); private static ItemStack blockIronBars = new ItemStack (Blocks.iron_bars, 1); private static ItemStack itemClayDust = new ItemStack(Items.clay_ball, 1); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index d5b484e314..9eebeb5560 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -141,7 +141,9 @@ public interface IGregtech_RecipeAdder { public boolean addLFTRRecipe(ItemStack aInput1, FluidStack aInput2, ItemStack aOutput1, FluidStack aOutput2, int aDuration, int aEUt); public boolean addLFTRRecipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt); - + public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue); + public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue); + public boolean addFissionFuel( FluidStack aInput1, FluidStack aInput2, FluidStack aInput3, FluidStack aInput4, FluidStack aInput5, FluidStack aInput6, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java index f052d64a34..e531103a37 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java @@ -134,13 +134,13 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo public static ItemStack getScrapPile() { if (mScrap[0] == null) { - mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); } return mScrap[0]; } public static ItemStack getScrapBox() { if (mScrap[1] == null) { - mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); + mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); } return mScrap[1]; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java index 66775f7872..15627a827f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -264,8 +264,8 @@ public class RecipeGen_Ore extends RecipeGen_Base { matDust, tinyDustA,null, null, null,null, new int[]{10000, 10000}, //Chances - 5*20, //Eu - tVoltageMultiplier/2)){ //Time + 5*20, //Time + tVoltageMultiplier/2)){ //Eu Logger.MATERIALS("[Centrifuge] Added Recipe: Purified Dust to Clean Dust"); } @@ -277,8 +277,8 @@ public class RecipeGen_Ore extends RecipeGen_Base { matDust, tinyDustB,null, null, null,null, new int[]{10000, 10000}, //Chances - 5*20, //Eu - tVoltageMultiplier/2)){ //Time + 5*20, //Time + tVoltageMultiplier/2)){ //Eu Logger.MATERIALS("[Centrifuge] Added Recipe: Inpure Dust to Clean Dust"); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index b4f7347b52..d16bffef86 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -15,6 +15,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; +import gregtech.api.util.SemiFluidFuelHandler; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; @@ -1064,6 +1065,16 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { return true; } + + @Override + public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue) { + return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); + } + + @Override + public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue) { + return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java index 8064c68559..6362b07b93 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java @@ -221,10 +221,10 @@ public class GregtechIndustrialMassFabricator { public static ItemStack getScrapPile() { - return ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + return ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); } public static ItemStack getScrapBox() { - return ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); + return ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); } } \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_sides.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_sides.png new file mode 100644 index 0000000000..1754172689 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_sides.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_top.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_top.png new file mode 100644 index 0000000000..4835240aee Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/sewer_top.png differ -- cgit From 86c8b91b00624c7b1824b6b75290ed383338e48f Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 8 Mar 2019 03:47:14 +0000 Subject: % Rebalanced AgroChem recipes a bit. $ Fixed AgroChem fuels being worth 1000x the intended EU total. $ Fixed Unique Dusts not having recipes for their Small/Tiny forms. --- .../core/item/base/BaseItemComponent.java | 7 +-- .../core/item/chemistry/AgriculturalChem.java | 54 ++++++++++++++------- .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 55 ++++++++++++++++++++++ .../core/util/minecraft/RecipeUtils.java | 17 ++++--- .../interfaces/internal/IGregtech_RecipeAdder.java | 14 ++++++ 5 files changed, 115 insertions(+), 32 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index fd69c97ff5..ceeff7e655 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -82,12 +82,7 @@ public class BaseItemComponent extends Item{ // Handles .'s from fluid internal names. String aFormattedNameForFluids; if (unlocalName.contains(".")) { - if (StringUtils.characterCount(unlocalName, '.') > 1) { - aFormattedNameForFluids = StringUtils.splitAndUppercase(unlocalName, "."); - } - else { - aFormattedNameForFluids = unlocalName.replace(".", ""); - } + aFormattedNameForFluids = StringUtils.splitAndUppercase(unlocalName, "."); } else { aFormattedNameForFluids = unlocalName; diff --git a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java index bd8630da69..a8753677be 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import forestry.plugins.PluginCore; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; @@ -20,6 +21,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import scala.xml.dtd.ELEMENTS; public class AgriculturalChem { @@ -144,10 +146,7 @@ public class AgriculturalChem { //Sewage FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", 45+175, new short[]{65, 50, 15, 100}, null, null, 0, true); - - - - //Ca5(PO4)3(OH) + // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon @@ -276,8 +275,9 @@ public class AgriculturalChem { private static void addBasicSlurryRecipes() { - - ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); + + ItemStack aManureByprod1 = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + ItemStack aManureByprod2 = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); ItemStack aDirtDust = ItemUtils.getSimpleStack(dustDirt, 1); //Poop Juice to Basic Slurry @@ -288,10 +288,10 @@ public class AgriculturalChem { FluidUtils.getFluidStack(ManureSlurry, 250), //Out Fluid aDirtDust, aDirtDust, - aManureByprod, - aManureByprod, - aManureByprod, - aManureByprod, + aManureByprod1, + aManureByprod1, + aManureByprod1, + aManureByprod1, new int[]{2000, 2000, 500, 500, 250, 250}, //Chances 10*20, //Time 30); //EU @@ -304,10 +304,10 @@ public class AgriculturalChem { FluidUtils.getFluidStack(ManureSlurry, 50), //Out Fluid aDirtDust, aDirtDust, - aManureByprod, - aManureByprod, - aManureByprod, - aManureByprod, + aManureByprod1, + aManureByprod1, + aManureByprod2, + aManureByprod2, new int[]{4000, 3000, 1250, 1250, 675, 675}, //Chances 20*20, //Time 60); //EU @@ -429,10 +429,30 @@ public class AgriculturalChem { // Dirt Production CORE.RA.addCompressorRecipe(ItemUtils.getSimpleStack(dustDirt, 9), ItemUtils.getSimpleStack(Blocks.dirt), 20 * 2, 8); + //Centrifuge Byproducts + + + // Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + ItemUtils.getSimpleStack(aManureByprod, 4), + FluidUtils.getFluidStack("sulfuricacid", 250), //In Fluid + FluidUtils.getFluidStack("sulfuricapatite", 50), //Out Fluid + Materials.Phosphorus.getDustSmall(2), + Materials.Calcium.getDustSmall(2), + Materials.Copper.getDustTiny(1), + Materials.Carbon.getDust(1), + ItemUtils.getSimpleStack(dustDirt, 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAmmoniumNitrate", 1), + new int[]{2500, 2500, 750, 1000, 5000, 250}, //Chances + 20*20, //Time + 60); //EU + + // Add Fuel Usages - CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(PoopJuice, 1000), 12000); - CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(ManureSlurry, 1000), 24000); - CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(FertileManureSlurry, 1000), 32000); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(PoopJuice, 1000), 12); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(ManureSlurry, 1000), 24); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(FertileManureSlurry, 1000), 32); } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 50778e1285..9ce51d5858 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -396,6 +396,61 @@ public class ItemUtils { new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, mChemForm, Colour, "Dust"), new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, mChemForm, Colour, "Small"), new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, mChemForm, Colour, "Tiny") }; + + //Generate Shaped/Shapeless Recipes + + final ItemStack normalDust = ItemUtils.getSimpleStack(output[0]); + final ItemStack smallDust = ItemUtils.getSimpleStack(output[1]); + final ItemStack tinyDust = ItemUtils.getSimpleStack(output[2]); + + + if (ItemUtils.checkForInvalidItems(tinyDust) && ItemUtils.checkForInvalidItems(normalDust)) { + if (RecipeUtils.recipeBuilder( + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + normalDust)){ + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+materialName+" - Success"); + } + else { + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+materialName+" - Failed"); + } + + if (RecipeUtils.recipeBuilder( + normalDust, null, null, + null, null, null, + null, null, null, + ItemUtils.getSimpleStack(tinyDust, 9))){ + Logger.WARNING("9 Tiny dust from 1 Recipe: "+materialName+" - Success"); + } + else { + Logger.WARNING("9 Tiny dust from 1 Recipe: "+materialName+" - Failed"); + } + } + + if (ItemUtils.checkForInvalidItems(smallDust) && ItemUtils.checkForInvalidItems(normalDust)) { + if (RecipeUtils.recipeBuilder( + smallDust, smallDust, null, + smallDust, smallDust, null, + null, null, null, + normalDust)){ + Logger.WARNING("4 Small dust to 1 Dust Recipe: "+materialName+" - Success"); + } + else { + Logger.WARNING("4 Small dust to 1 Dust Recipe: "+materialName+" - Failed"); + } + if (RecipeUtils.recipeBuilder( + null, normalDust, null, + null, null, null, + null, null, null, + ItemUtils.getSimpleStack(smallDust, 4))){ + Logger.WARNING("4 Small dust from 1 Dust Recipe: "+materialName+" - Success"); + } + else { + Logger.WARNING("4 Small dust from 1 Dust Recipe: "+materialName+" - Failed"); + } + } + return output; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index 664ab40e6f..cc71b910c6 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -5,12 +5,6 @@ import java.util.Iterator; import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; - import gregtech.api.enums.Materials; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; @@ -22,9 +16,12 @@ import gtPlusPlus.api.objects.minecraft.ShapedRecipe; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; @@ -33,7 +30,8 @@ public class RecipeUtils { public static int mInvalidID = 1; public static boolean recipeBuilder(final Object slot_1, final Object slot_2, final Object slot_3, final Object slot_4, final Object slot_5, final Object slot_6, final Object slot_7, final Object slot_8, final Object slot_9, ItemStack resultItem){ - if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { + //Old Debug Code, useful for finding recipes loading too early. + /*if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { Logger.INFO(ReflectionUtils.getMethodName(1)); Logger.INFO(ReflectionUtils.getMethodName(2)); Logger.INFO(ReflectionUtils.getMethodName(3)); @@ -44,7 +42,7 @@ public static int mInvalidID = 1; Logger.INFO(ReflectionUtils.getMethodName(8)); Logger.INFO(ReflectionUtils.getMethodName(9)); System.exit(1); - } + }*/ if (resultItem == null){ Logger.RECIPE("[Fix] Found a recipe with an invalid output, yet had a valid inputs. Using Dummy output so recipe can be found.."); @@ -395,6 +393,7 @@ public static int mInvalidID = 1; else { Logger.RECIPE("[Fix] Output is Null for a recipe. Report to Alkalus."); output = ItemUtils.getItemStackOfAmountFromOreDict("sadibasdkjnad", 1); + RegistrationHandler.recipesFailed++; } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index 9eebeb5560..721facd8d0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -141,7 +141,21 @@ public interface IGregtech_RecipeAdder { public boolean addLFTRRecipe(ItemStack aInput1, FluidStack aInput2, ItemStack aOutput1, FluidStack aOutput2, int aDuration, int aEUt); public boolean addLFTRRecipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt); + + /** + * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. + * @param aFuelItem - A Fluidstack to be consumed. + * @param aFuelValue - Fuel value in thousands (1 = 1000) + * @return - Was the Fuel added? + */ public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue); + + /** + * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. + * @param aFuelItem - A Fluidstack to be consumed. + * @param aFuelValue - Fuel value in thousands (1 = 1000) + * @return - Was the Fuel added? + */ public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue); public boolean addFissionFuel( -- cgit From 15beaef7c208a5ec84c7ef92288c50e39387cdbd Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 8 Mar 2019 21:27:30 +0000 Subject: % Allowed Hand-Pumps to function on all Tanks again & also allowed GT output slots. Closes #423. % Adjusted Generic Bucket handling of Textures and Colouring. $ Fixed several issues with Hand-Pump logic, Fixes #353. $ Fixed load issues with FluidFactory.java. --- src/Java/gtPlusPlus/core/common/CommonProxy.java | 5 +- .../gtPlusPlus/core/fluids/BlockFluidBase.java | 27 ++++- src/Java/gtPlusPlus/core/fluids/FactoryFluid.java | 12 +- src/Java/gtPlusPlus/core/fluids/FluidFactory.java | 57 ++++++++-- src/Java/gtPlusPlus/core/fluids/FluidPackage.java | 26 ++++- .../core/fluids/ItemGenericFluidBucket.java | 102 ++++++++++++++--- .../core/item/tool/misc/GregtechPump.java | 125 ++++++++++++++------- .../gtPlusPlus/plugin/agrichem/Core_Agrichem.java | 43 +++++++ .../plugin/agrichem/fluids/FluidLoader.java | 21 ++++ .../GregtechMetaTileEntity_Refinery.java | 2 +- .../textures/items/bucket.generic.overlay.png | Bin 0 -> 279 bytes 11 files changed, 343 insertions(+), 77 deletions(-) create mode 100644 src/Java/gtPlusPlus/plugin/agrichem/Core_Agrichem.java create mode 100644 src/Java/gtPlusPlus/plugin/agrichem/fluids/FluidLoader.java create mode 100644 src/resources/assets/miscutils/textures/items/bucket.generic.overlay.png (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 03b643abdb..7d4644f275 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -18,6 +18,7 @@ import gtPlusPlus.core.entity.InternalEntityRegistry; import gtPlusPlus.core.entity.monster.EntityGiantChickenBase; import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; +import gtPlusPlus.core.fluids.FluidFactory; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.handler.BurnableFuelHandler; import gtPlusPlus.core.handler.COMPAT_HANDLER; @@ -81,7 +82,7 @@ public class CommonProxy { ModItems.init(); ModBlocks.init(); CI.preInit(); - + FluidFactory.preInit(); COMPAT_IntermodStaging.preInit(e); BookHandler.run(); // Registration of entities and renderers @@ -117,6 +118,7 @@ public class CommonProxy { Logger.ERROR("[ERROR] Did not generate fluids at all."); } CI.init(); + FluidFactory.init(); /** * Register the Event Handlers. @@ -158,6 +160,7 @@ public class CommonProxy { public void postInit(final FMLPostInitializationEvent e) { Logger.INFO("Cleaning up, doing postInit."); PlayerCache.initCache(); + FluidFactory.postInit(); // Make Burnables burnable if (!CORE.burnables.isEmpty()) { diff --git a/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java b/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java index 2aa598fc96..dc7c9c2e78 100644 --- a/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java +++ b/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java @@ -9,6 +9,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.BlockFluidClassic; @@ -20,12 +21,20 @@ public class BlockFluidBase extends BlockFluidClassic { protected static IIcon stillIcon; @SideOnly(Side.CLIENT) protected static IIcon flowingIcon; - + protected final short[] mRGB; + + public BlockFluidBase(Fluid fluid, short[] aRGB) { + this(fluid, Material.water, aRGB); + } + public BlockFluidBase(Fluid fluid, Material material, short[] aRGB) { super(fluid, material); mRGB = aRGB; + this.setHardness(100.0F); + this.setLightOpacity(3); + this.disableStats(); } @Override @@ -76,4 +85,20 @@ public class BlockFluidBase extends BlockFluidClassic { return super.recolourBlock(world, x, y, z, side, colour); } + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.displaceIfPossible(world, x, y, z); + } + } diff --git a/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java b/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java index befdf87c27..3359f18f7d 100644 --- a/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java +++ b/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java @@ -10,17 +10,25 @@ public class FactoryFluid extends Fluid implements Runnable { private final String mTextureName; private final short[] mRGBa; - public FactoryFluid(String fluidName, int luminosity, int density, int temp, int viscosity, final short[] aRGBa) { - this(fluidName, null, luminosity, density, temp, viscosity, false, EnumRarity.common, aRGBa); + public FactoryFluid(String fluidName, final short[] aRGBa) { + this(fluidName, null, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, false, EnumRarity.common, aRGBa); } + public FactoryFluid(String fluidName, int luminosity, int density, int temp, int viscosity, final short[] aRGBa) { + this(fluidName, null, luminosity, density, temp, viscosity, (density == Short.MIN_VALUE || density >= 0 ? false : true), EnumRarity.common, aRGBa); + } + public FactoryFluid(String fluidName, Block aBlock, int luminosity, int density, int temp, int viscosity, boolean gas, EnumRarity aRarity, final short[] aRGBa) { super(fluidName); this.mRGBa = aRGBa; this.setBlock(aBlock); + if (luminosity != Short.MIN_VALUE) this.setLuminosity(luminosity); + if (density != Short.MIN_VALUE) this.setDensity(density); + if (temp != Short.MIN_VALUE) this.setTemperature(temp); + if (viscosity != Short.MIN_VALUE) this.setViscosity(viscosity); this.setGaseous(gas); this.setRarity(aRarity); diff --git a/src/Java/gtPlusPlus/core/fluids/FluidFactory.java b/src/Java/gtPlusPlus/core/fluids/FluidFactory.java index fad545ce68..dffd7f55e9 100644 --- a/src/Java/gtPlusPlus/core/fluids/FluidFactory.java +++ b/src/Java/gtPlusPlus/core/fluids/FluidFactory.java @@ -18,6 +18,7 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -52,8 +53,13 @@ public class FluidFactory { public static final Map mMetaToFluidMap = new LinkedHashMap(); public static final Map mMetaToBucketMap = new LinkedHashMap(); public static final Map mMetaToBlockMap = new LinkedHashMap(); + + + //Special Colour Handling + public static final Map mMetaToColourMap = new LinkedHashMap(); + public static Item mGenericBucket; private static FluidPackage mErrorFluid; private static AutoMap mGeneratedFluids = new AutoMap(); @@ -61,10 +67,13 @@ public class FluidFactory { } - public static void init() { - GameRegistry.registerItem(new ItemGenericFluidBucket(Blocks.air), "gtpp.bucket.generic"); - for (FluidPackage y : mGeneratedFluids) { - FluidRegistry.registerFluid(y.get()); + public static void init() { + mGenericBucket = new ItemGenericFluidBucket(Blocks.air); + GameRegistry.registerItem(mGenericBucket, "gtpp.bucket.generic"); + for (FluidPackage y : mGeneratedFluids) { + if (!y.valid()) { + continue; + } GameRegistry.registerBlock(y.mBlock, FluidItemBlock.class, "gtpp_" + y.mName); FluidContainerRegistry.registerFluidContainer(y.get(), y.mBucket, new ItemStack(Items.bucket)); } @@ -75,6 +84,34 @@ public class FluidFactory { } + /** + * Generates a 'Water' type fluid. + * @param aID - The Fluid ID (Must be unique) + * @param aUnlocalName - Unlocalized Fluid Name + * @param aRGB - a {@link Short[]} containing the RGB of the FluidPackage. + * @return - A fully constructed & registered {@linkplain FluidPackage} + */ + public static FluidPackage generate(int aID, String aUnlocalName, short[] aRGB) { + return generate(aID, aUnlocalName, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, aRGB); + } + + /** + * Generate a {@link FluidPackage} from the data provided. This FluidPackage is automatically registered and handled internally. + * Pass in {@link Short}.MIN_VALUE for any of the Fluid Fields (Besides ID, Name or RGB) and it will default to water values. + * @param aID - The Fluid ID (Must be unique) + * @param aUnlocalName - Unlocalized Fluid Name + * @param luminosity - How bright is the fluid. + * @param density - completely arbitrary; negative density indicates that the fluid is + * lighter than air. Default value is approximately the real-life density of water in kg/m^3. + * @param temp - completely arbitrary; higher temperature indicates that the fluid is + * hotter than air. Default value is approximately the real-life room temperature of water in degrees Kelvin + * @param viscosity - completely arbitrary; negative values are not + * permissible. Default value is approximately the real-life density of water in m/s^2 (x10^-3). * + * Higher viscosity means that a fluid flows more slowly, like molasses. + * Lower viscosity means that a fluid flows more quickly, like helium. + * @param aRGB - a {@link Short[]} containing the RGB of the FluidPackage. + * @return - A fully constructed & registered {@linkplain FluidPackage} + */ public static FluidPackage generate(int aID, String aUnlocalName, int luminosity, int density, int temp, int viscosity, short[] aRGB) { @@ -91,7 +128,7 @@ public class FluidFactory { Fluid aGenFluid = fluid(aUnlocalName, luminosity, density, temp, viscosity, aRGB); Block aGenBlock = block(aGenFluid, aRGB); - ItemStack aGenBucket = bucket(); + ItemStack aGenBucket = bucket(aID); aFluidToGenerate = new FluidPackage(aID, aUnlocalName, aGenFluid, aGenBucket, aGenBlock); @@ -118,12 +155,16 @@ public class FluidFactory { return new FactoryFluid(aUnlocalName, luminosity, density, temp, viscosity, aRGB); } - private static ItemStack bucket() { - return null; + private static ItemStack bucket(int aID) { + return ItemGenericFluidBucket.registerFluidForBucket(aID); } private static Block block(Fluid aFluidForBlock, short[] aRGB) { - return new BlockFluidBase(aFluidForBlock, Material.water, aRGB); + if (aFluidForBlock != null) { + FluidRegistry.registerFluid(aFluidForBlock); + return new BlockFluidBase(aFluidForBlock, aRGB); + } + return Blocks.dirt; } /** diff --git a/src/Java/gtPlusPlus/core/fluids/FluidPackage.java b/src/Java/gtPlusPlus/core/fluids/FluidPackage.java index 7c8cf70c70..29f831776b 100644 --- a/src/Java/gtPlusPlus/core/fluids/FluidPackage.java +++ b/src/Java/gtPlusPlus/core/fluids/FluidPackage.java @@ -1,9 +1,26 @@ package gtPlusPlus.core.fluids; -import static gtPlusPlus.core.fluids.FluidFactory.*; - -import java.util.LinkedHashMap; -import java.util.Map; +import static gtPlusPlus.core.fluids.FluidFactory.mBlockToBucketMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBlockToFluidMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBlockToMetaMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBlockToNameMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBucketToBlockMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBucketToFluidMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBucketToMetaMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBucketToNameMap; +import static gtPlusPlus.core.fluids.FluidFactory.mFluidToBlockMap; +import static gtPlusPlus.core.fluids.FluidFactory.mFluidToBucketMap; +import static gtPlusPlus.core.fluids.FluidFactory.mFluidToMetaMap; +import static gtPlusPlus.core.fluids.FluidFactory.mFluidToNameMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToBlockMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToBucketMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToColourMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToFluidMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToNameMap; +import static gtPlusPlus.core.fluids.FluidFactory.mNameToBlockMap; +import static gtPlusPlus.core.fluids.FluidFactory.mNameToBucketMap; +import static gtPlusPlus.core.fluids.FluidFactory.mNameToFluidMap; +import static gtPlusPlus.core.fluids.FluidFactory.mNameToMetaMap; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @@ -45,6 +62,7 @@ public class FluidPackage { mMetaToBucketMap.put(aID, aBucket); mMetaToBlockMap.put(aID, aBlock); + mMetaToColourMap.put(aID, aFluid.getColor()); mID = aID; mName = aName; diff --git a/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java b/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java index ab2fe11d8c..d41fccb3ed 100644 --- a/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java +++ b/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java @@ -5,8 +5,13 @@ import java.util.List; import java.util.Map; import cpw.mods.fml.common.eventhandler.Event; +import gtPlusPlus.api.objects.GregtechException; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -22,10 +27,28 @@ import net.minecraftforge.event.entity.player.FillBucketEvent; public class ItemGenericFluidBucket extends ItemBucket { + private static IIcon mBaseBucketTexture; + private static IIcon mOverlayBucketTexture; + private static AutoMap mInternalFluidCache = new AutoMap(); + public ItemGenericFluidBucket(Block aFluid) { super(aFluid); this.setContainerItem(Items.bucket); this.maxStackSize = 1; + mInternalFluidCache.put(aFluid); + } + + public static ItemStack registerFluidForBucket(int aID) { + + if (FluidFactory.mMetaToBucketMap.containsKey(aID)) { + try { + throw new GregtechException(""+aID+" is already registered! Unable to register fluid: "+FluidFactory.mMetaToFluidMap.get(aID).getLocalizedName()); + } catch (GregtechException e) { + System.exit(0); + } + } + mInternalFluidCache.put(FluidFactory.mMetaToBlockMap.get(aID)); + return ItemUtils.simpleMetaStack(FluidFactory.mGenericBucket, aID, 1); } Map mIconCache = new LinkedHashMap(); @@ -36,7 +59,7 @@ public class ItemGenericFluidBucket extends ItemBucket { */ public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - Block isFull = FluidFactory.mBucketToBlockMap.get(aStack); + Block isFull = FluidFactory.mMetaToBlockMap.get(aStack.getItemDamage()); boolean flag = isFull == Blocks.air; MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(aWorld, aPlayer, flag); @@ -179,19 +202,27 @@ public class ItemGenericFluidBucket extends ItemBucket { } @Override - public int getMetadata(int p_77647_1_) { - // TODO Auto-generated method stub - return super.getMetadata(p_77647_1_); + public boolean getHasSubtypes() { + return mInternalFluidCache.size() > 0; } @Override - public boolean getHasSubtypes() { - return super.getHasSubtypes(); + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item, 1, 0)); + for (Block f : mInternalFluidCache) { + Integer aMeta; + if (f != null) { + aMeta = FluidFactory.mBlockToMetaMap.get(f); + if (aMeta != null) { + list.add(new ItemStack(item, 1, aMeta)); + } + } + } } @Override public int getMaxDamage() { - return super.getMaxDamage(); + return 512; } @Override @@ -210,21 +241,21 @@ public class ItemGenericFluidBucket extends ItemBucket { return 0; } - @Override - public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) { - // TODO Auto-generated method stub - super.getSubItems(p_150895_1_, p_150895_2_, p_150895_3_); - } - @Override public boolean isRepairable() { return false; } @Override - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - IIcon aTemp = mIconCache.get(stack.getItemDamage()); - return aTemp != null ? aTemp : super.getIcon(stack, renderPass, player, usingItem, useRemaining); + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (stack != null && renderPass == 1) { + return mOverlayBucketTexture; + } + else { + return mBaseBucketTexture; + } + /*IIcon aTemp = mIconCache.get(stack.getItemDamage()); + return aTemp != null ? aTemp : super.getIcon(stack, renderPass, player, usingItem, useRemaining);*/ } @Override @@ -234,7 +265,7 @@ public class ItemGenericFluidBucket extends ItemBucket { @Override public int getMaxDamage(ItemStack stack) { - return 0; + return 512; } @Override @@ -245,6 +276,43 @@ public class ItemGenericFluidBucket extends ItemBucket { @Override public int getItemEnchantability(ItemStack stack) { return 0; + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (pass == 1) { + return mOverlayBucketTexture; + } + else { + return mBaseBucketTexture; + } + } + + @Override + public void registerIcons(final IIconRegister i) { + mBaseBucketTexture = i.registerIcon("bucket_empty"); + mOverlayBucketTexture = i.registerIcon(CORE.MODID+":bucket.generic.overlay"); + } + + @Override + public boolean tryPlaceContainedLiquid(World p_77875_1_, int p_77875_2_, int p_77875_3_, int p_77875_4_) { + return tryPlaceContainedLiquid(Blocks.air, p_77875_1_, p_77875_2_, p_77875_3_, p_77875_4_); + } + + @Override + public int getColorFromItemStack(ItemStack aStack, int aPass) { + if (aPass == 0) { + return super.getColorFromItemStack(aStack, aPass); + } + else { + return FluidFactory.mMetaToColourMap.get(aStack.getItemDamage()); + } + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; } + } diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java index 721ebc8c24..4616ab0aa0 100644 --- a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java +++ b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java @@ -19,6 +19,7 @@ import gregtech.api.interfaces.IItemBehaviour; import gregtech.api.interfaces.IItemContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.ItemData; import gregtech.api.util.GT_LanguageManager; @@ -110,8 +111,8 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri aPumpName, // Name aEuMax, // Eu Storage (short) aTier, // Tier - "Can be used to remove fluids from GT machine input slots.", // Tooltip - EnumRarity.common, // Rarity + "Can be used to remove fluids from GT machine input & output slots.", // Tooltip + aTier <= 0 ? EnumRarity.common : aTier == 1 ? EnumRarity.uncommon : aTier == 2 ? EnumRarity.rare : aTier == 3 ? EnumRarity.epic : EnumRarity.common, // Rarity EnumChatFormatting.GRAY, // Desc colour false // Effect? ); @@ -183,7 +184,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return false; } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "unchecked" }) @Override public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { // aList.add("Meta: "+(aStack.getItemDamage()-mOffset)); @@ -498,7 +499,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return this; } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({ "unchecked" }) @Override @SideOnly(Side.CLIENT) public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { @@ -970,9 +971,10 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri if ((tTileEntity instanceof IGregTechTileEntity)) { return this.drainTankGT(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); } - /*else if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { + //Try support Standard Fluid Tanks too (May disable if dupes appear again) + else if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { return this.drainIFluidTank(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); - }*/ + } } } } @@ -1097,7 +1099,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri FluidStack f = aTileEntity.getFluid(); Logger.WARNING("Returning Fluid stack from tile. Found: " + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); - return f.copy(); + return f; } public FluidStack getStoredFluidOfVanillaTank(IFluidHandler aTileEntity) { @@ -1128,7 +1130,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri FluidStack f = ((IFluidTank) aTileEntity).getFluid(); if (aSetFluid == null) { aSetFluid = f; - aSetFluid.amount = 0; + aSetFluid.amount = f.amount; } int toDrain = (f.amount - aSetFluid.amount); FluidStack newStack; @@ -1146,44 +1148,48 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return false; } } - else { - Logger.WARNING("Tile Was instanceof IFluidHandler."); - FluidStack containedStack = null; - if ((IFluidHandler) aTileEntity != null) { - FluidTankInfo[] a1 = (((IFluidHandler) aTileEntity).getTankInfo(ForgeDirection.UNKNOWN)); - if (a1 != null) { - if (a1[0] != null) { - Logger.WARNING("Found Fluid in Tank."); - containedStack = a1[0].fluid; - } - } + else { + + //Rewrite Fluid handling for Vanilla type tanks + if (!IFluidHandler.class.isInstance(aTileEntity)) { + Logger.WARNING("Tile Was not an instance of IFluidHandler."); + return false; } - if (containedStack != null) { - if (aSetFluid == null) { - aSetFluid = containedStack; - aSetFluid.amount = 0; - } - int toDrain = (containedStack.amount - aSetFluid.amount); - Logger.WARNING("Found "+containedStack.amount+"L of "+containedStack.getLocalizedName()+". Trying to drain "+toDrain+"L."); - FluidStack newStack; - if (toDrain <= 0) { - Logger.WARNING("Draining Nothing"); - newStack = containedStack; - } else { - Logger.WARNING("Draining Something"); - newStack = ((IFluidTank) aTileEntity).drain(toDrain, true); + + + IFluidHandler aTank = (IFluidHandler) aTileEntity; + FluidStack aTankContents = null; + FluidTankInfo[] a1 = aTank.getTankInfo(ForgeDirection.UNKNOWN); + if (a1 != null) { + if (a1[0] != null) { + aTankContents = a1[0].fluid; + Logger.WARNING("Found Fluid in Tank. "+aTankContents.getLocalizedName()+" - "+aTankContents.amount); } - - if (newStack.isFluidEqual(aSetFluid) && newStack.amount == aSetFluid.amount) { - Logger.WARNING("Removed fluid from vanilla IFluidHandler successfully."); + } + if (aSetFluid == null) { + Logger.WARNING("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.WARNING("Tile Was instance of IFluidHandler. Trying to Drain "+aSetFluid.getLocalizedName()+" - "+aSetFluid.amount); + + if (a1 == null || aTankContents == null) { + Logger.WARNING("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!"); return true; - } else { - Logger.WARNING("Failed trying to remove fluid from vanilla IFluidHandler."); - return false; } - } else { - Logger.WARNING("Could not drain vanilla tank, IFluidHandler claims there is no fluid."); - return false; + else { + Logger.WARNING("Partially Drained! This is probably an error."); + return true; + } } } } else { @@ -1216,9 +1222,36 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri public FluidStack getStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity) { 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(); + } + } + } + } + } + Logger.WARNING("Returning Fluid stack from tile. Found: " + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); - return f.copy(); + return f; } public boolean setStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity, FluidStack aSetFluid) { @@ -1240,6 +1273,12 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri public boolean setStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity, FluidStack aSetFluid) { try { + + //Try Handle Outputs First + 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); diff --git a/src/Java/gtPlusPlus/plugin/agrichem/Core_Agrichem.java b/src/Java/gtPlusPlus/plugin/agrichem/Core_Agrichem.java new file mode 100644 index 0000000000..d515375149 --- /dev/null +++ b/src/Java/gtPlusPlus/plugin/agrichem/Core_Agrichem.java @@ -0,0 +1,43 @@ +package gtPlusPlus.plugin.agrichem; + +import gtPlusPlus.api.interfaces.IPlugin; +import gtPlusPlus.plugin.agrichem.fluids.FluidLoader; +import gtPlusPlus.plugin.manager.Core_Manager; + +public class Core_Agrichem implements IPlugin { + + final static Core_Agrichem mInstance; + + static { + mInstance = new Core_Agrichem(); + Core_Manager.registerPlugin(mInstance); + mInstance.log("Preparing "+mInstance.getPluginName()+" for use."); + } + + @Override + public boolean preInit() { + FluidLoader.generate(); + return true; + } + + @Override + public boolean init() { + return true; + } + + @Override + public boolean postInit() { + return true; + } + + @Override + public String getPluginName() { + return "GT++ Agrichemistry Module"; + } + + @Override + public String getPluginAbbreviation() { + return "FARM"; + } + +} diff --git a/src/Java/gtPlusPlus/plugin/agrichem/fluids/FluidLoader.java b/src/Java/gtPlusPlus/plugin/agrichem/fluids/FluidLoader.java new file mode 100644 index 0000000000..a60a8c09de --- /dev/null +++ b/src/Java/gtPlusPlus/plugin/agrichem/fluids/FluidLoader.java @@ -0,0 +1,21 @@ +package gtPlusPlus.plugin.agrichem.fluids; + +import gtPlusPlus.core.fluids.FluidFactory; + +public class FluidLoader { + + private static final int ID_DIRTY_WATER = 50; + private static final int ID_RAW_SEWERAGE = 51; + private static final int ID_GUANO = 52; + private static final int ID_POOPJUICE = 53; + + public static void generate() { + + FluidFactory.generate(ID_DIRTY_WATER, "dirtywater", new short[] {25, 25, 180}); + FluidFactory.generate(ID_RAW_SEWERAGE, "sewerage", new short[] {100, 45, 25}); + FluidFactory.generate(ID_GUANO, "guano", new short[] {175, 175, 180}); + FluidFactory.generate(ID_POOPJUICE, "poo", new short[] {75, 45, 10}); + + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java index e6fecf5d18..07c8a4a7ac 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java @@ -93,7 +93,7 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase g.mRecipeMap = null; } boolean ab = super.checkRecipeGeneric(); - Logger.INFO("Did Recipe? "+ab); + //Logger.INFO("Did Recipe? "+ab); return ab; } diff --git a/src/resources/assets/miscutils/textures/items/bucket.generic.overlay.png b/src/resources/assets/miscutils/textures/items/bucket.generic.overlay.png new file mode 100644 index 0000000000..1597a9cc4a Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/bucket.generic.overlay.png differ -- cgit From 6093c5e76fad9cb1ec8a44e7a638c0350f11e952 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 11 Mar 2019 18:04:40 +0000 Subject: % Updated Buffered Dynamo Tooltips to reflect changes made in https://github.com/Blood-Asp/GT5-Unofficial/pull/1518/commits/23d8fb6b6743b25bf24d320a647fccdc016a9930 --- .../GT_MetaTileEntity_Hatch_DynamoBuffer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java index e427587be0..9b730c84a3 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java @@ -2,7 +2,8 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; - +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -47,7 +48,14 @@ public class GT_MetaTileEntity_Hatch_DynamoBuffer extends GT_MetaTileEntity_Hatc @Override public String[] getDescription() { - String[] g = new String[]{"Generating electric Energy from Multiblocks", "Stores "+maxEUStore()+"EU", "Puts out up to 4 Amps", "Does not accept more than "+this.maxEUOutput()+"EU/t as input", "Large Turbines only supply 1A to this, other Multiblocks can inject more amps"}; + String[] g; + if (CORE.GTNH || (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechVersionAsInt() >= 50932)) { + g = new String[]{"Dynamo with internal storage and additional Amp capacity", "Capacity: "+maxEUStore()+"EU", "Voltage: "+this.maxEUOutput(), "Amperage In: 4", "Amperage Out: 4"}; + + } + else { + g = new String[]{"Dynamo with internal storage and additional Amp capacity", "Stores "+maxEUStore()+"EU", "Amperage In: 4", "Amperage Out: 4", "Does not accept more than "+this.maxEUOutput()+"EU/t as input", "Large Turbines only supply 1A to this, other Multiblocks can inject more amps"}; + } return g; } -- cgit From dbe1827984f9dd1e87d500882c541181bdaeb542 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 12 Mar 2019 05:08:33 +0000 Subject: + Added framework for additional Oil chemistry in future updates. + Added additional processes for obtaining Kerosene. % Mild rebalance to GT++ Rocket Fuels. % Swapped Coal by-products (Coal Tar, Coal Tar Oil and Sulfuric Coal Tar Oil) from Gas Turbine fuel to Semifluid fuel. % Allowed ItemPackages to register themselves to the onLoadComplete() event. $ Fixed GT++ Rocket Fuels being unusable in Rocket Engines. $ Fixed Tooltip on GC Fuel loader when the GC-ASM is not active. --- .../api/objects/minecraft/ItemPackage.java | 19 +- src/Java/gtPlusPlus/core/common/CommonProxy.java | 1 + .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 26 ++ .../gtPlusPlus/core/item/chemistry/CoalTar.java | 28 ++- .../gtPlusPlus/core/item/chemistry/OilChem.java | 210 ++++++++++++++++ .../core/item/chemistry/RocketFuels.java | 272 +++++++++++++++++++-- .../core/util/minecraft/MaterialUtils.java | 18 ++ .../core/util/minecraft/RecipeUtils.java | 9 + .../galacticraft/handler/HandlerTooltip_GC.java | 37 +-- .../GregtechRocketFuelGeneratorBase.java | 101 ++++++-- .../GregtechMetaTileEntityRocketFuelGenerator.java | 8 +- 11 files changed, 661 insertions(+), 68 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/chemistry/OilChem.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java index e725d250cc..fa85f23cf3 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java @@ -1,13 +1,21 @@ package gtPlusPlus.api.objects.minecraft; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.core.handler.COMPAT_HANDLER; public abstract class ItemPackage implements RunnableWithInfo { public ItemPackage() { + this(false); + } + + public ItemPackage(boolean hasExtraLateRun) { // Register for late run - COMPAT_HANDLER.mObjectsToRunInPostInit.put(this); + COMPAT_HANDLER.mObjectsToRunInPostInit.put(this); + if (hasExtraLateRun) { + COMPAT_HANDLER.mObjectsToRunInOnLoadComplete.put(this); + } init(); } @@ -37,5 +45,14 @@ public abstract class ItemPackage implements RunnableWithInfo { public abstract void fluids(); + /** + * Override this to handle GT Recipe map manipulation after they're Baked. + * @param event - the {@link FMLLoadCompleteEvent}. + * @return - Did we do anything? + */ + public boolean onLoadComplete(FMLLoadCompleteEvent event) { + return false; + }; + } diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 7d4644f275..301ca992a4 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -183,6 +183,7 @@ public class CommonProxy { public void onLoadComplete(FMLLoadCompleteEvent event) { COMPAT_IntermodStaging.onLoadComplete(event); + COMPAT_HANDLER.onLoadComplete(event); } public void registerNetworkStuff() { diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index a5b876efb6..1e3cb0ffbb 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -4,11 +4,13 @@ import static gtPlusPlus.core.lib.LoadedMods.Gregtech; import java.util.*; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.common.compat.*; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; @@ -19,6 +21,7 @@ import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.recipe.*; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; import gtPlusPlus.xmod.gregtech.registration.gregtech.*; import net.minecraft.item.ItemStack; @@ -207,11 +210,18 @@ public class COMPAT_HANDLER { RecipeGen_Recycling.executeGenerators(); runQueuedMisc(); } + + + + public static void onLoadComplete(FMLLoadCompleteEvent event) { + runQueuedOnLoadComplete(event); + } public static final AutoMap> mRecipesToGenerate = new AutoMap>(); public static final AutoMap> mGtRecipesToGenerate = new AutoMap>(); public static final AutoMap> mObjectsToRunInPostInit = new AutoMap>(); + public static final AutoMap mObjectsToRunInOnLoadComplete = new AutoMap(); public static void runQueuedRecipes() { //Add autogenerated Recipes from Item Components @@ -249,4 +259,20 @@ public class COMPAT_HANDLER { } } + + /** + * Generally used to register GT recipe map changes after they've been populated. + */ + public static void runQueuedOnLoadComplete(FMLLoadCompleteEvent event) { + for (ItemPackage m : mObjectsToRunInOnLoadComplete) { + try { + m.onLoadComplete(event); + } + catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] "+m.getInfoData()); + } + + } + } } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java index 76827b32d1..1f10261b36 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java @@ -24,6 +24,7 @@ import net.minecraftforge.fluids.FluidStack; public class CoalTar extends ItemPackage { public static Fluid Coal_Gas; + public static Fluid Coal_Oil; public static Fluid Ethylene; public static Fluid Benzene; public static Fluid Ethylbenzene; @@ -185,14 +186,24 @@ public class CoalTar extends ItemPackage { 900, //aDuration 30,//aEUt false //Hidden? - ); + ); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(5), //Circuit + FluidUtils.getFluidStack("fluid.coaltar", 1430), //aInput + FluidUtils.getFluidStack("fluid.kerosene", 360), //aOutput + 300, //aDuration + 64,//aEUt + false //Hidden? + ); + GT_Values.RA.addDistillationTowerRecipe( FluidUtils.getFluidStack("fluid.coaltar", 1000), new FluidStack[]{ - FluidUtils.getFluidStack("fluid.coaltaroil", 600), //aOutput - FluidUtils.getFluidStack("liquid_naphtha", 150), //aOutput - FluidUtils.getFluidStack("fluid.ethylbenzene", 200), //aOutput + FluidUtils.getFluidStack("fluid.coaltaroil", 500), //aOutput + FluidUtils.getFluidStack("liquid_naphtha", 100), //aOutput + FluidUtils.getFluidStack("fluid.ethylbenzene", 150), //aOutput FluidUtils.getFluidStack("fluid.anthracene", 50), //aOutput + FluidUtils.getFluidStack("fluid.kerosene", 200), //aOutput }, null, 900, @@ -343,14 +354,13 @@ public class CoalTar extends ItemPackage { recipeLithiumHydroperoxide(); recipeLithiumPeroxide(); - recipeEthylBenzineFuelsIntoHeavyFuel(); - + recipeEthylBenzineFuelsIntoHeavyFuel(); //Burn the coal gas! GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), null, 32, 3); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), null, 64, 3); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), null, 128, 3); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), 32); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), 64); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), 128); return true; } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java b/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java new file mode 100644 index 0000000000..fd168f24f2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java @@ -0,0 +1,210 @@ +package gtPlusPlus.core.item.chemistry; + +import java.util.ArrayList; + +import forestry.plugins.PluginCore; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +public class OilChem extends ItemPackage { + + /** + * Fluids + */ + + // Poop Juice + public static Fluid PoopJuice; + // Manure Slurry + public static Fluid ManureSlurry; + // Fertile Manure Slurry + public static Fluid FertileManureSlurry; + + /** + * Items + */ + + // Manure Byproducts + public static Item dustManureByproducts; + // Organic Fertilizer + public static Item dustOrganicFertilizer; + // Dirt + public static Item dustDirt; + + // Poop Juice + // vv - Centrifuge + // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny + // piles + // vv - Chem Reactor - Add Peat, Meat + // Organic Fertilizer + // vv - Dehydrate + // Fertilizer + + // Poop Juice + // vv - Mixer - Add Blood, Bone, Meat (1000L Poo, 200L Blood, x2 Bone, x3 Meat) + // Fertile Manure Slurry + // vv - Chem Reactor - Add Peat x1.5 + // Organic Fertilizer x3 + // vv - Dehydrate + // Fertilizer + + + @Override + public void items() { + // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", + "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; + + // Basically Guano + dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", + "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; + + // Dirt Dust :) + dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + } + + @Override + public void blocks() { + // None yet + } + + @Override + public void fluids() { + // Sewage + PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32 + 175, + new short[] { 100, 70, 30, 100 }, null, null, 0, true); + + // Sewage + ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39 + 175, + new short[] { 75, 45, 15, 100 }, null, null, 0, true); + + // Sewage + FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", + 45 + 175, new short[] { 65, 50, 15, 100 }, null, null, 0, true); + } + + private static AutoMap mMeats = new AutoMap(); + private static AutoMap mFish = new AutoMap(); + private static AutoMap mFruits = new AutoMap(); + private static AutoMap mVege = new AutoMap(); + private static AutoMap mNuts = new AutoMap(); + private static AutoMap mSeeds = new AutoMap(); + private static AutoMap mPeat = new AutoMap(); + private static AutoMap mBones = new AutoMap(); + private static AutoMap mBoneMeal = new AutoMap(); + + private static AutoMap mList_Master_Meats = new AutoMap(); + private static AutoMap mList_Master_FruitVege = new AutoMap(); + private static AutoMap mList_Master_Bones = new AutoMap(); + private static AutoMap mList_Master_Seeds = new AutoMap(); + + private static void processAllOreDict() { + processOreDict("listAllmeatraw", mMeats); + processOreDict("listAllfishraw", mFish); + processOreDict("listAllfruit", mFruits); + processOreDict("listAllVeggie", mVege); + processOreDict("listAllnut", mNuts); + processOreDict("listAllSeed", mSeeds); + processOreDict("brickPeat", mPeat); + processOreDict("bone", mBones); + processOreDict("dustBone", mBoneMeal); + // Just make a mega list, makes life easier. + if (!mMeats.isEmpty()) { + for (ItemStack g : mMeats) { + mList_Master_Meats.put(g); + } + } + if (!mFish.isEmpty()) { + for (ItemStack g : mFish) { + mList_Master_Meats.put(g); + } + } + if (!mFruits.isEmpty()) { + for (ItemStack g : mFruits) { + mList_Master_FruitVege.put(g); + } + } + if (!mVege.isEmpty()) { + for (ItemStack g : mVege) { + mList_Master_FruitVege.put(g); + } + } + if (!mNuts.isEmpty()) { + for (ItemStack g : mNuts) { + mList_Master_FruitVege.put(g); + } + } + if (!mSeeds.isEmpty()) { + for (ItemStack g : mSeeds) { + mList_Master_Seeds.put(g); + } + } + if (!mBoneMeal.isEmpty()) { + for (ItemStack g : mBoneMeal) { + mList_Master_Bones.put(g); + } + } + if (!mBones.isEmpty()) { + for (ItemStack g : mBones) { + mList_Master_Bones.put(g); + } + } + } + + private static void processOreDict(String aOreName, AutoMap aMap) { + ArrayList aTemp = OreDictionary.getOres(aOreName); + if (!aTemp.isEmpty()) { + for (ItemStack stack : aTemp) { + aMap.put(stack); + } + } + } + + private static void addBasicSlurryRecipes() {} + + private static void addAdvancedSlurryRecipes() {} + + private static void addBasicOrganiseFertRecipes() {} + + private static void addAdvancedOrganiseFertRecipes() {} + + private static void addMiscRecipes() {} + + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Failed to generate recipes for AgroChem."; + } + + @Override + public boolean generateRecipes() { + + // Organise OreDict + processAllOreDict(); + + // Slurry Production + addBasicSlurryRecipes(); + addAdvancedSlurryRecipes(); + + // Organic Fert. Production + addBasicOrganiseFertRecipes(); + addAdvancedOrganiseFertRecipes(); + + addMiscRecipes(); + return true; + } +} diff --git a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java index ddac7f1d88..f2b5d0683c 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -2,21 +2,26 @@ package gtPlusPlus.core.item.chemistry; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; public class RocketFuels extends ItemPackage { @@ -24,7 +29,9 @@ public class RocketFuels extends ItemPackage { public static HashSet mValidRocketFuelNames = new HashSet(); public static HashMap mValidRocketFuels = new HashMap(); - public static Fluid Kerosene; + public static Fluid Oil_Heavy; + public static Fluid Diesel; + public static Fluid Kerosene; public static Fluid RP1; public static Fluid Nitrogen_Tetroxide; public static Fluid Hydrazine; @@ -46,15 +53,21 @@ public class RocketFuels extends ItemPackage { public static Item Formaldehyde_Catalyst; public static void createKerosene(){ - FluidStack fuelA = FluidUtils.getFluidStack("diesel", 400); - FluidStack fuelB = FluidUtils.getFluidStack("fuel", 400); + + + + FluidStack fuelA = FluidUtils.getFluidStack("diesel", 300); + FluidStack fuelB = FluidUtils.getFluidStack("fuel", 300); + + + if (fuelA != null){ //GT_Values.RA.addDistilleryRecipe(23, fuelA, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); - GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); + GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(Kerosene, 100), 200, 64, false); } if (fuelA == null && fuelB != null){ //GT_Values.RA.addDistilleryRecipe(23, fuelB, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); - GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelB, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); + GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelB, FluidUtils.getFluidStack(Kerosene, 100), 200, 64, false); } } @@ -187,9 +200,9 @@ public class RocketFuels extends ItemPackage { } - private static void addRocketFuelsToMap() { - AutoMap mRocketFuels = new AutoMap(); - mRocketFuels.put(new Recipe_GT( + private static void addRocketFuelsToMap() { + HashMap mRocketFuels = new LinkedHashMap(); + mRocketFuels.put(0, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -201,7 +214,7 @@ public class RocketFuels extends ItemPackage { 0, 256)); //Fuel Value - mRocketFuels.put(new Recipe_GT( + mRocketFuels.put(1, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -213,7 +226,7 @@ public class RocketFuels extends ItemPackage { 0, 512)); //Fuel Value - mRocketFuels.put(new Recipe_GT( + mRocketFuels.put(2, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -225,7 +238,7 @@ public class RocketFuels extends ItemPackage { 0, 768)); //Fuel Value - mRocketFuels.put(new Recipe_GT( + mRocketFuels.put(3, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -239,15 +252,15 @@ public class RocketFuels extends ItemPackage { //Add in default Diesel for the Buggy - mValidRocketFuelNames.add(Materials.Fuel.getFluid(1).getFluid().getName()); - mValidRocketFuels.put(-1, Materials.Fuel.getFluid(1).getFluid()); - - int mID = 0; - for (Recipe_GT r : mRocketFuels) { - if (r != null) { - mValidRocketFuelNames.add(r.mFluidInputs[0].getFluid().getName()); - mValidRocketFuels.put(mID++, r.mFluidInputs[0].getFluid()); - Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.add(r); + mValidRocketFuels.put(-1, Diesel); + + mValidRocketFuelNames.add(FluidRegistry.getFluidName(Diesel)); + for (int mID : mRocketFuels.keySet()) { + Recipe_GT aFuelRecipe = mRocketFuels.get(mID); + if (aFuelRecipe != null) { + mValidRocketFuelNames.add(FluidRegistry.getFluidName(aFuelRecipe.mFluidInputs[0].getFluid())); + mValidRocketFuels.put(mID, aFuelRecipe.mFluidInputs[0].getFluid()); + Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.add(aFuelRecipe); } } @@ -430,6 +443,214 @@ public class RocketFuels extends ItemPackage { return true; } + @Override + public boolean onLoadComplete(FMLLoadCompleteEvent event) { + + + if (MathUtils.randInt(1, 2) > 0) { + return false; + } + + + Materials aMaterial_Chloramine = MaterialUtils.getMaterial("Chloramine"); + Materials aMaterial_Dimethylamine = MaterialUtils.getMaterial("Dimethylamine"); + Materials aMaterial_DilutedHydrochloricAcid = MaterialUtils.getMaterial("DilutedHydrochloricAcid"); + Materials aMaterial_NitrogenDioxide = MaterialUtils.getMaterial("NitrogenDioxide"); + Materials aMaterial_DinitrogenTetroxide = MaterialUtils.getMaterial("DinitrogenTetroxide"); + Materials aMaterial_Dimethylhydrazine = MaterialUtils.getMaterial("Dimethylhydrazine"); + + Materials aMaterial_Oxygen = Materials.Oxygen; + Materials aMaterial_Water = Materials.Water; + Materials aMaterial_HypochlorousAcid = MaterialUtils.getMaterial("HypochlorousAcid"); + Materials aMaterial_Ammonia = MaterialUtils.getMaterial("Ammonia"); + Materials aMaterial_Methanol = MaterialUtils.getMaterial("Methanol"); + + if (aMaterial_Chloramine == null || aMaterial_Dimethylamine == null || aMaterial_DilutedHydrochloricAcid == null + || aMaterial_Dimethylhydrazine == null || aMaterial_NitrogenDioxide == null || aMaterial_DinitrogenTetroxide == null + || aMaterial_HypochlorousAcid == null || aMaterial_Ammonia == null || aMaterial_Methanol == null) { + return false; + } + + + ItemStack aCellEmpty = CI.emptyCells(1); + ItemStack aCellWater = aMaterial_Water.getCells(1); + ItemStack aCellOxygen = aMaterial_Oxygen.getCells(1); + ItemStack aCellChloramine = aMaterial_Chloramine.getCells(1); + ItemStack aCellDimethylamine = aMaterial_Dimethylamine.getCells(1); + ItemStack aCellDilutedHydrochloricAcid = aMaterial_DilutedHydrochloricAcid.getCells(1); + ItemStack aCellNitrogenDioxide = aMaterial_NitrogenDioxide.getCells(1); + ItemStack aCellDinitrogenTetroxide = aMaterial_DinitrogenTetroxide.getCells(1); + ItemStack aCellDimethylhydrazine = aMaterial_Dimethylhydrazine.getCells(1); + + + + + + + GT_Recipe aChemReactor_1 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_2 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + + + + GT_Recipe aChemReactor_Basic_1 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Basic_2 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Basic_3 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Basic_4 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + + + + + + + + + + + + + GT_Recipe aChemReactor_Adv_1 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Adv_2 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + + + + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + + + + + + + /* GT_Values.RA.addChemicalRecipe( Materials.Chloramine.getCells(2), GT_Utility.getIntegratedCircuit(1), Materials.Dimethylamine.getGas(5000), Materials.Dimethylhydrazine.getFluid(6000), Materials.DilutedHydrochloricAcid.getCells(1), Materials.Empty.getCells(1), 960, 480); + GT_Values.RA.addChemicalRecipe( Materials.Dimethylamine.getCells(5), GT_Utility.getIntegratedCircuit(1), Materials.Chloramine.getFluid(2000), Materials.Dimethylhydrazine.getFluid(6000), Materials.DilutedHydrochloricAcid.getCells(1), Materials.Empty.getCells(4), 960, 480); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Chloramine.getCells(2), Materials.Empty.getCells(4), Materials.Dimethylamine.getGas(5000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), GT_Values.NI, 960, 480); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Dimethylamine.getCells(5), Materials.Empty.getCells(1), Materials.Chloramine.getFluid(2000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), GT_Values.NI, 960, 480); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Dimethylamine.getCells(5), Materials.Chloramine.getCells(2), Materials.Chloramine.getFluid(2000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), Materials.DilutedHydrochloricAcid.getCells(1), 960, 480); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(24)}, new FluidStack[]{Materials.HypochlorousAcid.getFluid(3000), Materials.Ammonia.getGas(8000), Materials.Methanol.getFluid(12000)}, new FluidStack[]{Materials.Dimethylhydrazine.getFluid(12000), Materials.DilutedHydrochloricAcid.getFluid(2000), Materials.Water.getFluid(9000)}, null, 1040, 480); + + GT_Values.RA.addChemicalRecipe(GT_Utility.getIntegratedCircuit(2), GT_Values.NI, Materials.NitrogenDioxide.getGas(1000), Materials.DinitrogenTetroxide.getGas(1000), GT_Values.NI, 640); + GT_Values.RA.addChemicalRecipe(Materials.NitrogenDioxide.getCells(1), GT_Utility.getIntegratedCircuit(2), GT_Values.NF, Materials.DinitrogenTetroxide.getGas(1000), Materials.Empty.getCells(1), 640); + GT_Values.RA.addChemicalRecipe(Materials.NitrogenDioxide.getCells(1), GT_Utility.getIntegratedCircuit(12), GT_Values.NF, GT_Values.NF, Materials.DinitrogenTetroxide.getCells(1), 640); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(23)}, new FluidStack[]{Materials.Ammonia.getGas(8000), Materials.Oxygen.getGas(7000)}, new FluidStack[]{Materials.DinitrogenTetroxide.getGas(6000), Materials.Water.getFluid(9000)}, null, 480, 30); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(23)}, new FluidStack[]{Materials.Nitrogen.getGas(2000), Materials.Hydrogen.getGas(6000), Materials.Oxygen.getGas(7000)}, new FluidStack[]{Materials.DinitrogenTetroxide.getGas(6000), Materials.Water.getFluid(9000)}, null, 1100, 480); + + GT_Values.RA.addMixerRecipe(Materials.Dimethylhydrazine.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.DinitrogenTetroxide.getGas(1000), new FluidStack(ItemList.sRocketFuel, 2000), Materials.Empty.getCells(1), 60, 16); + GT_Values.RA.addMixerRecipe(Materials.DinitrogenTetroxide.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Dimethylhydrazine.getFluid(1000), new FluidStack(ItemList.sRocketFuel, 2000), Materials.Empty.getCells(1), 60, 16); + GT_Values.RA.addMixerRecipe(Materials.Dimethylhydrazine.getCells(2), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Oxygen.getGas(1000), new FluidStack(ItemList.sRocketFuel, 3000), Materials.Empty.getCells(2), 60, 16); + GT_Values.RA.addMixerRecipe(Materials.Oxygen.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Dimethylhydrazine.getFluid(2000), new FluidStack(ItemList.sRocketFuel, 3000), Materials.Empty.getCells(1), 60, 16); + + + */ + + + + + + + + + + //Get Rocket Fuel + + //Find recipes using default values + + //Remove + + //Rebake map + + return true; + }; + @Override public void items() { Formaldehyde_Catalyst = ItemUtils.generateSpecialUseDusts("FormaldehydeCatalyst", "Formaldehyde Catalyst", "Fe16V1", Utils.rgbtoHexValue(25, 5, 25))[0]; @@ -441,9 +662,16 @@ public class RocketFuels extends ItemPackage { @Override public void fluids() { + + //Register default fluids + Diesel = MaterialUtils.getMaterial("Fuel", "Diesel").getFluid(1).getFluid(); + Oil_Heavy = MaterialUtils.getMaterial("OilHeavy", "Oil").getFluid(1).getFluid(); + + //Create Kerosene Kerosene = FluidUtils.generateFluidNonMolten("Kerosene", "Kerosene", 500, new short[]{150, 40, 150, 100}, null, null); - + CoalTar.Coal_Oil = Kerosene; + //RP! Focket Fuel RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1 Rocket Fuel", 500, new short[]{210, 50, 50, 100}, null, null); diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 842b8eecb2..a7fc4507e8 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -348,12 +348,30 @@ public class MaterialUtils { TextureSet o = (r != null && r.isPresent() && r.get() != null) ? r.get() : null; return o;*/ } + + + + public static Materials getMaterial(String aMaterialName, String aFallbackMaterialName) { + Materials g = getMaterial(aMaterialName); + if (g == null) { + g = getMaterial(aFallbackMaterialName); + } + if (g == null) { + Logger.INFO("Failed finding material '"+aMaterialName+"' & fallback '"+aFallbackMaterialName+"', returning _NULL."); + g = Materials._NULL; + } + return g; + } public static Materials getMaterial(String aMaterialName) { Materials m = gtPlusPlus.xmod.gregtech.common.StaticFields59.getMaterial(aMaterialName); if (m == null) { m = getMaterialByName(aMaterialName); } + if (m == null) { + Logger.INFO("Failed finding material '"+aMaterialName+"', returning _NULL."); + m = Materials._NULL; + } return m; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index cc71b910c6..774c8b6f13 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -8,6 +8,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.Materials; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; @@ -573,5 +574,13 @@ public static int mInvalidID = 1; } + public static boolean removeGtRecipe(GT_Recipe aRecipeToRemove, GT_Recipe_Map aRecipeMap) { + if (aRecipeMap.mRecipeList.contains(aRecipeToRemove)) { + return aRecipeMap.mRecipeList.remove(aRecipeToRemove); + } + return false; + } + + } diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java index 58331c4300..64f1cfbe23 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java @@ -1,6 +1,8 @@ package gtPlusPlus.xmod.galacticraft.handler; import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.LinkedHashMap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; @@ -18,7 +20,7 @@ public class HandlerTooltip_GC { private static Block mBlock; private static Class oMainClass; private static Class oFuelLoaderClass; - private static String[] mFuelNames; + private static HashMap mFuelNames; @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { @@ -30,8 +32,7 @@ public class HandlerTooltip_GC { if (GCBlocks != null) { oMainClass = GCBlocks; - Class GCFuelLoader = Class - .forName("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader"); + Class GCFuelLoader = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader"); if (GCFuelLoader != null) { oFuelLoaderClass = GCFuelLoader; @@ -49,24 +50,26 @@ public class HandlerTooltip_GC { } catch (Throwable t) { } } - if (mFuelNames == null || mFuelNames.length == 0) { - mFuelNames = new String[RocketFuels.mValidRocketFuels.size()]; - int slot = 0; - for (Fluid f : RocketFuels.mValidRocketFuels.values()) { - mFuelNames[slot++] = f.getLocalizedName(); + + if (mFuelNames == null || mFuelNames.isEmpty()) { + mFuelNames = new LinkedHashMap(); + for (int aMapKey : RocketFuels.mValidRocketFuels.keySet()) { + Fluid aFuel = RocketFuels.mValidRocketFuels.get(aMapKey); + if (aFuel != null) { + mFuelNames.put(aMapKey, aFuel.getLocalizedName()); + } } - } - if (mItemBlock != null) { + } + if (mItemBlock != null && !mFuelNames.isEmpty()) { Item aTempItem = event.itemStack.getItem(); Block aTempBlock = Block.getBlockFromItem(aTempItem); - if (aTempItem == mItemBlock || oFuelLoaderClass.isInstance(aTempBlock) - || event.itemStack.getUnlocalizedName().toLowerCase().contains("fuelloader")) { - int aTier = 0; - for (String s : mFuelNames) { - if (s != null) { - event.toolTip.add("Tier "+aTier+": "+s); + if (aTempItem == mItemBlock || oFuelLoaderClass.isInstance(aTempBlock) || event.itemStack.getUnlocalizedName().toLowerCase().contains("fuelloader")) { + for (int aMapKey : mFuelNames.keySet()) { + String aFuel = mFuelNames.get(aMapKey); + if (aFuel != null) { + event.toolTip.add("Tier "+(aMapKey+1)+": "+aFuel); } - } + } } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java index a88d6a4832..15c6fa00f6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java @@ -15,8 +15,9 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; - +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import net.minecraftforge.fluids.FluidStack; @@ -144,7 +145,7 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public boolean isOutputFacing(final byte aSide) { - return true; + return this.getBaseMetaTileEntity().getFrontFacing() == aSide; } @Override @@ -154,7 +155,7 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public long maxEUOutput() { - return this.getBaseMetaTileEntity().isAllowedToWork() ? V[this.mTier] : 0; + return V[this.mTier]; } @Override @@ -164,22 +165,22 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public boolean doesFillContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return false; } @Override public boolean doesEmptyContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return true; } @Override public boolean canTankBeFilled() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return true; } @Override public boolean canTankBeEmptied() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return false; } @Override @@ -199,6 +200,61 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + + + //super.onPostTick(aBaseMetaTileEntity, aTick); + + /*if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { + int tFuelValue; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + tFuelValue = this.getFuelValue(this.mFluid); + int tConsumed = this.consumedFluidPerOperation(this.mFluid); + if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { + long tFluidAmountToUse = Math.min((long) (this.mFluid.amount / tConsumed), + (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); + if (tFluidAmountToUse > 0L && aBaseMetaTileEntity + .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + this.mFluid.amount = (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); + } + } + } + + if (this.mInventory[this.getInputSlot()] != null + && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + + this.getMinimumStoredEU() + && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { + tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity + .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); + }*/ + + + + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { if (this.mFluid == null) { if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { @@ -211,16 +267,14 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ } } else { final int tFuelValue = this.getFuelValue(this.mFluid), tConsumed = this.consumedFluidPerOperation(this.mFluid); - if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed)) { + if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount >= tConsumed)) { final long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, (((this.maxEUOutput() * 20) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - if ((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ - if (this.useFuel){ - this.mFluid.amount -= tFluidAmountToUse * tConsumed; - this.useFuel = false; - } - else { - this.useFuel = true; - } + if ((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ + useFuel = Utils.invertBoolean(useFuel); + int aSafeFloor= (int) Math.max(((tFluidAmountToUse * tConsumed)/3), 1); + int toConsumeTrue = (int) (useFuel ? aSafeFloor : 0); + //Logger.INFO("True consumption: "+toConsumeTrue+" | Consuming this tick? "+useFuel); + this.mFluid.amount -= toConsumeTrue; PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution()); } } @@ -260,14 +314,25 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ FluidStack tLiquid; final Collection tRecipeList = this.getRecipes().mRecipeList; if (tRecipeList != null) { + //Logger.INFO("Step A"); for (final GT_Recipe tFuel : tRecipeList) { - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) { + //Logger.INFO("Step B"); + if ((tLiquid = tFuel.mFluidInputs[0]) != null) { + //Logger.INFO("Step C"); if (aLiquid.isFluidEqual(tLiquid)) { - return (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * this.consumedFluidPerOperation(tLiquid)) / 100); + //Logger.INFO("Found some fuel?"); + int aperOp = this.consumedFluidPerOperation(tLiquid); + int aConsume = (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * aperOp) / 100); + //Logger.INFO("Fuel Value: "+tFuel.mSpecialValue); + //Logger.INFO("Efficiency: "+getEfficiency()); + //Logger.INFO("Consumed per op: "+aperOp); + //Logger.INFO("Consuming "+aConsume); + return aConsume; } } } } + //Logger.INFO("No Fuel Value | Valid? "+(aLiquid != null)); return 0; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java index 288501086b..1d81e44e1f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -15,6 +15,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -41,6 +42,7 @@ extends GregtechRocketFuelGeneratorBase { @Override public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + Logger.INFO("Valid Fuels: "+Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.mRecipeList.size()); return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); } @@ -60,7 +62,10 @@ extends GregtechRocketFuelGeneratorBase { @Override public int getEfficiency() { - return ((40+((this.mTier) * 16))/4)+(this.mTier); + int eff = ((40+((this.mTier) * 16))/4)+(this.mTier); + + return eff; + } @Override @@ -69,6 +74,7 @@ extends GregtechRocketFuelGeneratorBase { if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); } + Logger.INFO("Fuel Item is worth: "+rValue); return rValue; } -- cgit From e2ea3eda910e8b8147bf64d786be72b6a7cb1bca Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 12 Mar 2019 05:33:35 +0000 Subject: - Removed some logging. % Updated CircleCI config. --- .circleci/config.yml | 6 ++++++ .../base/generators/GregtechRocketFuelGeneratorBase.java | 8 +++----- .../GregtechMetaTileEntityRocketFuelGenerator.java | 13 ++++--------- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/.circleci/config.yml b/.circleci/config.yml index c52e759544..ec060fc967 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,6 +13,12 @@ jobs: steps: - checkout + + - run: + name: Run build + command: export TERM=${TERM:-dumb} + # && ./gradlew clean build + - run: sudo chmod +x gradlew #https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/forge-1.7.10-10.13.4.1614-1.7.10-src.zip diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java index 15c6fa00f6..b6e7b35d68 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java @@ -4,10 +4,6 @@ import static gregtech.api.enums.GT_Values.V; import java.util.Collection; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -15,10 +11,12 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_BasicTank { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java index 1d81e44e1f..6a42232e40 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -1,9 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.item.ItemStack; - import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.ItemList; @@ -15,10 +12,10 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; public class GregtechMetaTileEntityRocketFuelGenerator extends GregtechRocketFuelGeneratorBase { @@ -26,7 +23,7 @@ extends GregtechRocketFuelGeneratorBase { public int mEfficiency; public GregtechMetaTileEntityRocketFuelGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires Rocket Fuels.", new ITexture[0]); + super(aID, aName, aNameRegional, aTier, "Requires GT++ Rocket Fuels", new ITexture[0]); this.onConfigLoad(); } @@ -42,7 +39,7 @@ extends GregtechRocketFuelGeneratorBase { @Override public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - Logger.INFO("Valid Fuels: "+Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.mRecipeList.size()); + //Logger.INFO("Valid Fuels: "+Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.mRecipeList.size()); return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); } @@ -62,8 +59,7 @@ extends GregtechRocketFuelGeneratorBase { @Override public int getEfficiency() { - int eff = ((40+((this.mTier) * 16))/4)+(this.mTier); - + int eff = ((40+((this.mTier) * 16))/4)+(this.mTier); return eff; } @@ -74,7 +70,6 @@ extends GregtechRocketFuelGeneratorBase { if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); } - Logger.INFO("Fuel Item is worth: "+rValue); return rValue; } -- cgit From bd05cb931933a8c2475dc77e394d3db83d8b109b Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 13 Mar 2019 14:41:37 +0000 Subject: - Removed some unused classes causing compile time dependencies on OpenBlocks. --- src/Java/gtPlusPlus/xmod/ob/CallbackObject.java | 20 ------------- .../xmod/ob/CustomSprinklerInventory.java | 35 ---------------------- 2 files changed, 55 deletions(-) delete mode 100644 src/Java/gtPlusPlus/xmod/ob/CallbackObject.java delete mode 100644 src/Java/gtPlusPlus/xmod/ob/CustomSprinklerInventory.java (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/ob/CallbackObject.java b/src/Java/gtPlusPlus/xmod/ob/CallbackObject.java deleted file mode 100644 index 89c2952a54..0000000000 --- a/src/Java/gtPlusPlus/xmod/ob/CallbackObject.java +++ /dev/null @@ -1,20 +0,0 @@ -package gtPlusPlus.xmod.ob; - -import net.minecraft.inventory.IInventory; -import openblocks.common.tileentity.TileEntitySprinkler; -import openmods.api.IInventoryCallback; - -public class CallbackObject implements IInventoryCallback { - - private TileEntitySprinkler mTile; - - CallbackObject(TileEntitySprinkler aTile){ - mTile = aTile; - } - - @Override - public void onInventoryChanged(IInventory inventory, int slotNumber) { - mTile.updateEntity(); - } - -} diff --git a/src/Java/gtPlusPlus/xmod/ob/CustomSprinklerInventory.java b/src/Java/gtPlusPlus/xmod/ob/CustomSprinklerInventory.java deleted file mode 100644 index 60c340592b..0000000000 --- a/src/Java/gtPlusPlus/xmod/ob/CustomSprinklerInventory.java +++ /dev/null @@ -1,35 +0,0 @@ -package gtPlusPlus.xmod.ob; - -import java.util.HashMap; - -import gtPlusPlus.api.objects.Logger; -import net.minecraft.item.ItemStack; -import openblocks.common.tileentity.TileEntitySprinkler; -import openmods.inventory.TileEntityInventory; - -public class CustomSprinklerInventory extends TileEntityInventory { - private final TileEntitySprinkler owner; - - public CustomSprinklerInventory(TileEntitySprinkler owner, String name, boolean isInvNameLocalized, int size) { - super(owner, name, isInvNameLocalized, size); - this.owner = owner; - this.addCallback(new CallbackObject(this.owner)); - } - - ItemStack[] mFerts; - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - Logger.INFO("Inserting: "+itemstack != null ? itemstack.getDisplayName() : "Nothing"); - HashMap mFerts = SprinklerHandler.getValidFerts(); - if (itemstack != null && mFerts != null && mFerts.size() > 0) { - for (ItemStack u : mFerts.values()) { - if (itemstack.isItemEqual(u)) { - return true; - } - } - } - return false; - } - -} \ No newline at end of file -- cgit From 1de090fb2eac6a26ffd71617c940127130206f5d Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Mar 2019 12:46:27 +0000 Subject: * % Xenil is no longer a primal aspect. % Disabled Control Cores for Multiblocks. --- .../implementations/base/GregtechMeta_MultiBlockBase.java | 3 ++- .../xmod/thaumcraft/aspect/GTPP_AspectCompat.java | 3 ++- src/resources/assets/miscutils/textures/items/bomb.png | Bin 0 -> 311 bytes .../assets/miscutils/textures/items/bomb_casing.png | Bin 0 -> 280 bytes .../assets/miscutils/textures/items/bomb_lit.png | Bin 0 -> 328 bytes 5 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/resources/assets/miscutils/textures/items/bomb.png create mode 100644 src/resources/assets/miscutils/textures/items/bomb_casing.png create mode 100644 src/resources/assets/miscutils/textures/items/bomb_lit.png (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 7ae0c6b246..d011043a57 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -71,6 +71,7 @@ extends GT_MetaTileEntity_MultiBlockBase { + private static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; static { @@ -1567,7 +1568,7 @@ GT_MetaTileEntity_MultiBlockBase { public final boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { boolean aStructureCheck = checkMultiblock(aBaseMetaTileEntity, aStack); - boolean aHasCore = (requireControlCores ? (this.getControlCoreBus() != null) : true); + boolean aHasCore = DEBUG_DISABLE_CORES_TEMPORARILY; //(requireControlCores ? (this.getControlCoreBus() != null) : true); return aStructureCheck && aHasCore; } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java index ee623f4a1e..6cd5af02b6 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java @@ -132,7 +132,8 @@ public class GTPP_AspectCompat { "Xenil", Utils.rgbtoHexValue(25, 25, 25), new TC_Aspect_Wrapper[]{ - }, + get(TC_Aspects.MAGNETO), + get(TC_Aspects.RADIO)}, new ResourceLocation(CORE.MODID+":textures/aspects/" + "Xenil.png"), false, 1, diff --git a/src/resources/assets/miscutils/textures/items/bomb.png b/src/resources/assets/miscutils/textures/items/bomb.png new file mode 100644 index 0000000000..e8e9b0f532 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/bomb.png differ diff --git a/src/resources/assets/miscutils/textures/items/bomb_casing.png b/src/resources/assets/miscutils/textures/items/bomb_casing.png new file mode 100644 index 0000000000..d4238babe2 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/bomb_casing.png differ diff --git a/src/resources/assets/miscutils/textures/items/bomb_lit.png b/src/resources/assets/miscutils/textures/items/bomb_lit.png new file mode 100644 index 0000000000..e40029160b Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/bomb_lit.png differ -- cgit From df8c981bd3dd0ba8c6bb3e538920f34e4e80fc76 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Mar 2019 15:21:13 +0000 Subject: % Made Control Cores Optional, they will still lock to the Core's tier if present. % Tweaked Control Core recipes. % Updated CircleCI config.yml. $ Fixed mild issue where Control Core Modules could be shared between multiblocks. --- .circleci/config.yml | 26 ++++++++++++++------- src/Java/gtPlusPlus/core/config/ConfigHandler.java | 4 +++- .../core/handler/AchievementHandler.java | 3 ++- src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 13 +++++------ .../GT_MetaTileEntity_Hatch_ControlCore.java | 24 +++++++++++++++++++ .../base/GregtechMeta_MultiBlockBase.java | 27 ++++++++++++++-------- 7 files changed, 71 insertions(+), 28 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/.circleci/config.yml b/.circleci/config.yml index ab0869d286..14c330e651 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ jobs: steps: - - checkout + # - checkout - run: name: Run build @@ -21,23 +21,33 @@ jobs: - run: sudo chmod +x gradlew - #https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/forge-1.7.10-10.13.4.1614-1.7.10-src.zip - - restore_cache: - key: jars-{{ checksum "build.gradle" }}-{{ checksum "build.gradle" }} - + key: jars-{{ checksum "GTPP_BuildRepo.sh" }}-{{ checksum "GTPP_BuildRepo.sh" }} + + # Build Forge and MCP - run: name: Download Build Script - command: wget https://alkcorp.overminddl1.com/GTPP_BuildScript.sh + command: wget https://alkcorp.overminddl1.com/GTPP_BuildRepo.sh - run: name: Run Build Script - command: sh GTPP_BuildScript.sh ${CIRCLE_BUILD_NUM} "${CIRCLE_BRANCH}" "${CIRCLE_USERNAME}" "${CIRCLE_SHA1}" "${CIRCLE_PROJECT_REPONAME}" "${CIRCLE_PROJECT_USERNAME}" "https://github.com/draknyte1/GTplusplus/archive/master.zip" + command: sh GTPP_BuildRepo.sh + # Cache All Libs - save_cache: paths: - ~/.gradle - key: jars-{{ checksum "build.gradle" }}-{{ checksum "build.gradle" }} + - ~/home/circleci/repo + key: jars-{{ checksum "GTPP_BuildRepo.sh" }}-{{ checksum "GTPP_BuildRepo.sh" }} + + # Build Mod + - run: + name: Download Build Script + command: wget https://alkcorp.overminddl1.com/GTPP_BuildScript.sh + + - run: + name: Run Build Script + command: sh GTPP_BuildScript.sh ${CIRCLE_BUILD_NUM} "${CIRCLE_BRANCH}" "${CIRCLE_USERNAME}" "${CIRCLE_SHA1}" "${CIRCLE_PROJECT_REPONAME}" "${CIRCLE_PROJECT_USERNAME}" "https://github.com/draknyte1/GTplusplus/archive/master.zip" - store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/ path: build/libs diff --git a/src/Java/gtPlusPlus/core/config/ConfigHandler.java b/src/Java/gtPlusPlus/core/config/ConfigHandler.java index 2fbd3f60c2..64c8b74b33 100644 --- a/src/Java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/Java/gtPlusPlus/core/config/ConfigHandler.java @@ -46,7 +46,9 @@ public class ConfigHandler { enableAlternativeDivisionSigilRecipe = config.getBoolean("enableAlternativeDivisionSigilRecipe", "machines", false, "Utilizes Neutronium instead."); boilerSteamPerSecond = config.getInt("boilerSteamPerSecond", "machines", 750, 0, 10000, "Sets the steam per second value in LV,MV,HV boilers (respectively 1x,2x,3x this number for the tiers)"); - requireControlCores = config.getBoolean("requireControlCores", "machines", true, "Multiblocks Require Control Cores"); + + //requireControlCores + boolean temp = config.getBoolean("requireControlCores", "machines", true, "Multiblocks Require Control Cores"); diff --git a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java index faca4449ce..482ca66f09 100644 --- a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java +++ b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java @@ -18,6 +18,7 @@ import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; @@ -46,7 +47,7 @@ public class AchievementHandler { //Useful Info boolean cores = CORE.ConfigSwitches.requireControlCores; - if (cores) { + if (cores || GregtechMeta_MultiBlockBase.DEBUG_DISABLE_CORES_TEMPORARILY) { this.registerAchievement("hatch.control", -2, -2, GregtechItemList.Hatch_Control_Core.get(1), aBaseAchievementName, false); } this.registerAchievement("hatch.dynamo.buffered", 2, -2, GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1), aBaseAchievementName, false); diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 17b210f176..632378987a 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -202,7 +202,7 @@ public class CORE { public static boolean disableIC2Recipes = false; public static boolean enableAlternativeDivisionSigilRecipe = false; public static int boilerSteamPerSecond = 750; - public static boolean requireControlCores = true; + public static final boolean requireControlCores = false; //Feature Related public static boolean enableCustomCapes = false; diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 092214a714..54d9994edc 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -1676,11 +1676,10 @@ public class RECIPES_Machines { for (int i = 0; i < 10; i++) { - boolean aDub = i >= 5; - + boolean aDub = false; ItemStack aPlateStack = aMat_A[i].getPlateDouble((GTNH ? 16 : 8) * (aDub ? 2 : 1)); - ItemStack aGearStack = aMat_B[i].getGear(GTNH ? 8 : 4 * (aDub ? 2 : 1)); - ItemStack aRodStack = aMat_A[i].getLongRod(GTNH ? 32 : 16 * (aDub ? 2 : 1)); + ItemStack aGearStack = aMat_B[i].getGear(GTNH ? 4 : 2 * (aDub ? 2 : 1)); + ItemStack aRodStack = aMat_A[i].getLongRod(GTNH ? 16 : 8 * (aDub ? 2 : 1)); ItemStack aScrewStack = aMat_B[i].getScrew(32 * (aDub ? 2 : 1)); if (!ItemUtils.checkForInvalidItems(aPlateStack)) { @@ -1704,14 +1703,14 @@ public class RECIPES_Machines { CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - aInputPrevTier[i], + CI.getEnergyCore(i, 4), aPlateStack, aGearStack, aRodStack, aScrewStack, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName((int) (4+Math.ceil((double) i / (double) 2))), GTNH ? (i * 2 * 2 * 2) : (i * 2 * 2)) + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName((int) (4+Math.ceil((double) i / (double) 2))), GTNH ? (i * 2 * 2) : (i * 2)) }, - aMat_A[i].getFluid(144 * 4 * (i+1)), //Input Fluid + CI.getTieredFluid(i, 144 * 4 * (i+1)), //Input Fluid aOutput[i], 60 * 20 * 1 * (i+1), MaterialUtils.getVoltageForTier(i)); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java index fe0ffd5dc8..7a532807c8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java @@ -8,16 +8,20 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.item.general.ItemControlCore; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; + + public BlockPos mControllerLocation; public GT_MetaTileEntity_Hatch_ControlCore(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Core determines maximum tier machine will operate at"); @@ -113,4 +117,24 @@ public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return aSide == getBaseMetaTileEntity().getFrontFacing() && (aStack != null && aStack.getItem() instanceof ItemControlCore); } + + public boolean setOwner(TileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } + else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } + + public boolean setOwner(IGregTechTileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } + else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index d011043a57..873c93aae1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -71,7 +71,7 @@ extends GT_MetaTileEntity_MultiBlockBase { - private static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; + public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; static { @@ -203,7 +203,7 @@ GT_MetaTileEntity_MultiBlockBase { } } - int tTier = requireControlCores ? this.getControlCoreTier() : -1; + int tTier = this.getControlCoreTier(); mInfo.add(getMachineTooltip()); @@ -554,8 +554,8 @@ GT_MetaTileEntity_MultiBlockBase { //Control Core to control the Multiblocks behaviour. int aControlCoreTier = getControlCoreTier(); - - //If no core, return false; + + //If no core, return false; if (aControlCoreTier == 0 && requireControlCores) { log("No control core found."); return false; @@ -640,7 +640,7 @@ GT_MetaTileEntity_MultiBlockBase { //Only Overclock as high as the control circuit. byte tTierOld = tTier; - tTier = requireControlCores ? (byte) aControlCoreTier : tTierOld; + tTier = getControlCoreTier() > 0 ? (byte) aControlCoreTier : tTierOld; // Overclock if (this.mEUt <= 16) { @@ -954,10 +954,10 @@ GT_MetaTileEntity_MultiBlockBase { public int getControlCoreTier() { //Always return best tier if config is off. - boolean aCoresConfig = gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; + /*boolean aCoresConfig = gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; if (!aCoresConfig) { return 10; - } + }*/ if (mControlCoreBus.isEmpty()) { log("No Control Core Modules Found."); @@ -998,9 +998,16 @@ GT_MetaTileEntity_MultiBlockBase { log("Tried to add a secondary control core module."); return false; } - - log("Adding control core module."); - return addToMachineListInternal(mControlCoreBus, aMetaTileEntity, aBaseCasingIndex); + + GT_MetaTileEntity_Hatch_ControlCore Module = (GT_MetaTileEntity_Hatch_ControlCore) aMetaTileEntity; + + if (Module != null) { + if (Module.setOwner(aTileEntity)) { + log("Adding control core module."); + return addToMachineListInternal(mControlCoreBus, aMetaTileEntity, aBaseCasingIndex); + } + } + return false; } @Override -- cgit From 3f6606f61cd5d1f822d26036f218da9defeed17a Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Mar 2019 15:59:02 +0000 Subject: $ Fixed #425. % Updated CircleCI config.yml one last time. --- .circleci/config.yml | 4 ++-- .../base/GregtechMeta_MultiBlockBase.java | 6 ++++++ .../GregtechMetaTileEntity_IndustrialCuttingMachine.java | 16 ---------------- .../GregtechMetaTileEntity_IndustrialExtruder.java | 11 ----------- .../GregtechMetaTileEntity_IndustrialWireMill.java | 11 ----------- 5 files changed, 8 insertions(+), 40 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/.circleci/config.yml b/.circleci/config.yml index 345792b86b..2be7471253 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: environment: - JVM_OPTS: -Xmx3200m + JVM_OPTS: -Xms2048m Xmx4000m steps: @@ -46,7 +46,7 @@ jobs: command: wget https://alkcorp.overminddl1.com/GTPP_BuildScript.sh - run: - name: Run "${CIRCLE_PROJECT_REPONAME}" Build Script + name: Run Build Script command: sh GTPP_BuildScript.sh ${CIRCLE_BUILD_NUM} "${CIRCLE_BRANCH}" "${CIRCLE_USERNAME}" "${CIRCLE_SHA1}" "${CIRCLE_PROJECT_REPONAME}" "${CIRCLE_PROJECT_USERNAME}" "https://github.com/draknyte1/GTplusplus/archive/master.zip" - store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 873c93aae1..9393ca08be 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -16,6 +16,7 @@ import org.apache.commons.lang3.ArrayUtils; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; +import gregtech.api.enums.TAE; import gregtech.api.gui.GT_Container_MultiMachine; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -1586,6 +1587,11 @@ GT_MetaTileEntity_MultiBlockBase { Block aFoundBlock, int aFoundMeta, Block aExpectedBlock, int aExpectedMeta) { boolean isHatch = false; if (aBaseMetaTileEntity != null) { + + if (aCasingID < 64) { + aCasingID = TAE.GTPP_INDEX(aCasingID); + } + isHatch = this.addToMachineList(aBaseMetaTileEntity, aCasingID); if (isHatch) { return true; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java index e627e99aa7..9c9fa7fa58 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -51,7 +51,6 @@ extends GregtechMeta_MultiBlockBase { "1x Output Bus", "1x Input Hatch", "1x Energy Hatch", - "Maintenance Hatch must be at the back, centered", }; } @@ -129,25 +128,10 @@ extends GregtechMeta_MultiBlockBase { } } } - if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() != 0)) { - Logger.INFO("Use Busses, Not Hatches for Input/Output."); - return false; - } if ((this.mInputBusses.size() == 0) || (this.mOutputBusses.size() == 0)) { Logger.INFO("Incorrect amount of Input & Output busses."); return false; } - this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { - this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this.getCasingTextureIndex(); - } else { - Logger.INFO("Maintenance hatch must be in the middle block on the back."); - return false; - } - } if ((this.mMaintenanceHatches.size() != 1)) { Logger.INFO("Incorrect amount of Maintenance or Energy hatches."); return false; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java index 0b1691358c..e407e28b0e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java @@ -176,17 +176,6 @@ extends GregtechMeta_MultiBlockBase { Logger.WARNING("Incorrect amount of Input || Output busses."); return false; } - this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { - this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this.getCasingTextureIndex(); - } else { - Logger.WARNING("Maintenance hatch must be in the middle block on the back."); - return false; - } - } if ((this.mMaintenanceHatches.size() != 1)) { Logger.WARNING("Incorrect amount of Maintenance hatches."); return false; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java index bf33892420..502b5e47b2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java @@ -144,17 +144,6 @@ extends GregtechMeta_MultiBlockBase { Logger.INFO("Incorrect amount of Input & Output busses."); return false; } - this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { - this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this.getCasingTextureIndex(); - } else { - Logger.INFO("Maintenance hatch must be in the middle block on the back."); - return false; - } - } if ((this.mMaintenanceHatches.size() != 1)) { Logger.INFO("Incorrect amount of Maintenance or Energy hatches."); return false; -- cgit From 0cb924d25dd80c22d000898fb27ab3ed0e0f80fb Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Mar 2019 18:16:17 +0000 Subject: + Added Bombs. % Made RAW collectors produce 10x less. $ Fixed tooltips on RAW collectors. $ Fixed a bug regarding STARTUP_PHASE. --- src/Java/gtPlusPlus/GTplusplus.java | 2 +- .../core/entity/InternalEntityRegistry.java | 3 + .../entity/projectile/EntityThrowableBomb.java | 115 +++++++++++++++++++ .../handler/events/GeneralTooltipEventHandler.java | 11 +- src/Java/gtPlusPlus/core/item/ModItems.java | 16 +++ .../core/item/base/itemblock/ItemBlockMeta.java | 2 +- .../core/item/general/ItemControlCore.java | 22 ++-- .../item/general/throwables/ItemThrowableBomb.java | 123 +++++++++++++++++++++ .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 70 ++++++++++++ .../machines/TileEntityAdvPooCollector.java | 3 +- .../machines/TileEntityBaseFluidCollector.java | 2 - .../machines/TileEntityPooCollector.java | 4 +- .../xmod/gregtech/api/enums/GregtechItemList.java | 7 +- .../common/items/MetaGeneratedGregtechItems.java | 14 +++ .../textures/items/MU-metaitem.01/111.png | Bin 0 -> 345 bytes .../textures/items/MU-metaitem.01/112.png | Bin 0 -> 341 bytes .../textures/items/MU-metaitem.01/113.png | Bin 0 -> 337 bytes .../textures/items/MU-metaitem.01/114.png | Bin 0 -> 396 bytes .../textures/items/MU-metaitem.01/115.png | Bin 0 -> 428 bytes 19 files changed, 370 insertions(+), 24 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java create mode 100644 src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/111.png create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/112.png create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/113.png create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/114.png create mode 100644 src/resources/assets/miscutils/textures/items/MU-metaitem.01/115.png (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 5c3d5fb801..e10369abe3 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -230,6 +230,7 @@ public class GTplusplus implements ActionListener { if (LoadedMods.Thaumcraft) { event.registerServerCommand(new CommandDumpAspects()); } + INIT_PHASE.STARTED.setPhaseActive(true); } @Mod.EventHandler @@ -257,7 +258,6 @@ public class GTplusplus implements ActionListener { */ @Mod.EventHandler public void onLoadComplete(FMLLoadCompleteEvent event) { - INIT_PHASE.STARTED.setPhaseActive(true); proxy.onLoadComplete(event); generateGregtechRecipeMaps(); } diff --git a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java index 36f5b86184..e5c779adcf 100644 --- a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java +++ b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java @@ -14,6 +14,7 @@ import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; import gtPlusPlus.core.entity.projectile.EntityHydrofluoricAcidPotion; import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion; +import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; import gtPlusPlus.core.util.Utils; @@ -51,6 +52,8 @@ public class InternalEntityRegistry { //EntityRegistry.registerGlobalEntityID(EntityTeslaTowerLightning.class, "plasmaBolt", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(125, 125, 125)); EntityRegistry.registerModEntity(EntityTeslaTowerLightning.class, "plasmaBolt", mEntityID++, GTplusplus.instance, 64, 5, true); + EntityRegistry.registerModEntity(EntityThrowableBomb.class, "EntityThrowableBomb", mEntityID++, GTplusplus.instance, 64, 10, true); + /** * Globals, which generate spawn eggs. (Currently required for Giant chicken spawning) */ diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java b/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java new file mode 100644 index 0000000000..9e72daf687 --- /dev/null +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java @@ -0,0 +1,115 @@ +package gtPlusPlus.core.entity.projectile; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.init.Blocks; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; + +public class EntityThrowableBomb extends EntityThrowable { + + public EntityThrowableBomb(World world) { + super(world); + } + + public EntityThrowableBomb(World world, EntityLivingBase entity) { + super(world, entity); + } + + public EntityThrowableBomb(World world, double posX, double posY, double posZ) { + super(world, posX, posY, posZ); + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + @Override + protected void onImpact(MovingObjectPosition object) { + int xBlock = object.blockX; + int yBlock = object.blockY; + int zBlock = object.blockZ; + if (object.entityHit != null) { + byte b0 = 6; + if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)){ + object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0); + EntityUtils.setEntityOnFire(object.entityHit, 10); + object.entityHit.fireResistance = 0; + ravage(EntityUtils.findBlockPosUnderEntity(object.entityHit)); + } + } + if (object.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ + ravage(new BlockPos(xBlock, yBlock, zBlock)); + } + + String mParticleType = "reddust"; + int e=0; + for (int i = 0; i < 24; ++i) { + if ((e = MathUtils.randInt(0, 5)) <= 1){ + if (e==0) + mParticleType = "largesmoke"; + if (e==1) + mParticleType = "flame"; + } + this.worldObj.spawnParticle(mParticleType, this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + } + + if (!this.worldObj.isRemote) { + this.setDead(); + } + } + + private boolean ravage(BlockPos blockpos){ + + int radius = 1; + + for (int i=(blockpos.xPos-radius);i<(blockpos.xPos+radius);i++){ + for (int j=(blockpos.yPos-radius);j<(blockpos.yPos+radius);j++){ + for (int h=(blockpos.zPos-radius);h<(blockpos.zPos+radius);h++){ + + int mChance = MathUtils.randInt(1, 10); + if (mChance <= 3){ + Block mBlockhit = worldObj.getBlock(i, j, h); + this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + + //GT_Pollution.addPollution(worldObj.getChunkFromBlockCoords(blockpos.xPos, blockpos.zPos), mPol); + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 0.01f, true); + if (mBlockhit == Blocks.grass || mBlockhit == Blocks.mycelium){ + worldObj.setBlock(i, j+1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } + else if (mBlockhit == Blocks.leaves || mBlockhit == Blocks.leaves2){ + worldObj.setBlock(i, j, h, Blocks.fire); + } + else if (mBlockhit == Blocks.tallgrass){ + worldObj.setBlock(i, j, h, Blocks.fire); + if (worldObj.getBlock(i, j-1, h) == Blocks.grass){ + worldObj.setBlock(i, j-1, h, Blocks.dirt); + } + } + else if (mBlockhit == Blocks.carrots || mBlockhit == Blocks.melon_block || mBlockhit == Blocks.pumpkin || mBlockhit == Blocks.potatoes){ + worldObj.setBlock(i, j+1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } + else if (mBlockhit == Blocks.air){ + worldObj.setBlock(i, j, h, Blocks.fire); + } + } + } + } + } + + + return true; + } + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java index 3acc3b6bcf..ef91647c1a 100644 --- a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java @@ -8,8 +8,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.lib.CORE; @@ -27,13 +29,12 @@ public class GeneralTooltipEventHandler { public void onItemTooltip(ItemTooltipEvent event){ - if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED) { + if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED && GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.SERVER_START) { return; } if (event.itemStack == null) { return; } - if (CORE.ConfigSwitches.chanceToDropFluoriteOre > 0) { if (BlockEventHandler.blockLimestone != null && !BlockEventHandler.blockLimestone.isEmpty()) { for (ItemStack h : BlockEventHandler.blockLimestone) { @@ -55,13 +56,14 @@ public class GeneralTooltipEventHandler { } } - //Material Collector Tooltips - if (event.itemStack.getItem() == Item.getItemFromBlock(ModBlocks.blockPooCollector)) { + //Material Collector Tooltips + if (ModBlocks.blockPooCollector != null && Block.getBlockFromItem(event.itemStack.getItem()) == ModBlocks.blockPooCollector) { //Normal if (event.itemStack.getItemDamage() == 0) { event.toolTip.add("Used to collect animal waste"); event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); event.toolTip.add("Use Hoppers/Pipes to empty"); + event.toolTip.add(EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.AQUA+"8000L"); } //Advanced else { @@ -69,6 +71,7 @@ public class GeneralTooltipEventHandler { event.toolTip.add("Significantly faster than the simple version"); event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); event.toolTip.add("Use Hoppers/Pipes to empty"); + event.toolTip.add(EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.AQUA+"128000L"); } } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index ed1df1f333..bb2ab8ae47 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -61,6 +61,7 @@ import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoil; import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoilWire; import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; +import gtPlusPlus.core.item.general.throwables.ItemThrowableBomb; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.materials.DustDecayable; import gtPlusPlus.core.item.tool.misc.DebugScanner; @@ -338,6 +339,11 @@ public final class ModItems { public static ItemDummyResearch itemDummyResearch; + public static CoreItem itemBombCasing; + public static CoreItem itemBombUnf; + public static CoreItem itemDetCable; + public static ItemThrowableBomb itemBomb; + static { Logger.INFO("Items!"); //Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon. @@ -889,6 +895,16 @@ public final class ModItems { //Farm Animal Fun new AgriculturalChem(); + + //Bombs + itemBombCasing = new CoreItem("itemBombCasing", "Bomb Casing", tabMisc); + itemBombCasing.setTextureName(CORE.MODID + ":bomb_casing"); + itemBombUnf = new CoreItem("itemBombUnf", "Bomb (unf)", tabMisc); + itemBombUnf.setTextureName(CORE.MODID + ":bomb_casing"); + itemDetCable = new CoreItem("itemDetCable", "Det. Cable", tabMisc); + itemDetCable.setTextureName("string"); + itemBomb = new ItemThrowableBomb(); + //Only used for debugging. /*if (CORE.DEVENV) { new ConnectedBlockFinder(); diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java index c271ab39d0..b26ac67225 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java @@ -22,7 +22,7 @@ public class ItemBlockMeta extends ItemBlockWithMetadata { super(aBlock, aBlock); this.mBlock = aBlock; - this.setMaxDamage(15); + this.setMaxDamage(0); this.setHasSubtypes(true); if (aBlock instanceof ITileTooltip) { ITileTooltip aTooltip = (ITileTooltip) aBlock; diff --git a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java index eb22f8fa07..5ef72b6f17 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java @@ -17,7 +17,7 @@ import gtPlusPlus.core.lib.CORE; public class ItemControlCore extends Item { - public IIcon[] icons = new IIcon[10]; + public static IIcon[] icons = new IIcon[10]; public ItemControlCore() { super(); @@ -31,16 +31,16 @@ public class ItemControlCore extends Item { @Override public void registerIcons(IIconRegister reg) { - this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); - this.icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); - this.icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); - this.icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); - this.icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); - this.icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); - this.icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); - this.icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); - this.icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); - this.icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); + icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); + icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); + icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); + icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); + icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); + icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); + icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); + icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); + icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); + icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); } @Override diff --git a/src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java b/src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java new file mode 100644 index 0000000000..9467c3a58c --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java @@ -0,0 +1,123 @@ +package gtPlusPlus.core.item.general.throwables; + +import java.util.List; + +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemThrowableBomb extends CoreItem { + + private static AutoMap mLighters = new AutoMap(); + public static IIcon[] icons = new IIcon[10]; + + public ItemThrowableBomb() { + super("gtpp.throwable.bomb", "Bomb", AddToCreativeTab.tabMisc, 16, 0, new String[] {"Just like Bomberman", "Have a fire source in inventory to prime"}, EnumRarity.uncommon, EnumChatFormatting.GRAY, false, null); + this.setHasSubtypes(true); + } + + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + + if (mLighters.isEmpty()) { + mLighters.put(ItemUtils.getSimpleStack(Items.flint_and_steel)); + mLighters.put(ItemList.Tool_Lighter_Invar_Full.get(1)); + mLighters.put(ItemList.Tool_Lighter_Invar_Used.get(1)); + mLighters.put(ItemList.Tool_Lighter_Platinum_Full.get(1)); + mLighters.put(ItemList.Tool_Lighter_Platinum_Used.get(1)); + mLighters.put(ItemUtils.getSimpleStack(ModItems.itemBasicFireMaker)); + } + + //Unlit + if (item.getItemDamage() == 0) { + boolean hasLighter = false; + for (ItemStack aPlaySlot : player.inventory.mainInventory) { + if (aPlaySlot != null) { + for (ItemStack aLighter : mLighters) { + if (GT_Utility.areStacksEqual(aPlaySlot, aLighter)) { + hasLighter = true; + break; + } + } + } + } + if (hasLighter) { + item.setItemDamage(1); + } + } + //Lit + else if (item.getItemDamage() == 1) { + if (!player.capabilities.isCreativeMode) { + --item.stackSize; + } + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + if (!world.isRemote) { + world.spawnEntityInWorld(new EntityThrowableBomb(world, player)); + } + /*if (item.stackSize <= 0) { + item = null; + }*/ + } + return item; + } + + + + @Override + public void registerIcons(IIconRegister reg) { + icons[0] = reg.registerIcon(CORE.MODID + ":" + "bomb"); + icons[1] = reg.registerIcon(CORE.MODID + ":" + "bomb_lit"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } + + @SuppressWarnings({ "unchecked" }) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i ++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + String aLitStatus = "unlit"; + if (stack.getItemDamage() == 0) { + aLitStatus = EnumChatFormatting.BLUE+"Unlit"; + } + else if (stack.getItemDamage() == 1) { + aLitStatus = EnumChatFormatting.RED+"Lit"; + } + list.add(EnumChatFormatting.GOLD+"Fuse Status: "+aLitStatus); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + // TODO Auto-generated method stub + return super.getItemStackDisplayName(p_77653_1_); + } + + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 1b24fb6e87..a22d8523ff 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -18,6 +18,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.chemistry.IonParticles; +import gtPlusPlus.core.item.chemistry.RocketFuels; import gtPlusPlus.core.item.crafting.ItemDummyResearch; import gtPlusPlus.core.item.crafting.ItemDummyResearch.ASSEMBLY_LINE_RESEARCH; import gtPlusPlus.core.lib.CORE; @@ -85,10 +86,34 @@ public class RECIPES_GREGTECH { breweryRecipes(); laserEngraverRecipes(); assemblyLineRecipes(); + latheRecipes(); + vacuumFreezerRecipes(); addFuels(); } + private static void vacuumFreezerRecipes() { + GT_Values.RA.addVacuumFreezerRecipe(GregtechItemList.Bomb_Cast_Molten.get(1), GregtechItemList.Bomb_Cast_Set.get(1), 20 * 30); + } + + private static void latheRecipes() { + + GT_Values.RA.addLatheRecipe( + ALLOY.EGLIN_STEEL.getBlock(1), + GregtechItemList.Bomb_Cast_Mold.get(1), + null, + 20 * 60 * 15, + 120); + + GT_Values.RA.addLatheRecipe( + GregtechItemList.Bomb_Cast_Set.get(1), + GregtechItemList.Bomb_Cast_Broken.get(2), + ItemUtils.getSimpleStack(ModItems.itemBombCasing, 2), + 20 * 60 * 5, + 30); + + } + private static void fusionRecipes() { /** @@ -1249,6 +1274,21 @@ public class RECIPES_GREGTECH { FluidUtils.getFluidStack("molten.krypton", 500), T6, 2000, 512000); + addAR(ItemUtils.getItemStackOfAmountFromOreDict( + "dustClay", 32), + GregtechItemList.Bomb_Cast_Mold.get(0), + FluidUtils.getWater(4000), + GregtechItemList.Bomb_Cast.get(4), + 30, 120); + addAR(ItemUtils.getSimpleStack(Items.redstone, 32), + ItemUtils.getSimpleStack(ModItems.itemRope, 16), + Materials.Glue.getFluid(500), + ItemUtils.getSimpleStack(ModItems.itemDetCable, 24), + 30, + 120); + + + /*addAR(ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloy020", 16), ItemUtils.getItemStackOfAmountFromOreDict("frameGtIncoloyMA956", 4), null, GregtechItemList.Casing_Power_SubStation.get(4), 80, 120);*/ @@ -1564,6 +1604,24 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustLithium7", 16), FluidUtils.getFluidStack("water", 1000), FluidUtils.getFluidStack("lithiumhydroxide", 144 * 4), CI.emptyCells(1), 300 * 20); + + //Bombs + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(ModItems.itemBombCasing, 4), + ItemUtils.getSimpleStack(RocketFuels.Ammonium_Nitrate_Dust, 8), + Materials.Fuel.getFluid(1000), + null, + ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), + 300 * 20); + + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), + ItemUtils.getSimpleStack(ModItems.itemDetCable, 4), + FluidUtils.getFluidStack(RocketFuels.Kerosene, 100), + null, + ItemUtils.getSimpleStack(ModItems.itemBomb, 4), + 10 * 20); + // LFTR Fuel Related Compounds if (GTNH) { @@ -1666,6 +1724,18 @@ public class RECIPES_GREGTECH { MaterialUtils.getVoltageForTier(GTNH ? 5 : 4), 4500); + //Bomb Casings + GT_Values.RA.addBlastRecipe( + GregtechItemList.Bomb_Cast.get(4), + ALLOY.STEEL.getDust(16), + ELEMENT.getInstance().OXYGEN.getFluid(2000), + GT_Values.NF, + GregtechItemList.Bomb_Cast_Molten.get(4), + null, + 4 * 60 * 20, + MaterialUtils.getVoltageForTier(GTNH ? 3 : 2), + 2800); + } diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java index bdf899e22d..18954f12b6 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java @@ -24,7 +24,6 @@ public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { public TileEntityAdvPooCollector() { super(18, 128000); - Logger.INFO("Created"); } @@ -120,7 +119,7 @@ public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { } } aPooAmount = Math.max(Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount), 1); - return aPooAmount * MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}); + return Math.max(1, (aPooAmount * MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}) / 10)); } else { return 0; diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java index 2438d57355..7afb4727b4 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java @@ -177,7 +177,6 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem AxisAlignedBB box = AxisAlignedBB.getBoundingBox(startX, startY, startZ, endX, endY, endZ); if (box != null) { for (Class c2 : aThingsToLookFor()) { - Logger.INFO("Looking for "+c2.getName()); tickEntityType(w, box, c2); } } else { @@ -197,7 +196,6 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem public final void tickEntityType(World w, AxisAlignedBB box, Class aClassToFind) { List entities = w.getEntitiesWithinAABB(aClassToFind, box); if (entities != null && !entities.isEmpty()) { - Logger.INFO("Found some "+aClassToFind.getName()); interactWithEntities(entities); } } diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java index 3667dd6a29..f6570c6cc6 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java @@ -20,7 +20,7 @@ import net.minecraftforge.fluids.Fluid; public class TileEntityPooCollector extends TileEntityBaseFluidCollector { public TileEntityPooCollector() { - super(9, 64000); + super(9, 8000); } @@ -109,7 +109,7 @@ public class TileEntityPooCollector extends TileEntityBaseFluidCollector { aPooAmount = MathUtils.randInt(1, 10); } } - aPooAmount = Math.max(Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount), 1); + aPooAmount = Math.max((Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount)/10), 1); return aPooAmount; } else { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index f377a2da3d..83abe22568 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -104,6 +104,11 @@ public enum GregtechItemList implements GregtechItemContainer { //End Game Laser Engraver Lens Laser_Lens_Special, + //Bombs + Bomb_Cast, Bomb_Cast_Molten, + Bomb_Cast_Set, Bomb_Cast_Broken, + Bomb_Cast_Mold, + //---------------------------------------------------------------------------- @@ -561,7 +566,7 @@ public enum GregtechItemList implements GregtechItemContainer { */ //Fluid Void Covers - Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, + Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index 6b061c3704..f42fc49e53 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -304,6 +304,20 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { + /* + * Bombs + */ + GregtechItemList.Bomb_Cast.set(this.addItem(111, "Bomb Cast", "Used in the production of Bombs", new Object[0])); + GregtechItemList.Bomb_Cast_Molten.set(this.addItem(112, "Bomb Cast (Hot)", "Consider cooling this off", new Object[0])); + GregtechItemList.Bomb_Cast_Set.set(this.addItem(113, "Bomb Cast (Set)", "Break it open for the goodies inside!", new Object[0])); + GregtechItemList.Bomb_Cast_Broken.set(this.addItem(114, "Bomb Cast (Broken)", "This is probably just junk", new Object[0])); + GregtechItemList.Bomb_Cast_Mold.set(this.addItem(115, "Mold (Bomb Cast)", "Used in the production of Bombs", new Object[0])); + + + + + + } private boolean registerComponents_ULV(){ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/111.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/111.png new file mode 100644 index 0000000000..3147037815 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/111.png differ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/112.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/112.png new file mode 100644 index 0000000000..dce530370f Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/112.png differ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/113.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/113.png new file mode 100644 index 0000000000..0c85939327 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/113.png differ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/114.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/114.png new file mode 100644 index 0000000000..b3c3716abb Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/114.png differ diff --git a/src/resources/assets/miscutils/textures/items/MU-metaitem.01/115.png b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/115.png new file mode 100644 index 0000000000..a9a9c6fcee Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/MU-metaitem.01/115.png differ -- cgit From ec3ad861c70a4dc76ee6a391026b40904469b29f Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Mar 2019 21:11:08 +0000 Subject: $ Hopefully Fixed #425 properly. --- ...echMetaTileEntity_IndustrialCuttingMachine.java | 28 +++++++++++++---- .../GregtechMetaTileEntity_IndustrialExtruder.java | 30 ++++++++++++++----- .../GregtechMetaTileEntity_IndustrialWireMill.java | 35 +++++++++++++--------- 3 files changed, 67 insertions(+), 26 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java index 9c9fa7fa58..5e852b5f76 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -113,6 +113,24 @@ extends GregtechMeta_MultiBlockBase { final int tX = this.getBaseMetaTileEntity().getXCoord(); final int tY = this.getBaseMetaTileEntity().getYCoord(); final int tZ = this.getBaseMetaTileEntity().getZCoord(); + + + //Check Rear Middle + { + Block aBlock = this.getBaseMetaTileEntity() + .getBlockAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + int aMeta = this.getBaseMetaTileEntity() + .getMetaIDAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + IGregTechTileEntity aTile = this.getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), + getCasingMeta())) { + log("Bad Casing on Cutting Machine."); + return false; + } + } + + for (byte i = -1; i < 2; i = (byte) (i + 1)) { for (byte j = -1; j < 2; j = (byte) (j + 1)) { if ((i != 0) || (j != 0)) { @@ -121,7 +139,7 @@ extends GregtechMeta_MultiBlockBase { int aMeta = this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); IGregTechTileEntity aTile = this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), getCasingMeta())) { - Logger.INFO("Bad Casing on Cutting Machine."); + log("Bad Casing on Cutting Machine."); return false; } } @@ -129,18 +147,18 @@ extends GregtechMeta_MultiBlockBase { } } if ((this.mInputBusses.size() == 0) || (this.mOutputBusses.size() == 0)) { - Logger.INFO("Incorrect amount of Input & Output busses."); + log("Incorrect amount of Input & Output busses."); return false; } if ((this.mMaintenanceHatches.size() != 1)) { - Logger.INFO("Incorrect amount of Maintenance or Energy hatches."); + log("Incorrect amount of Maintenance or Energy hatches."); return false; } } else { - Logger.INFO("False 5"); + log("False 5"); return false; } - Logger.INFO("True"); + log("True"); return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java index e407e28b0e..f4f8a5fe78 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java @@ -113,9 +113,9 @@ extends GregtechMeta_MultiBlockBase { } if (inputs.length > 0) { int para = (4* GT_Utility.getTier(this.getMaxInputVoltage())); - Logger.WARNING("Recipe. ["+inputs.length+"]["+para+"]"); + log("Recipe. ["+inputs.length+"]["+para+"]"); if (checkRecipeGeneric(inputs, new FluidStack[]{}, para, 100, 250, 10000)) { - Logger.WARNING("Recipe 2."); + log("Recipe 2."); return true; } } @@ -152,6 +152,22 @@ extends GregtechMeta_MultiBlockBase { return false; } } + + //Check Rear Middle + { + Block aBlock = this.getBaseMetaTileEntity() + .getBlockAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + int aMeta = this.getBaseMetaTileEntity() + .getMetaIDAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + IGregTechTileEntity aTile = this.getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), + getCasingMeta())) { + log("Bad Casing on Extruder."); + return false; + } + } + final int tX = this.getBaseMetaTileEntity().getXCoord(); final int tY = this.getBaseMetaTileEntity().getYCoord(); final int tZ = this.getBaseMetaTileEntity().getZCoord(); @@ -164,7 +180,7 @@ extends GregtechMeta_MultiBlockBase { int aMeta = this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); IGregTechTileEntity aTile = this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), getCasingMeta())) { - Logger.INFO("Bad Casing on Extruder."); + log("Bad Casing on Extruder."); return false; } @@ -173,18 +189,18 @@ extends GregtechMeta_MultiBlockBase { } } if ((this.mInputBusses.size() == 0) || (this.mOutputBusses.size() == 0)) { - Logger.WARNING("Incorrect amount of Input || Output busses."); + log("Incorrect amount of Input || Output busses."); return false; } if ((this.mMaintenanceHatches.size() != 1)) { - Logger.WARNING("Incorrect amount of Maintenance hatches."); + log("Incorrect amount of Maintenance hatches."); return false; } } else { - Logger.WARNING("False 5"); + log("False 5"); return false; } - Logger.WARNING("True"); + log("True"); return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java index 502b5e47b2..d798691d04 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java @@ -118,6 +118,21 @@ extends GregtechMeta_MultiBlockBase { return false; } } + + //Check Rear Middle + { + Block aBlock = this.getBaseMetaTileEntity() + .getBlockAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + int aMeta = this.getBaseMetaTileEntity() + .getMetaIDAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + IGregTechTileEntity aTile = this.getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), + getCasingMeta())) { + log("Bad Casing on Wiremill."); + return false; + } + } final int tX = this.getBaseMetaTileEntity().getXCoord(); final int tY = this.getBaseMetaTileEntity().getYCoord(); final int tZ = this.getBaseMetaTileEntity().getZCoord(); @@ -129,7 +144,7 @@ extends GregtechMeta_MultiBlockBase { int aMeta = this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); IGregTechTileEntity aTile = this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), getCasingMeta())) { - Logger.INFO("Bad Casing on Wiremill."); + log("Bad Casing on Wiremill."); return false; } } @@ -137,22 +152,22 @@ extends GregtechMeta_MultiBlockBase { } } if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() != 0)) { - Logger.INFO("Use Busses, Not Hatches for Input/Output."); + log("Use Busses, Not Hatches for Input/Output."); return false; } if ((this.mInputBusses.size() == 0) || (this.mOutputBusses.size() == 0)) { - Logger.INFO("Incorrect amount of Input & Output busses."); + log("Incorrect amount of Input & Output busses."); return false; } if ((this.mMaintenanceHatches.size() != 1)) { - Logger.INFO("Incorrect amount of Maintenance or Energy hatches."); + log("Incorrect amount of Maintenance or Energy hatches."); return false; } } else { - Logger.INFO("False 5"); + log("False 5"); return false; } - Logger.INFO("True"); + log("True"); return true; } @@ -189,12 +204,4 @@ extends GregtechMeta_MultiBlockBase { public byte getCasingTextureIndex() { return (byte) TAE.GTPP_INDEX(6); } - - private boolean addToMachineList(final IGregTechTileEntity tTileEntity) { - return ((this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex()))); - } - - private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { - return ((this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()))); - } } \ No newline at end of file -- cgit