diff options
author | Alkalus <draknyte1@hotmail.com> | 2020-04-13 23:50:26 +0000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2020-04-13 23:50:26 +0000 |
commit | e724a728061ec4a78cff73a4a2dd46eea4af4521 (patch) | |
tree | fee3354917be32870ec349b605990a091ace9e62 /src | |
parent | 24b1356471191a10fde6e4f1baf58ae74e87cfba (diff) | |
parent | 87ab3c0ab5f1b682295e2a010cc88cf4ae7db51c (diff) | |
download | GT5-Unofficial-e724a728061ec4a78cff73a4a2dd46eea4af4521.tar.gz GT5-Unofficial-e724a728061ec4a78cff73a4a2dd46eea4af4521.tar.bz2 GT5-Unofficial-e724a728061ec4a78cff73a4a2dd46eea4af4521.zip |
Merged in MillingRecipes (pull request #7)
Milling Recipes & many other misc fixes
Diffstat (limited to 'src')
103 files changed, 8013 insertions, 1982 deletions
diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index 3ddb25e754..d8cbb6525e 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -1,6 +1,8 @@ package gregtech.api.util; -import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; +import static gregtech.api.enums.GT_Values.W; import java.util.*; @@ -12,9 +14,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map_Fuel; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map_Macerator; import gtPlusPlus.api.interfaces.IComparableRecipe; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -24,7 +23,9 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.nei.GT_NEI_MultiBlockHandler; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; /** * Custom GT Recipe Class @@ -248,8 +249,8 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ public static final GT_Recipe_Map_Fuel sRocketFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.rocketenginefuel", "Rocket Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 3000, " EU", true, true); public static final GT_Recipe_Map sGeoThermalFuels = new GT_Recipe_Map(new HashSet<GT_Recipe>(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map sChemicalDehydratorRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.chemicaldehydrator", "Chemical Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sVacuumFurnaceRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(500), "gt.recipe.vacfurnace", "Vacuum Furnace", null, "gregtech:textures/gui/basicmachines/Default", 2, 2, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); + public static final GT_Recipe_Map sChemicalDehydratorRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.chemicaldehydrator", "Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sVacuumFurnaceRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(500), "gt.recipe.vacfurnace", "Vacuum Furnace", null, "gregtech:textures/gui/basicmachines/Default", 6, 6, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); public static final GT_Recipe_Map sAlloyBlastSmelterRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.alloyblastsmelter", "Alloy Blast Smelter", null, RES_PATH_GUI + "basicmachines/BlastSmelter", 9, 9, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sSteamTurbineFuels = new GT_Recipe_Map(new HashSet<GT_Recipe>(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); @@ -258,7 +259,7 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ public static final GT_Recipe_Map sLiquidFluorineThoriumReactorRecipesEx = new GT_Recipe_Map(new NoConflictGTRecipeMap(), "gt.recipe.lftr.2", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); // Ore Milling Map - public static final GT_Recipe_Map sOreMillRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.oremill", "Milling", null, RES_PATH_GUI + "basicmachines/LFTR", 3, 4, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sOreMillRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.oremill", "Milling", null, RES_PATH_GUI + "basicmachines/LFTR", 3, 4, 1, 0, 1, E, 1, E, true, false); //Fission Fuel Plant Recipes //public static final GT_Recipe_Map sFissionFuelProcessing = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.fissionfuel", "Fission Fuel Processing", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 9, 1, E, 1, E, true, true); @@ -323,6 +324,10 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ //Semi-Fluid Fuel Map public static final GT_Recipe_Map_Fuel sSemiFluidLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.semifluidgeneratorfuels", "Semifluid Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + + // Flotation Cell + public static final GT_Recipe_Map sFlotationCellRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.flotationcell", "Flotation Cell", null, RES_PATH_GUI + "basicmachines/LFTR", 6, 4, 1, 1, 1, "Ore Key: ", 1, E, true, false); + diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 0e70baf524..4ddec1f9f4 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -182,7 +182,6 @@ public class GTplusplus implements ActionListener { public void init(final FMLInitializationEvent event) { INIT_PHASE.INIT.setPhaseActive(true); proxy.init(event); - HazmatUtils.init(); proxy.registerNetworkStuff(); Meta_GT_Proxy.init(); Core_Manager.init(); @@ -199,6 +198,7 @@ public class GTplusplus implements ActionListener { public void postInit(final FMLPostInitializationEvent event) { INIT_PHASE.POST_INIT.setPhaseActive(true); proxy.postInit(event); + HazmatUtils.init(); BookHandler.runLater(); Meta_GT_Proxy.postInit(); Core_Manager.postInit(); diff --git a/src/Java/gtPlusPlus/RoadMap.java b/src/Java/gtPlusPlus/RoadMap.java index 95d00dab95..c7bb4d5a22 100644 --- a/src/Java/gtPlusPlus/RoadMap.java +++ b/src/Java/gtPlusPlus/RoadMap.java @@ -40,62 +40,41 @@ public class RoadMap { */ - /*private static final LinkedHashMap<String, ObjMap<Integer, Boolean>>mCachedResults = new LinkedHashMap<String, ObjMap<Integer, Boolean>>(); - public boolean contains(ItemStack aStack) { - if (aStack == null){ - return false; - } - ObjMap<Integer, Boolean> aCurrentSet; - if (mCachedResults.get(this.toString()) != null){ - aCurrentSet = mCachedResults.get(this.toString()); - } - - else { - aCurrentSet = new ObjMap<Integer, Boolean>(mPrefixedItems.size(), 0.5f); - mCachedResults.put(this.toString(), aCurrentSet); - } - - if (aCurrentSet.get(aStack.hashCode()) != null){ - return aCurrentSet.get(aStack.hashCode()); - } - else { - for (ItemStack tStack : mPrefixedItems){ - if (GT_Utility.areStacksEqual(aStack, tStack, !tStack.hasTagCompound())){ - aCurrentSet.put(aStack.hashCode(), true); - return true; - } - } - } - aCurrentSet.put(aStack.hashCode(), false); - return false; - }*/ - - /*private static final LinkedHashMap<String, ObjMap<Integer, Boolean>>mCachedResults = new LinkedHashMap<String, ObjMap<Integer, Boolean>>(); - - public boolean contains(ItemStack aStack) { - if (aStack == null){ - return false; - } - ObjMap<Integer, Boolean> aCurrentSet = mCachedResults.get(this.toString().toUpperCase()); - if (aCurrentSet == null){ - aCurrentSet = new ObjMap<Integer, Boolean>((mPrefixedItems != null && mPrefixedItems.size() > 0 ? mPrefixedItems.size() : 1000), 0.5f); - mCachedResults.put(this.toString().toUpperCase(), aCurrentSet); - } - int mainHash = Objects.hashCode(aStack.getItem(), aStack.getItemDamage()); - Boolean result = aCurrentSet.get(mainHash); - if (result != null){ - return result; - } - else { - for (ItemStack tStack : mPrefixedItems){ - if (GT_Utility.areStacksEqual(aStack, tStack, !tStack.hasTagCompound())){ - aCurrentSet.put(Objects.hashCode(tStack.getItem(), tStack.getItemDamage()), true); - return true; - } - } - } - aCurrentSet.put(mainHash, false); - return false; - }*/ + /* + Thallium - Everglades only. (Mostly useless) + Technetium - Has some recipes but seem to be dead ends so unobtainable. + Polonium - Unobtainable. (Radioactive, Mostly Useless) + Francium - Unobtainable. (Radioactive, Mostly Useless) + Promethium - Unobtainable. + Radium - Everglades only. (Do use, Moderately Rare) + Actinium - Unobtainable. (Radioactive, Do use) + Proactinium - Unobtainable. (Do use) + Neptunium - Has some recipes but seem to be dead ends so unobtainable. + Curium - Fusion only. + Berkelium - Unobtainable. + Californium - Fusion only. + Einsteinium - Unobtainable. + Fermium - Unobtainable. + Strontium - Everglades only. (Do use 1) + Iodine - Everglades only. + Dysprosium - Everglades only. (Do use 1) + Rhenium - Weird ABS recipe only. + Flerovium - Unobtainable. + Dubnium - Unobtainable. + Seaborgium - Unobtainable. + Bohrium - Unobtainable. + Hassium - Unobtainable. + Meitnerium - Unobtainable. + Darmstadtium - Unobtainable. + Roentgenium - Unobtainable. + Copernicium - Unobtainable. + Nihonium - Unobtainable. + Moscovium - Unobtainable. + Livermorium - Unobtainable. + Tennessine - Unobtainable. + Nobelium - Unobtainable. + Lawrencium - Unobtainable. + Astatine - Unobtainable. (Radioactive, Mostly Useless) + */ } diff --git a/src/Java/gtPlusPlus/api/objects/data/Quad.java b/src/Java/gtPlusPlus/api/objects/data/Quad.java index 01c62e95e6..fa2e52951e 100644 --- a/src/Java/gtPlusPlus/api/objects/data/Quad.java +++ b/src/Java/gtPlusPlus/api/objects/data/Quad.java @@ -1,5 +1,8 @@ package gtPlusPlus.api.objects.data; +import java.util.ArrayList; +import java.util.List; + public class Quad<K,V,C,R> { private final K key; @@ -29,5 +32,14 @@ public class Quad<K,V,C,R> { final public R getValue_3(){ return this.value3; } + + public final List values() { + List<Object> aVals = new ArrayList<Object>(); + aVals.add(key); + aVals.add(value); + aVals.add(value2); + aVals.add(value3); + return aVals; + } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java index 903730f767..c9cdc41424 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java +++ b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java @@ -7,6 +7,7 @@ import java.util.Map; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; @@ -19,6 +20,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; public class CommandEnableDebugWhileRunning implements ICommand @@ -33,14 +38,14 @@ public class CommandEnableDebugWhileRunning implements ICommand @Override public int compareTo(final Object o){ if (o instanceof Comparable<?>) { - @SuppressWarnings("unchecked") - Comparable<ICommand> a = (Comparable<ICommand>) o; - if (a.equals(this)) { - return 0; - } - else { - return -1; - } + @SuppressWarnings("unchecked") + Comparable<ICommand> a = (Comparable<ICommand>) o; + if (a.equals(this)) { + return 0; + } + else { + return -1; + } } return -1; } @@ -66,7 +71,7 @@ public class CommandEnableDebugWhileRunning implements ICommand @Override public void processCommand(final ICommandSender S, final String[] argString){ - int aMaxArgumentsAllowed = 1; + int aMaxArgumentsAllowed = 2; if ((argString == null || argString.length == 0 || argString.length > aMaxArgumentsAllowed) || argString[0].toLowerCase().equals("?")) { Logger.INFO("Listing commands and their uses."); @@ -75,6 +80,8 @@ public class CommandEnableDebugWhileRunning implements ICommand PlayerUtils.messagePlayer(P, "The following are valid args for the '/gtpp' command:"); PlayerUtils.messagePlayer(P, "? - This help command."); PlayerUtils.messagePlayer(P, "logging - Toggles ALL GT++ logging for current session."); + PlayerUtils.messagePlayer(P, "hand - Lists information about held item."); + PlayerUtils.messagePlayer(P, "fuid xxx - Tries to find the fluid in the FluidRegistry."); PlayerUtils.messagePlayer(P, "debug - Toggles GT++ Debug Mode. Only use when advised, may break everything. (OP)"); } else if (argString[0].toLowerCase().equals("debug")) { @@ -106,13 +113,72 @@ public class CommandEnableDebugWhileRunning implements ICommand String aItemDisplayName = ItemUtils.getItemName(aHeldItem); String aItemUnlocalName = ItemUtils.getUnlocalizedItemName(aHeldItem); String aNbtString = tryIterateNBTData(aHeldItem); - PlayerUtils.messagePlayer(P, "["+aItemUnlocalName+"]"+"["+aItemDisplayName+"] "+aNbtString); + AutoMap<String> aOreDictNames = new AutoMap<String>(); + + int[] aOreIDs = OreDictionary.getOreIDs(aHeldItem); + for (int id : aOreIDs) { + String aOreNameFromID = OreDictionary.getOreName(id); + if (aOreNameFromID != null && aOreNameFromID.length() > 0 && !aOreNameFromID.equals("Unknown")) { + aOreDictNames.add(aOreNameFromID); + } + } + + String aOreDictData = ""; + if (!aOreDictNames.isEmpty()) { + for (String tag : aOreDictNames) { + aOreDictData += (tag+", "); + } + if (aOreDictData.endsWith(", ")) { + aOreDictData = aOreDictData.substring(0, aOreDictData.length()-2); + } + } + + String aFluidContainerData = ""; + FluidStack aHeldItemFluid = FluidContainerRegistry.getFluidForFilledItem(aHeldItem); + if (aHeldItemFluid != null) { + aFluidContainerData = "["+aHeldItemFluid.getUnlocalizedName()+"]["+aHeldItemFluid.getLocalizedName()+"]"; + } + + PlayerUtils.messagePlayer(P, "["+aItemUnlocalName+"]"+"["+aItemDisplayName+"] "); + if (aFluidContainerData.length() > 0) { + PlayerUtils.messagePlayer(P, ""+aFluidContainerData); + } + if (!aOreDictNames.isEmpty()) { + PlayerUtils.messagePlayer(P, ""+aOreDictData); + } + if (aNbtString.length() > 0) { + PlayerUtils.messagePlayer(P, ""+aNbtString); + } } else { PlayerUtils.messagePlayer(P, "No item held."); } } } + else if (argString[0].toLowerCase().equals("fluid")) { + if (argString.length > 1 && argString[1] != null && argString[1].length() > 0) { + final EntityPlayer P = CommandUtils.getPlayer(S); + FluidStack aFluid = FluidUtils.getWildcardFluidStack(argString[1], 1); + if (P != null && aFluid != null) { + PlayerUtils.messagePlayer(P, "Found fluid stack: "+FluidRegistry.getFluidName(aFluid)); + } + else if (P != null && aFluid == null) { + PlayerUtils.messagePlayer(P, "Could not find any fluids."); + } + } + } + else if (argString[0].toLowerCase().equals("item")) { + if (argString.length > 1 && argString[1] != null && argString[1].length() > 0) { + final EntityPlayer P = CommandUtils.getPlayer(S); + ItemStack aTest = ItemUtils.getItemStackFromFQRN(argString[1], 1); + if (P != null && aTest != null) { + PlayerUtils.messagePlayer(P, "Found fluid stack: "+ItemUtils.getItemName(aTest)); + } + else if (P != null && aTest == null) { + PlayerUtils.messagePlayer(P, "Could not find valid item."); + } + } + } else { final EntityPlayer P = CommandUtils.getPlayer(S); PlayerUtils.messagePlayer(P, "Invalid command, use '?' as an argument for help.'"); @@ -134,6 +200,8 @@ public class CommandEnableDebugWhileRunning implements ICommand aTabCompletes.add("?"); aTabCompletes.add("logging"); aTabCompletes.add("debug"); + aTabCompletes.add("hand"); + aTabCompletes.add("fluid"); return aTabCompletes; } @@ -146,7 +214,7 @@ public class CommandEnableDebugWhileRunning implements ICommand public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost){ return true; } - + public static String tryIterateNBTData(ItemStack aStack) { try { AutoMap<String> aItemDataTags = new AutoMap<String>(); @@ -161,9 +229,9 @@ public class CommandEnableDebugWhileRunning implements ICommand int a = 0; String data = ""; for (String tag : aItemDataTags) { - data += (tag+","); + data += (tag+", "); } - if (data.endsWith(",")) { + if (data.endsWith(", ")) { data = data.substring(0, data.length()-2); } return data; diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 0aeff5ae16..4dad732e25 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -1,10 +1,6 @@ package gtPlusPlus.core.common; -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 cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; @@ -19,18 +15,8 @@ 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; -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.EnderDragonDeathHandler; -import gtPlusPlus.core.handler.events.EntityDeathHandler; -import gtPlusPlus.core.handler.events.GeneralTooltipEventHandler; -import gtPlusPlus.core.handler.events.PickaxeBlockBreakEventHandler; -import gtPlusPlus.core.handler.events.ZombieBackupSpawnEventHandler; +import gtPlusPlus.core.handler.*; +import gtPlusPlus.core.handler.events.*; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.chemistry.GenericChem; import gtPlusPlus.core.lib.CORE; @@ -50,7 +36,6 @@ import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO; import gtPlusPlus.xmod.galacticraft.handler.HandlerTooltip_GC; -import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; import net.minecraft.enchantment.Enchantment; @@ -89,10 +74,7 @@ public class CommonProxy { } AddToCreativeTab.initialiseTabs(); - - if (LoadedMods.Gregtech) { - HANDLER_GT.addNewOrePrefixes(); - } + EnumHelperHandler.init(); // Moved from Init after Debug Loading. // 29/01/18 - Alkalus diff --git a/src/Java/gtPlusPlus/core/handler/EnumHelperHandler.java b/src/Java/gtPlusPlus/core/handler/EnumHelperHandler.java new file mode 100644 index 0000000000..d164efa3d7 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/EnumHelperHandler.java @@ -0,0 +1,21 @@ +package gtPlusPlus.core.handler; + +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; +import gtPlusPlus.xmod.ic2.CustomInternalName; + +public class EnumHelperHandler { + + public static void init() { + + if (LoadedMods.IndustrialCraft2) { + CustomInternalName.init(); + } + + if (LoadedMods.Gregtech) { + HANDLER_GT.addNewOrePrefixes(); + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java index b3738e6ea2..6da2dac38b 100644 --- a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java @@ -19,6 +19,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -87,7 +88,6 @@ public class BlockEventHandler { } - public static final Map<String, EntityPlayer> mCachedFakePlayers = new WeakHashMap<String, EntityPlayer>(); // Used to handle Thaumcraft Shards when TC is not installed. @SubscribeEvent @@ -97,21 +97,9 @@ public class BlockEventHandler { if (event != null && event.harvester != null && event.harvester.worldObj != null) { if (!event.harvester.worldObj.isRemote) { - EntityPlayer p = event.harvester; - ChunkCoordinates aChunkLocation = p.getPlayerCoordinates(); - - // Cache Fake Player - if (p instanceof FakePlayer || p instanceof FakeThaumcraftPlayer - || (event.harvester.getCommandSenderName() == null - || event.harvester.getCommandSenderName().length() <= 0) - || (p.isEntityInvulnerable() && !p.canCommandSenderUseCommand(0, "") - && (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 - && aChunkLocation.posZ == 0))) { - mCachedFakePlayers.put(p.getUniqueID().toString(), p); - } + EntityPlayer p = event.harvester; - if (!mCachedFakePlayers.containsKey(event.harvester.getUniqueID().toString())) { - + if (PlayerUtils.isRealPlayer(p)) { // Spawns Fluorite from Lime Stone if (chanceToDropFluoriteOre != 0) { if (!oreLimestone.isEmpty() || !blockLimestone.isEmpty()) { diff --git a/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java b/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java index c4ab6edaa6..3492ee4788 100644 --- a/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java @@ -7,18 +7,25 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.ChunkCoordinates; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.entity.living.LivingDropsEvent; +import thaumcraft.common.lib.FakeThaumcraftPlayer; public class EntityDeathHandler { - - + + private static final HashMap<Class, AutoMap<Triplet<ItemStack, Integer, Integer>>> mMobDropMap = new HashMap<Class, AutoMap<Triplet<ItemStack, Integer, Integer>>>(); private static final HashSet<Class> mInternalClassKeyCache = new HashSet<Class>(); - + /** * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. * @param aMobClass - The Base Class you want to drop this item. @@ -34,15 +41,15 @@ public class EntityDeathHandler { } aDataMap.put(aData); mMobDropMap.put(aMobClass, aDataMap); - + Logger.INFO("[Loot] Registered "+aStack.getDisplayName()+" (1-"+aMaxAmount+") as a valid drop for "+aMobClass.getCanonicalName()); - + if (!mInternalClassKeyCache.contains(aMobClass)) { mInternalClassKeyCache.add(aMobClass); } - + } - + private static ItemStack processItemDropTriplet(Triplet<ItemStack, Integer, Integer> aData) { ItemStack aLoot = aData.getValue_1(); int aMaxDrop = aData.getValue_2(); @@ -55,7 +62,7 @@ public class EntityDeathHandler { } return null; } - + private static boolean processDropsForMob(EntityLivingBase entityLiving) { AutoMap<Triplet<ItemStack, Integer, Integer>> aMobData = mMobDropMap.get(entityLiving.getClass()); boolean aDidDrop = false; @@ -74,10 +81,30 @@ public class EntityDeathHandler { } return aDidDrop; } - - - - + + + + private static void dropMeatFromPlayer(EntityPlayer aPlayer) { + + // always drop some meat. + int aBigMeatStackSize1 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize1), MathUtils.randInt(0, 1)); + + // additional chances for more meat. + if (MathUtils.randInt(0, 10) < 7) { + int aBigMeatStackSize2 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize2), MathUtils.randInt(0, 1)); + } + if (MathUtils.randInt(0, 10) < 4) { + int aBigMeatStackSize3 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize3), MathUtils.randInt(0, 1)); + } + if (MathUtils.randInt(0, 10) < 2) { + int aBigMeatStackSize4 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize4), MathUtils.randInt(0, 1)); + } + + } @SubscribeEvent public void onEntityDrop(LivingDropsEvent event) { @@ -85,10 +112,16 @@ public class EntityDeathHandler { if (event == null || event.entityLiving == null) { return; } - for (Class c : mInternalClassKeyCache) { - if (c.isInstance(event.entityLiving)) { - aDidDrop = processDropsForMob(event.entityLiving); - } + if (PlayerUtils.isRealPlayer(event.entityLiving)) { + EntityPlayer aPlayer = (EntityPlayer) event.entityLiving; + dropMeatFromPlayer(aPlayer); + } + else { + for (Class c : mInternalClassKeyCache) { + if (c.isInstance(event.entityLiving)) { + aDidDrop = processDropsForMob(event.entityLiving); + } + } } } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java index 3f02ca898d..e11b163753 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -110,6 +110,7 @@ public class AgriculturalChem extends ItemPackage { * 21 - Lithium Chloride * 22 - Pellet Mold * 23 - Clean Aluminium Mix + * 24 - Pinecone */ public static ItemStack mAlgaeBiosmass; @@ -136,6 +137,8 @@ public class AgriculturalChem extends ItemPackage { public static ItemStack mLithiumChloride; public static ItemStack mPelletMold; public static ItemStack mCleanAluminiumMix; + public static ItemStack mPinecone; + public static ItemStack mCrushedPine; @Override @@ -205,6 +208,8 @@ public class AgriculturalChem extends ItemPackage { mLithiumChloride = ItemUtils.simpleMetaStack(mAgrichemItem1, 21, 1); mPelletMold = ItemUtils.simpleMetaStack(mAgrichemItem1, 22, 1); mCleanAluminiumMix = ItemUtils.simpleMetaStack(mAgrichemItem1, 23, 1); + mPinecone = ItemUtils.simpleMetaStack(mAgrichemItem1, 24, 1); + mCrushedPine = ItemUtils.simpleMetaStack(mAgrichemItem1, 25, 1); ItemUtils.addItemToOreDictionary(mGreenAlgaeBiosmass, "biomassGreenAlgae"); ItemUtils.addItemToOreDictionary(mBrownAlgaeBiosmass, "biomassBrownAlgae"); @@ -231,6 +236,8 @@ public class AgriculturalChem extends ItemPackage { ItemUtils.addItemToOreDictionary(mSodiumHydroxide, "dustSodiumHydroxide"); ItemUtils.addItemToOreDictionary(mSodiumCarbonate, "dustSodiumCarbonate"); ItemUtils.addItemToOreDictionary(mLithiumChloride, "dustLithiumChloride"); + ItemUtils.addItemToOreDictionary(mPinecone, "pinecone"); + ItemUtils.addItemToOreDictionary(mCrushedPine, "crushedPineMaterial"); //Handle GT NaOH dusts List<ItemStack> NaOHSmall = OreDictionary.getOres("dustSmallSodiumHydroxide_GT5U", false); diff --git a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java index ff55326031..80a51d80cc 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java @@ -1,33 +1,26 @@ package gtPlusPlus.core.item.chemistry; -import static gtPlusPlus.core.lib.CORE.GTNH; - -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.TextureSet; +import gregtech.api.enums.*; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; +import gtPlusPlus.core.item.circuit.ItemAdvancedChip; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.MISC_MATERIALS; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.MaterialGenerator; -import gtPlusPlus.core.material.MaterialStack; -import gtPlusPlus.core.material.NONMATERIAL; +import gtPlusPlus.core.material.*; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.plugin.agrichem.BioRecipes; import gtPlusPlus.plugin.agrichem.block.AgrichemFluids; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import net.minecraft.init.Items; 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.fluids.*; public class GenericChem extends ItemPackage { @@ -37,6 +30,7 @@ public class GenericChem extends ItemPackage { private static boolean usingGregtechNitricOxide = false; private static boolean usingGregtechNitrogenDioxide = false; + private static boolean usingGregtechHydricSulfur = false; /** * Materials @@ -94,6 +88,8 @@ public class GenericChem extends ItemPackage { public static Fluid Lithium_Peroxide; public static Fluid Nitric_Oxide; public static Fluid Nitrogen_Dioxide; + public static Fluid Carbon_Disulfide; + public static Fluid Hydrogen_Sulfide; /** * Items @@ -102,6 +98,7 @@ public class GenericChem extends ItemPackage { // Phenol Byproducts public Item PhenolicResins; //https://en.wikipedia.org/wiki/Phenol_formaldehyde_resin public static ItemGenericChemBase mGenericChemItem1; + public static Item mAdvancedCircuit; private ItemStack mCatalystCarrier; @@ -115,6 +112,11 @@ public class GenericChem extends ItemPackage { public static ItemStack mMillingBallAlumina; public static ItemStack mMillingBallSoapstone; + + public static ItemStack mSodiumEthoxide; + public static ItemStack mSodiumEthylXanthate; + public static ItemStack mPotassiumEthylXanthate; + public static ItemStack mPotassiumHydroxide; @@ -125,7 +127,9 @@ public class GenericChem extends ItemPackage { MaterialGenerator.generate(NYLON, false); MaterialGenerator.generate(TEFLON, false); - mGenericChemItem1 = new ItemGenericChemBase(); + mGenericChemItem1 = new ItemGenericChemBase(); + mAdvancedCircuit = new ItemAdvancedChip(); + GregtechItemList.Circuit_T3RecipeSelector.set(mAdvancedCircuit); registerItemStacks(); registerOreDict(); @@ -149,6 +153,10 @@ public class GenericChem extends ItemPackage { mPinkCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 6, 1); mMillingBallAlumina = ItemUtils.simpleMetaStack(mGenericChemItem1, 7, 1); mMillingBallSoapstone = ItemUtils.simpleMetaStack(mGenericChemItem1, 8, 1); + mSodiumEthoxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 9, 1); + mSodiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 10, 1); + mPotassiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 11, 1); + mPotassiumHydroxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 12, 1); } @@ -163,6 +171,10 @@ public class GenericChem extends ItemPackage { ItemUtils.addItemToOreDictionary(mPinkCatalyst, "catalystPlatinumRhodium"); ItemUtils.addItemToOreDictionary(mMillingBallAlumina, "millingballAlumina"); ItemUtils.addItemToOreDictionary(mMillingBallSoapstone, "millingballSoapstone"); + ItemUtils.addItemToOreDictionary(mSodiumEthoxide, "dustSodiumEthoxide"); + ItemUtils.addItemToOreDictionary(mSodiumEthylXanthate, "dustSodiumEthylXanthate"); + ItemUtils.addItemToOreDictionary(mPotassiumEthylXanthate, "dustPotassiumEthylXanthate"); + ItemUtils.addItemToOreDictionary(mPotassiumHydroxide, "dustPotassiumHydroxide"); } @@ -241,8 +253,30 @@ public class GenericChem extends ItemPackage { //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); - - + Carbon_Disulfide = FluidUtils.generateFluidNoPrefix("CarbonDisulfide", "Carbon Disulfide", 350, new short[]{175, 175, 175, 100}); + + if (FluidRegistry.isFluidRegistered("fluid.liquid_hydricsulfur") || MaterialUtils.doesMaterialExist("HydricSulfide")) { + usingGregtechHydricSulfur = true; + Fluid aFluid = null; + if (ItemUtils.doesItemListEntryExist("sHydricSulfur")) { + ItemStack aListItem = ItemUtils.getValueOfItemList("sHydricSulfur", 1, (ItemList) null); + if (aListItem != null) { + FluidStack aFluidStack = FluidContainerRegistry.getFluidForFilledItem(aListItem); + if (aFluidStack != null) { + aFluid = aFluidStack.getFluid(); + } + + } + } + if (aFluid == null) { + aFluid = FluidUtils.getWildcardFluidStack("liquid_hydricsulfur", 1000).getFluid(); + } + Hydrogen_Sulfide = aFluid; + } + else { + Hydrogen_Sulfide = FluidUtils.generateFluidNoPrefix("HydrogenSulfide", "Hydrogen Sulfide", 446, new short[]{240, 130, 30, 100}); + } + } @Override @@ -253,6 +287,7 @@ public class GenericChem extends ItemPackage { @Override public boolean generateRecipes() { + recipeAdvancedChip(); recipeCatalystRed(); recipeCatalystYellow(); recipeCatalystBlue(); @@ -281,17 +316,173 @@ public class GenericChem extends ItemPackage { if (!usingGregtechNitrogenDioxide) { recipeNitrogenDioxide(); } + if (!usingGregtechHydricSulfur) { + recipeHydricSulfur(); + } // Add recipes if we are not using GT's fluid. if (!FluidRegistry.isFluidRegistered("hydrochloricacid_gt5u")) { recipeHydrochloricAcid(); } + + recipeSodiumEthoxide(); + recipeCarbonDisulfide(); + recipeEthylXanthates(); + recipePotassiumHydroxide(); + registerFuels(); return true; } + private void recipeSodiumEthoxide() { + //2 C2H5OH + 2 Na → 2 C2H5ONa + H2 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(16), + ELEMENT.getInstance().SODIUM.getDust(2) + }, + new FluidStack[] { + FluidUtils.getFluidStack(BioRecipes.mEthanol, 1000), + }, + new ItemStack[] { + ItemUtils.getSimpleStack(mSodiumEthoxide, 2) + + }, + new FluidStack[] { + ELEMENT.getInstance().HYDROGEN.getFluid(2000) + }, + 20 *20, + 120, + 2); + } + + + private void recipePotassiumHydroxide() { + //Ca(OH)2 + K2CO3 → CaCO3 + 2 KOH + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(18), + ELEMENT.getInstance().POTASSIUM.getDust(4), + ELEMENT.getInstance().CARBON.getDust(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumHydroxide", 2), + }, + new FluidStack[] { + FluidUtils.getFluidStack("oxygen", 6000), + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumCarbonate", 2), + ItemUtils.getSimpleStack(mPotassiumHydroxide, 4) + + }, + new FluidStack[] { + + }, + 20 *30, + 120, + 2); + + } + + + private void recipeEthylXanthates() { + + //Potassium ethyl xanthate - CH3CH2OH + CS2 + KOH → CH3CH2OCS2K + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(17), + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumHydroxide", 2), + }, + new FluidStack[] { + FluidUtils.getFluidStack(BioRecipes.mEthanol, 1000), + FluidUtils.getFluidStack(Carbon_Disulfide, 1000), + }, + new ItemStack[] { + ItemUtils.getSimpleStack(mPotassiumEthylXanthate, 1) + }, + new FluidStack[] { + FluidUtils.getWater(1000) + }, + 20 *60, + 120, + 2); + + //Sodium ethyl xanthate - CH3CH2ONa + CS2 → CH3CH2OCS2Na + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(17), + ItemUtils.getSimpleStack(mSodiumEthoxide, 1) + }, + new FluidStack[] { + FluidUtils.getFluidStack(Carbon_Disulfide, 1000), + }, + new ItemStack[] { + ItemUtils.getSimpleStack(mSodiumEthylXanthate, 1) + }, + new FluidStack[] { + + }, + 20 *60, + 120, + 2); + + } + + + private void recipeHydricSulfur() { + + ItemStack aCellHydricSulfide = ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenSulfide", 1); + GT_Values.RA.addChemicalRecipe( ELEMENT.getInstance().SULFUR.getDust(1), GT_Utility.getIntegratedCircuit(1), ELEMENT.getInstance().HYDROGEN.getFluid(2000), FluidUtils.getFluidStack(Hydrogen_Sulfide, 3000), GT_Values.NI, 60, 8); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(ELEMENT.getInstance().SULFUR.getDust(1), CI.emptyCells(3), ELEMENT.getInstance().HYDROGEN.getFluid(2000), GT_Values.NF, ItemUtils.getSimpleStack(aCellHydricSulfide, 3), GT_Values.NI, 60, 8); + + } + + + private void recipeCarbonDisulfide() { + + CORE.RA.addBlastRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 8), + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 16) + }, + new FluidStack[] { + + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustDarkAsh", 1) + }, + new FluidStack[] { + FluidUtils.getFluidStack(Carbon_Disulfide, 4000) + }, + 20 *60 * 10, + 30, + 1500); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(20), + ItemUtils.getSimpleStack(mBrownCatalyst, 0), + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 4) + }, + new FluidStack[] { + FluidUtils.getFluidStack(CoalTar.Coal_Gas, 1000), + }, + new ItemStack[] { + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Carbon_Disulfide, 2000), + FluidUtils.getFluidStack(Hydrogen_Sulfide, 4000) + }, + 20 *60 * 5, + 30, + 2); + + + } + + private static void registerFuels() { // Burnables @@ -859,18 +1050,72 @@ public class GenericChem extends ItemPackage { private static final ItemStack getTierOneChip() { - return CI.getNumberedBioCircuit(4); + return CI.getNumberedAdvancedCircuit(4); } private static final ItemStack getTierTwoChip() { - return CI.getNumberedBioCircuit(8); + return CI.getNumberedAdvancedCircuit(8); } private static final ItemStack getTierThreeChip() { - return CI.getNumberedBioCircuit(12); + return CI.getNumberedAdvancedCircuit(12); } private static final ItemStack getTierFourChip() { - return CI.getNumberedBioCircuit(16); + return CI.getNumberedAdvancedCircuit(16); } + private static void recipeAdvancedChip() { + GT_ModHandler.addShapelessCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 0L), 0, new Object[]{OrePrefixes.circuit.get(Materials.Advanced)}); + + long bits = 0; + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 1L, new Object[0]), bits, + new Object[]{"d ", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 2L, new Object[0]), bits, + new Object[]{" d ", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 3L, new Object[0]), bits, + new Object[]{" d", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 4L, new Object[0]), bits, + new Object[]{" ", " Pd", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 5L, new Object[0]), bits, + new Object[]{" ", " P ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 6L, new Object[0]), bits, + new Object[]{" ", " P ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 7L, new Object[0]), bits, + new Object[]{" ", " P ", "d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 8L, new Object[0]), bits, + new Object[]{" ", "dP ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 9L, new Object[0]), bits, + new Object[]{"P d", " ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 10L, new Object[0]), bits, + new Object[]{"P ", " d", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 11L, new Object[0]), bits, + new Object[]{"P ", " ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 12L, new Object[0]), bits, + new Object[]{"P ", " ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 13L, new Object[0]), bits, + new Object[]{" P", " ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 14L, new Object[0]), bits, + new Object[]{" P", " ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 15L, new Object[0]), bits, + new Object[]{" P", " ", "d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 16L, new Object[0]), bits, + new Object[]{" P", "d ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 17L, new Object[0]), bits, + new Object[]{" ", " ", "d P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 18L, new Object[0]), bits, + new Object[]{" ", "d ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 19L, new Object[0]), bits, + new Object[]{"d ", " ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 20L, new Object[0]), bits, + new Object[]{" d ", " ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 21L, new Object[0]), bits, + new Object[]{"d ", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 22L, new Object[0]), bits, + new Object[]{" d ", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 23L, new Object[0]), bits, + new Object[]{" d", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 24L, new Object[0]), bits, + new Object[]{" ", " d", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); + } } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java b/src/Java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java index 426f48ecf9..71bf2f3e6f 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java @@ -1,56 +1,104 @@ package gtPlusPlus.core.item.chemistry; +import java.util.HashMap; + import gregtech.api.enums.Materials; +import gregtech.api.util.GT_OreDictUnificator; +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.api.objects.data.Quad; import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.base.ore.BaseItemMilledOre; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.NONMATERIAL; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.*; +import gtPlusPlus.xmod.bop.HANDLER_BiomesOPlenty; +import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; public class MilledOreProcessing extends ItemPackage { /** * Fluids */ - - public static Fluid ZincFlotationFroth; - public static Fluid CopperFlotationFroth; + + public static Fluid SphaleriteFlotationFroth; + public static Fluid ChalcopyriteFlotationFroth; public static Fluid NickelFlotationFroth; public static Fluid PlatinumFlotationFroth; public static Fluid PentlanditeFlotationFroth; - - + + public static Fluid RedstoneFlotationFroth; + public static Fluid SpessartineFlotationFroth; + public static Fluid GrossularFlotationFroth; + public static Fluid AlmandineFlotationFroth; + public static Fluid PyropeFlotationFroth; + + public static Fluid PineOil; + + /** * Items */ // Zinc, Iron, Indium, Germanium public static Item milledSphalerite; - + // Copper, Iron, Cadmium, Indium public static Item milledChalcopyrite; - + // Nickel, Cobalt, Rhodium, Ruthenium public static Item milledNickel; - + // Platinum, Rhodium, Selenium, Tellurium public static Item milledPlatinum; // Iron, Nickel, Promethium, Hafnium public static Item milledPentlandite; - + + + + + // Redstone, Chrome, Firestone, Dysprosium + public static Item milledRedstone; + + // Manganese, Aluminium, Osmium, Strontium + public static Item milledSpessartine; + + // Calcium, Aluminium, Tungsten, Thallium + public static Item milledGrossular; + + // Aluminium, Magnesium, Yttrium, Ytterbium + public static Item milledAlmandine; + + // Magnesium, Manganese, Borax, Rhenium + public static Item milledPyrope; + @Override public void items() { - milledSphalerite = BaseItemMilledOre.generate(Materials.Sphalerite, MaterialUtils.getVoltageForTier(5)); - milledChalcopyrite = BaseItemMilledOre.generate(Materials.Chalcopyrite, MaterialUtils.getVoltageForTier(4)); - milledNickel = BaseItemMilledOre.generate(Materials.Nickel, MaterialUtils.getVoltageForTier(4)); - milledPlatinum = BaseItemMilledOre.generate(Materials.Platinum, MaterialUtils.getVoltageForTier(5)); - milledPentlandite = BaseItemMilledOre.generate(Materials.Pentlandite, MaterialUtils.getVoltageForTier(5)); - + milledSphalerite = BaseItemMilledOre.generate(Materials.Sphalerite, MaterialUtils.getVoltageForTier(6)); + milledChalcopyrite = BaseItemMilledOre.generate(Materials.Chalcopyrite, MaterialUtils.getVoltageForTier(5)); + milledNickel = BaseItemMilledOre.generate(Materials.Nickel, MaterialUtils.getVoltageForTier(5)); + milledPlatinum = BaseItemMilledOre.generate(Materials.Platinum, MaterialUtils.getVoltageForTier(6)); + milledPentlandite = BaseItemMilledOre.generate(Materials.Pentlandite, MaterialUtils.getVoltageForTier(6)); + + milledRedstone = BaseItemMilledOre.generate(Materials.Redstone, MaterialUtils.getVoltageForTier(5)); + milledSpessartine = BaseItemMilledOre.generate(Materials.Spessartine, MaterialUtils.getVoltageForTier(6)); + milledGrossular = BaseItemMilledOre.generate(Materials.Grossular, MaterialUtils.getVoltageForTier(6)); + milledAlmandine = BaseItemMilledOre.generate(Materials.Almandine, MaterialUtils.getVoltageForTier(6)); + milledPyrope = BaseItemMilledOre.generate(Materials.Pyrope, MaterialUtils.getVoltageForTier(4)); + } @Override @@ -60,11 +108,11 @@ public class MilledOreProcessing extends ItemPackage { @Override public void fluids() { - + short[] aZincFrothRGB = Materials.Sphalerite.mRGBa; - ZincFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.zincflotation", "Zinc Froth", 32 + 175, new short[] { aZincFrothRGB[0], aZincFrothRGB[1], aZincFrothRGB[2], 100 }, true); + SphaleriteFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.zincflotation", "Sphalerite Froth", 32 + 175, new short[] { aZincFrothRGB[0], aZincFrothRGB[1], aZincFrothRGB[2], 100 }, true); short[] aCopperFrothRGB = Materials.Chalcopyrite.mRGBa; - CopperFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.copperflotation", "Copper Froth", 32 + 175, new short[] { aCopperFrothRGB[0], aCopperFrothRGB[1], aCopperFrothRGB[2], 100 }, true); + ChalcopyriteFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.copperflotation", "Chalcopyrite Froth", 32 + 175, new short[] { aCopperFrothRGB[0], aCopperFrothRGB[1], aCopperFrothRGB[2], 100 }, true); short[] aNickelFrothRGB = Materials.Nickel.mRGBa; NickelFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.nickelflotation", "Nickel Froth", 32 + 175, new short[] { aNickelFrothRGB[0], aNickelFrothRGB[1], aNickelFrothRGB[2], 100 }, true); short[] aPlatinumFrothRGB = Materials.Platinum.mRGBa; @@ -72,9 +120,23 @@ public class MilledOreProcessing extends ItemPackage { short[] aPentlanditeFrothRGB = Materials.Pentlandite.mRGBa; PentlanditeFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.pentlanditeflotation", "Pentlandite Froth", 32 + 175, new short[] { aPentlanditeFrothRGB[0], aPentlanditeFrothRGB[1], aPentlanditeFrothRGB[2], 100 }, true); + short[] aRedstoneFrothRGB = Materials.Redstone.mRGBa; + RedstoneFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.redstoneflotation", "Redstone Froth", 32 + 175, new short[] { aRedstoneFrothRGB[0], aRedstoneFrothRGB[1], aRedstoneFrothRGB[2], 100 }, true); + short[] aSpessartineFrothRGB = Materials.Spessartine.mRGBa; + SpessartineFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.spessartineflotation", "Spessartine Froth", 32 + 175, new short[] { aSpessartineFrothRGB[0], aSpessartineFrothRGB[1], aSpessartineFrothRGB[2], 100 }, true); + short[] aGrossularFrothRGB = Materials.Grossular.mRGBa; + GrossularFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.grossularflotation", "Grossular Froth", 32 + 175, new short[] { aGrossularFrothRGB[0], aGrossularFrothRGB[1], aGrossularFrothRGB[2], 100 }, true); + short[] aAlmandineFrothRGB = Materials.Almandine.mRGBa; + AlmandineFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.almandineflotation", "Almandine Froth", 32 + 175, new short[] { aAlmandineFrothRGB[0], aAlmandineFrothRGB[1], aAlmandineFrothRGB[2], 100 }, true); + short[] aPyropeFrothRGB = Materials.Pyrope.mRGBa; + PyropeFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.pyropeflotation", "Pyrope Froth", 32 + 175, new short[] { aPyropeFrothRGB[0], aPyropeFrothRGB[1], aPyropeFrothRGB[2], 100 }, true); + + + PineOil = FluidUtils.generateFluidNoPrefix("pineoil", "Pine Oil", 32 + 175, new short[] { 250, 200, 60, 100 }, true); + } - - + + public MilledOreProcessing() { super(); @@ -83,20 +145,95 @@ public class MilledOreProcessing extends ItemPackage { private static void addMiscRecipes() { - /*GT_Values.RA.addCentrifugeRecipe( - CI.getNumberedBioCircuit(10), - GT_Values.NI, - FluidUtils.getFluidStack(MilledOreProcessing.ZincFlotationFroth, 1000), - FluidUtils.getWater(500), - ELEMENT.getInstance().IRON.getSmallDust(1), - ELEMENT.getInstance().COPPER.getSmallDust(1), - ELEMENT.getInstance().TIN.getSmallDust(1), - ELEMENT.getInstance().SULFUR.getSmallDust(1), - ELEMENT.getInstance().NICKEL.getTinyDust(1), - ELEMENT.getInstance().LEAD.getTinyDust(1), - new int[] { 3000, 3000, 2000, 2000, 1000, 1000 }, - 30 * 20, - 30);*/ + /* + * First 5 + */ + + //milledSphalerite + registerOreDataForMilledType( + SphaleriteFlotationFroth, + ELEMENT.getInstance().ZINC, 180, + ELEMENT.getInstance().IRON, 120, + ELEMENT.getInstance().INDIUM, 40, + ELEMENT.getInstance().GERMANIUM, 15 + ); + //milledChalcopyrite + registerOreDataForMilledType( + ChalcopyriteFlotationFroth, + ELEMENT.getInstance().COPPER, 180, + ELEMENT.getInstance().IRON, 120, + ELEMENT.getInstance().CADMIUM, 50, + ELEMENT.getInstance().INDIUM, 10 + ); + //milledNickel + registerOreDataForMilledType( + NickelFlotationFroth, + ELEMENT.getInstance().NICKEL, 150, + ELEMENT.getInstance().COBALT, 120, + ELEMENT.getInstance().RHODIUM, 32, + ELEMENT.getInstance().RUTHENIUM, 16 + ); + //milledPlatinum + registerOreDataForMilledType( + PlatinumFlotationFroth, + ELEMENT.getInstance().PLATINUM, 120, + ELEMENT.getInstance().RHODIUM, 60, + ELEMENT.getInstance().SELENIUM, 40, + ELEMENT.getInstance().TELLURIUM, 10 + ); + //milledPentlandite + registerOreDataForMilledType( + PentlanditeFlotationFroth, + ELEMENT.getInstance().IRON, 150, + ELEMENT.getInstance().NICKEL, 100, + ELEMENT.getInstance().PROMETHIUM, 20, + ELEMENT.getInstance().HAFNIUM, 10 + ); + + /* + * Second 5 + */ + //milledRedstone + registerOreDataForMilledType( + RedstoneFlotationFroth, + NONMATERIAL.REDSTONE, 300, + ELEMENT.getInstance().CHROMIUM, 60, + MaterialUtils.generateMaterialFromGtENUM(Materials.Firestone), 45, + ELEMENT.getInstance().DYSPROSIUM, 16 + ); + //milledSpessartine + registerOreDataForMilledType( + SpessartineFlotationFroth, + ELEMENT.getInstance().MANGANESE, 150, + ELEMENT.getInstance().ALUMINIUM, 90, + ELEMENT.getInstance().OSMIUM, 30, + ELEMENT.getInstance().STRONTIUM, 20 + ); + //milledGrossular + registerOreDataForMilledType( + GrossularFlotationFroth, + ELEMENT.getInstance().CALCIUM, 180, + ELEMENT.getInstance().ALUMINIUM, 110, + ELEMENT.getInstance().TUNGSTEN, 60, + ELEMENT.getInstance().THALLIUM, 15 + ); + //milledAlmandine + registerOreDataForMilledType( + AlmandineFlotationFroth, + ELEMENT.getInstance().ALUMINIUM, 150, + ELEMENT.getInstance().MAGNESIUM, 75, + ELEMENT.getInstance().YTTRIUM, 25, + ELEMENT.getInstance().YTTERBIUM, 15 + ); + //milledPyrope + registerOreDataForMilledType( + PyropeFlotationFroth, + ELEMENT.getInstance().MAGNESIUM, 110, + ELEMENT.getInstance().MANGANESE, 70, + MaterialUtils.generateMaterialFromGtENUM(Materials.Borax), 60, + ELEMENT.getInstance().RHENIUM, 20 + ); + } @@ -108,6 +245,532 @@ public class MilledOreProcessing extends ItemPackage { @Override public boolean generateRecipes() { addMiscRecipes(); + addPineOilExtraction(); + addFlotationRecipes1(); + addFlotationRecipes2(); + addVacuumFurnaceRecipes(); return true; } + + private void addVacuumFurnaceRecipes() { + int aCircuitID = 1; + + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(SphaleriteFlotationFroth, 4000) + }, + getOutputsFromMap(SphaleriteFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(ChalcopyriteFlotationFroth, 4000) + }, + getOutputsFromMap(ChalcopyriteFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(5), + 4500); + + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(NickelFlotationFroth, 4000) + }, + getOutputsFromMap(NickelFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(5), + 4500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(PlatinumFlotationFroth, 4000) + }, + getOutputsFromMap(PlatinumFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(PentlanditeFlotationFroth, 4000) + }, + getOutputsFromMap(PentlanditeFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + + + + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(RedstoneFlotationFroth, 4000) + }, + getOutputsFromMap(RedstoneFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(5), + 4500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(SpessartineFlotationFroth, 4000) + }, + getOutputsFromMap(SpessartineFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(GrossularFlotationFroth, 4000) + }, + getOutputsFromMap(GrossularFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(AlmandineFlotationFroth, 4000) + }, + getOutputsFromMap(AlmandineFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] { + CI.getNumberedCircuit(aCircuitID++) + }, + new FluidStack[] { + FluidUtils.getFluidStack(PyropeFlotationFroth, 4000) + }, + getOutputsFromMap(PyropeFlotationFroth), + new FluidStack[] { + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), + FluidUtils.getWater(2000) + }, + 20 * 120, + MaterialUtils.getVoltageForTier(4), + 3500); + + } + + private void addFlotationRecipes1() { + + // Sphalerite + CORE.RA.addFlotationRecipe( + Materials.Sphalerite, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 14000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(SphaleriteFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(6) + ); + + // Chalcopyrite + CORE.RA.addFlotationRecipe( + Materials.Chalcopyrite, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 12000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(ChalcopyriteFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(5) + ); + + // Nickel + CORE.RA.addFlotationRecipe( + Materials.Nickel, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 25000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(NickelFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(5) + ); + + // Platinum + CORE.RA.addFlotationRecipe( + Materials.Platinum, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 35000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(PlatinumFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(6) + ); + + + // Pentlandite + CORE.RA.addFlotationRecipe( + Materials.Pentlandite, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 14000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(PentlanditeFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(6) + ); + + } + + private void addFlotationRecipes2() { + + // Redstone + CORE.RA.addFlotationRecipe( + Materials.Redstone, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 13000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(RedstoneFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(5) + ); + + // Spessartine + CORE.RA.addFlotationRecipe( + Materials.Spessartine, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 35000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(SpessartineFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(6) + ); + + // Grossular + CORE.RA.addFlotationRecipe( + Materials.Grossular, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 28000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(GrossularFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(6) + ); + + // Almandine + CORE.RA.addFlotationRecipe( + Materials.Almandine, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 18000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(AlmandineFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(5) + ); + + // Pyrope + CORE.RA.addFlotationRecipe( + Materials.Pyrope, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 8000), + }, + new FluidStack[] { + FluidUtils.getFluidStack(PyropeFlotationFroth, 1000) + }, + 20 * 1200, + MaterialUtils.getVoltageForTier(4) + ); + + } + + private void addPineOilExtraction() { + AutoMap<ItemStack> aLogs = new AutoMap<ItemStack>(); + AutoMap<ItemStack> aLeaves = new AutoMap<ItemStack>(); + AutoMap<ItemStack> aSaplings = new AutoMap<ItemStack>(); + AutoMap<ItemStack> aPinecones = new AutoMap<ItemStack>(); + + ItemStack aCrushedPine = ItemUtils.getSimpleStack(AgriculturalChem.mCrushedPine, 1); + + aLogs.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.log_Pine)); + aLeaves.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.leaves_Pine)); + aSaplings.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Pine)); + aPinecones.add(ItemUtils.getSimpleStack(AgriculturalChem.mPinecone, 1)); + + if (LoadedMods.BiomesOPlenty) { + aLogs.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.logs4, 0, 1)); + aLeaves.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.colorizedLeaves2, 1, 1)); + aSaplings.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.colorizedSaplings, 5, 1)); + aPinecones.add(ItemUtils.simpleMetaStack(HANDLER_BiomesOPlenty.mPineCone, 13, 1)); + } + if (LoadedMods.Forestry) { + ItemStack aForestryLog = ItemUtils.getItemStackFromFQRN("Forestry:logs", 1); + if (aForestryLog != null) { + aForestryLog.setItemDamage(20); // Set to Pine + aLogs.add(aForestryLog); + } + ItemStack aForestryLeaves = ItemUtils.getItemStackFromFQRN("Forestry:leaves", 1); + if (aForestryLeaves != null) { + NBTUtils.setString(aForestryLeaves, "species", "forestry.treePine"); // Set to Pine + aLeaves.add(aForestryLeaves); + } + } + + for (ItemStack aLog : aLogs) { + addRecipe(aLog, ItemUtils.getSimpleStack(aCrushedPine, 16), new int[] {10000, 7500, 5000, 2500}, 10, 120); + } + for (ItemStack aLeaf : aLeaves) { + addRecipe(aLeaf, ItemUtils.getSimpleStack(aCrushedPine, 2), new int[] {5000, 5000, 2500, 2500}, 10, 30); + } + for (ItemStack aSapling : aSaplings) { + addRecipe(aSapling, ItemUtils.getSimpleStack(aCrushedPine, 4), new int[] {7500, 7500, 2500, 2500}, 10, 60); + } + for (ItemStack aCone : aPinecones) { + addRecipe(aCone, ItemUtils.getSimpleStack(aCrushedPine, 1), new int[] {7500, 7500, 5000, 2500}, 10, 60); + } + + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(16), + ItemUtils.getSimpleStack(aCrushedPine, 64) + }, + new FluidStack[] { + FluidUtils.getSteam(5000), + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5) + }, + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 500) + }, + new int[] { + 2000, 2000, 2000, 2000 + }, + 20 * 60, + 120, + 2); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemUtils.getSimpleStack(aCrushedPine, 64) + }, + new FluidStack[] { + FluidUtils.getSuperHeatedSteam(5000), + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5) + }, + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 1500) + }, + new int[] { + 3000, 3000, 3000, 3000 + }, + 20 * 45, + 120, + 3); + + } + + public boolean addRecipe(ItemStack aInput, ItemStack aOutput1, int[] aChances, int aTime, int aEU) { + aOutput1 = GT_OreDictUnificator.get(true, aOutput1); + ItemStack aOutputs[] = new ItemStack[4]; + for (int i=0;i<aChances.length;i++) { + aOutputs[i] = aOutput1; + } + aOutputs = cleanArray(aOutputs); + if ((GT_Utility.isStackInvalid(aInput)) || (GT_Utility.isStackInvalid(aOutput1) || (GT_Utility.getContainerItem(aInput, false) != null))) { + return false; + } + + return CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(14), + aInput + }, + new FluidStack[] { + + }, + aOutputs, + new FluidStack[] { + + }, + aChances, + aTime * 20, + aEU, + 1); + } + + public static ItemStack[] cleanArray(ItemStack[] input) { + int aArraySize = input.length; + AutoMap<ItemStack> aCleanedItems = new AutoMap<ItemStack>(); + for (ItemStack checkStack : input) { + if (ItemUtils.checkForInvalidItems(checkStack)) { + aCleanedItems.put(checkStack); + } + } + ItemStack[] aOutput = new ItemStack[aCleanedItems.size()]; + for (int i=0;i<aArraySize;i++) { + ItemStack aMappedStack = aCleanedItems.get(i); + if (aMappedStack != null){ + aOutput[i] = aMappedStack; + } + } + return aOutput; + } + + private static final HashMap<String, Quad<Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>>> aMilledFluidMap = new HashMap<String, Quad<Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>>>(); + + public static void registerOreDataForMilledType(Fluid aMilledFluid, Materials aOutput1, int aPerc1, Materials aOutput2, int aPerc2, Materials aOutput3, int aPerc3, Materials aOutput4, int aPerc4) { + registerOreDataForMilledType(aMilledFluid, MaterialUtils.generateMaterialFromGtENUM(aOutput1), aPerc1, MaterialUtils.generateMaterialFromGtENUM(aOutput2), aPerc2, MaterialUtils.generateMaterialFromGtENUM(aOutput3), aPerc3, MaterialUtils.generateMaterialFromGtENUM(aOutput4), aPerc4); + } + + public static void registerOreDataForMilledType(Fluid aMilledFluid, Material aOutput1, int aPerc1, Material aOutput2, int aPerc2, Material aOutput3, int aPerc3, Material aOutput4, int aPerc4) { + + Pair<Material, Integer> aFluidOutput1 = new Pair<Material, Integer>(aOutput1, aPerc1); + Pair<Material, Integer> aFluidOutput2 = new Pair<Material, Integer>(aOutput2, aPerc2); + Pair<Material, Integer> aFluidOutput3 = new Pair<Material, Integer>(aOutput3, aPerc3); + Pair<Material, Integer> aFluidOutput4 = new Pair<Material, Integer>(aOutput4, aPerc4); + Quad<Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>> aDataQuad = new Quad<Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>>(aFluidOutput1, aFluidOutput2, aFluidOutput3, aFluidOutput4); + aMilledFluidMap.put(aMilledFluid.getUnlocalizedName(), aDataQuad); + + } + + private static ItemStack[] getOutputsFromMap(Fluid aFluid) { + String aKey = aFluid.getUnlocalizedName(); + return getArrayFromQuad(aMilledFluidMap.get(aKey)); + } + + private static ItemStack[] getArrayFromQuad(Quad<Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>, Pair<Material, Integer>> aData) { + AutoMap<ItemStack> aOutputs = new AutoMap<ItemStack>(); + for (Object aPair : aData.values()) { + if (aPair != null && Pair.class.isInstance(aPair)) { + Pair aObj = (Pair) aPair; + Material aMat = (Material) aObj.getKey(); + int aCount = (int) aObj.getValue(); + aOutputs.addAll(getItemStackFromPair(aMat, aCount)); + } + } + ItemStack[] aRealOutputArray = new ItemStack[aOutputs.size()]; + int aIndex = 0; + for (ItemStack aStack : aOutputs) { + aRealOutputArray[aIndex++] = aStack; + } + return aRealOutputArray; + } + + private static AutoMap<ItemStack> getItemStackFromPair(Material aMat, Integer aCount) { + AutoMap<ItemStack> aOutputs = new AutoMap<ItemStack>(); + if (aCount > 64) { + AutoMap<Integer> sizes = getStackSizes(aCount); + for (int aSplitSize : sizes) { + ItemStack aDustStack = aMat.getDust(aSplitSize); + aOutputs.put(aDustStack); + } + } + else { + ItemStack aDustStack = aMat.getDust(aCount); + aOutputs.put(aDustStack); + } + return aOutputs; + } + + private static AutoMap<Integer> getStackSizes(int aBigSize){ + AutoMap<Integer> aSizes = new AutoMap<Integer>(); + if (aBigSize <= 64) { + aSizes.add(aBigSize); + } + else { + for (int i = aBigSize; i > 0; i -= 64) { + aSizes.add(i); + } + } + return aSizes; + } + } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java index 459acb31b9..7745f50010 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -185,7 +185,7 @@ public class RocketFuels extends ItemPackage { CORE.RA.addChemicalPlantRecipe( new ItemStack[] { - CI.getNumberedBioCircuit(21), + CI.getNumberedAdvancedCircuit(21), }, new FluidStack[] { FluidUtils.getFluidStack("ammonia", 4000), @@ -220,7 +220,7 @@ public class RocketFuels extends ItemPackage { CORE.RA.addChemicalPlantRecipe( new ItemStack[] { - CI.getNumberedBioCircuit(21), + CI.getNumberedAdvancedCircuit(21), ItemUtils.getSimpleStack(Formaldehyde_Catalyst, 0), }, new FluidStack[] { @@ -258,7 +258,7 @@ public class RocketFuels extends ItemPackage { CORE.RA.addChemicalPlantRecipe( new ItemStack[] { - CI.getNumberedBioCircuit(21), + CI.getNumberedAdvancedCircuit(21), ItemUtils.getSimpleStack(Formaldehyde_Catalyst, 0), }, new FluidStack[] { diff --git a/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java b/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java index 7fb5f207f6..ed17f8547a 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java @@ -3,6 +3,8 @@ package gtPlusPlus.core.item.chemistry.general; import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.item.chemistry.GenericChem; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.client.renderer.texture.IIconRegister; @@ -12,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; @@ -19,7 +23,7 @@ public class ItemGenericChemBase extends Item { final protected IIcon base[]; - final private int aMetaSize = 9; + final private int aMetaSize = 13; /* * 0 - Red Metal Catalyst //FeCu @@ -31,6 +35,10 @@ public class ItemGenericChemBase extends Item { * 6 - Pink Metal Catalyst //PtRh * 7 - Alumina Grinding Ball * 8 - Soapstone Grinding Ball + * 9 - Sodium Ethoxide // 2 Sodium + 1 Ethanol | 2 C2H5OH + 2 Na → 2 C2H5ONa + H2 + * 10 - Sodium Ethyl Xanthate //CH3CH2ONa + CS2 → CH3CH2OCS2Na + * 11 - Potassium Ethyl Xanthate //CH3CH2OH + CS2 + KOH → CH3CH2OCS2K + H2O + * 12 - Potassium Hydroxide // KOH */ public ItemGenericChemBase() { @@ -44,6 +52,14 @@ public class ItemGenericChemBase extends Item { } @Override + public int getItemStackLimit(ItemStack stack) { + if (ItemUtils.isMillingBall(stack)) { + return 16; + } + return super.getItemStackLimit(stack); + } + + @Override public boolean isDamageable() { return false; } @@ -64,17 +80,6 @@ public class ItemGenericChemBase extends Item { } @Override - public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { - try { - - } - catch (Throwable t) { - t.printStackTrace(); - } - super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); - } - - @Override public EnumRarity getRarity(ItemStack p_77613_1_) { return EnumRarity.common; } @@ -112,11 +117,6 @@ public class ItemGenericChemBase extends Item { } @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - - @Override public int getItemEnchantability() { return 0; } @@ -161,4 +161,167 @@ public class ItemGenericChemBase extends Item { } + + @Override + public double getDurabilityForDisplay(ItemStack aStack) { + if (ItemUtils.isMillingBall(aStack)) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()){ + createMillingBallNBT(aStack); + } + double currentDamage = getMillingBallDamage(aStack); + double durabilitypercent = currentDamage / 100; + return durabilitypercent; + } + else if (ItemUtils.isCatalyst(aStack)) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()){ + createCatalystNBT(aStack); + } + double currentDamage = getCatalystDamage(aStack); + double durabilitypercent = currentDamage / 100; + return durabilitypercent; + } + else { + return 1D; + } + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack aStack, EntityPlayer player, List list, boolean bool) { + boolean aHasSpecialTooltips = false; + int aMaxDamage = 0; + int aDamageSegment = 0; + int aDam = 0; + EnumChatFormatting durability = EnumChatFormatting.GRAY; + if (ItemUtils.isMillingBall(aStack)) { + list.add(EnumChatFormatting.GRAY+"Tumble Tumble Tumble"); + aMaxDamage = getMillingBallMaxDamage(aStack); + aDamageSegment = aMaxDamage / 5; + aDam = aMaxDamage-getMillingBallDamage(aStack); + aHasSpecialTooltips = true; + } + if (ItemUtils.isCatalyst(aStack)) { + list.add(EnumChatFormatting.GRAY+"Active Reaction Agent"); + aMaxDamage = getCatalystMaxDamage(aStack); + aDamageSegment = aMaxDamage / 5; + aDam = aMaxDamage-getCatalystDamage(aStack); + aHasSpecialTooltips = true; + } + if (aHasSpecialTooltips) { + if (aDam > aDamageSegment * 4){ + durability = EnumChatFormatting.GRAY; + } + else if (aDam > aDamageSegment * 3){ + durability = EnumChatFormatting.GREEN; + } + else if (aDam > aDamageSegment * 2){ + durability = EnumChatFormatting.YELLOW; + } + else if (aDam > aDamageSegment){ + durability = EnumChatFormatting.GOLD; + } + else if (aDam > 0){ + durability = EnumChatFormatting.RED; + } + list.add(durability+""+(aDam)+EnumChatFormatting.GRAY+" / "+aMaxDamage); + } + super.addInformation(aStack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack aStack) { + if (ItemUtils.isMillingBall(aStack)) { + int aDam = getMillingBallDamage(aStack); + if (aDam > 0) { + return true; + } + } + else if (ItemUtils.isCatalyst(aStack)) { + int aDam = getCatalystDamage(aStack); + if (aDam > 0) { + return true; + } + } + return false; + } + + public static boolean createMillingBallNBT(ItemStack rStack){ + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagNBT.setLong("MaxDamage", getMaxBallDurability(rStack)); + tagMain.setTag("MillingBall", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static int getMillingBallDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createMillingBallNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("MillingBall").getInteger("Damage"); + } + + public static int getMillingBallMaxDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createMillingBallNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("MillingBall").getInteger("MaxDamage"); + } + + public static void setMillingBallDamage(ItemStack aStack,int aAmount) { + NBTTagCompound aNBT = aStack.getTagCompound(); + aNBT = aNBT.getCompoundTag("MillingBall"); + aNBT.setInteger("Damage", aAmount); + } + + public static int getMaxBallDurability(ItemStack aStack) { + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { + return 100; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallSoapstone, true)) { + return 50; + } + return 0; + } + + public static boolean createCatalystNBT(ItemStack rStack){ + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagNBT.setLong("MaxDamage", getMaxCatalystDurability(rStack)); + tagMain.setTag("catalyst", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static int getCatalystDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createCatalystNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("catalyst").getInteger("Damage"); + } + + public static int getCatalystMaxDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createCatalystNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("catalyst").getInteger("MaxDamage"); + } + + public static void setCatalystDamage(ItemStack aStack,int aAmount) { + NBTTagCompound aNBT = aStack.getTagCompound(); + aNBT = aNBT.getCompoundTag("catalyst"); + aNBT.setInteger("Damage", aAmount); + } + + public static int getMaxCatalystDurability(ItemStack aStack) { + return 50; + } + + } diff --git a/src/Java/gtPlusPlus/core/item/circuit/ItemAdvancedChip.java b/src/Java/gtPlusPlus/core/item/circuit/ItemAdvancedChip.java new file mode 100644 index 0000000000..c375c32952 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/circuit/ItemAdvancedChip.java @@ -0,0 +1,138 @@ +package gtPlusPlus.core.item.circuit; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemAdvancedChip extends Item { + + protected IIcon base; + + public ItemAdvancedChip() { + this.setHasSubtypes(true); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName("T3RecipeSelector"); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean shouldRotateAroundWhenRendering() { + return super.shouldRotateAroundWhenRendering(); + } + + @Override + public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + return super.getItemStackDisplayName(aStack); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + try { + aList.add("Configuration == "+aStack.getItemDamage()); + } + catch (Throwable t) { + t.printStackTrace(); + } + super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); + } + + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return EnumRarity.common; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + aList.add(ItemUtils.simpleMetaStack(aItem, 0, 1)); + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return stack.getItemDamage(); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } + + @Override + public void registerIcons(final IIconRegister u) { + this.base = u.registerIcon(CORE.MODID + ":" + "science/general/AdvancedCircuit"); + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + return this.base; + } + + @Override + public IIcon getIconFromDamage(int damage) { + return this.base; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return this.base; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return this.base; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName(); + } + + +} diff --git a/src/Java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java b/src/Java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java new file mode 100644 index 0000000000..1f8009e54a --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java @@ -0,0 +1,31 @@ +package gtPlusPlus.core.item.wearable.hazmat; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.ic2.CustomInternalName; +import ic2.core.IC2; +import ic2.core.init.InternalName; +import ic2.core.item.armor.ItemArmorHazmat; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; + +public class ItemArmorHazmatEx extends ItemArmorHazmat { + + public static void init() { + GregtechItemList.Armour_Hazmat_Advanced_Helmet.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatHelmetEx, 0))); + GregtechItemList.Armour_Hazmat_Advanced_Chest.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatChestEx, 1))); + GregtechItemList.Armour_Hazmat_Advanced_Legs.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatLegsEx, 2))); + GregtechItemList.Armour_Hazmat_Advanced_Boots.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatBootsEx, 3))); + } + + private ItemArmorHazmatEx(InternalName internalName, int type) { + super(internalName, type); + this.setMaxDamage(256); + } + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + int suffix = this.armorType == 2 ? 2 : 1; + return IC2.textureDomain + ":textures/armor/" + "hazmatEx_" + suffix + ".png"; + } + +} diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 7d49a8d635..dee064353a 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -3,11 +3,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; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -1304,6 +1300,23 @@ public class Material { } + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (!Material.class.isInstance(obj)) { + return false; + } + Material aObj = (Material) obj; + if (aObj.unlocalizedName.equals(this.unlocalizedName)) { + if (aObj.localizedName.equals(this.localizedName)) { + return true; + } + } + return false; + } + public boolean registerComponentForMaterial(FluidStack aStack) { return registerComponentForMaterial(this, aStack); } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 1561f4b475..ea1bcdb9de 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -120,7 +120,7 @@ public class RECIPES_GREGTECH { // Advanced method for Nitric Acid Production CORE.RA.addChemicalPlantRecipe( new ItemStack[] { - CI.getNumberedBioCircuit(17), + CI.getNumberedAdvancedCircuit(17), CI.getPinkCatalyst(0), }, new FluidStack[] { @@ -140,7 +140,7 @@ public class RECIPES_GREGTECH { CORE.RA.addChemicalPlantRecipe( new ItemStack[] { - CI.getNumberedBioCircuit(16), + CI.getNumberedAdvancedCircuit(16), CI.getPinkCatalyst(0), }, new FluidStack[] { @@ -161,7 +161,7 @@ public class RECIPES_GREGTECH { // Produce Boric Acid CORE.RA.addChemicalPlantRecipe( new ItemStack[] { - CI.getNumberedCircuit(21), + CI.getNumberedAdvancedCircuit(21), ItemUtils.getItemStackOfAmountFromOreDict("dustBorax", 4), }, new FluidStack[] { @@ -182,7 +182,7 @@ public class RECIPES_GREGTECH { // Produce Th232 CORE.RA.addChemicalPlantRecipe( new ItemStack[] { - CI.getNumberedCircuit(22), + CI.getNumberedAdvancedCircuit(22), ELEMENT.getInstance().THORIUM.getDust(16) }, new FluidStack[] { diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index ebc2c07a63..387f7bef65 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -265,6 +265,21 @@ public class RECIPES_Machines { GregtechItemList.ChemicalPlant_Controller.get(1), 120 * 20, MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedBioCircuit(15), + CI.getTieredGTPPMachineCasing(1, 2), + ItemList.Hatch_Input_Bus_MV.get(1), + CI.getTieredComponentOfMaterial(Materials.Bronze, OrePrefixes.gearGt, 8), + CI.getTieredComponentOfMaterial(Materials.Lead, OrePrefixes.plate, 48), + CI.getTieredComponentOfMaterial(Materials.SolderingAlloy, OrePrefixes.wireFine, 16), + }, + ALLOY.BRONZE.getFluid(2 * (144 * 4)), + GregtechItemList.Bus_Catalysts.get(1), + 60 * 20, + MaterialUtils.getVoltageForTier(2)); } @@ -301,7 +316,7 @@ public class RECIPES_Machines { CORE.RA.addChemicalPlantRecipe( new ItemStack[] { - CI.getNumberedBioCircuit(19), + CI.getNumberedAdvancedCircuit(19), ItemList.Distillation_Tower.get(2), GregtechItemList.GTPP_Casing_IV.get(16), CI.getTieredComponent(OrePrefixes.circuit, 6, 8) @@ -340,7 +355,7 @@ public class RECIPES_Machines { } CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - CI.getNumberedBioCircuit(21), + CI.getNumberedAdvancedCircuit(21), CI.getElectricPiston(i, 10), CI.getFieldGenerator(i + 1, 6), CI.getPlate(i, 16), @@ -917,7 +932,7 @@ public class RECIPES_Machines { CI.getGear(1, GTNH ? 4 : 2) }; aSemiFluidInputs[1] = new ItemStack[]{ - CI.getNumberedBioCircuit(14), + CI.getNumberedCircuit(14), CI.getTieredMachineHull(2, 1), CI.getElectricPiston(2, GTNH ? 4 : 2), CI.getTieredComponent(OrePrefixes.circuit, 2, GTNH ? 4 : 2), @@ -925,7 +940,7 @@ public class RECIPES_Machines { CI.getGear(2, GTNH ? 4 : 2) }; aSemiFluidInputs[2] = new ItemStack[]{ - CI.getNumberedBioCircuit(14), + CI.getNumberedAdvancedCircuit(14), CI.getTieredMachineHull(3, 1), CI.getElectricPiston(3, GTNH ? 4 : 2), CI.getTieredComponent(OrePrefixes.circuit, 3, GTNH ? 4 : 2), @@ -2268,7 +2283,7 @@ public class RECIPES_Machines { CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - GregtechItemList.Casing_Vacuum_Furnace.get(Casing_Amount), + GregtechItemList.Casing_Vacuum_Furnace.get(aCostMultiplier), CI.getTieredComponent(OrePrefixes.wireGt16, 7, 4 * aCostMultiplier), CI.getEnergyCore(6, 1 * aCostMultiplier), CI.getRobotArm(4, 4 * aCostMultiplier), diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index d67a372572..93ede378a8 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -1235,6 +1235,10 @@ public class CI { return ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, i, 0); } + public static ItemStack getNumberedAdvancedCircuit(int i) { + return ItemUtils.simpleMetaStack(GenericChem.mAdvancedCircuit, i, 0); + } + public static ItemStack getTieredGTPPMachineCasing(int aTier, int aAmount) { GregtechItemList[] aHulls = new GregtechItemList[] { GregtechItemList.GTPP_Casing_ULV, diff --git a/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java b/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java index 48b050d678..19795a41e4 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java +++ b/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java @@ -11,6 +11,7 @@ public class SlotIntegratedCircuit extends Slot { public static Item mCircuitItem; public static Item mCircuitItem2; + public static Item mCircuitItem3; private final short mCircuitLock; public SlotIntegratedCircuit(final IInventory inventory, final int slot, final int x, final int y) { @@ -44,9 +45,12 @@ public class SlotIntegratedCircuit extends Slot { if (mCircuitItem2 == null) { mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); } - if (mCircuitItem != null && mCircuitItem2 != null) { + if (mCircuitItem3 == null) { + mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { if (itemstack != null) { - if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2) { + if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2 || itemstack.getItem() == mCircuitItem3) { if (aLockedCircuitNumber == -1) { isValid = true; } @@ -73,7 +77,10 @@ public class SlotIntegratedCircuit extends Slot { if (mCircuitItem2 == null) { mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); } - if (mCircuitItem != null && mCircuitItem2 != null) { + if (mCircuitItem3 == null) { + mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { if (itemstack != null) { if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2) { if (itemstack.getItem() == mCircuitItem) { @@ -81,7 +88,10 @@ public class SlotIntegratedCircuit extends Slot { } else if (itemstack.getItem() == mCircuitItem2) { return 1; - } + } + else if (itemstack.getItem() == mCircuitItem3) { + return 2; + } } } } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java index 23ad2a3233..835d9da2cd 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java @@ -110,6 +110,9 @@ public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInv else if (aTypeInSlot == 1) { aOutput = CI.getNumberedBioCircuit(e); } + else if (aTypeInSlot == 2) { + aOutput = CI.getNumberedAdvancedCircuit(e); + } else { aOutput = null; } diff --git a/src/Java/gtPlusPlus/core/util/data/AES.java b/src/Java/gtPlusPlus/core/util/data/AES.java new file mode 100644 index 0000000000..1183cdd8e7 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/data/AES.java @@ -0,0 +1 @@ +\u0070\u0061\u0063\u006b\u0061\u0067\u0065\u0020\u0067\u0074\u0050\u006c\u0075\u0073\u0050\u006c\u0075\u0073\u002e\u0063\u006f\u0072\u0065\u002e\u0075\u0074\u0069\u006c\u002e\u0064\u0061\u0074\u0061\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0069\u006f\u002e\u0055\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u006d\u0061\u0074\u0068\u002e\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u006e\u0069\u006f\u002e\u0063\u0068\u0061\u0072\u0073\u0065\u0074\u002e\u0053\u0074\u0061\u006e\u0064\u0061\u0072\u0064\u0043\u0068\u0061\u0072\u0073\u0065\u0074\u0073\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0073\u0065\u0063\u0075\u0072\u0069\u0074\u0079\u002e\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0073\u0065\u0063\u0075\u0072\u0069\u0074\u0079\u002e\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0075\u0074\u0069\u006c\u002e\u0041\u0072\u0072\u0061\u0079\u0073\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0075\u0074\u0069\u006c\u002e\u0042\u0061\u0073\u0065\u0036\u0034\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u0078\u002e\u0063\u0072\u0079\u0070\u0074\u006f\u002e\u0043\u0069\u0070\u0068\u0065\u0072\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u0078\u002e\u0063\u0072\u0079\u0070\u0074\u006f\u002e\u0073\u0070\u0065\u0063\u002e\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u003b\u000d\u000a\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0063\u006c\u0061\u0073\u0073\u0020\u0041\u0045\u0053\u0020\u007b\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u003b\u003b\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u003b\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u006b\u0065\u0079\u003b\u0009\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0041\u0045\u0053\u0028\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0074\u0068\u0069\u0073\u0028\u0022\u0044\u0061\u0072\u006b\u006e\u0065\u0073\u0073\u0020\u0049\u006e\u0020\u0054\u0068\u0065\u0069\u0072\u0020\u0048\u0065\u0061\u0072\u0074\u0073\u0022\u0029\u003b\u0009\u0009\u000d\u000a\u0009\u007d\u0009\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0041\u0045\u0053\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0065\u0063\u0072\u0065\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0073\u0065\u0063\u0072\u0065\u0074\u0020\u003d\u0020\u0061\u0053\u0065\u0063\u0072\u0065\u0074\u003b\u000d\u000a\u0009\u0009\u006b\u0065\u0079\u0020\u003d\u0020\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0067\u0065\u0074\u0048\u0061\u0073\u0068\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0073\u0065\u0063\u0072\u0065\u0074\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0020\u003d\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u004b\u0065\u0079\u0028\u006b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0067\u0065\u0074\u0048\u0061\u0073\u0068\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0074\u006f\u0048\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0067\u0065\u0074\u0053\u0048\u0041\u0028\u0061\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0067\u0065\u0074\u0053\u0048\u0041\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0070\u0075\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u006d\u0064\u003b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u006d\u0064\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0053\u0048\u0041\u002d\u0032\u0035\u0036\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006d\u0064\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0069\u006e\u0070\u0075\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0053\u0074\u0061\u006e\u0064\u0061\u0072\u0064\u0043\u0068\u0061\u0072\u0073\u0065\u0074\u0073\u002e\u0055\u0054\u0046\u005f\u0038\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u007b\u007d\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0074\u006f\u0048\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0068\u0061\u0073\u0068\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0028\u0031\u002c\u0020\u0068\u0061\u0073\u0068\u0029\u003b\u000d\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0042\u0075\u0069\u006c\u0064\u0065\u0072\u0020\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0042\u0075\u0069\u006c\u0064\u0065\u0072\u0028\u006e\u0075\u006d\u0062\u0065\u0072\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0031\u0036\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u006c\u0065\u006e\u0067\u0074\u0068\u0028\u0029\u0020\u003c\u0020\u0033\u0032\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0069\u006e\u0073\u0065\u0072\u0074\u0028\u0030\u002c\u0020\u0027\u0030\u0027\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u004b\u0065\u0079\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u003b\u000d\u000a\u0009\u0009\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u0073\u0068\u0061\u003b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0073\u0068\u0061\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0053\u0048\u0041\u002d\u0032\u0035\u0036\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0073\u0068\u0061\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0061\u004b\u0065\u0079\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0053\u0074\u0061\u006e\u0064\u0061\u0072\u0064\u0043\u0068\u0061\u0072\u0073\u0065\u0074\u0073\u002e\u0055\u0054\u0046\u005f\u0038\u0029\u0029\u003b\u0020\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0031\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0065\u0031\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0009\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u0061\u004b\u0065\u0079\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0022\u0055\u0054\u0046\u002d\u0038\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0073\u0068\u0061\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0053\u0048\u0041\u002d\u0031\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u0073\u0068\u0061\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u006b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u0041\u0072\u0072\u0061\u0079\u0073\u002e\u0063\u006f\u0070\u0079\u004f\u0066\u0028\u006b\u0065\u0079\u002c\u0020\u0031\u0036\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u003b\u000d\u000a\u0009\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0055\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u007d\u0009\u0009\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u007b\u007d\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u004b\u0065\u0079\u0028\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0061\u004b\u0065\u0079\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0028\u0061\u004b\u0065\u0079\u002c\u0020\u0022\u0041\u0045\u0053\u0022\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0065\u006e\u0063\u006f\u0064\u0065\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0074\u0072\u0054\u006f\u0045\u006e\u0063\u0072\u0079\u0070\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0045\u0043\u0042\u002f\u0050\u004b\u0043\u0053\u0035\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0045\u004e\u0043\u0052\u0059\u0050\u0054\u005f\u004d\u004f\u0044\u0045\u002c\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0042\u0061\u0073\u0065\u0036\u0034\u002e\u0067\u0065\u0074\u0045\u006e\u0063\u006f\u0064\u0065\u0072\u0028\u0029\u002e\u0065\u006e\u0063\u006f\u0064\u0065\u0054\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0064\u006f\u0046\u0069\u006e\u0061\u006c\u0028\u0073\u0074\u0072\u0054\u006f\u0045\u006e\u0063\u0072\u0079\u0070\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0022\u0055\u0054\u0046\u002d\u0038\u0022\u0029\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u006f\u0075\u0074\u002e\u0070\u0072\u0069\u006e\u0074\u006c\u006e\u0028\u0022\u0045\u0072\u0072\u006f\u0072\u0020\u0077\u0068\u0069\u006c\u0065\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0069\u006e\u0067\u003a\u0020\u0022\u0020\u002b\u0020\u0065\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0075\u006c\u006c\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u006f\u0064\u0065\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0074\u0072\u0054\u006f\u0044\u0065\u0063\u0072\u0079\u0070\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0045\u0043\u0042\u002f\u0050\u004b\u0043\u0053\u0035\u0050\u0041\u0044\u0044\u0049\u004e\u0047\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0044\u0045\u0043\u0052\u0059\u0050\u0054\u005f\u004d\u004f\u0044\u0045\u002c\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0064\u006f\u0046\u0069\u006e\u0061\u006c\u0028\u0042\u0061\u0073\u0065\u0036\u0034\u002e\u0067\u0065\u0074\u0044\u0065\u0063\u006f\u0064\u0065\u0072\u0028\u0029\u002e\u0064\u0065\u0063\u006f\u0064\u0065\u0028\u0073\u0074\u0072\u0054\u006f\u0044\u0065\u0063\u0072\u0079\u0070\u0074\u0029\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0075\u006c\u006c\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u007d
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/data/EnumUtils.java b/src/Java/gtPlusPlus/core/util/data/EnumUtils.java index 9c96b61876..edcc071b54 100644 --- a/src/Java/gtPlusPlus/core/util/data/EnumUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/EnumUtils.java @@ -12,10 +12,13 @@ public class EnumUtils { **/ public static <T extends Enum<T>> T getValue(Class<T> enumeration, String name) { Optional<T> j = Enums.getIfPresent(enumeration, name); - T VALUE = j.get(); - if (j.get() == null) { + T VALUE; + if (j == null || !j.isPresent()) { VALUE = valueOfIgnoreCase(enumeration, name); } + else { + VALUE = j.get(); + } return VALUE; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java index 7daefbcc23..8b02ea9c7c 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/EnergyUtils.java @@ -1,17 +1,20 @@ package gtPlusPlus.core.util.minecraft; import gregtech.api.util.GT_ModHandler; -import gtPlusPlus.api.objects.Logger; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; import ic2.api.item.ISpecialElectricItem; +import net.minecraft.item.ItemRedstone; import net.minecraft.item.ItemStack; public class EnergyUtils { public static class EU { - public static boolean isElectricItem(ItemStack aStack) { + public static boolean isElectricItem(ItemStack aStack) { + if (aStack == null || aStack.getItem() == null || aStack.getItem() instanceof ItemRedstone) { + return false; + } if (aStack.getItem() instanceof ISpecialElectricItem) { return true; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java index 66f9e2453d..fda7b0b738 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java @@ -16,12 +16,11 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.IC2Potion; import ic2.core.item.armor.ItemArmorHazmat; import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; @@ -103,7 +102,7 @@ public class EntityUtils { duration = radiationLevel*30; } //IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15); - GT_Utility.applyRadioactivity(entityLiving, radiationLevel, stackSize); + applyRadioactivity(entityLiving, radiationLevel, stackSize); } } } @@ -111,6 +110,68 @@ public class EntityUtils { } return false; } + + public static boolean isWearingFullFrostHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Frost(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullHeatHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Fire(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullBioHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Biohazard(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullRadioHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Radiation(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullElectroHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Electricity(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean isWearingFullGasHazmat(EntityLivingBase aEntity) { + for (byte i = 1; i < 5; i++) + if (!HazmatUtils.providesProtetion_Gas(aEntity.getEquipmentInSlot(i))) { + return false; + } + return true; + } + + public static boolean applyRadioactivity(EntityLivingBase aEntity, int aLevel, int aAmountOfItems) { + if (aLevel > 0 && aEntity != null && aEntity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD && aEntity.getCreatureAttribute() != EnumCreatureAttribute.ARTHROPOD && !ItemArmorHazmat.hasCompleteHazmat(aEntity)) { + PotionEffect tEffect = null; + aEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, aLevel * 140 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.moveSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.digSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(Potion.confusion.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.confusion)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(Potion.weakness.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.weakness)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(Potion.hunger.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.hunger)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect(IC2Potion.radiation.id, aLevel * 180 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.potionTypes[24])) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + return true; + } + return false; + } public static boolean applyHeatDamageToEntity(final int heatLevel, final World world, final Entity entityHolding){ if (!world.isRemote){ diff --git a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java index be57853dda..f0b93a32dc 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java @@ -1,29 +1,27 @@ package gtPlusPlus.core.util.minecraft; -import static gregtech.api.GregTech_API.sBioHazmatList; -import static gregtech.api.GregTech_API.sElectroHazmatList; -import static gregtech.api.GregTech_API.sFrostHazmatList; -import static gregtech.api.GregTech_API.sGasHazmatList; -import static gregtech.api.GregTech_API.sHeatHazmatList; -import static gregtech.api.GregTech_API.sRadioHazmatList; - -import java.util.Collections; +import static gregtech.api.GregTech_API.*; + +import java.lang.reflect.Field; import java.util.HashMap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.objects.GT_HashSet; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_ModHandler; +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.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import ic2.core.Ic2Items; import ic2.core.item.armor.ItemArmorHazmat; import ic2.core.item.armor.ItemArmorNanoSuit; import ic2.core.item.armor.ItemArmorQuantumSuit; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.event.entity.player.ItemTooltipEvent; @@ -36,39 +34,8 @@ public class HazmatUtils { private static boolean mInit = false; private static HazmatUtils mInstance; - - private static final String[] mDefaultHazmat = new String[] { - "IC2:itemArmorNanoHelmet:27", - "IC2:itemArmorNanoChestplate:27", - "IC2:itemArmorNanoLegs:27", - "IC2:itemArmorNanoBoots:27", - - "IC2:itemArmorQuantumHelmet:27", - "IC2:itemArmorQuantumChestplate:27", - "IC2:itemArmorQuantumLegs:27", - "IC2:itemArmorQuantumBoots:27", - }; - - - private static final String[] mGravisuit = new String[] { - "GraviSuite:advNanoChestPlate:27", - "GraviSuite:graviChestPlate:27", - }; - private static final String[] mElectroMagicTools = new String[] { - "EMT:NanosuitGogglesRevealing:27", - "EMT:NanoBootsTraveller:27", - "EMT:NanosuitWing:27", - "EMT:itemArmorQuantumChestplate:27", - "EMT:QuantumGogglesRevealing:27", - "EMT:QuantumBootsTraveller:27", - "EMT:QuantumWing:27", - }; - private static final String[] mAdvancedSolarPanels = new String[] { - "AdvancedSolarPanel:advanced_solar_helmet:27", - "AdvancedSolarPanel:hybrid_solar_helmet:27", - "AdvancedSolarPanel:ultimate_solar_helmet:27", - }; + @SuppressWarnings("rawtypes") public static void init() { if (mInit) { return; @@ -76,39 +43,101 @@ public class HazmatUtils { mInstance = new HazmatUtils(); - sHazmatList.add(GT_ModHandler.getIC2Item("hazmatHelmet", 1L, 32767)); - sHazmatList.add(GT_ModHandler.getIC2Item("hazmatChestplate", 1L, 32767)); - sHazmatList.add(GT_ModHandler.getIC2Item("hazmatLeggings", 1L, 32767)); - sHazmatList.add(GT_ModHandler.getIC2Item("hazmatBoots", 1L, 32767)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatHelmet, 1)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatChestplate, 1)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatLeggings, 1)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatBoots, 1)); // Make Nano a hazmat suit // Make Quantum a hazmat suit if (LoadedMods.IndustrialCraft2 || LoadedMods.IndustrialCraft2Classic) { - for (String aItemName : mDefaultHazmat) { - addProtection(ItemUtils.getItemStackFromFQRN(aItemName, 1)); + AutoMap<ItemStack> aVanillaIC2Armour = new AutoMap<ItemStack>(); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoHelmet, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoBodyarmor, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoLeggings, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoBoots, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumHelmet, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumBodyarmor, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumLeggings, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumBoots, 1)); + for (ItemStack aItem : aVanillaIC2Armour) { + addProtection(aItem); } Logger.INFO("[Hazmat] Registered IC2 Items as hazmat gear."); } if (LoadedMods.isModLoaded("EMT")) { - for (String aItemName : mElectroMagicTools) { - addProtection(ItemUtils.getItemStackFromFQRN(aItemName, 1)); + AutoMap<Field> aItemFields = new AutoMap<Field>(); + Class aItemsEMT = ReflectionUtils.getClass("emt.init.EMTItems"); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoThaumicHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoWing")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoBootsTraveller")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumThaumicHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumWing")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumArmor")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumBootsTraveller")); + AutoMap<ItemStack> aEMT = new AutoMap<ItemStack>(); + for (Field aItemField : aItemFields) { + Item aItemObject = null; + if (aItemField != null) { + try { + aItemObject = (Item) aItemField.get(null); + } + catch (Exception t) { + t.printStackTrace(); + } + } + if (aItemObject != null) { + aEMT.add(ItemUtils.getSimpleStack(aItemObject)); + } + else { + Logger.INFO("[Hazmat] Could not get "+aItemField.getName()+" from "+aItemsEMT.getName()); + } + } + Logger.INFO("[Hazmat] Registering "+aEMT.size()+" EMT Items as hazmat gear."); + for (ItemStack aItem : aEMT) { + addProtection(aItem); } Logger.INFO("[Hazmat] Registered EMT Items as hazmat gear."); } - if (LoadedMods.isModLoaded("GraviSuite")) { - for (String aItemName : mGravisuit) { - addProtection(ItemUtils.getItemStackFromFQRN(aItemName, 1)); + if (LoadedMods.isModLoaded("GraviSuite")) { + AutoMap<Field> aItemFields = new AutoMap<Field>(); + Class aItemsGravisuite = ReflectionUtils.getClass("gravisuite.GraviSuite"); + aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "advNanoChestPlate")); + aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "graviChestPlate")); + AutoMap<ItemStack> aGravisuite = new AutoMap<ItemStack>(); + for (Field aItemField : aItemFields) { + Item aItemObject = (Item) ReflectionUtils.getFieldValue(aItemField); + if (aItemObject != null) { + aGravisuite.add(ItemUtils.getSimpleStack(aItemObject)); + } + } + Logger.INFO("[Hazmat] Registering "+aGravisuite.size()+" Gravisuit Items as hazmat gear."); + for (ItemStack aItem : aGravisuite) { + addProtection(aItem); } Logger.INFO("[Hazmat] Registered Gravisuit Items as hazmat gear."); } if (LoadedMods.isModLoaded("AdvancedSolarPanel")) { - for (String aItemName : mAdvancedSolarPanels) { - addProtection(ItemUtils.getItemStackFromFQRN(aItemName, 1)); + AutoMap<Field> aItemFields = new AutoMap<Field>(); + Class aItemsEMT = ReflectionUtils.getClass("advsolar.common.AdvancedSolarPanel"); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "advancedSolarHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "hybridSolarHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "ultimateSolarHelmet")); + AutoMap<ItemStack> aASP = new AutoMap<ItemStack>(); + for (Field aItemField : aItemFields) { + Item aItemObject = (Item) ReflectionUtils.getFieldValue(aItemField); + if (aItemObject != null) { + aASP.add(ItemUtils.getSimpleStack(aItemObject)); + } + } + Logger.INFO("[Hazmat] Registering "+aASP.size()+" Adv. Solar Items as hazmat gear."); + for (ItemStack aItem : aASP) { + addProtection(aItem); } Logger.INFO("[Hazmat] Registered Adv. Solar Items as hazmat gear."); } @@ -124,38 +153,36 @@ public class HazmatUtils { @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { //Logger.INFO("Ticking Hazmat handler"); - if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED - && GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.SERVER_START) { - //Logger.INFO("[Hazmat] Bad Phase : " + GTplusplus.CURRENT_LOAD_PHASE); - return; - } - if (event.itemStack == null || isVanillaHazmatPiece(event.itemStack)) { - //Logger.INFO("[Hazmat] Invalid Itemstack or vanilla hazmat"); - return; - } else { - ItemStack aStackTemp = event.itemStack; - GT_ItemStack aStack = new GT_ItemStack(aStackTemp); - if (isNanoArmourPiece(aStackTemp) || isQuantumArmourPiece(aStackTemp)) { - event.toolTip.add(EnumChatFormatting.DARK_PURPLE+"Provides full hazmat protection."); - } - else { - //Logger.INFO("[Hazmat] Finding Tooltip Data"); - String[] aTooltips = getTooltips(aStack); - if (aTooltips == null || aTooltips.length == 0) { - //Logger.INFO("[Hazmat] No Info!"); - return; - } else { - //Logger.INFO("[Hazmat] Found Tooltips!"); - if (providesProtection(aStackTemp)) { - event.toolTip.add(EnumChatFormatting.LIGHT_PURPLE+"Provides full hazmat protection."); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + + if (event.itemStack == null || isVanillaHazmatPiece(event.itemStack)) { + //Logger.INFO("[Hazmat] Invalid Itemstack or vanilla hazmat"); + return; + } else { + ItemStack aStackTemp = event.itemStack; + GT_ItemStack aStack = new GT_ItemStack(aStackTemp); + if (isNanoArmourPiece(aStackTemp) || isQuantumArmourPiece(aStackTemp)) { + event.toolTip.add(EnumChatFormatting.DARK_PURPLE+"Provides full hazmat protection."); + } + else { + //Logger.INFO("[Hazmat] Finding Tooltip Data"); + String[] aTooltips = getTooltips(aStack); + if (aTooltips == null || aTooltips.length == 0) { + //Logger.INFO("[Hazmat] No Info!"); + return; } else { - event.toolTip.add(mToolTipText); - for (String r : aTooltips) { - event.toolTip.add(" - " + r); + //Logger.INFO("[Hazmat] Found Tooltips!"); + if (providesProtection(aStackTemp)) { + event.toolTip.add(EnumChatFormatting.LIGHT_PURPLE+"Provides full hazmat protection."); + } else { + event.toolTip.add(mToolTipText); + for (String r : aTooltips) { + event.toolTip.add(" - " + r); + } } } - } - } + } + } } } @@ -173,7 +200,7 @@ public class HazmatUtils { if (living == null || living.isDead) { return false; } else { - + // Map All Player Armour slots AutoMap<ItemStack> aEquipment = new AutoMap<ItemStack>(); for (int i = 1; i < 5; ++i) { @@ -190,11 +217,13 @@ public class HazmatUtils { // Compare Equipment to all items mapped for full hazmat. for (ItemStack aSlotStack : aEquipment) { if (!isHazmatPiece(aSlotStack)) { + //Logger.INFO("Found item which is not hazmat. "+ItemUtils.getItemName(aSlotStack)); return false; } } // We are in some kind of full hazmat, huzzah! + //Logger.INFO("Has full hazmat."); return true; } } @@ -247,6 +276,18 @@ public class HazmatUtils { * @return - Did we register this ItemStack properly? */ public static boolean addProtection(ItemStack aVanStack) { + if (!ItemUtils.checkForInvalidItems(aVanStack)) { + Logger.INFO("=================Bad Hazmat Addition======================"); + Logger.INFO("Called from: "+ReflectionUtils.getMethodName(0)); + Logger.INFO(ReflectionUtils.getMethodName(1)); + Logger.INFO(ReflectionUtils.getMethodName(2)); + Logger.INFO(ReflectionUtils.getMethodName(3)); + Logger.INFO(ReflectionUtils.getMethodName(4)); + Logger.INFO(ReflectionUtils.getMethodName(5)); + Logger.INFO(ReflectionUtils.getMethodName(6)); + Logger.INFO("=========================================================="); + return false; + } Logger.INFO("[Hazmat] Registering " + aVanStack.getDisplayName() + " for full Hazmat protection."); GT_ItemStack aStack = getGtStackFromVanilla(aVanStack); AutoMap<Boolean> aAdded = new AutoMap<Boolean>(); @@ -339,22 +380,35 @@ public class HazmatUtils { return providesProtetion_Generic(sElectroHazmatList, aStack); } - private static boolean providesProtetion_Generic(GT_HashSet aSet, ItemStack aStack) { + private static boolean providesProtetion_Generic(GT_HashSet<GT_ItemStack> aSet, ItemStack aStack) { if (isVanillaHazmatPiece(aStack)) { return true; } - return aSet.getMap().containsKey(aStack); + for (GT_ItemStack o : aSet) { + if (o != null && o.mItem != null && aStack != null && aStack.getItem() != null) { + if (GT_Utility.areStacksEqual(o.toStack(), aStack, true)) { + return true; + } + if (o.isStackEqual(aStack)){ + return true; + } + if (o.mItem == aStack.getItem() && EnergyUtils.EU.isElectricItem(aStack)) { + return true; + } + } + } + return false; } private static String[] getTooltips(GT_ItemStack aStack) { - String aKey = convertGtItemstackToStringData(aStack); + String aKey = convertGtItemstackToStringDataIgnoreDamage(aStack); AutoMap<String> aTempTooltipData = mToolTips.get(aKey); - if (aTempTooltipData == null) { + if (aTempTooltipData == null || aTempTooltipData.isEmpty()) { //Logger.INFO("[Hazmat] Item was not mapped for TTs - "+aKey); return new String[] {}; } else { //Logger.INFO("[Hazmat] Item was mapped for TTs"); - Collections.sort(aTempTooltipData); + //Collections.sort(aTempTooltipData); //Logger.INFO("[Hazmat] Sorted TTs"); String[] mBuiltOutput = new String[aTempTooltipData.size()]; @@ -368,15 +422,15 @@ public class HazmatUtils { } private static void registerTooltip(GT_ItemStack aStack, String aTooltip) { - String aKey = convertGtItemstackToStringData(aStack); + String aKey = convertGtItemstackToStringDataIgnoreDamage(aStack); Logger.INFO("[Hazmat] Mapping " + aTooltip + " for " + aKey); AutoMap<String> aTempTooltipData = mToolTips.get(aKey); if (aTempTooltipData == null) { Logger.INFO("No data mapped yet, creating."); aTempTooltipData = new AutoMap<String>(); + mToolTips.put(aKey, aTempTooltipData); } aTempTooltipData.add(aTooltip); - mToolTips.put(convertGtItemstackToStringData(aStack), aTempTooltipData); } public static ItemStack getStackFromGtStack(GT_ItemStack aGtStack) { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 725799a43d..70b635583d 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -109,7 +109,7 @@ public class ItemUtils { final ItemStack y = ItemUtils.simpleMetaStack(x, WILDCARD_VALUE, 1); return y; } - + public static ItemStack getIC2Cell(final String S) { final ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + S, 1); @@ -174,7 +174,7 @@ public class ItemUtils { Logger.ERROR(ItemUtils.getItemName(stack) + " not registered. [NULL]"); } } - + public static void addItemToOreDictionary(final ItemStack stack, final String oreDictName) { addItemToOreDictionary(stack, oreDictName, false); } @@ -291,8 +291,31 @@ public class ItemUtils { public static ItemStack getItemStackFromFQRN(final String fqrn, final int Size) // fqrn = fully qualified resource name { + Logger.INFO("Trying to split string '"+fqrn+"'."); final String[] fqrnSplit = fqrn.split(":"); - return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + if (fqrnSplit.length < 2) { + return null; + } + else { + if (fqrnSplit.length == 2) { + Logger.INFO("Mod: "+fqrnSplit[0]+", Item: "+fqrnSplit[1]); + return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + } + else if (fqrnSplit.length == 3 && fqrnSplit[2] != null && fqrnSplit[2].length() > 0) { + Logger.INFO("Mod: "+fqrnSplit[0]+", Item: "+fqrnSplit[1]+", Meta: "+fqrnSplit[2]); + ItemStack aStack = GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + int aMeta = Integer.parseInt(fqrnSplit[2]); + if (aStack != null && (aMeta >= 0 && aMeta <= Short.MAX_VALUE)){ + return ItemUtils.simpleMetaStack(aStack, aMeta, Size); + } + else { + Logger.INFO("Could not find instance of Item: "+fqrnSplit[1]); + + } + } + + } + return null; } public static void generateSpawnEgg(final String entityModID, final String parSpawnName, final int colourEgg, @@ -871,6 +894,9 @@ public class ItemUtils { } public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { + if (mPrefix == OrePrefixes.rod) { + mPrefix = OrePrefixes.stick; + } ItemStack aGtStack = GT_OreDictUnificator.get(mPrefix, mMat, mAmount); if (aGtStack == null) { Logger.INFO( @@ -1065,11 +1091,11 @@ public class ItemUtils { } - + public static String getFluidName(FluidStack aFluid) { return aFluid != null ? aFluid.getFluid().getLocalizedName(aFluid) : "NULL"; } - + public static String getFluidName(Fluid aFluid) { return aFluid != null ? aFluid.getLocalizedName() : "NULL"; } @@ -1227,10 +1253,11 @@ public class ItemUtils { public static ItemStack depleteStack(ItemStack aStack, int aAmount) { final int cap = aStack.stackSize; - if (cap > 1 && cap > aAmount) { - aStack.stackSize = (MathUtils.balance((aStack.stackSize - 1), 0, 64)); - if (aStack.stackSize > 0) { - return aStack; + if (cap >= 1 && cap >= aAmount) { + ItemStack aDepStack = aStack.copy(); + aDepStack.stackSize = (MathUtils.balance((aDepStack.stackSize - 1), 0, 64)); + if (aDepStack.stackSize > 0) { + return aDepStack; } } return getNullStack(); @@ -1239,13 +1266,13 @@ public class ItemUtils { public static boolean isControlCircuit(ItemStack aStack) { if (aStack != null) { Item aItem = aStack.getItem(); - if (aItem == CI.getNumberedBioCircuit(0).getItem() || aItem == CI.getNumberedCircuit(0).getItem()) { + if (aItem == CI.getNumberedBioCircuit(0).getItem() || aItem == CI.getNumberedCircuit(0).getItem() || aItem == CI.getNumberedAdvancedCircuit(0).getItem()) { return true; } } return false; } - + public static boolean isCatalyst(ItemStack aStack) { if (GT_Utility.areStacksEqual(aStack, RocketFuels.Formaldehyde_Catalyst_Stack, true)) { return true; @@ -1276,7 +1303,7 @@ public class ItemUtils { } return false; } - + public static boolean isMillingBall(ItemStack aStack) { if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { return true; @@ -1290,9 +1317,9 @@ public class ItemUtils { public static String getLocalizedNameOfBlock(Block aBlock, int aMeta) { return LangUtils.getLocalizedNameOfBlock(aBlock, aMeta); } - - + + public static boolean doesItemListEntryExist(String string) { ItemList[] aListValues = ItemList.class.getEnumConstants(); for (ItemList aItem : aListValues) { @@ -1320,11 +1347,11 @@ public class ItemUtils { } return aOther; } - + public static ItemStack getValueOfItemList(String string, int aAmount, ItemList aOther) { return getValueOfItemList(string, aOther).get(aAmount); } - + public static ItemStack getValueOfItemList(String string, int aAmount, ItemStack aOther) { ItemList[] aListValues = ItemList.class.getEnumConstants(); for (ItemList aItem : aListValues) { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 64a6c9e820..7e9e34ae47 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -209,10 +209,10 @@ public class MaterialUtils { } public static int getTierOfMaterial(final double aMeltingPoint){ - + return aMeltingPoint < 1000 ? 0 : (MathUtils.roundToClosestInt(aMeltingPoint/1000f)); - - + + /*if ((aMeltingPoint >= 0) && (aMeltingPoint <= 1000)){ return 1; } @@ -250,40 +250,42 @@ public class MaterialUtils { public static int getVoltageForTier(int aTier) { //aTier += 1; - Probably some logic to this, idk. - if (aTier <= 0) { - return 16; - } else if (aTier == 1) { - return 30; - } else if (aTier == 2) { - return 120; - } else if (aTier == 3) { - return 480; - } else if (aTier == 4) { - return 1920; - } else if (aTier == 5) { - return 7680; - } else if (aTier == 6) { - return 30720; - } else if (aTier == 7) { - return 122880; - } else if (aTier == 8) { - return 491520; - } else if (aTier == 9) { - return 1966080; - } else if (aTier == 10) { - return 7864320; - } else if (aTier == 11) { - return 31457280; - } else if (aTier == 12) { - return 125829120; - } else if (aTier == 13) { - return 503316480; - } else if (aTier == 14) { - return 2013265920; - } else { - return Integer.MAX_VALUE; - } - + + switch(aTier){ + case 0: + return 16; + case 1: + return 30; + case 2: + return 120; + case 3: + return 480; + case 4: + return 1920; + case 5: + return 7680; + case 6: + return 30720; + case 7: + return 122880; + case 8: + return 491520; + case 9: + return 1966080; + case 10: + return 7864320; + case 11: + return 31457280; + case 12: + return 125829120; + case 13: + return 503316480; + case 14: + return 2013265920; + default: + return Integer.MAX_VALUE; + } + /*else { int newTier = aTier - 1; return (int) ((4*(Math.pow(4, newTier)))*7.5); @@ -342,7 +344,7 @@ 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) { @@ -416,7 +418,7 @@ public class MaterialUtils { return aDataSet; } return aDataSet; - */} + */} public static AutoMap<Material> getCompoundMaterialsRecursively_Speiger(Material toSearch) { AutoMap<Material> resultList = new AutoMap<Material>(); @@ -425,11 +427,11 @@ public class MaterialUtils { return resultList; } final int HARD_LIMIT = 1000; - + // Could be a Deque but i dont use the interface // enough to use it as default. LinkedList<Material> toCheck = new LinkedList<Material>(); - + toCheck.add(toSearch); int processed = 0; while (toCheck.size() > 0 && processed < HARD_LIMIT) { @@ -445,11 +447,11 @@ public class MaterialUtils { } return resultList; } - + public static void generateComponentAndAssignToAMaterial(ComponentTypes aType, Material aMaterial) { generateComponentAndAssignToAMaterial(aType, aMaterial, true); } - + public static void generateComponentAndAssignToAMaterial(ComponentTypes aType, Material aMaterial, boolean generateRecipes) { Item aGC; if (aType == ComponentTypes.PLATEHEAVY) { @@ -460,33 +462,33 @@ public class MaterialUtils { } if (aGC != null) { String aFormattedLangName = aType.getName(); - + if (!aFormattedLangName.startsWith(" ")) { if (aFormattedLangName.contains("@")) { String[] aSplit = aFormattedLangName.split("@"); aFormattedLangName = aSplit[0] + " " + aMaterial.getLocalizedName() + " " + aSplit[1]; } } - + if (aFormattedLangName.equals(aType.getName())) { aFormattedLangName = aMaterial.getLocalizedName() + aFormattedLangName; - + } - - - + + + Logger.MATERIALS("[Lang] "+aGC.getUnlocalizedName()+".name="+aFormattedLangName); aMaterial.registerComponentForMaterial(aType, ItemUtils.getSimpleStack(aGC)); } } - - - - - - - - + + + + + + + + public static void generateSpecialDustAndAssignToAMaterial(Material aMaterial) { generateSpecialDustAndAssignToAMaterial(aMaterial, true); } @@ -498,7 +500,7 @@ public class MaterialUtils { aMaterial.registerComponentForMaterial(OrePrefixes.dustSmall, ItemUtils.getSimpleStack(aDusts[1])); aMaterial.registerComponentForMaterial(OrePrefixes.dustTiny, ItemUtils.getSimpleStack(aDusts[2])); } - + } public static boolean doesMaterialExist(String aMatName) { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java index e64414b493..110b2baf25 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java @@ -1,23 +1,27 @@ package gtPlusPlus.core.util.minecraft; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; +import java.util.*; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.util.Utils; import net.minecraft.client.Minecraft; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; +import thaumcraft.common.lib.FakeThaumcraftPlayer; public class PlayerUtils { + public static final Map<String, EntityPlayer> mCachedFakePlayers = new WeakHashMap<String, EntityPlayer>(); + public static void messagePlayer(final EntityPlayer P, final String S){ gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); } @@ -195,5 +199,53 @@ public class PlayerUtils { public static boolean canTakeDamage(EntityPlayer aPlayer) { return !aPlayer.capabilities.disableDamage; } + + public static void cacheFakePlayer(EntityPlayer aPlayer) { + ChunkCoordinates aChunkLocation = aPlayer.getPlayerCoordinates(); + // Cache Fake Player + if (aPlayer instanceof FakePlayer || aPlayer instanceof FakeThaumcraftPlayer + || (aPlayer.getCommandSenderName() == null + || aPlayer.getCommandSenderName().length() <= 0) + || (aPlayer.isEntityInvulnerable() && !aPlayer.canCommandSenderUseCommand(0, "") + && (aChunkLocation == null) || (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 + && aChunkLocation.posZ == 0))) { + mCachedFakePlayers.put(aPlayer.getUniqueID().toString(), aPlayer); + } + } + + public static boolean isCachedFakePlayer(String aUUID) { + return mCachedFakePlayers.containsKey(aUUID); + } + + public static boolean isRealPlayer(EntityLivingBase aEntity) { + if (aEntity instanceof EntityPlayer) { + EntityPlayer p = (EntityPlayer) aEntity; + ChunkCoordinates aChunkLocation = p.getPlayerCoordinates(); + if (p instanceof FakePlayer) { + cacheFakePlayer(p); + return false; + } + if (p instanceof FakeThaumcraftPlayer) { + cacheFakePlayer(p); + return false; + } + if (p.getCommandSenderName() == null) { + cacheFakePlayer(p); + return false; + } + if (p.getCommandSenderName().length() <= 0) { + cacheFakePlayer(p); + return false; + } + if (p.isEntityInvulnerable() && !p.canCommandSenderUseCommand(0, "") && (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 && aChunkLocation.posZ == 0)) { + cacheFakePlayer(p); + return false; + } + if (!isCachedFakePlayer(p.getUniqueID().toString())) { + return true; + } + } + return false; + } } diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index e45d27b926..e0634dfb14 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -22,6 +22,7 @@ import com.google.common.reflect.ClassPath; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; public class ReflectionUtils { @@ -507,6 +508,30 @@ public class ReflectionUtils { Logger.REFLECTION("Invoke failed or did something wrong."); return false; } + + public static boolean invokeVoid(Object objectInstance, Method method, Object[] values){ + if (method == null || values == null || (!ReflectionUtils.isStaticMethod(method) && objectInstance == null)){ + //Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName()); + return false; + } + String methodName = method.getName(); + String classname = objectInstance != null ? objectInstance.getClass().getCanonicalName() : method.getDeclaringClass().getCanonicalName(); + Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+classname+"."); + try { + Method mInvokingMethod = method; + if (mInvokingMethod != null){ + Logger.REFLECTION(methodName+" was not null."); + mInvokingMethod.invoke(objectInstance, values); + Logger.REFLECTION("Successfully invoked "+methodName+"."); + return true; + } + } + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+classname); + } + Logger.REFLECTION("Invoke failed or did something wrong."); + return false; + } public static boolean invokeVoid(Object objectInstance, String methodName, Class[] parameters, Object[] values){ if (objectInstance == null || methodName == null || parameters == null || values == null){ @@ -536,17 +561,17 @@ public class ReflectionUtils { public static Object invokeNonBool(Object objectInstance, Method method, Object[] values){ - if (objectInstance == null || method == null || values == null){ + if ((!ReflectionUtils.isStaticMethod(method) && objectInstance == null) || method == null || values == null){ return false; } String methodName = method.getName(); - Class<?> mLocalClass = (objectInstance instanceof Class ? (Class<?>) objectInstance : objectInstance.getClass()); - Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+mLocalClass.getCanonicalName()+"."); + String classname = objectInstance != null ? objectInstance.getClass().getCanonicalName() : method.getDeclaringClass().getCanonicalName(); + Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+classname+"."); try { return method.invoke(objectInstance, values); } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName()); + Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+classname); } Logger.REFLECTION("Invoke failed or did something wrong."); @@ -1035,5 +1060,19 @@ public class ReflectionUtils { return null; } + public static <T> T createNewInstanceFromConstructor(Constructor aConstructor, Object[] aArgs) { + T aInstance; + try { + aInstance = (T) aConstructor.newInstance(aArgs); + if (aInstance != null) { + return aInstance; + } + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + } diff --git a/src/Java/gtPlusPlus/core/util/sys/NetworkUtils.java b/src/Java/gtPlusPlus/core/util/sys/NetworkUtils.java index b883391a86..1403713b3d 100644 --- a/src/Java/gtPlusPlus/core/util/sys/NetworkUtils.java +++ b/src/Java/gtPlusPlus/core/util/sys/NetworkUtils.java @@ -41,10 +41,10 @@ public class NetworkUtils { public static boolean checkNetworkIsAvailableWithValidInterface(){ try { if (hasValidNetworkInterface()){ - if (checkAddressWithTimeout("http://www.google.com", 10) || - checkAddressWithTimeout("http://www.baidu.com", 10) || - checkAddressWithTimeout("https://github.com/draknyte1/GTplusplus", 10) || - checkAddressWithTimeout("www.yahoo.com", 10)/* || + if (checkAddressWithTimeout("http://www.google.com", 100) || + checkAddressWithTimeout("http://www.baidu.com", 100) || + checkAddressWithTimeout("http://www.github.com/alkcorp/GTplusplus", 100) || + checkAddressWithTimeout("http://www.yahoo.com", 100)/* || netIsAvailableGoogle() || netIsAvailableBaidu() || netIsAvailableGithub() || @@ -63,82 +63,26 @@ public class NetworkUtils { return false; } - private static boolean netIsAvailableGoogle() { - try { - final URL url = new URL("http://www.google.com"); - final URLConnection conn = url.openConnection(); - conn.connect(); - return true; - } catch (final MalformedURLException e) { - throw new RuntimeException(e); - } catch (final IOException e) { - return false; - } - } - - private static boolean netIsAvailableBaidu() { - try { - final URL url = new URL("http://www.baidu.com"); - final URLConnection conn = url.openConnection(); - conn.connect(); - return true; - } catch (final MalformedURLException e) { - throw new RuntimeException(e); - } catch (final IOException e) { - return false; - } - } + private static boolean checkAddressWithTimeout(String URL, int timeout) { - private static boolean netIsAvailableGithub() { try { - final URL url = new URL("https://github.com/draknyte1/GTplusplus"); - final URLConnection conn = url.openConnection(); - conn.connect(); + InetAddress.getByName(URL).isReachable(timeout); //Replace with your name return true; - } catch (final MalformedURLException e) { - throw new RuntimeException(e); - } catch (final IOException e) { - return false; - } - } - - private static boolean netIsAvailableOther() { - try { - final int timeout = 200; - final InetAddress[] addresses = InetAddress.getAllByName("www.yahoo.com"); - for (final InetAddress address : addresses) { - if (address.isReachable(timeout)) { - return true; - } - return false; - } - } catch (final Exception e) { - return false; - } - return false; - } - - private static boolean checkAddressWithTimeout(String URL, int timeout) { - - try { - InetAddress.getByName(URL).isReachable(timeout); //Replace with your name - return true; - } catch (Exception e) { - return false; - } - - /*try { - final InetAddress[] addresses = InetAddress.getAllByName(URL); - for (final InetAddress address : addresses) { - if (address.isReachable(timeout)) { - return true; + } catch (Exception e) { + boolean result = false; + try { + URL urlObj = new URL(URL); + HttpURLConnection con = (HttpURLConnection) urlObj.openConnection(); + con.setRequestMethod("GET"); + con.setConnectTimeout(timeout); + con.connect(); + int code = con.getResponseCode(); + if (code == 200) { + result = true; } - return false; - } - } catch (final Exception e) { - return false; + } catch (Exception e2) {} + return result; } - return false;*/ } private static boolean hasValidNetworkInterface() throws SocketException{ diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_FlotationCell.java b/src/Java/gtPlusPlus/nei/GT_NEI_FlotationCell.java new file mode 100644 index 0000000000..0d4e84b4b7 --- /dev/null +++ b/src/Java/gtPlusPlus/nei/GT_NEI_FlotationCell.java @@ -0,0 +1,462 @@ +package gtPlusPlus.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.*; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import codechicken.nei.recipe.*; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_NEI_FlotationCell +extends TemplateRecipeHandler { + public static final int sOffsetX = 5; + public static final int sOffsetY = 11; + + static { + GuiContainerManager.addInputHandler(new GT_RectHandler()); + GuiContainerManager.addTooltipHandler(new GT_RectHandler()); + } + + protected GT_Recipe_Map mRecipeMap; + + public GT_NEI_FlotationCell() { + this.mRecipeMap = Gregtech_Recipe_Map.sFlotationCellRecipes; + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), this.getRecipeMapName(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtechplusplus@" + this.getRecipeName() + "@" + this.getRecipeMapName()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public List<Recipe_GT> getSortedRecipes() { + List<Recipe_GT> result = new ArrayList(this.mRecipeMap.mRecipeList); + Collections.sort(result); + return result; + } + + public static void drawText(final int aX, final int aY, final String aString, final int aColor) { + Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_FlotationCell(); + } + + @Override + public void loadCraftingRecipes(final String outputId, final Object... results) { + if (outputId.equals(getRecipeMapName())) { + for (Recipe_GT tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(final ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList<ItemStack> tResults = new ArrayList<ItemStack>(); + tResults.add(aResult); + tResults.add(GT_OreDictUnificator.get(true, aResult)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); + if (tFluid != null) { + tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tResults.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (Recipe_GT tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (ItemStack tStack : tResults) { + if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + + ArrayList<ItemStack> tInputs = new ArrayList<ItemStack>(); + tInputs.add(aInput); + tInputs.add(GT_OreDictUnificator.get(false, aInput)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + if (tFluid != null) { + tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tInputs.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (Recipe_GT tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (ItemStack tStack : tInputs) { + if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + public String getRecipeMapName() { + return this.mRecipeMap.mNEIName; + } + + @Override + public String getOverlayIdentifier() { + return this.mRecipeMap.mNEIName; + } + + @Override + public void drawBackground(final int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + @Override + public String getGuiTexture() { + return this.mRecipeMap.mNEIGUIPath; + } + + @Override + public List<String> handleItemTooltip(final GuiRecipe gui, final ItemStack aStack, final List<String> currenttip, final int aRecipeIndex) { + final TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + final CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + for (final PositionedStack tStack : tRecipe.mOutputs) { + if (aStack == tStack.item) { + if ((!(tStack instanceof FixedPositionedStack)) || (((FixedPositionedStack) tStack).mChance <= 0) || (((FixedPositionedStack) tStack).mChance == 10000)) { + break; + } + currenttip.add("Chance: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + break; + } + } + for (final PositionedStack tStack : tRecipe.mInputs) { + if (GT_Utility.areStacksEqual(aStack, tStack.item)) { + if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || + (tStack.item.stackSize != 0)) { + break; + } + if (ItemUtils.isControlCircuit(aStack)) { + currenttip.add("Does not get consumed in the process"); + } + break; + } + } + } + return currenttip; + } + + @Override + public void drawExtras(final int aRecipeIndex) { + final long tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + final int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + if (tEUt != 0) { + drawText(10, 73, "Total: " + (long) (tDuration * tEUt) + " EU", -16777216); + //drawText(10, 83, "Usage: " + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 83, "Voltage: " + (tEUt / this.mRecipeMap.mAmperage) + " EU/t", -16777216); + drawText(10, 93, "Amperage: " + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, "Voltage: unspecified", -16777216); + drawText(10, 103, "Amperage: unspecified", -16777216); + } + } + if (tDuration > 0) { + drawText(10, 103, "Time: " + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + " secs", -16777216); + } + //if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + //drawText(10, 113, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + //} + } + + public static class GT_RectHandler + implements IContainerInputHandler, IContainerTooltipHandler { + @Override + public boolean mouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + if (this.canHandle(gui)) { + if (button == 0) { + return this.transferRect(gui, false); + } + if (button == 1) { + return this.transferRect(gui, true); + } + } + return false; + } + + @Override + public boolean lastKeyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + public boolean canHandle(final GuiContainer gui) { + return (((gui instanceof GT_GUIContainer_BasicMachine)) && (GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) /*|| ((gui instanceof GT_GUIContainer_FusionReactor)) && (GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI))*/); + } + + @Override + public List<String> handleTooltip(final GuiContainer gui, final int mousex, final int mousey, final List<String> currenttip) { + if ((this.canHandle(gui)) && (currenttip.isEmpty())) { + if ((gui instanceof GT_GUIContainer_BasicMachine) && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + }*/ + + } + return currenttip; + } + + private boolean transferRect(final GuiContainer gui, final boolean usage) { + if (gui instanceof GT_GUIContainer_BasicMachine) { + return (this.canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0])); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor) { + return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0])); + }*/ + return false; + } + + @Override + public List<String> handleItemDisplayName(final GuiContainer gui, final ItemStack itemstack, final List<String> currenttip) { + return currenttip; + } + + @Override + public List<String> handleItemTooltip(final GuiContainer gui, final ItemStack itemstack, final int mousex, final int mousey, final List<String> currenttip) { + return currenttip; + } + + @Override + public boolean keyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + @Override + public void onKeyTyped(final GuiContainer gui, final char keyChar, final int keyID) { + } + + @Override + public void onMouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public void onMouseUp(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public boolean mouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + return false; + } + + @Override + public void onMouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + } + + @Override + public void onMouseDragged(final GuiContainer gui, final int mousex, final int mousey, final int button, final long heldTime) { + } + } + + public class FixedPositionedStack + extends PositionedStack { + public final int mChance; + public boolean permutated = false; + + public FixedPositionedStack(final Object object, final int x, final int y) { + this(object, x, y, 0); + } + + public FixedPositionedStack(final Object object, final int x, final int y, final int aChance) { + super(object, x, y, true); + this.mChance = aChance; + } + + @Override + public void generatePermutations() { + if (this.permutated) { + return; + } + final ArrayList<ItemStack> tDisplayStacks = new ArrayList<ItemStack>(); + for (final ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + final List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (final Iterator<ItemStack> i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = i$.next(); + } + } else { + final ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = (tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + this.setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe + extends TemplateRecipeHandler.CachedRecipe { + public final GT_Recipe mRecipe; + public final List<PositionedStack> mOutputs = new ArrayList<PositionedStack>(); + public final List<PositionedStack> mInputs = new ArrayList<PositionedStack>(); + + public CachedDefaultRecipe(final GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + + int tStartIndex = 0; + + + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + + if (aRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + + //Four Output Slots + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + + if ((aRecipe.mFluidInputs.length > 0) && (aRecipe.mFluidInputs[0] != null) && (aRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[0], true), 30, 52)); + if ((aRecipe.mFluidInputs.length > 1) && (aRecipe.mFluidInputs[1] != null) && (aRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[1], true), 48, 52)); + } + } + + if (aRecipe.mFluidOutputs.length > 0) { + if ((aRecipe.mFluidOutputs[0] != null) && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 102, 52)); + } + if ((aRecipe.mFluidOutputs.length > 1) && (aRecipe.mFluidOutputs[1] != null) && (aRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[1], true), 120, 52)); + } + } + } + + @Override + public List<PositionedStack> getIngredients() { + return this.getCycledIngredients(GT_NEI_FlotationCell.this.cycleticks / 10, this.mInputs); + } + + @Override + public PositionedStack getResult() { + return null; + } + + @Override + public List<PositionedStack> getOtherStacks() { + return this.mOutputs; + } + } +} diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_VacFurnace.java b/src/Java/gtPlusPlus/nei/GT_NEI_VacFurnace.java new file mode 100644 index 0000000000..571ee79ee6 --- /dev/null +++ b/src/Java/gtPlusPlus/nei/GT_NEI_VacFurnace.java @@ -0,0 +1,483 @@ +package gtPlusPlus.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.*; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import codechicken.nei.recipe.*; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.nei.GT_NEI_MultiBlockHandler.FixedPositionedStack; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_NEI_VacFurnace +extends TemplateRecipeHandler { + public static final int sOffsetX = 5; + public static final int sOffsetY = 11; + + static { + GuiContainerManager.addInputHandler(new GT_RectHandler()); + GuiContainerManager.addTooltipHandler(new GT_RectHandler()); + } + + protected GT_Recipe_Map mRecipeMap; + + public GT_NEI_VacFurnace() { + this.mRecipeMap = Gregtech_Recipe_Map.sVacuumFurnaceRecipes; + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), this.getRecipeMapName(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtechplusplus@" + this.getRecipeName() + "@" + this.getRecipeMapName()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public List<Recipe_GT> getSortedRecipes() { + List<Recipe_GT> result = new ArrayList(this.mRecipeMap.mRecipeList); + Collections.sort(result); + return result; + } + + public static void drawText(final int aX, final int aY, final String aString, final int aColor) { + Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_VacFurnace(); + } + + @Override + public void loadCraftingRecipes(final String outputId, final Object... results) { + if (outputId.equals(getRecipeMapName())) { + for (Recipe_GT tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(final ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList<ItemStack> tResults = new ArrayList<ItemStack>(); + tResults.add(aResult); + tResults.add(GT_OreDictUnificator.get(true, aResult)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); + if (tFluid != null) { + tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tResults.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (Recipe_GT tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (ItemStack tStack : tResults) { + if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + + ArrayList<ItemStack> tInputs = new ArrayList<ItemStack>(); + tInputs.add(aInput); + tInputs.add(GT_OreDictUnificator.get(false, aInput)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + if (tFluid != null) { + tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tInputs.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (Recipe_GT tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (ItemStack tStack : tInputs) { + if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + public String getRecipeMapName() { + return this.mRecipeMap.mNEIName; + } + + @Override + public String getOverlayIdentifier() { + return this.mRecipeMap.mNEIName; + } + + @Override + public void drawBackground(final int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + @Override + public String getGuiTexture() { + return CustomRecipeMap.sFissionFuelProcessing.mNEIGUIPath; + } + + @Override + public List<String> handleItemTooltip(final GuiRecipe gui, final ItemStack aStack, final List<String> currenttip, final int aRecipeIndex) { + final TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + final CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + for (final PositionedStack tStack : tRecipe.mOutputs) { + if (aStack == tStack.item) { + if ((!(tStack instanceof FixedPositionedStack)) || (((FixedPositionedStack) tStack).mChance <= 0) || (((FixedPositionedStack) tStack).mChance == 10000)) { + break; + } + currenttip.add("Chance: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + break; + } + } + for (final PositionedStack tStack : tRecipe.mInputs) { + if (GT_Utility.areStacksEqual(aStack, tStack.item)) { + if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || + (tStack.item.stackSize != 0)) { + break; + } + if (ItemUtils.isControlCircuit(aStack)) { + currenttip.add("Does not get consumed in the process"); + } + break; + } + } + } + return currenttip; + } + + @Override + public void drawExtras(final int aRecipeIndex) { + final long tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + final int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + if (tEUt != 0) { + drawText(10, 88, "Total: " + (long) (tDuration * tEUt) + " EU", -16777216); + drawText(10, 98, "Usage: " + tEUt + " EU/t", -16777216); + /*if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 83, "Voltage: " + (tEUt / this.mRecipeMap.mAmperage) + " EU/t", -16777216); + drawText(10, 93, "Amperage: " + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, "Voltage: unspecified", -16777216); + drawText(10, 103, "Amperage: unspecified", -16777216); + }*/ + } + if (tDuration > 0) { + drawText(10, 108, "Time: " + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + " secs", -16777216); + } + if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + drawText(10, 118, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + } + } + + public static class GT_RectHandler + implements IContainerInputHandler, IContainerTooltipHandler { + @Override + public boolean mouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + if (this.canHandle(gui)) { + if (button == 0) { + return this.transferRect(gui, false); + } + if (button == 1) { + return this.transferRect(gui, true); + } + } + return false; + } + + @Override + public boolean lastKeyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + public boolean canHandle(final GuiContainer gui) { + return (((gui instanceof GT_GUIContainer_BasicMachine)) && (GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) /*|| ((gui instanceof GT_GUIContainer_FusionReactor)) && (GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI))*/); + } + + @Override + public List<String> handleTooltip(final GuiContainer gui, final int mousex, final int mousey, final List<String> currenttip) { + if ((this.canHandle(gui)) && (currenttip.isEmpty())) { + if ((gui instanceof GT_GUIContainer_BasicMachine) && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + }*/ + + } + return currenttip; + } + + private boolean transferRect(final GuiContainer gui, final boolean usage) { + if (gui instanceof GT_GUIContainer_BasicMachine) { + return (this.canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0])); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor) { + return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0])); + }*/ + return false; + } + + @Override + public List<String> handleItemDisplayName(final GuiContainer gui, final ItemStack itemstack, final List<String> currenttip) { + return currenttip; + } + + @Override + public List<String> handleItemTooltip(final GuiContainer gui, final ItemStack itemstack, final int mousex, final int mousey, final List<String> currenttip) { + return currenttip; + } + + @Override + public boolean keyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + @Override + public void onKeyTyped(final GuiContainer gui, final char keyChar, final int keyID) { + } + + @Override + public void onMouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public void onMouseUp(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public boolean mouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + return false; + } + + @Override + public void onMouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + } + + @Override + public void onMouseDragged(final GuiContainer gui, final int mousex, final int mousey, final int button, final long heldTime) { + } + } + + public class FixedPositionedStack + extends PositionedStack { + public final int mChance; + public boolean permutated = false; + + public FixedPositionedStack(final Object object, final int x, final int y) { + this(object, x, y, 0); + } + + public FixedPositionedStack(final Object object, final int x, final int y, final int aChance) { + super(object, x, y, true); + this.mChance = aChance; + } + + @Override + public void generatePermutations() { + if (this.permutated) { + return; + } + final ArrayList<ItemStack> tDisplayStacks = new ArrayList<ItemStack>(); + for (final ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + final List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (final Iterator<ItemStack> i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = i$.next(); + } + } else { + final ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = (tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + this.setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe + extends TemplateRecipeHandler.CachedRecipe { + public final GT_Recipe mRecipe; + public final List<PositionedStack> mOutputs = new ArrayList<PositionedStack>(); + public final List<PositionedStack> mInputs = new ArrayList<PositionedStack>(); + + public CachedDefaultRecipe(final GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + + int tStartIndex = 0; + + + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + + if (aRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + + //9 Output Slots + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 101, 4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 119, 4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 137, 4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 101, 22, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 119, 22, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 137, 22, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 101, 40, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 119, 40, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 137, 40, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + + if ((aRecipe.mFluidInputs.length > 0) && (aRecipe.mFluidInputs[0] != null) && (aRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[0], true), 12, 60)); + if ((aRecipe.mFluidInputs.length > 1) && (aRecipe.mFluidInputs[1] != null) && (aRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[1], true), 30, 60)); + } + } + + if (aRecipe.mFluidOutputs.length > 0) { + if ((aRecipe.mFluidOutputs[0] != null) && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 101, 60)); + } + if ((aRecipe.mFluidOutputs.length > 1) && (aRecipe.mFluidOutputs[1] != null) && (aRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[1], true), 119, 60)); + } + } + } + + @Override + public List<PositionedStack> getIngredients() { + return this.getCycledIngredients(GT_NEI_VacFurnace.this.cycleticks / 10, this.mInputs); + } + + @Override + public PositionedStack getResult() { + return null; + } + + @Override + public List<PositionedStack> getOtherStacks() { + return this.mOutputs; + } + } +} diff --git a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java index 438ada00ba..32d2a464f9 100644 --- a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java +++ b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java @@ -18,6 +18,8 @@ implements IConfigureNEI { mUniqueRecipeMapHandling.add(Gregtech_Recipe_Map.sChemicalPlantRecipes.mUnlocalizedName); mUniqueRecipeMapHandling.add(Gregtech_Recipe_Map.sOreMillRecipes.mUnlocalizedName); + mUniqueRecipeMapHandling.add(Gregtech_Recipe_Map.sFlotationCellRecipes.mUnlocalizedName); + mUniqueRecipeMapHandling.add(Gregtech_Recipe_Map.sVacuumFurnaceRecipes.mUnlocalizedName); for (final CustomRecipeMap tMap : gregtech.api.util.CustomRecipeMap.sMappings) { if (tMap.mNEIAllowed) { @@ -33,6 +35,8 @@ implements IConfigureNEI { } new GT_NEI_FluidReactor(); new GT_NEI_MillingMachine(); + new GT_NEI_FlotationCell(); + new GT_NEI_VacFurnace(); sIsAdded = true; API.registerRecipeHandler(new DecayableRecipeHandler()); API.registerUsageHandler(new DecayableRecipeHandler()); diff --git a/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java b/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java index 541f02cccd..490b94d71c 100644 --- a/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java +++ b/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java @@ -23,11 +23,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.MISC_MATERIALS; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.MaterialUtils; -import gtPlusPlus.core.util.minecraft.OreDictUtils; -import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.core.util.minecraft.*; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.plugin.agrichem.block.AgrichemFluids; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -61,7 +57,7 @@ public class BioRecipes { private static Fluid mCarbonDioxide; private static Fluid mCarbonMonoxide; private static Fluid mEthylene; - private static Fluid mEthanol; + public static Fluid mEthanol; private static Fluid mChlorine; private static Fluid mHydrogen; private static Fluid mDilutedSulfuricAcid; @@ -1323,14 +1319,10 @@ public class BioRecipes { } private static void recipeBioChip() { - GT_ModHandler.addShapelessCraftingRecipe( GregtechItemList.Circuit_BioRecipeSelector.getWithDamage(1L, 0L), 0, new Object[]{OrePrefixes.circuit.get(Materials.Primitive)}); long bits = 0; - - - addCraftingRecipe(GregtechItemList.Circuit_BioRecipeSelector.getWithDamage(1L, 1L, new Object[0]), bits, new Object[]{"d ", " P ", " ", 'P', GregtechItemList.Circuit_BioRecipeSelector.getWildcard(1L, new Object[0])}); addCraftingRecipe(GregtechItemList.Circuit_BioRecipeSelector.getWithDamage(1L, 2L, new Object[0]), bits, diff --git a/src/Java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java b/src/Java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java index 201da99488..c3c51983e3 100644 --- a/src/Java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java +++ b/src/Java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java @@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.OreDictUtils; @@ -17,6 +18,7 @@ import net.minecraft.entity.player.EntityPlayer; 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; import net.minecraftforge.oredict.OreDictionary; @@ -50,6 +52,8 @@ public class ItemAgrichemBase extends Item { * 21 - Lithium Chloride * 22 - Pellet Mold * 23 - Clean Aluminium Mix + * 24 - Pinecone + * 25 - Crushed Pine */ public ItemAgrichemBase() { @@ -57,7 +61,7 @@ public class ItemAgrichemBase extends Item { this.setNoRepair(); this.setMaxStackSize(64); this.setMaxDamage(0); - base = new IIcon[24]; + base = new IIcon[26]; this.setUnlocalizedName("BasicAgrichemItem"); GameRegistry.registerItem(this, this.getUnlocalizedName()); } @@ -83,17 +87,6 @@ public class ItemAgrichemBase extends Item { } @Override - public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { - try { - - } - catch (Throwable t) { - t.printStackTrace(); - } - super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); - } - - @Override public EnumRarity getRarity(ItemStack p_77613_1_) { return EnumRarity.common; } @@ -169,11 +162,6 @@ public class ItemAgrichemBase extends Item { } @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - - @Override public int getItemEnchantability() { return 0; } @@ -244,4 +232,87 @@ public class ItemAgrichemBase extends Item { } + + @Override + public double getDurabilityForDisplay(ItemStack aStack) { + if (ItemUtils.isCatalyst(aStack)) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()){ + createCatalystNBT(aStack); + } + double currentDamage = getCatalystDamage(aStack); + double durabilitypercent = currentDamage / 100; + return durabilitypercent; + } + else { + return 1D; + } + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack aStack, EntityPlayer player, List list, boolean bool) { + boolean aHasSpecialTooltips = false; + int aMaxDamage = 0; + int aDamageSegment = 0; + int aDam = 0; + EnumChatFormatting durability = EnumChatFormatting.GRAY; + if (ItemUtils.isCatalyst(aStack)) { + list.add(EnumChatFormatting.GRAY+"Active Reaction Agent"); + aMaxDamage = getCatalystMaxDamage(aStack); + aDamageSegment = aMaxDamage / 5; + aDam = aMaxDamage-getCatalystDamage(aStack); + aHasSpecialTooltips = true; + } + if (aHasSpecialTooltips) { + if (aDam > aDamageSegment * 4){ + durability = EnumChatFormatting.GRAY; + } + else if (aDam > aDamageSegment * 3){ + durability = EnumChatFormatting.GREEN; + } + else if (aDam > aDamageSegment * 2){ + durability = EnumChatFormatting.YELLOW; + } + else if (aDam > aDamageSegment){ + durability = EnumChatFormatting.GOLD; + } + else if (aDam > 0){ + durability = EnumChatFormatting.RED; + } + list.add(durability+""+(aDam)+EnumChatFormatting.GRAY+" / "+aMaxDamage); + } + super.addInformation(aStack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack aStack) { + if (ItemUtils.isCatalyst(aStack)) { + int aDam = getCatalystDamage(aStack); + if (aDam > 0) { + return true; + } + } + return false; + } + + public static boolean createCatalystNBT(ItemStack rStack){ + return ItemGenericChemBase.createCatalystNBT(rStack); + } + + public static int getCatalystDamage(ItemStack aStack) { + return ItemGenericChemBase.getCatalystDamage(aStack); + } + + public static int getCatalystMaxDamage(ItemStack aStack) { + return ItemGenericChemBase.getCatalystMaxDamage(aStack); + } + + public static void setCatalystDamage(ItemStack aStack,int aAmount) { + ItemGenericChemBase.setCatalystDamage(aStack, aAmount); + } + + public static int getMaxCatalystDurability(ItemStack aStack) { + return ItemGenericChemBase.getMaxCatalystDurability(aStack); + } + } diff --git a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java index d0c59726de..a5981b15d9 100644 --- a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java +++ b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java @@ -30,6 +30,7 @@ public class AsmConfig { public static boolean enableTcAspectSafety; public static boolean enabledLwjglKeybindingFix; public static boolean enabledFixEntitySetHealth; + public static boolean enableThaumicTinkererRepairFix; public static boolean disableAllLogging; public static boolean debugMode; @@ -96,6 +97,14 @@ public class AsmConfig { enableOreDictPatch = prop.getBoolean(false); propOrderDebug.add(prop.getName()); + prop = config.get("debug", "enableThaumicTinkererRepairFix", false); + prop.comment = "Enable/Disable Patch for Thaumic Repairer"; + prop.setLanguageKey("gtpp.enableThaumicTinkererRepairFix").setRequiresMcRestart(true); + enableThaumicTinkererRepairFix = prop.getBoolean(false); + propOrderDebug.add(prop.getName()); + + + diff --git a/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java b/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java index 84593f6597..3366f4aefe 100644 --- a/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java +++ b/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java @@ -52,6 +52,7 @@ public class ClassesToTransform { public static final String THAUMCRAFT_ITEM_WISP_ESSENCE = "thaumcraft.common.items.ItemWispEssence"; + public static final String THAUMICTINKERER_TILE_REPAIRER = "thaumic.tinkerer.common.block.tile.TileRepairer"; public static final String IC2_ITEM_ARMOUR_HAZMAT = "ic2.core.item.armor.ItemArmorHazmat"; public static final String IC2_BLOCK_BASE_TILE_ENTITY = "ic2.core.block.BlockTileEntity"; diff --git a/src/Java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java b/src/Java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java index 46196cb87f..8aa449df5d 100644 --- a/src/Java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java +++ b/src/Java/gtPlusPlus/preloader/asm/Preloader_FMLLoadingPlugin.java @@ -13,6 +13,8 @@ import net.minecraft.launchwrapper.Launch; @SortingIndex(10097) @MCVersion(value = "1.7.10") +@IFMLLoadingPlugin.TransformerExclusions("gtPlusPlus.preloader") +@IFMLLoadingPlugin.Name(CORE_Preloader.NAME) public class Preloader_FMLLoadingPlugin implements IFMLLoadingPlugin { //-Dfml.coreMods.load=gtPlusPlus.preloader.asm.Preloader_FMLLoadingPlugin diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java index 307900ad9e..fa711e5693 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Utility.java @@ -1,11 +1,6 @@ package gtPlusPlus.preloader.asm.transformers; -import static org.objectweb.asm.Opcodes.ACC_PUBLIC; -import static org.objectweb.asm.Opcodes.ACC_STATIC; -import static org.objectweb.asm.Opcodes.ASM5; -import static org.objectweb.asm.Opcodes.INVOKESTATIC; -import static org.objectweb.asm.Opcodes.IRETURN; -import static org.objectweb.asm.Opcodes.LLOAD; +import static org.objectweb.asm.Opcodes.*; import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; @@ -14,8 +9,14 @@ import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; -import cpw.mods.fml.relauncher.FMLRelaunchLog; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.preloader.Preloader_Logger; +import ic2.core.IC2Potion; +import ic2.core.item.armor.ItemArmorHazmat; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; public class ClassTransformer_GT_Utility { @@ -23,6 +24,8 @@ public class ClassTransformer_GT_Utility { private final ClassReader reader; private final ClassWriter writer; private final String className; + + public ClassTransformer_GT_Utility(byte[] basicClass, String aClassName) { @@ -40,13 +43,20 @@ public class ClassTransformer_GT_Utility { isValid = false; } - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Valid patch? " + isValid + "."); + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Valid patch? " + isValid + "."); reader = aTempReader; writer = aTempWriter; if (reader != null && writer != null) { - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Attempting Method Injection."); + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Attempting Method Injection."); injectMethod("getTier"); + injectMethod("applyRadioactivity"); + injectMethod("isWearingFullFrostHazmat"); + injectMethod("isWearingFullHeatHazmat"); + injectMethod("isWearingFullBioHazmat"); + injectMethod("isWearingFullRadioHazmat"); + injectMethod("isWearingFullElectroHazmat"); + injectMethod("isWearingFullGasHazmat"); } } @@ -67,9 +77,118 @@ public class ClassTransformer_GT_Utility { MethodVisitor mv; boolean didInject = false; ClassWriter cw = getWriter(); - String aClassNameFormatted = Utils.class.getName().replace(".", "/"); - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassNameFormatted+"."); + String aClassNameFormatted = Utils.class.getName().replace(".", "/"); + + if (aMethodName.equals("isWearingFullFrostHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullFrostHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1273, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullFrostHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); + mv.visitInsn(IRETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullHeatHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullHeatHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1277, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullHeatHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); + mv.visitInsn(IRETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullBioHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullBioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1281, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullBioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); + mv.visitInsn(IRETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullRadioHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullRadioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1285, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullRadioHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); + mv.visitInsn(IRETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullElectroHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullElectroHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1289, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullElectroHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); + mv.visitInsn(IRETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + } + + if (aMethodName.equals("isWearingFullGasHazmat")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "isWearingFullGasHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1293, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "isWearingFullGasHazmat", "(Lnet/minecraft/entity/EntityLivingBase;)Z", false); + mv.visitInsn(IRETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + } + if (aMethodName.equals("getTier")) { + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassNameFormatted+"."); mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "getTier", "(J)B", null, null); mv.visitCode(); Label l0 = new Label(); @@ -84,8 +203,31 @@ public class ClassTransformer_GT_Utility { mv.visitMaxs(2, 2); mv.visitEnd(); didInject = true; + } + + if (aMethodName.equals("applyRadioactivity")){ + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Injecting " + aMethodName + "."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "applyRadioactivity", "(Lnet/minecraft/entity/EntityLivingBase;II)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(1342, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/EntityUtils", "applyRadioactivity", "(Lnet/minecraft/entity/EntityLivingBase;II)Z", false); + mv.visitInsn(IRETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("aEntity", "Lnet/minecraft/entity/EntityLivingBase;", null, l0, l1, 0); + mv.visitLocalVariable("aLevel", "I", null, l0, l1, 1); + mv.visitLocalVariable("aAmountOfItems", "I", null, l0, l1, 2); + mv.visitMaxs(3, 3); + mv.visitEnd(); + didInject = true; } - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, "Method injection complete."); + + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Method injection complete."); return didInject; } @@ -104,13 +246,35 @@ public class ClassTransformer_GT_Utility { if (name.equals("getTier")) { methodVisitor = null; - } else { + } + else if (name.equals("applyRadioactivity")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullFrostHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullHeatHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullBioHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullRadioHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullElectroHazmat")){ + methodVisitor = null; + } + else if (name.equals("isWearingFullGasHazmat")){ + methodVisitor = null; + } + else { methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); } if (methodVisitor == null) { - FMLRelaunchLog.log("[GT++ ASM] Gregtech Utilities Patch", Level.INFO, - "Found method " + name + ", removing."); + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Found method " + name + ", removing."); + Preloader_Logger.LOG("Gregtech Utilities Patch", Level.INFO, "Descriptor: "+desc); } return methodVisitor; } diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_Hazmat.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_Hazmat.java index 52e4d7d99d..10f04e7a48 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_Hazmat.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_Hazmat.java @@ -3,11 +3,7 @@ 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 org.objectweb.asm.*; import cpw.mods.fml.relauncher.FMLRelaunchLog; import gtPlusPlus.core.util.minecraft.HazmatUtils; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java new file mode 100644 index 0000000000..05b8054ff8 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer.java @@ -0,0 +1,611 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.*; + +import cpw.mods.fml.common.Loader; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.Preloader_Logger; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +public class ClassTransformer_TT_ThaumicRestorer { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + private static boolean mInit = false; + + private static Class mTileRepairerClass; + private static Class mTTConfigHandler; + private static Class mTinkersConstructCompat; + private static Class mThaumicTinkerer; + private static Class mTCProxy; + + private static Method mIsTcTool; + private static Method mGetTcDamage; + private static Method mFixTcDamage; + private static Method mSparkle; + private static Method mDrawEssentia; + + private static Field mRepairTiconTools; + private static Field mTicksExisted; + private static Field mInventory; + private static Field mTookLastTick; + private static Field mDamageLastTick; + private static Field mProxyTC; + + private static boolean repairTConTools = false; + + // thaumic.tinkerer.common.block.tile.TileRepairer + + private static final boolean isTConstructTool(ItemStack aStack) { + return ReflectionUtils.invoke(null, mIsTcTool, new Object[] {aStack}); + } + private static final int getDamage(ItemStack aStack) { + return (int) ReflectionUtils.invokeNonBool(null, mGetTcDamage, new Object[] {aStack}); + } + private static final boolean fixDamage(ItemStack aStack, int aAmount) { + return ReflectionUtils.invoke(null, mFixTcDamage, new Object[] {aStack, aAmount}); + } + private static final int drawEssentia(TileEntity aTile) { + return (int) ReflectionUtils.invokeNonBool(aTile, mDrawEssentia, new Object[] {}); + } + private static final void sparkle(float a, float b, float c, int d) { + ReflectionUtils.invokeVoid(ReflectionUtils.getFieldValue(mProxyTC), mSparkle, new Object[] {a, b, c, d}); + } + + public static void updateEntity(TileEntity aTile) { + if (!mInit) { + // Set the classes we need + mTileRepairerClass = ReflectionUtils.getClass("thaumic.tinkerer.common.block.tile.TileRepairer"); + mTTConfigHandler = ReflectionUtils.getClass("thaumic.tinkerer.common.core.handler.ConfigHandler"); + mTinkersConstructCompat = ReflectionUtils.getClass("thaumic.tinkerer.common.compat.TinkersConstructCompat"); + mThaumicTinkerer = ReflectionUtils.getClass("thaumic.tinkerer.common.ThaumicTinkerer"); + mTCProxy = ReflectionUtils.getClass("thaumcraft.common.CommonProxy"); + // Set the methods we need + mIsTcTool = ReflectionUtils.getMethod(mTinkersConstructCompat, "isTConstructTool", new Class[] {ItemStack.class}); + mGetTcDamage = ReflectionUtils.getMethod(mTinkersConstructCompat, "getDamage", new Class[] {ItemStack.class}); + mFixTcDamage = ReflectionUtils.getMethod(mTinkersConstructCompat, "fixDamage", new Class[] {ItemStack.class, int.class}); + mSparkle = ReflectionUtils.getMethod(mTCProxy, "sparkle", new Class[] {float.class, float.class, float.class, int.class}); + mDrawEssentia = ReflectionUtils.getMethod(mTileRepairerClass, "drawEssentia", new Class[] {}); + // Set the fields we need + mRepairTiconTools = ReflectionUtils.getField(mTTConfigHandler, "repairTConTools"); + mTicksExisted = ReflectionUtils.getField(mTileRepairerClass, "ticksExisted"); + mInventory = ReflectionUtils.getField(mTileRepairerClass, "inventorySlots"); + mTookLastTick = ReflectionUtils.getField(mTileRepairerClass, "tookLastTick"); + mDamageLastTick = ReflectionUtils.getField(mTileRepairerClass, "dmgLastTick"); + mProxyTC = ReflectionUtils.getField(mThaumicTinkerer, "tcProxy"); + repairTConTools = (boolean) ReflectionUtils.getFieldValue(mRepairTiconTools); + mInit = true; + } + if (mInit) { + if (mTileRepairerClass.isInstance(aTile)) { + int ticksExisted = (int) ReflectionUtils.getFieldValue(mTicksExisted, aTile); + ItemStack[] inventorySlots = (ItemStack[]) ReflectionUtils.getFieldValue(mInventory, aTile); + boolean tookLastTick = (boolean) ReflectionUtils.getFieldValue(mTookLastTick, aTile); + int dmgLastTick = (int) ReflectionUtils.getFieldValue(mDamageLastTick, aTile); + ticksExisted++; + ReflectionUtils.setField(aTile, mTicksExisted, ticksExisted); + boolean aDidRun = false; + if (ticksExisted % 10 == 0) { + if (Loader.isModLoaded("TConstruct") && repairTConTools && inventorySlots[0] != null && isTConstructTool(inventorySlots[0])) { + final int dmg = getDamage(inventorySlots[0]); + if (dmg > 0) { + final int essentia = drawEssentia(aTile); + fixDamage(inventorySlots[0], essentia); + aTile.markDirty(); + if (dmgLastTick != 0 && dmgLastTick != dmg) { + sparkle((float)(aTile.xCoord + 0.25 + Math.random() / 2.0), (float)(aTile.yCoord + 1 + Math.random() / 2.0), (float)(aTile.zCoord + 0.25 + Math.random() / 2.0), 0); + tookLastTick = true; + } + else { + tookLastTick = false; + } + } + else { + tookLastTick = false; + } + dmgLastTick = ((inventorySlots[0] == null) ? 0 : getDamage(inventorySlots[0])); + aDidRun = true; + } + if (inventorySlots[0] != null && inventorySlots[0].getItemDamage() > 0 && inventorySlots[0].getItem().isRepairable()) { + final int essentia2 = drawEssentia(aTile); + final int dmg2 = inventorySlots[0].getItemDamage(); + inventorySlots[0].setItemDamage(Math.max(0, dmg2 - essentia2)); + aTile.markDirty(); + if (dmgLastTick != 0 && dmgLastTick != dmg2) { + sparkle((float)(aTile.xCoord + 0.25 + Math.random() / 2.0), (float)(aTile.yCoord + 1 + Math.random() / 2.0), (float)(aTile.zCoord + 0.25 + Math.random() / 2.0), 0); + tookLastTick = true; + } + else { + tookLastTick = false; + } + } + else { + tookLastTick = false; + } + dmgLastTick = ((inventorySlots[0] == null) ? 0 : inventorySlots[0].getItemDamage()); + aDidRun = true; + } + if (aDidRun) { + ReflectionUtils.setField(aTile, mInventory, inventorySlots); + ReflectionUtils.setField(aTile, mTookLastTick, tookLastTick); + ReflectionUtils.setField(aTile, mDamageLastTick, dmgLastTick); + } + } + } + } + + public ClassTransformer_TT_ThaumicRestorer(byte[] basicClass) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + boolean obfuscated = false; + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + AddAdapter aMethodStripper = new AddAdapter(aTempWriter); + aTempReader.accept(aMethodStripper, 0); + obfuscated = aMethodStripper.isObfuscated; + String aUpdateEntity = obfuscated ? "func_145845_h" : "updateEntity"; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Patching: "+aUpdateEntity+", Are we patching obfuscated methods? "+obfuscated); + //injectMethod(aUpdateEntity, aTempWriter, obfuscated); + injectMethodNew(aTempWriter, obfuscated); + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem 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 injectMethodNew(ClassWriter cw, boolean obfuscated) { + MethodVisitor mv; + boolean didInject = false; + String aUpdateEntity = obfuscated ? "func_145845_h" : "updateEntity"; + String aTileEntity = obfuscated ? "aor" : "net/minecraft/tileentity/TileEntity"; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Injecting " + aUpdateEntity + "."); + mv = cw.visitMethod(ACC_PUBLIC, aUpdateEntity, "()V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(60, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/ClassTransformer_TT_ThaumicRestorer", "updateEntity", "(L"+aTileEntity+";)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(61, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lthaumic/tinkerer/common/block/tile/TileRepairer;", null, l0, l2, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + didInject = true; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Method injection complete. "+(obfuscated ? "Obfuscated" : "Non-Obfuscated")); + return didInject; + } + + public boolean injectMethod(String aMethodName, ClassWriter cw, boolean obfuscated) { + MethodVisitor mv; + boolean didInject = false; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem Patch", Level.INFO, "Injecting " + aMethodName + "."); + + String aItemStack = obfuscated ? "add" : "net/minecraft/item/ItemStack"; + String aItem = obfuscated ? "adb" : "net/minecraft/item/Item"; + String aGetItemDamage = obfuscated ? "func_150976_a" : "getItemDamage"; + String aGetItem = obfuscated ? "func_77973_b" : "getItem"; + String aSetItemDamage = obfuscated ? "func_77964_b" : "setItemDamage"; + String aIsRepairable = obfuscated ? "func_82789_a" : "isRepairable"; + + mv = cw.visitMethod(ACC_PUBLIC, aMethodName, "()V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(59, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "ticksExisted", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(DUP_X1); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "ticksExisted", "I"); + mv.visitIntInsn(BIPUSH, 10); + mv.visitInsn(IREM); + Label l1 = new Label(); + mv.visitJumpInsn(IFNE, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(60, l2); + mv.visitLdcInsn("TConstruct"); + mv.visitMethodInsn(INVOKESTATIC, "cpw/mods/fml/common/Loader", "isModLoaded", "(Ljava/lang/String;)Z", false); + Label l3 = new Label(); + mv.visitJumpInsn(IFEQ, l3); + mv.visitFieldInsn(GETSTATIC, "thaumic/tinkerer/common/core/handler/ConfigHandler", "repairTConTools", "Z"); + mv.visitJumpInsn(IFEQ, l3); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(61, l4); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitJumpInsn(IFNULL, l3); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(62, l5); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKESTATIC, "thaumic/tinkerer/common/compat/TinkersConstructCompat", "isTConstructTool", "(L"+aItemStack+";)Z", false); + mv.visitJumpInsn(IFEQ, l3); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(63, l6); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKESTATIC, "thaumic/tinkerer/common/compat/TinkersConstructCompat", "getDamage", "(L"+aItemStack+";)I", false); + mv.visitVarInsn(ISTORE, 1); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(64, l7); + mv.visitVarInsn(ILOAD, 1); + Label l8 = new Label(); + mv.visitJumpInsn(IFLE, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(65, l9); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumic/tinkerer/common/block/tile/TileRepairer", "drawEssentia", "()I", false); + mv.visitVarInsn(ISTORE, 2); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(66, l10); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "thaumic/tinkerer/common/compat/TinkersConstructCompat", "fixDamage", "(L"+aItemStack+";I)Z", false); + mv.visitInsn(POP); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(67, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumic/tinkerer/common/block/tile/TileRepairer", "markDirty", "()V", false); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(68, l12); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + Label l13 = new Label(); + mv.visitJumpInsn(IFEQ, l13); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + mv.visitVarInsn(ILOAD, 1); + mv.visitJumpInsn(IF_ICMPEQ, l13); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(69, l14); + mv.visitFieldInsn(GETSTATIC, "thaumic/tinkerer/common/ThaumicTinkerer", "tcProxy", "Lthaumcraft/common/CommonProxy;"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "xCoord", "I"); + mv.visitInsn(I2D); + mv.visitLdcInsn(new Double("0.25")); + mv.visitInsn(DADD); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "yCoord", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2D); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "zCoord", "I"); + mv.visitInsn(I2D); + mv.visitLdcInsn(new Double("0.25")); + mv.visitInsn(DADD); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/common/CommonProxy", "sparkle", "(FFFI)V", false); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(70, l15); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_1); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + Label l16 = new Label(); + mv.visitLabel(l16); + mv.visitLineNumber(71, l16); + Label l17 = new Label(); + mv.visitJumpInsn(GOTO, l17); + mv.visitLabel(l13); + mv.visitFrame(Opcodes.F_APPEND,2, new Object[] {Opcodes.INTEGER, Opcodes.INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_0); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + Label l18 = new Label(); + mv.visitLabel(l18); + mv.visitLineNumber(72, l18); + mv.visitJumpInsn(GOTO, l17); + mv.visitLabel(l8); + mv.visitFrame(Opcodes.F_CHOP,1, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_0); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + mv.visitLabel(l17); + mv.visitLineNumber(73, l17); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + Label l19 = new Label(); + mv.visitJumpInsn(IFNONNULL, l19); + mv.visitInsn(ICONST_0); + Label l20 = new Label(); + mv.visitJumpInsn(GOTO, l20); + mv.visitLabel(l19); + mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer"}); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKESTATIC, "thaumic/tinkerer/common/compat/TinkersConstructCompat", "getDamage", "(L"+aItemStack+";)I", false); + mv.visitLabel(l20); + mv.visitFrame(Opcodes.F_FULL, 2, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer", Opcodes.INTEGER}, 2, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer", Opcodes.INTEGER}); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + Label l21 = new Label(); + mv.visitLabel(l21); + mv.visitLineNumber(74, l21); + mv.visitInsn(RETURN); + mv.visitLabel(l3); + mv.visitLineNumber(78, l3); + mv.visitFrame(Opcodes.F_CHOP,1, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + Label l22 = new Label(); + mv.visitJumpInsn(IFNULL, l22); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aGetItemDamage+"", "()I", false); + mv.visitJumpInsn(IFLE, l22); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aGetItem+"", "()L"+aItem+";", false); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItem+"", ""+aIsRepairable+"", "()Z", false); + mv.visitJumpInsn(IFEQ, l22); + Label l23 = new Label(); + mv.visitLabel(l23); + mv.visitLineNumber(79, l23); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumic/tinkerer/common/block/tile/TileRepairer", "drawEssentia", "()I", false); + mv.visitVarInsn(ISTORE, 1); + Label l24 = new Label(); + mv.visitLabel(l24); + mv.visitLineNumber(80, l24); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aGetItemDamage+"", "()I", false); + mv.visitVarInsn(ISTORE, 2); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(81, l25); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 1); + mv.visitInsn(ISUB); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "max", "(II)I", false); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aSetItemDamage+"", "(I)V", false); + Label l26 = new Label(); + mv.visitLabel(l26); + mv.visitLineNumber(82, l26); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumic/tinkerer/common/block/tile/TileRepairer", "markDirty", "()V", false); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(84, l27); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + Label l28 = new Label(); + mv.visitJumpInsn(IFEQ, l28); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + mv.visitVarInsn(ILOAD, 2); + mv.visitJumpInsn(IF_ICMPEQ, l28); + Label l29 = new Label(); + mv.visitLabel(l29); + mv.visitLineNumber(85, l29); + mv.visitFieldInsn(GETSTATIC, "thaumic/tinkerer/common/ThaumicTinkerer", "tcProxy", "Lthaumcraft/common/CommonProxy;"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "xCoord", "I"); + mv.visitInsn(I2D); + mv.visitLdcInsn(new Double("0.25")); + mv.visitInsn(DADD); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "yCoord", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitInsn(I2D); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "zCoord", "I"); + mv.visitInsn(I2D); + mv.visitLdcInsn(new Double("0.25")); + mv.visitInsn(DADD); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Math", "random", "()D", false); + mv.visitLdcInsn(new Double("2.0")); + mv.visitInsn(DDIV); + mv.visitInsn(DADD); + mv.visitInsn(D2F); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/common/CommonProxy", "sparkle", "(FFFI)V", false); + Label l30 = new Label(); + mv.visitLabel(l30); + mv.visitLineNumber(86, l30); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_1); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + Label l31 = new Label(); + mv.visitLabel(l31); + mv.visitLineNumber(87, l31); + Label l32 = new Label(); + mv.visitJumpInsn(GOTO, l32); + mv.visitLabel(l28); + mv.visitFrame(Opcodes.F_APPEND,2, new Object[] {Opcodes.INTEGER, Opcodes.INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_0); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + Label l33 = new Label(); + mv.visitLabel(l33); + mv.visitLineNumber(88, l33); + mv.visitJumpInsn(GOTO, l32); + mv.visitLabel(l22); + mv.visitFrame(Opcodes.F_CHOP,2, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ICONST_0); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "tookLastTick", "Z"); + mv.visitLabel(l32); + mv.visitLineNumber(90, l32); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + Label l34 = new Label(); + mv.visitJumpInsn(IFNONNULL, l34); + mv.visitInsn(ICONST_0); + Label l35 = new Label(); + mv.visitJumpInsn(GOTO, l35); + mv.visitLabel(l34); + mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer"}); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "inventorySlots", "[L"+aItemStack+";"); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, ""+aItemStack+"", ""+aGetItemDamage+"", "()I", false); + mv.visitLabel(l35); + mv.visitFrame(Opcodes.F_FULL, 1, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer"}, 2, new Object[] {"thaumic/tinkerer/common/block/tile/TileRepairer", Opcodes.INTEGER}); + mv.visitFieldInsn(PUTFIELD, "thaumic/tinkerer/common/block/tile/TileRepairer", "dmgLastTick", "I"); + mv.visitLabel(l1); + mv.visitLineNumber(92, l1); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitInsn(RETURN); + Label l36 = new Label(); + mv.visitLabel(l36); + mv.visitLocalVariable("this", "Lthaumic/tinkerer/common/block/tile/TileRepairer;", null, l0, l36, 0); + mv.visitLocalVariable("dmg", "I", null, l7, l3, 1); + mv.visitLocalVariable("essentia", "I", null, l10, l18, 2); + mv.visitLocalVariable("essentia", "I", null, l24, l33, 1); + mv.visitLocalVariable("dmg", "I", null, l25, l33, 2); + mv.visitMaxs(9, 3); + mv.visitEnd(); + didInject = true; + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem 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[] {"updateEntity", "func_145845_h"}; + public boolean isObfuscated = false; + + + @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; + if (s.equals(aMethodsToStrip[1])) { + isObfuscated = true; + } + break; + } + } + if (!found) { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + else { + methodVisitor = null; + } + + if (found) { + Preloader_Logger.LOG("Thaumic Tinkerer RepairItem 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 5dc7dcfbc8..cb9799fce7 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -1,52 +1,6 @@ package gtPlusPlus.preloader.asm.transformers; -import static gtPlusPlus.preloader.asm.ClassesToTransform.COFH_ORE_DICTIONARY_ARBITER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.FORGE_CHUNK_MANAGER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.FORGE_ORE_DICTIONARY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GALACTICRAFT_ENTITY_AUTO_ROCKET; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GALACTICRAFT_FLUID_UTILS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GALACTICRAFT_TILE_ENTITY_FUEL_LOADER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GTPP_MTE_HATCH_SUPER_INPUT_BUS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GTPP_MTE_HATCH_SUPER_OUTPUT_BUS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_ACHIEVEMENTS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_BASE_META_TILE_ENTITY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_BLOCK_MACHINES; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_CLIENT_PROXY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_ITEM_MACHINES; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_METAGENERATED_TOOL; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_METAPIPE_FLUID; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_METAPIPE_FRAME; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_METAPIPE_ITEM; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_MTE_CHARCOAL_PIT; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_MTE_HATCH_INPUTBUS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_MTE_HATCH_OUTPUTBUS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_PACKET_TILE_ENTITY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.GT_UTILITY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_BASE_TILE_ENTITY; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_CHARGEPAD; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_ELECTRIC; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_GENERATOR; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_HEAT_GENERATOR; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_KINETIC_GENERATOR; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_LUMINATOR; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_MACHINE1; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_MACHINE2; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_MACHINE3; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_PERSONAL; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_ACCESS_HATCH; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_CHAMBER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_FLUID_PORT; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_REDSTONE_PORT; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_BLOCK_REACTOR_VESSEL; -import static gtPlusPlus.preloader.asm.ClassesToTransform.IC2_ITEM_ARMOUR_HAZMAT; -import static gtPlusPlus.preloader.asm.ClassesToTransform.LWJGL_KEYBOARD; -import static gtPlusPlus.preloader.asm.ClassesToTransform.MINECRAFT_GAMESETTINGS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.MINECRAFT_GAMESETTINGS_OBF; -import static gtPlusPlus.preloader.asm.ClassesToTransform.RAILCRAFT_FLUID_HELPER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.RAILCRAFT_INVENTORY_TOOLS; -import static gtPlusPlus.preloader.asm.ClassesToTransform.RAILCRAFT_TILE_FLUID_LOADER; -import static gtPlusPlus.preloader.asm.ClassesToTransform.THAUMCRAFT_ITEM_WISP_ESSENCE; -import static gtPlusPlus.preloader.asm.ClassesToTransform.TINKERS_FLUID_BLOCK; +import static gtPlusPlus.preloader.asm.ClassesToTransform.*; import java.io.File; import java.io.IOException; @@ -317,6 +271,11 @@ public class Preloader_Transformer_Handler implements IClassTransformer { Preloader_Logger.INFO("Thaumcraft WispEssence_Patch", "Transforming "+transformedName); return new ClassTransformer_TC_ItemWispEssence(basicClass, obfuscated).getWriter().toByteArray(); } + //Fix Thaumic Tinkerer Shit + if (transformedName.equals(THAUMICTINKERER_TILE_REPAIRER) && AsmConfig.enableThaumicTinkererRepairFix) { + //Preloader_Logger.INFO("Thaumic Tinkerer RepairItem Patch", "Transforming "+transformedName); + //return new ClassTransformer_TT_ThaumicRestorer(basicClass).getWriter().toByteArray(); + } return basicClass; diff --git a/src/Java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java b/src/Java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java index 9d646e3eb5..95067300c8 100644 --- a/src/Java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java +++ b/src/Java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java @@ -1,16 +1,42 @@ package gtPlusPlus.xmod.bop; +import java.lang.reflect.Field; + import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; public class HANDLER_BiomesOPlenty { + + public static Item mPineCone; + + public static Block logs1; + public static Block logs2; + public static Block logs3; + public static Block logs4; + + public static Block leaves1; + public static Block leaves2; + public static Block leaves3; + public static Block leaves4; + public static Block colorizedLeaves1; + public static Block colorizedLeaves2; + public static Block saplings; + public static Block colorizedSaplings; + public static void preInit(){ - //if (LoadedMods.BiomesOPlenty){ - BOP_Block_Registrator.run(); - //} + BOP_Block_Registrator.run(); + if (LoadedMods.BiomesOPlenty){ + setFields(); + registerPineconeToOreDict(); + } } @@ -21,11 +47,135 @@ public class HANDLER_BiomesOPlenty { } public static void postInit(){ + BOP_Block_Registrator.recipes(); if (LoadedMods.BiomesOPlenty){ - BOP_Block_Registrator.recipes(); + } + } + private static void registerPineconeToOreDict() { + if (mPineCone != null) { + ItemStack aPinecone = ItemUtils.simpleMetaStack(mPineCone, 13, 1); + if (aPinecone != null) { + ItemUtils.addItemToOreDictionary(aPinecone, "pinecone"); + } + } + } + + public static ItemStack getStack(Block aBlock, int aMeta, int aSize) { + return ItemUtils.simpleMetaStack(aBlock, aMeta, aSize); } + + //BOPCBlocks.logs4 - 0 + //BOPCBlocks.colorizedLeaves2 - 1 + + private static void setFields() { + Field aBopMiscItem = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCItems"), "misc"); + + Field aBopBlock1 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs1"); + Field aBopBlock2 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs2"); + Field aBopBlock3 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs3"); + Field aBopBlock4 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs4"); + + Field aBopLeaves1 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves1"); + Field aBopLeaves2 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves2"); + Field aBopLeaves3 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves3"); + Field aBopLeaves4 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves4"); + + Field aBopColouredLeaves1 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves1"); + Field aBopColouredLeaves2 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves2"); + + Field aBopSapling = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "saplings"); + Field aBopColouredSapling = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedSaplings"); + + if (aBopMiscItem != null) { + Item aMiscItem = (Item) ReflectionUtils.getFieldValue(aBopMiscItem); + if (aMiscItem != null) { + mPineCone = aMiscItem; + } + } + + + if (aBopBlock1 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock1); + if (aBlock != null) { + logs1 = aBlock; + } + } + if (aBopBlock2 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock2); + if (aBlock != null) { + logs2 = aBlock; + } + } + if (aBopBlock3 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock3); + if (aBlock != null) { + logs3 = aBlock; + } + } + if (aBopBlock4 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock4); + if (aBlock != null) { + logs4 = aBlock; + } + } + + + if (aBopLeaves1 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves1); + if (aBlock != null) { + leaves1 = aBlock; + } + } + if (aBopLeaves2 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves2); + if (aBlock != null) { + leaves2 = aBlock; + } + } + if (aBopLeaves3 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves3); + if (aBlock != null) { + leaves3 = aBlock; + } + } + if (aBopLeaves4 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves4); + if (aBlock != null) { + leaves4 = aBlock; + } + } + + + if (aBopColouredLeaves1 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopColouredLeaves1); + if (aBlock != null) { + colorizedLeaves1 = aBlock; + } + } + if (aBopColouredLeaves2 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopColouredLeaves2); + if (aBlock != null) { + colorizedLeaves2 = aBlock; + } + } + + + if (aBopSapling != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopSapling); + if (aBlock != null) { + saplings = aBlock; + } + } + if (aBopColouredSapling != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopColouredSapling); + if (aBlock != null) { + colorizedSaplings = aBlock; + } + } + } + } diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java b/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java index 2ee1587809..3716359d7a 100644 --- a/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java @@ -16,6 +16,9 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.bop.blocks.pine.LeavesPineTree; +import gtPlusPlus.xmod.bop.blocks.pine.LogPineTree; +import gtPlusPlus.xmod.bop.blocks.pine.SaplingPineTree; import gtPlusPlus.xmod.bop.blocks.rainforest.LeavesRainforestTree; import gtPlusPlus.xmod.bop.blocks.rainforest.LogRainforestTree; import gtPlusPlus.xmod.bop.blocks.rainforest.SaplingRainforestTree; @@ -30,10 +33,14 @@ public class BOP_Block_Registrator { public static Block log_Rainforest; public static Block leaves_Rainforest; public static Block sapling_Rainforest; + public static Block log_Pine; + public static Block leaves_Pine; + public static Block sapling_Pine; //Runs Each tree Type separately public static final void run(){ registerTree_Rainforest(); + registerTree_Pine(); } @@ -47,10 +54,23 @@ public class BOP_Block_Registrator { return true; } + private static final boolean registerTree_Pine(){ + log_Pine = new LogPineTree(); + leaves_Pine = new LeavesPineTree(); + sapling_Pine = new SaplingPineTree(); + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(log_Pine), "logWood", true); + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(leaves_Pine), "treeLeaves", true); + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(sapling_Pine), "treeSapling", true); + return true; + } + public static final void recipes() { - //Rainforest Oak + // Rainforest Oak addLogRecipes(ItemUtils.getSimpleStack(log_Rainforest)); addSaplingRecipes(ItemUtils.getSimpleStack(sapling_Rainforest)); + // Pine + addLogRecipes(ItemUtils.getSimpleStack(log_Pine)); + addSaplingRecipes(ItemUtils.getSimpleStack(sapling_Pine)); } diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java b/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java index 264aaa2a20..5c86c45591 100644 --- a/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java @@ -55,16 +55,12 @@ public class LeavesBase extends BlockLeaves { @Override//Drops when Leaf is broken protected void func_150124_c(World world, int x, int y, int z, int meta, int randomChance){ - if (this.treeType.length == this.bonusDrops.length){ - for (int i = 0; i < this.treeType.length; ++i){ - if (this.bonusDrops[i] != null && world.rand.nextInt(randomChance) == 0){ - this.dropBlockAsItem(world, x, y, z, ItemUtils.getSimpleStack(this.bonusDrops[i], 1)); - } + Logger.INFO("Dropping Bonus Drops"); + for (int i = 0; i < this.bonusDrops.length; ++i){ + if (this.bonusDrops[i] != null && world.rand.nextInt(randomChance) == 0){ + this.dropBlockAsItem(world, x, y, z, ItemUtils.getSimpleStack(this.bonusDrops[i], 1)); } } - else { - Logger.WARNING("Unable to drop anything, Leaf Type array and Loot array are different sizes."); - } } /** diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LeavesPineTree.java b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LeavesPineTree.java new file mode 100644 index 0000000000..c942db14cf --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LeavesPineTree.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.bop.blocks.pine; + +import java.util.Random; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; +import gtPlusPlus.xmod.bop.blocks.base.LeavesBase; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class LeavesPineTree extends LeavesBase { + + public LeavesPineTree(){ + super("Pine", "pine", new ItemStack[]{}); + this.treeType = new String[] {"pine"}; + this.leafType = new String[][] {{"pine"},{"pine_opaque"}}; + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_){ + return Item.getItemFromBlock(BOP_Block_Registrator.sapling_Pine); + } + + @Override//Drops when Leaf is broken + protected void func_150124_c(World world, int x, int y, int z, int meta, int randomChance){ + Logger.INFO("Dropping Bonus Drops"); + if (MathUtils.randInt(0, 10) >= 9) { + this.dropBlockAsItem(world, x, y, z, ItemUtils.getSimpleStack(AgriculturalChem.mPinecone, MathUtils.randInt(1, 4))); + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LogPineTree.java b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LogPineTree.java new file mode 100644 index 0000000000..dee5bf02fd --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LogPineTree.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.bop.blocks.pine; + +import gtPlusPlus.xmod.bop.blocks.base.LogBase; + +public class LogPineTree extends LogBase { + + public LogPineTree(){ + super("Pine Log", "pine", new String[]{"pine"}); + this.treeType = new String[] {"pine"}; + } + + /*@Override + @SideOnly(Side.CLIENT) + protected IIcon getSideIcon(int metaID){ + return this.textureSide[metaID % this.textureSide.length]; + } + + @Override + @SideOnly(Side.CLIENT) + protected IIcon getTopIcon(int metaID){ + return this.textureTop[metaID % this.textureTop.length]; + }*/ + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/pine/SaplingPineTree.java b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/SaplingPineTree.java new file mode 100644 index 0000000000..0ee04de899 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/SaplingPineTree.java @@ -0,0 +1,55 @@ +package gtPlusPlus.xmod.bop.blocks.pine; + +import java.util.Random; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.bop.blocks.base.SaplingBase; +import gtPlusPlus.xmod.bop.world.features.trees.WorldGenPineTree; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenBigTree; +import net.minecraft.world.gen.feature.WorldGenTrees; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class SaplingPineTree extends SaplingBase { + + public SaplingPineTree(){ + super("Pine Sapling", "pine", new String[]{"pine"}); + } + + @Override + public void func_149878_d(World world, int x, int y, int z, Random rand){ + Logger.WARNING("func_149878_d - 1"); + if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(world, rand, x, y, z)) return; + rand.nextInt(10); + new WorldGenBigTree(true); + new WorldGenTrees(true); + int i1 = 0; + int j1 = 0; + boolean flag = false; + + Block block = Blocks.air; + + if (flag) + { + world.setBlock(x + i1, y, z + j1, block, 0, 4); + world.setBlock(x + i1 + 1, y, z + j1, block, 0, 4); + world.setBlock(x + i1, y, z + j1 + 1, block, 0, 4); + world.setBlock(x + i1 + 1, y, z + j1 + 1, block, 0, 4); + } + else + { + world.setBlock(x, y, z, block, 0, 4); + } + Object obj = new WorldGenPineTree(); + if (obj != null) { + world.setBlockToAir(x, y, z); + if (!((WorldGenerator) obj).generate(world, CORE.RANDOM, x, y, z)) { + world.setBlock(x, y, z, this, 0, 2); + } + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bop/world/features/trees/WorldGenPineTree.java b/src/Java/gtPlusPlus/xmod/bop/world/features/trees/WorldGenPineTree.java new file mode 100644 index 0000000000..831108ec99 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bop/world/features/trees/WorldGenPineTree.java @@ -0,0 +1,171 @@ +package gtPlusPlus.xmod.bop.world.features.trees; + +import java.util.Random; + +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenPineTree extends WorldGenAbstractTree{ + + public WorldGenPineTree() { + super(true); + } + + @Override + public boolean generate(World world, Random random, int x, int y, int z) { + while (world.isAirBlock(x, y, z) && y > 2) { + --y; + } + + Block aSoilBlock = world.getBlock(x, y, z); + + if (!canBlockSustainSapling(world, aSoilBlock, x, y, z)) { + return false; + } else { + int height; + int branches; + for (height = -2; height <= 2; ++height) { + for (branches = -2; branches <= 2; ++branches) { + if (world.isAirBlock(x + height, y - 1, z + branches) + && world.isAirBlock(x + height, y - 2, z + branches) + && !world.isAirBlock(x + height, y, z + branches)) { + return false; + } + } + } + + height = 2 + MathUtils.randInt(8, 16); + branches = 2 + MathUtils.randInt(6, 18); + int h = 1; + aSoilBlock.onPlantGrow(world, x, y - 1, z, x, y, z); + + int c; + int r = MathUtils.randInt(1, 3); + for (c = 0; c < height; ++c) { + this.buildBlock(world, x, y + h, z, BOP_Block_Registrator.log_Pine, 0); + h++; + if (c >= r && c % 2 == 0) { + this.generateBranch(world, random, x, y + h, z, c); + } + } + + this.generateTop(world, x, y + h, z); + return true; + } + } + + public void generateTop(World world, int x, int y, int z) { + for (int i = -1; i < 2; ++i) { + for (int j = -1; j < 2; ++j) { + this.buildBlock(world, x + i, y, z + j, BOP_Block_Registrator.leaves_Pine, 0); + } + } + + this.buildBlock(world, x, y, z, BOP_Block_Registrator.log_Pine, 0); + this.buildBlock(world, x + 1, y + 1, z, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x, y + 1, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x, y + 1, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 1, y + 1, z, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x, y + 2, z, BOP_Block_Registrator.leaves_Pine, 0); + } + + public void generateBranch(World world, Random rand, int x, int y, int z, int n) { + int var99999; + int var99998; + for (var99999 = -1; var99999 < 2; ++var99999) { + for (var99998 = -1; var99998 < 2; ++var99998) { + this.buildBlock(world, x + var99999, y, z + var99998, BOP_Block_Registrator.leaves_Pine, 0); + } + } + + var99999 = rand.nextInt(2); + var99998 = rand.nextInt(2); + int var99997 = rand.nextInt(2); + int var99996 = rand.nextInt(2); + if (n % 2 == 0) { + if (var99998 == 0) { + this.buildBlock(world, x + 1, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 2, y - 1, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + if (var99999 == 0) { + this.buildBlock(world, x + 2, y - 2, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x + 2, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + this.buildBlock(world, x + 1, y, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 2, y, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 2, y, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } + + if (var99997 == 0) { + this.buildBlock(world, x - 2, y - 1, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 1, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + if (var99996 == 0) { + this.buildBlock(world, x - 2, y - 2, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x - 2, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + this.buildBlock(world, x - 2, y, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 1, y, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 2, y, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + if (var99998 == 0) { + this.buildBlock(world, x + 2, y - 1, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 1, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + if (var99999 == 0) { + this.buildBlock(world, x + 2, y - 2, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x + 2, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + this.buildBlock(world, x + 2, y, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 1, y, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + if (var99999 == 0) { + this.buildBlock(world, x + 2, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x + 2, y, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } + + if (var99997 == 0) { + this.buildBlock(world, x - 1, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 2, y - 1, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + if (var99996 == 0) { + this.buildBlock(world, x - 2, y - 2, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x - 2, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + this.buildBlock(world, x - 1, y, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 2, y, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + if (var99996 == 0) { + this.buildBlock(world, x - 2, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x - 2, y, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } + } + + this.buildBlock(world, x, y, z, BOP_Block_Registrator.log_Pine, 0); + this.buildBlock(world, x, y + 1, z, BOP_Block_Registrator.log_Pine, 0); + } + + public void buildBlock(World world, int x, int y, int z, Block block, int meta) { + if (world.isAirBlock(x, y, z) || world.getBlock(x, y, z).isLeaves(world, x, y, z)) { + world.setBlock(x, y, z, block, meta, 2); + } + } + + public boolean canBlockSustainSapling(World world, Block block, int x, int y, int z) { + return block.canSustainPlant(world, x, y, z, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 1cb499479f..7c1b854770 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -53,6 +53,7 @@ import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricButcherKnife; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricLighter; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricSnips; import gtPlusPlus.xmod.gregtech.loaders.ProcessingToolHeadChoocher; +import gtPlusPlus.xmod.gregtech.loaders.misc.AddCustomMachineToPA; import gtPlusPlus.xmod.gregtech.loaders.misc.WoodCentrifuging; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; import gtPlusPlus.xmod.gregtech.recipes.RecipesToRemove; @@ -129,6 +130,9 @@ public class HANDLER_GT { if (ConfigSwitches.enableOldGTcircuits && !CORE.GTNH){ OldCircuitHandler.postInit(); } + + // Register custom singles to the PA + AddCustomMachineToPA.register(); // Register the No-Bonus Special Behaviour. diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 504533c406..b7662ca25e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -19,6 +19,12 @@ public enum GregtechItemList implements GregtechItemContainer { /** * Items */ + + // Advanced Hazmat Suit + Armour_Hazmat_Advanced_Helmet, + Armour_Hazmat_Advanced_Chest, + Armour_Hazmat_Advanced_Legs, + Armour_Hazmat_Advanced_Boots, //Gregtech Machine Parts Electric_Motor_LuV, Electric_Motor_ZPM, Electric_Motor_UV, Electric_Motor_MAX, @@ -49,6 +55,7 @@ public enum GregtechItemList implements GregtechItemContainer { //Recipe Circuit Circuit_BioRecipeSelector, + Circuit_T3RecipeSelector, //Circuits Old_Circuit_Primitive, Old_Circuit_Basic, Old_Circuit_Good, @@ -363,6 +370,9 @@ public enum GregtechItemList implements GregtechItemContainer { Casing_Turbine_LP, Casing_Turbine_HP, Casing_Turbine_Gas, Casing_Turbine_Plasma, + // Large Engine + Casing_Reinforced_Engine_Casing, + //Large Vacuum Furnace Casing_Vacuum_Furnace, Controller_Vacuum_Furnace, @@ -375,10 +385,13 @@ public enum GregtechItemList implements GregtechItemContainer { Controller_LargeSemifluidGenerator, // IsaMill - Controller_IsaMill_Controller, + Controller_IsaMill, Casing_IsaMill_Casing, Casing_IsaMill_Gearbox, Casing_IsaMill_Pipe, + + // Flotation Cell + Controller_Flotation_Cell, //---------------------------------------------------------------------------- @@ -402,6 +415,12 @@ public enum GregtechItemList implements GregtechItemContainer { //Control Core Hatch_Control_Core, + + // Milling Ball Bus + Bus_Milling_Balls, + + // Catalyst Bus + Bus_Catalysts, //Custom Fluid Hatches Hatch_Input_Cryotheum, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java new file mode 100644 index 0000000000..9596d41387 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java @@ -0,0 +1,282 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_Container; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.core.slots.SlotNoInput; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CONTAINER_HatchNbtConsumable extends GT_Container { + + public final int mInputslotCount; + private final int mTotalSlotCount; + + public CONTAINER_HatchNbtConsumable(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aInputslotCount) { + super(aInventoryPlayer, aTileEntity); + mInputslotCount = aInputslotCount; + mTotalSlotCount = aInputslotCount*2; + mTileEntity = aTileEntity; + if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { + addSlots(aInventoryPlayer); + if (doesBindPlayerInventory()) { + bindPlayerInventory(aInventoryPlayer); + } + detectAndSendChanges(); + } else { + aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; + } + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + if (mTotalSlotCount == 8) { + final int aSlotYStart = 26; + final int aSlotYFinish = aSlotYStart + (18*2); + final int aSlotXStart1 = 26; + final int aSlotXFinish1 = aSlotXStart1 + (18*2); + final int aSlotXStart2 = 116; + final int aSlotXFinish2 = aSlotXStart2 + (18*2); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } + else if (mTotalSlotCount == 18) { + int aSlotYStart = 20; + int aSlotYFinish = aSlotYStart + (18*3); + int aSlotXStart1 = 26; + int aSlotXFinish1 = aSlotXStart1 + (18*3); + int aSlotXStart2 = 98; + int aSlotXFinish2 = aSlotXStart2 + (18*3); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } + else if (mTotalSlotCount == 32) { + int aSlotYStart = 8; + int aSlotYFinish = aSlotYStart + (18*4); + int aSlotXStart1 = 8; + int aSlotXFinish1 = aSlotXStart1 + (18*4); + int aSlotXStart2 = 97; + int aSlotXFinish2 = aSlotXStart2 + (18*4); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } + } + + @Override + public int getSlotCount() { + return mTotalSlotCount; + } + + @Override + public int getShiftClickSlotCount() { + return mInputslotCount; + } + + /* + * Uselss stuff copied from GT + */ + + + public int mActive = 0, mMaxProgressTime = 0, mProgressTime = 0, mEnergy = 0, mSteam = 0, mSteamStorage = 0, mStorage = 0, mOutput = 0, mInput = 0, mID = 0, mDisplayErrorCode = 0; + private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, oEnergy = 0, oSteam = 0, oSteamStorage = 0, oStorage = 0, oOutput = 0, oInput = 0, oID = 0, oDisplayErrorCode = 0, mTimer = 0; + + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + mStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getEUCapacity()); + mEnergy = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredEU()); + mSteamStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getSteamCapacity()); + mSteam = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredSteam()); + mOutput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getOutputVoltage()); + mInput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getInputVoltage()); + mDisplayErrorCode = mTileEntity.getErrorDisplayID(); + mProgressTime = mTileEntity.getProgress(); + mMaxProgressTime = mTileEntity.getMaxProgress(); + mActive = mTileEntity.isActive() ? 1 : 0; + mTimer++; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + if (mTimer % 500 == 10 || oEnergy != mEnergy) { + var1.sendProgressBarUpdate(this, 0, mEnergy & 65535); + var1.sendProgressBarUpdate(this, 1, mEnergy >>> 16); + } + if (mTimer % 500 == 10 || oStorage != mStorage) { + var1.sendProgressBarUpdate(this, 2, mStorage & 65535); + var1.sendProgressBarUpdate(this, 3, mStorage >>> 16); + } + if (mTimer % 500 == 10 || oOutput != mOutput) { + var1.sendProgressBarUpdate(this, 4, mOutput); + } + if (mTimer % 500 == 10 || oInput != mInput) { + var1.sendProgressBarUpdate(this, 5, mInput); + } + if (mTimer % 500 == 10 || oDisplayErrorCode != mDisplayErrorCode) { + var1.sendProgressBarUpdate(this, 6, mDisplayErrorCode); + } + if (mTimer % 500 == 10 || oProgressTime != mProgressTime) { + var1.sendProgressBarUpdate(this, 11, mProgressTime & 65535); + var1.sendProgressBarUpdate(this, 12, mProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oMaxProgressTime != mMaxProgressTime) { + var1.sendProgressBarUpdate(this, 13, mMaxProgressTime & 65535); + var1.sendProgressBarUpdate(this, 14, mMaxProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oID != mID) { + var1.sendProgressBarUpdate(this, 15, mID); + } + if (mTimer % 500 == 10 || oActive != mActive) { + var1.sendProgressBarUpdate(this, 16, mActive); + } + if (mTimer % 500 == 10 || oSteam != mSteam) { + var1.sendProgressBarUpdate(this, 17, mSteam & 65535); + var1.sendProgressBarUpdate(this, 18, mSteam >>> 16); + } + if (mTimer % 500 == 10 || oSteamStorage != mSteamStorage) { + var1.sendProgressBarUpdate(this, 19, mSteamStorage & 65535); + var1.sendProgressBarUpdate(this, 20, mSteamStorage >>> 16); + } + } + + oID = mID; + oSteam = mSteam; + oInput = mInput; + oActive = mActive; + oOutput = mOutput; + oEnergy = mEnergy; + oStorage = mStorage; + oSteamStorage = mSteamStorage; + oProgressTime = mProgressTime; + oMaxProgressTime = mMaxProgressTime; + oDisplayErrorCode = mDisplayErrorCode; + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 0: + mEnergy = mEnergy & -65536 | par2; + break; + case 1: + mEnergy = mEnergy & 65535 | par2 << 16; + break; + case 2: + mStorage = mStorage & -65536 | par2; + break; + case 3: + mStorage = mStorage & 65535 | par2 << 16; + break; + case 4: + mOutput = par2; + break; + case 5: + mInput = par2; + break; + case 6: + mDisplayErrorCode = par2; + break; + case 11: + mProgressTime = mProgressTime & -65536 | par2; + break; + case 12: + mProgressTime = mProgressTime & 65535 | par2 << 16; + break; + case 13: + mMaxProgressTime = mMaxProgressTime & -65536 | par2; + break; + case 14: + mMaxProgressTime = mMaxProgressTime & 65535 | par2 << 16; + break; + case 15: + mID = par2; + break; + case 16: + mActive = par2; + break; + case 17: + mSteam = mSteam & -65536 | par2; + break; + case 18: + mSteam = mSteam & 65535 | par2 << 16; + break; + case 19: + mSteamStorage = mSteamStorage & -65536 | par2; + break; + case 20: + mSteamStorage = mSteamStorage & 65535 | par2 << 16; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return mTileEntity.isUseableByPlayer(player); + } + + public String trans(String aKey, String aEnglish){ + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + } + + private static class ViewingSlot extends SlotNoInput { + + public ViewingSlot(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return false; + } + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return true; + } + + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java new file mode 100644 index 0000000000..dd19571646 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java @@ -0,0 +1,59 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import gregtech.api.gui.GT_GUIContainer; + +public class GUI_HatchNbtConsumable extends GT_GUIContainer { + + private final String mName; + private final int mTotalSlotCount; + public final CONTAINER_HatchNbtConsumable mContainer; + + public GUI_HatchNbtConsumable(CONTAINER_HatchNbtConsumable aContainer, String aName) { + super(aContainer, RES_PATH_GUI + getTextureForGUI(aContainer.mInputslotCount*2)+".png"); + mContainer = aContainer; + mName = aName; + mTotalSlotCount = aContainer.mInputslotCount*2; + } + + private static final String getTextureForGUI(int aTotalSlotCOunt) { + if (aTotalSlotCOunt == 18) { + return "HatchNbtConsumable_3By3"; + } + else if (aTotalSlotCOunt == 32) { + return "HatchNbtConsumable_4By4"; + } + else { + return "HatchNbtConsumable_2By2"; + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + if (mTotalSlotCount == 18) { + fontRendererObj.drawString(mName, 8, 4, 4210752); + fontRendererObj.drawString("Stock", 25, 14, 4210752); + fontRendererObj.drawString("Active", 115, 14, 4210752); + } + else if (mTotalSlotCount == 32) { + //fontRendererObj.drawString("Slots: "+mTotalSlotCount, 8, 4, 4210752); + //fontRendererObj.drawString(mName, 8, 4, 4210752); + //fontRendererObj.drawString("Stock", 25, 16, 4210752); + //fontRendererObj.drawString("Active", 115, 16, 4210752); + } + else { + fontRendererObj.drawString(mName, 8, 4, 4210752); + fontRendererObj.drawString("Stock", 25, 16, 4210752); + fontRendererObj.drawString("Active", 115, 16, 4210752); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} 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 688433b3ac..bf36b56015 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 @@ -268,7 +268,8 @@ public interface IGregtech_RecipeAdder { public boolean addVacuumFurnaceRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt, int aLevel); - + + public boolean addVacuumFurnaceRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aLevel); public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu); public boolean addIrLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu); @@ -289,5 +290,9 @@ public interface IGregtech_RecipeAdder { public boolean addMillingRecipe(Materials aMat, int aEU); public boolean addMillingRecipe(Material aMat, int aEU); + public boolean addFlotationRecipe(Materials aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU); + public boolean addFlotationRecipe(Material aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU); + + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java new file mode 100644 index 0000000000..23f7b2a6a0 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java @@ -0,0 +1,63 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Hatch_Catalysts extends GT_MetaTileEntity_Hatch_NbtConsumable { + + public GT_MetaTileEntity_Hatch_Catalysts(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 7, 16, "Dedicated Catalyst Storage", false); + } + + public GT_MetaTileEntity_Hatch_Catalysts(String aName, String aDescription, ITexture[][][] aTextures) { + super(aName, 7, 16, aDescription, false, aTextures); + } + + public GT_MetaTileEntity_Hatch_Catalysts(String aName, String[] aDescription, ITexture[][][] aTextures) { + super(aName, 7, 16, aDescription[0], false, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { + return GT_MetaTileEntity_Hatch_Catalysts.class; + } + + @Override + public String getNameGUI() { + return "Catalyst Container"; + } + + @Override + public AutoMap<ItemStack> getItemsValidForUsageSlots() { + return new AutoMap<ItemStack>(); + } + + @Override + public boolean isItemValidForUsageSlot(ItemStack aStack) { + return ItemUtils.isCatalyst(aStack); + } + + @Override + public int getInputSlotCount() { + return 16; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java new file mode 100644 index 0000000000..6c28ab2e27 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java @@ -0,0 +1,63 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Hatch_MillingBalls extends GT_MetaTileEntity_Hatch_NbtConsumable { + + public GT_MetaTileEntity_Hatch_MillingBalls(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 6, 4, "Dedicated Milling Ball Storage", true); + } + + public GT_MetaTileEntity_Hatch_MillingBalls(String aName, String aDescription, ITexture[][][] aTextures) { + super(aName, 6, 4, aDescription, true, aTextures); + } + + public GT_MetaTileEntity_Hatch_MillingBalls(String aName, String[] aDescription, ITexture[][][] aTextures) { + super(aName, 6, 4, aDescription[0], true, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { + return GT_MetaTileEntity_Hatch_MillingBalls.class; + } + + @Override + public String getNameGUI() { + return "Ball Housing"; + } + + @Override + public AutoMap<ItemStack> getItemsValidForUsageSlots() { + return new AutoMap<ItemStack>(); + } + + @Override + public boolean isItemValidForUsageSlot(ItemStack aStack) { + return ItemUtils.isMillingBall(aStack); + } + + @Override + public int getInputSlotCount() { + return 4; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java new file mode 100644 index 0000000000..d1ce55d3f2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java @@ -0,0 +1,273 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; + +import java.lang.reflect.Constructor; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +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.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_HatchNbtConsumable; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_HatchNbtConsumable; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public abstract class GT_MetaTileEntity_Hatch_NbtConsumable extends GT_MetaTileEntity_Hatch { + + public GT_Recipe_Map mRecipeMap = null; + private final int mInputslotCount; + private final int mTotalSlotCount; + private final boolean mAllowDuplicateUsageTypes; + + public GT_MetaTileEntity_Hatch_NbtConsumable(int aID, String aName, String aNameRegional, int aTier, int aInputSlots, String aDescription, boolean aAllowDuplicateTypes) { + super(aID, aName, aNameRegional, aTier, aInputSlots*2, aDescription); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount()*2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + public GT_MetaTileEntity_Hatch_NbtConsumable(String aName, int aTier, int aInputSlots, String aDescription, boolean aAllowDuplicateTypes, ITexture[][][] aTextures) { + super(aName, aTier, aInputSlots*2, aDescription, aTextures); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount()*2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + public GT_MetaTileEntity_Hatch_NbtConsumable(String aName, int aTier, int aInputSlots, String[] aDescription, boolean aAllowDuplicateTypes, ITexture[][][] aTextures) { + super(aName, aTier, aInputSlots*2, aDescription[0], aTextures); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount()*2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + @Override + public abstract ITexture[] getTexturesActive(ITexture aBaseTexture); + + @Override + public abstract ITexture[] getTexturesInactive(ITexture aBaseTexture); + + public abstract int getInputSlotCount(); + + @Override + public final boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public final boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public final boolean isValidSlot(int aIndex) { + return aIndex < mInputslotCount; + } + + @Override + public final MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + Constructor<?> aConstructor = ReflectionUtils.getConstructor(getHatchEntityClass(), new Class[] {String.class, String[].class, ITexture[][][].class}); + GT_MetaTileEntity_Hatch_NbtConsumable aInstance = ReflectionUtils.createNewInstanceFromConstructor(aConstructor, new Object[] {mName, StaticFields59.getDescriptionArray(this), mTextures}); + if (aInstance instanceof GT_MetaTileEntity_Hatch_NbtConsumable) { + GT_MetaTileEntity_Hatch_NbtConsumable aMetaTile = (GT_MetaTileEntity_Hatch_NbtConsumable) aInstance; + return aMetaTile; + } + return null; + } + + public abstract Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass(); + + @Override + public final boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public final Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); + } + + @Override + public final Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + CONTAINER_HatchNbtConsumable aContainer = new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); + return new GUI_HatchNbtConsumable(aContainer, getNameGUI()); + } + + public abstract String getNameGUI(); + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + tryFillUsageSlots(); + } + } + + public final void updateSlots() { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] != null && mInventory[i].stackSize <= 0) { + mInventory[i] = null; + } + // Only moves items in the first four slots + if (i <= getSlotID_LastInput()) { + fillStacksIntoFirstSlots(); + } + } + } + + // Only moves items in the first four slots + protected final void fillStacksIntoFirstSlots() { + for (int i = 0; i <= getSlotID_LastInput() ; i++) { + for (int j = i + 1; j <= getSlotID_LastInput(); j++) { + if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + } + + private final void tryFillUsageSlots() { + int aSlotSpace = (mInputslotCount - getContentUsageSlots().size()); + if (aSlotSpace > 0) { + Logger.INFO("We have empty usage slots. "+aSlotSpace); + for (int i=getSlotID_FirstInput();i<=getSlotID_LastInput();i++) { + ItemStack aStackToTryMove = mInventory[i]; + if (aStackToTryMove != null && isItemValidForUsageSlot(aStackToTryMove)) { + Logger.INFO("Trying to move stack from input slot "+i); + if (moveItemFromStockToUsageSlots(aStackToTryMove)) { + Logger.INFO("Updating Slots."); + updateSlots(); + } + } + } + } + } + + private int getSlotID_FirstInput() { + return 0; + } + private int getSlotID_LastInput() { + return mInputslotCount-1; + } + private int getSlotID_FirstUsage() { + return mInputslotCount; + } + private int getSlotID_LastUsage() { + return mTotalSlotCount-1; + } + + + public final AutoMap<ItemStack> getContentUsageSlots() { + AutoMap<ItemStack> aItems = new AutoMap<ItemStack>(); + for (int i=mInputslotCount;i<mTotalSlotCount;i++) { + if (mInventory[i] != null) { + aItems.add(mInventory[i]); + } + } + return aItems; + } + + + public final boolean moveItemFromStockToUsageSlots(ItemStack aStack) { + return moveItemFromStockToUsageSlots(aStack, mAllowDuplicateUsageTypes); + } + + public final boolean moveItemFromStockToUsageSlots(ItemStack aStack, boolean aAllowMultiOfSameTypeInUsageSlots) { + if (aStack != null) { + if (aStack.stackSize > 0) { + + if (!isItemValidForUsageSlot(aStack)) { + Logger.INFO("Stack not valid: "+ItemUtils.getItemName(aStack)); + return false; + } + + // Copy the input stack into a new object + ItemStack aStackToMove = aStack.copy(); + // Set stack size of stack to move to 1. + aStackToMove.stackSize = 1; + // Did we set a stack in the usage slots? + boolean aDidSet = false; + // Did we find another of this item already in the usage slots? + boolean aFoundMatching = false; + // Continue processing with our new stack + // First check for duplicates + for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { + if (mInventory[i] != null) { + if (GT_Utility.areStacksEqual(aStackToMove, mInventory[i], true)) { + Logger.INFO("Found matching stack in slot "+i+"."); + aFoundMatching = true; + break; + } + } + } + // Then Move stack to Usage slots + for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { + if (mInventory[i] == null) { + if ((aFoundMatching && aAllowMultiOfSameTypeInUsageSlots) || !aFoundMatching) { + mInventory[i] = aStackToMove; + aDidSet = true; + Logger.INFO("Moving new stack to usage slots."); + break; + } + } + } + if (aDidSet) { + Logger.INFO("Depleting input stack size by 1."); + // Depleted one from the original input stack + aStack.stackSize--; + } + return aDidSet; + } + } + return false; + } + + @Override + public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() && isItemValidForUsageSlot(aStack); + } + + /** + * Items that get compared when checking for Usage Slot validity. + * Can return an empty map if isItemValidForUsageSlot() is overridden. + * @return + */ + public abstract AutoMap<ItemStack> getItemsValidForUsageSlots(); + + /** + * Checks if the given item is valid for Usage Slots. + * Can be overridden for easier handling if you already have methods to check this. + * @param aStack + * @return + */ + public boolean isItemValidForUsageSlot(ItemStack aStack) { + if (aStack != null) { + for (ItemStack aValid : getItemsValidForUsageSlots()) { + if (GT_Utility.areStacksEqual(aStack, aValid, true)) { + return true; + } + } + } + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java index be180bf4e9..a4a396e4cf 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java @@ -47,8 +47,8 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Structural Solar Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Salt Containment Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Thermally Insulated Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Flotation Cell Casings"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Reinforced Engine Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused @@ -64,6 +64,7 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs GregtechItemList.Casing_SolarTower_Structural.set(new ItemStack(this, 1, 6)); GregtechItemList.Casing_SolarTower_SaltContainment.set(new ItemStack(this, 1, 7)); GregtechItemList.Casing_SolarTower_HeatContainment.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_Reinforced_Engine_Casing.set(new ItemStack(this, 1, 9)); } public IIcon getIcon(int aSide, int aMeta) { @@ -88,6 +89,10 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs return TexturesGtBlock.Casing_Material_Stellite.getIcon(); case 8: return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + case 9: + return TexturesGtBlock.TEXTURE_CASING_FLOTATION.getIcon(); + case 10: + return TexturesGtBlock.Casing_Material_Talonite.getIcon(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 7903da8c6d..93322d2ef1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -281,6 +281,7 @@ public class TexturesGtBlock { public static final CustomIcon TEXTURE_CASING_ADVANCED_VOLCNUS = new CustomIcon("TileEntities/MACHINE_CASING_ADVANCED_VOLCANUS"); public static final CustomIcon TEXTURE_CASING_ROCKETDYNE = new CustomIcon("TileEntities/MACHINE_CASING_ROCKETDYNE"); public static final CustomIcon TEXTURE_CASING_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_GRINDING_FACTORY"); + public static final CustomIcon TEXTURE_CASING_FLOTATION = new CustomIcon("TileEntities/MACHINE_CASING_FLOTATION"); // Custom Pipes public static final CustomIcon TEXTURE_PIPE_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_PIPE_T1"); @@ -388,6 +389,13 @@ public class TexturesGtBlock { //Control Core Bus private static final CustomIcon Internal_Overlay_Hatch_Control_Core = new CustomIcon("iconsets/OVERLAY_CONTROL_CORE_BUS"); public static final CustomIcon Overlay_Hatch_Control_Core = Internal_Overlay_Hatch_Control_Core; + // Milling Ball Bus + private static final CustomIcon Internal_Overlay_Bus_Milling_Balls = new CustomIcon("iconsets/OVERLAY_MILLING_BALL_BUS"); + public static final CustomIcon Overlay_Bus_Milling_Balls = Internal_Overlay_Bus_Milling_Balls; + // Catalyst Bus + private static final CustomIcon Internal_Overlay_Bus_Catalyst = new CustomIcon("iconsets/OVERLAY_CATALYSTS"); + public static final CustomIcon Overlay_Bus_Catalyst = Internal_Overlay_Bus_Catalyst; + //Dimensional private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java new file mode 100644 index 0000000000..333939d800 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java @@ -0,0 +1,79 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.util.HashMap; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.data.AES; +import gtPlusPlus.xmod.gregtech.api.enums.CustomOrePrefix; +import net.minecraft.item.ItemStack; + +public class FlotationRecipeHandler { + + private static HashMap<String, Material> sMaterialMap = new HashMap<String, Material>(); + private static HashMap<String, ItemStack> sMilledMap = new HashMap<String, ItemStack>(); + private static final AES sEncodingHandler = new AES(); + + public static boolean registerOreType(Material aMaterial) { + String aMaterialKey = sEncodingHandler.encode(aMaterial.getUnlocalizedName()); + if (sMaterialMap.containsKey(aMaterialKey)) { + CORE.crash("Tried to register a Flotation material to an ID already in use. ID: "+aMaterialKey); + return false; + } + else { + sMaterialMap.put(aMaterialKey, aMaterial); + sMilledMap.put(aMaterialKey, aMaterial.getMilled(1)); + } + return true; + } + + public static int getHashForMaterial(Material aMaterial) { + return getMaterialsID(aMaterial).hashCode(); + } + + public static String getMaterialsID(Material aMaterial) { + for (String aKey : sMaterialMap.keySet()) { + if (sMaterialMap.get(aKey).equals(aMaterial)) { + return aKey; + } + } + return "BAD_MATERIAL_ID"; + } + + public static Material getMaterialOfMilledProduct(ItemStack aMilled) { + for (String aKey : sMilledMap.keySet()) { + ItemStack aTempMilledStack = sMilledMap.get(aKey); + if (GT_Utility.areStacksEqual(aTempMilledStack, aMilled, true)) { + return sMaterialMap.get(aKey); + } + } + return null; + } + + public static ItemStack findMilledStack(GT_Recipe aRecipe) { + if (aRecipe == null || aRecipe.mInputs == null || aRecipe.mInputs.length <= 0) { + return null; + } + return findMilledStack(aRecipe.mInputs); + } + + public static ItemStack findMilledStack(ItemStack[] aInputs) { + if (aInputs == null || aInputs.length <= 0) { + return null; + } + for (ItemStack aStack : aInputs) { + if (CustomOrePrefix.milled.get().contains(aStack)) { + return aStack; + } + } + return null; + } + + public static AES getEncoder() { + return sEncodingHandler; + } + +} 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 6201a782de..73a60889c6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -1,44 +1,26 @@ package gtPlusPlus.xmod.gregtech.common.render; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigInteger; +import java.io.*; import java.net.URL; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Base64; import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.List; import java.util.UUID; -import javax.crypto.Cipher; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import javax.xml.bind.DatatypeConverter; - import org.apache.commons.io.IOUtils; import org.lwjgl.opengl.GL11; import com.mojang.authlib.GameProfile; -import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_Log; 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.lib.CORE.ConfigSwitches; import gtPlusPlus.core.proxy.ClientProxy; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.AES; import gtPlusPlus.core.util.data.FileUtils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.sys.NetworkUtils; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelBiped; @@ -49,29 +31,28 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.common.UsernameCache; public class GTPP_CapeRenderer extends RenderPlayer { - private final ResourceLocation[] mCapes = { + private static final ResourceLocation[] mCapes = { new ResourceLocation("miscutils:textures/OrangeHD.png"), new ResourceLocation("miscutils:textures/FancyCapeHD.png"), new ResourceLocation("miscutils:textures/TesterCapeHD.png"), + new ResourceLocation("miscutils:textures/PatreonCapeHD.png"), new ResourceLocation("miscutils:textures/DevCapeHD.png"), - new ResourceLocation("miscutils:textures/PatreonCapeHD.png") }; + }; - private final ArrayList<String> mData; + private final boolean mInit; public GTPP_CapeRenderer() { - downloadCapeList(); - ArrayList<String> aTemp = new ArrayList<String>(); - try { - aTemp = returnDatData(); + mInit = init(); + } + + private final boolean init() { + if (mInit) { + return false; } - catch (Throwable t) { - aTemp = new ArrayList<String>(); - } - mData = aTemp; + return CapeUtils.init(); } private static boolean hasResourceChecked = false; @@ -80,107 +61,127 @@ public class GTPP_CapeRenderer extends RenderPlayer { private ResourceLocation tResource = null; public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { + + // Check we have set Render Manager if (this.renderManager == null) { hasSetRenderer = false; } + + // Set Render Manager if (!hasSetRenderer) { if (RenderManager.instance != null) { setRenderManager(RenderManager.instance); + hasSetRenderer = true; } - } - AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; - if (!ConfigSwitches.enableCustomCapes) { - aEvent.setCanceled(true); - Logger.WARNING("A1"); - return; - } - - if (hasResourceChecked) { - if (!hasCape && !CORE.DEVENV) { - aEvent.setCanceled(true); - Logger.WARNING("A2"); + } + + // Actually Render + if (hasSetRenderer) { + + // We have capes turned off, so let's not render. + if (!ConfigSwitches.enableCustomCapes) { return; } - } - // Make sure we don't keep checking on clients who dont have capes. - if (!hasResourceChecked) { - - // Time to Spliterate some data - Map<String, ResourceLocation> aPlayerData = new HashMap<String, ResourceLocation>(); - Map<String, String> aNameMap = new HashMap<String, String>(); - int i = 0; - if (!CORE.DEVENV) { - for (String s : mData) { - String[] aSplit = s.split("@"); - int a[] = new int[] { 0, mCapes.length - 1 }; - int aID = Integer.parseInt(aSplit[1]); - // Quick Check to prevent lag - Logger.WARNING("Trying to create UUID from - " + aSplit[0]); - UUID aPlayerID = UUID.fromString(aSplit[0]); - Logger.WARNING("Result: " + aPlayerID.toString()); - if (aPlayerID != null) { - if (UsernameCache.containsUUID(aPlayerID)) { - Logger.WARNING("UsernameCache contains a last known username for current players UUID."); - if (!UsernameCache.getLastKnownUsername(aPlayerID).toLowerCase() - .equals(ClientProxy.playerName)) { - Logger.WARNING("Last known name does not match current name. Checking next UUID."); - continue; - } else { - Logger.WARNING("Last known name does match current name."); - } - } else { - Logger.WARNING("UsernameCache did not hold results for current player, oops."); - continue; - } - } - String aPlayerName = this.getPlayerName("iteration-" + (i++), aSplit[0]); - aNameMap.put(aSplit[0], aPlayerName); - aPlayerData.put(aPlayerName, this.mCapes[Math.max(a[0], Math.min(aID, a[1]))]); + // We have already checked if this player has a cape, but since they do not, we best not render. + if (hasResourceChecked) { + if (!hasCape && !CORE.DEVENV) { + return; } } - // Set flag to only render this event if player has a cape. - for (String s : aNameMap.values()) { - if (s.toLowerCase().equals(ClientProxy.playerName)) { + // Allocate client player object + AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; + + // Make sure we don't keep checking on clients who dont have capes. + if (!hasResourceChecked) { + + // Get players UUID + String aPlayerUUID = aPlayer != null ? aPlayer.getGameProfile().getId().toString() : "BAD"; + + // If for whatever reason this fails, we just exit early. + if (aPlayerUUID.equals("BAD")) { + return; + } + + // Automatically allocate a Dev cape while in Dev mode. + if (tResource == null && CORE.DEVENV) { + tResource = mCapes[4]; hasCape = true; - tResource = aPlayerData.get(ClientProxy.playerName); - break; } - } - // Dev capes for dev mode. - if (CORE.DEVENV) { - hasCape = true; - tResource = mCapes[3]; - } + String aPlayerName = ClientProxy.playerName; - // Safety Check - if (tResource == null) { - if (aPlayerData.get(aPlayer.getDisplayName()) != null) { - tResource = aPlayerData.get(aPlayer.getDisplayName()); - } else { - hasCape = false; + // Check cape lists for the cape this player owns. + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mOrangeCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[0]; + hasCape = true; + break; + } + } } + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mMiscCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[1]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mBetaTestCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[2]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mPatreonCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[3]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mDevCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[4]; + hasCape = true; + break; + } + } + } + hasResourceChecked = true; } - // Only run once. - hasResourceChecked = true; + if (hasResourceChecked) { + // We have met all the conditions, let's render that cape. + renderCapeOnPlayer(aEvent, aPlayer); + } } - if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() - || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { - aEvent.setCanceled(true); - Logger.WARNING("A3"); - return; - } + } + private final boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) { float aPartialTicks = aEvent.partialRenderTick; try { - if (tResource == null && CORE.DEVENV) { tResource = mCapes[3]; } + + // If player is invisible, don't render. + if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() + || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { + aEvent.setCanceled(true); + return false; + } if ((tResource != null) && (!aPlayer.getHideCape())) { bindTexture(tResource); @@ -221,14 +222,22 @@ public class GTPP_CapeRenderer extends RenderPlayer { GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); ((ModelBiped) this.mainModel).renderCloak(0.0625F); GL11.glPopMatrix(); + return true; } } catch (Throwable e) { - if (GT_Values.D1) { - e.printStackTrace(GT_Log.err); - } + } + return false; } + @SuppressWarnings("unused") + @Deprecated + /** + * Should be able to get the username from a UUID + * @param name - Players Name + * @param uuid - Players known UUID + * @return - The newest Player name + */ private String getPlayerName(String name, String uuid) { try { Logger.WORLD("[Capes++] Trying to UUID check " + name + "."); @@ -271,29 +280,242 @@ public class GTPP_CapeRenderer extends RenderPlayer { return name; } - private void downloadCapeList() { - if (!NetworkUtils.checkNetworkIsAvailableWithValidInterface()) { - return; - } - try { - File dat = new File(Utils.getMcDir(), "GTPP.dat"); - if (FileUtils.doesFileExist(dat)) { + + + private static class CapeUtils { + + private static char SPLIT_CHARACTER = '§'; + private static AES sAES; + + // UUID - Username + private static final AutoMap<Pair<String, String>> mOrangeCapes = new AutoMap<Pair<String, String>>(); + private static final AutoMap<Pair<String, String>> mMiscCapes = new AutoMap<Pair<String, String>>(); + private static final AutoMap<Pair<String, String>> mBetaTestCapes = new AutoMap<Pair<String, String>>(); + private static final AutoMap<Pair<String, String>> mPatreonCapes = new AutoMap<Pair<String, String>>(); + private static final AutoMap<Pair<String, String>> mDevCapes = new AutoMap<Pair<String, String>>(); + + private static final boolean init() { + CapeUtils.handleOldCapeCache(); + if (CORE.DEVENV) { + return true; + } + try { + if (shouldDownloadCapeList()) { + downloadCapeList(); + } + } + catch (Exception e) { + return false; + } + writeCacheToMaps(); + return true; + } + + + private static boolean shouldDownloadCapeList() { + if (!doesCapeCacheExistLocally()) { + return true; + } + if (isCapeCacheWeekOld()) { + return true; + } + return false; + } + + private static final boolean isCapeCacheWeekOld() { + if (!doesCapeCacheExistLocally()) { + return true; + } + else { + File dat = CapeUtils.getCapeCache(); Date dateLastMod = new Date(dat.lastModified()); Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000)); - if (!dateLastMod.before(dateNow)) { - return; + if (dateLastMod.before(dateNow)) { + return true; } } - InputStream inputStream = new URL("https://alkcorp.overminddl1.com/GTPP.dat").openStream(); - FileOutputStream fileOS = new FileOutputStream(dat); - IOUtils.copy(inputStream, fileOS); + return false; + } - } catch (Throwable t) { - Logger.INFO("Unable to download GT++ cape list."); + private static final void downloadCapeList() { + if (!NetworkUtils.checkNetworkIsAvailableWithValidInterface()) { + return; + } + try { + File dat = getCapeCache(); + File temp = allocateTempFile(); + InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream(); + FileOutputStream fileOS = new FileOutputStream(temp); + IOUtils.copy(inputStream, fileOS); + if (isDownloadedCapeListBigger(temp)) { + fileOS = new FileOutputStream(dat); + IOUtils.copy(inputStream, fileOS); + } + } catch (Throwable t) { + Logger.INFO("Unable to download GT++ cape list."); + } + } + + private static final boolean isDownloadedCapeListBigger(File aFile) { + double aExistingFileSize = (doesCapeCacheExistLocally() ? getCapeCache().length() : 0); + double aNewFileSize = aFile.length(); + if (aNewFileSize > aExistingFileSize) { + return true; + } + return false; + } + + private static void handleOldCapeCache() { + File aCacheFile = FileUtils.getFile("GTPP", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + aCacheFile.delete(); + } + } + + private static final boolean doesCapeCacheExistLocally() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + return true; + } + return false; + } + + private static final File getCapeCache() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + FileUtils.createFile(aCacheFile); + } + return aCacheFile; + } + + public static final List<String> getDataFromCache(){ + File aCacheFile = getCapeCache(); + List<String> aCache = FileUtils.readLines(aCacheFile); + if (aCache != null && !aCache.isEmpty()) { + return aCache; + } + return new AutoMap<String>(); + } + + private static final File allocateTempFile() { + File tempFile = null; + try { + tempFile = File.createTempFile("gtpp-", null); + } + catch (IOException e) { + e.printStackTrace(); + } + if (tempFile == null) { + tempFile = FileUtils.createFile("", "gtpp-"+MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE/2)), "tmp"); + } + tempFile.deleteOnExit(); + return tempFile; + } + + + public static final void writeCacheToMaps() { + List<String> aCacheData = getDataFromCache(); + if (aCacheData != null && !aCacheData.isEmpty()) { + if (sAES == null) { + sAES = new AES(); + } + AutoMap<String> aDecodedData = new AutoMap<String>(); + for (String aToDecode : aCacheData) { + aDecodedData.put(sAES.decode(aToDecode)); + } + if (!aDecodedData.isEmpty()) { + AutoMap<Pair<String, String>> aCapeType1 = new AutoMap<Pair<String, String>>(); + AutoMap<Pair<String, String>> aCapeType2 = new AutoMap<Pair<String, String>>(); + AutoMap<Pair<String, String>> aCapeType3 = new AutoMap<Pair<String, String>>(); + AutoMap<Pair<String, String>> aCapeType4 = new AutoMap<Pair<String, String>>(); + AutoMap<Pair<String, String>> aCapeType5 = new AutoMap<Pair<String, String>>(); + boolean didProcessStringData = false; + Logger.INFO("Decoded String Count: "+aDecodedData.size()); + for (String aToSplit : aDecodedData) { + String[] aSplitData = aToSplit.split(""+SPLIT_CHARACTER); + if (aSplitData != null && aSplitData.length >= 2) { + if (aSplitData[0] != null) { + Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]); + if (aCapeTypeID2 != null) { + int aCapeTypeID = aCapeTypeID2; + Pair<String, String> aFinalString = new Pair<String, String>("UUID: "+aSplitData[1], "Username: "+(aSplitData[2] != null && aSplitData[0].length() > 0 ? aSplitData[2] : "Not Specified")); + Logger.INFO("Cape Type: "+aCapeTypeID); + switch (aCapeTypeID) { + case 0: + aCapeType1.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType1.size()+" users."); + break; + case 1: + aCapeType2.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType2.size()+" users."); + break; + case 2: + aCapeType3.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType3.size()+" users."); + break; + case 3: + aCapeType4.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType4.size()+" users."); + break; + case 4: + aCapeType5.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType5.size()+" users."); + break; + default: + break; + } + } + } + } + } + if (!aCapeType1.isEmpty() || !aCapeType2.isEmpty() || !aCapeType3.isEmpty() || !aCapeType4.isEmpty() || !aCapeType5.isEmpty()) { + didProcessStringData = true; + } + else { + // did not process any data + } + if (didProcessStringData) { + if (!aCapeType1.isEmpty()) { + for (Pair<String, String> aUser : aCapeType1) { + Logger.INFO("Adding Generic cape for "+aUser.getKey()); + mOrangeCapes.add(aUser); + } + } + if (!aCapeType2.isEmpty()) { + for (Pair<String, String> aUser : aCapeType2) { + Logger.INFO("Adding Blue cape for "+aUser.getKey()); + mMiscCapes.add(aUser); + } + } + if (!aCapeType3.isEmpty()) { + for (Pair<String, String> aUser : aCapeType3) { + Logger.INFO("Adding Beta cape for "+aUser.getKey()); + mBetaTestCapes.add(aUser); + } + } + if (!aCapeType4.isEmpty()) { + for (Pair<String, String> aUser : aCapeType4) { + Logger.INFO("Adding Patreon cape for "+aUser.getKey()); + mPatreonCapes.add(aUser); + } + } + if (!aCapeType5.isEmpty()) { + for (Pair<String, String> aUser : aCapeType5) { + Logger.INFO("Adding Dev cape for "+aUser.getKey()); + mDevCapes.add(aUser); + } + } + } + } + else { + // No data decoded + } + } + else { + // Nothing was cached? + } } } - - /* TODO: fix this stuff \u002a\u002f\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0044\u0061\u0074\u0044\u0061\u0074\u0061\u0028\u0029\u007b\u000a\u0009\u0009\u0046\u0069\u006c\u0065\u0020\u0064\u0061\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0028\u0055\u0074\u0069\u006c\u0073\u002e\u0067\u0065\u0074\u004d\u0063\u0044\u0069\u0072\u0028\u0029\u002c\u0020\u0022\u0047\u0054\u0050\u0050\u002e\u0064\u0061\u0074\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0048\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u0028\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0020\u0062\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u0064\u0061\u0074\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006c\u0069\u006e\u0065\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0028\u006c\u0069\u006e\u0065\u0020\u003d\u0020\u0062\u0072\u002e\u0072\u0065\u0061\u0064\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0048\u002e\u0061\u0064\u0064\u0028\u006c\u0069\u006e\u0065\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0049\u004f\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u005b\u005d\u0020\u003d\u0020\u0048\u002e\u0067\u0065\u0074\u0028\u0030\u0029\u002e\u0073\u0070\u006c\u0069\u0074\u0028\u0022\u0025\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0020\u003a\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0073\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0020\u0026\u0026\u0020\u0073\u002e\u006c\u0065\u006e\u0067\u0074\u0068\u0028\u0029\u0020\u003e\u0020\u0030\u0020\u0026\u0026\u0020\u0021\u0073\u002e\u0065\u0071\u0075\u0061\u006c\u0073\u0028\u0022\u0020\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0073\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0030\u0030\u0031\u0020\u0030\u0031\u0030\u0031\u0030\u0030\u0031\u0022\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0031\u0030\u0030\u0020\u0030\u0031\u0031\u0030\u0031\u0031\u0031\u0022\u003b\u000a\u0009\u0009\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0068\u0020\u003a\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0029\u0020\u007b\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u003d\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0068\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0029\u003b\u000a\u0009\u0009\u0009\u0061\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0061\u0044\u0061\u0074\u0061\u003b\u0009\u0009\u000a\u0009\u007d\u000a\u0009\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006d\u0064\u0035\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0070\u0075\u0074\u0029\u0020\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u006d\u0064\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u004d\u0044\u0035\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u003d\u0020\u006d\u0064\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0069\u006e\u0070\u0075\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0028\u0031\u002c\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0029\u003b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0066\u006f\u0072\u006d\u0061\u0074\u0028\u0022\u0025\u0030\u0033\u0032\u0078\u0022\u002c\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0029\u003b\u000a\u0009\u007d\u000a\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0069\u006e\u0069\u0074\u0043\u0069\u0070\u0068\u0065\u0072\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0069\u006e\u0074\u0020\u006d\u006f\u0064\u0065\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u000a\u0009\u0009\u0009\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u004b\u0065\u0079\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u000a\u0009\u0009\u0009\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0028\u0074\u006f\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0028\u006d\u0064\u0035\u0028\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u0029\u002c\u0020\u0022\u0041\u0045\u0053\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0028\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0043\u0046\u0042\u0038\u002f\u004e\u006f\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0022\u0029\u003b\u000a\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u006d\u006f\u0064\u0065\u002c\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u002c\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0029\u003b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u003b\u000a\u0009\u007d\u000a\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0074\u006f\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0029\u0020\u007b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0044\u0061\u0074\u0061\u0074\u0079\u0070\u0065\u0043\u006f\u006e\u0076\u0065\u0072\u0074\u0065\u0072\u002e\u0070\u0061\u0072\u0073\u0065\u0048\u0065\u0078\u0042\u0069\u006e\u0061\u0072\u0079\u0028\u0073\u0029\u003b\u000a\u0009\u007d\u000a\u0009\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u0020\u007b\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0069\u006e\u0069\u0074\u0043\u0069\u0070\u0068\u0065\u0072\u0028\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0044\u0045\u0043\u0052\u0059\u0050\u0054\u005f\u004d\u004f\u0044\u0045\u002c\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u002c\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u003b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0020\u003d\u0020\u0042\u0061\u0073\u0065\u0036\u0034\u002e\u0067\u0065\u0074\u0044\u0065\u0063\u006f\u0064\u0065\u0072\u0028\u0029\u002e\u0064\u0065\u0063\u006f\u0064\u0065\u0028\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0029\u003b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0020\u003d\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0064\u006f\u0046\u0069\u006e\u0061\u006c\u0028\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0029\u003b\u000a\u0009\u0009\u0009\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u002c\u0020\u0022\u0055\u0054\u0046\u0038\u0022\u0029\u003b\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u003b\u000a\u0009\u007d\u002f\u002a */ - + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java index 2f00600af6..faaabbd159 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java @@ -183,7 +183,7 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); } else { - if (this.mTier < (CORE.GTNH ? GT_Values.V.length : 9)) { + if (this.mTier < (CORE.GTNH ? GT_Values.V.length-1 : 9)) { this.mTier++; } else { 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 6a154051d5..31c9636cac 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 @@ -1,25 +1,28 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - 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; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaTileEntity_IndustrialCuttingMachine extends GregtechMeta_MultiBlockBase { + + private boolean mCuttingMode = true; + public GregtechMetaTileEntity_IndustrialCuttingMachine(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -35,7 +38,7 @@ extends GregtechMeta_MultiBlockBase { @Override public String getMachineType() { - return "Cutting Machine"; + return "Cutting Machine / Slicing Machine"; } @Override @@ -74,7 +77,7 @@ extends GregtechMeta_MultiBlockBase { @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCutterRecipes; + return mCuttingMode ? GT_Recipe.GT_Recipe_Map.sCutterRecipes : GT_Recipe.GT_Recipe_Map.sSlicerRecipes; } @Override @@ -202,11 +205,22 @@ extends GregtechMeta_MultiBlockBase { return (byte) TAE.GTPP_INDEX(29); } - 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()))); + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mCuttingMode = Utils.invertBoolean(mCuttingMode); + String aMode = mCuttingMode ? "Cutting" : "Slicing"; + PlayerUtils.messagePlayer(aPlayer, "Mode: "+aMode); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mCuttingMode", mCuttingMode); } - private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { - return ((this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()))); + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mCuttingMode = aNBT.getBoolean("mCuttingMode"); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java index d06b7ed0d1..9dca082807 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java @@ -1,8 +1,13 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import org.apache.commons.lang3.ArrayUtils; + import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; @@ -11,15 +16,19 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; 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.api.objects.minecraft.BlockPos; import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_MillingBalls; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; @@ -30,6 +39,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase { @@ -40,7 +50,8 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase private static ITexture frontFace; private static ITexture frontFaceActive; - + + private ArrayList<GT_MetaTileEntity_Hatch_MillingBalls> mMillingBallBuses = new ArrayList<GT_MetaTileEntity_Hatch_MillingBalls>(); private static final DamageSource mIsaMillDamageSource = new DamageSource("gtpp.grinder").setDamageBypassesArmor(); public GregtechMetaTileEntity_IsaMill(int aID, String aName, String aNameRegional) { @@ -85,6 +96,20 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase return getMaxEfficiency(aStack) > 0; } + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MillingBalls) { + log("Found GT_MetaTileEntity_Hatch_MillingBalls"); + return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeDieselEngine.png"); } @@ -96,10 +121,15 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mMillingBallBuses.clear(); + } + } if (aTick % 20 == 0) { checkForEntities(aBaseMetaTileEntity, aTick); } + super.onPostTick(aBaseMetaTileEntity, aTick); } private final AutoMap<BlockPos> mFrontBlockPosCache = new AutoMap<BlockPos>(); @@ -401,4 +431,259 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase public int getEuDiscountForParallelism() { return 0; } + + /* + * Milling Ball Handling + */ + + @Override + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_MillingBalls tHatch : mMillingBallBuses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getContentUsageSlots()); + } + } + return tItems; + } + + + public int getMaxBallDurability(ItemStack aStack) { + return ItemGenericChemBase.getMaxBallDurability(aStack); + } + + private ItemStack findMillingBall(ItemStack[] aItemInputs) { + if (mMillingBallBuses.isEmpty() || mMillingBallBuses.size() > 1) { + return null; + } + else { + GT_MetaTileEntity_Hatch_MillingBalls aBus = mMillingBallBuses.get(0); + if (aBus != null) { + AutoMap<ItemStack> aAvailableItems = aBus.getContentUsageSlots(); + if (!aAvailableItems.isEmpty()) { + for (final ItemStack aInput : aItemInputs) { + if (ItemUtils.isMillingBall(aInput)) { + for (ItemStack aBall : aAvailableItems) { + if (GT_Utility.areStacksEqual(aBall, aInput, true)) { + Logger.INFO("Found a valid milling ball to use."); + return aBall; + } + } + } + } + } + } + } + return null; + } + + + private void damageMillingBall(ItemStack aStack) { + if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * 1))) { + int damage = getMillingBallDamage(aStack) + 1; + log("damage milling ball "+damage); + if (damage >= getMaxBallDurability(aStack)) { + log("consuming milling ball"); + aStack.stackSize -= 1; + } + else { + setDamage(aStack,damage); + } + } + else { + log("not damaging milling ball"); + } + } + + private int getMillingBallDamage(ItemStack aStack) { + return ItemGenericChemBase.getMillingBallDamage(aStack); + } + + private void setDamage(ItemStack aStack,int aAmount) { + ItemGenericChemBase.setMillingBallDamage(aStack, aAmount); + } + + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + // checks if it has a milling ball with enough durability + ItemStack tMillingBallRecipe = findMillingBall(aItemInputs); + if (tMillingBallRecipe == null) { + log("does not have milling ball"); + return false; + } + + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + log("aEUPercent "+aEUPercent); + log("mEUt "+tRecipe.mEUt); + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+1); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tEnergy: "+tEnergy); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < 1 && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List<ItemStack> splitStacks = new ArrayList<ItemStack>(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + + // Damage Milling ball once all is said and done. + if (tMillingBallRecipe != null) { + log("damaging milling ball"); + damageMillingBall(tMillingBallRecipe); + } + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java index aad16d3a56..f6cc06059b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.a import java.lang.reflect.Method; +import gregtech.GT_Mod; import gregtech.api.enums.Dyes; import gregtech.api.enums.GT_Values; import gregtech.api.enums.TAE; @@ -25,6 +26,7 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_FusionComputer { @@ -282,5 +284,96 @@ public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_Fus private boolean isFusionCoil(int aX, int aY, int aZ) { return (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getFusionCoil() && (getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getFusionCoilMeta())); } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (mEfficiency < 0) + mEfficiency = 0; + if (mRunningOnLoad && checkMachine(aBaseMetaTileEntity, mInventory[1])) { + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipe(mInventory[1]); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + mInputHatches.clear(); + mInputBusses.clear(); + mOutputHatches.clear(); + mOutputBusses.clear(); + mDynamoHatches.clear(); + mEnergyHatches.clear(); + mMufflerHatches.clear(); + mMaintenanceHatches.clear(); + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + } + if (mStartUpCheck < 0) { + if (mMachine) { + if (this.mEnergyHatches != null) { + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) { + long aVoltage = GT_Values.V[tHatch.mTier]; + if (aBaseMetaTileEntity.getStoredEU() + (aVoltage) < maxEUStore() + && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aVoltage, false)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(aVoltage, true); + } + } + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + stopMachine(); + } + if (getRepairStatus() > 0) { + if (mMaxProgresstime > 0) { + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputItems != null) + for (ItemStack tStack : mOutputItems) if (tStack != null) addOutput(tStack); + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) if (tStack != null) addOutput(tStack); + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + mOutputItems = null; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) { + try { + GT_Mod.instance.achievements.issueAchivementHatchFluid(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), mOutputFluids[0]); + } catch (Exception e) { + } + } + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) + checkRecipe(mInventory[1]); + } + } else { + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { + turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (checkRecipe(mInventory[1])) { + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + mMaxProgresstime = 0; + turnCasingActive(false); + } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); + } + } + if (mMaxProgresstime <= 0) + mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + this.mLastRecipe = null; + stopMachine(); + } + } else { + turnCasingActive(false); + this.mLastRecipe = null; + stopMachine(); + } + } + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) + | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java new file mode 100644 index 0000000000..1ceb6bd93f --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java @@ -0,0 +1,492 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.GregTech_API; +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase { + + public GregtechMTE_FrothFlotationCell(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_FrothFlotationCell(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_FrothFlotationCell(this.mName); + } + + @Override + public String getMachineType() { + return "Flotation Cell"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Process that milled ore!", + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + + @Override + public boolean isFacingValid(final byte aFacing) { + if (aFacing == 0 || aFacing > 1) { + return false; + } + return true; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + int aID = TAE.getIndexFromPage(2, 1); + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID]}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return Recipe_GT.Gregtech_Recipe_Map.sFlotationCellRecipes; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + Block aCasing1 = ModBlocks.blockCasings3Misc; + int aCasingMeta1 = 1; + Block aCasing2 = ModBlocks.blockSpecialMultiCasings; + int aCasingMeta2 = 9; + int aCasingCount1 = 0; + int aCasingCount2 = 0; + int aControllerY = aBaseMetaTileEntity.getYCoord(); + // Check adjacent blocks + for (byte side = 2; side < 6; side++) { + Block aBlock = aBaseMetaTileEntity.getBlockAtSide(side); + int aMeta = aBaseMetaTileEntity.getMetaIDAtSide(side); + if (this.isValidBlockForStructure(null, 0, false, aBlock, aMeta, aCasing1, aCasingMeta1)) { + aCasingCount1++; + } + else { + log("Bad block at Y:"+(aControllerY)); + return false; + } + } + // Check first layer + aControllerY--; + for (int x = -2; x < 3; x++) { + for (int z = -2; z < 3; z++) { + + int aWorldOffsetX = aBaseMetaTileEntity.getXCoord() + x; + int aWorldOffsetZ = aBaseMetaTileEntity.getZCoord() + z; + + // Don't check air + if ((x == -2 && z != 0) || (x == 2 && z != 0) || (z == -2 && x != 0) || (z == 2 && x != 0) || (x == 0 && z == 0)) { + continue; + } + else { + Block aBlock = aBaseMetaTileEntity.getBlock(aWorldOffsetX, aControllerY, aWorldOffsetZ); + int aMeta = aBaseMetaTileEntity.getMetaID(aWorldOffsetX, aControllerY, aWorldOffsetZ); + if (this.isValidBlockForStructure(null, 0, false, aBlock, aMeta, aCasing2, aCasingMeta2)) { + aCasingCount2++; + } + else { + log("Bad block at Y:"+(aControllerY)+", X:"+aWorldOffsetX+", Z:"+aWorldOffsetZ); + aBaseMetaTileEntity.getWorld().setBlock(aWorldOffsetX, aControllerY, aWorldOffsetZ, Blocks.bookshelf); + return false; + } + } + } + } + // Check circular tower + aControllerY--; + for (int y = aControllerY; y > (aControllerY-5); y--) { + for (int x = -2; x < 3; x++) { + for (int z = -2; z < 3; z++) { + + int aWorldOffsetX = aBaseMetaTileEntity.getXCoord() + x; + int aWorldOffsetZ = aBaseMetaTileEntity.getZCoord() + z; + + // Don't check air + if ((x == -2 && z != 0) || (x == 2 && z != 0) || (z == -2 && x != 0) || (z == 2 && x != 0) || (x == 0 && z == 0)) { + continue; + } + // Don't check air + else if ((x == -1 && z == 0) || (x == 1 && z == 0) || (z == -1 && x == 0) || (z == 1 && x == 0) || (x == 0 && z == 0)) { + continue; + } + else { + Block aBlock = aBaseMetaTileEntity.getBlock(aWorldOffsetX, y, aWorldOffsetZ); + int aMeta = aBaseMetaTileEntity.getMetaID(aWorldOffsetX, y, aWorldOffsetZ); + if (this.isValidBlockForStructure(null, 0, false, aBlock, aMeta, aCasing2, aCasingMeta2)) { + aCasingCount2++; + } + else { + log("Bad block at Y:"+(y)+", X:"+aWorldOffsetX+", Z:"+aWorldOffsetZ); + return false; + } + } + } + } + } + // Check Base + aControllerY -= 5; + for (int y = aControllerY; y > (aControllerY-2); y--) { + for (int x = -3; x < 4; x++) { + for (int z = -3; z < 4; z++) { + int aWorldOffsetX = aBaseMetaTileEntity.getXCoord() + x; + int aWorldOffsetZ = aBaseMetaTileEntity.getZCoord() + z; + if ((x == -3 && z == -3) || (x == 3 && z == 3) || (x == -3 && z == 3) || (x == 3 && z == -3)) { + continue; + } + else if ((x == -3 && z == -2) || (x == -2 && z == -3) || (x == 3 && z == 2) || (x == 2 && z == 3)) { + continue; + } + else if ((x == -2 && z == 3) || (x == -3 && z == 2) || (x == 3 && z == -2) || (x == 2 && z == -3)) { + continue; + } + else { + Block aBlock = aBaseMetaTileEntity.getBlock(aWorldOffsetX, y, aWorldOffsetZ); + int aMeta = aBaseMetaTileEntity.getMetaID(aWorldOffsetX, y, aWorldOffsetZ); + IGregTechTileEntity aTile = aBaseMetaTileEntity.getIGregTechTileEntity(aWorldOffsetX, y, aWorldOffsetZ); + if (this.isValidBlockForStructure(aTile, TAE.getIndexFromPage(2, 1), true, aBlock, aMeta, aCasing1, aCasingMeta1)) { + if (aTile == null) { + aCasingCount1++; + } + } + else { + log("Bad block at Y:"+(y)+", X:"+aWorldOffsetX+", Z:"+aWorldOffsetZ); + return false; + } + } + } + } + } + if (aCasingCount1 < 68) { + log("Inconel Casings found: "+aCasingCount1); + log("Inconel Casings required: 68"); + return false; + } + if (aCasingCount2 < 52) { + log("Flotation Casings found: "+aCasingCount2); + log("Flotation Casings required: 52"); + return false; + } + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + // Fix GT bug + if (this.getBaseMetaTileEntity().getFrontFacing() == 0 && this.getBaseMetaTileEntity().getBackFacing() == 1) { + log("Fixing Bad Facing. (GT Bug)"); + this.getBaseMetaTileEntity().setFrontFacing((byte) 1); + } + } + + @Override + public boolean checkRecipe(ItemStack arg0) { + return super.checkRecipeGeneric(); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + /* + * + * Material Hash checks + * Makes sure we can only ever use one type of material in this flotation cell. + * + */ + int aExpectedMaterialHash; + // Set the hash of expected material type + if (mLockedOreType == -1) { + mLockedOreType = FlotationRecipeHandler.getHashForMaterial(FlotationRecipeHandler.getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(aRecipe))); + } + // Set the hash for this recipe check + aExpectedMaterialHash = mLockedOreType; + + // Compute hash of current inputs + int aFoundMaterialHash = FlotationRecipeHandler.getHashForMaterial(FlotationRecipeHandler.getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(aItemInputs))); + + // Check hashes match + if (aExpectedMaterialHash != aFoundMaterialHash) { + log("Did not find the correct milled type."); + log("Found: "+aFoundMaterialHash); + log("Expected: "+mLockedOreType); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+aMaxParallelRecipes); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List<ItemStack> splitStacks = new ArrayList<ItemStack>(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + /* + * Handle NBT + */ + + private int mLockedOreType = -1; + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (mLockedOreType != -1) { + aNBT.setInteger("mLockedOreType", mLockedOreType); + } + super.setItemNBT(aNBT); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (mLockedOreType != -1) { + aNBT.setInteger("mLockedOreType", mLockedOreType); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mLockedOreType = aNBT.getInteger("mLockedOreType"); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 81d1581724..9064921c6a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -21,11 +21,13 @@ 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.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -42,6 +44,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { private int mPipeCasingTier = 0; private int mCoilTier = 0; + private ArrayList<GT_MetaTileEntity_Hatch_Catalysts> mCatalystBuses = new ArrayList<GT_MetaTileEntity_Hatch_Catalysts>(); + public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -664,6 +668,19 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return 0; } + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts) { + log("Found GT_MetaTileEntity_Hatch_Catalysts"); + return addToMachineListInternal(mCatalystBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + public int getMachineCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { Block aInitStructureCheck; int aInitStructureCheckMeta; @@ -734,11 +751,16 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mCatalystBuses.clear(); + } + } // Silly Client Syncing if (aBaseMetaTileEntity.isClientSide()) { this.mSolidCasingTier = getCasingTierOnClientSide(); } + super.onPostTick(aBaseMetaTileEntity, aTick); } @Override @@ -771,6 +793,13 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { long tEnergy = getMaxInputEnergy(); log("Running checkRecipeGeneric(0)"); + // checks if it has a catalyst with enough durability + ItemStack tCatalystRecipe = findCatalyst(aItemInputs); + if (tCatalystRecipe == null) { + log("does not have catalyst"); + return false; + } + GT_Recipe tRecipe = findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); @@ -801,11 +830,10 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { // checks if it has enough catalyst durabilety ArrayList<ItemStack>tCatalysts = null; int tMaxParrallelCatalyst = aMaxParallelRecipes; - ItemStack tCatalystRecipe = findCatalyst(tRecipe.mInputs); if (tCatalystRecipe != null) { - log("has catalyst"); tCatalysts = new ArrayList<ItemStack>(); - tMaxParrallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes,tCatalysts); + tMaxParrallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes, tCatalysts); + log("Can process "+tMaxParrallelCatalyst+" recipes. If less than "+aMaxParallelRecipes+", catalyst does not have enough durability."); } if (tMaxParrallelCatalyst == 0) { @@ -842,20 +870,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return false; } - if (tCatalysts != null) { - log("damaging catalyst"); - for (int j = 0;j<parallelRecipes;j++) { - log("j = "+j); - for (int i = 0;i<tCatalysts.size();i++) { - log("i = "+i); - if (tCatalysts.get(i) != null && tCatalysts.get(i).stackSize != 0) { - damageCatalyst(tCatalysts.get(i)); - break; - } - } - } - } - // -- Try not to fail after this point - inputs have already been consumed! -- @@ -942,6 +956,12 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + // Damage catalyst once all is said and done. + if (tCatalystRecipe != null) { + log("damaging catalyst"); + damageCatalyst(tCatalystRecipe, parallelRecipes); + } + // Commit outputs this.mOutputItems = tOutputItems; this.mOutputFluids = tOutputFluids; @@ -954,23 +974,12 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return true; } - private int getCatalysts(ItemStack[] aItemInputs,ItemStack aRecipeCatalyst,int aMaxParrallel,ArrayList<ItemStack> aOutPut) { + private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParrallel, ArrayList<ItemStack> aOutPut) { int allowedParrallel = 0; for (final ItemStack aInput : aItemInputs) { - if (aRecipeCatalyst.isItemEqual(aInput)) { - if (aInput.stackSize == 1) { - int damage = getDamage(aInput) + aMaxParrallel; - if (damage > getMaxCatalystDurability() ) { - aOutPut.add(aInput); - allowedParrallel += aMaxParrallel + (getMaxCatalystDurability() - damage); - if (allowedParrallel >aMaxParrallel ) { - return aMaxParrallel; - } - continue; - } - } - aOutPut.add(aInput); - return aMaxParrallel; + if (aRecipeCatalyst.isItemEqual(aInput)) { + int aDurabilityRemaining = getMaxCatalystDurability() - getDamage(aInput); + return Math.min(aMaxParrallel, aDurabilityRemaining); } } return allowedParrallel; @@ -990,42 +999,36 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } - private void damageCatalyst(ItemStack aStack) { - if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { - int damage = getDamage(aStack) + 1; - log("damage catalyst "+damage); - if (damage >= getMaxCatalystDurability()) { - log("consume catalyst"); - ItemStack emptyCatalyst = CI.getEmptyCatalyst(1); - addOutput(emptyCatalyst); - setDamage(aStack,0); - aStack.stackSize -= 1; + private void damageCatalyst(ItemStack aStack, int parallelRecipes) { + for (int i=0; i<parallelRecipes; i++){ + if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { + int damage = getDamage(aStack) + 1; + log("damage catalyst "+damage); + if (damage >= getMaxCatalystDurability()) { + log("consume catalyst"); + addOutput(CI.getEmptyCatalyst(1)); + aStack = null; + } + else { + log("damaging catalyst"); + setDamage(aStack, damage); + } } else { - setDamage(aStack,damage); + log("not consuming catalyst"); } - } - else { - log("not consuming catalyst"); } + + + } private int getDamage(ItemStack aStack) { - if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setInteger("Damage", 0); - tagMain.setTag("catalyst", tagNBT); - aStack.setTagCompound(tagMain); - } - NBTTagCompound aNBT = aStack.getTagCompound(); - return aNBT.getCompoundTag("catalyst").getInteger("Damage"); + return ItemGenericChemBase.getCatalystDamage(aStack); } private void setDamage(ItemStack aStack,int aAmount) { - NBTTagCompound aNBT = aStack.getTagCompound(); - aNBT = aNBT.getCompoundTag("catalyst"); - aNBT.setInteger("Damage", aAmount); + ItemGenericChemBase.setCatalystDamage(aStack, aAmount); } @@ -1081,6 +1084,23 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { + /* + * Catalyst Handling + */ + + + + @Override + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_Catalysts tHatch : mCatalystBuses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getContentUsageSlots()); + } + } + return tItems; + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java index d4a25e03dd..da93fe212c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java @@ -46,9 +46,8 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base { } private void generateRecipes(final Material material, final boolean disableOptional){ - final int tVoltageMultiplier = material.vVoltageMultiplier; - Logger.WARNING("Generating Shaped Crafting recipes for "+material.getLocalizedName()); //TODO + Logger.WARNING("Generating Shaped Crafting recipes for "+material.getLocalizedName()); final ItemStack normalDust = material.getDust(1); final ItemStack smallDust = material.getSmallDust(1); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java new file mode 100644 index 0000000000..321cab4628 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.loaders.misc; + +import java.lang.reflect.Method; + +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class AddCustomMachineToPA { + + private static final boolean sDoesPatchExist; + private static final Class sManagerPA; + private static final Method sRegisterRecipeMapForMeta; + + static { + sDoesPatchExist = ReflectionUtils.doesClassExist("gregtech.api.util.GT_ProcessingArray_Manager"); + if (sDoesPatchExist) { + sManagerPA = ReflectionUtils.getClass("gregtech.api.util.GT_ProcessingArray_Manager"); + sRegisterRecipeMapForMeta = ReflectionUtils.getMethod(sManagerPA, "registerRecipeMapForMeta", int.class, GT_Recipe_Map.class); + } + else { + sManagerPA = null; + sRegisterRecipeMapForMeta = null; + } + } + + public static final void registerRecipeMapForID(int aID, GT_Recipe_Map aMap) { + if (sDoesPatchExist) { + ReflectionUtils.invokeNonBool(null, sRegisterRecipeMapForMeta, new Object[] {aID, aMap}); + } + + } + + public static final void registerRecipeMapBetweenRangeOfIDs(int aMin, int aMax, GT_Recipe_Map aMap) { + if (sDoesPatchExist) { + for (int i=aMin; i<=aMax;i++) { + ReflectionUtils.invokeNonBool(null, sRegisterRecipeMapForMeta, new Object[] {i, aMap}); + //GT_ProcessingArray_Manager.registerRecipeMapForMeta(i, aMap); + } + } + } + + public static void register() { + + // Simple Washers + registerRecipeMapForID(767, Recipe_GT.Gregtech_Recipe_Map.sSimpleWasherRecipes); + registerRecipeMapBetweenRangeOfIDs(31017, 31020, Recipe_GT.Gregtech_Recipe_Map.sSimpleWasherRecipes); + + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index cc3130af98..6b5d8d6802 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -11,14 +11,8 @@ import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.interfaces.internal.IGT_RecipeAdder; -import gregtech.api.util.CustomRecipeMap; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; +import gregtech.api.util.*; 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.SemiFluidFuelHandler; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; @@ -33,6 +27,7 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; import gtPlusPlus.xmod.gregtech.recipes.machines.RECIPEHANDLER_MatterFabricator; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -40,1118 +35,1138 @@ import net.minecraftforge.oredict.OreDictionary; public class GregtechRecipeAdder implements IGregtech_RecipeAdder { - @Override - public boolean addCokeOvenRecipe(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, - final FluidStack aFluidOutput, final ItemStack aOutput, int aDuration, final int aEUt) { - try { - try { - // RECIPEHANDLER_CokeOven.debug1(); - if (((aInput1 == null) /* && (aFluidInput == null) */) - || ((aOutput == null) || (aFluidOutput == null))) { - // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" - // aInput2:"+aInput2.toString()+" - // aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Something was null, returning false"); - return false; - } - - } - catch (final NullPointerException e) { - e.getStackTrace(); - } - try { - // RECIPEHANDLER_CokeOven.debug2(aInput1, aInput2, aFluidInput, - // aFluidOutput, aOutput, aDuration, aEUt); - if ((aOutput != null) - && ((aDuration = GregTech_API.sRecipeFile.get("cokeoven", aOutput, aDuration)) <= 0)) { - // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" - // aInput2:"+aInput2.toString()+" - // aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Something was null, returning false"); - return false; - } - - } - catch (final NullPointerException e) { - e.getStackTrace(); - } - try { - // RECIPEHANDLER_CokeOven.debug3(aInput1, aInput2, aFluidInput, - // aFluidOutput, aOutput, aDuration, aEUt); - if ((aFluidOutput == null) || ((aDuration = GregTech_API.sRecipeFile.get("cokeoven", - aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { - // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" - // aInput2:"+aInput2.toString()+" - // aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Something was null, returning false"); - return false; - } - - } - catch (final NullPointerException e) { - e.getStackTrace(); - } - try { - // RECIPEHANDLER_CokeOven.debug4(aInput1, aInput2, aFluidInput, - // aFluidOutput, aOutput, aDuration, aEUt); - if (aFluidInput == null && aInput2 != null) { - Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, - new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, - aEUt, 0); - } - else if (aFluidInput == null && aInput2 == null) { - Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1 }, - new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, - aEUt, 0); - } - else { - Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, - new ItemStack[] { aOutput }, null, null, new FluidStack[] { aFluidInput }, - new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - } - // RECIPEHANDLER_CokeOven.debug5(aInput1, aInput2, aFluidInput, - // aFluidOutput, aOutput, aDuration, aEUt); - - return true; - - } - catch (final NullPointerException e) { - Logger.WARNING("Something was null, returning false"); - return false; - } - } - catch (final Throwable e) { - // Logger.WARNING("aInput1:"+aInput1.toString()+" - // aInput2:"+aInput2.toString()+" - // aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Failed."); - e.getStackTrace(); - return false; - } - } - - @Override - public boolean addMatterFabricatorRecipe(final FluidStack aFluidInput, final FluidStack aFluidOutput, - final int aDuration, final int aEUt) { - try { - try { - // RECIPEHANDLER_MatterFabricator.debug1(); - if (aFluidOutput == null) { - // Utils.LOG_WARNING("aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aDuration:"+aDuration+" aEU/t:"+aEUt); - Logger.WARNING("Something was null, returning false"); - return false; - } - - } - catch (final NullPointerException e) { - e.getStackTrace(); - } - try { - - // RECIPEHANDLER_MatterFabricator.debug4(aFluidInput, - // aFluidOutput, aDuration, aEUt); - if (aFluidInput == null) { - // Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, - // null, new FluidStack[]{aFluidOutput}, aDuration, aEUt, - // 0); - Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, null, null, null, null, - new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - } - else { - // Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, - // new FluidStack[]{aFluidInput}, new - // FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); - Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, null, null, null, - new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - } - RECIPEHANDLER_MatterFabricator.debug5(aFluidInput, aFluidOutput, aDuration, aEUt); - - return true; - - } - catch (final NullPointerException e) { - return false; - } - } - catch (final Throwable e) { - // Utils.LOG_WARNING("aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Failed."); - e.getStackTrace(); - return false; - } - } - - @Override - public boolean addMatterFabricatorRecipe(final ItemStack aInputStack, final FluidStack aFluidInput, - final FluidStack aFluidOutput, final int aDuration, final int aEUt) { - try { - try { - if ((aFluidOutput == null) || (aInputStack == null)) { - return false; - } - } - catch (final NullPointerException e) { - } - try { - if (aFluidInput == null) { - Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, new ItemStack[] { aInputStack }, - null, null, null, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - } - else { - Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, new ItemStack[] { aInputStack }, - null, null, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, - aEUt, 0); - } - RECIPEHANDLER_MatterFabricator.debug5(aFluidInput, aFluidOutput, aDuration, aEUt); - return true; - } - catch (final NullPointerException e) { - return false; - } - } - catch (final Throwable e) { - return false; - } - } - - @Override - public boolean addFuel(final ItemStack aInput1, final ItemStack aOutput1, final int aEU, final int aType) { - if (aInput1 == null) { - Logger.WARNING("Fuel Input is Invalid."); - return false; - } - // new GregtechRecipe(aInput1, aOutput1, - // GregTech_API.sRecipeFile.get("fuel_" + aType, aInput1, aEU), aType); - return true; - } - - /* - * @Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack - * aItemB, FluidStack aFluid, ItemStack[] aOutputItems, FluidStack - * aOutputFluid, int aDuration, int aEUt) { if ((aItemA == null) || (aItemB - * == null) || (aOutputItems == null)) { return false; } for (ItemStack - * tStack : aOutputItems) { if (tStack != null) { if ((aDuration = - * GregTech_API.sRecipeFile.get("dehydrator", aItemA, aDuration)) <= 0) { - * return false; } - * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, - * new ItemStack[]{aItemA, aItemB}, aOutputItems, null, null, null, - * aDuration, aEUt, 0); RECIPEHANDLER_Dehydrator.debug5(aItemA, aItemB, - * aFluid, aOutputFluid, aOutputItems, aDuration, aEUt); return true; } } - * return false; } - * @Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack - * aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt) { if ((aItemA - * == null) || (aItemB == null) || (aOutputItems == null)) { return false; } - * if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aItemA, - * aDuration)) <= 0) { return false; } - * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, - * new ItemStack[]{aItemA, aItemB}, aOutputItems, null, null, null, - * aDuration, aEUt, 0); RECIPEHANDLER_Dehydrator.debug5(aItemA, aItemB, - * null, null, aOutputItems, aDuration, aEUt); return true; } - * @Override public boolean addDehydratorRecipe(FluidStack aFluid, - * FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int - * aEUt){ if ((aFluid == null) || (aOutputFluid == null || aOutputItems == - * null)) { return false; } if ((aDuration = - * GregTech_API.sRecipeFile.get("dehydrator", aFluid.getUnlocalizedName(), - * aDuration)) <= 0) { return false; } - * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, - * null, aOutputItems, null, new FluidStack[]{aFluid}, new - * FluidStack[]{aOutputFluid}, aDuration, aEUt, 0); - * RECIPEHANDLER_Dehydrator.debug5(null, null, aFluid, aOutputFluid, - * aOutputItems, aDuration, aEUt); return true; } - */ - - @Override - public boolean addDehydratorRecipe(final ItemStack aInput, final FluidStack aFluid, final ItemStack[] aOutput, - int aDuration, final int aEUt) { - Logger.WARNING("Trying to add a Dehydrator recipe."); - try { - if ((aInput == null) || (aFluid == null) || (aOutput == null)) { - return false; - } - if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aInput, aDuration)) <= 0) { - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, new ItemStack[] { aInput }, - aOutput, null, new FluidStack[] { aFluid }, null, aDuration, aEUt, 0); - // RECIPEHANDLER_Dehydrator.debug5(aInput, null, aFluid, null, - // aOutput, aDuration, aEUt); - return true; - } - catch (final NullPointerException e) { - Logger.WARNING("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); - return false; - } - } - - @Override - public boolean addDehydratorRecipe(final ItemStack[] aInput, final FluidStack aFluidInput, - final FluidStack aFluidOutput, final ItemStack[] aOutputItems, final int[] aChances, int aDuration, - final int aEUt) throws IndexOutOfBoundsException { - Logger.WARNING("Trying to add a Dehydrator recipe."); - try { - if (aInput[0] != null) { - Logger.WARNING("Recipe requires input: " + aInput[0].getDisplayName() + " x" + aInput[0].stackSize); - } - if (aInput.length > 1) { - if (aInput[1] != null) { - Logger.WARNING("Recipe requires input: " + aInput[1].getDisplayName() + " x" + aInput[1].stackSize); - } - } - if (aFluidInput != null) { - Logger.WARNING("Recipe requires input: " + aFluidInput.getFluid().getName() + " " + aFluidInput.amount - + "mbst"); - } - if (((aInput[0] == null) && (aFluidInput == null)) || ((aOutputItems == null) && (aFluidOutput == null))) { - return false; - } - if ((aOutputItems != null) - && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aOutputItems[0], aDuration)) <= 0)) { - return false; - } - if (aOutputItems != null) { - Logger.WARNING("Recipe will output: " + ItemUtils.getArrayStackNames(aOutputItems)); - } - if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", - aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { - return false; - } - if (aFluidOutput != null) { - Logger.WARNING("Recipe will output: " + aFluidOutput.getFluid().getName()); - } - - if (aInput.length == 1) { - Logger.WARNING("Dehydrator recipe only has a single input item."); - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, - aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, - 0); - - } - else { - Logger.WARNING("Dehydrator recipe has two input items."); - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, - aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, - 0); - - } - - return true; - } - catch (final NullPointerException e) { - Logger.WARNING("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); - return false; - } - } - - @Override - public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aOutput, final int aChance, int aDuration, - final int aEUt) { - return addBlastSmelterRecipe(aInput, null, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, 3700); - } - - @Override - public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, - final int aChance, int aDuration, final int aEUt) { - return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, 3700); - } - - @Override - public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, - final int aChance[], int aDuration, final int aEUt) { - return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, aOutputStack, aChance, aDuration, aEUt, 3700); - } - - @Override - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, - int aDuration, int aEUt, int aSpecialValue) { - return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, aSpecialValue); - } - - @Override - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, - int aDuration, int aEUt, int aSpecialValue) { - if ((aInput == null) || (aOutput == null)) { - Logger.WARNING("Fail - Input or Output was null."); - return false; - } - - if (aOutput.isFluidEqual(Materials.PhasedGold.getMolten(1))) { - aOutput = Materials.VibrantAlloy.getMolten(aOutput.amount); - } - if (aOutput.isFluidEqual(Materials.PhasedIron.getMolten(1))) { - aOutput = Materials.PulsatingIron.getMolten(aOutput.amount); - } - if ((aDuration = GregTech_API.sRecipeFile.get("blastsmelter", aOutput.getFluid().getName(), aDuration)) <= 0) { - Logger.WARNING("Recipe did not register."); - return false; - } - - for (int das = 0; das < aInput.length; das++) { - if (aInput[das] != null) { - Logger.WARNING("tMaterial[" + das + "]: " + aInput[das].getDisplayName() + ", Amount: " - + aInput[das].stackSize); - } - } - - ArrayUtils.removeNulls(aInput); - if (aInput.length <= 1) { - return false; - } - - - - Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes.addRecipe(true, aInput, aOutputStack, null, - aChance, new FluidStack[] { aInputFluid }, new FluidStack[] { aOutput }, aDuration, aEUt, - aSpecialValue); - return true; - } - - @Override - public boolean addLFTRRecipe(final ItemStack aInput1, final FluidStack aInput2, final ItemStack aOutput1, - final FluidStack aOutput2, final int aDuration, final int aEUt) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean addLFTRRecipe(final ItemStack aInput1, final ItemStack aInput2, final ItemStack aOutput1, - final int aDuration, final int aEUt) { - return false; - } - - @Override - public boolean addLFTRRecipe(final FluidStack aInput1, final FluidStack aInput2, final FluidStack aOutput1, - final int aDuration, final int aEUt) { - if ((aInput1 == null) || (aInput2 == null) || (aOutput1 == null) || (aDuration < 1) || (aEUt < 1)) { - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.addRecipe(null, - new FluidStack[] { aInput1, aInput2 }, new FluidStack[] { aOutput1 }, aDuration, aEUt, 16000); - return true; - } - - @Override - public boolean addFissionFuel(final FluidStack aInput1, final FluidStack aInput2, final FluidStack aInput3, - final FluidStack aInput4, final FluidStack aInput5, final FluidStack aInput6, final FluidStack aInput7, - final FluidStack aInput8, final FluidStack aInput9, final FluidStack aOutput1, final FluidStack aOutput2, - final int aDuration, final int aEUt) { - - if ((aInput1 == null) || (aInput2 == null) || (aOutput1 == null) || (aDuration < 1) || (aEUt < 1)) { - return false; - } - final FluidStack inputs[] = { aInput1, aInput2, aInput3, aInput4, aInput5, aInput6, aInput7, aInput8, aInput9 }; - final FluidStack outputs[] = { aOutput1, aOutput2 }; - // Recipe_GT.Gregtech_Recipe_Map.sFissionFuelProcessing.addRecipe(null, - // inputs, outputs, aDuration, aEUt, 0); - CustomRecipeMap.sFissionFuelProcessing.addRecipe(null, inputs, outputs, aDuration, aEUt, 0); - return true; - } - - @Override - public boolean addCyclotronRecipe(ItemStack aInputs, FluidStack aFluidInput, ItemStack[] aOutputs, - FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue) { - return addCyclotronRecipe(new ItemStack[] {aInputs}, aFluidInput, aOutputs, aFluidOutput, aChances, aDuration, aEUt, aSpecialValue); - } - - @Override - public boolean addCyclotronRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack[] aOutput, - FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue) { - if (aOutput == null || aOutput.length < 1 || !ItemUtils.checkForInvalidItems(aOutput)) { - return false; - } - if (Recipe_GT.Gregtech_Recipe_Map.sCyclotronRecipes.addRecipe(true, aInputs, aOutput, - null, aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, - Math.max(1, aDuration), Math.max(1, aEUt), aSpecialValue) != null) { - return true; - } - - return false; - } - - @Override - public boolean addMixerRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aInput3, ItemStack aInput4, - FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, - ItemStack aOutput4, int aDuration, int aEUt) { - if (((aInput1 == null) && (aFluidInput == null)) || ((aOutput1 == null) && (aFluidOutput == null))) { - return false; - } - if ((aOutput1 != null) - && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", aOutput1, aDuration)) <= 0)) { - return false; - } - if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", - aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sAdvancedMixerRecipes.addRecipe(true, - new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, - new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 }, null, null, - new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - return true; - } - - // Machine Component Assembler - @Override - public boolean addComponentMakerRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack aOutput1, - int aDuration, int aEUt) { - if (areItemsAndFluidsBothNull(aInputs, new FluidStack[] { aFluidInput })) { - return false; - } - if (aOutput1 == null) { - return false; - } - if ((aDuration = GregTech_API.sRecipeFile.get("machinecomponents", aOutput1, aDuration)) <= 0) { - return false; - } - if (GTNH) { - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sComponentAssemblerRecipes.addRecipe(true, aInputs, new ItemStack[] { aOutput1 }, - null, new FluidStack[] { aFluidInput }, null, aDuration, aEUt, 0); - return true; - } - - - public boolean addMultiblockCentrifugeRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial){ - if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { - return false; - } - - if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { - Logger.INFO("[Recipe] Error generating Large Centrifuge recipe."); - Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); - Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); - Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); - Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sMultiblockCentrifugeRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial); - return true; - } - - public boolean addMultiblockElectrolyzerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial){ - if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { - return false; - } - if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { - Logger.INFO("[Recipe] Error generating Large Electrolyzer recipe."); - Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); - Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); - Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); - Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sMultiblockElectrolyzerRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial); - return true; - } - - - public boolean addAdvancedFreezerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial) { - if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { - return false; - } - - if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { - Logger.INFO("[Recipe] Error generating Adv. Vac Freezer recipe."); - Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); - Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); - Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); - Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); - return false; - } - if (Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial) != null) { - return true; - } - return false; - - } - - public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, ItemStack aOutput, int a1, int a2) { - if (aInput1 instanceof String || aInput2 instanceof String) { - int mCompleted = 0; - if (aInput1 instanceof String && aInput2 instanceof String) { - List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); - List<ItemStack> x1 = OreDictionary.getOres((String) aInput2, false); - if (x != null && x.size() > 0 && x1 != null && x1.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - for (ItemStack r1 : x1) { - r1.stackSize = aAmount2; - if (GT_Values.RA.addAssemblerRecipe(r, r1, aOutput, a1, a2)) { - mCompleted++; - } - } - } - } - } - else if (aInput1 instanceof String) { - List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); - if (x != null && x.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - if (GT_Values.RA.addAssemblerRecipe(r, (ItemStack) aInput2, aOutput, a1, a2)) { - mCompleted++; - } - } - } - - } - else { - List<ItemStack> x = OreDictionary.getOres((String) aInput2, false); - if (x != null && x.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - if (GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, r, aOutput, a1, a2)) { - mCompleted++; - } - } - } - } - return mCompleted > 0; - } - else { - return GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, (ItemStack) aInput2, aOutput, a1, a2); - } - } - - public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, FluidStack aInputFluid, ItemStack aOutput, int a1, int a2) { - if (aInput1 instanceof String || aInput2 instanceof String) { - int mCompleted = 0; - if (aInput1 instanceof String && aInput2 instanceof String) { - List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); - List<ItemStack> x1 = OreDictionary.getOres((String) aInput2, false); - if (x != null && x.size() > 0 && x1 != null && x1.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - for (ItemStack r1 : x1) { - r1.stackSize = aAmount2; - if (GT_Values.RA.addAssemblerRecipe(r, r1, aInputFluid, aOutput, a1, a2)) { - mCompleted++; - } - } - } - } - } - else if (aInput1 instanceof String) { - List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); - if (x != null && x.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - if (GT_Values.RA.addAssemblerRecipe(r, (ItemStack) aInput2, aInputFluid, aOutput, a1, a2)) { - mCompleted++; - } - } - } - - } - else { - List<ItemStack> x = OreDictionary.getOres((String) aInput2, false); - if (x != null && x.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - if (GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, r, aInputFluid, aOutput, a1, a2)) { - mCompleted++; - } - } - } - } - return mCompleted > 0; - } - else { - return GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, (ItemStack) aInput2, aInputFluid, aOutput, a1, a2); - } - } - - /* - * Reflection Based Recipe Additions with Fallbacks - */ - - private static final Method mSixSlotAssembly; - private static final Method mAssemblyLine; - private static final Method mScannerTT; - private static final Method[] mChemicalRecipe = new Method[3]; - private static final Method mLargeChemReactor; - private static final Method mPyroOven; - - static { - - //Get GT's RA class; - Class<? extends IGT_RecipeAdder> clazz = GT_Values.RA.getClass(); - - mChemicalRecipe[0] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, int.class); - - - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { - //6 Slot Assembler - mSixSlotAssembly = ReflectionUtils.getMethod(clazz, "addAssemblerRecipe", ItemStack[].class, FluidStack.class, ItemStack.class, int.class, int.class); - //Assembly Line - mAssemblyLine = ReflectionUtils.getMethod(clazz, "addAssemblylineRecipe", ItemStack.class, int.class, ItemStack[].class, FluidStack[].class, ItemStack.class, int.class, int.class); - - - Method T = null; - if (LoadedMods.TecTech) { - 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, - FluidStack[].class, ItemStack.class, int.class, int.class); - if (ttTest != null) { - T = ttTest; - } - else { - Method[] aDump = TTRecipeAdder.getDeclaredMethods(); - for (Method m : aDump) { - if (m != null) { - Logger.INFO("Found "+m.getName()+" | "+m.getModifiers()+" | "+ArrayUtils.toString(m.getParameters(), "EMPTY")+""); - if (m.getName().toLowerCase().equals("addresearchableassemblylinerecipe")){ - Logger.INFO("Types: "+ArrayUtils.toString(m.getParameterTypes())); - } - } - } - } - } - } - else { - T = null; - } - mScannerTT = T; - - mChemicalRecipe[1] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, int.class, int.class); - mChemicalRecipe[2] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, ItemStack.class, int.class); - - mLargeChemReactor = ReflectionUtils.getMethod(clazz, "addMultiblockChemicalRecipe", ItemStack[].class, FluidStack[].class, FluidStack[].class, ItemStack[].class, int.class, int.class); - - mPyroOven = ReflectionUtils.getMethod(clazz, "addPyrolyseRecipe", ItemStack.class, FluidStack.class, int.class, ItemStack.class, FluidStack.class, int.class, int.class); - - - - } - else { - mSixSlotAssembly = null; - mAssemblyLine = null; - mLargeChemReactor = null; - mScannerTT = null; - mPyroOven = null; - } - - - } - - - - - - - public boolean addSixSlotAssemblingRecipe(ItemStack[] aInputs, FluidStack aInputFluid, ItemStack aOutput1, int aDuration, int aEUt) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { - if (mSixSlotAssembly != null) { - try { - return (boolean) mSixSlotAssembly.invoke(GT_Values.RA, aInputs, aInputFluid, aOutput1, aDuration, aEUt); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - if (CORE.GTNH) { - return false; - } - } - } - } - return CORE.RA.addComponentMakerRecipe(aInputs, aInputFluid, aOutput1, aDuration, aEUt); - } - - public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs_OLD, ItemStack aOutput, int aDuration, int aEUt) { - - FluidStack[] aFluidInputs = new FluidStack[4]; - AutoMap<FluidStack> aNewFluidMap = new AutoMap<FluidStack>(); - 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 addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); - } - return false; - } - else { - if ((aResearchItem==null)||(aResearchTime<=0)||(aInputs == null) || (aOutput == null) || aInputs.length>15 || aInputs.length<4) { - return false; - } - else { - if (mAssemblyLine != null) { - try { - if (!tryAddTecTechScannerRecipe(aResearchItem, aInputs, aFluidInputs, aOutput, aDuration, aEUt)) { - try { - Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus."); - } - catch (Throwable t) { - t.printStackTrace(); - } - } - return (boolean) mAssemblyLine.invoke(GT_Values.RA, aResearchItem, aResearchTime, aInputs, - aFluidInputs, aOutput, aDuration, aEUt); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - if (aInputs.length < 6 && aFluidInputs.length < 2) { - ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], - aInputs[2], aInputs[3], aInputs[4] }; - return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, - aEUt); - } - return false; - } - } else { - if (aInputs.length < 6 && aFluidInputs.length < 2) { - ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], aInputs[2], - aInputs[3], aInputs[4] }; - return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, - aEUt); - } - return false; - } - } - } - } - - private boolean tryAddTecTechScannerRecipe(ItemStack aResearchItem, Object[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int assDuration, int assEUt) { - if (!LoadedMods.TecTech) { - return true; - } - else { - - int compSec = (GT_Utility.getTier(assEUt)+1) * 16; - int compMax = (GT_Utility.getTier(assEUt)+1) * 10000; - - if (mScannerTT != null) { - try { - 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 "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus. [Severe]"); - e.printStackTrace(); - } - } - } - return false; - } - - - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, int time, int eu){ - return addChemicalRecipe(input1, input2, inputFluid, outputFluid, output, null, time, eu); - } - - @Override - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, Object object, int time, int eu) { - try { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - return (boolean) mChemicalRecipe[0].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time); - } - else { - return (boolean) mChemicalRecipe[1].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time, eu); - } - } - catch (Throwable t) { - return false; - } - } - - @Override - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time) { - try { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - return (boolean) mChemicalRecipe[0].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time); - } - else { - return (boolean) mChemicalRecipe[2].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, output2, time); - } - } - catch (Throwable t) { - return false; - } - } - - @Override - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, int aCircuit, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time, int eu) { - if (aCircuit < 0 || aCircuit > 24) { - aCircuit = 22; - } - GT_Recipe aSpecialRecipe = new Recipe_GT( - false, - new ItemStack[] {input1, input2}, - new ItemStack[] {output, output2}, - CI.getNumberedCircuit(aCircuit), - new int[] {}, - new FluidStack[] {inputFluid}, - new FluidStack[] {outputFluid}, - time, - eu, - 0); - return GT_Recipe.GT_Recipe_Map.sChemicalRecipes.mRecipeList.add(aSpecialRecipe); - } - - @Override - public boolean addMultiblockChemicalRecipe(ItemStack[] itemStacks, FluidStack[] fluidStacks, FluidStack[] fluidStacks2, ItemStack[] outputs, int time, int eu) { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || mLargeChemReactor == null) { - return false; - } - try { - return (boolean) mLargeChemReactor.invoke(GT_Values.RA, itemStacks, fluidStacks, fluidStacks2, outputs, time, eu); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } - } - - - - - - - - - private boolean areItemsAndFluidsBothNull(final ItemStack[] items, final FluidStack[] fluids) { - boolean itemsNull = true; - if (items != null) { - for (final ItemStack itemStack : items) { - if (itemStack != null) { - itemsNull = false; - break; - } - } - } - boolean fluidsNull = true; - if (fluids != null) { - for (final FluidStack fluidStack : fluids) { - if (fluidStack != null) { - fluidsNull = false; - break; - } - } - } - return itemsNull && fluidsNull; - } - - @Override - public boolean addCompressorRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt) { - if ((aInput1 == null) || (aOutput1 == null)) { - return false; - } - if ((aInput1 != null) && ((aDuration = GregTech_API.sRecipeFile.get("compressor", aInput1, aDuration)) <= 0)) { - return false; - } - GT_Recipe.GT_Recipe_Map.sCompressorRecipes.addRecipe(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, aDuration, aEUt, 0); - return true; - } - - @Override - public boolean addBrewingRecipe(int aCircuit, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden) { - return addBrewingRecipe(CI.getNumberedCircuit(aCircuit), aInput, aOutput, aTime, aEu, aHidden); - } - - @Override - public boolean addBrewingRecipe(ItemStack aIngredient, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden) { - if ((aIngredient == null) || (aInput == null) || (aOutput == null)) { - return false; - } - if (!GregTech_API.sRecipeFile.get("brewing", aOutput.getUnlocalizedName(), true)) { - return false; - } - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBrewingRecipes.addRecipe(false, new ItemStack[]{aIngredient}, null, null, new FluidStack[]{aInput}, new FluidStack[]{aOutput}, aTime, aEu, 0); - if ((aHidden) && (tRecipe != null)) { - tRecipe.mHidden = true; - } - return true; - } - - - /** - * Lets me add recipes for GT 5.08 & 5.09, since someone broke the method headers. - */ - @Override - public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput) { - Method m = StaticFields59.mAddFurnaceRecipe; - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - try { - return (boolean) m.invoke(null, aDust, aOutput); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } - } - else { - try { - return (boolean) m.invoke(null, aDust, aOutput, true); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } - } - } - - @Override - public boolean addFluidExtractionRecipe(ItemStack input, FluidStack output, int aTime, int aEu) { - return MaterialGenerator.addFluidExtractionRecipe(GT_Values.NI, input, output, aTime, aEu); - } - - @Override - public boolean addFluidExtractionRecipe(ItemStack aEmpty, ItemStack aRemains, FluidStack aFluid, int aDuration, int aEU) { - return MaterialGenerator.addFluidExtractionRecipe(aEmpty, aRemains, aFluid, aDuration, aEU); - } - - @Override - public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn) { - return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, null); - } - - @Override - public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut) { - return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, rFluidOut); - } - - - @Override - public boolean addFluidCannerRecipe(ItemStack aFullContainer, ItemStack container, FluidStack rFluidIn, FluidStack rFluidOut, int aTime, int aEu) { - return MaterialGenerator.addFluidCannerRecipe(container, aFullContainer, rFluidIn, rFluidOut, aTime, aEu); - } - - /** - * Adds a Fusion reactor Recipe - * - * @param aInputStackA = first Input (not null, and respects StackSize) - * @param aInputStackB = second Input (not null, and respects StackSize) - * @param plasma = Output of the Fusion (can be null, and respects StackSize) - * @param aOutputChance = chance to output plasma (can be 0) - * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) - * @param aEu = The EU generated per Tick (can even be negative!) - * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) - */ - @Override - public boolean addFusionReactorRecipe(FluidStack aInputStackA, FluidStack aInputStackB, FluidStack plasma, - int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { - if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { - return false; - } - Recipe_GT aFusionCustom = new Recipe_GT( - true, - null, - null, - null, - new int[] {aOutputChance}, - new FluidStack[]{aInputStackA, aInputStackB}, - new FluidStack[]{plasma}, - aFusionDurationInTicks, - aEu, - aSpecial); - GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); - return true; - } - - - - - - - /** - * Adds a Fusion reactor Recipe - * - * @param aInputStackA = first Input (not null, and respects StackSize) - * @param aInputStackB = second Input (not null, and respects StackSize) - * @param plasma = Output of the Fusion (can be null, and respects StackSize) - * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) - * @param aEu = The EU generated per Tick (can even be negative!) - * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) - */ - @Override - public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, - int aFusionDurationInTicks, int aEu, int aSpecial) { - return addFusionReactorRecipe(aInputStackA, aInputStackB, plasma, 10000, aFusionDurationInTicks, aEu, aSpecial); - } - - - /** - * Adds a Fusion reactor Recipe - * - * @param aInputStackA = first Input (not null, and respects StackSize) - * @param aInputStackB = second Input (not null, and respects StackSize) - * @param plasma = Output of the Fusion (can be null, and respects StackSize) - * @param aOutputChance = chance to output plasma (can be 0) - * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) - * @param aEu = The EU generated per Tick (can even be negative!) - * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) - */ - @Override - public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, - int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { - if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { - return false; - } - Recipe_GT aFusionCustom = new Recipe_GT( - true, - new ItemStack[]{aInputStackA, aInputStackB}, - null, - null, - new int[] {aOutputChance}, - null, - new FluidStack[]{plasma}, - aFusionDurationInTicks, - aEu, - aSpecial); - GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); - 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); - } - - - - - @Override - public boolean addVacuumFurnaceRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, - ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt, int aLevel) { - if (aInput1 != null && aOutput1 != null) { - if ((aDuration = GregTech_API.sRecipeFile.get("vacuumfurnace", aInput1, aDuration)) <= 0) { - return false; - } else { - Recipe_GT.Gregtech_Recipe_Map.sVacuumFurnaceRecipes.addRecipe(true, new ItemStack[]{aInput1, aInput2}, - new ItemStack[]{aOutput1, aOutput2}, (Object) null, (int[]) null, new FluidStack[]{aFluidInput}, - new FluidStack[]{aFluidOutput}, aDuration, aEUt, aLevel); - return true; - } - } else { - return false; - } - } + @Override + public boolean addCokeOvenRecipe(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, + final FluidStack aFluidOutput, final ItemStack aOutput, int aDuration, final int aEUt) { + try { + try { + // RECIPEHANDLER_CokeOven.debug1(); + if (((aInput1 == null) /* && (aFluidInput == null) */) + || ((aOutput == null) || (aFluidOutput == null))) { + // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" + // aInput2:"+aInput2.toString()+" + // aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Something was null, returning false"); + return false; + } + + } + catch (final NullPointerException e) { + e.getStackTrace(); + } + try { + // RECIPEHANDLER_CokeOven.debug2(aInput1, aInput2, aFluidInput, + // aFluidOutput, aOutput, aDuration, aEUt); + if ((aOutput != null) + && ((aDuration = GregTech_API.sRecipeFile.get("cokeoven", aOutput, aDuration)) <= 0)) { + // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" + // aInput2:"+aInput2.toString()+" + // aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Something was null, returning false"); + return false; + } + + } + catch (final NullPointerException e) { + e.getStackTrace(); + } + try { + // RECIPEHANDLER_CokeOven.debug3(aInput1, aInput2, aFluidInput, + // aFluidOutput, aOutput, aDuration, aEUt); + if ((aFluidOutput == null) || ((aDuration = GregTech_API.sRecipeFile.get("cokeoven", + aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { + // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" + // aInput2:"+aInput2.toString()+" + // aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Something was null, returning false"); + return false; + } + + } + catch (final NullPointerException e) { + e.getStackTrace(); + } + try { + // RECIPEHANDLER_CokeOven.debug4(aInput1, aInput2, aFluidInput, + // aFluidOutput, aOutput, aDuration, aEUt); + if (aFluidInput == null && aInput2 != null) { + Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, + new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, + aEUt, 0); + } + else if (aFluidInput == null && aInput2 == null) { + Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1 }, + new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, + aEUt, 0); + } + else { + Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, + new ItemStack[] { aOutput }, null, null, new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + } + // RECIPEHANDLER_CokeOven.debug5(aInput1, aInput2, aFluidInput, + // aFluidOutput, aOutput, aDuration, aEUt); + + return true; + + } + catch (final NullPointerException e) { + Logger.WARNING("Something was null, returning false"); + return false; + } + } + catch (final Throwable e) { + // Logger.WARNING("aInput1:"+aInput1.toString()+" + // aInput2:"+aInput2.toString()+" + // aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Failed."); + e.getStackTrace(); + return false; + } + } + + @Override + public boolean addMatterFabricatorRecipe(final FluidStack aFluidInput, final FluidStack aFluidOutput, + final int aDuration, final int aEUt) { + try { + try { + // RECIPEHANDLER_MatterFabricator.debug1(); + if (aFluidOutput == null) { + // Utils.LOG_WARNING("aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Something was null, returning false"); + return false; + } + + } + catch (final NullPointerException e) { + e.getStackTrace(); + } + try { + + // RECIPEHANDLER_MatterFabricator.debug4(aFluidInput, + // aFluidOutput, aDuration, aEUt); + if (aFluidInput == null) { + // Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, + // null, new FluidStack[]{aFluidOutput}, aDuration, aEUt, + // 0); + Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, null, null, null, null, + new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + } + else { + // Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, + // new FluidStack[]{aFluidInput}, new + // FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); + Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, null, null, null, + new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + } + RECIPEHANDLER_MatterFabricator.debug5(aFluidInput, aFluidOutput, aDuration, aEUt); + + return true; + + } + catch (final NullPointerException e) { + return false; + } + } + catch (final Throwable e) { + // Utils.LOG_WARNING("aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Failed."); + e.getStackTrace(); + return false; + } + } + + @Override + public boolean addMatterFabricatorRecipe(final ItemStack aInputStack, final FluidStack aFluidInput, + final FluidStack aFluidOutput, final int aDuration, final int aEUt) { + try { + try { + if ((aFluidOutput == null) || (aInputStack == null)) { + return false; + } + } + catch (final NullPointerException e) { + } + try { + if (aFluidInput == null) { + Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, new ItemStack[] { aInputStack }, + null, null, null, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + } + else { + Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, new ItemStack[] { aInputStack }, + null, null, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, + aEUt, 0); + } + RECIPEHANDLER_MatterFabricator.debug5(aFluidInput, aFluidOutput, aDuration, aEUt); + return true; + } + catch (final NullPointerException e) { + return false; + } + } + catch (final Throwable e) { + return false; + } + } + + @Override + public boolean addFuel(final ItemStack aInput1, final ItemStack aOutput1, final int aEU, final int aType) { + if (aInput1 == null) { + Logger.WARNING("Fuel Input is Invalid."); + return false; + } + // new GregtechRecipe(aInput1, aOutput1, + // GregTech_API.sRecipeFile.get("fuel_" + aType, aInput1, aEU), aType); + return true; + } + + /* + * @Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack + * aItemB, FluidStack aFluid, ItemStack[] aOutputItems, FluidStack + * aOutputFluid, int aDuration, int aEUt) { if ((aItemA == null) || (aItemB + * == null) || (aOutputItems == null)) { return false; } for (ItemStack + * tStack : aOutputItems) { if (tStack != null) { if ((aDuration = + * GregTech_API.sRecipeFile.get("dehydrator", aItemA, aDuration)) <= 0) { + * return false; } + * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, + * new ItemStack[]{aItemA, aItemB}, aOutputItems, null, null, null, + * aDuration, aEUt, 0); RECIPEHANDLER_Dehydrator.debug5(aItemA, aItemB, + * aFluid, aOutputFluid, aOutputItems, aDuration, aEUt); return true; } } + * return false; } + * @Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack + * aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt) { if ((aItemA + * == null) || (aItemB == null) || (aOutputItems == null)) { return false; } + * if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aItemA, + * aDuration)) <= 0) { return false; } + * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, + * new ItemStack[]{aItemA, aItemB}, aOutputItems, null, null, null, + * aDuration, aEUt, 0); RECIPEHANDLER_Dehydrator.debug5(aItemA, aItemB, + * null, null, aOutputItems, aDuration, aEUt); return true; } + * @Override public boolean addDehydratorRecipe(FluidStack aFluid, + * FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int + * aEUt){ if ((aFluid == null) || (aOutputFluid == null || aOutputItems == + * null)) { return false; } if ((aDuration = + * GregTech_API.sRecipeFile.get("dehydrator", aFluid.getUnlocalizedName(), + * aDuration)) <= 0) { return false; } + * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, + * null, aOutputItems, null, new FluidStack[]{aFluid}, new + * FluidStack[]{aOutputFluid}, aDuration, aEUt, 0); + * RECIPEHANDLER_Dehydrator.debug5(null, null, aFluid, aOutputFluid, + * aOutputItems, aDuration, aEUt); return true; } + */ + + @Override + public boolean addDehydratorRecipe(final ItemStack aInput, final FluidStack aFluid, final ItemStack[] aOutput, + int aDuration, final int aEUt) { + Logger.WARNING("Trying to add a Dehydrator recipe."); + try { + if ((aInput == null) || (aFluid == null) || (aOutput == null)) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aInput, aDuration)) <= 0) { + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, new ItemStack[] { aInput }, + aOutput, null, new FluidStack[] { aFluid }, null, aDuration, aEUt, 0); + // RECIPEHANDLER_Dehydrator.debug5(aInput, null, aFluid, null, + // aOutput, aDuration, aEUt); + return true; + } + catch (final NullPointerException e) { + Logger.WARNING("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); + return false; + } + } + + @Override + public boolean addDehydratorRecipe(final ItemStack[] aInput, final FluidStack aFluidInput, + final FluidStack aFluidOutput, final ItemStack[] aOutputItems, final int[] aChances, int aDuration, + final int aEUt) throws IndexOutOfBoundsException { + Logger.WARNING("Trying to add a Dehydrator recipe."); + try { + if (aInput[0] != null) { + Logger.WARNING("Recipe requires input: " + aInput[0].getDisplayName() + " x" + aInput[0].stackSize); + } + if (aInput.length > 1) { + if (aInput[1] != null) { + Logger.WARNING("Recipe requires input: " + aInput[1].getDisplayName() + " x" + aInput[1].stackSize); + } + } + if (aFluidInput != null) { + Logger.WARNING("Recipe requires input: " + aFluidInput.getFluid().getName() + " " + aFluidInput.amount + + "mbst"); + } + if (((aInput[0] == null) && (aFluidInput == null)) || ((aOutputItems == null) && (aFluidOutput == null))) { + return false; + } + if ((aOutputItems != null) + && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aOutputItems[0], aDuration)) <= 0)) { + return false; + } + if (aOutputItems != null) { + Logger.WARNING("Recipe will output: " + ItemUtils.getArrayStackNames(aOutputItems)); + } + if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", + aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { + return false; + } + if (aFluidOutput != null) { + Logger.WARNING("Recipe will output: " + aFluidOutput.getFluid().getName()); + } + + if (aInput.length == 1) { + Logger.WARNING("Dehydrator recipe only has a single input item."); + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, + aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, + 0); + + } + else { + Logger.WARNING("Dehydrator recipe has two input items."); + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, + aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, + 0); + + } + + return true; + } + catch (final NullPointerException e) { + Logger.WARNING("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); + return false; + } + } + + @Override + public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aOutput, final int aChance, int aDuration, + final int aEUt) { + return addBlastSmelterRecipe(aInput, null, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, 3700); + } + + @Override + public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, + final int aChance, int aDuration, final int aEUt) { + return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, 3700); + } + + @Override + public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, + final int aChance[], int aDuration, final int aEUt) { + return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, aOutputStack, aChance, aDuration, aEUt, 3700); + } + + @Override + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, + int aDuration, int aEUt, int aSpecialValue) { + return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, aSpecialValue); + } + + @Override + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, + int aDuration, int aEUt, int aSpecialValue) { + if ((aInput == null) || (aOutput == null)) { + Logger.WARNING("Fail - Input or Output was null."); + return false; + } + + if (aOutput.isFluidEqual(Materials.PhasedGold.getMolten(1))) { + aOutput = Materials.VibrantAlloy.getMolten(aOutput.amount); + } + if (aOutput.isFluidEqual(Materials.PhasedIron.getMolten(1))) { + aOutput = Materials.PulsatingIron.getMolten(aOutput.amount); + } + if ((aDuration = GregTech_API.sRecipeFile.get("blastsmelter", aOutput.getFluid().getName(), aDuration)) <= 0) { + Logger.WARNING("Recipe did not register."); + return false; + } + + for (int das = 0; das < aInput.length; das++) { + if (aInput[das] != null) { + Logger.WARNING("tMaterial[" + das + "]: " + aInput[das].getDisplayName() + ", Amount: " + + aInput[das].stackSize); + } + } + + ArrayUtils.removeNulls(aInput); + if (aInput.length <= 1) { + return false; + } + + + + Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes.addRecipe(true, aInput, aOutputStack, null, + aChance, new FluidStack[] { aInputFluid }, new FluidStack[] { aOutput }, aDuration, aEUt, + aSpecialValue); + return true; + } + + @Override + public boolean addLFTRRecipe(final ItemStack aInput1, final FluidStack aInput2, final ItemStack aOutput1, + final FluidStack aOutput2, final int aDuration, final int aEUt) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean addLFTRRecipe(final ItemStack aInput1, final ItemStack aInput2, final ItemStack aOutput1, + final int aDuration, final int aEUt) { + return false; + } + + @Override + public boolean addLFTRRecipe(final FluidStack aInput1, final FluidStack aInput2, final FluidStack aOutput1, + final int aDuration, final int aEUt) { + if ((aInput1 == null) || (aInput2 == null) || (aOutput1 == null) || (aDuration < 1) || (aEUt < 1)) { + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.addRecipe(null, + new FluidStack[] { aInput1, aInput2 }, new FluidStack[] { aOutput1 }, aDuration, aEUt, 16000); + return true; + } + + @Override + public boolean addFissionFuel(final FluidStack aInput1, final FluidStack aInput2, final FluidStack aInput3, + final FluidStack aInput4, final FluidStack aInput5, final FluidStack aInput6, final FluidStack aInput7, + final FluidStack aInput8, final FluidStack aInput9, final FluidStack aOutput1, final FluidStack aOutput2, + final int aDuration, final int aEUt) { + + if ((aInput1 == null) || (aInput2 == null) || (aOutput1 == null) || (aDuration < 1) || (aEUt < 1)) { + return false; + } + final FluidStack inputs[] = { aInput1, aInput2, aInput3, aInput4, aInput5, aInput6, aInput7, aInput8, aInput9 }; + final FluidStack outputs[] = { aOutput1, aOutput2 }; + // Recipe_GT.Gregtech_Recipe_Map.sFissionFuelProcessing.addRecipe(null, + // inputs, outputs, aDuration, aEUt, 0); + CustomRecipeMap.sFissionFuelProcessing.addRecipe(null, inputs, outputs, aDuration, aEUt, 0); + return true; + } + + @Override + public boolean addCyclotronRecipe(ItemStack aInputs, FluidStack aFluidInput, ItemStack[] aOutputs, + FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue) { + return addCyclotronRecipe(new ItemStack[] {aInputs}, aFluidInput, aOutputs, aFluidOutput, aChances, aDuration, aEUt, aSpecialValue); + } + + @Override + public boolean addCyclotronRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack[] aOutput, + FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue) { + if (aOutput == null || aOutput.length < 1 || !ItemUtils.checkForInvalidItems(aOutput)) { + return false; + } + if (Recipe_GT.Gregtech_Recipe_Map.sCyclotronRecipes.addRecipe(true, aInputs, aOutput, + null, aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), Math.max(1, aEUt), aSpecialValue) != null) { + return true; + } + + return false; + } + + @Override + public boolean addMixerRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aInput3, ItemStack aInput4, + FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, + ItemStack aOutput4, int aDuration, int aEUt) { + if (((aInput1 == null) && (aFluidInput == null)) || ((aOutput1 == null) && (aFluidOutput == null))) { + return false; + } + if ((aOutput1 != null) + && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", aOutput1, aDuration)) <= 0)) { + return false; + } + if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", + aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sAdvancedMixerRecipes.addRecipe(true, + new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, + new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 }, null, null, + new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + return true; + } + + // Machine Component Assembler + @Override + public boolean addComponentMakerRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack aOutput1, + int aDuration, int aEUt) { + if (areItemsAndFluidsBothNull(aInputs, new FluidStack[] { aFluidInput })) { + return false; + } + if (aOutput1 == null) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("machinecomponents", aOutput1, aDuration)) <= 0) { + return false; + } + if (GTNH) { + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sComponentAssemblerRecipes.addRecipe(true, aInputs, new ItemStack[] { aOutput1 }, + null, new FluidStack[] { aFluidInput }, null, aDuration, aEUt, 0); + return true; + } + + + public boolean addMultiblockCentrifugeRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial){ + if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { + return false; + } + + if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { + Logger.INFO("[Recipe] Error generating Large Centrifuge recipe."); + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); + Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); + Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sMultiblockCentrifugeRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial); + return true; + } + + public boolean addMultiblockElectrolyzerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial){ + if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { + return false; + } + if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { + Logger.INFO("[Recipe] Error generating Large Electrolyzer recipe."); + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); + Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); + Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sMultiblockElectrolyzerRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial); + return true; + } + + + public boolean addAdvancedFreezerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial) { + if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { + return false; + } + + if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { + Logger.INFO("[Recipe] Error generating Adv. Vac Freezer recipe."); + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); + Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); + Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); + return false; + } + if (Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial) != null) { + return true; + } + return false; + + } + + public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, ItemStack aOutput, int a1, int a2) { + if (aInput1 instanceof String || aInput2 instanceof String) { + int mCompleted = 0; + if (aInput1 instanceof String && aInput2 instanceof String) { + List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); + List<ItemStack> x1 = OreDictionary.getOres((String) aInput2, false); + if (x != null && x.size() > 0 && x1 != null && x1.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + for (ItemStack r1 : x1) { + r1.stackSize = aAmount2; + if (GT_Values.RA.addAssemblerRecipe(r, r1, aOutput, a1, a2)) { + mCompleted++; + } + } + } + } + } + else if (aInput1 instanceof String) { + List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); + if (x != null && x.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + if (GT_Values.RA.addAssemblerRecipe(r, (ItemStack) aInput2, aOutput, a1, a2)) { + mCompleted++; + } + } + } + + } + else { + List<ItemStack> x = OreDictionary.getOres((String) aInput2, false); + if (x != null && x.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + if (GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, r, aOutput, a1, a2)) { + mCompleted++; + } + } + } + } + return mCompleted > 0; + } + else { + return GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, (ItemStack) aInput2, aOutput, a1, a2); + } + } + + public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, FluidStack aInputFluid, ItemStack aOutput, int a1, int a2) { + if (aInput1 instanceof String || aInput2 instanceof String) { + int mCompleted = 0; + if (aInput1 instanceof String && aInput2 instanceof String) { + List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); + List<ItemStack> x1 = OreDictionary.getOres((String) aInput2, false); + if (x != null && x.size() > 0 && x1 != null && x1.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + for (ItemStack r1 : x1) { + r1.stackSize = aAmount2; + if (GT_Values.RA.addAssemblerRecipe(r, r1, aInputFluid, aOutput, a1, a2)) { + mCompleted++; + } + } + } + } + } + else if (aInput1 instanceof String) { + List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); + if (x != null && x.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + if (GT_Values.RA.addAssemblerRecipe(r, (ItemStack) aInput2, aInputFluid, aOutput, a1, a2)) { + mCompleted++; + } + } + } + + } + else { + List<ItemStack> x = OreDictionary.getOres((String) aInput2, false); + if (x != null && x.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + if (GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, r, aInputFluid, aOutput, a1, a2)) { + mCompleted++; + } + } + } + } + return mCompleted > 0; + } + else { + return GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, (ItemStack) aInput2, aInputFluid, aOutput, a1, a2); + } + } + + /* + * Reflection Based Recipe Additions with Fallbacks + */ + + private static final Method mSixSlotAssembly; + private static final Method mAssemblyLine; + private static final Method mScannerTT; + private static final Method[] mChemicalRecipe = new Method[3]; + private static final Method mLargeChemReactor; + private static final Method mPyroOven; + + static { + + //Get GT's RA class; + Class<? extends IGT_RecipeAdder> clazz = GT_Values.RA.getClass(); + + mChemicalRecipe[0] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, int.class); + + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + //6 Slot Assembler + mSixSlotAssembly = ReflectionUtils.getMethod(clazz, "addAssemblerRecipe", ItemStack[].class, FluidStack.class, ItemStack.class, int.class, int.class); + //Assembly Line + mAssemblyLine = ReflectionUtils.getMethod(clazz, "addAssemblylineRecipe", ItemStack.class, int.class, ItemStack[].class, FluidStack[].class, ItemStack.class, int.class, int.class); + + + Method T = null; + if (LoadedMods.TecTech) { + 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, + FluidStack[].class, ItemStack.class, int.class, int.class); + if (ttTest != null) { + T = ttTest; + } + else { + Method[] aDump = TTRecipeAdder.getDeclaredMethods(); + for (Method m : aDump) { + if (m != null) { + Logger.INFO("Found "+m.getName()+" | "+m.getModifiers()+" | "+ArrayUtils.toString(m.getParameters(), "EMPTY")+""); + if (m.getName().toLowerCase().equals("addresearchableassemblylinerecipe")){ + Logger.INFO("Types: "+ArrayUtils.toString(m.getParameterTypes())); + } + } + } + } + } + } + else { + T = null; + } + mScannerTT = T; + + mChemicalRecipe[1] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, int.class, int.class); + mChemicalRecipe[2] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, ItemStack.class, int.class); + + mLargeChemReactor = ReflectionUtils.getMethod(clazz, "addMultiblockChemicalRecipe", ItemStack[].class, FluidStack[].class, FluidStack[].class, ItemStack[].class, int.class, int.class); + + mPyroOven = ReflectionUtils.getMethod(clazz, "addPyrolyseRecipe", ItemStack.class, FluidStack.class, int.class, ItemStack.class, FluidStack.class, int.class, int.class); + + + + } + else { + mSixSlotAssembly = null; + mAssemblyLine = null; + mLargeChemReactor = null; + mScannerTT = null; + mPyroOven = null; + } + + + } + + + + + + + public boolean addSixSlotAssemblingRecipe(ItemStack[] aInputs, FluidStack aInputFluid, ItemStack aOutput1, int aDuration, int aEUt) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + if (mSixSlotAssembly != null) { + try { + return (boolean) mSixSlotAssembly.invoke(GT_Values.RA, aInputs, aInputFluid, aOutput1, aDuration, aEUt); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + if (CORE.GTNH) { + return false; + } + } + } + } + return CORE.RA.addComponentMakerRecipe(aInputs, aInputFluid, aOutput1, aDuration, aEUt); + } + + public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs_OLD, ItemStack aOutput, int aDuration, int aEUt) { + + FluidStack[] aFluidInputs = new FluidStack[4]; + AutoMap<FluidStack> aNewFluidMap = new AutoMap<FluidStack>(); + 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 addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); + } + return false; + } + else { + if ((aResearchItem==null)||(aResearchTime<=0)||(aInputs == null) || (aOutput == null) || aInputs.length>15 || aInputs.length<4) { + return false; + } + else { + if (mAssemblyLine != null) { + try { + if (!tryAddTecTechScannerRecipe(aResearchItem, aInputs, aFluidInputs, aOutput, aDuration, aEUt)) { + try { + Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus."); + } + catch (Throwable t) { + t.printStackTrace(); + } + } + return (boolean) mAssemblyLine.invoke(GT_Values.RA, aResearchItem, aResearchTime, aInputs, + aFluidInputs, aOutput, aDuration, aEUt); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + if (aInputs.length < 6 && aFluidInputs.length < 2) { + ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], + aInputs[2], aInputs[3], aInputs[4] }; + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, + aEUt); + } + return false; + } + } else { + if (aInputs.length < 6 && aFluidInputs.length < 2) { + ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], aInputs[2], + aInputs[3], aInputs[4] }; + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, + aEUt); + } + return false; + } + } + } + } + + private boolean tryAddTecTechScannerRecipe(ItemStack aResearchItem, Object[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int assDuration, int assEUt) { + if (!LoadedMods.TecTech) { + return true; + } + else { + + int compSec = (GT_Utility.getTier(assEUt)+1) * 16; + int compMax = (GT_Utility.getTier(assEUt)+1) * 10000; + + if (mScannerTT != null) { + try { + 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 "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus. [Severe]"); + e.printStackTrace(); + } + } + } + return false; + } + + + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, int time, int eu){ + return addChemicalRecipe(input1, input2, inputFluid, outputFluid, output, null, time, eu); + } + + @Override + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, Object object, int time, int eu) { + try { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return (boolean) mChemicalRecipe[0].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time); + } + else { + return (boolean) mChemicalRecipe[1].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time, eu); + } + } + catch (Throwable t) { + return false; + } + } + + @Override + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time) { + try { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return (boolean) mChemicalRecipe[0].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time); + } + else { + return (boolean) mChemicalRecipe[2].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, output2, time); + } + } + catch (Throwable t) { + return false; + } + } + + @Override + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, int aCircuit, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time, int eu) { + if (aCircuit < 0 || aCircuit > 24) { + aCircuit = 22; + } + GT_Recipe aSpecialRecipe = new Recipe_GT( + false, + new ItemStack[] {input1, input2}, + new ItemStack[] {output, output2}, + CI.getNumberedCircuit(aCircuit), + new int[] {}, + new FluidStack[] {inputFluid}, + new FluidStack[] {outputFluid}, + time, + eu, + 0); + return GT_Recipe.GT_Recipe_Map.sChemicalRecipes.mRecipeList.add(aSpecialRecipe); + } + + @Override + public boolean addMultiblockChemicalRecipe(ItemStack[] itemStacks, FluidStack[] fluidStacks, FluidStack[] fluidStacks2, ItemStack[] outputs, int time, int eu) { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || mLargeChemReactor == null) { + return false; + } + try { + return (boolean) mLargeChemReactor.invoke(GT_Values.RA, itemStacks, fluidStacks, fluidStacks2, outputs, time, eu); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + + + + + + + + + private boolean areItemsAndFluidsBothNull(final ItemStack[] items, final FluidStack[] fluids) { + boolean itemsNull = true; + if (items != null) { + for (final ItemStack itemStack : items) { + if (itemStack != null) { + itemsNull = false; + break; + } + } + } + boolean fluidsNull = true; + if (fluids != null) { + for (final FluidStack fluidStack : fluids) { + if (fluidStack != null) { + fluidsNull = false; + break; + } + } + } + return itemsNull && fluidsNull; + } + + @Override + public boolean addCompressorRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt) { + if ((aInput1 == null) || (aOutput1 == null)) { + return false; + } + if ((aInput1 != null) && ((aDuration = GregTech_API.sRecipeFile.get("compressor", aInput1, aDuration)) <= 0)) { + return false; + } + GT_Recipe.GT_Recipe_Map.sCompressorRecipes.addRecipe(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, aDuration, aEUt, 0); + return true; + } + + @Override + public boolean addBrewingRecipe(int aCircuit, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden) { + return addBrewingRecipe(CI.getNumberedCircuit(aCircuit), aInput, aOutput, aTime, aEu, aHidden); + } + + @Override + public boolean addBrewingRecipe(ItemStack aIngredient, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden) { + if ((aIngredient == null) || (aInput == null) || (aOutput == null)) { + return false; + } + if (!GregTech_API.sRecipeFile.get("brewing", aOutput.getUnlocalizedName(), true)) { + return false; + } + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBrewingRecipes.addRecipe(false, new ItemStack[]{aIngredient}, null, null, new FluidStack[]{aInput}, new FluidStack[]{aOutput}, aTime, aEu, 0); + if ((aHidden) && (tRecipe != null)) { + tRecipe.mHidden = true; + } + return true; + } + + + /** + * Lets me add recipes for GT 5.08 & 5.09, since someone broke the method headers. + */ + @Override + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput) { + Method m = StaticFields59.mAddFurnaceRecipe; + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + return (boolean) m.invoke(null, aDust, aOutput); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + else { + try { + return (boolean) m.invoke(null, aDust, aOutput, true); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + } + + @Override + public boolean addFluidExtractionRecipe(ItemStack input, FluidStack output, int aTime, int aEu) { + return MaterialGenerator.addFluidExtractionRecipe(GT_Values.NI, input, output, aTime, aEu); + } + + @Override + public boolean addFluidExtractionRecipe(ItemStack aEmpty, ItemStack aRemains, FluidStack aFluid, int aDuration, int aEU) { + return MaterialGenerator.addFluidExtractionRecipe(aEmpty, aRemains, aFluid, aDuration, aEU); + } + + @Override + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn) { + return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, null); + } + + @Override + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut) { + return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, rFluidOut); + } + + + @Override + public boolean addFluidCannerRecipe(ItemStack aFullContainer, ItemStack container, FluidStack rFluidIn, FluidStack rFluidOut, int aTime, int aEu) { + return MaterialGenerator.addFluidCannerRecipe(container, aFullContainer, rFluidIn, rFluidOut, aTime, aEu); + } + + /** + * Adds a Fusion reactor Recipe + * + * @param aInputStackA = first Input (not null, and respects StackSize) + * @param aInputStackB = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aOutputChance = chance to output plasma (can be 0) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + @Override + public boolean addFusionReactorRecipe(FluidStack aInputStackA, FluidStack aInputStackB, FluidStack plasma, + int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { + if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { + return false; + } + Recipe_GT aFusionCustom = new Recipe_GT( + true, + null, + null, + null, + new int[] {aOutputChance}, + new FluidStack[]{aInputStackA, aInputStackB}, + new FluidStack[]{plasma}, + aFusionDurationInTicks, + aEu, + aSpecial); + GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); + return true; + } + + + + + + + /** + * Adds a Fusion reactor Recipe + * + * @param aInputStackA = first Input (not null, and respects StackSize) + * @param aInputStackB = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + @Override + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, + int aFusionDurationInTicks, int aEu, int aSpecial) { + return addFusionReactorRecipe(aInputStackA, aInputStackB, plasma, 10000, aFusionDurationInTicks, aEu, aSpecial); + } + + + /** + * Adds a Fusion reactor Recipe + * + * @param aInputStackA = first Input (not null, and respects StackSize) + * @param aInputStackB = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aOutputChance = chance to output plasma (can be 0) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + @Override + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, + int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { + if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { + return false; + } + Recipe_GT aFusionCustom = new Recipe_GT( + true, + new ItemStack[]{aInputStackA, aInputStackB}, + null, + null, + new int[] {aOutputChance}, + null, + new FluidStack[]{plasma}, + aFusionDurationInTicks, + aEu, + aSpecial); + GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); + 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); + } + + + + + @Override + public boolean addVacuumFurnaceRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, + ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt, int aLevel) { + if (aInput1 != null && aOutput1 != null) { + return addVacuumFurnaceRecipe(new ItemStack[] {aInput1, aInput2}, new FluidStack[] {aFluidInput}, new ItemStack[] {aOutput1, aOutput2}, new FluidStack[] {aFluidOutput}, aDuration, aEUt, aLevel); + } + else { + return false; + } + } + + + @Override + public boolean addVacuumFurnaceRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aLevel) { + if (aInputs != null && aOutputs != null) { + Recipe_GT aSpecialRecipe = new Recipe_GT( + false, + aInputs, + aOutputs, + null, + new int[] {}, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aLevel); + + int aSize = Recipe_GT.Gregtech_Recipe_Map.sVacuumFurnaceRecipes.mRecipeList.size(); + int aSize2 = aSize; + Recipe_GT.Gregtech_Recipe_Map.sVacuumFurnaceRecipes.addRecipe(aSpecialRecipe); + aSize = Recipe_GT.Gregtech_Recipe_Map.sVacuumFurnaceRecipes.mRecipeList.size(); + return aSize > aSize2; + } else { + return false; + } + } @Override public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu) { @@ -1190,7 +1205,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addChemicalPlantRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int[] aChances, int time, long eu, int aTier) { - + if (aInputs.length > 4 || aInputFluids.length > 4 || aOutputs.length > 4 || aFluidOutputs.length > 2) { Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aInputFluids)); @@ -1198,20 +1213,20 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); CORE.crash(); } - - + + Recipe_GT aSpecialRecipe = new Recipe_GT( - false, - aInputs, - aOutputs, - null, - aChances, - aInputFluids, - aFluidOutputs, - time, - (int) eu, - aTier); - + false, + aInputs, + aOutputs, + null, + aChances, + aInputFluids, + aFluidOutputs, + time, + (int) eu, + aTier); + int aSize = Recipe_GT.Gregtech_Recipe_Map.sChemicalPlantRecipes.mRecipeList.size(); int aSize2 = aSize; Recipe_GT.Gregtech_Recipe_Map.sChemicalPlantRecipes.add(aSpecialRecipe); @@ -1222,35 +1237,35 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addBlastRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int time, long eu, int aHeat) { Recipe_GT aSpecialRecipe = new Recipe_GT( - false, - aInputs, - aOutputs, - null, - new int[] {}, - aInputFluids, - aFluidOutputs, - time, - (int) eu, - aHeat); - + false, + aInputs, + aOutputs, + null, + new int[] {}, + aInputFluids, + aFluidOutputs, + time, + (int) eu, + aHeat); + int aSize = GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.size(); int aSize2 = aSize; GT_Recipe.GT_Recipe_Map.sBlastRecipes.add(aSpecialRecipe); aSize = GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.size(); return aSize > aSize2; - + } @Override public boolean addPyrolyseRecipe(ItemStack aInput, FluidStack aFluidInput, int intCircuit, ItemStack aOutput, FluidStack aFluidOutput, int aDuration, int aEUt) { if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || mPyroOven == null) { - return false; - } - try { - return (boolean) mPyroOven.invoke(GT_Values.RA, aInput, aFluidInput, intCircuit, aOutput, aFluidOutput, aDuration, aEUt); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } + return false; + } + try { + return (boolean) mPyroOven.invoke(GT_Values.RA, aInput, aFluidInput, intCircuit, aOutput, aFluidOutput, aDuration, aEUt); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } } @Override @@ -1308,7 +1323,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { new int[] { 10000, 10000, 10000 }, 400, 2); } return true; - + } @Override @@ -1318,14 +1333,14 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addMillingRecipe(Material aMat, int aEU) { - + ItemStack aOreStack = aMat.getOre(16); ItemStack aCrushedStack = aMat.getCrushed(16); - + ItemStack aMilledStackOres1 = aMat.getMilled(64); - ItemStack aMilledStackCrushed1 = aMat.getMilled(48); + ItemStack aMilledStackCrushed1 = aMat.getMilled(32); ItemStack aMilledStackOres2 = aMat.getMilled(48); - ItemStack aMilledStackCrushed2 = aMat.getMilled(32); + ItemStack aMilledStackCrushed2 = aMat.getMilled(16); ItemStack aMillingBall_Alumina = GregtechItemList.Milling_Ball_Alumina.get(0); ItemStack aMillingBall_Soapstone = GregtechItemList.Milling_Ball_Soapstone.get(0); @@ -1336,38 +1351,38 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { aOreStack, aMillingBall_Alumina }; - + ItemStack[] aInputsOre2 = new ItemStack[] { CI.getNumberedCircuit(11), aOreStack, aMillingBall_Soapstone }; - + ItemStack[] aInputsCrushed1 = new ItemStack[] { CI.getNumberedCircuit(10), aCrushedStack, aMillingBall_Alumina }; - + ItemStack[] aInputsCrushed2 = new ItemStack[] { CI.getNumberedCircuit(11), aCrushedStack, aMillingBall_Soapstone }; - + // Outputs ItemStack[] aOutputsOre1 = new ItemStack[] { aMilledStackOres1 }; - + ItemStack[] aOutputsOre2 = new ItemStack[] { aMilledStackOres2 }; - + ItemStack[] aOutputsCrushed1 = new ItemStack[] { aMilledStackCrushed1 }; - + ItemStack[] aOutputsCrushed2 = new ItemStack[] { aMilledStackCrushed2 }; @@ -1378,26 +1393,66 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { int aSize = Recipe_GT.Gregtech_Recipe_Map.sOreMillRecipes.mRecipeList.size(); int aSize2 = aSize; - + for (int i=0;i<4;i++) { Recipe_GT aOreRecipe = new Recipe_GT( - false, - aInputArray[i], - aOutputArray[i], - null, - new int[] {}, - null, - null, - aTime[i], - aEU, - 0); + false, + aInputArray[i], + aOutputArray[i], + null, + new int[] {}, + null, + null, + aTime[i], + aEU, + 0); Recipe_GT.Gregtech_Recipe_Map.sOreMillRecipes.add(aOreRecipe); } - + aSize = Recipe_GT.Gregtech_Recipe_Map.sOreMillRecipes.mRecipeList.size(); return aSize > aSize2; } + @Override + public boolean addFlotationRecipe(Materials aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU) { + return addFlotationRecipe(MaterialUtils.generateMaterialFromGtENUM(aMat), aXanthate, aInputFluids, aOutputFluids, aTime, aEU); + } + + @Override + public boolean addFlotationRecipe(Material aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU) { + + FlotationRecipeHandler.registerOreType(aMat); + int aSpecialValue = FlotationRecipeHandler.getHashForMaterial(aMat); + + int aSize = Recipe_GT.Gregtech_Recipe_Map.sFlotationCellRecipes.mRecipeList.size(); + int aSize2 = aSize; + + GT_Recipe aRecipe = new Recipe_GT( + false, + new ItemStack[] { + ItemUtils.getSimpleStack(aXanthate, 32), + aMat.getMilled(64), + aMat.getMilled(64), + aMat.getMilled(64), + aMat.getMilled(64), + }, + new ItemStack[] { + + }, + null, + new int[] {}, + aInputFluids, + aOutputFluids, + aTime, + aEU, + aSpecialValue); + + Recipe_GT.Gregtech_Recipe_Map.sFlotationCellRecipes.add(aRecipe); + aSize = Recipe_GT.Gregtech_Recipe_Map.sFlotationCellRecipes.mRecipeList.size(); + + return aSize > aSize2; + } + diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java index 2c9f1d1943..08901a1a3b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae.GregtechMTE_AlgaePondBase; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant.GregtechMTE_ChemicalPlant; @@ -22,7 +23,8 @@ public class GregtechAlgaeContent { // Chemical Plant GregtechItemList.ChemicalPlant_Controller.set(new GregtechMTE_ChemicalPlant(998, "chemicalplant.controller.tier.single", "ExxonMobil Chemical Plant").getStackForm(1L)); - + + GregtechItemList.Bus_Catalysts.set((new GT_MetaTileEntity_Hatch_Catalysts(31030, "hatch.catalysts", "Catalyst Housing")).getStackForm(1L)); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java index 9c5fb483a7..19c361be93 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java @@ -1,13 +1,22 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_MillingBalls; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IsaMill; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_FrothFlotationCell; public class GregtechIsaMill { public static void run(){ + + Logger.INFO("Gregtech5u Content | Registering Milling Content."); - GregtechItemList.Controller_IsaMill_Controller.set(new GregtechMetaTileEntity_IsaMill(31027, "gtpp.multimachine.isamill", "IsaMill Grinding Machine").getStackForm(1L)); + GregtechItemList.Controller_IsaMill.set(new GregtechMetaTileEntity_IsaMill(31027, "gtpp.multimachine.isamill", "IsaMill Grinding Machine").getStackForm(1L)); + GregtechItemList.Controller_Flotation_Cell.set(new GregtechMTE_FrothFlotationCell(31028, "gtpp.multimachine.flotationcell", "Flotation Cell Regulator").getStackForm(1L)); + + // Milling Ball Bus + GregtechItemList.Bus_Milling_Balls.set((new GT_MetaTileEntity_Hatch_MillingBalls(31029, "hatch.milling", "Ball Housing")).getStackForm(1L)); } diff --git a/src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java b/src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java new file mode 100644 index 0000000000..18fb286d15 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java @@ -0,0 +1,27 @@ +package gtPlusPlus.xmod.ic2; + +import gtPlusPlus.core.util.data.EnumUtils; +import ic2.core.init.InternalName; +import net.minecraftforge.common.util.EnumHelper; + +public class CustomInternalName { + + public static InternalName aHazmatHelmetEx; + public static InternalName aHazmatChestEx; + public static InternalName aHazmatLegsEx; + public static InternalName aHazmatBootsEx; + + public static void init() { + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatHelmetEx", new Class[] {}, new Object[] {}); + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatChestplateEx", new Class[] {}, new Object[] {}); + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatLeggingsEx", new Class[] {}, new Object[] {}); + EnumHelper.addEnum(InternalName.class, "itemArmorRubBootsEx", new Class[] {}, new Object[] {}); + aHazmatHelmetEx = EnumUtils.getValue(InternalName.class, "itemArmorHazmatHelmetEx"); + aHazmatChestEx = EnumUtils.getValue(InternalName.class, "itemArmorHazmatChestplateEx"); + aHazmatLegsEx = EnumUtils.getValue(InternalName.class, "itemArmorHazmatLeggingsEx"); + aHazmatBootsEx = EnumUtils.getValue(InternalName.class, "itemArmorRubBootsEx"); + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java b/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java index 862ba38748..8c8b2ea7ad 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java +++ b/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.ic2.item; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.item.wearable.hazmat.ItemArmorHazmatEx; import gtPlusPlus.core.lib.LoadedMods; import net.minecraft.item.ItemStack; @@ -52,6 +53,8 @@ public class IC2_Items { rotor_Material_2 = new ItemStack (new CustomKineticRotor(1)); rotor_Material_3 = new ItemStack (new CustomKineticRotor(2)); rotor_Material_4 = new ItemStack (new CustomKineticRotor(3)); + + ItemArmorHazmatEx.init(); } } diff --git a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java index 6c43e2b6e0..1f5f9abe1d 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java +++ b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.ic2.recipe; import static gtPlusPlus.core.recipe.RECIPES_Tools.*; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import gregtech.api.enums.*; @@ -12,10 +13,15 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.ic2.item.IC2_Items; +import ic2.core.Ic2Items; public class RECIPE_IC2 { @@ -84,6 +90,7 @@ public class RECIPE_IC2 { public static void initRecipes() { checkForEnderIO(); + addAdvancedHazmat(); if (!CORE.GTNH) { //Rotor Blade Recipes @@ -236,4 +243,84 @@ public class RECIPE_IC2 { } + + private static void addAdvancedHazmat() { + + ItemStack[] aBasicHazmatPieces = new ItemStack[] { + Ic2Items.hazmatHelmet.copy(), + Ic2Items.hazmatChestplate.copy(), + Ic2Items.hazmatLeggings.copy(), + Ic2Items.hazmatBoots.copy() + }; + + Material aRubber = MaterialUtils.generateMaterialFromGtENUM(Materials.Rubber); + ItemStack aYellowWool = ItemUtils.getSimpleStack(Blocks.wool, 4, 1); + ItemStack aBlackWool = ItemUtils.getSimpleStack(Blocks.wool, 15, 1); + ItemStack aCoilIC2 = Ic2Items.coil; + ItemStack aPlateCobalt = CI.getTieredComponentOfMaterial(Materials.Cobalt, OrePrefixes.plate, 1); + ItemStack aGearSmallSteel = CI.getTieredComponentOfMaterial(Materials.Steel, OrePrefixes.gearGtSmall, 1); + ItemStack aGearSmallAluminium = CI.getTieredComponentOfMaterial(Materials.Aluminium, OrePrefixes.gearGtSmall, 1); + ItemStack aGearPotin = ALLOY.TUMBAGA.getGear(1); + ItemStack aGearSiliconCarbide = ALLOY.SILICON_CARBIDE.getGear(1); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[0], + ItemUtils.getSimpleStack(aYellowWool,16), + ItemUtils.getSimpleStack(aPlateCobalt, 4), + ItemUtils.getSimpleStack(aCoilIC2, 8), + ItemUtils.getSimpleStack(aGearSmallAluminium, 4), + }, + aRubber.getFluid(144 * 4), + GregtechItemList.Armour_Hazmat_Advanced_Helmet.get(1), + 30 * 20, + MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[1], + ItemUtils.getSimpleStack(aYellowWool, 64), + ItemUtils.getSimpleStack(aCoilIC2, 32), + ItemUtils.getSimpleStack(aPlateCobalt, 16), + ItemUtils.getSimpleStack(aGearSiliconCarbide, 8), + }, + aRubber.getFluid(144 * 10), + GregtechItemList.Armour_Hazmat_Advanced_Chest.get(1), + 90 * 20, + MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[2], + ItemUtils.getSimpleStack(aYellowWool, 32), + ItemUtils.getSimpleStack(aCoilIC2, 16), + ItemUtils.getSimpleStack(aPlateCobalt, 8), + ItemUtils.getSimpleStack(aGearSiliconCarbide, 4), + }, + aRubber.getFluid(144 * 8), + GregtechItemList.Armour_Hazmat_Advanced_Legs.get(1), + 75 * 20, + MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[3], + ItemUtils.getSimpleStack(aBlackWool, 16), + ItemUtils.getSimpleStack(aCoilIC2, 6), + ItemUtils.getSimpleStack(aGearSmallSteel, 8), + ItemUtils.getSimpleStack(aGearPotin, 4), + }, + aRubber.getFluid(144 * 6), + GregtechItemList.Armour_Hazmat_Advanced_Boots.get(1), + 45 * 20, + MaterialUtils.getVoltageForTier(2)); + + } } diff --git a/src/resources/assets/gregtech/textures/gui/HatchNbtConsumable_2By2.png b/src/resources/assets/gregtech/textures/gui/HatchNbtConsumable_2By2.png Binary files differnew file mode 100644 index 0000000000..a669575ce1 --- /dev/null +++ b/src/resources/assets/gregtech/textures/gui/HatchNbtConsumable_2By2.png diff --git a/src/resources/assets/gregtech/textures/gui/HatchNbtConsumable_3By3.png b/src/resources/assets/gregtech/textures/gui/HatchNbtConsumable_3By3.png Binary files differnew file mode 100644 index 0000000000..7ed8d56b0e --- /dev/null +++ b/src/resources/assets/gregtech/textures/gui/HatchNbtConsumable_3By3.png diff --git a/src/resources/assets/gregtech/textures/gui/HatchNbtConsumable_4By4.png b/src/resources/assets/gregtech/textures/gui/HatchNbtConsumable_4By4.png Binary files differnew file mode 100644 index 0000000000..ccbea96e0c --- /dev/null +++ b/src/resources/assets/gregtech/textures/gui/HatchNbtConsumable_4By4.png diff --git a/src/resources/assets/ic2/lang/en_US.lang b/src/resources/assets/ic2/lang/en_US.lang index 3fb59885d4..9b44f2d14e 100644 --- a/src/resources/assets/ic2/lang/en_US.lang +++ b/src/resources/assets/ic2/lang/en_US.lang @@ -27,3 +27,9 @@ ic2.SulfuricLithium=Sulfuric Lithium Cell ic2.UraniumHexaFluoride=Uranium Hexafluoride Cell ic2.ThoriumTetraFluoride=Thorium Tetrafluoride Cell ic2.UraniumTetraFluoride=Uranium Tetrafluoride Cell + + +ic2.itemArmorHazmatHelmetEx=Advanced Hazmat Helmet +ic2.itemArmorHazmatChestplateEx=Advanced Hazmat Suit +ic2.itemArmorHazmatLeggingsEx=Advanced Hazmat Leggings +ic2.itemArmorRubBootsEx=Advanced Hazmat Boots
\ No newline at end of file diff --git a/src/resources/assets/ic2/textures/armor/hazmatEx_1.png b/src/resources/assets/ic2/textures/armor/hazmatEx_1.png Binary files differnew file mode 100644 index 0000000000..2275007fbe --- /dev/null +++ b/src/resources/assets/ic2/textures/armor/hazmatEx_1.png diff --git a/src/resources/assets/ic2/textures/armor/hazmatEx_2.png b/src/resources/assets/ic2/textures/armor/hazmatEx_2.png Binary files differnew file mode 100644 index 0000000000..758adafdf2 --- /dev/null +++ b/src/resources/assets/ic2/textures/armor/hazmatEx_2.png diff --git a/src/resources/assets/ic2/textures/items/itemArmorHazmatChestplateEx.png b/src/resources/assets/ic2/textures/items/itemArmorHazmatChestplateEx.png Binary files differnew file mode 100644 index 0000000000..742d1d7035 --- /dev/null +++ b/src/resources/assets/ic2/textures/items/itemArmorHazmatChestplateEx.png diff --git a/src/resources/assets/ic2/textures/items/itemArmorHazmatHelmetEx.png b/src/resources/assets/ic2/textures/items/itemArmorHazmatHelmetEx.png Binary files differnew file mode 100644 index 0000000000..5340375595 --- /dev/null +++ b/src/resources/assets/ic2/textures/items/itemArmorHazmatHelmetEx.png diff --git a/src/resources/assets/ic2/textures/items/itemArmorHazmatLeggingsEx.png b/src/resources/assets/ic2/textures/items/itemArmorHazmatLeggingsEx.png Binary files differnew file mode 100644 index 0000000000..80cdca9b23 --- /dev/null +++ b/src/resources/assets/ic2/textures/items/itemArmorHazmatLeggingsEx.png diff --git a/src/resources/assets/ic2/textures/items/itemArmorRubBootsEx.png b/src/resources/assets/ic2/textures/items/itemArmorRubBootsEx.png Binary files differnew file mode 100644 index 0000000000..901a8fbc35 --- /dev/null +++ b/src/resources/assets/ic2/textures/items/itemArmorRubBootsEx.png diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index 8064848316..df6fbaa5b3 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -3147,12 +3147,36 @@ item.milledSphalerite.name=Milled Sphalerite item.milledNickel.name=Milled Nickel item.milledPlatinum.name=Milled Platinum item.milledPentlandite.name=Milled Pentlandite - -item.BasicGenericChemItem.7.name=Alumina Milling Ball -item.BasicGenericChemItem.8.name=Soapstone Milling Ball - item.FrothZincflotation.name=Sphalerite Flotation Froth Cell item.FrothCopperflotation.name=Chalcopyrite Flotation Froth Cell item.FrothNickelflotation.name=Nickel Flotation Froth Cell item.FrothPlatinumflotation.name=Platinum Flotation Froth Cell -item.FrothPentlanditeflotation.name=Pentlandite Flotation Froth Cell
\ No newline at end of file +item.FrothPentlanditeflotation.name=Pentlandite Flotation Froth Cell +item.BasicGenericChemItem.7.name=Alumina Milling Ball +item.BasicGenericChemItem.8.name=Soapstone Milling Ball + +//Added 31/03/20 +item.BasicGenericChemItem.9.name=Sodium Ethoxide Dust +item.BasicGenericChemItem.10.name=Sodium Ethyl Xanthate Dust +item.BasicGenericChemItem.11.name=Potassium Ethyl Xanthate Dust +item.BasicGenericChemItem.12.name=Potassium Hydroxide Dust +item.CarbonDisulfide.name=Carbon Disulfide Cell +item.HydrogenSulfide.name=Hydrogen Sulfide Cell +item.BasicAgrichemItem.24.name=Pinecone +item.BasicAgrichemItem.25.name=Crushed Pine Materials +item.pineoil.name=Pine Oil Cell + +//Added 11/4/20 +item.milledRedstone.name=Milled Redstone +item.milledSpessartine.name=Milled Spessartine +item.milledGrossular.name=Milled Grossular +item.milledAlmandine.name=Milled Almandine +item.milledPyrope.name=Milled Pyrope +item.FrothRedstoneflotation.name=Redstone Flotation Froth Cell +item.FrothSpessartineflotation.name=Spessartine Flotation Froth Cell +item.FrothGrossularflotation.name=Grossular Flotation Froth Cell +item.FrothAlmandineflotation.name=Almandine Flotation Froth Cell +item.FrothPyropeflotation.name=Pyrope Flotation Froth Cell + +//Added 13/04/20 +item.T3RecipeSelector.name=Programmed Breakthrough Circuit
\ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FLOTATION.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FLOTATION.png Binary files differnew file mode 100644 index 0000000000..5965bfce89 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FLOTATION.png diff --git a/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_CATALYSTS.png b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_CATALYSTS.png Binary files differnew file mode 100644 index 0000000000..110e9ee38f --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_CATALYSTS.png diff --git a/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_CATALYSTS.png.mcmeta b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_CATALYSTS.png.mcmeta new file mode 100644 index 0000000000..24f863c95e --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_CATALYSTS.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":3 + } +}
\ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_MILLING_BALL_BUS.png b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_MILLING_BALL_BUS.png Binary files differnew file mode 100644 index 0000000000..c7b22a7ef8 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_MILLING_BALL_BUS.png diff --git a/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_MILLING_BALL_BUS.png.mcmeta b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_MILLING_BALL_BUS.png.mcmeta new file mode 100644 index 0000000000..5d86d73ad2 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/iconsets/OVERLAY_MILLING_BALL_BUS.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":5 + } +}
\ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/trees/leaves/leaves_pine.png b/src/resources/assets/miscutils/textures/blocks/trees/leaves/leaves_pine.png Binary files differnew file mode 100644 index 0000000000..68949e5f47 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/trees/leaves/leaves_pine.png diff --git a/src/resources/assets/miscutils/textures/blocks/trees/leaves/leaves_pine_opaque .png b/src/resources/assets/miscutils/textures/blocks/trees/leaves/leaves_pine_opaque .png Binary files differnew file mode 100644 index 0000000000..c7c0d6492f --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/trees/leaves/leaves_pine_opaque .png diff --git a/src/resources/assets/miscutils/textures/blocks/trees/saplings/sapling_pine.png b/src/resources/assets/miscutils/textures/blocks/trees/saplings/sapling_pine.png Binary files differnew file mode 100644 index 0000000000..f4c3ca84ac --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/trees/saplings/sapling_pine.png diff --git a/src/resources/assets/miscutils/textures/items/bioscience/MetaItem1/24.png b/src/resources/assets/miscutils/textures/items/bioscience/MetaItem1/24.png Binary files differnew file mode 100644 index 0000000000..0c065db4ce --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/bioscience/MetaItem1/24.png diff --git a/src/resources/assets/miscutils/textures/items/bioscience/MetaItem1/25.png b/src/resources/assets/miscutils/textures/items/bioscience/MetaItem1/25.png Binary files differnew file mode 100644 index 0000000000..168b15adb3 --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/bioscience/MetaItem1/25.png diff --git a/src/resources/assets/miscutils/textures/items/science/general/AdvancedCircuit.png b/src/resources/assets/miscutils/textures/items/science/general/AdvancedCircuit.png Binary files differnew file mode 100644 index 0000000000..8bcfa62ae4 --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/science/general/AdvancedCircuit.png diff --git a/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/10.png b/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/10.png Binary files differnew file mode 100644 index 0000000000..b50c781c6d --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/10.png diff --git a/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/11.png b/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/11.png Binary files differnew file mode 100644 index 0000000000..0656c10957 --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/11.png diff --git a/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/12.png b/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/12.png Binary files differnew file mode 100644 index 0000000000..3a32ed06fc --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/12.png diff --git a/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/9.png b/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/9.png Binary files differnew file mode 100644 index 0000000000..0c165f3e59 --- /dev/null +++ b/src/resources/assets/miscutils/textures/items/science/general/MetaItem1/9.png |