diff options
author | Martin Robertz <dream-master@gmx.net> | 2021-12-15 16:11:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-15 16:11:54 +0100 |
commit | 128c74faa99dfef8d056c1d82c6e4388b9d470e8 (patch) | |
tree | 2c84162154ba681232f86dffd4106db530236814 /src/main/java/gtPlusPlus/xmod/gregtech | |
parent | 47ce336f288a45aa3244c8ae1177499fa5080942 (diff) | |
parent | ff4b8c7068c2ea7d654e9beda00646d23e62b314 (diff) | |
download | GT5-Unofficial-128c74faa99dfef8d056c1d82c6e4388b9d470e8.tar.gz GT5-Unofficial-128c74faa99dfef8d056c1d82c6e4388b9d470e8.tar.bz2 GT5-Unofficial-128c74faa99dfef8d056c1d82c6e4388b9d470e8.zip |
Merge pull request #65 from GTNewHorizons/unified-build-script2
Move sources and resources
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech')
424 files changed, 89627 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java new file mode 100644 index 0000000000..a375f77cda --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -0,0 +1,612 @@ +package gtPlusPlus.xmod.gregtech; + +import static gtPlusPlus.core.recipe.common.CI.bits; +import static gtPlusPlus.core.util.minecraft.MaterialUtils.getMaterialName; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_ModHandler.RecipeBits; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.minecraft.multi.NoEUBonusMultiBehaviour; +import gtPlusPlus.api.objects.minecraft.multi.NoOutputBonusMultiBehaviour; +import gtPlusPlus.api.objects.minecraft.multi.NoSpeedBonusMultiBehaviour; +import gtPlusPlus.australia.gen.gt.WorldGen_GT_Australia; +import gtPlusPlus.core.handler.COMPAT_HANDLER; +import gtPlusPlus.core.handler.OldCircuitHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.CORE.ConfigSwitches; +import gtPlusPlus.core.material.ELEMENT; +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.core.util.reflect.AddGregtechRecipe; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.everglades.gen.gt.WorldGen_GT; +import gtPlusPlus.xmod.gregtech.api.enums.CustomOrePrefix; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; +import gtPlusPlus.xmod.gregtech.api.world.GTPP_Worldgen; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import gtPlusPlus.xmod.gregtech.loaders.Gregtech_Blocks; +import gtPlusPlus.xmod.gregtech.loaders.ProcessingAngleGrinder; +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.recipe.RecipeLoader_AlgaeFarm; +import gtPlusPlus.xmod.gregtech.recipes.RecipesToRemove; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; +import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechNitroDieselFix; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class HANDLER_GT { + + public static GT_Config mMaterialProperties = null; + + public static GTPP_Config sCustomWorldgenFile = null; + public static final List<WorldGen_GT> sWorldgenListEverglades = new ArrayList<WorldGen_GT>(); + public static final List<WorldGen_GT_Australia> sWorldgenListAustralia = new ArrayList<WorldGen_GT_Australia>(); + public static final List<GTPP_Worldgen> sCustomWorldgenList = new ArrayList<GTPP_Worldgen>(); + public static GT_MetaGenerated_Tool sMetaGeneratedToolInstance; + + public static void preInit(){ + + if (mMaterialProperties != null){ + GT_Materials.init(mMaterialProperties); + } + + if (ConfigSwitches.enableOldGTcircuits && !CORE.GTNH){ + OldCircuitHandler.preInit(); + } + + GregtechFluidHandler.run(); + } + + public static void init(){ + + //Load General Blocks and set up some Basic Meta Tile Entity states + Gregtech_Blocks.run(); + + //Add Custom Pipes, Wires and Cables. + GregtechConduits.run(); + + //Register Tile Entities + COMPAT_HANDLER.registerGregtechMachines(); + + + //Only loads if the config option is true (default: true) + if (CORE.ConfigSwitches.enableSkookumChoochers){ + sMetaGeneratedToolInstance= MetaGeneratedGregtechTools.getInstance(); + } + + if (ConfigSwitches.enableOldGTcircuits && !CORE.GTNH){ + OldCircuitHandler.init(); + } + + //Generates recipes for all gregtech smelting and alloy smelting combinations. + //RecipeGen_BlastSmelterGT.generateRecipes(); + //new RecipeGen_BlastSmelterGT_Ex(); + + } + + public static void postInit(){ + + //Only loads if the config option is true (default: true) + if (CORE.ConfigSwitches.enableSkookumChoochers){ + new ProcessingToolHeadChoocher().run(); + } + new ProcessingAngleGrinder().run(); + new ProcessingElectricSnips().run(); + new ProcessingElectricButcherKnife().run(); + new ProcessingElectricLighter().run(); + + if (CORE.ConfigSwitches.enableNitroFix){ + GregtechNitroDieselFix.run(); + } + + if (ConfigSwitches.enableOldGTcircuits && !CORE.GTNH){ + OldCircuitHandler.postInit(); + } + + // Register custom singles to the PA + AddCustomMachineToPA.register(); + + + // Register the No-Bonus Special Behaviour. + Multiblock_API.registerSpecialMultiBehaviour(new NoOutputBonusMultiBehaviour()); + Multiblock_API.registerSpecialMultiBehaviour(new NoSpeedBonusMultiBehaviour()); + Multiblock_API.registerSpecialMultiBehaviour(new NoEUBonusMultiBehaviour()); + + //Register some custom recipe maps for any enabled multiblocks. + //MultiblockRecipeMapHandler.run(); + + if (GregtechItemList.Circuit_BioRecipeSelector.hasBeenSet()) { + for (int i = 1; i <= 24; i++) { + GregTech_API.registerConfigurationCircuit(CI.getNumberedBioCircuit(i), 0); + } + } + + if (GregtechItemList.Circuit_T3RecipeSelector.hasBeenSet()) { + for (int i = 1; i <= 24; i++) { + GregTech_API.registerConfigurationCircuit(CI.getNumberedAdvancedCircuit(i), 3); + } + } + } + + public static void onLoadComplete(FMLLoadCompleteEvent event) { + removeCrudeTurbineRotors(); + //cleanAssemblyLineRecipeMap(); + if (ConfigSwitches.enableHarderRecipesForHighTierCasings) { + removeOldHighTierCasingRecipes(); + } + RecipesToRemove.go(); + convertPyroToCokeOven(); + Meta_GT_Proxy.fixIC2FluidNames(); + RecipeLoader_AlgaeFarm.generateRecipes(); + } + + public static void addNewOrePrefixes() { + for (CustomOrePrefix aPrefixTest : CustomOrePrefix.values()) { + Logger.INFO("Adding "+aPrefixTest.name()+" to OrePrefixes Enum."); + Logger.INFO("Injecting: "+aPrefixTest.addToEnum()); + } + } + + private static void convertPyroToCokeOven() { + if (ReflectionUtils.doesFieldExist(GT_Recipe.GT_Recipe_Map.class, "sPyrolyseRecipes")) { + int aCount = 0; + GT_Recipe_Map aMap = StaticFields59.getPyrolyseRecipeMap(); + if (aMap != null) { + for (GT_Recipe g : aMap.mRecipeList) { + if (AddGregtechRecipe.importPyroRecipe(g)) { + aCount++; + } + } + Logger.INFO("Converted "+aCount+" Pyrolyse recipes into Industrial Coke Oven recipes."); + } + } + } + + private static GT_Recipe replaceItemInRecipeWithAnother(GT_Recipe aRecipe, ItemStack aExisting, ItemStack aNewItem) { + ItemStack[] aInputItemsCopy = aRecipe.mInputs; + String aOutputName = ItemUtils.getItemName(aRecipe.mOutputs[0]); + boolean aDidChange = false; + Logger.INFO("Attempting to Modify Recipe for "+aOutputName); + for (int i=0;i<aRecipe.mInputs.length;i++) { + ItemStack aCurrentInputSlot = aRecipe.mInputs[i]; + if (aCurrentInputSlot != null) { + if (GT_Utility.areStacksEqual(aCurrentInputSlot, aExisting, true)) { + aInputItemsCopy[i] = ItemUtils.getSimpleStack(aNewItem, aCurrentInputSlot.stackSize); + aDidChange = true; + } + } + } + if (aDidChange) { + aRecipe.mInputs = aInputItemsCopy; + Logger.INFO("Modifed Recipe for "+aOutputName); + return aRecipe; + } + else { + Logger.INFO("Failed to Modify Recipe for "+aOutputName); + return aRecipe; + } + } + + private static void updateRecipeMap(GT_Recipe aOld, GT_Recipe aNew, GT_Recipe_Map aMap) { + RecipeUtils.removeGtRecipe(aOld, aMap); + RecipeUtils.addGtRecipe(aNew, aMap); + Logger.INFO("Updating recipe map: "+aMap.mNEIName); + Logger.INFO("Removed Recipe with hash: "+aOld.hashCode()); + Logger.INFO("Added Recipe with hash: "+aNew.hashCode()); + + } + + private static void removeOldHighTierCasingRecipes() { + + Logger.INFO("Trying to appropriately retier GT Machine Hulls/Casings from LuV+"); + final Object aHardCasingsTest = StaticFields59.getFieldFromGregtechProxy("mHardMachineCasings"); + + boolean aHardCasings = aHardCasingsTest != null ? (boolean) aHardCasingsTest : false; + + Logger.INFO("Are Hard casings/hulls enabled within GT? "+(aHardCasingsTest == null ? "Version does not support config option" : aHardCasings)); + + // Static objects to save memory + ItemStack aCasing_LUV = CI.machineCasing_LuV; + ItemStack aCasing_ZPM = CI.machineCasing_ZPM; + ItemStack aCasing_UV = CI.machineCasing_UV; + ItemStack aCasing_MAX = CI.machineCasing_MAX; + + ItemStack aHull_LUV = CI.machineHull_LuV; + ItemStack aHull_ZPM = CI.machineHull_ZPM; + ItemStack aHull_UV = CI.machineHull_UV; + ItemStack aHull_MAX = CI.machineHull_MAX; + + int aTier_LUV = 5; + int aTier_ZPM = 6; + int aTier_UV = 7; + //int aTier_MAX = 8; + + + ItemStack[] aCasings = new ItemStack[] {aCasing_LUV, aCasing_ZPM, aCasing_UV, aCasing_MAX}; + ItemStack[] aHulls = new ItemStack[] {aHull_LUV, aHull_ZPM, aHull_UV, aHull_MAX}; + + // Remove Hand Crafting Recipes + + // Casings + Logger.INFO("Removing shaped crafting for Casings."); + RecipeUtils.removeRecipeByOutput(aCasing_LUV); + RecipeUtils.removeRecipeByOutput(aCasing_ZPM); + RecipeUtils.removeRecipeByOutput(aCasing_UV); + //RecipeUtils.removeRecipeByOutput(aCasing_MAX); + + // Hulls + Logger.INFO("Removing shaped crafting for Hulls."); + RecipeUtils.removeRecipeByOutput(aHull_LUV); + RecipeUtils.removeRecipeByOutput(aHull_ZPM); + RecipeUtils.removeRecipeByOutput(aHull_UV); + //RecipeUtils.removeRecipeByOutput(aHull_MAX); + + // Modify Assembler Recipes + Logger.INFO("Attempting to modify existing Assembly recipes for Casings & Hulls, this should provide best compatibility."); + int aUpdateCount = 0; + + AutoMap<Pair<GT_Recipe, GT_Recipe>> aDataToModify = new AutoMap<Pair<GT_Recipe, GT_Recipe>>(); + + + Outer :for (final GT_Recipe r : GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.mRecipeList) { + + if (r != null && r.mOutputs != null && r.mOutputs.length > 0) { + + GT_Recipe aOldRecipeCopy = r; + GT_Recipe aNewRecipe = r.copy(); + + //Casings + Inner : for (ItemStack aCasingObject : aCasings) { + if (GT_Utility.areStacksEqual(aOldRecipeCopy.mOutputs[0], aCasingObject)) { + String aOutputName = ItemUtils.getItemName(aOldRecipeCopy.mOutputs[0]); + Logger.INFO("Attempting to Modify Assembly Recipe for "+aOutputName); + //Replace Chrome + if (GT_Utility.areStacksEqual(aOldRecipeCopy.mOutputs[0], aCasing_LUV)) { + aNewRecipe = replaceItemInRecipeWithAnother(aOldRecipeCopy, ItemUtils.getItemStackOfAmountFromOreDict("plateChrome", 1), ELEMENT.getInstance().SELENIUM.getPlate(1)); + aDataToModify.put(new Pair<GT_Recipe, GT_Recipe>(r, aNewRecipe)); + aUpdateCount++; + continue Outer; + } + //Replace Iridium + else if (GT_Utility.areStacksEqual(aOldRecipeCopy.mOutputs[0], aCasing_ZPM)) { + aNewRecipe = replaceItemInRecipeWithAnother(aOldRecipeCopy, ItemUtils.getItemStackOfAmountFromOreDict("plateIridium", 1), CI.getPlate(aTier_ZPM, 1)); + aDataToModify.put(new Pair<GT_Recipe, GT_Recipe>(r, aNewRecipe)); + aUpdateCount++; + continue Outer; + } + //Replace Osmium + else if (GT_Utility.areStacksEqual(aOldRecipeCopy.mOutputs[0], aCasing_UV)) { + aNewRecipe = replaceItemInRecipeWithAnother(aOldRecipeCopy, ItemUtils.getItemStackOfAmountFromOreDict("plateOsmium", 1), CI.getPlate(aTier_UV, 1)); + aDataToModify.put(new Pair<GT_Recipe, GT_Recipe>(r, aNewRecipe)); + aUpdateCount++; + continue Outer; + } + //else if (aOldRecipeCopy.mOutputs[0] == aCasing_LUV) { + // aOldRecipeCopy = replaceItemInRecipeWithAnother(aOldRecipeCopy, ItemUtils.getItemStackOfAmountFromOreDict("plateChrome", 8), CI.getPlate(aTier_MAX, 8)); + // updateRecipeMap(aOldRecipeCopy, aNewRecipe, GT_Recipe.GT_Recipe_Map.sAssemblerRecipes); + //} + else { + continue Inner; + } + } + } + + //Hulls + Inner : for (ItemStack aHullObject : aHulls) { + if (GT_Utility.areStacksEqual(aOldRecipeCopy.mOutputs[0], aHullObject)) { + String aOutputName = ItemUtils.getItemName(aOldRecipeCopy.mOutputs[0]); + Logger.INFO("Attempting to Modify Assembly Recipe for "+aOutputName); + //Replace Chrome + if (GT_Utility.areStacksEqual(aOldRecipeCopy.mOutputs[0], aHull_LUV)) { + aNewRecipe = replaceItemInRecipeWithAnother(aOldRecipeCopy, ItemUtils.getItemStackOfAmountFromOreDict("plateChrome", 1), ELEMENT.getInstance().SELENIUM.getPlate(1)); + aDataToModify.put(new Pair<GT_Recipe, GT_Recipe>(r, aNewRecipe)); + aUpdateCount++; + continue Outer; + } + //Replace Iridium + else if (GT_Utility.areStacksEqual(aOldRecipeCopy.mOutputs[0], aHull_ZPM)) { + aNewRecipe = replaceItemInRecipeWithAnother(aOldRecipeCopy, ItemUtils.getItemStackOfAmountFromOreDict("plateIridium", 1), CI.getPlate(aTier_ZPM, 1)); + aDataToModify.put(new Pair<GT_Recipe, GT_Recipe>(r, aNewRecipe)); + aUpdateCount++; + continue Outer; + } + //Replace Osmium + else if (GT_Utility.areStacksEqual(aOldRecipeCopy.mOutputs[0], aHull_UV)) { + aNewRecipe = replaceItemInRecipeWithAnother(aOldRecipeCopy, ItemUtils.getItemStackOfAmountFromOreDict("plateOsmium", 1), CI.getPlate(aTier_UV, 1)); + aDataToModify.put(new Pair<GT_Recipe, GT_Recipe>(r, aNewRecipe)); + aUpdateCount++; + continue Outer; + } + //else if (aOldRecipeCopy.mOutputs[0] == aHull_LUV) { + // aOldRecipeCopy = replaceItemInRecipeWithAnother(aOldRecipeCopy, ItemUtils.getItemStackOfAmountFromOreDict("plateChrome", 8), CI.getPlate(aTier_MAX, 8)); + // updateRecipeMap(aOldRecipeCopy, aNewRecipe, GT_Recipe.GT_Recipe_Map.sAssemblerRecipes); + //} + else { + continue Inner; + } + } + } + } + } + + Logger.INFO("There is "+aUpdateCount+" recipes flagged for update."); + + if (aUpdateCount > 0) { + for (Pair<GT_Recipe, GT_Recipe> g : aDataToModify) { + updateRecipeMap(g.getKey(), g.getValue(), GT_Recipe.GT_Recipe_Map.sAssemblerRecipes); + } + Logger.INFO("Modified "+aUpdateCount+" recipes."); + } + + + + Logger.INFO("Adding new Shaped recipes for Casings."); + GT_ModHandler.addCraftingRecipe(ItemList.Casing_LuV.get(1), bits, new Object[]{"PPP", "PwP", "PPP", 'P', ELEMENT.getInstance().SELENIUM.getPlate(1)}); + GT_ModHandler.addCraftingRecipe(ItemList.Casing_ZPM.get(1), bits, new Object[]{"PPP", "PwP", "PPP", 'P', CI.getPlate(aTier_ZPM, 1)}); + GT_ModHandler.addCraftingRecipe(ItemList.Casing_UV.get(1), bits, new Object[]{"PPP", "PwP", "PPP", 'P', CI.getPlate(aTier_UV, 1)}); + //GT_ModHandler.addCraftingRecipe(ItemList.Casing_MAX.get(1), bits, new Object[]{"PPP", "PwP", "PPP", 'P', OrePrefixes.plate.get(Materials.Neutronium)}); + + if (!aHardCasings) { + Logger.INFO("Adding new easy Shaped recipes for Hulls."); + GT_ModHandler.addCraftingRecipe(ItemList.Hull_LuV.get(1), + RecipeBits.NOT_REMOVABLE | RecipeBits.BUFFERED, new Object[]{"CMC", 'M', ItemList.Casing_LuV, 'C', + OrePrefixes.cableGt01.get(Materials.VanadiumGallium)}); + GT_ModHandler.addCraftingRecipe(ItemList.Hull_ZPM.get(1), + RecipeBits.NOT_REMOVABLE | RecipeBits.BUFFERED, + new Object[]{"CMC", 'M', ItemList.Casing_ZPM, 'C', OrePrefixes.cableGt01.get(Materials.Naquadah)}); + GT_ModHandler.addCraftingRecipe(ItemList.Hull_UV.get(1), + RecipeBits.NOT_REMOVABLE | RecipeBits.BUFFERED, new Object[]{"CMC", 'M', ItemList.Casing_UV, 'C', + OrePrefixes.wireGt04.get(Materials.NaquadahAlloy)}); + /*GT_ModHandler.addCraftingRecipe(ItemList.Hull_MAX.get(1), + RecipeBits.NOT_REMOVABLE | RecipeBits.BUFFERED, new Object[]{"CMC", 'M', ItemList.Casing_MAX, 'C', + OrePrefixes.wireGt01.get(Materials.Superconductor)});*/ + } + else { + + + Materials aPolytetrafluoroethylene = MaterialUtils.getMaterial("Polytetrafluoroethylene", "Plastic"); + + Logger.INFO("Adding new hard Shaped recipes for Hulls."); + GT_ModHandler.addCraftingRecipe(ItemList.Hull_LuV.get(1), + RecipeBits.NOT_REMOVABLE | RecipeBits.BUFFERED, + new Object[]{"PHP", "CMC", 'M', ItemList.Casing_LuV, 'C', + OrePrefixes.cableGt01.get(Materials.VanadiumGallium), 'H', + ELEMENT.getInstance().SELENIUM.getPlate(1), 'P', OrePrefixes.plate.get(Materials.Plastic)}); + GT_ModHandler.addCraftingRecipe(ItemList.Hull_ZPM.get(1), + RecipeBits.NOT_REMOVABLE | RecipeBits.BUFFERED, + new Object[]{"PHP", "CMC", 'M', ItemList.Casing_ZPM, 'C', + OrePrefixes.cableGt01.get(Materials.Naquadah), 'H', + CI.getPlate(aTier_ZPM, 1), 'P', + OrePrefixes.plate.get(aPolytetrafluoroethylene)}); + GT_ModHandler.addCraftingRecipe(ItemList.Hull_UV.get(1), + RecipeBits.NOT_REMOVABLE | RecipeBits.BUFFERED, + new Object[]{"PHP", "CMC", 'M', ItemList.Casing_UV, 'C', + OrePrefixes.wireGt04.get(Materials.NaquadahAlloy), 'H', + CI.getPlate(aTier_UV, 1), 'P', + OrePrefixes.plate.get(aPolytetrafluoroethylene)}); + /*GT_ModHandler.addCraftingRecipe(ItemList.Hull_MAX.get(1), + RecipeBits.NOT_REMOVABLE | RecipeBits.BUFFERED, + new Object[]{"PHP", "CMC", 'M', ItemList.Casing_MAX, 'C', + OrePrefixes.wireGt01.get(Materials.Superconductor), 'H', + OrePrefixes.plate.get(Materials.Neutronium), 'P', + OrePrefixes.plate.get(Materials.Polytetrafluoroethylene)});*/ + } + + + + //Casings + + /*GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Chrome, 8L), + ItemList.Circuit_Integrated.getWithDamage(0L, 8L, new Object[0]), + ItemList.Casing_LuV.get(1), 50, 16); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 8L), + ItemList.Circuit_Integrated.getWithDamage(0L, 8L, new Object[0]), + ItemList.Casing_ZPM.get(1), 50, 16); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 8L), + ItemList.Circuit_Integrated.getWithDamage(0L, 8L, new Object[0]), + ItemList.Casing_UV.get(1), 50, 16); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 8L), + ItemList.Circuit_Integrated.getWithDamage(0L, 8L, new Object[0]), + ItemList.Casing_MAX.get(1), 50, 16); */ + + + + //Hulls + + //Hard Hulls + /*GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.VanadiumGallium, 2L), + ItemList.Casing_LuV.get(1), Materials.Plastic.getMolten(288L), + ItemList.Hull_LuV.get(1), 50, 16); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Naquadah, 2L), + ItemList.Casing_ZPM.get(1), Materials.Polytetrafluoroethylene.getMolten(288L), + ItemList.Hull_ZPM.get(1), 50, 16); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2L), + ItemList.Casing_UV.get(1), Materials.Polytetrafluoroethylene.getMolten(288L), + ItemList.Hull_UV.get(1), 50, 16); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 2L), + ItemList.Casing_MAX.get(1), Materials.Polytetrafluoroethylene.getMolten(288L), + ItemList.Hull_MAX.get(1), 50, 16);*/ + + //Easy Hulls + /*GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.VanadiumGallium, 2L), + ItemList.Casing_LuV.get(1), ItemList.Hull_LuV.get(1), 50, 16); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Naquadah, 2L), + ItemList.Casing_ZPM.get(1), ItemList.Hull_ZPM.get(1), 50, 16); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2L), + ItemList.Casing_UV.get(1), ItemList.Hull_UV.get(1), 50, 16); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 2L), + ItemList.Casing_MAX.get(1), ItemList.Hull_MAX.get(1), 50, 16);*/ + } + + private static int removeCrudeTurbineRotors() { + int aRemoved = 0; + int CUT = CORE.turbineCutoffBase; + Item aU; + Collection<GT_Recipe> aAssRecipes = GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.mRecipeList; + //170, 172, 174, 176 + if (aAssRecipes.size() > 0 && (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH)) { + recipe: for (GT_Recipe aG : aAssRecipes) { + if (aG.mOutputs != null && aG.mOutputs.length > 0) { + outputs: for (ItemStack aI : aG.mOutputs) { + if (aI == null) { + continue; + } + aU = aI.getItem(); + if (aU == null) { + continue; + } + if (aU instanceof GT_MetaGenerated_Tool_01) { + int aMeta = aI.getItemDamage(); + //Logger.INFO("Found assembler recipe outputting a GT Tool with a meta value of "+aMeta); + if (aMeta >= 170 && aMeta <= 176) { + //Found a Turbine + int aCutoff = aMeta == 170 ? CUT : (aMeta == 172 ? CUT*2 : (aMeta == 174 ? CUT*3 : CUT*4)); + String aType = aMeta == 170 ? "Small " : (aMeta == 172 ? "" : (aMeta == 174 ? "Large " : "Huge ")); + Materials aMainMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(aI); + Materials aSecondaryMaterial = GT_MetaGenerated_Tool.getSecondaryMaterial(aI); + long rotorDurabilityMax = GT_MetaGenerated_Tool.getToolMaxDamage(aI); + //Logger.INFO("Found "+aType+"Turbine made out of "+getMaterialName(aMainMaterial)+", using "+getMaterialName(aSecondaryMaterial)); + if (rotorDurabilityMax < aCutoff) { + Logger.WARNING("[Turbine Cleanup] "+getMaterialName(aMainMaterial)+" "+aType+"Turbines have "+rotorDurabilityMax+", which is below the cutoff durability of "+aCutoff+", disabling."); + aG.mEnabled = false; + aG.mHidden = true; + aG.mCanBeBuffered = false; + aRemoved++; + } + else { + break outputs; + } + + } + else { + continue outputs; + } + } + else { + continue outputs; + } + } + } + else { + continue recipe; + } + } + } + + Logger.INFO("Removed "+aRemoved+" useless Turbines."); + + return aRemoved; + } + + /** + * Should clean out any invalid Assembly Line recipes, if the map actually exists. + * Prevents NPE's being thrown by GT's AL handler. (Fucking Annoying) + * @return - Amount of Recipes removed, which were invalid in some way. + */ + private static int cleanAssemblyLineRecipeMap() { + GT_Recipe_Map g = StaticFields59.sAssemblylineVisualRecipes; + if (g == null) { + return 0; + } + else { + AutoMap<GT_Recipe> aNewMap = new AutoMap<GT_Recipe>(); + AutoMap<GT_Recipe> aBadRecipeTempMap = new AutoMap<GT_Recipe>(); + for (GT_Recipe r : g.mRecipeList) { + if (r != null) { + if (r.mOutputs == null || r.mOutputs.length == 0 || r.mOutputs[0] == null) { + aBadRecipeTempMap.put(r.copy()); + continue; + } + else { + aNewMap.put(r.copy()); + } + } + } + if (aNewMap.size() > 0) { + g.mRecipeList.clear(); + for (GT_Recipe i : aNewMap) { + g.add(i); + } + } + if (aBadRecipeTempMap.size() > 0) { + Logger.INFO("Found "+aBadRecipeTempMap.size()+" bad Assembly Line Recipes, attempting to dump all data about them."); + Logger.INFO("This data should be given to the mod author for the recipe in question."); + for (GT_Recipe i : aBadRecipeTempMap) { + if (i == null) { + Logger.INFO("Found NULL recipe. Impossible to determine who added this one. Please Report to Alkalus on Github."); + } + else { + if (i.mOutputs == null || i.mOutputs.length == 0 || i.mOutputs[0] == null) { + Logger.INFO("Found recipe with NULL output array, this will cause some issues. Attempting to determine other info about recipe."); + if (i.mInputs != null && i.mInputs.length > 0) { + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(i.mInputs)); + } + else { + Logger.INFO("Recipe had no valid inputs."); + } + Logger.INFO("Time: "+i.mDuration); + Logger.INFO("EU/T: "+i.mEUt); + Logger.INFO("Special: "+i.mSpecialValue); + } + else { + Logger.INFO("Found bad recipe, Attempting to determine other info."); + if (i.mInputs != null && i.mInputs.length > 0) { + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(i.mInputs)); + } + else { + Logger.INFO("Recipe had no valid inputs."); + } + if (i.mOutputs != null && i.mOutputs.length > 0) { + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(i.mOutputs)); + } + else { + Logger.INFO("Recipe had no valid outputs."); + } + Logger.INFO("Time: "+i.mDuration); + Logger.INFO("EU/T: "+i.mEUt); + Logger.INFO("Special: "+i.mSpecialValue); + } + } + } + } + else { + Logger.INFO("No bad Assembly Line recipes found, this is great news!"); + } + return aBadRecipeTempMap.size(); + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java new file mode 100644 index 0000000000..4ec4589c03 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItem.java @@ -0,0 +1,55 @@ +package gtPlusPlus.xmod.gregtech.api.energy; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Provides the ability to store energy on the implementing item. + * + * The item should have a maximum damage of 13. + */ +public interface IC2ElectricItem { + /** + * Determine if the item can be used in a machine or as an armor part to supply energy. + * + * @return Whether the item can supply energy + */ + boolean canProvideEnergy(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy greater than 0. + * + * @return Item ID to use + */ + Item getChargedItem(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy of 0. + * + * @return Item ID to use + */ + Item getEmptyItem(ItemStack itemStack); + + /** + * Get the item's maximum charge energy in EU. + * + * @return Maximum charge energy + */ + double getMaxCharge(ItemStack itemStack); + + /** + * Get the item's tier, lower tiers can't send energy to higher ones. + * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. + * + * @return Item's tier + */ + int getTier(ItemStack itemStack); + + /** + * Get the item's transfer limit in EU per transfer operation. + * + * @return Transfer limit + */ + double getTransferLimit(ItemStack itemStack); +} + diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java new file mode 100644 index 0000000000..8bf42578cc --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/energy/IC2ElectricItemManager.java @@ -0,0 +1,95 @@ +package gtPlusPlus.xmod.gregtech.api.energy; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +/** + * This interface specifies a manager to handle the various tasks for electric items. + * + * The default implementation does the following: + * - store and retrieve the charge + * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account + * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) + * - update and manage the damage value for the visual charge indicator + * + * @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the + * default implementations through ElectricItem.rawManager. The default implementation is designed + * to minimize its dependency on its own constraints/structure and delegates most work back to the + * more atomic features in the gateway manager. + */ +public interface IC2ElectricItemManager { + /** + * Charge an item with a specified amount of energy. + * + * @param itemStack electric item's stack + * @param amount amount of energy to charge in EU + * @param tier tier of the charging device, has to be at least as high as the item to charge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param simulate don't actually change the item, just determine the return value + * @return Energy transferred into the electric item + */ + double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate); + + /** + * Discharge an item by a specified amount of energy + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param tier tier of the discharging device, has to be at least as high as the item to discharge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param externally use the supplied item externally, i.e. to power something else as if it was a battery + * @param simulate don't actually discharge the item, just determine the return value + * @return Energy retrieved from the electric item + */ + double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate); + + /** + * Determine the charge level for the specified item. + * + * @param itemStack ItemStack containing the electric item + * @return charge level in EU + */ + double getCharge(ItemStack stack); + + /** + * Determine if the specified electric item has at least a specific amount of EU. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * BatPacks are not taken into account. + * + * @param itemStack electric item's stack + * @param amount minimum amount of energy required + * @return true if there's enough energy + */ + boolean canUse(ItemStack stack, double amount); + + /** + * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param entity entity holding the item + * @return true if the operation succeeded + */ + boolean use(ItemStack stack, double amount, EntityLivingBase entity); + + /** + * Charge an item from the BatPack a player is wearing. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * use() already contains this functionality. + * + * @param itemStack electric item's stack + * @param entity entity holding the item + */ + void chargeFromArmor(ItemStack stack, EntityLivingBase entity); + + /** + * Get the tool tip to display for electric items. + * + * @param itemStack ItemStack to determine the tooltip for + * @return tool tip string or null for none + */ + String getToolTip(ItemStack stack); + + // TODO: add tier getter +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomGtTextures.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomGtTextures.java new file mode 100644 index 0000000000..554983c41c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomGtTextures.java @@ -0,0 +1,81 @@ +package gtPlusPlus.xmod.gregtech.api.enums; + +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_RenderedTexture; + +import gtPlusPlus.core.lib.CORE; + +public class CustomGtTextures { + public enum ItemIcons implements IIconContainer, Runnable { + VOID, // The Empty Texture + RENDERING_ERROR, + PUMP, + SKOOKUMCHOOCHER; + + public static final ITexture[] ERROR_RENDERING = new ITexture[]{new GT_RenderedTexture(RENDERING_ERROR)}; + + protected IIcon mIcon, mOverlay; + + private ItemIcons() { + GregTech_API.sGTItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + "iconsets/" + this); + this.mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + "iconsets/" + this + "_OVERLAY"); + } + + public static class CustomIcon implements IIconContainer, Runnable { + protected IIcon mIcon, mOverlay; + protected String mIconName; + + public CustomIcon(final String aIconName) { + this.mIconName = aIconName; + GregTech_API.sGTItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + this.mIconName); + this.mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.RES_PATH_ITEM + this.mIconName + "_OVERLAY"); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomOrePrefix.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomOrePrefix.java new file mode 100644 index 0000000000..9647b00578 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/CustomOrePrefix.java @@ -0,0 +1,112 @@ +package gtPlusPlus.xmod.gregtech.api.enums; + +import static gregtech.api.enums.GT_Values.B; + +import gregtech.api.enums.OrePrefixes; +import net.minecraftforge.common.util.EnumHelper; + +public enum CustomOrePrefix { + + milled("Milled Ores", "Milled ", " Ore", true, true, false, false, false, false, false, false, false, true, B[3], -1, 64, -1); + + private final String mRegularLocalName; + private final String mLocalizedMaterialPre; + private final String mLocalizedMaterialPost; + private final boolean mIsUnificatable; + private final boolean mIsMaterialBased; + private final boolean mIsSelfReferencing; + private final boolean mIsContainer; + private final boolean mDontUnificateActively; + private final boolean mIsUsedForBlocks; + private final boolean mAllowNormalRecycling; + private final boolean mGenerateDefaultItem; + private final boolean mIsEnchantable; + private final boolean mIsUsedForOreProcessing; + private final int mMaterialGenerationBits; + private final long mMaterialAmount; + private final int mDefaultStackSize; + private final int mTextureindex; + + private OrePrefixes mSelfReference; + + private CustomOrePrefix( + String aRegularLocalName, + String aLocalizedMaterialPre, + String aLocalizedMaterialPost, + boolean aIsUnificatable, + boolean aIsMaterialBased, + boolean aIsSelfReferencing, + boolean aIsContainer, + boolean aDontUnificateActively, + boolean aIsUsedForBlocks, + boolean aAllowNormalRecycling, + boolean aGenerateDefaultItem, + boolean aIsEnchantable, + boolean aIsUsedForOreProcessing, + int aMaterialGenerationBits, + long aMaterialAmount, + int aDefaultStackSize, + int aTextureindex) { + + mRegularLocalName = aRegularLocalName; + mLocalizedMaterialPre = aLocalizedMaterialPre; + mLocalizedMaterialPost = aLocalizedMaterialPost; + mIsUnificatable = aIsUnificatable; + mIsMaterialBased = aIsMaterialBased; + mIsSelfReferencing = aIsSelfReferencing; + mIsContainer = aIsContainer; + mDontUnificateActively = aDontUnificateActively; + mIsUsedForBlocks = aIsUsedForBlocks; + mAllowNormalRecycling = aAllowNormalRecycling; + mGenerateDefaultItem = aGenerateDefaultItem; + mIsEnchantable = aIsEnchantable; + mIsUsedForOreProcessing = aIsUsedForOreProcessing; + mMaterialGenerationBits = aMaterialGenerationBits; + mMaterialAmount = aMaterialAmount; + mDefaultStackSize = aDefaultStackSize; + mTextureindex = aTextureindex; + + } + + public final boolean addToEnum() { + + mSelfReference = EnumHelper.addEnum(OrePrefixes.class, this.name(), + new Class[] { + String.class, + String.class, String.class, boolean.class, + boolean.class, boolean.class, boolean.class, + boolean.class, boolean.class, boolean.class, + boolean.class, boolean.class, boolean.class, + int.class, long.class, int.class, int.class + }, + new Object[] { + mRegularLocalName, + mLocalizedMaterialPre, + mLocalizedMaterialPost, + mIsUnificatable, + mIsMaterialBased, + mIsSelfReferencing, + mIsContainer, + mDontUnificateActively, + mIsUsedForBlocks, + mAllowNormalRecycling, + mGenerateDefaultItem, + mIsEnchantable, + mIsUsedForOreProcessing, + mMaterialGenerationBits, + mMaterialAmount, + mDefaultStackSize, + mTextureindex}); + + return mSelfReference != null; + } + + public static final boolean checkEntryWasAdded(CustomOrePrefix aCustomPrefixObject) { + return aCustomPrefixObject.mSelfReference != null; + } + + public OrePrefixes get() { + return mSelfReference; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java new file mode 100644 index 0000000000..8c814489f2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -0,0 +1,903 @@ +package gtPlusPlus.xmod.gregtech.api.enums; + +import static gregtech.api.enums.GT_Values.W; + +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.api.interfaces.GregtechItemContainer; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Class containing all non-OreDict Items of GregTech. + */ +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, + Electric_Pump_LuV, Electric_Pump_ZPM, Electric_Pump_UV, Electric_Pump_MAX, + Conveyor_Module_LuV, Conveyor_Module_ZPM, Conveyor_Module_UV, Conveyor_Module_MAX, + Electric_Piston_LuV, Electric_Piston_ZPM, Electric_Piston_UV, Electric_Piston_MAX, + Robot_Arm_LuV, Robot_Arm_ZPM, Robot_Arm_UV, Robot_Arm_MAX, + Field_Generator_LuV, Field_Generator_ZPM, Field_Generator_UV, Field_Generator_MAX, + Emitter_LuV, Emitter_ZPM, Emitter_UV, Emitter_MAX, + Sensor_LuV, Sensor_ZPM, Sensor_UV, Sensor_MAX, + + //ULV Components + Electric_Motor_ULV, + Electric_Pump_ULV, + Conveyor_Module_ULV, + Electric_Piston_ULV, + Robot_Arm_ULV, + Field_Generator_ULV, + Emitter_ULV, + Sensor_ULV, + + // Mixed Components + TransmissionComponent_ULV, TransmissionComponent_LV, + TransmissionComponent_MV, TransmissionComponent_HV, + TransmissionComponent_EV, TransmissionComponent_IV, + TransmissionComponent_LuV, TransmissionComponent_ZPM, + TransmissionComponent_UV, TransmissionComponent_MAX, + + //Recipe Circuit + Circuit_BioRecipeSelector, + Circuit_T3RecipeSelector, + + //Circuits + Old_Circuit_Primitive, Old_Circuit_Basic, Old_Circuit_Good, + Old_Circuit_Advanced, Old_Circuit_Data, Old_Circuit_Elite, + Old_Circuit_Master, Old_Tool_DataOrb, Old_Circuit_Ultimate, Old_Tool_DataStick, + Circuit_IV, Circuit_LuV, Circuit_ZPM, + + //Circuit Parts + Circuit_Board_IV, Circuit_Board_LuV, Circuit_Board_ZPM, + Circuit_Parts_Crystal_Chip_IV, Circuit_Parts_Crystal_Chip_LuV, Circuit_Parts_Crystal_Chip_ZPM, + Circuit_Parts_IV, Circuit_Parts_LuV, Circuit_Parts_ZPM, + Circuit_Parts_Wiring_IV, Circuit_Parts_Wiring_LuV, Circuit_Parts_Wiring_ZPM, + + //Old Style Circuits + Old_Circuit_Board_Basic, Old_Circuit_Board_Advanced, Old_Circuit_Board_Elite, + Old_Circuit_Parts_Crystal_Chip_Elite, Old_Circuit_Parts_Crystal_Chip_Master, Old_Circuit_Parts_Advanced, + Old_Circuit_Parts_Wiring_Basic, Old_Circuit_Parts_Wiring_Advanced, Old_Circuit_Parts_Wiring_Elite, + Old_Empty_Board_Basic, Old_Empty_Board_Elite, + + //Batteries + Battery_RE_EV_Sodium, + Battery_RE_EV_Cadmium, + Battery_RE_EV_Lithium, + + //Shapes for Extruder + Shape_Extruder_WindmillShaft, + Shape_Extruder_SmallGear, + + //Cooked Raisin Toast for ImQ009 + Food_Baked_Raisin_Bread, + + + //Fluid Cells to regulate flows. + Fluid_Cell_1L, Fluid_Cell_16L, + Fluid_Cell_36L, Fluid_Cell_144L, + + //Debug + TESTITEM, + + // Larger Volumetric Flasks + VOLUMETRIC_FLASK_8k, + VOLUMETRIC_FLASK_32k, + + //RTG Fuels + Pellet_RTG_PU238, Pellet_RTG_SR90, + Pellet_RTG_PO210, Pellet_RTG_AM241, + + //Computer Cube + Gregtech_Computer_Cube, + + //Casings for batteries + Battery_Casing_Gem_1, Battery_Casing_Gem_2, + Battery_Casing_Gem_3, Battery_Casing_Gem_4, + + //Custom Batteries + Battery_Gem_1, Battery_Gem_2, + Battery_Gem_3, Battery_Gem_4, + + //Compressed Fusion MK3 + Compressed_Fusion_Reactor, + + //Carbon Materials + NanoTube_Base_Substrate, + NanoTube_Finished, + Carbyne_Tube_Finished, + Carbyne_Sheet_Finished, + + //End Game Laser Engraver Lens + Laser_Lens_WoodsGlass, + Laser_Lens_Special, + + //Bombs + Bomb_Cast, Bomb_Cast_Molten, + Bomb_Cast_Set, Bomb_Cast_Broken, + Bomb_Cast_Mold, + + // Pellet Mold + Pellet_Mold, + + //Charged Items for Tree Farms + Farm_Processor_EV, + Farm_Processor_IV, + Farm_Processor_LuV, + Farm_Processor_ZPM, + Farm_Processor_UV, + + // Upgrade chip for Distillus + Distillus_Upgrade_Chip, + + + // Chips used to nerf my multis via custom behavioural attachments + Chip_MultiNerf_NoOutputBonus, + Chip_MultiNerf_NoSpeedBonus, + Chip_MultiNerf_NoEuBonus, + + // Milling Balls + Milling_Ball_Alumina, + Milling_Ball_Soapstone, + + + //---------------------------------------------------------------------------- + + + + /** + * MultiBlocks + */ + + + // Tier GT++ Casings + GTPP_Casing_ULV, GTPP_Casing_LV, + GTPP_Casing_MV, GTPP_Casing_HV, + GTPP_Casing_EV, GTPP_Casing_IV, + GTPP_Casing_LuV, GTPP_Casing_ZPM, + GTPP_Casing_UV, GTPP_Casing_MAX, + + //IronBlastFurnace Machine_Bronze_BlastFurnace + Machine_Iron_BlastFurnace, + Casing_IronPlatedBricks, + + //Large Centrifuge + Industrial_Centrifuge, + Casing_Centrifuge1, + + // Large Alloy Smelter + Industrial_AlloySmelter, + + //Coke Oven + Industrial_CokeOven, + Casing_CokeOven, + Casing_CokeOven_Coil1, + Casing_CokeOven_Coil2, + + //Bending Maching // Plate Press // Press + Industrial_PlatePress, + Casing_MaterialPress, + + //Matter Fab + Industrial_MassFab, + Casing_MatterGen, + Casing_MatterFab, + + //ABS + Industrial_AlloyBlastSmelter, + Casing_Coil_BlastSmelter, + Casing_BlastSmelter, + + //Industrial Electrolyzer + Industrial_Electrolyzer, + Casing_Electrolyzer, + + //Industrial Maceration Stack + Industrial_MacerationStack, + Casing_MacerationStack, + + //Industrial Wire Factory + Industrial_WireFactory, + Casing_WireFactory, + + //Power sub-station for mass storage. 3 hatches for input and output, whatever voltages you desire. + PowerSubStation, + Casing_Vanadium_Redox, + Casing_Vanadium_Redox_IV, + Casing_Vanadium_Redox_LuV, + Casing_Vanadium_Redox_ZPM, + Casing_Vanadium_Redox_UV, + Casing_Vanadium_Redox_MAX, + Casing_Power_SubStation, + + + //LFTR + ThoriumReactor, + Casing_Reactor_I, + Casing_Reactor_II, + + //Multitank + /*Industrial_MultiTank,*/ + Industrial_MultiTankDense, + Casing_MultitankExterior, + + + //Fission Fuel Refinery + Industrial_FuelRefinery, + Casing_Refinery_External, + Casing_Refinery_Structural, + Casing_Refinery_Internal, + + + //Industrial Sifter + Industrial_Sifter, + Casing_Sifter, + Casing_SifterGrate, + + + //Large Thermal Centrifuge + Industrial_ThermalCentrifuge, + Casing_ThermalCentrifuge, + + + //Cyclotron + COMET_Cyclotron, + Casing_Cyclotron_Coil, + Casing_Cyclotron_External, + + //Thermal Boiler + GT4_Thermal_Boiler, + Casing_ThermalContainment, + + + //Tree Farm + Industrial_TreeFarm, + TreeFarmer_Structural, + Casing_PLACEHOLDER_TreeFarmer, + + + //Fish Pond + Industrial_FishingPond, + Casing_FishPond, + + //Algae + AlgaeFarm_Controller, + + //Chemical Plant + ChemicalPlant_Controller, + + //GT4 autoCrafter + GT4_Multi_Crafter, + Casing_Autocrafter, + + + //industrial Ore-Washer + Industrial_WashPlant, + Casing_WashPlant, + + + //Generator Array + Generator_Array_Controller, + + + //Cutting Factory Controller + Industrial_CuttingFactoryController, + Casing_CuttingFactoryFrame, + + + //Tesla Tower + /*TelsaTower,*/ + Casing_TeslaTower, + + + //Large Extruder + Industrial_Extruder, + Casing_Extruder, + + + //Multi-Machine + Industrial_MultiMachine, + Casing_Multi_Use, + + + //Bedrock Mining Platforms + /*BedrockMiner_MKI, */ + /*BedrockMiner_MKII, */ + /*BedrockMiner_MKIII, */ + Casing_BedrockMiner, + + + //Large Packager + Amazon_Warehouse_Controller, + Casing_AmazonWarehouse, + + + //Advanced GT vanilla Multis + Machine_Adv_BlastFurnace, + Casing_Adv_BlastFurnace, + Machine_Adv_ImplosionCompressor, + Machine_Adv_DistillationTower, + + //Advanced Assembly Line + /*Machine_Adv_AssemblyLine,*/ + + //Advanced Vacuum Freezer + Industrial_Cryogenic_Freezer, + Casing_AdvancedVacuum, + + + //FusionTek MK IV + FusionComputer_UV2, + Casing_Fusion_External, + Casing_Fusion_Internal, + + + //large mixer + Industrial_Mixer, + + + //Naq Reactor + Casing_Naq_Reactor_A, + Casing_Naq_Reactor_B, + Casing_Naq_Reactor_C, + /*Controller_Naq_Reactor, */ + Casing_Containment, + + //Arc Furnace + Industrial_Arc_Furnace, + Casing_Industrial_Arc_Furnace, + + //Solar Tower + /*Industrial_Solar_Tower,*/ + Casing_SolarTower_Structural, + Casing_SolarTower_SaltContainment, + Casing_SolarTower_HeatContainment, + + //Larger Turbines + /*Large_Steam_Turbine, Large_HPSteam_Turbine, */ + Casing_Turbine_Shaft, + 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, + + // Large Rocket Engine + Casing_RocketEngine, + Controller_RocketEngine, + + // Large Semi-Fluid + Controller_LargeSemifluidGenerator, + + // IsaMill + Controller_IsaMill, + Casing_IsaMill_Casing, + Casing_IsaMill_Gearbox, + Casing_IsaMill_Pipe, + + // Flotation Cell + Controller_Flotation_Cell, + Casing_Flotation_Cell, + + // Sparge Tower + Controller_Sparge_Tower, + Casing_Sparge_Tower_Exterior, + Casing_Sparge_Tower_Interior, + + // Elemental Duplicator + Controller_ElementalDuplicator, + Casing_ElementalDuplicator, + + // Big Steam Macerator + Controller_SteamMaceratorMulti, + + // Custom Machine Casings + Casing_Machine_Custom_1, + Casing_Machine_Custom_2, + Casing_Machine_Custom_3, + Casing_Machine_Custom_4, + Casing_Machine_Custom_5, + Casing_Machine_Custom_6, + + + //---------------------------------------------------------------------------- + + /** + * Custom hatches/Busses + */ + + //Buffer Dynamos + Hatch_Buffer_Dynamo_ULV, Hatch_Buffer_Dynamo_LV, Hatch_Buffer_Dynamo_MV, Hatch_Buffer_Dynamo_HV, Hatch_Buffer_Dynamo_EV, + Hatch_Buffer_Dynamo_IV, Hatch_Buffer_Dynamo_LuV, Hatch_Buffer_Dynamo_ZPM, Hatch_Buffer_Dynamo_UV, Hatch_Buffer_Dynamo_MAX, + + //Air Intake hatch + Hatch_Air_Intake, + + //XL Turbine Rotor Hatch + /*Hatch_Turbine_Rotor,*/ + + //Standard Turbine Rotor Hatch + Hatch_Input_TurbineHousing, + + //Control Core + Hatch_Control_Core, + + // Milling Ball Bus + Bus_Milling_Balls, + + // Catalyst Bus + Bus_Catalysts, + + //Custom Fluid Hatches + Hatch_Input_Cryotheum, + Hatch_Input_Pyrotheum, + Hatch_Input_Naquadah, + Hatch_Input_Steam, + + //Steam Multi Buses + Hatch_Input_Bus_Steam, + Hatch_Output_Bus_Steam, + + //Elemental Duplicator Data Orb Bus + Hatch_Input_Elemental_Duplicator, + + //RTG Hatch + Hatch_RTG_LV, + Hatch_RTG_MV, + Hatch_RTG_HV, + + //Battery hatches for PSS + Hatch_Input_Battery_MV, + Hatch_Input_Battery_EV, + Hatch_Output_Battery_MV, + Hatch_Output_Battery_EV, + + //Advanced Mufflers + Hatch_Muffler_Adv_LV, Hatch_Muffler_Adv_MV, Hatch_Muffler_Adv_HV, + Hatch_Muffler_Adv_EV, Hatch_Muffler_Adv_IV, Hatch_Muffler_Adv_LuV, + Hatch_Muffler_Adv_ZPM, Hatch_Muffler_Adv_UV, Hatch_Muffler_Adv_MAX, + + //Super Input Busses + Hatch_SuperBus_Input_ULV, Hatch_SuperBus_Input_LV, Hatch_SuperBus_Input_MV, + Hatch_SuperBus_Input_HV, Hatch_SuperBus_Input_EV, Hatch_SuperBus_Input_IV, + Hatch_SuperBus_Input_LuV, Hatch_SuperBus_Input_ZPM, Hatch_SuperBus_Input_UV, + Hatch_SuperBus_Input_MAX, + + //Super Output Busses + Hatch_SuperBus_Output_ULV, Hatch_SuperBus_Output_LV, Hatch_SuperBus_Output_MV, + Hatch_SuperBus_Output_HV, Hatch_SuperBus_Output_EV, Hatch_SuperBus_Output_IV, + Hatch_SuperBus_Output_LuV, Hatch_SuperBus_Output_ZPM, Hatch_SuperBus_Output_UV, + Hatch_SuperBus_Output_MAX, + + + + + //---------------------------------------------------------------------------- + + + + + + /** + * Single Block Tile Entities + */ + + //ULV Generators + Generator_Diesel_ULV, Generator_Gas_Turbine_ULV, Generator_Steam_Turbine_ULV, + + //Crate Box + CrateStorage, + + //Auto TC Research Creator + Thaumcraft_Researcher, + + //Threaded Buffers + Automation_Threaded_SuperBuffer_ULV, Automation_Threaded_SuperBuffer_LV, Automation_Threaded_SuperBuffer_MV, Automation_Threaded_SuperBuffer_HV, Automation_Threaded_SuperBuffer_EV, + Automation_Threaded_SuperBuffer_IV, Automation_Threaded_SuperBuffer_LuV, Automation_Threaded_SuperBuffer_ZPM, Automation_Threaded_SuperBuffer_UV, Automation_Threaded_SuperBuffer_MAX, + + //infinite Items + Infinite_Item_Chest, + + + //Gt4 Workbenches + GT4_Workbench_Bronze, + GT4_Workbench_Advanced, + + + //Geothermal Engines + Geothermal_Engine_EV, + Geothermal_Engine_IV, + Geothermal_Engine_LuV, + + + //Tesseracts + GT4_Tesseract_Generator, + GT4_Tesseract_Terminal, + + + //Advanced Boilers + Boiler_Advanced_LV, + Boiler_Advanced_MV, + Boiler_Advanced_HV, + + + //Fancy Pollution Devices + Pollution_Detector, + Pollution_Cleaner_ULV, Pollution_Cleaner_LV, + Pollution_Cleaner_MV, Pollution_Cleaner_HV, + Pollution_Cleaner_EV, Pollution_Cleaner_IV, + Pollution_Cleaner_LuV, Pollution_Cleaner_ZPM, + Pollution_Cleaner_UV, Pollution_Cleaner_MAX, + + + //Debug machine + Pollution_Creator, + Garbage_Collector_Debug_Machine, + + + //Basically is an automatic Cauldron + SimpleDustWasher_ULV, + SimpleDustWasher_MV, + SimpleDustWasher_EV, + SimpleDustWasher_LuV, + SimpleDustWasher_UV, + + //Solar Tower Reflector + /*Solar_Tower_Reflector,*/ + + //Super Tier Chests + Super_Chest_LV, Super_Chest_MV, Super_Chest_HV, Super_Chest_EV, Super_Chest_IV, + + //Chunkloader + GT_Chunkloader_HV, GT_Chunkloader_ZPM, GT_Chunkloader_IV, + + + //Wireless Chargers + Charger_LV, Charger_MV, Charger_HV, + Charger_EV, Charger_IV, Charger_LuV, + Charger_ZPM, Charger_UV, Charger_MAX, + + + //Tiny Fusion + /*Miniature_Fusion, */ + + + //Component Makers + Machine_LV_Component_Maker, + Machine_MV_Component_Maker, + Machine_HV_Component_Maker, + Machine_EV_Component_Maker, + Machine_IV_Component_Maker, + Machine_LuV_Component_Maker, + Machine_ZPM_Component_Maker, + Machine_UV_Component_Maker, + + // Reactor Processing Unit + ReactorProcessingUnit_IV, + ReactorProcessingUnit_ZPM, + + // Cold Trap + ColdTrap_IV, + ColdTrap_ZPM, + + //Breakers + BreakerBox_ULV, BreakerBox_LV, BreakerBox_MV, + BreakerBox_HV, BreakerBox_EV, BreakerBox_IV, + BreakerBox_LuV, BreakerBox_ZPM, BreakerBox_UV, + BreakerBox_MAX, + + + //Solar Generators + GT_Solar_ULV, GT_Solar_LV, GT_Solar_MV, + GT_Solar_HV, GT_Solar_EV, GT_Solar_IV, + GT_Solar_LuV, GT_Solar_ZPM, GT_Solar_UV, GT_Solar_MAX, + + + //512v Creative Buffer + Energy_Buffer_CREATIVE, + //Variable voltage RF convertor + Energy_Buffer_RF_Convertor, + //Energy Buffers + Energy_Buffer_1by1_ULV, Energy_Buffer_1by1_LV, + Energy_Buffer_1by1_MV, Energy_Buffer_1by1_HV, + Energy_Buffer_1by1_EV, Energy_Buffer_1by1_IV, + Energy_Buffer_1by1_LuV, Energy_Buffer_1by1_ZPM, + Energy_Buffer_1by1_UV, Energy_Buffer_1by1_MAX, + + + //Cobble Generators + Cobble_Generator_ULV, Cobble_Generator_LV, + Cobble_Generator_MV, Cobble_Generator_HV, + Cobble_Generator_EV, Cobble_Generator_IV, + Cobble_Generator_LuV, Cobble_Generator_ZPM, + Cobble_Generator_UV, Cobble_Generator_MAX, + + + //The max Steam condenser + Condensor_MAX, + + + //Player owned Safes + GT_Safe_ULV, GT_Safe_LV, + GT_Safe_MV, GT_Safe_HV, + GT_Safe_EV, GT_Safe_IV, + GT_Safe_LuV, GT_Safe_ZPM, + GT_Safe_UV, GT_Safe_MAX, + + + //Rocket Engines + Rocket_Engine_EV, + Rocket_Engine_IV, + Rocket_Engine_LuV, + + + //GT4 Shelves + GT4_Shelf, GT4_Shelf_Iron, + GT4_Shelf_FileCabinet, GT4_Shelf_Desk, + GT4_Shelf_Compartment, GT4_Shelf_Large, + + + //Hi Amp Transformers + Transformer_HA_LV_ULV, Transformer_HA_MV_LV, Transformer_HA_HV_MV, + Transformer_HA_EV_HV, Transformer_HA_IV_EV, Transformer_HA_LuV_IV, + Transformer_HA_ZPM_LuV, Transformer_HA_UV_ZPM, Transformer_HA_MAX_UV, + + + //Semi-Fluid generators + Generator_SemiFluid_LV, + Generator_SemiFluid_MV, + Generator_SemiFluid_HV, + + + //Advanced Mixer 4x4 + Machine_Advanced_LV_Mixer, Machine_Advanced_MV_Mixer, Machine_Advanced_HV_Mixer, + Machine_Advanced_EV_Mixer, Machine_Advanced_IV_Mixer, Machine_Advanced_LuV_Mixer, + Machine_Advanced_ZPM_Mixer, Machine_Advanced_UV_Mixer, + + + //Block that enables uplink to a superconductor network + SuperConductorInputNode, + + //Heat Pipes + HeatPipe_Tier_1, + HeatPipe_Tier_2, + HeatPipe_Tier_3, + + + //Chemical Dehydrators for nuclear fuels + GT_Dehydrator_MV, GT_Dehydrator_HV, + GT_Dehydrator_EV, GT_Dehydrator_IV, + GT_Dehydrator_LuV, GT_Dehydrator_ZPM, + + + //Fluid Storage Tanks + GT_FluidTank_ULV, GT_FluidTank_LV, + GT_FluidTank_MV, GT_FluidTank_HV, + GT_FluidTank_EV, GT_FluidTank_IV, + GT_FluidTank_LuV, GT_FluidTank_ZPM, + GT_FluidTank_UV, GT_FluidTank_MAX, + + //Tick Accelerators from GTNH + AcceleratorLV, AcceleratorMV, + AcceleratorHV, AcceleratorEV, + AcceleratorIV, AcceleratorLuV, + AcceleratorZPM, AcceleratorUV, + + //GT RTG + RTG, + + //Plasma Tank + /*Plasma_Tank,*/ + + + //---------------------------------------------------------------------------- + + + /** + * Covers + */ + + //Fluid Void Covers + Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, + + //Item Void Covers + Cover_Overflow_Item_ULV, Cover_Overflow_Item_LV, Cover_Overflow_Item_MV, Cover_Overflow_Item_HV, Cover_Overflow_Item_EV, Cover_Overflow_Item_IV, + + //Fake Hull Covers + FakeMachineCasingPlate_ULV, FakeMachineCasingPlate_LV, + FakeMachineCasingPlate_MV, FakeMachineCasingPlate_HV, + FakeMachineCasingPlate_EV, FakeMachineCasingPlate_IV, + FakeMachineCasingPlate_LuV, FakeMachineCasingPlate_ZPM, + FakeMachineCasingPlate_UV, FakeMachineCasingPlate_MAX, + + + + + //---------------------------------------------------------------------------- + + ; + + public static final GregtechItemList[] + DYE_ONLY_ITEMS = { + Energy_Buffer_1by1_EV, Energy_Buffer_1by1_EV }; + private ItemStack mStack; + private boolean mHasNotBeenSet = true; + + + @Override + public GregtechItemList set(final Item aItem) { + this.mHasNotBeenSet = false; + if (aItem == null) { + return this; + } + final ItemStack aStack = new ItemStack(aItem, 1, 0); + this.mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public GregtechItemList set(final ItemStack aStack) { + this.mHasNotBeenSet = false; + this.mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public Item getItem() { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return null; + } + return this.mStack.getItem(); + } + + @Override + public Block getBlock() { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + return getBlockFromStack(this.getItem()); + } + + @Override + public final boolean hasBeenSet() { + return !this.mHasNotBeenSet; + } + + @Override + public boolean isStackEqual(final Object aStack) { + return this.isStackEqual(aStack, false, false); + } + + @Override + public boolean isStackEqual(final Object aStack, final boolean aWildcard, final boolean aIgnoreNBT) { + if (GT_Utility.isStackInvalid(aStack)) { + return false; + } + return GT_Utility.areUnificationsEqual((ItemStack)aStack, aWildcard?this.getWildcard(1):this.get(1), aIgnoreNBT); + } + + public static Block getBlockFromStack(Object aStack) { + if (GT_Utility.isStackInvalid(aStack)) + return Blocks.air; + return Block.getBlockFromItem(((ItemStack) aStack).getItem()); + } + + @Override + public ItemStack get(final long aAmount, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getWildcard(final long aAmount, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getUndamaged(final long aAmount, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getAlmostBroken(final long aAmount, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, this.mStack.getMaxDamage()-1, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getWithName(final long aAmount, final String aDisplayName, final Object... aReplacements) { + final ItemStack rStack = this.get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) { + return null; + } + rStack.setStackDisplayName(aDisplayName); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithCharge(final long aAmount, final int aEnergy, final Object... aReplacements) { + final ItemStack rStack = this.get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) { + return null; + } + GT_ModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithDamage(final long aAmount, final long aMetaValue, final Object... aReplacements) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + if (GT_Utility.isStackInvalid(this.mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } + return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(this.mStack)); + } + + @Override + public GregtechItemList registerOre(final Object... aOreNames) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + for (final Object tOreName : aOreNames) { + GT_OreDictUnificator.registerOre(tOreName, this.get(1)); + } + return this; + } + + @Override + public GregtechItemList registerWildcardAsOre(final Object... aOreNames) { + if (this.mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + } + for (final Object tOreName : aOreNames) { + GT_OreDictUnificator.registerOre(tOreName, this.getWildcard(1)); + } + return this; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOreDictNames.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOreDictNames.java new file mode 100644 index 0000000000..7ef6b5701e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOreDictNames.java @@ -0,0 +1,39 @@ +package gtPlusPlus.xmod.gregtech.api.enums; + +/* Electric Components. + * + * usual Materials for this are: + * Primitive (Tier 1) + * Basic (Tier 2) as used by UE as well : IC2 Circuit and RE-Battery + * Good (Tier 3) + * Advanced (Tier 4) as used by UE as well : Advanced Circuit, Advanced Battery and Lithium Battery + * Data (Tier 5) : Data Storage Circuit + * Elite (Tier 6) as used by UE as well : Energy Crystal and Data Control Circuit + * Master (Tier 7) : Energy Flow Circuit and Lapotron Crystal + * Ultimate (Tier 8) : Data Orb and Lapotronic Energy Orb + * Infinite (Cheaty) + * +Circuits + Circuit_Primitive, Circuit_Basic, Circuit_Good, Circuit_Advanced, + Circuit_Data, Circuit_Elite, Circuit_Master, Tool_DataOrb, Circuit_Ultimate, Tool_DataStick, + Circuit_IV, Circuit_LuV, Circuit_ZPM, +Circuit Parts + Circuit_Board_IV, Circuit_Board_LuV, Circuit_Board_ZPM, + Circuit_Parts_Crystal_Chip_IV, Circuit_Parts_Crystal_Chip_LuV, Circuit_Parts_Crystal_Chip_ZPM, + Circuit_Parts_IV, Circuit_Parts_LuV, Circuit_Parts_ZPM, + Circuit_Parts_Wiring_IV, Circuit_Parts_Wiring_LuV, Circuit_Parts_Wiring_ZPM; + */ +public enum GregtechOreDictNames { + buffer_core, itemGregConduit, Circuit_IV, Circuit_LuV, Circuit_ZPM, + Circuit_Board_IV, Circuit_Board_LuV, Circuit_Board_ZPM, + Circuit_Parts_Crystal_Chip_IV, Circuit_Parts_Crystal_Chip_LuV, Circuit_Parts_Crystal_Chip_ZPM, + Circuit_Parts_IV, Circuit_Parts_LuV, Circuit_Parts_ZPM, + Circuit_Parts_Wiring_IV, Circuit_Parts_Wiring_LuV, Circuit_Parts_Wiring_ZPM; + + public String unlocalisedName; + + private void ModObject() { + this.unlocalisedName = this.name(); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java new file mode 100644 index 0000000000..b17b4a26ff --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechOrePrefixes.java @@ -0,0 +1,941 @@ +package gtPlusPlus.xmod.gregtech.api.enums; + +import static gregtech.api.enums.GT_Values.*; +import static gtPlusPlus.core.util.Utils.getTcAspectStack; + +import java.util.*; + +import gregtech.api.enums.*; +import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.interfaces.*; +import gregtech.api.objects.GT_FluidStack; +import gregtech.api.objects.MaterialStack; +import gregtech.api.util.*; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; +import gtPlusPlus.xmod.gregtech.api.objects.GregtechItemData; +import gtPlusPlus.xmod.gregtech.api.objects.GregtechMaterialStack; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public enum GregtechOrePrefixes { + /* Electric Components. + * + * usual Materials for this are: + * Primitive (Tier 1) + * Basic (Tier 2) as used by UE as well : IC2 Circuit and RE-Battery + * Good (Tier 3) + * Advanced (Tier 4) as used by UE as well : Advanced Circuit, Advanced Battery and Lithium Battery + * Data (Tier 5) : Data Storage Circuit + * Elite (Tier 6) as used by UE as well : Energy Crystal and Data Control Circuit + * Master (Tier 7) : Energy Flow Circuit and Lapotron Crystal + * Ultimate (Tier 8) : Data Orb and Lapotronic Energy Orb + * Infinite (Cheaty) + */ + ingotHot("Hot Ingots", "Hot ", " Ingot", true, true, false, false, false, false, false, true, false, false, B[1], M * 1, 16, 12), // A hot Ingot, which has to be cooled down by a Vacuum Freezer. + ingot("Ingots", "", " Ingot", true, true, false, false, false, false, false, true, false, false, B[1], M * 1, 64, 11), // A regular Ingot. Introduced by Eloraam + dustTiny("Tiny Dusts", "Tiny Pile of ", " Dust", true, true, false, false, false, false, false, true, false, false, B[0] | B[1] | B[2] | B[3], M / 9, 64, 0), // 1/9th of a Dust. + dustSmall("Small Dusts", "Small Pile of ", " Dust", true, true, false, false, false, false, false, true, false, false, B[0] | B[1] | B[2] | B[3], M / 4, 64, 1), // 1/4th of a Dust. + dustImpure("Impure Dusts", "Impure Pile of ", " Dust", true, true, false, false, false, false, false, true, false, true, B[3], M * 1, 64, 3), // Dust with impurities. 1 Unit of Main Material and 1/9 - 1/4 Unit of secondary Material + dustRefined("Refined Dusts", "Refined Pile of ", " Dust", true, true, false, false, false, false, false, true, false, true, B[3], M * 1, 64, 2), + dustPure("Purified Dusts", "Purified Pile of ", " Dust", true, true, false, false, false, false, false, true, false, true, B[3], M * 1, 64, 4), + dust("Dusts", "", " Dust", true, true, false, false, false, false, false, true, false, false, B[0] | B[1] | B[2] | B[3], M * 1, 64, 2), // Pure Dust worth of one Ingot or Gem. Introduced by Alblaka. + nugget("Nuggets", "", " Nugget", true, true, false, false, false, false, false, true, false, false, B[1], M / 9, 64, 9), // A Nugget. Introduced by Eloraam + plate("Plates", "", " Plate", true, true, false, false, false, false, true, true, false, false, B[1] | B[2], M * 1, 64, 17), // Regular Plate made of one Ingot/Dust. Introduced by Calclavia + block("Storage Blocks", "Block of ", "", true, true, false, false, false, true, true, false, false, false, 0, M * 9, 64, 71), // Storage Block consisting out of 9 Ingots/Gems/Dusts. Introduced by CovertJaguar + gem("Gemstones", "", "", true, true, true, false, false, false, true, true, false, false, B[2], M * 1, 64, 8), // A regular Gem worth one Dust. Introduced by Eloraam + gemChipped("Chipped Gemstones", "Chipped ", "", true, true, true, false, false, false, true, true, false, false, B[2], M / 4, 64, 59), // A regular Gem worth one small Dust. Introduced by TerraFirmaCraft + gemFlawed("Flawed Gemstones", "Flawed ", "", true, true, true, false, false, false, true, true, false, false, B[2], M / 2, 64, 60), // A regular Gem worth two small Dusts. Introduced by TerraFirmaCraft + gemFlawless("Flawless Gemstones", "Flawless ", "", true, true, true, false, false, false, true, true, false, false, B[2], M * 2, 32, 61), // A regular Gem worth two Dusts. Introduced by TerraFirmaCraft + gemExquisite("Exquisite Gemstones", "Exquisite ", "", true, true, true, false, false, false, true, true, false, false, B[2], M * 4, 16, 62), // A regular Gem worth four Dusts. Introduced by TerraFirmaCraft + stick("Sticks/Rods", "", " Rod", true, true, false, false, false, false, true, true, false, false, B[1] | B[2], M / 2, 64, 23), // Stick made of half an Ingot. Introduced by Eloraam + type2("16x Wires", "16x ", " Wire", true, true, false, false, false, false, true, false, false, false, 0, M * 8, 64, -1), + + toolSkookumChoocher("Skookum Choocher", "", " Skookum Choocher", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. + toolAngleGrinder("Angle Grinder", "", "Angle Grinder", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. + toolElectricSnips("Electric Snips", "", "Electric Snips", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. + toolElectricLighter("Electric Lighter", "", "Electric Lighter", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. + toolElectricButcherKnife("Electric Butcher Knife", "", "Electric Butcher Knife", true, true, false, false, false, false, true, true, false, false, B[6], M * 6, 16, 37), // consisting out of 6 Ingots. + + + + batterySingleuse("Single Use Batteries", "", "", false, true, false, false, false, false, false, false, false, false, 0, -1, 64, -1), + battery("Reusable Batteries", "", "", false, true, false, false, false, false, false, false, false, false, 0, -1, 64, -1), // Introduced by Calclavia + circuit("Circuits", "", "", true, true, false, false, false, false, false, false, false, false, 0, -1, 64, -1), // Introduced by Calclavia + chipset("Chipsets", "", "", true, true, false, false, false, false, false, false, false, false, 0, -1, 64, -1), // Introduced by Buildcraft + computer("Computers", "", "", true, true, false, false, true, false, false, false, false, false, 0, -1, 64, -1),; // A whole Computer. "computerMaster" = ComputerCube + + public static volatile int VERSION = 508; + + static { + + ingotHot.mHeatDamage = 3.0F; + + } + + public final ArrayList<ItemStack> mPrefixedItems = new ArrayList<>(); + public final short mTextureIndex; + public final String mRegularLocalName, mLocalizedMaterialPre, mLocalizedMaterialPost; + public final boolean mIsUsedForOreProcessing, mIsEnchantable, mIsUnificatable, mIsMaterialBased, mIsSelfReferencing, mIsContainer, mDontUnificateActively, mIsUsedForBlocks, mAllowNormalRecycling, mGenerateDefaultItem; + public final List<TC_AspectStack> mAspects = new ArrayList<>(); + public final Collection<GregtechOrePrefixes> mFamiliarPrefixes = new HashSet<>(); + /** + * Used to determine the amount of Material this Prefix contains. + * Multiply or Divide GregTech_API.MATERIAL_UNIT to get the Amounts in comparision to one Ingot. + * 0 = Null + * Negative = Undefined Amount + */ + public final long mMaterialAmount; + private final Collection<Materials> mNotGeneratedItems = new HashSet<>(), mIgnoredMaterials = new HashSet<>(), mGeneratedItems = new HashSet<>(); + private final ArrayList<Interface_OreRecipeRegistrator> mOreProcessing = new ArrayList<>(); + private final ArrayList<Interface_OreRecipeRegistrator> mOreProcessingFake = new ArrayList<>(); + public ItemStack mContainerItem = null; + public ICondition<ISubTagContainer> mCondition = null; + public byte mDefaultStackSize = 64; + public GregtechMaterialStack mSecondaryMaterial = null; + public GregtechOrePrefixes mPrefixInto = this; + public float mHeatDamage = 0.0F; // Negative for Frost Damage + /** + * Yes this Value can be changed to add Bits for the MetaGenerated-Item-Check. + */ + public int mMaterialGenerationBits = 0; + private GregtechOrePrefixes(final String aRegularLocalName, final String aLocalizedMaterialPre, final String aLocalizedMaterialPost, final boolean aIsUnificatable, final boolean aIsMaterialBased, final boolean aIsSelfReferencing, final boolean aIsContainer, final boolean aDontUnificateActively, final boolean aIsUsedForBlocks, final boolean aAllowNormalRecycling, final boolean aGenerateDefaultItem, final boolean aIsEnchantable, final boolean aIsUsedForOreProcessing, final int aMaterialGenerationBits, final long aMaterialAmount, final int aDefaultStackSize, final int aTextureindex) { + this.mIsUnificatable = aIsUnificatable; + this.mIsMaterialBased = aIsMaterialBased; + this.mIsSelfReferencing = aIsSelfReferencing; + this.mIsContainer = aIsContainer; + this.mDontUnificateActively = aDontUnificateActively; + this.mIsUsedForBlocks = aIsUsedForBlocks; + this.mAllowNormalRecycling = aAllowNormalRecycling; + this.mGenerateDefaultItem = aGenerateDefaultItem; + this.mIsEnchantable = aIsEnchantable; + this.mIsUsedForOreProcessing = aIsUsedForOreProcessing; + this.mMaterialGenerationBits = aMaterialGenerationBits; + this.mMaterialAmount = aMaterialAmount; + this.mRegularLocalName = aRegularLocalName; + this.mLocalizedMaterialPre = aLocalizedMaterialPre; + this.mLocalizedMaterialPost = aLocalizedMaterialPost; + this.mDefaultStackSize = (byte) aDefaultStackSize; + this.mTextureIndex = (short) aTextureindex; + + + //TODO - Utilise some form of way to check if it's gt 5.9 if so, use string switch. + if (this.name().startsWith("ore")) { + getTcAspectStack(TC_Aspects.TERRA.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("wire") || this.name().startsWith("cable")) { + getTcAspectStack(TC_Aspects.ELECTRUM.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("dust")) { + getTcAspectStack(TC_Aspects.PERDITIO.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("crushed")) { + getTcAspectStack(TC_Aspects.PERFODIO.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("ingot") || this.name().startsWith("nugget")) { + getTcAspectStack(TC_Aspects.METALLUM.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("armor")) { + getTcAspectStack(TC_Aspects.TUTAMEN.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("stone")) { + getTcAspectStack(TC_Aspects.TERRA.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("pipe")) { + getTcAspectStack(TC_Aspects.ITER.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("gear")) { + getTcAspectStack(TC_Aspects.MOTUS.name(), 1).addToAspectList(this.mAspects); + getTcAspectStack(TC_Aspects.MACHINA.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("frame") || this.name().startsWith("plate")) { + getTcAspectStack(TC_Aspects.FABRICO.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("tool")) { + getTcAspectStack(TC_Aspects.INSTRUMENTUM.name(), 2).addToAspectList(this.mAspects); + } else if (this.name().startsWith("gem") || this.name().startsWith("crystal") || this.name().startsWith("lens")) { + getTcAspectStack(TC_Aspects.VITREUS.name(), 1).addToAspectList(this.mAspects); + } else if (this.name().startsWith("crate")) { + getTcAspectStack(TC_Aspects.ITER.name(), 2).addToAspectList(this.mAspects); + } else if (this.name().startsWith("circuit")) { + getTcAspectStack("COGNITIO", 1); + } else if (this.name().startsWith("computer")) { + getTcAspectStack("COGNITIO", 4).addToAspectList(this.mAspects); + } else if (this.name().startsWith("battery")) { + getTcAspectStack(TC_Aspects.ELECTRUM.name(), 1).addToAspectList(this.mAspects); + } + } + + public static GregtechOrePrefixes getOrePrefix(final String aOre) { + for (final GregtechOrePrefixes tPrefix : values()) { + if (aOre.startsWith(tPrefix.toString())) { + return tPrefix; + } + } + return null; + } + + public static String stripPrefix(final String aOre) { + for (final GregtechOrePrefixes tPrefix : values()) { + if (aOre.startsWith(tPrefix.toString())) { + return aOre.replaceFirst(tPrefix.toString(), ""); + } + } + return aOre; + } + + public static String replacePrefix(final String aOre, final GregtechOrePrefixes aPrefix) { + for (final GregtechOrePrefixes tPrefix : values()) { + if (aOre.startsWith(tPrefix.toString())) { + return aOre.replaceFirst(tPrefix.toString(), aPrefix.toString()); + } + } + return ""; + } + + public static GregtechOrePrefixes getPrefix(final String aPrefixName) { + return getPrefix(aPrefixName, null); + } + + public static GregtechOrePrefixes getPrefix(final String aPrefixName, final GregtechOrePrefixes aReplacement) { + final Object tObject = GT_Utility.getFieldContent(GregtechOrePrefixes.class, aPrefixName, false, false); + if ((tObject != null) && (tObject instanceof GregtechOrePrefixes)) { + return (GregtechOrePrefixes) tObject; + } + return aReplacement; + } + + public static Materials getMaterial(final String aOre) { + return Materials.get(stripPrefix(aOre)); + } + + public static Materials getMaterial(final String aOre, final GregtechOrePrefixes aPrefix) { + return Materials.get(aOre.replaceFirst(aPrefix.toString(), "")); + } + + public static Materials getRealMaterial(final String aOre, final GregtechOrePrefixes aPrefix) { + return Materials.getRealMaterial(aOre.replaceFirst(aPrefix.toString(), "")); + } + + public static boolean isInstanceOf(final String aName, final GregtechOrePrefixes aPrefix) { + return aName == null ? false : aName.startsWith(aPrefix.toString()); + } + + public boolean add(final ItemStack aStack) { + if (aStack == null) { + return false; + } + if (!this.contains(aStack)) { + this.mPrefixedItems.add(aStack); + } + while (this.mPrefixedItems.contains(null)) { + this.mPrefixedItems.remove(null); + } + return true; + } + + + public boolean contains(final ItemStack aStack) { + if (aStack == null) { + return false; + } + for (final ItemStack tStack : this.mPrefixedItems) { + if (GT_Utility.areStacksEqual(aStack, tStack, !tStack.hasTagCompound())) { + return true; + } + } + return false; + } + + public boolean doGenerateItem(final Materials aMaterial) { + return (aMaterial != null) && (aMaterial != Materials._NULL) && (((aMaterial.mTypes & this.mMaterialGenerationBits) != 0) || this.mGeneratedItems.contains(aMaterial)) && !this.mNotGeneratedItems.contains(aMaterial) && ((this.mCondition == null) || this.mCondition.isTrue(aMaterial)); + } + + public boolean ignoreMaterials(final Materials... aMaterials) { + for (final Materials tMaterial : aMaterials) { + if (tMaterial != null) { + this.mIgnoredMaterials.add(tMaterial); + } + } + return true; + } + + public boolean addFamiliarPrefix(final GregtechOrePrefixes aPrefix) { + if ((aPrefix == null) || this.mFamiliarPrefixes.contains(aPrefix) || (aPrefix == this)) { + return false; + } + return this.mFamiliarPrefixes.add(aPrefix); + } + + public boolean add(final Interface_OreRecipeRegistrator aRegistrator) { + if (aRegistrator == null) { + return false; + } + return this.mOreProcessing.add(aRegistrator); + } + + public void processOre(final GT_Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { + if ((aMaterial != null) && ((aMaterial != GT_Materials._NULL) || this.mIsSelfReferencing || !this.mIsMaterialBased) && GT_Utility.isStackValid(aStack)) { + for (final Interface_OreRecipeRegistrator tRegistrator : this.mOreProcessing) { + if (D2) { + GT_Log.ore.println("Processing '" + aOreDictName + "' with the Prefix '" + this.name() + "' and the Material '" + aMaterial.name() + "' at " + GT_Utility.getClassName(tRegistrator)); + } + tRegistrator.registerOre(this, aMaterial, aOreDictName, aModName, GT_Utility.copyAmount(1, aStack)); + } + } + } + + //TODO + public void processOre(final Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { + if ((aMaterial != null) && ((aMaterial != Materials._NULL) || this.mIsSelfReferencing || !this.mIsMaterialBased) && GT_Utility.isStackValid(aStack)) { + for (final Interface_OreRecipeRegistrator tRegistrator : this.mOreProcessingFake) { + if (D2) { + GT_Log.ore.println("Processing '" + aOreDictName + "' with the Prefix '" + this.name() + "' and the Material '" + aMaterial.name() + "' at " + GT_Utility.getClassName(tRegistrator)); + } + tRegistrator.registerOre(this, aMaterial, aOreDictName, aModName, GT_Utility.copyAmount(1, aStack)); + } + } + } + + public Object get(final Object aMaterial) { + if (aMaterial instanceof GT_Materials) { + return new GregtechItemData(this, (GT_Materials) aMaterial); + } + return this.name() + aMaterial; + } + + public String getDefaultLocalNameForItem(final Materials aMaterial) { + + + // Use Standard Localization + return this.mLocalizedMaterialPre + aMaterial.mDefaultLocalName + this.mLocalizedMaterialPost; + } + + public enum GT_Materials implements IColorModulationContainer, ISubTagContainer { + + + + /** + * This is the Default Material returned in case no Material has been found or a NullPointer has been inserted at a location where it shouldn't happen. + * <p/> + * Mainly for preventing NullPointer Exceptions and providing Default Values. + * + * Unknown Material Components. Dead End Section. + * + * Alkalus Range 730-799 & 970-998 + * (aMetaItemSubID, TextureSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, R, G, B, Alpha, aLocalName, + * aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor + * this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, true); + * + */ + _NULL(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 255, 255, 255, 0, "NULL", 0, 0, 0, 0, false, false, 1, 1, 1, Dyes._NULL, Element._NULL, Arrays.asList(getTcAspectStack(TC_Aspects.VACUOS.name(), 1))), + + + //Lapis(526, TextureSet.SET_LAPIS, 1.0F, 0, 1, 1 | 4 | 8, 70, 70, 220, 0, "Lapis", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeBlue, 2, Arrays.asList(new MaterialStack(Materials.Lazurite, 12), new MaterialStack(Materials.Sodalite, 2), new MaterialStack(Materials.Pyrite, 1), new MaterialStack(Materials.Calcite, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.SENSUS, 1))), + Pyrotheum(20, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 255, 128, 0, 0, "Pyrotheum", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeYellow, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1)), Arrays.asList(getTcAspectStack("PRAECANTATIO", 2), getTcAspectStack(TC_Aspects.IGNIS, 1))), + Cryotheum(21, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 102, 178, 255, 0, "Cryotheum", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Blizz, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Snow, 1), new MaterialStack(Materials.Niter, 1)), Arrays.asList(getTcAspectStack("PRAECANTATIO", 2), getTcAspectStack(TC_Aspects.GELUM, 1))), + Ender(22, TextureSet.SET_FLUID, 1.0F, 0, 2, 1, 255, 255, 255, 0, "Ender", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeGreen), + + /** + * Circuitry, Batteries and other Technical things + */ + Symbiotic(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 255, 255, 255, 0, "IV Tier", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray, Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 4), getTcAspectStack(TC_Aspects.MACHINA, 4))), + Neutronic(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 255, 255, 255, 0, "LuV Tier", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray, Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 6), getTcAspectStack(TC_Aspects.MACHINA, 6))), + Quantum(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 255, 255, 255, 0, "ZPM Tier", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray, Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 8), getTcAspectStack(TC_Aspects.MACHINA, 8))), + + Superconductor(-1, TextureSet.SET_NONE, 1.0F, 0, 0, 0, 190, 240, 190, 0, "Superconductor", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeGreen, Arrays.asList(getTcAspectStack(TC_Aspects.ELECTRUM, 8))), + + Staballoy(30, TextureSet.SET_ROUGH, 10.0F, 5120, 4, 1 | 2 | 16 | 32 | 64 | 128, 68, 75, 66, 0, "Staballoy", 0, 0, 1500, 2800, true, false, 1, 3, 1, Dyes.dyeGreen, 2, Arrays.asList(new MaterialStack(Materials.Titanium, 1), new MaterialStack(Materials.Uranium, 9)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + Bedrockium(31, TextureSet.SET_FINE, 8.0F, 8196, 3, 1 | 2 | 16 | 32 | 64 | 128, 39, 39, 39, 0, "Bedrockium", 0, 0, -1, 0, false, false, 1, 5, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Materials.Carbon, 63), new MaterialStack(Materials.Carbon, 56)), Arrays.asList(getTcAspectStack(TC_Aspects.VACUOS, 8), getTcAspectStack(TC_Aspects.TUTAMEN, 3))), + BloodSteel(32, TextureSet.SET_METALLIC, 11.0F, 768, 4, 1 | 2 | 16 | 32 | 64 | 128, 142, 28, 0, 0, "Blood Steel", 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeRed, 2, Arrays.asList(new MaterialStack(Materials.Steel, 3)), Arrays.asList(getTcAspectStack(TC_Aspects.VICTUS, 8), getTcAspectStack(TC_Aspects.IGNIS, 3))), + Void(33, TextureSet.SET_METALLIC, 6.0F, 1280, 3, 1 | 2 | 16 | 32 | 64 | 128, 82, 17, 82, 0, "Void Metal", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeBlack, Arrays.asList(getTcAspectStack("PRAECANTATIO", 5), getTcAspectStack(TC_Aspects.VACUOS, 7))), + ConductiveIron(34, TextureSet.SET_METALLIC, 5.0F, 256, 2, 1 | 2, 164, 109, 100, 0, "Conductive Iron", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeRed, 2, Arrays.asList(new MaterialStack(Materials.Iron, 6), new MaterialStack(Materials.Redstone, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.POTENTIA, 2), getTcAspectStack(TC_Aspects.METALLUM, 2))), + ElectricalSteel(35, TextureSet.SET_METALLIC, 7.0F, 768, 3, 1 | 2 | 64 | 128, 194, 194, 194, 0, "Electrical Steel", 0, 0, 1811, 1000, true, false, 3, 1, 1, Dyes.dyeLightGray, 2, Arrays.asList(new MaterialStack(Materials.Iron, 3), new MaterialStack(Materials.Coal, 2), new MaterialStack(Materials.Silicon, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.MAGNETO, 2), getTcAspectStack(TC_Aspects.ELECTRUM, 5))), + EnergeticAlloy(36, TextureSet.SET_SHINY, 5.0F, 512, 3, 1 | 2 | 64 | 128, 252, 152, 45, 0, "Energetic Alloy", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeOrange, 2, Arrays.asList(new MaterialStack(Materials.Gold, 3), new MaterialStack(Materials.Glowstone, 2), new MaterialStack(Materials.Redstone, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.POTENTIA, 4), getTcAspectStack(TC_Aspects.LUX, 3))), + VibrantAlloy(37, TextureSet.SET_SHINY, 7.0F, 1280, 4, 1 | 2 | 64 | 128, 204, 242, 142, 0, "Vibrant Alloy", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeLime, 2, Arrays.asList(new MaterialStack(Materials.EnergeticAlloy, 1), new MaterialStack(Materials.EnderPearl, 3)), Arrays.asList(getTcAspectStack(TC_Aspects.MACHINA, 5), getTcAspectStack(TC_Aspects.TELUM, 4))), + PulsatingIron(38, TextureSet.SET_SHINY, 5.0F, 256, 2, 1 | 2 | 64 | 128, 50, 91, 21, 0, "Pulsating Iron", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeGreen, 2, Arrays.asList(new MaterialStack(Materials.Iron, 2), new MaterialStack(Materials.EnderPearl, 2)), Arrays.asList(getTcAspectStack(TC_Aspects.ALIENIS, 3), getTcAspectStack(TC_Aspects.METALLUM, 3))), + /* TODO*/ RedstoneAlloy(39, TextureSet.SET_METALLIC, 1.0F, 256, 2, 1|2|16|32|64, 178,34,34, 0, "Redstone Alloy", 0, 0, -1, 0, false, false, 3, 1, 1, Dyes.dyeRed, 2, Arrays.asList(new MaterialStack(Materials.Iron, 2), new MaterialStack(Materials.Redstone, 4))), + + //Needs more Use, I think. + Tantalloy60(40, TextureSet.SET_DULL, 8.0F, 5120, 3, 1 | 2 | 16 | 32 | 64 | 128, 68, 75, 166, 0, "Tantalloy-60", 0, 0, 3035, 2200, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + Tantalloy61(41, TextureSet.SET_DULL, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 122, 135, 196, 0, "Tantalloy-61", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + + Potin(42, TextureSet.SET_METALLIC, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 201,151,129, 0, "Potin", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + Inconel792(43, TextureSet.SET_METALLIC, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 108, 240, 118, 0, "Inconel-792", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + Inconel690(44, TextureSet.SET_DULL, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 118, 220, 138, 0, "Inconel-690", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + MaragingSteel300(45, TextureSet.SET_METALLIC, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 150, 150, 150, 0, "Maraging Steel 300", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + MaragingSteel350(46, TextureSet.SET_METALLIC, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 160, 160, 160, 0, "Maraging Steel 350", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + HastelloyX(47, TextureSet.SET_SHINY, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 255, 193, 37, 0, "Hastelloy-X", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + + TriniumNaquadahCarbonite(48, TextureSet.SET_SHINY, 7.0F, 5120, 2, 1 | 2 | 16 | 32 | 64 | 128, 255, 233, 0, 0, "Trinium Naquadah Carbonite", 0, 0, 3015, 2150, true, false, 1, 2, 1, Dyes.dyeLightBlue, 2, Arrays.asList(new MaterialStack(Materials.Tungsten, 1), new MaterialStack(Materials.Tantalum, 9), new MaterialStack(Materials.Titanium, 1)), Arrays.asList(getTcAspectStack(TC_Aspects.METALLUM, 8), getTcAspectStack(TC_Aspects.STRONTIO, 3))), + + + //Radioactive Materials + HydrofluoricAcid(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 200, 200, 200, 0, "Hydrofluoric Acid", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + UraniumHexaFluoride(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 73, 220, 83, 0, "Uranium Hexafluoride", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeLime, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + UraniumTetraFluoride(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 73, 220, 83, 0, "Uranium Tetrafluoride", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeLime, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + ThoriumTetraFluoride(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 15, 120, 15, 0, "Thorium Tetrafluoride", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeGreen, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + + SulfurousAcid(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 110, 220, 30, 0, "Sulfurous Acid", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + SulfurDioxide(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 150, 200, 50, 0, "Sulfur Dioxide", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + HydrogenChloride(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 150, 240, 90, 0, "Hydrogen Chloride", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + SulfuricApatite(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 0, 105, 105, 0, "Sulfuric Apatite Solution", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + + SulfuricLithium(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 0, 105, 105, 0, "Sulfuric Lithium Solution", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + LithiumHydroxide(-1, TextureSet.SET_FLUID, 1.0F, 0, 1, 2 | 16 | 32, 0, 105, 105, 0, "Lithium Hydroxide", 0, 0, -1, 0, false, false, 2, 3, 1, Dyes.dyeWhite, 2, Arrays.asList(new MaterialStack(Materials.Coal, 1), new MaterialStack(Materials.Redstone, 1), new MaterialStack(Materials.Blaze, 1), new MaterialStack(Materials.Sulfur, 1))), + + ; + + + + + /** + * List of all Materials. + */ + public static final Collection<GT_Materials> VALUES = new HashSet<>(Arrays.asList(values())); + + + static { + /*Primitive.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Basic.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Good.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Advanced.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Data.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Elite.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Master.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Ultimate.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Superconductor.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Infinite.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING);*/ + Symbiotic.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Neutronic.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + Quantum.add(SubTag.NO_SMASHING, SubTag.NO_SMELTING); + } + + + /** + * This Array can be changed dynamically by a Tick Handler in order to get a glowing Effect on all GT Meta Items out of this Material. + */ + public final short[] mRGBa = new short[]{255, 255, 255, 0}, mMoltenRGBa = new short[]{255, 255, 255, 0}; + public final TextureSet mIconSet; + public final int mMetaItemSubID; + public final boolean mUnificatable; + public final GT_Materials mMaterialInto; + public final List<MaterialStack> mMaterialList = new ArrayList<>(); + public final List<GT_Materials> mOreByProducts = new ArrayList<>(), mOreReRegistrations = new ArrayList<>(); + public final List<TC_AspectStack> mAspects = new ArrayList<>(); + private final ArrayList<ItemStack> mMaterialItems = new ArrayList<>(); + private final Collection<SubTag> mSubTags = new HashSet<>(); + public Enchantment mEnchantmentTools = null, mEnchantmentArmors = null; + public byte mEnchantmentToolsLevel = 0, mEnchantmentArmorsLevel = 0; + public boolean mBlastFurnaceRequired = false; + public float mToolSpeed = 1.0F, mHeatDamage = 0.0F; + public String mChemicalFormula = "?", mDefaultLocalName = "null"; + public Dyes mColor = Dyes._NULL; + public short mMeltingPoint = 0, mBlastFurnaceTemp = 0; + public int mTypes = 0, mDurability = 16, mFuelPower = 0, mFuelType = 0, mExtraData = 0, mOreValue = 0, mOreMultiplier = 1, mByProductMultiplier = 1, mSmeltingMultiplier = 1; + public long mDensity = M; + public Element mElement = null; + public GT_Materials mDirectSmelting = this, mOreReplacement = this, mMacerateInto = this, mSmeltInto = this, mArcSmeltInto = this, mHandleMaterial = this; + public byte mToolQuality = 0; + public Fluid mSolid = null, mFluid = null, mGas = null, mPlasma = null; + /** + * This Fluid is used as standard Unit for Molten Materials. 1296 is a Molten Block, what means 144 is one Material Unit worth + */ + public Fluid mStandardMoltenFluid = null; + + private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final boolean aUnificatable) { + this.mUnificatable = aUnificatable; + this.mMaterialInto = this; + this.mMetaItemSubID = aMetaItemSubID; + this.mToolQuality = (byte) aToolQuality; + this.mDurability = aToolDurability; + this.mToolSpeed = aToolSpeed; + this.mIconSet = aIconSet; + if (aMetaItemSubID >= 0) { + if (CORE.sMU_GeneratedMaterials[aMetaItemSubID] == null) { + CORE.sMU_GeneratedMaterials[aMetaItemSubID] = this; + } else { + throw new IllegalArgumentException("The Index " + aMetaItemSubID + " is already used!"); + } + } + } + + private GT_Materials(final GT_Materials aMaterialInto, final boolean aReRegisterIntoThis) { + this.mUnificatable = false; + this.mDefaultLocalName = aMaterialInto.mDefaultLocalName; + this.mMaterialInto = aMaterialInto.mMaterialInto; + if (aReRegisterIntoThis) { + this.mMaterialInto.mOreReRegistrations.add(this); + } + this.mChemicalFormula = aMaterialInto.mChemicalFormula; + this.mMetaItemSubID = -1; + this.mIconSet = TextureSet.SET_NONE; + } + + /** + * @param aMetaItemSubID the Sub-ID used in my own MetaItems. Range 0-1000. -1 for no Material + * @param aTypes which kind of Items should be generated. Bitmask as follows: + * 1 = Dusts of all kinds. + * 2 = Dusts, Ingots, Plates, Rods/Sticks, Machine Components and other Metal specific things. + * 4 = Dusts, Gems, Plates, Lenses (if transparent). + * 8 = Dusts, Impure Dusts, crushed Ores, purified Ores, centrifuged Ores etc. + * 16 = Cells + * 32 = Plasma Cells + * 64 = Tool Heads + * 128 = Gears + * @param aR, aG, aB Color of the Material 0-255 each. + * @param aA transparency of the Material Texture. 0 = fully visible, 255 = Invisible. + * @param aLocalName The Name used as Default for localization. + * @param aFuelType Type of Generator to get Energy from this Material. + * @param aFuelPower EU generated. Will be multiplied by 1000, also additionally multiplied by 2 for Gems. + * @param aAmplificationValue Amount of UUM amplifier gotten from this. + * @param aUUMEnergy Amount of EU needed to shape the UUM into this Material. + * @param aMeltingPoint Used to determine the smelting Costs in Furnii. + * @param aBlastFurnaceTemp Used to determine the needed Heat capactiy Costs in Blast Furnii. + * @param aBlastFurnaceRequired If this requires a Blast Furnace. + * @param aColor Vanilla MC Wool Color which comes the closest to this. + */ + private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor) { + this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, true); + this.mDefaultLocalName = aLocalName; + this.mMeltingPoint = (short) aMeltingPoint; + this.mBlastFurnaceTemp = (short) aBlastFurnaceTemp; + this.mBlastFurnaceRequired = aBlastFurnaceRequired; + if (aTransparent) { + this.add(SubTag.TRANSPARENT); + } + this.mFuelPower = aFuelPower; + this.mFuelType = aFuelType; + this.mOreValue = aOreValue; + this.mDensity = (M * aDensityMultiplier) / aDensityDivider; + this.mColor = aColor == null ? Dyes._NULL : aColor; + if (this.mColor != null) { + this.add(SubTag.HAS_COLOR); + } + this.mRGBa[0] = this.mMoltenRGBa[0] = (short) aR; + this.mRGBa[1] = this.mMoltenRGBa[1] = (short) aG; + this.mRGBa[2] = this.mMoltenRGBa[2] = (short) aB; + this.mRGBa[3] = this.mMoltenRGBa[3] = (short) aA; + this.mTypes = aTypes; + if ((this.mTypes & 2) != 0) { + this.add(SubTag.SMELTING_TO_FLUID); + } + } + + private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor, final List<TC_AspectStack> aAspects) { + this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, aR, aG, aB, aA, aLocalName, aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor); + this.mAspects.addAll(aAspects); + } + + /** + * @param aElement The Element Enum represented by this Material + */ + private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor, final Element aElement, final List<TC_AspectStack> aAspects) { + this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, aR, aG, aB, aA, aLocalName, aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor); + this.mElement = aElement; + //mElement.mLinkedMaterials.add(this); + if (aElement == Element._NULL) { + this.mChemicalFormula = "Empty"; + } else { + this.mChemicalFormula = aElement.toString(); + this.mChemicalFormula = this.mChemicalFormula.replaceAll("_", "-"); + } + this.mAspects.addAll(aAspects); + } + + private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor, final int aExtraData, final List<MaterialStack> aMaterialList) { + this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, aR, aG, aB, aA, aLocalName, aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor, aExtraData, aMaterialList, null); + } + + private GT_Materials(final int aMetaItemSubID, final TextureSet aIconSet, final float aToolSpeed, final int aToolDurability, final int aToolQuality, final int aTypes, final int aR, final int aG, final int aB, final int aA, final String aLocalName, final int aFuelType, final int aFuelPower, final int aMeltingPoint, final int aBlastFurnaceTemp, final boolean aBlastFurnaceRequired, final boolean aTransparent, final int aOreValue, final int aDensityMultiplier, final int aDensityDivider, final Dyes aColor, final int aExtraData, final List<MaterialStack> aMaterialList, final List<TC_AspectStack> aAspects) { + this(aMetaItemSubID, aIconSet, aToolSpeed, aToolDurability, aToolQuality, aTypes, aR, aG, aB, aA, aLocalName, aFuelType, aFuelPower, aMeltingPoint, aBlastFurnaceTemp, aBlastFurnaceRequired, aTransparent, aOreValue, aDensityMultiplier, aDensityDivider, aColor); + this.mExtraData = aExtraData; + this.mMaterialList.addAll(aMaterialList); + this.mChemicalFormula = ""; + for (final MaterialStack tMaterial : this.mMaterialList) { + this.mChemicalFormula += tMaterial.toString(); + } + this.mChemicalFormula = this.mChemicalFormula.replaceAll("_", "-"); + + int tAmountOfComponents = 0, tMeltingPoint = 0; + for (final MaterialStack tMaterial : this.mMaterialList) { + tAmountOfComponents += tMaterial.mAmount; + if (tMaterial.mMaterial.mMeltingPoint > 0) { + tMeltingPoint += tMaterial.mMaterial.mMeltingPoint * tMaterial.mAmount; + } + if (aAspects == null) { + for (final TC_AspectStack tAspect : tMaterial.mMaterial.mAspects) { + tAspect.addToAspectList(this.mAspects); + } + } + } + + if (this.mMeltingPoint < 0) { + this.mMeltingPoint = (short) (tMeltingPoint / tAmountOfComponents); + } + + tAmountOfComponents *= aDensityMultiplier; + tAmountOfComponents /= aDensityDivider; + if (aAspects == null) { + for (final TC_AspectStack tAspect : this.mAspects) { + tAspect.mAmount = Math.max(1, tAspect.mAmount / Math.max(1, tAmountOfComponents)); + } + } else { + this.mAspects.addAll(aAspects); + } + } + + public static GT_Materials get(final String aMaterialName) { + final Object tObject = GT_Utility.getFieldContent(GT_Materials.class, aMaterialName, false, false); + if ((tObject != null) && (tObject instanceof GT_Materials)) { + return (GT_Materials) tObject; + } + return _NULL; + } + + public static GT_Materials getRealMaterial(final String aMaterialName) { + return get(aMaterialName).mMaterialInto; + } + + /** + * Called in preInit with the Config to set Values. + * + * @param aConfiguration + */ + public static void init(final GT_Config aConfiguration) { + for (final GT_Materials tMaterial : VALUES) { + final String tString = tMaterial.toString().toLowerCase(); + tMaterial.mHeatDamage = (float) aConfiguration.get(ConfigCategories.Materials.heatdamage, tString, tMaterial.mHeatDamage); + if (tMaterial.mBlastFurnaceRequired) { + tMaterial.mBlastFurnaceRequired = aConfiguration.get(ConfigCategories.Materials.blastfurnacerequirements, tString, true); + } + if (tMaterial.mBlastFurnaceRequired && aConfiguration.get(ConfigCategories.Materials.blastinductionsmelter, tString, tMaterial.mBlastFurnaceTemp < 1500)){} + //GT_ModHandler.ThermalExpansion.addSmelterBlastOre(tMaterial); + //tMaterial.mHandleMaterial = (tMaterial == Desh ? tMaterial.mHandleMaterial : tMaterial == Diamond || tMaterial == Thaumium ? Wood : tMaterial.contains(SubTag.BURNING) ? Blaze : tMaterial.contains(SubTag.MAGICAL) && tMaterial.contains(SubTag.CRYSTAL) && Loader.isModLoaded(MOD_ID_TC) ? Thaumium : tMaterial.getMass() > Element.Tc.getMass() * 2 ? TungstenSteel : tMaterial.getMass() > Element.Tc.getMass() ? Steel : Wood); + } + } + + public boolean isRadioactive() { + if (this.mElement != null) { + return this.mElement.mHalfLifeSeconds >= 0; + } + for (final MaterialStack tMaterial : this.mMaterialList) { + if (tMaterial.mMaterial.isRadioactive()) { + return true; + } + } + return false; + } + + public long getProtons() { + if (this.mElement != null) { + return this.mElement.getProtons(); + } + if (this.mMaterialList.size() <= 0) { + return Element.Tc.getProtons(); + } + long rAmount = 0, tAmount = 0; + for (final MaterialStack tMaterial : this.mMaterialList) { + tAmount += tMaterial.mAmount; + rAmount += tMaterial.mAmount * tMaterial.mMaterial.getProtons(); + } + return (this.getDensity() * rAmount) / (tAmount * M); + } + + public long getNeutrons() { + if (this.mElement != null) { + return this.mElement.getNeutrons(); + } + if (this.mMaterialList.size() <= 0) { + return Element.Tc.getNeutrons(); + } + long rAmount = 0, tAmount = 0; + for (final MaterialStack tMaterial : this.mMaterialList) { + tAmount += tMaterial.mAmount; + rAmount += tMaterial.mAmount * tMaterial.mMaterial.getNeutrons(); + } + return (this.getDensity() * rAmount) / (tAmount * M); + } + + public long getMass() { + if (this.mElement != null) { + return this.mElement.getMass(); + } + if (this.mMaterialList.size() <= 0) { + return Element.Tc.getMass(); + } + long rAmount = 0, tAmount = 0; + for (final MaterialStack tMaterial : this.mMaterialList) { + tAmount += tMaterial.mAmount; + rAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); + } + return (this.getDensity() * rAmount) / (tAmount * M); + } + + public long getDensity() { + return this.mDensity; + } + + public String getToolTip() { + return this.getToolTip(1, false); + } + + public String getToolTip(final boolean aShowQuestionMarks) { + return this.getToolTip(1, aShowQuestionMarks); + } + + public String getToolTip(final long aMultiplier) { + return this.getToolTip(aMultiplier, false); + } + + public String getToolTip(final long aMultiplier, final boolean aShowQuestionMarks) { + if (!aShowQuestionMarks && this.mChemicalFormula.equals("?")) { + return ""; + } + if ((aMultiplier >= (M * 2)) && !this.mMaterialList.isEmpty()) { + return (((this.mElement != null) || ((this.mMaterialList.size() < 2) && (this.mMaterialList.get(0).mAmount == 1))) ? this.mChemicalFormula : "(" + this.mChemicalFormula + ")") + aMultiplier; + } + return this.mChemicalFormula; + } + + /** + * Adds an ItemStack to this Material. + */ + public GT_Materials add(final ItemStack aStack) { + if ((aStack != null) && !this.contains(aStack)) { + this.mMaterialItems.add(aStack); + } + return this; + } + + /** + * This is used to determine if any of the ItemStacks belongs to this Material. + */ + public boolean contains(final ItemStack... aStacks) { + if ((aStacks == null) || (aStacks.length <= 0)) { + return false; + } + for (final ItemStack tStack : this.mMaterialItems) { + for (final ItemStack aStack : aStacks) { + if (GT_Utility.areStacksEqual(aStack, tStack, !tStack.hasTagCompound())) { + return true; + } + } + } + return false; + } + + /** + * This is used to determine if an ItemStack belongs to this Material. + */ + public boolean remove(final ItemStack aStack) { + if (aStack == null) { + return false; + } + boolean temp = false; + for (int i = 0; i < this.mMaterialItems.size(); i++) { + if (GT_Utility.areStacksEqual(aStack, this.mMaterialItems.get(i))) { + this.mMaterialItems.remove(i--); + temp = true; + } + } + return temp; + } + + /** + * Adds a SubTag to this Material + */ + @Override + public ISubTagContainer add(final SubTag... aTags) { + if (aTags != null) { + for (final SubTag aTag : aTags) { + if ((aTag != null) && !this.contains(aTag)) { + aTag.addContainerToList(this); + this.mSubTags.add(aTag); + } + } + } + return this; + } + + /** + * If this Material has this exact SubTag + */ + @Override + public boolean contains(final SubTag aTag) { + return this.mSubTags.contains(aTag); + } + + /** + * Removes a SubTag from this Material + */ + @Override + public boolean remove(final SubTag aTag) { + return this.mSubTags.remove(aTag); + } + + /** + * Sets the Heat Damage for this Material (negative = frost) + */ + public GT_Materials setHeatDamage(final float aHeatDamage) { + this.mHeatDamage = aHeatDamage; + return this; + } + + /** + * Adds a Material to the List of Byproducts when grinding this Ore. + * Is used for more precise Ore grinding, so that it is possible to choose between certain kinds of Materials. + */ + public GT_Materials addOreByProduct(final GT_Materials aMaterial) { + if (!this.mOreByProducts.contains(aMaterial.mMaterialInto)) { + this.mOreByProducts.add(aMaterial.mMaterialInto); + } + return this; + } + + /** + * Adds multiple Materials to the List of Byproducts when grinding this Ore. + * Is used for more precise Ore grinding, so that it is possible to choose between certain kinds of Materials. + */ + public GT_Materials addOreByProducts(final GT_Materials... aMaterials) { + for (final GT_Materials tMaterial : aMaterials) { + if (tMaterial != null) { + this.addOreByProduct(tMaterial); + } + } + return this; + } + + /** + * If this Ore gives multiple drops of its Main Material. + * Lapis Ore for example gives about 6 drops. + */ + public GT_Materials setOreMultiplier(final int aOreMultiplier) { + if (aOreMultiplier > 0) { + this.mOreMultiplier = aOreMultiplier; + } + return this; + } + + /** + * If this Ore gives multiple drops of its Byproduct Material. + */ + public GT_Materials setByProductMultiplier(final int aByProductMultiplier) { + if (aByProductMultiplier > 0) { + this.mByProductMultiplier = aByProductMultiplier; + } + return this; + } + + /** + * If this Ore gives multiple drops of its Main Material. + * Lapis Ore for example gives about 6 drops. + */ + public GT_Materials setSmeltingMultiplier(final int aSmeltingMultiplier) { + if (aSmeltingMultiplier > 0) { + this.mSmeltingMultiplier = aSmeltingMultiplier; + } + return this; + } + + /** + * This Ore should be smolten directly into an Ingot of this Material instead of an Ingot of itself. + */ + public GT_Materials setDirectSmelting(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mDirectSmelting = aMaterial.mMaterialInto.mDirectSmelting; + } + return this; + } + + /** + * This Material should be the Main Material this Ore gets ground into. + * Example, Chromite giving Chrome or Tungstate giving Tungsten. + */ + public GT_Materials setOreReplacement(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mOreReplacement = aMaterial.mMaterialInto.mOreReplacement; + } + return this; + } + + /** + * This Material smelts always into an instance of aMaterial. Used for Magnets. + */ + public GT_Materials setSmeltingInto(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mSmeltInto = aMaterial.mMaterialInto.mSmeltInto; + } + return this; + } + + /** + * This Material arc smelts always into an instance of aMaterial. Used for Wrought Iron. + */ + public GT_Materials setArcSmeltingInto(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mArcSmeltInto = aMaterial.mMaterialInto.mArcSmeltInto; + } + return this; + } + + /** + * This Material macerates always into an instance of aMaterial. + */ + public GT_Materials setMaceratingInto(final GT_Materials aMaterial) { + if (aMaterial != null) { + this.mMacerateInto = aMaterial.mMaterialInto.mMacerateInto; + } + return this; + } + + public GT_Materials setEnchantmentForTools(final Enchantment aEnchantment, final int aEnchantmentLevel) { + this.mEnchantmentTools = aEnchantment; + this.mEnchantmentToolsLevel = (byte) aEnchantmentLevel; + return this; + } + + public GT_Materials setEnchantmentForArmors(final Enchantment aEnchantment, final int aEnchantmentLevel) { + this.mEnchantmentArmors = aEnchantment; + this.mEnchantmentArmorsLevel = (byte) aEnchantmentLevel; + return this; + } + + public FluidStack getSolid(final long aAmount) { + if (this.mSolid == null) { + return null; + } + return new GT_FluidStack(this.mSolid, (int) aAmount); + } + + public FluidStack getFluid(final long aAmount) { + if (this.mFluid == null) { + return null; + } + return new GT_FluidStack(this.mFluid, (int) aAmount); + } + + public FluidStack getGas(final long aAmount) { + if (this.mGas == null) { + return null; + } + return new GT_FluidStack(this.mGas, (int) aAmount); + } + + public FluidStack getPlasma(final long aAmount) { + if (this.mPlasma == null) { + return null; + } + return new GT_FluidStack(this.mPlasma, (int) aAmount); + } + + public FluidStack getMolten(final long aAmount) { + if (this.mStandardMoltenFluid == null) { + return null; + } + return new GT_FluidStack(this.mStandardMoltenFluid, (int) aAmount); + } + + @Override + public short[] getRGBA() { + return this.mRGBa; + } + + public static volatile int VERSION = 508; + + } + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextureSet.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextureSet.java new file mode 100644 index 0000000000..26ee2bd401 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextureSet.java @@ -0,0 +1,144 @@ +package gtPlusPlus.xmod.gregtech.api.enums; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; + +public class GregtechTextureSet { + public static final GregtechTextureSet + SET_NONE = new GregtechTextureSet("NONE"), SET_DULL = new GregtechTextureSet("DULL"), SET_RUBY = new GregtechTextureSet("RUBY"), SET_OPAL = new GregtechTextureSet("OPAL"), SET_LEAF = new GregtechTextureSet("LEAF"), SET_WOOD = new GregtechTextureSet("WOOD"), SET_SAND = new GregtechTextureSet("SAND"), SET_FINE = new GregtechTextureSet("FINE"), SET_FIERY = new GregtechTextureSet("FIERY"), SET_FLUID = new GregtechTextureSet("FLUID"), SET_ROUGH = new GregtechTextureSet("ROUGH"), SET_PAPER = new GregtechTextureSet("PAPER"), SET_GLASS = new GregtechTextureSet("GLASS"), SET_FLINT = new GregtechTextureSet("FLINT"), SET_LAPIS = new GregtechTextureSet("LAPIS"), SET_SHINY = new GregtechTextureSet("SHINY"), SET_SHARDS = new GregtechTextureSet("SHARDS"), SET_POWDER = new GregtechTextureSet("POWDER"), SET_QUARTZ = new GregtechTextureSet("QUARTZ"), SET_EMERALD = new GregtechTextureSet("EMERALD"), SET_DIAMOND = new GregtechTextureSet("DIAMOND"), SET_LIGNITE = new GregtechTextureSet("LIGNITE"), SET_MAGNETIC = new GregtechTextureSet("MAGNETIC"), SET_METALLIC = new GregtechTextureSet("METALLIC"), SET_NETHERSTAR = new GregtechTextureSet("NETHERSTAR"), SET_GEM_VERTICAL = new GregtechTextureSet("GEM_VERTICAL"), SET_GEM_HORIZONTAL = new GregtechTextureSet("GEM_HORIZONTAL"); + + public final IIconContainer[] mTextures = new IIconContainer[128]; + public final String mSetName; + + public GregtechTextureSet(final String aSetName) { + this.mSetName = aSetName; + this.mTextures[0] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/turbineBlade"); + this.mTextures[1] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/toolHeadSkookumChoocher"); + this.mTextures[2] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[3] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[4] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[5] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[6] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[7] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[8] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[9] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[10] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[11] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[12] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[13] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[14] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[15] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[16] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[17] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[18] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[19] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[20] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[21] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[22] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[23] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[24] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[25] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[26] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[27] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[28] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[29] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[30] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[31] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[32] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[33] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[34] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[35] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[36] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[37] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[38] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[39] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[40] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[41] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[42] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[43] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[44] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[45] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[46] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[47] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[48] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[49] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[50] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[51] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[52] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[53] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[54] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[55] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[56] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[57] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[58] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[59] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[60] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[61] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[62] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[63] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[64] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[65] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[66] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[67] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[68] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[69] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[70] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[71] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[72] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[73] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[74] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[75] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[76] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[77] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[78] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[79] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[80] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[81] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[82] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[83] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[84] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[85] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[86] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[87] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[88] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[89] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[90] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[91] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[92] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[93] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[94] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[95] = new Textures.BlockIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[96] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[97] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[98] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[99] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[100] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[101] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[102] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[103] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[104] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[105] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[106] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[107] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[108] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[109] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[110] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[111] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[112] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[113] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[114] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[115] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[116] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[117] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[118] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[119] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[120] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[121] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[122] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[123] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[124] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[125] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[126] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + this.mTextures[127] = new Textures.ItemIcons.CustomIcon("materialicons/" + this.mSetName + "/void"); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java new file mode 100644 index 0000000000..5b1a34590f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java @@ -0,0 +1,203 @@ +package gtPlusPlus.xmod.gregtech.api.enums; + +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_IconContainer; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_Texture; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; + +public class GregtechTextures { + public enum BlockIcons implements Interface_IconContainer, Runnable { + + VOID, + + LARGECENTRIFUGE1, LARGECENTRIFUGE2, LARGECENTRIFUGE3, + LARGECENTRIFUGE4, LARGECENTRIFUGE5, LARGECENTRIFUGE6, + LARGECENTRIFUGE7, LARGECENTRIFUGE8, LARGECENTRIFUGE9, + LARGECENTRIFUGE_ACTIVE1, LARGECENTRIFUGE_ACTIVE2, LARGECENTRIFUGE_ACTIVE3, + LARGECENTRIFUGE_ACTIVE4, LARGECENTRIFUGE_ACTIVE5, LARGECENTRIFUGE_ACTIVE6, + LARGECENTRIFUGE_ACTIVE7, LARGECENTRIFUGE_ACTIVE8, LARGECENTRIFUGE_ACTIVE9; + + public static final Interface_IconContainer[] + + CENTRIFUGE = new Interface_IconContainer[]{ + LARGECENTRIFUGE1, + LARGECENTRIFUGE2, + LARGECENTRIFUGE3, + LARGECENTRIFUGE4, + LARGECENTRIFUGE5, + LARGECENTRIFUGE6, + LARGECENTRIFUGE7, + LARGECENTRIFUGE8, + LARGECENTRIFUGE9 + }, + CENTRIFUGE_ACTIVE = new Interface_IconContainer[]{ + LARGECENTRIFUGE_ACTIVE1, + LARGECENTRIFUGE_ACTIVE2, + LARGECENTRIFUGE_ACTIVE3, + LARGECENTRIFUGE_ACTIVE4, + LARGECENTRIFUGE_ACTIVE5, + LARGECENTRIFUGE_ACTIVE6, + LARGECENTRIFUGE_ACTIVE7, + LARGECENTRIFUGE_ACTIVE8, + LARGECENTRIFUGE_ACTIVE9 + }; + + public static Interface_Texture[] + GT_CASING_BLOCKS = new Interface_Texture[64]; + + protected IIcon mIcon; + + private BlockIcons() { + Meta_GT_Proxy.GT_BlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + this.mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + "iconsets/" + this); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + + public static class CustomIcon implements Interface_IconContainer, Runnable { + protected IIcon mIcon; + protected String mIconName; + + public CustomIcon(final String aIconName) { + this.mIconName = aIconName; + Meta_GT_Proxy.GT_BlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + this.mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + this.mIconName); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + } + } + + + public enum ItemIcons implements Interface_IconContainer, Runnable { + VOID, // The Empty Texture + RENDERING_ERROR, //The Purple/Black Texture + SKOOKUMCHOOCHER, //The Skookum Tool Texture + PUMP, // The Hand Pump Texture + TURBINE_SMALL, TURBINE_LARGE, TURBINE_HUGE; + + /* public static final Interface_IconContainer[] + DURABILITY_BAR = new Interface_IconContainer[]{ + DURABILITY_BAR_0, + DURABILITY_BAR_1, + DURABILITY_BAR_2, + DURABILITY_BAR_3, + DURABILITY_BAR_4, + DURABILITY_BAR_5, + DURABILITY_BAR_6, + DURABILITY_BAR_7, + DURABILITY_BAR_8, + }, + ENERGY_BAR = new Interface_IconContainer[]{ + ENERGY_BAR_0, + ENERGY_BAR_1, + ENERGY_BAR_2, + ENERGY_BAR_3, + ENERGY_BAR_4, + ENERGY_BAR_5, + ENERGY_BAR_6, + ENERGY_BAR_7, + ENERGY_BAR_8, + };*/ + + //public static final Interface_Texture[] ERROR_RENDERING = new Interface_Texture[]{new GregtechRenderedTexture(RENDERING_ERROR)}; + + protected IIcon mIcon, mOverlay; + + private ItemIcons() { + Meta_GT_Proxy.GT_ItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + + @Override + public void run() { + this.mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this); + this.mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this + "_OVERLAY"); + } + + public static class CustomIcon implements Interface_IconContainer, Runnable { + protected IIcon mIcon, mOverlay; + protected String mIconName; + + public CustomIcon(final String aIconName) { + this.mIconName = aIconName; + Meta_GT_Proxy.GT_ItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public void run() { + this.mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + this.mIconName); + this.mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + this.mIconName + "_OVERLAY"); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + } + } + +} + diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechToolDictNames.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechToolDictNames.java new file mode 100644 index 0000000000..105023065c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechToolDictNames.java @@ -0,0 +1,7 @@ +package gtPlusPlus.xmod.gregtech.api.enums; + +public enum GregtechToolDictNames { + + craftingToolSkookumChoocher, craftingToolHandPump, craftingToolAngleGrinder, craftingToolElectricSnips, craftingToolElectricLighter, craftingToolElectricButcherKnife; + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedBoiler.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedBoiler.java new file mode 100644 index 0000000000..04d8d91201 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_AdvancedBoiler.java @@ -0,0 +1,93 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GT_MetaTileEntity_Boiler_Base; + +public class CONTAINER_AdvancedBoiler + extends GT_ContainerMetaTile_Machine { + public int mWaterAmount = 0; + public int mSteamAmount = 0; + public int mProcessingEnergy = 0; + public int mTemperature = 2; + + public CONTAINER_AdvancedBoiler(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); + addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); + addSlotToContainer(new Slot(this.mTileEntity, 3, 116, 26)); + } + + @Override + public int getSlotCount() { + return 4; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + return; + } + + int steamCapacity = ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).getSteamCapacity(); + int waterCapacity = ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).getCapacity(); + this.mTemperature = ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mTemperature; + this.mProcessingEnergy = ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; + this.mSteamAmount = (((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mSteam == null ? 0 : ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mSteam.amount); + this.mWaterAmount = (((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mFluid == null ? 0 : ((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).mFluid.amount); + + this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GT_MetaTileEntity_Boiler_Base) this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); + this.mSteamAmount = Math.min(54, Math.max(0, this.mSteamAmount * 54 / (steamCapacity - 100))); + this.mWaterAmount = Math.min(54, Math.max(0, this.mWaterAmount * 54 / (waterCapacity - 100))); + this.mProcessingEnergy = Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, this.mProcessingEnergy * 14 / 1000)); + + Iterator<?> var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mTemperature); + var1.sendProgressBarUpdate(this, 101, this.mProcessingEnergy); + var1.sendProgressBarUpdate(this, 102, this.mSteamAmount); + var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + this.mTemperature = par2; + break; + case 101: + this.mProcessingEnergy = par2; + break; + case 102: + this.mSteamAmount = par2; + break; + case 103: + this.mWaterAmount = par2; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Cyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Cyclotron.java new file mode 100644 index 0000000000..6d0eb6b14c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Cyclotron.java @@ -0,0 +1,37 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * The Container I use for all my Basic Machines + */ +public class CONTAINER_Cyclotron extends GT_ContainerMetaTile_Machine { + + public CONTAINER_Cyclotron(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_Cyclotron(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + //this.addSlotToContainer(new Slot(this.mTileEntity, 1, 154, 42)); + } + + @Override + public int getSlotCount() { + return 0; + } + + @Override + public int getShiftClickSlotCount() { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java new file mode 100644 index 0000000000..a4508781aa --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_DeluxeTank.java @@ -0,0 +1,80 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +import gregtech.api.gui.GT_Container_BasicTank; +import gregtech.api.gui.GT_Slot_Output; +import gregtech.api.gui.GT_Slot_Render; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * The Container I use for all my Basic Tanks + */ +public class CONTAINER_DeluxeTank extends GT_Container_BasicTank { + + public CONTAINER_DeluxeTank(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 0, 80, 17)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 41, 42)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 3, 59, 42)); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (this.mTileEntity.isClientSide() || (this.mTileEntity.getMetaTileEntity() == null)) { + return; + } + if (((GT_MetaTileEntity_DeluxeTank) this.mTileEntity.getMetaTileEntity()).mFluid != null) { + this.mContent = ((GT_MetaTileEntity_DeluxeTank) this.mTileEntity.getMetaTileEntity()).mFluid.amount; + } else { + this.mContent = 0; + } + final Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + final ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mContent & 65535); + var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(final int par1, final int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + this.mContent = (this.mContent & -65536) | par2; + break; + case 101: + this.mContent = (this.mContent & 65535) | (par2 << 16); + break; + } + } + + @Override + public int getSlotCount() { + return 2; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java new file mode 100644 index 0000000000..17226a399e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.slots.SlotAirFilter; +import net.minecraft.entity.player.InventoryPlayer; + + +public class CONTAINER_Hatch_Muffler_Advanced extends GT_ContainerMetaTile_Machine { + + public long maxEU = 0; + public long storedEU = 0; + + public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new SlotAirFilter(this.mTileEntity, 0, 80, 35)); + } + + @Override + public int getSlotCount() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } + + @Override + public void updateProgressBar(final int id, final int value) { + super.updateProgressBar(id, value); + switch (id) { + default: + break; + } + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java new file mode 100644 index 0000000000..df8df2f775 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IndustrialCentrifuge.java @@ -0,0 +1,39 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * The Container I use for all my Basic Machines + */ +public class CONTAINER_IndustrialCentrifuge extends GT_ContainerMetaTile_Machine { + + public CONTAINER_IndustrialCentrifuge(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_IndustrialCentrifuge(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 1, 154, 42)); + } + + @Override + public int getSlotCount() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IronBlastFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IronBlastFurnace.java new file mode 100644 index 0000000000..78150aedbe --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_IronBlastFurnace.java @@ -0,0 +1,32 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Output; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class CONTAINER_IronBlastFurnace extends GT_ContainerMetaTile_Machine { + public CONTAINER_IronBlastFurnace(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 0, 34, 16)); + this.addSlotToContainer(new Slot(this.mTileEntity, 1, 34, 34)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 2, 86, 25)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 3, 104, 25)); + } + + @Override + public int getSlotCount() { + return 4; + } + + @Override + public int getShiftClickSlotCount() { + return 2; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java new file mode 100644 index 0000000000..808eb90728 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MatterFab.java @@ -0,0 +1,42 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_MassFabricator; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * The Container I use for all my Basic Machines + */ +public class CONTAINER_MatterFab extends GT_ContainerMetaTile_Machine { + + public int mUUA_USED = ((GregtechMetaTileEntity_MassFabricator)this.mTileEntity.getMetaTileEntity()).getAmplifierUsed(); + public int mUUM_MADE = ((GregtechMetaTileEntity_MassFabricator)this.mTileEntity.getMetaTileEntity()).getMatterProduced(); + + public CONTAINER_MatterFab(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_MatterFab(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + //addSlotToContainer(new SlotNoInput(mTileEntity, 1, 152, 5)); + } + + @Override + public int getSlotCount() { + return 0; + } + + @Override + public int getShiftClickSlotCount() { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java new file mode 100644 index 0000000000..6a3322ab2e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MetaTileMachineLong.java @@ -0,0 +1,244 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +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.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; + +import java.util.Iterator; + +public class CONTAINER_MetaTileMachineLong extends GT_Container { + + public int mActive = 0, mMaxProgressTime = 0, mProgressTime = 0, mSteam = 0, mSteamStorage = 0, mOutput = 0, mInput = 0, mID = 0, mDisplayErrorCode = 0; + private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, oSteam = 0, oSteamStorage = 0, oOutput = 0, oInput = 0, oID = 0, oDisplayErrorCode = 0, mTimer = 0; + + public long pEnergy, pStorage; + private long nEnergy, nStorage; + + public short pIntMaxCountCurrent, pIntMaxCountMax; + private short nIntMaxCountCurrent, nIntMaxCountMax; + + public CONTAINER_MetaTileMachineLong(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + + mTileEntity = aTileEntity; + + if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { + addSlots(aInventoryPlayer); + if (doesBindPlayerInventory()) bindPlayerInventory(aInventoryPlayer); + detectAndSendChanges(); + } else { + aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; + } + } + public CONTAINER_MetaTileMachineLong(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean doesBindInventory) { + super(aInventoryPlayer, aTileEntity); + mTileEntity = aTileEntity; + + if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { + addSlots(aInventoryPlayer); + if (doesBindPlayerInventory() && doesBindInventory) bindPlayerInventory(aInventoryPlayer); + detectAndSendChanges(); + } else { + aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; + } + } + + private Pair<Integer, Integer> getPowerStored(){ + final long mStoredPower = this.pEnergy; + long mMaxInts = (mStoredPower/Integer.MAX_VALUE); + long mLeftOver = (mStoredPower % Integer.MAX_VALUE); + if (mMaxInts < 0 || mMaxInts >= /*4294967298L*/ Integer.MAX_VALUE) { + return new Pair<Integer, Integer>(-1, 0); + } + if (mLeftOver < 0 || mLeftOver > Integer.MAX_VALUE) { + mLeftOver = 0; + } + Pair<Integer, Integer> power = new Pair<Integer, Integer>((int) mMaxInts, (int) mLeftOver); + return power; + } + + private Pair<Integer, Integer> getMaxPowerStored(){ + final long mMaxStoredPower = this.pStorage; + long mMaxInts = (mMaxStoredPower/Integer.MAX_VALUE); + long mLeftOver = (mMaxStoredPower % Integer.MAX_VALUE); + if (mMaxInts < 0 || mMaxInts >= /*4294967298L*/ Integer.MAX_VALUE) { + return new Pair<Integer, Integer>(-1, 0); + } + if (mLeftOver < 0 || mLeftOver > Integer.MAX_VALUE) { + mLeftOver = 0; + } + Pair<Integer, Integer> power = new Pair<Integer, Integer>((int) mMaxInts, (int) mLeftOver); + return power; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + pStorage = Math.min(Long.MAX_VALUE, mTileEntity.getEUCapacity()); + pEnergy = Math.min(Long.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++; + + Pair<Integer, Integer> powerPacket = getPowerStored(); + Pair<Integer, Integer> maxPowerPacket = getMaxPowerStored(); + + int mPacketsToSend = powerPacket.getKey(); + int mLeftOverPowerStored = powerPacket.getValue(); + + int mMaxStorageA = maxPowerPacket.getKey(); + int mMaxStorageB = maxPowerPacket.getValue(); + + //Someone has a VERY FULL power supply. + if (mPacketsToSend == -1) { + Logger.INFO("TOO MUCH MATH - USE BIGINTEGER - GAME BREAKING BUG MAY OCCUR"); + return; + } + + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + if (mTimer % 500 == 10 || nEnergy != pEnergy) { + var1.sendProgressBarUpdate(this, 0, mLeftOverPowerStored & 65535); + var1.sendProgressBarUpdate(this, 1, mLeftOverPowerStored >>> 16); + var1.sendProgressBarUpdate(this, 7730, mPacketsToSend); + } + if (mTimer % 500 == 10 || nStorage != pStorage) { + var1.sendProgressBarUpdate(this, 2, mMaxStorageB & 65535); + var1.sendProgressBarUpdate(this, 3, mMaxStorageB >>> 16); + var1.sendProgressBarUpdate(this, 7731, mMaxStorageA); + } + 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; + nEnergy = pEnergy; + nStorage = pStorage; + 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 7730: + pIntMaxCountCurrent = par2;*/ + case 0: + pEnergy = pEnergy & -65536 | par2; + break; + case 1: + pEnergy = pEnergy & 65535 | par2 << 16; + break; + case 2: + pStorage = pStorage & -65536 | par2; + break; + case 3: + pStorage = pStorage & 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); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java new file mode 100644 index 0000000000..88b9661c95 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java @@ -0,0 +1,283 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * The Container I use for all my Basic Machines + */ +public class CONTAINER_MultiMachine extends GT_ContainerMetaTile_Machine { + + public String[] mTileDescription; + private String[] oTileDescription; + + private GregtechMeta_MultiBlockBase mMCTEI; + private boolean mControllerSet = false; + + + public CONTAINER_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + public static void setControllerInstance(CONTAINER_MultiMachine aContainer, IGregTechTileEntity aTile) { + if (aTile == null) { + return; + } + final IMetaTileEntity aMetaTileEntity = aTile.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return; + } + if (aMetaTileEntity instanceof GregtechMeta_MultiBlockBase) { + aContainer.mMCTEI = (GregtechMeta_MultiBlockBase) aMetaTileEntity; + } + } + + public int aTotalTickTime = 0; + public int aMaxParallel = 0; + public int aPollutionTick = 0; + public int aMaxInputVoltage = 0; + public int aInputTier = 0; + public int aOutputTier = 0; + public int aRecipeDuration = 0; + public int aRecipeEU = 0; + public int aRecipeSpecial = 0; + public int aPollutionReduction = 0; + public int aStoredEnergy = 0; + public int aMaxEnergy = 0; + public int aEfficiency = 0; + + private int oTotalTickTime = 0; + private int oMaxParallel = 0; + private int oPollutionTick = 0; + private int oMaxInputVoltage = 0; + private int oInputTier = 0; + private int oOutputTier = 0; + private int oRecipeDuration = 0; + private int oRecipeEU = 0; + private int oRecipeSpecial = 0; + private int oPollutionReduction = 0; + private int oStoredEnergy = 0; + private int oMaxEnergy = 0; + private int oEfficiency = 0; + + private static Field timer; + //private static Field crafters; + + @Override + public final void detectAndSendChanges() { + super.detectAndSendChanges(); + if (this.mTileEntity.isClientSide() || this.mTileEntity.getMetaTileEntity() == null) { + return; + } + if (!mControllerSet) { + setControllerInstance(this, this.mTileEntity); + } + mControllerSet = (mMCTEI != null); + if (timer == null) { + timer = ReflectionUtils.getField(getClass(), "mTimer"); + } + if (crafters == null) { + //crafters = ReflectionUtils.getField(getClass(), "crafters"); + } + if (timer != null && crafters != null && mControllerSet) { + //Logger.INFO("Trying to update clientside GUI data"); + try { + //Logger.INFO("0"); + int aTimer = (int) ReflectionUtils.getFieldValue(timer, this); + + //List crafters1List = (List) crafters1; + List<ICrafting> crafters2 = new ArrayList<ICrafting>(); + //Logger.INFO("1"); + for (Object o : crafters) { + if (o instanceof ICrafting) { + crafters2.add((ICrafting) o); + } + } + //Logger.INFO("2"); + if (!crafters2.isEmpty()) { + //Logger.INFO("3"); + handleInitialFieldSetting(); + + try { + //Logger.INFO("4"); + for (final ICrafting var3 : crafters2) { + handleCraftingEvent(aTimer, var3); + } + //Logger.INFO("5"); + handleInternalFieldSetting(); + //Logger.INFO("6"); + } catch (Throwable t) { + + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + else { + Logger.INFO("Failed."); + } + } + + public void handleInitialFieldSetting() { + this.aTotalTickTime = MathUtils.balance((int) mMCTEI.getTotalRuntimeInTicks(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aMaxParallel = mMCTEI.getMaxParallelRecipes(); + this.aPollutionTick = mMCTEI.getPollutionPerTick(null); + this.aMaxInputVoltage = MathUtils.balance((int) mMCTEI.getMaxInputVoltage(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aInputTier = MathUtils.balance((int) mMCTEI.getInputTier(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aOutputTier = MathUtils.balance((int) mMCTEI.getOutputTier(), Integer.MIN_VALUE, Integer.MAX_VALUE); + if (mMCTEI.mLastRecipe != null) { + GT_Recipe aRecipe = mMCTEI.mLastRecipe; + this.aRecipeDuration = MathUtils.balance(aRecipe.mDuration, Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aRecipeEU = MathUtils.balance(aRecipe.mEUt, Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aRecipeSpecial = MathUtils.balance(aRecipe.mSpecialValue, Integer.MIN_VALUE, Integer.MAX_VALUE); + } + this.aPollutionReduction = mMCTEI.getPollutionReductionForAllMufflers(); + + this.aStoredEnergy = MathUtils.balance((int) mMCTEI.getStoredEnergyInAllEnergyHatches(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aMaxEnergy = MathUtils.balance((int) mMCTEI.getMaxEnergyStorageOfAllEnergyHatches(), Integer.MIN_VALUE, Integer.MAX_VALUE); + this.aEfficiency = MathUtils.balance(mMCTEI.mEfficiency, Integer.MIN_VALUE, Integer.MAX_VALUE); + } + + public void handleCraftingEvent(int aTimer, ICrafting aCrafter) { + int aID = 750; + if (aTimer % 500 == 10 || this.oTotalTickTime != this.aTotalTickTime) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aTotalTickTime); + } + if (aTimer % 500 == 10 || this.oMaxParallel != this.aMaxParallel) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxParallel); + } + if (aTimer % 500 == 10 || this.oPollutionTick != this.aPollutionTick) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aPollutionTick); + } + if (aTimer % 500 == 10 || this.oMaxInputVoltage != this.aMaxInputVoltage) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxInputVoltage); + } + if (aTimer % 500 == 10 || this.oInputTier != this.aInputTier) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aInputTier); + } + if (aTimer % 500 == 10 || this.oOutputTier != this.aOutputTier) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aOutputTier); + } + if (aTimer % 500 == 10 || this.oRecipeDuration != this.aRecipeDuration) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeDuration); + } + if (aTimer % 500 == 10 || this.oRecipeEU != this.aRecipeEU) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeEU); + } + if (aTimer % 500 == 10 || this.oRecipeSpecial != this.aRecipeSpecial) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aRecipeSpecial); + } + if (aTimer % 500 == 10 || this.oPollutionReduction != this.aPollutionReduction) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aPollutionReduction); + } + if (aTimer % 500 == 10 || this.oStoredEnergy != this.aStoredEnergy) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aStoredEnergy); + } + if (aTimer % 500 == 10 || this.oMaxEnergy != this.aMaxEnergy) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aMaxEnergy); + } + if (aTimer % 500 == 10 || this.oEfficiency != this.aEfficiency) { + aCrafter.sendProgressBarUpdate((Container) this, aID++, this.aEfficiency); + } + } + + public void handleInternalFieldSetting() { + this.oTotalTickTime = this.aTotalTickTime; + this.oMaxParallel = this.aMaxParallel; + this.oPollutionTick = this.aPollutionTick; + this.oMaxInputVoltage = this.aMaxInputVoltage; + this.oInputTier = this.aInputTier; + this.oOutputTier = this.aOutputTier; + this.oRecipeDuration = this.aRecipeDuration; + this.oRecipeEU = this.aRecipeEU; + this.oRecipeSpecial = this.aRecipeSpecial; + this.oPollutionReduction = this.aPollutionReduction; + this.oStoredEnergy = this.aStoredEnergy; + this.oMaxEnergy = this.aMaxEnergy; + this.oEfficiency = this.aEfficiency; + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(final int par1, final int par2) { + super.updateProgressBar(par1, par2); + int shiftedSwitch = par1 - 750; + switch (shiftedSwitch) { + case 0: { + this.aTotalTickTime = par2; + break; + } + case 1: { + this.aMaxParallel = par2; + break; + } + case 2: { + this.aPollutionTick = par2; + break; + } + case 3: { + this.aMaxInputVoltage = par2; + break; + } + case 4: { + this.aInputTier = par2; + break; + } + case 5: { + this.aOutputTier = par2; + break; + } + case 6: { + this.aRecipeDuration = par2; + break; + } + case 7: { + this.aRecipeEU = par2; + break; + } + case 8: { + this.aRecipeSpecial = par2; + break; + } + case 9: { + this.aPollutionReduction = par2; + break; + } + case 10: { + this.aStoredEnergy = par2; + break; + } + case 11: { + this.aMaxEnergy = par2; + break; + } + case 12: { + this.aEfficiency = par2; + break; + } + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine_NoPlayerInventory.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine_NoPlayerInventory.java new file mode 100644 index 0000000000..2d63a13d60 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine_NoPlayerInventory.java @@ -0,0 +1,27 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class CONTAINER_MultiMachine_NoPlayerInventory extends CONTAINER_MultiMachine { + + public CONTAINER_MultiMachine_NoPlayerInventory(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_MultiMachine_NoPlayerInventory(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + public boolean doesBindPlayerInventory() { + return false; + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + return null; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java new file mode 100644 index 0000000000..937513751b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_PowerSubStation.java @@ -0,0 +1,41 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; + +import gregtech.api.gui.GT_Container_MultiMachine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.slots.SlotNoInput; + +import net.minecraft.entity.player.InventoryPlayer; + +public class CONTAINER_PowerSubStation extends GT_Container_MultiMachine { + + public CONTAINER_PowerSubStation(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_PowerSubStation(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, + final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot((IInventory) this.mTileEntity, 1, 155, 5)); + this.addSlotToContainer(new SlotNoInput((IInventory) this.mTileEntity, 2, 155, 23)); + + for (int i = 0; i < 9; ++i) { + this.addSlotToContainer(new Slot((IInventory) aInventoryPlayer, i, 8 + i * 18, 167)); + } + + } + + public int getSlotCount() { + return 10; + } + + public int getShiftClickSlotCount() { + return 1; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SafeBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SafeBlock.java new file mode 100644 index 0000000000..9a84ba66ab --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SafeBlock.java @@ -0,0 +1,124 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.util.player.PlayerCache; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaSafeBlock; + +public class CONTAINER_SafeBlock +extends GT_ContainerMetaTile_Machine { + public CONTAINER_SafeBlock(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + //public String UUID = ((BaseMetaTileEntity)mTileEntity).getMetaTileEntity().getBaseMetaTileEntity().getOwnerName(); + public UUID ownerUUID = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).ownerUUID; + public String tempPlayer = PlayerCache.lookupPlayerByUUID(this.ownerUUID); + public boolean blockStatus = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bUnbreakable; + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + this.addSlotToContainer(new Slot(this.mTileEntity, x + (y * 9), 8 + (x * 18), 5 + (y * 18))); + } + } + this.addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 8, 63, false, true, 1)); + this.addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 26, 63, false, true, 1)); + this.addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 27, 44, 63, false, true, 1)); + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + final int runs = 0; + if (aSlotIndex < 27) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + final Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + if (tSlot != null) { + if (this.mTileEntity.getMetaTileEntity() == null) { + return null; + } + if (aSlotIndex == 27) { + + + /*((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bOutput = (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bOutput); + if (((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bOutput) { + if (aPlayer != null && aPlayer instanceof EntityPlayerMP && (((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bOutput != false)) { + + Utils.LOG_INFO(String.valueOf(Sys.is64Bit())); + Utils.messagePlayer(aPlayer, "Salmon"); + } + + GT_Utility.sendChatToPlayer(aPlayer, "Emit Energy to Outputside"); + } else { + GT_Utility.sendChatToPlayer(aPlayer, "Don't emit Energy"); + } + return null;*/ + + + } + if (aSlotIndex == 28) {} + /* ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull = (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull); + if (((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bRedstoneIfFull) { + GT_Utility.sendChatToPlayer(aPlayer, "Emit Redstone if no Slot is free"); + } else { + GT_Utility.sendChatToPlayer(aPlayer, "Don't emit Redstone"); + } + return null; + }*/ + if (aSlotIndex == 29) /*{ + if (((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable) { + if (((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable) { + makeIndestructible(aPlayer); + } + else { + + } + } else { + makeIndestructible(aPlayer); + } + return null; + }*/ + + { + ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable = (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable); + this.blockStatus = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bUnbreakable; + this.ownerUUID = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).ownerUUID; + //Utils.messagePlayer(aPlayer, "Is the safe locked? "+String.valueOf(((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable).toUpperCase()); + /*if (aPlayer != null && aPlayer instanceof EntityPlayerMP && (((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bUnbreakable != false)) { + UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); + Xasda.setmTileEntity((BaseMetaTileEntity) mTileEntity, aPlayer); + } + else { + UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); + Xasda.setmTileEntity((BaseMetaTileEntity) mTileEntity, aPlayer); + }*/ + return null; + } + + + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public int getSlotCount() { + return 27; + } + + @Override + public int getShiftClickSlotCount() { + return 27; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SolarGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SolarGenerator.java new file mode 100644 index 0000000000..a3f58836e3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SolarGenerator.java @@ -0,0 +1,85 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntitySolarGenerator; + +public class CONTAINER_SolarGenerator +extends GT_ContainerMetaTile_Machine { + public int mWaterAmount = 0; + public int mSteamAmount = 0; + public int mProcessingEnergy = 0; + public int mTemperature = 2; + public CONTAINER_SolarGenerator(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + //addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); + //addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); + //addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); + //addSlotToContainer(new Slot(this.mTileEntity, 3, 116, 26)); + } + + @Override + public int getSlotCount() { + return 0; + } + + @Override + public int getShiftClickSlotCount() { + return 0; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + return; + } + this.mTemperature = ((GregtechMetaTileEntitySolarGenerator) this.mTileEntity.getMetaTileEntity()).mSolarCharge; + this.mProcessingEnergy = ((GregtechMetaTileEntitySolarGenerator) this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; + + this.mTemperature = Math.min(54, Math.max(0, (this.mTemperature * 54) / (((GregtechMetaTileEntitySolarGenerator) this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); + this.mEnergy = (int) Math.min(Integer.MAX_VALUE, this.mTileEntity.getStoredEU()); + this.mProcessingEnergy = Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, (this.mProcessingEnergy * 14) / 1000)); + + final Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + final ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mTemperature); + var1.sendProgressBarUpdate(this, 101, this.mProcessingEnergy); + var1.sendProgressBarUpdate(this, 102, this.mSteamAmount); + var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(final int par1, final int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100: + this.mTemperature = par2; + break; + case 101: + this.mProcessingEnergy = par2; + break; + case 102: + this.mSteamAmount = par2; + break; + case 103: + this.mWaterAmount = par2; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SteamCondenser.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SteamCondenser.java new file mode 100644 index 0000000000..6fcd53b139 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SteamCondenser.java @@ -0,0 +1,99 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechMetaBoilerBase; + +public class CONTAINER_SteamCondenser extends GT_ContainerMetaTile_Machine +{ + public CONTAINER_SteamCondenser(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) + { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) + { + this.addSlotToContainer(new Slot(this.mTileEntity, 2, 116, 62)); + this.addSlotToContainer(new Slot(this.mTileEntity, 0, 44, 26)); + this.addSlotToContainer(new Slot(this.mTileEntity, 1, 44, 62)); + this.addSlotToContainer(new Slot(this.mTileEntity, 3, 116, 26)); + } + + @Override + public int getSlotCount() + { + return 4; + } + + @Override + public int getShiftClickSlotCount() + { + return 1; + } + + public int mWaterAmount = 0; + public int mSteamAmount = 0; + public int mProcessingEnergy = 0; + public int mTemperature = 2; + public long mTickingTime = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).RI; + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + return; + } + int steamCapacity = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).getSteamCapacity(); + int waterCapacity = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).getCapacity(); + this.mTemperature = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mTemperature; + this.mProcessingEnergy = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mProcessingEnergy; + this.mSteamAmount = (((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mSteam == null ? 0 : ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mSteam.amount); + this.mWaterAmount = (((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mFluid == null ? 0 : ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).mFluid.amount); + this.mTickingTime = ((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).RI; + + this.mTemperature = Math.min(54, Math.max(0, (this.mTemperature * 54) / (((GregtechMetaBoilerBase)this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); + this.mSteamAmount = Math.min(54, Math.max(0, (this.mSteamAmount * 54) / (steamCapacity - 100))); + this.mWaterAmount = Math.min(54, Math.max(0, (this.mWaterAmount * 54) / (waterCapacity - 100))); + this.mProcessingEnergy = Math.min(14, Math.max(this.mProcessingEnergy > 0 ? 1 : 0, (this.mProcessingEnergy * 14) / 1000)); + + final Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) + { + final ICrafting var1 = (ICrafting)var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mTemperature); + var1.sendProgressBarUpdate(this, 101, this.mProcessingEnergy); + var1.sendProgressBarUpdate(this, 102, this.mSteamAmount); + var1.sendProgressBarUpdate(this, 103, this.mWaterAmount); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(final int par1, final int par2) + { + super.updateProgressBar(par1, par2); + switch (par1) + { + case 100: + this.mTemperature = par2; break; + case 101: + this.mProcessingEnergy = par2; break; + case 102: + this.mSteamAmount = par2; break; + case 103: + this.mWaterAmount = par2; + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java new file mode 100644 index 0000000000..dcab57c380 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java @@ -0,0 +1,78 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Output; +import gregtech.api.gui.GT_Slot_Render; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.slots.SlotLockedInput; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_Large; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; + +public class CONTAINER_SuperChest extends GT_ContainerMetaTile_Machine { + + public int mContent = 0; + private ItemStack mLockedSlotStack = null; + + public CONTAINER_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new SlotLockedInput(this.mTileEntity, 0, 80, 17, mLockedSlotStack)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 59, 42)); + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) { + if (this.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_TieredChest) { + this.mContent = ((GT_MetaTileEntity_TieredChest) this.mTileEntity.getMetaTileEntity()).mItemCount; + mLockedSlotStack = ((GT_MetaTileEntity_TieredChest) this.mTileEntity.getMetaTileEntity()).mItemStack; + } + if (this.mTileEntity.getMetaTileEntity() instanceof GT4Entity_Shelf_Large) { + this.mContent = ((GT4Entity_Shelf_Large) this.mTileEntity.getMetaTileEntity()).mItemCount; + mLockedSlotStack = ((GT4Entity_Shelf_Large) this.mTileEntity.getMetaTileEntity()).mItemStack; + } + else { + this.mContent = 0; + } + + Iterator var2 = this.crafters.iterator(); + + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mContent & 65535); + var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); + } + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100 : + this.mContent = this.mContent & -65536 | par2; + break; + case 101 : + this.mContent = this.mContent & 65535 | par2 << 16; + } + + } + + public int getSlotCount() { + return 2; + } + + public int getShiftClickSlotCount() { + return 1; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java new file mode 100644 index 0000000000..bf4dffb904 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java @@ -0,0 +1,71 @@ + +package gtPlusPlus.xmod.gregtech.api.gui; + +import java.util.List; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.slots.SlotBuzzSaw; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntityTreeFarm; + +public class CONTAINER_TreeFarmer extends GT_ContainerMetaTile_Machine { + + public long maxEU = 0; + public long storedEU = 0; + + public CONTAINER_TreeFarmer(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_TreeFarmer(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new SlotBuzzSaw(this.mTileEntity, 1, 80, 17)); + } + + @Override + public int getSlotCount() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } + + @Override + public void updateProgressBar(final int id, final int value) { + super.updateProgressBar(id, value); + switch (id) { + case 100: + this.maxEU = value; + return; + case 101: + this.storedEU = value; + break; + default: + break; + } + } + + @SuppressWarnings("unchecked") + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + for(final ICrafting crafting : (List<ICrafting>)this.crafters) { + crafting.sendProgressBarUpdate(this, 100, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).maxEUStore()); + crafting.sendProgressBarUpdate(this, 101, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).getEUVar()); + if (((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).isCorrectMachinePart(this.mTileEntity.getStackInSlot(1))){ + this.mTileEntity.markDirty(); + } + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedBoiler.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedBoiler.java new file mode 100644 index 0000000000..d532a98030 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_AdvancedBoiler.java @@ -0,0 +1,44 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GUI_AdvancedBoiler + extends GT_GUIContainerMetaTile_Machine { + public GUI_AdvancedBoiler(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aTextureName) { + super(new CONTAINER_AdvancedBoiler(aInventoryPlayer, aTileEntity), "miscutils:textures/gui/" + aTextureName); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString("Advanced Boiler", 8, 4, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mContainer != null) { + int tScale = ((CONTAINER_AdvancedBoiler) this.mContainer).mSteamAmount; + if (tScale > 0) { + drawTexturedModalRect(x + 70, y + 25 + 54 - tScale, 194, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_AdvancedBoiler) this.mContainer).mWaterAmount; + if (tScale > 0) { + drawTexturedModalRect(x + 83, y + 25 + 54 - tScale, 204, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_AdvancedBoiler) this.mContainer).mTemperature; + if (tScale > 0) { + drawTexturedModalRect(x + 96, y + 25 + 54 - tScale, 214, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_AdvancedBoiler) this.mContainer).mProcessingEnergy; + if (tScale > 0) { + drawTexturedModalRect(x + 117, y + 44 + 14 - tScale, 177, 14 - tScale, 15, tScale + 1); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Cyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Cyclotron.java new file mode 100644 index 0000000000..0be44fa616 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Cyclotron.java @@ -0,0 +1,44 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_Container_MultiMachine; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_Cyclotron extends GT_GUIContainerMetaTile_Machine +{ + public final String mNEI; + public final String mName; + + public GUI_Cyclotron(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aNEI) { + super(new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity, false), "gregtech:textures/gui/multimachines/" + "FusionComputer.png"); + this.mName = aName; + this.mNEI = aNEI; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 8, -10, 16448255); + if (this.mContainer != null) { + if ((((GT_Container_MultiMachine)this.mContainer).mDisplayErrorCode & 0x40) != 0x0) { + this.fontRendererObj.drawString("Incomplete Structure.", 10, 8, 16448255); + } + if (((GT_Container_MultiMachine)this.mContainer).mDisplayErrorCode == 0) { + if (((GT_Container_MultiMachine)this.mContainer).mActive == 0) { + this.fontRendererObj.drawString("Hit with Soft Hammer to (re-)start the Machine if it doesn't start.", -70, 170, 16448255); + } + else { + this.fontRendererObj.drawString("Running perfectly.", 10, 170, 16448255); + } + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java new file mode 100644 index 0000000000..c6d8d4ef7e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_DeluxeTank.java @@ -0,0 +1,37 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GUI_DeluxeTank extends GT_GUIContainerMetaTile_Machine { + + private final String mName; + + public GUI_DeluxeTank(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName) { + super(new CONTAINER_DeluxeTank(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "BasicTank.png"); + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, (this.ySize - 96) + 2, 4210752); + this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); + if (this.mContainer != null) { + this.fontRendererObj.drawString("Fuel | A | B |", 10, 20, 16448255); + //fontRendererObj.drawString(GT_Utility.parseNumberToString(((CONTAINER_DeluxeTank) mContainer).mContent), 10, 30, 16448255); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java new file mode 100644 index 0000000000..4b998f6487 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java @@ -0,0 +1,46 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_Hatch_Muffler_Advanced extends GT_GUIContainerMetaTile_Machine { + + String mName = ""; + long maxPower = 0; + long storedPower = 0; + + public GUI_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { + super(new CONTAINER_Hatch_Muffler_Advanced(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 8, 8, 16448255); + /* + * ReflectionUtils.setField(this.fontRendererObj, "underlineStyle", true); + * ReflectionUtils.setField(this.fontRendererObj, "italicStyle", true); + * ReflectionUtils.setField(this.fontRendererObj, "boldStyle", true); boolean + * isBold = ReflectionUtils.getField(this.fontRendererObj, "boldStyle"); + * this.fontRendererObj.drawString("Insert Air Filters - Bold: "+isBold, 8, 18, + * 16448255); + */ + if (this.mContainer != null) { + //this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + //this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + //this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + //this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java new file mode 100644 index 0000000000..2e1f76f362 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IndustrialCentrifuge.java @@ -0,0 +1,73 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.lib.CORE; + + +public class GUI_IndustrialCentrifuge extends GT_GUIContainerMetaTile_Machine { + + String mName = ""; + private short counter = 0; + + public GUI_IndustrialCentrifuge(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { + super(new CONTAINER_IndustrialCentrifuge(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); + if (this.counter >= 100){ + this.counter = 0; + } + else { + this.counter++; + } + if (this.mContainer != null) { + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 1) != 0) { + this.fontRendererObj.drawString("Pipe is loose.", 10, 16, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 2) != 0) { + this.fontRendererObj.drawString("Screws are missing.", 10, 24, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 4) != 0) { + this.fontRendererObj.drawString("Something is stuck.", 10, 32, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 8) != 0) { + this.fontRendererObj.drawString("Platings are dented.", 10, 40, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 32) != 0) { + this.fontRendererObj.drawString("That doesn't belong there.", 10, 56, 16448255); + } + if ((((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode & 64) != 0) { + this.fontRendererObj.drawString("Incomplete Structure.", 10, 64, 16448255); + } + + if (((CONTAINER_IndustrialCentrifuge) this.mContainer).mDisplayErrorCode == 0) { + if (((CONTAINER_IndustrialCentrifuge) this.mContainer).mActive == 0) { + this.fontRendererObj.drawString("Hit with Soft Hammer", 10, 16, 16448255); + this.fontRendererObj.drawString("to (re-)start the Machine", 10, 24, 16448255); + this.fontRendererObj.drawString("if it doesn't start.", 10, 32, 16448255); + } else { + this.fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255); + /*if (CORE.DEBUG){ + fontRendererObj.drawString("Debug Counter: "+counter, 10, 56, 16448255); + }*/ + } + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IronBlastFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IronBlastFurnace.java new file mode 100644 index 0000000000..b44ad916b7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_IronBlastFurnace.java @@ -0,0 +1,32 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.lib.CORE; + +public class GUI_IronBlastFurnace +extends GT_GUIContainerMetaTile_Machine { + public GUI_IronBlastFurnace(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(new CONTAINER_IronBlastFurnace(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI+"IronBlastFurnace.png"); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString("Iron Blast Furnace", 8, 4, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if ((this.mContainer != null) && + (this.mContainer.mProgressTime > 0)) { + this.drawTexturedModalRect(x + 58, y + 28, 176, 0, Math.max(0, Math.min(20, 1 + ((this.mContainer.mProgressTime * 20) / (this.mContainer.mMaxProgressTime < 1 ? 1 : this.mContainer.mMaxProgressTime)))), 11); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MatterFab.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MatterFab.java new file mode 100644 index 0000000000..95bde9fd9f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MatterFab.java @@ -0,0 +1,81 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.lib.CORE; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * The GUI-Container I use for all my Basic Machines + * <p/> + * As the NEI-RecipeTransferRect Handler can't handle one GUI-Class for all GUIs I needed to produce some dummy-classes which extend this class + */ +public class GUI_MatterFab extends GT_GUIContainerMetaTile_Machine { + + String mName = ""; + int uuaUsed = 0; + int uumMade = 0; + + public GUI_MatterFab(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { + super(new CONTAINER_MatterFab(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); + + + + if (this.mContainer != null) { + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 1) != 0) { + this.fontRendererObj.drawString("Pipe is loose.", 10, 16, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 2) != 0) { + this.fontRendererObj.drawString("Screws are missing.", 10, 24, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 4) != 0) { + this.fontRendererObj.drawString("Something is stuck.", 10, 32, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 8) != 0) { + this.fontRendererObj.drawString("Platings are dented.", 10, 40, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 16) != 0) { + this.fontRendererObj.drawString("Circuitry burned out.", 10, 48, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 32) != 0) { + this.fontRendererObj.drawString("That doesn't belong there.", 10, 56, 16448255); + } + if ((((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode & 64) != 0) { + this.fontRendererObj.drawString("Incomplete Structure.", 10, 64, 16448255); + } + + if (((CONTAINER_MatterFab) this.mContainer).mDisplayErrorCode == 0) { + if (((CONTAINER_MatterFab) this.mContainer).mActive == 0) { + this.fontRendererObj.drawString("Hit with Soft Hammer", 10, 16, 16448255); + this.fontRendererObj.drawString("to (re-)start the Machine", 10, 24, 16448255); + this.fontRendererObj.drawString("if it doesn't start.", 10, 32, 16448255); + } else { + this.uuaUsed = ((CONTAINER_MatterFab) this.mContainer).mUUA_USED; + this.uumMade = ((CONTAINER_MatterFab) this.mContainer).mUUM_MADE; + this.fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255); + this.fontRendererObj.drawString("UU-Amplifier Used: "+this.uuaUsed, 10, 24, 16448255); + this.fontRendererObj.drawString("UU-Matter Fabricated: "+this.uumMade, 10, 32, 16448255); + } + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java new file mode 100644 index 0000000000..c78e7789b8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine.java @@ -0,0 +1,296 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * The GUI-Container I use for all my Basic Machines + * <p/> + * As the NEI-RecipeTransferRect Handler can't handle one GUI-Class for all GUIs I needed to produce some dummy-classes which extend this class + */ +public class GUI_MultiMachine extends GT_GUIContainerMetaTile_Machine { + + private final static Materials GOOD; + private final static Materials BAD; + private final String mName; + + private final static ConcurrentHashMap<String, ItemStack> mToolStacks = new ConcurrentHashMap<String, ItemStack>(); + + //net.minecraft.client.gui.inventory.GuiContainer.drawItemStack(ItemStack, int, int, String) + private final static Method mDrawItemStack; + + static { + GOOD = Materials.Uranium; + BAD = Materials.Plutonium; + + //net.minecraft.client.gui.inventory.GuiContainer.drawItemStack(ItemStack, int, int, String) + mDrawItemStack = ReflectionUtils.getMethod(GuiContainer.class, "drawItemStack", new Class[] {ItemStack.class, int.class, int.class, String.class}); + } + + public GUI_MultiMachine(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { + super(new CONTAINER_MultiMachine_NoPlayerInventory(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName != null ? aName : ""; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + if (this.mContainer != null) { + drawGuiInfoTextLayer(par1, par2); + drawGuiRepairStatusLayer(par1, par2); + } + } + + + protected void drawGuiInfoTextLayer(final float par1, final int par2) { + + if ((((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 64) != 0) { + this.fontRendererObj.drawString(mName, 6, 7, 16448255); // Move down 8px + this.fontRendererObj.drawString("Incomplete Structure.", 6, 15, 16448255); // Move down 8px + } + else { + int aTotalTickTime = ((CONTAINER_MultiMachine) this.mContainer).aTotalTickTime; + int aMaxParallel = ((CONTAINER_MultiMachine) this.mContainer).aMaxParallel; + int aPollutionTick = ((CONTAINER_MultiMachine) this.mContainer).aPollutionTick; + int aMaxInputVoltage = ((CONTAINER_MultiMachine) this.mContainer).aMaxInputVoltage; + int aInputTier = ((CONTAINER_MultiMachine) this.mContainer).aInputTier; + int aOutputTier = ((CONTAINER_MultiMachine) this.mContainer).aOutputTier; + int aRecipeDuration = ((CONTAINER_MultiMachine) this.mContainer).aRecipeDuration; + int aRecipeEU = ((CONTAINER_MultiMachine) this.mContainer).aRecipeEU; + int aRecipeSpecial = ((CONTAINER_MultiMachine) this.mContainer).aRecipeSpecial; + int aEfficiency = ((CONTAINER_MultiMachine) this.mContainer).aEfficiency; + + int aPollutionReduction = ((CONTAINER_MultiMachine) this.mContainer).aPollutionReduction; + + + long aStoredEnergy = ((CONTAINER_MultiMachine) this.mContainer).aStoredEnergy; + long aMaxEnergy = ((CONTAINER_MultiMachine) this.mContainer).aMaxEnergy; + + /* + * Logic Block + */ + + long seconds = (aTotalTickTime/20); + int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); + int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); + long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks); + long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); + + ArrayList<String> mInfo = new ArrayList<String>(); + + String EU = StatCollector.translateToLocal("GTPP.info.eu"); + + //GTPP.machines.tier + + mInfo.add(mName); + + if (aInputTier > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.machines.input")+" "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ EnumChatFormatting.GREEN +GT_Values.VOLTAGE_NAMES[aInputTier]); + } + if (aOutputTier > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.machines.output")+" "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ EnumChatFormatting.GREEN +GT_Values.VOLTAGE_NAMES[aOutputTier]); + } + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress")+": "+ + EnumChatFormatting.GREEN + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mProgressTime/20) + EnumChatFormatting.RESET +" s / "+ + EnumChatFormatting.YELLOW + Integer.toString(((CONTAINER_MultiMachine) this.mContainer).mMaxProgressTime/20) + EnumChatFormatting.RESET +" s"); + + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+": "+ + EnumChatFormatting.GREEN + Long.toString(aStoredEnergy) + EnumChatFormatting.RESET +" "+EU+" / "+ + EnumChatFormatting.YELLOW + Long.toString(aMaxEnergy) + EnumChatFormatting.RESET +" "+EU+""); + + if (aRecipeEU != 0 && aRecipeDuration > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+": "+ + EnumChatFormatting.RED + Integer.toString(-aRecipeEU) + EnumChatFormatting.RESET + " "+EU+"/t"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.duration")+": "+ + EnumChatFormatting.RED + Integer.toString(aRecipeDuration) + EnumChatFormatting.RESET + " ticks"); + if (aRecipeSpecial > 0) { + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.specialvalue")+": "+ + EnumChatFormatting.RED + Integer.toString(aRecipeEU) + EnumChatFormatting.RESET + ""); + } + } + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei")+": "+ + EnumChatFormatting.YELLOW+Long.toString(aMaxInputVoltage)+EnumChatFormatting.RESET+ " "+EU+"/t"+EnumChatFormatting.RESET); + + mInfo.add(StatCollector.translateToLocal(StatCollector.translateToLocal("GTPP.machines.tier")+": "+ + EnumChatFormatting.YELLOW+GT_Values.VN[GT_Utility.getTier(aMaxInputVoltage)]+ EnumChatFormatting.RESET)); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.efficiency")+": "+ EnumChatFormatting.YELLOW+Float.toString(aEfficiency / 100.0F)+EnumChatFormatting.RESET + " %"); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution")+": "+ EnumChatFormatting.RED + (aPollutionTick*20)+ EnumChatFormatting.RESET+"/sec"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced")+": "+ EnumChatFormatting.GREEN + aPollutionReduction + EnumChatFormatting.RESET+" %"); + + mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": "+EnumChatFormatting.GREEN+(aMaxParallel)+EnumChatFormatting.RESET); + + mInfo.add("Total Time Since Built: "); + mInfo.add("" + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks)+EnumChatFormatting.RESET+" Weeks,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Integer.toString(days) +EnumChatFormatting.RESET+ " Days,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Long.toString(hours) +EnumChatFormatting.RESET+ " Hours,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Long.toString(minutes) +EnumChatFormatting.RESET+ " Minutes,"); + mInfo.add("" + EnumChatFormatting.DARK_GREEN+ Long.toString(second) +EnumChatFormatting.RESET+ " Seconds"); + + + + // Machine Name + //fontRendererObj.drawString(this.mName, 6, 7, 16448255); + + for (int i=0;i<mInfo.size();i++) { + fontRendererObj.drawString(mInfo.get(i), 6, 7+(i*8), 16448255); + } + + } + + + + + } + + + protected void drawGuiRepairStatusLayer(final float par1, final int par2) { + + boolean aWrench = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0; + boolean aScrewdriver = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0; + boolean aMallet = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0; + boolean aHammer = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0; + boolean aSoldering = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0; + boolean aCrowbar = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0; + + if (mToolStacks.isEmpty()) { + // Map Stacks of Repair items + aWrench = false; + aScrewdriver = false; + aMallet = false; + aHammer = false; + aSoldering = false; + aCrowbar = false; + mToolStacks.put(aWrench+"WRENCH", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.WRENCH, 1, (aWrench ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aCrowbar+"CROWBAR", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.CROWBAR, 1, (aCrowbar ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aHammer+"HARDHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, (aHammer ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aMallet+"SOFTHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOFTHAMMER, 1, (aMallet ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aScrewdriver+"SCREWDRIVER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SCREWDRIVER, 1, (aScrewdriver ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aSoldering+"SOLDERING_IRON_LV", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, 1, (aSoldering ? BAD : GOOD), Materials.Tungsten, null)); + + // Map Stacks of valid items + aWrench = true; + aScrewdriver = true; + aMallet = true; + aHammer = true; + aSoldering = true; + aCrowbar = true; + mToolStacks.put(aWrench+"WRENCH", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.WRENCH, 1, (aWrench ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aCrowbar+"CROWBAR", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.CROWBAR, 1, (aCrowbar ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aHammer+"HARDHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, (aHammer ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aMallet+"SOFTHAMMER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOFTHAMMER, 1, (aMallet ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aScrewdriver+"SCREWDRIVER", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SCREWDRIVER, 1, (aScrewdriver ? BAD : GOOD), Materials.Tungsten, null)); + mToolStacks.put(aSoldering+"SOLDERING_IRON_LV", GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, 1, (aSoldering ? BAD : GOOD), Materials.Tungsten, null)); + + ItemStack aGlassPane1 = ItemUtils.getItemStackOfAmountFromOreDict("paneGlassRed", 1); + ItemStack aGlassPane2 = ItemUtils.getItemStackOfAmountFromOreDict("paneGlassLime", 1); + mToolStacks.put("falseGLASS", aGlassPane1); + mToolStacks.put("trueGLASS", aGlassPane2); + + // Reset vars to real state + aWrench = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0; + aScrewdriver = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0; + aMallet = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0; + aHammer = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0; + aSoldering = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0; + aCrowbar = (((CONTAINER_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0; + + } + + ItemStack aWrenchStack; + ItemStack aCrowbarStack; + ItemStack aHammerStack; + ItemStack aMalletStack; + ItemStack aScrewdriverStack; + ItemStack aSolderingStack; + if (!mToolStacks.isEmpty() && mDrawItemStack != null) { + + aWrenchStack = mToolStacks.get(aWrench + "WRENCH"); + aCrowbarStack = mToolStacks.get(aCrowbar + "CROWBAR"); + aHammerStack = mToolStacks.get(aHammer + "HARDHAMMER"); + aMalletStack = mToolStacks.get(aMallet + "SOFTHAMMER"); + aScrewdriverStack = mToolStacks.get(aScrewdriver + "SCREWDRIVER"); + aSolderingStack = mToolStacks.get(aSoldering + "SOLDERING_IRON_LV"); + + try { + + ItemStack[] aToolStacks2 = new ItemStack[] { + aWrenchStack, aCrowbarStack, + aHammerStack, aMalletStack, + aScrewdriverStack, aSolderingStack }; + + int aIndex = 0; + //Draw Repair status tools + for (aIndex = 0; aIndex < 6; aIndex++) { + int x = 156; + int y = 112 - (18 * 3) + (aIndex * 18); + mDrawItemStack.invoke(this, + new Object[] { + aToolStacks2[aIndex] != null ? aToolStacks2[aIndex] + : ItemUtils.getErrorStack(1, "Bad Times"), + x, y, "" + (aIndex == 2 ? "H" : aIndex == 3 ? "M" : "") // Stacksize Overlay + }); + //this.fontRendererObj.drawString("", 10, 64, 16448255); + } + + //Draw Running status + boolean running = ((CONTAINER_MultiMachine) this.mContainer).mActive != 0; + ItemStack aGlassPane = mToolStacks.get(running+"GLASS"); + + if (aGlassPane == null) { + aGlassPane = ItemUtils.getItemStackOfAmountFromOreDict("paneGlass" + (running ? "Lime" : "Red"), 1); + mToolStacks.put(running+"GLASS", aGlassPane); + } + + mDrawItemStack.invoke(this, + new Object[] { + aGlassPane != null ? aGlassPane + : ItemUtils.getErrorStack(1, "Bad Times"), + 156, + 112 - (18 * 5), + running ? "On" : "Off"}); // Stacksize Overlay + + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + + + + } + + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java new file mode 100644 index 0000000000..0cfab4e71e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_MultiMachine_Default.java @@ -0,0 +1,68 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_MultiMachine_Default extends GT_GUIContainerMetaTile_Machine +{ + String mName; + + public GUI_MultiMachine_Default(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { + super(new CONTAINER_MultiMachine(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + ((aTextureFile == null) ? "MultiblockDisplay" : aTextureFile)); + this.mName = ""; + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); + if (this.mContainer != null) { + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x1) != 0x0) { + this.fontRendererObj.drawString(this.trans("132", "Pipe is loose."), 10, 16, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x2) != 0x0) { + this.fontRendererObj.drawString(this.trans("133", "Screws are missing."), 10, 24, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x4) != 0x0) { + this.fontRendererObj.drawString(this.trans("134", "Something is stuck."), 10, 32, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x8) != 0x0) { + this.fontRendererObj.drawString(this.trans("135", "Platings are dented."), 10, 40, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x10) != 0x0) { + this.fontRendererObj.drawString(this.trans("136", "Circuitry burned out."), 10, 48, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x20) != 0x0) { + this.fontRendererObj.drawString(this.trans("137", "That doesn't belong there."), 10, 56, 16448255); + } + if ((((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode & 0x40) != 0x0) { + this.fontRendererObj.drawString(this.trans("138", "Incomplete Structure."), 10, 64, 16448255); + } + if (((CONTAINER_MultiMachine)this.mContainer).mDisplayErrorCode == 0) { + if (((CONTAINER_MultiMachine)this.mContainer).mActive == 0) { + this.fontRendererObj.drawString(this.trans("139", "Hit with Soft Hammer"), 10, 16, 16448255); + this.fontRendererObj.drawString(this.trans("140", "to (re-)start the Machine"), 10, 24, 16448255); + this.fontRendererObj.drawString(this.trans("141", "if it doesn't start."), 10, 32, 16448255); + } + else { + this.fontRendererObj.drawString(this.trans("142", "Running perfectly."), 10, 16, 16448255); + } + } + } + } + + public String trans(final String aKey, final String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Multi_Basic_Slotted.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Multi_Basic_Slotted.java new file mode 100644 index 0000000000..0756effa26 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Multi_Basic_Slotted.java @@ -0,0 +1,88 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_Container_MultiMachine; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class GUI_Multi_Basic_Slotted extends GT_GUIContainerMetaTile_Machine { + String mName = ""; + + public GUI_Multi_Basic_Slotted(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, + String aTextureFile) { + super(new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString(this.mName, 10, 8, 16448255); + if (this.mContainer != null) { + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 1) != 0) { + this.fontRendererObj.drawString(this.trans("132", "Pipe is loose."), 10, 16, 16448255); + } + + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 2) != 0) { + this.fontRendererObj.drawString(this.trans("133", "Screws are missing."), 10, 24, 16448255); + } + + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 4) != 0) { + this.fontRendererObj.drawString(this.trans("134", "Something is stuck."), 10, 32, 16448255); + } + + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 8) != 0) { + this.fontRendererObj.drawString(this.trans("135", "Platings are dented."), 10, 40, 16448255); + } + + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 16) != 0) { + this.fontRendererObj.drawString(this.trans("136", "Circuitry burned out."), 10, 48, 16448255); + } + + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 32) != 0) { + this.fontRendererObj.drawString(this.trans("137", "That doesn\'t belong there."), 10, 56, 16448255); + } + + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 64) != 0) { + this.fontRendererObj.drawString(this.trans("138", "Incomplete Structure."), 10, 64, 16448255); + } + + if (((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode == 0) { + if (((GT_Container_MultiMachine) this.mContainer).mActive == 0) { + this.fontRendererObj.drawString(this.trans("139", "Hit with Soft Hammer"), 10, 16, 16448255); + this.fontRendererObj.drawString(this.trans("140", "to (re-)start the Machine"), 10, 24, 16448255); + this.fontRendererObj.drawString(this.trans("141", "if it doesn\'t start."), 10, 32, 16448255); + } else { + this.fontRendererObj.drawString(this.trans("142", "Running perfectly."), 10, 16, 16448255); + } + + ItemStack tItem; + if (this.mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine) { + tItem = this.mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1); + if (tItem == null || tItem.getItem() != GT_MetaGenerated_Tool_01.INSTANCE + || tItem.getItemDamage() < 170 || tItem.getItemDamage() > 177) { + this.fontRendererObj.drawString(this.trans("144", "Missing Turbine Rotor"), 10, + ((GT_Container_MultiMachine) this.mContainer).mActive == 0 ? 40 : 24, 16448255); + } + } + } + } + + } + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java new file mode 100644 index 0000000000..65ba8610dd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_PowerSubStation.java @@ -0,0 +1,175 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; + +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; + +public class GUI_PowerSubStation extends GT_GUIContainerMetaTile_Machine { + public String mNEI; + String mName; + boolean[] mRepairStatus = new boolean[6]; + private static IIcon[] mGregToolIcons = new IIcon[6]; + + public GUI_PowerSubStation(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aNEI) { + super(new CONTAINER_PowerSubStation(aInventoryPlayer, aTileEntity, false), CORE.RES_PATH_GUI + "PowerSubStation.png"); + this.mName = aName; + this.mNEI = aNEI; + /** The X size of the inventory window in pixels. */ + this.xSize = 196; + /** The Y size of the inventory window in pixels. */ + this.ySize = 191; + for (IIcon g : mGregToolIcons) { + if (g == null) { + getToolTextures(); + } + } + } + + private static final boolean getToolTextures() { + mGregToolIcons[0] = Textures.ItemIcons.WRENCH.getIcon(); + mGregToolIcons[1] = Textures.ItemIcons.HANDLE_SCREWDRIVER.getIcon(); + mGregToolIcons[2] = Textures.ItemIcons.MORTAR.getIcon(); + mGregToolIcons[3] = Textures.ItemIcons.JACKHAMMER.getIcon(); + mGregToolIcons[4] = Textures.ItemIcons.HANDLE_SOLDERING.getIcon(); + mGregToolIcons[5] = Textures.ItemIcons.CROWBAR.getIcon(); + return true; + } + + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 8, -10, 16448255); + if (this.mContainer != null) { + + this.fontRendererObj.drawString("Error Code: "+((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode, 10, 142, 16448255); + + this.fontRendererObj.drawString("In", 178, 10, 16448255); + this.fontRendererObj.drawString("Out", 176, 28, 16448255); + + if (((this.mContainer).mDisplayErrorCode & 1) != 0) { + this.fontRendererObj.drawString("Pipe is loose.", 10, 8, 16448255); + mRepairStatus[0] = false; + } + else { + mRepairStatus[0] = true; + } + if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 2) != 0) { + this.fontRendererObj.drawString("Screws are missing.", 10, 16, 16448255); + mRepairStatus[1] = false; + } + else { + mRepairStatus[1] = true; + } + if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 4) != 0) { + this.fontRendererObj.drawString("Something is stuck.", 10, 24, 16448255); + mRepairStatus[2] = false; + } + else { + mRepairStatus[2] = true; + } + if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 8) != 0) { + this.fontRendererObj.drawString("Platings are dented.", 10, 32, 16448255); + mRepairStatus[3] = false; + } + else { + mRepairStatus[3] = true; + } + if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 16) != 0) { + this.fontRendererObj.drawString("Circuitry burned out.", 10, 40, 16448255); + mRepairStatus[4] = false; + } + else { + mRepairStatus[4] = true; + } + if ((((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode & 32) != 0) { + this.fontRendererObj.drawString("That doesn't belong there.", 10, 48, 16448255); + mRepairStatus[5] = false; + } + else { + mRepairStatus[5] = true; + } + if (((CONTAINER_PowerSubStation) this.mContainer).mDisplayErrorCode == 0) { + if (((CONTAINER_PowerSubStation) this.mContainer).mActive == 0) { + this.fontRendererObj.drawString( + "Hit with Soft Hammer to (re-)start the Machine if it doesn't start.", -70, 8, 16448255); + } else { + this.fontRendererObj.drawString("Running perfectly.", 10, 8, 16448255); + } + } + if (this.mContainer.mEnergy > 160000000 && this.mContainer.mEnergy < 160010000) { + this.fontRendererObj.drawString("160,000,000 EU", 50, 155, 16711680); + } else if (this.mContainer.mEnergy > 320000000 && this.mContainer.mEnergy < 320010000) { + this.fontRendererObj.drawString("320,000,000 EU", 50, 155, 16711680); + } else if (this.mContainer.mEnergy > 640000000 && this.mContainer.mEnergy < 640010000) { + this.fontRendererObj.drawString("640,000,000 EU", 50, 155, 16711680); + } else { + this.fontRendererObj.drawString(GT_Utility.formatNumbers((long) this.mContainer.mEnergy) + " EU", + 50, 155, 16711680); + } + } + } + + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + /** The X size of the inventory window in pixels. */ + if (this.xSize != 196) + this.xSize = 196; + /** The Y size of the inventory window in pixels. */ + if (this.ySize != 191) + this.ySize = 191; + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mContainer != null) { + final double tScale = this.mContainer.mEnergy / this.mContainer.mStorage; + this.drawTexturedModalRect(x + 5, y + 156, 0, 251, Math.min(147, (int) (tScale * 148.0)), 5); + + + //A1 + this.drawTexturedModalRect(x + 154, y + 76, 238, (!mRepairStatus[0] ? 0 : 18), 18, 18); + //A2 + this.drawTexturedModalRect(x + 154 + 20, y + 76, 238, (!mRepairStatus[1] ? 0 : 18), 18, 18); + //B1 + this.drawTexturedModalRect(x + 154, y + 76 + 18, 238, (!mRepairStatus[2] ? 0 : 18), 18, 18); + //B2 + this.drawTexturedModalRect(x + 154 + 20, y + 76 + 18, 238, (!mRepairStatus[3] ? 0 : 18), 18, 18); + //C1 + this.drawTexturedModalRect(x + 154, y + 76 + 36, 238, (!mRepairStatus[4] ? 0 : 18), 18, 18); + //C2 + this.drawTexturedModalRect(x + 154 + 20, y + 76 + 36, 238, (!mRepairStatus[5] ? 0 : 18), 18, 18); + + + if (mGregToolIcons[0] != null) { + //this.drawTexturedModelRectFromIcon(x + 154, y + 76, mGregToolIcons[0], 18, 18); + } + if (mGregToolIcons[1] != null) { + //this.drawTexturedModelRectFromIcon(x + 154 + 20, y + 76, mGregToolIcons[1], 18, 18); + } + if (mGregToolIcons[2] != null) { + //this.drawTexturedModelRectFromIcon(x + 154, y + 76 + 18, mGregToolIcons[2], 9, 9); + } + if (mGregToolIcons[3] != null) { + //this.drawTexturedModelRectFromIcon(x + 154 + 20, y + 76 + 18, mGregToolIcons[3], 9, 9); + } + if (mGregToolIcons[4] != null) { + //this.drawTexturedModelRectFromIcon(x + 154, y + 76 + 36, mGregToolIcons[4], 9, 9); + } + if (mGregToolIcons[5] != null) { + //this.drawTexturedModelRectFromIcon(x + 154 + 20, y + 76 + 36, mGregToolIcons[5], 9, 9); + } + + /*//Maint Done + this.drawTexturedModalRect(x + 154, y + 76, 238, 0, 18, 18); + //Maint Required + this.drawTexturedModalRect(x + 154 + 20, y + 76, 238, 18, 18, 18);*/ + + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SafeBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SafeBlock.java new file mode 100644 index 0000000000..c18d58b4b6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SafeBlock.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.lib.CORE; + +public class GUI_SafeBlock +extends GT_GUIContainerMetaTile_Machine { + public GUI_SafeBlock(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(new CONTAINER_SafeBlock(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "SafeBlock.png"); + } + + //String UUID = ((CONTAINER_SafeBlock)this.mContainer).ownerUUID.toString(); + boolean blockStatus = ((CONTAINER_SafeBlock)this.mContainer).blockStatus; + //String tempPlayer; + + private void updateVars(){ + //UUID = ((CONTAINER_SafeBlock)this.mContainer).ownerUUID; + this.blockStatus = ((CONTAINER_SafeBlock)this.mContainer).blockStatus; + // tempPlayer = PlayerCache.lookupPlayerByUUID(UUID); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) + { + this.updateVars(); + //this.fontRendererObj.drawString("Owner: "+ tempPlayer, 64, 72, 4210752); + //this.fontRendererObj.drawString(": "+ UUID.toLowerCase(), 44, 82, 4210752); + this.fontRendererObj.drawString("Safe Status", 76, 61, 4210752); + if (this.blockStatus){ + this.fontRendererObj.drawString("Locked", 88, 73, 4210752); + } + else { + this.fontRendererObj.drawString("Unlocked", 82, 73, 4210752); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + /*String UUID = ((CONTAINER_SafeBlock)this.mContainer).UUID; + this.fontRendererObj.drawString("Owner UUID: "+ UUID, 8, 12, 4210752);*/ + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SolarGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SolarGenerator.java new file mode 100644 index 0000000000..f0b3a0c879 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SolarGenerator.java @@ -0,0 +1,44 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GUI_SolarGenerator +extends GT_GUIContainerMetaTile_Machine { + public GUI_SolarGenerator(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aTextureName) { + super(new CONTAINER_SolarGenerator(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/" + aTextureName); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString("Solar Generator", 8, 4, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mContainer != null) { + int tScale = ((CONTAINER_SolarGenerator) this.mContainer).mProcessingEnergy; + if (tScale > 0) { + this.drawTexturedModalRect(x + 70, (y + 25 + 54) - tScale, 194, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SolarGenerator) this.mContainer).mEnergy; + if (tScale > 0) { + this.drawTexturedModalRect(x + 83, (y + 25 + 54) - tScale, 204, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SolarGenerator) this.mContainer).mTemperature; + if (tScale > 0) { + this.drawTexturedModalRect(x + 96, (y + 25 + 54) - tScale, 214, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SolarGenerator) this.mContainer).mProcessingEnergy; + if (tScale > 0) { + this.drawTexturedModalRect(x + 117, (y + 44 + 14) - tScale, 177, 14 - tScale, 15, tScale + 1); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SteamCondenser.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SteamCondenser.java new file mode 100644 index 0000000000..88a3e00bb5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SteamCondenser.java @@ -0,0 +1,56 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.preloader.CORE_Preloader; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_SteamCondenser extends GT_GUIContainerMetaTile_Machine +{ + long tickTime = 0; + + public GUI_SteamCondenser(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aTextureName) + { + super(new CONTAINER_SteamCondenser(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + aTextureName); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) + { + this.fontRendererObj.drawString("Condenser", 8, 4, 4210752); + if (CORE_Preloader.DEBUG_MODE){ + this.tickTime = ((CONTAINER_SteamCondenser)this.mContainer).mTickingTime; + this.fontRendererObj.drawString("Tick Time: "+this.tickTime, 8, 12, 4210752); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) + { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mContainer != null) + { + + int tScale = ((CONTAINER_SteamCondenser)this.mContainer).mSteamAmount; + if (tScale > 0) { + this.drawTexturedModalRect(x + 70, (y + 25 + 54) - tScale, 194, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SteamCondenser)this.mContainer).mWaterAmount; + if (tScale > 0) { + this.drawTexturedModalRect(x + 83, (y + 25 + 54) - tScale, 204, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SteamCondenser)this.mContainer).mTemperature; + if (tScale > 0) { + this.drawTexturedModalRect(x + 96, (y + 25 + 54) - tScale, 214, 54 - tScale, 10, tScale); + } + tScale = ((CONTAINER_SteamCondenser)this.mContainer).mProcessingEnergy; + if (tScale > 0) { + this.drawTexturedModalRect(x + 115, y + 44 + 2/* - tScale*/, 177, 14 - tScale, 15, 1+tScale); + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java new file mode 100644 index 0000000000..d324c50dd0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java @@ -0,0 +1,38 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; + +public class GUI_SuperChest extends GT_GUIContainerMetaTile_Machine { + private final String mName; + + public GUI_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, + String aName) { + super(new CONTAINER_SuperChest(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/BasicTank.png"); + this.mName = aName; + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, + 4210752); + this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); + if (this.mContainer != null) { + this.fontRendererObj.drawString("Item Amount", 10, 20, 16448255); + this.fontRendererObj.drawString( + GT_Utility.parseNumberToString(((CONTAINER_SuperChest) this.mContainer).mContent), 10, 30, + 16448255); + } + + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java new file mode 100644 index 0000000000..b236b0ff32 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java @@ -0,0 +1,46 @@ + +package gtPlusPlus.xmod.gregtech.api.gui; + + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.lib.CORE; + +public class GUI_TreeFarmer extends GT_GUIContainerMetaTile_Machine { + + String mName = ""; + long maxPower = 0; + long storedPower = 0; + + public GUI_TreeFarmer(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { + super(new CONTAINER_TreeFarmer(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 64, 6, 16448255); + if (this.mContainer != null) { + this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + if (((CONTAINER_TreeFarmer) this.mContainer).mDisplayErrorCode == 0) { + this.fontRendererObj.drawString("Current Power: "+this.storedPower+"EU", 8, 52, 16448255); + this.fontRendererObj.drawString("Max Power: "+this.maxPower+"EU", 8, 60, 16448255); + this.fontRendererObj.drawString("Current operations left: "+(this.storedPower/32), 8, 68, 16448255); + } + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java new file mode 100644 index 0000000000..79d1033bd0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/CONTAINER_PollutionCleaner.java @@ -0,0 +1,105 @@ +package gtPlusPlus.xmod.gregtech.api.gui.basic; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import gregtech.api.gui.*; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.slots.SlotPollutionScrubber; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaAtmosphericReconditioner; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * The Container I use for all my Basic Machines + */ +public class CONTAINER_PollutionCleaner extends GT_Container_BasicTank { + + public boolean mFluidTransfer = false, mItemTransfer = false, mStuttering = false; + public int mReduction = 0; + + public CONTAINER_PollutionCleaner(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + + int tStartIndex = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).getInputSlot(); + int aTier = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mTier; + + + //Add 2 Item Slots + addSlotToContainer(new SlotPollutionScrubber(0, aTier, mTileEntity, tStartIndex++, 53, 25)); + addSlotToContainer(new SlotPollutionScrubber(1, aTier, mTileEntity, tStartIndex++, 107, 25)); + // Upgrade Slot + addSlotToContainer(new SlotPollutionScrubber(2, aTier, mTileEntity, tStartIndex++, 125, 63)); + + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + Logger.INFO("Clicked on slot "+aSlotIndex); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + + mReduction = ((GregtechMetaAtmosphericReconditioner) mTileEntity.getMetaTileEntity()).mPollutionReduction; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 105, mReduction); + } + } + + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 105: + mReduction = (par2); + break; + } + } + + @Override + public int getSlotStartIndex() { + return 0; + } + + @Override + public int getShiftClickStartIndex() { + return 0; + } + + @Override + public int getSlotCount() { + return getShiftClickSlotCount(); + } + + @Override + public int getShiftClickSlotCount() { + return 3; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java new file mode 100644 index 0000000000..3b96731f00 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/basic/GUI_PollutionCleaner.java @@ -0,0 +1,65 @@ +package gtPlusPlus.xmod.gregtech.api.gui.basic; + +import java.util.ArrayList; +import java.util.List; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_PollutionCleaner extends GT_GUIContainerMetaTile_Machine { + public final String mName; + public final String mNEI; + public final byte mProgressBarDirection; + public final byte mProgressBarAmount; + public int mReduction; + + public GUI_PollutionCleaner(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, + final String aName, final String aTextureFile) { + this(aInventoryPlayer, aTileEntity, aName, aTextureFile, "PollutionCleaner",(byte) 0, (byte) 1); + } + + public GUI_PollutionCleaner(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, + final String aName, final String aTextureFile, final String aNEI, final byte aProgressBarDirection, + final byte aProgressBarAmount) { + super(new CONTAINER_PollutionCleaner(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + "PollutionCleaner.png"); + this.mProgressBarDirection = aProgressBarDirection; + this.mProgressBarAmount = (byte) Math.max(1, aProgressBarAmount); + this.mName = aName; + this.mNEI = aNEI; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 8, 4, 4210752); + this.drawTooltip(par1, par2); + } + + private void drawTooltip(final int x2, final int y2) { + final int xStart = (this.width - this.xSize) / 2; + final int yStart = (this.height - this.ySize) / 2; + final int x3 = x2 - xStart; + final int y3 = y2 - yStart + 5; + final List<String> list = new ArrayList<String>(); + if (y3 >= 67 && y3 <= 84) { + if (x3 >= 77 && x3 <= 95) { + //Do Dumb shit + CONTAINER_PollutionCleaner aContainerCast = (CONTAINER_PollutionCleaner) this.mContainer; + mReduction = aContainerCast.mReduction; + list.add("Reduction: "+mReduction+"/s"); + } + } + if (!list.isEmpty()) { + this.drawHoveringText(list, x3, y3, this.fontRendererObj); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/Container_FluidReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/Container_FluidReactor.java new file mode 100644 index 0000000000..cdca065e60 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/Container_FluidReactor.java @@ -0,0 +1,184 @@ +package gtPlusPlus.xmod.gregtech.api.gui.fluidreactor; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_Container_BasicMachine; +import gregtech.api.gui.GT_Slot_Render; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.slots.SlotChemicalPlantInput; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.slots.SlotNoInputLogging; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_ChemicalReactor; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; + +public class Container_FluidReactor extends GT_Container_BasicMachine { + + public boolean mFluidTransfer_1 = false; + public boolean mFluidTransfer_2 = false; + public boolean oFluidTransfer_1 = false; + public boolean oFluidTransfer_2 = false; + + public Container_FluidReactor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + + // Gui Buttons + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 0, 8, 63)); // Fluid 1 + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 1, 44, 63)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, 2, 26, 63)); // Fluid 2 + + int tStartIndex = 3; + // Input Slots + this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 8, 7)); + this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 26, 7)); + this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 44, 7)); + this.addSlotToContainer(new SlotChemicalPlantInput(this.mTileEntity, tStartIndex++, 62, 7)); + + // Output Slots + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 107, 16)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 125, 16)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 107, 34)); + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 125, 34)); + + // Cell Collector Slot + this.addSlotToContainer(new SlotNoInput(this.mTileEntity, tStartIndex++, 116, 63)); + + + // Inputs Fluids + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 8, 42)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 26, 42)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 44, 42)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 62, 42)); + + // Output Fluids + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 143, 16)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, tStartIndex++, 143, 34)); + + + + + } + + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (aSlotIndex == 0 || aSlotIndex == 2) { + if (this.mTileEntity != null && this.mTileEntity.isServerSide()) { + try { + final IMetaTileEntity aMetaTileEntity = this.mTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return null; + } + if (aMetaTileEntity instanceof GregtechMetaTileEntity_ChemicalReactor) { + //Set Tile + if (aSlotIndex == 0) { + ((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_1 = !((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_1; + } + else if (aSlotIndex == 2) { + ((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_2 = !((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_2; + } + return null; + } + } + catch (Throwable t) { + t.printStackTrace(); + } + } + } + //Logger.INFO("Clicked slot "+aSlotIndex); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (this.mTileEntity != null && this.mTileEntity.isServerSide()) { + try { + Iterator var2 = this.crafters.iterator(); + final IMetaTileEntity aMetaTileEntity = this.mTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + Logger.INFO("bad"); + return; + } + if (aMetaTileEntity instanceof GregtechMetaTileEntity_ChemicalReactor) { + //Read from Tile + this.mFluidTransfer_1 = ((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_1; + this.mFluidTransfer_2 = ((GregtechMetaTileEntity_ChemicalReactor)aMetaTileEntity).mFluidTransfer_2; + int mTimer; + mTimer = (int) ReflectionUtils.getField(this.getClass(), "mTimer").get(this); + while (true) { + ICrafting var1; + do { + if (!var2.hasNext()) { + this.oFluidTransfer_1 = this.mFluidTransfer_1; + this.oFluidTransfer_2 = this.mFluidTransfer_2; + return; + } + var1 = (ICrafting) var2.next(); + if (mTimer % 500 == 10 || this.oFluidTransfer_1 != this.mFluidTransfer_1) { + var1.sendProgressBarUpdate(this, -50, this.mFluidTransfer_1 ? 1 : 0); + } + if (mTimer % 500 == 10 || this.oFluidTransfer_2 != this.mFluidTransfer_2) { + var1.sendProgressBarUpdate(this, -51, this.mFluidTransfer_2 ? 1 : 0); + } + } while (mTimer % 500 != 10); + } + } + else { + Logger.INFO("bad cast"); + } + } + catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + } + } + + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + if (par1 > 0) { + super.updateProgressBar(par1, par2); + } + else { + switch (par1) { + case -50 : + this.mFluidTransfer_1 = par2 != 0; + break; + case -51 : + this.mFluidTransfer_2 = par2 != 0; + break; + default : + break; + } + } + } + + public int getSlotStartIndex() { + return 3; + } + + public int getShiftClickStartIndex() { + return 3; + } + + public int getSlotCount() { + return this.getShiftClickSlotCount() + 5 + 2; + } + + public int getShiftClickSlotCount() { + return 4; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java new file mode 100644 index 0000000000..1be79b40cc --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/fluidreactor/GUI_FluidReactor.java @@ -0,0 +1,122 @@ +package gtPlusPlus.xmod.gregtech.api.gui.fluidreactor; + +import gregtech.api.gui.GT_Container_BasicMachine; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_FluidReactor extends GT_GUIContainerMetaTile_Machine { + public final String mName; + public final String mNEI; + public final byte mProgressBarDirection; + public final byte mProgressBarAmount; + + public GUI_FluidReactor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, + String aTextureFile, String aNEI) { + this(aInventoryPlayer, aTileEntity, aName, aTextureFile, aNEI, (byte) 0, (byte) 1); + } + + public GUI_FluidReactor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, + String aTextureFile, String aNEI, byte aProgressBarDirection, byte aProgressBarAmount) { + super(new Container_FluidReactor(aInventoryPlayer, aTileEntity), CORE.MODID+":textures/gui/FluidReactor.png"); + this.mProgressBarDirection = aProgressBarDirection; + this.mProgressBarAmount = (byte) Math.max(1, aProgressBarAmount); + this.mName = aName; + this.mNEI = aNEI; + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString(this.mName, 82, 5, 4210752); + this.drawTooltip(par1, par2); + } + + private void drawTooltip(int x2, int y2) { + int xStart = (this.width - this.xSize) / 2; + int yStart = (this.height - this.ySize) / 2; + int x = x2 - xStart; + int y = y2 - yStart + 5; + List<String> list = new ArrayList(); + if (y >= 67 && y <= 84) { + if (x >= 7 && x <= 24) { + list.add("Fluid 1 Auto-Output"); + } + if (x >= 25 && x <= 42) { + list.add("Fluid 2 Auto-Output"); + } + if (x >= 43 && x <= 61) { + list.add("Item Auto-Output"); + } + } + + if (!list.isEmpty()) { + this.drawHoveringText(list, x, y, this.fontRendererObj); + } + + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + if (this.mContainer != null) { + if (((Container_FluidReactor) this.mContainer).mFluidTransfer_1) { + this.drawTexturedModalRect(x + 7, y + 62, 176, 18, 18, 18); + } + if (((Container_FluidReactor) this.mContainer).mFluidTransfer_2) { + this.drawTexturedModalRect(x + 25, y + 62, 194, 18, 18, 18); + } + if (((GT_Container_BasicMachine) this.mContainer).mItemTransfer) { + this.drawTexturedModalRect(x + 43, y + 62, 176, 36, 18, 18); + } + + if (((GT_Container_BasicMachine) this.mContainer).mStuttering) { + this.drawTexturedModalRect(x + 79, y + 44, 176, 54, 18, 18); + } + + if (this.mContainer.mMaxProgressTime > 0) { + int tSize = this.mProgressBarDirection < 2 ? 20 : 18; + int tProgress = Math + .max(1, Math + .min(tSize * this.mProgressBarAmount, + (this.mContainer.mProgressTime > 0 ? 1 : 0) + this.mContainer.mProgressTime + * tSize * this.mProgressBarAmount / this.mContainer.mMaxProgressTime)) + % (tSize + 1); + switch (this.mProgressBarDirection) { + case 0 : + this.drawTexturedModalRect(x + 82, y + 24, 176, 0, tProgress, 18); + break; + case 1 : + this.drawTexturedModalRect(x + 82 + 20 - tProgress, y + 24, 196 - tProgress, 0, tProgress, 18); + break; + case 2 : + this.drawTexturedModalRect(x + 82, y + 24, 176, 0, 20, tProgress); + break; + case 3 : + this.drawTexturedModalRect(x + 82, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress); + break; + case 4 : + tProgress = 20 - tProgress; + this.drawTexturedModalRect(x + 82, y + 24, 176, 0, tProgress, 18); + break; + case 5 : + tProgress = 20 - tProgress; + this.drawTexturedModalRect(x + 82 + 20 - tProgress, y + 24, 196 - tProgress, 0, tProgress, 18); + break; + case 6 : + tProgress = 18 - tProgress; + this.drawTexturedModalRect(x + 82, y + 24, 176, 0, 20, tProgress); + break; + case 7 : + tProgress = 18 - tProgress; + this.drawTexturedModalRect(x + 82, y + 24 + 18 - tProgress, 176, 18 - tProgress, 20, tProgress); + } + } + } + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java new file mode 100644 index 0000000000..e6203823b6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_1by1_Turbine.java @@ -0,0 +1,60 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import gregtech.api.gui.GT_Container_1by1; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CONTAINER_1by1_Turbine extends GT_Container_1by1 { + + public CONTAINER_1by1_Turbine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new SlotTurbine(mTileEntity, 0, 80, 35)); + } + + @Override + public int getShiftClickSlotCount() { + return 0; + } + + @Override + public boolean canDragIntoSlot(Slot par1Slot) { + return false; + } + + public class SlotTurbine extends Slot { + public SlotTurbine(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool) { + if (itemstack.getItemDamage() >= 170 && itemstack.getItemDamage() <= 176) { + return true; + } + } + return false; + } + @Override + public int getSlotStackLimit() { + return 1; + } + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return false; + } + @Override + public void putStack(ItemStack p_75215_1_) { + // TODO Auto-generated method stub + super.putStack(p_75215_1_); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java new file mode 100644 index 0000000000..1d396811c1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java @@ -0,0 +1,32 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class CONTAINER_2by2 extends GT_ContainerMetaTile_Machine { + + public CONTAINER_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 71, 26)); + addSlotToContainer(new Slot(mTileEntity, 1, 89, 26)); + addSlotToContainer(new Slot(mTileEntity, 2, 71, 44)); + addSlotToContainer(new Slot(mTileEntity, 3, 89, 44)); + } + + @Override + public int getSlotCount() { + return 4; + } + + @Override + public int getShiftClickSlotCount() { + return 4; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java new file mode 100644 index 0000000000..8efe60a06e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java @@ -0,0 +1,44 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class CONTAINER_4by4 extends GT_ContainerMetaTile_Machine { + + public CONTAINER_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 53, 8)); + addSlotToContainer(new Slot(mTileEntity, 1, 71, 8)); + addSlotToContainer(new Slot(mTileEntity, 2, 89, 8)); + addSlotToContainer(new Slot(mTileEntity, 3, 107, 8)); + addSlotToContainer(new Slot(mTileEntity, 4, 53, 26)); + addSlotToContainer(new Slot(mTileEntity, 5, 71, 26)); + addSlotToContainer(new Slot(mTileEntity, 6, 89, 26)); + addSlotToContainer(new Slot(mTileEntity, 7, 107, 26)); + addSlotToContainer(new Slot(mTileEntity, 8, 53, 44)); + addSlotToContainer(new Slot(mTileEntity, 9, 71, 44)); + addSlotToContainer(new Slot(mTileEntity, 10, 89, 44)); + addSlotToContainer(new Slot(mTileEntity, 11, 107, 44)); + addSlotToContainer(new Slot(mTileEntity, 12, 53, 62)); + addSlotToContainer(new Slot(mTileEntity, 13, 71, 62)); + addSlotToContainer(new Slot(mTileEntity, 14, 89, 62)); + addSlotToContainer(new Slot(mTileEntity, 15, 107, 62)); + } + + @Override + public int getSlotCount() { + return 16; + } + + @Override + public int getShiftClickSlotCount() { + return 16; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java new file mode 100644 index 0000000000..9596d41387 --- /dev/null +++ b/src/main/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/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_1by1_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_1by1_Turbine.java new file mode 100644 index 0000000000..5623f0e224 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_1by1_Turbine.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; + +public class GUI_1by1_Turbine extends GT_GUIContainerMetaTile_Machine { + + private final String mName; + + public GUI_1by1_Turbine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_1by1_Turbine(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "1by1.png"); + mName = aName; + } + + public GUI_1by1_Turbine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(new CONTAINER_1by1_Turbine(aInventoryPlayer, aTileEntity), RES_PATH_GUI + aBackground + "1by1.png"); + mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(mName, 8, 4, 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/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java new file mode 100644 index 0000000000..b427a632f7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GUI_2by2 extends GT_GUIContainerMetaTile_Machine { + + private final String mName; + + public GUI_2by2(CONTAINER_2by2 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(containerType, RES_PATH_GUI + "2by2.png"); + mName = aName; + } + + public GUI_2by2(CONTAINER_2by2 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(containerType, RES_PATH_GUI + aBackground + "2by2.png"); + mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(mName, 8, 4, 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/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java new file mode 100644 index 0000000000..aced4342b3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class GUI_4by4 extends GT_GUIContainerMetaTile_Machine { + + private final String mName; + + public GUI_4by4(CONTAINER_4by4 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(containerType, RES_PATH_GUI + "4by4.png"); + mName = aName; + } + + public GUI_4by4(CONTAINER_4by4 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(containerType, RES_PATH_GUI + aBackground + "4by4.png"); + mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(mName, 8, 4, 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/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java new file mode 100644 index 0000000000..dd19571646 --- /dev/null +++ b/src/main/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/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java new file mode 100644 index 0000000000..00d022c481 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.slots.SlotElectric; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_2by2; + +public class CONTAINER_Electric_2by2 extends CONTAINER_2by2{ + + public CONTAINER_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new SlotElectric(mTileEntity, 0, 71, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 1, 89, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 2, 71, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 3, 89, 44)); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java new file mode 100644 index 0000000000..1f833eb3cb --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java @@ -0,0 +1,37 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.slots.SlotElectric; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_4by4; + +public class CONTAINER_Electric_4by4 extends CONTAINER_4by4{ + + public CONTAINER_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new SlotElectric(mTileEntity, 0, 53, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 1, 71, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 2, 89, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 3, 107, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 4, 53, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 5, 71, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 6, 89, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 7, 107, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 8, 53, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 9, 71, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 10, 89, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 11, 107, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 12, 53, 62)); + addSlotToContainer(new SlotElectric(mTileEntity, 13, 71, 62)); + addSlotToContainer(new SlotElectric(mTileEntity, 14, 89, 62)); + addSlotToContainer(new SlotElectric(mTileEntity, 15, 107, 62)); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java new file mode 100644 index 0000000000..9be7104bbc --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_2by2; + +public class GUI_Electric_2by2 extends GUI_2by2{ + + public GUI_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_Electric_2by2(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, aName); + } + + public GUI_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(new CONTAINER_Electric_2by2(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, RES_PATH_GUI + aBackground + "2by2.png"); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java new file mode 100644 index 0000000000..ed3fce5e2c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_4by4; + +public class GUI_Electric_4by4 extends GUI_4by4{ + + public GUI_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_Electric_4by4(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, aName); + } + + public GUI_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(new CONTAINER_Electric_4by4(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, RES_PATH_GUI + aBackground + "4by4.png"); + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/CONTAINER_BasicTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/CONTAINER_BasicTank.java new file mode 100644 index 0000000000..9a58e74ec4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/CONTAINER_BasicTank.java @@ -0,0 +1,69 @@ +package gtPlusPlus.xmod.gregtech.api.gui.power; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.gui.GT_Slot_Output; +import gregtech.api.gui.GT_Slot_Render; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.GTPP_MTE_BasicTank; + +import java.util.Iterator; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +public class CONTAINER_BasicTank extends GT_ContainerMetaTile_Machine { + public int mContent = 0; + + public CONTAINER_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 0, 80, 17)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 59, 42)); + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) { + if (((GTPP_MTE_BasicTank) this.mTileEntity.getMetaTileEntity()).mFluid != null) { + this.mContent = ((GTPP_MTE_BasicTank) this.mTileEntity.getMetaTileEntity()).mFluid.amount; + } else { + this.mContent = 0; + } + + Iterator var2 = this.crafters.iterator(); + + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mContent & ''); + var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); + } + + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100 : + this.mContent = this.mContent & -65536 | par2; + break; + case 101 : + this.mContent = this.mContent & '' | par2 << 16; + } + + } + + public int getSlotCount() { + return 2; + } + + public int getShiftClickSlotCount() { + return 1; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/GUI_BasicTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/GUI_BasicTank.java new file mode 100644 index 0000000000..a03aac346b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/gui/power/GUI_BasicTank.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.gregtech.api.gui.power; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; + +public class GUI_BasicTank extends GT_GUIContainerMetaTile_Machine { + private final String mName; + + public GUI_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_BasicTank(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/BasicTank.png"); + this.mName = aName; + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, + 4210752); + this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); + if (this.mContainer != null) { + this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255); + this.fontRendererObj.drawString( + GT_Utility.parseNumberToString(((CONTAINER_BasicTank) this.mContainer).mContent), 10, 30, + 16448255); + } + + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/GregtechItemContainer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/GregtechItemContainer.java new file mode 100644 index 0000000000..3c29b34e27 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/GregtechItemContainer.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public interface GregtechItemContainer { + public Item getItem(); + public Block getBlock(); + public boolean isStackEqual(Object aStack); + public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT); + public ItemStack get(long aAmount, Object... aReplacements); + public ItemStack getWildcard(long aAmount, Object... aReplacements); + public ItemStack getUndamaged(long aAmount, Object... aReplacements); + public ItemStack getAlmostBroken(long aAmount, Object... aReplacements); + public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements); + public GregtechItemContainer set(Item aItem); + public GregtechItemContainer set(ItemStack aStack); + public GregtechItemContainer registerOre(Object... aOreNames); + public GregtechItemContainer registerWildcardAsOre(Object... aOreNames); + public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements); + public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements); + public boolean hasBeenSet(); +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatEntity.java new file mode 100644 index 0000000000..824bb258d8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatEntity.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces; + +import ic2.api.energy.tile.IHeatSource; +import net.minecraftforge.common.util.ForgeDirection; + +public interface IHeatEntity extends IHeatSource, IHeatSink { + + public int getHeatBuffer(); + + public void setHeatBuffer(int HeatBuffer); + + public void addtoHeatBuffer(int heat); + + public int getTransmitHeat(); + + public int fillHeatBuffer(int maxAmount); + + public int getMaxHeatEmittedPerTick(); + + public void updateHeatEntity(); + + public int maxrequestHeatTick(ForgeDirection directionFrom); + + public int requestHeat(ForgeDirection directionFrom, int requestheat); + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatSink.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatSink.java new file mode 100644 index 0000000000..80adcf0d51 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IHeatSink.java @@ -0,0 +1,13 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IHeatSink { + + + int maxHeatInPerTick(ForgeDirection var1); + + int addHeat(ForgeDirection var1, int var2); + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IMetaTileEntityHeatPipe.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IMetaTileEntityHeatPipe.java new file mode 100644 index 0000000000..770f249648 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/IMetaTileEntityHeatPipe.java @@ -0,0 +1,14 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces; + +import java.util.ArrayList; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import net.minecraft.tileentity.TileEntity; + +public interface IMetaTileEntityHeatPipe extends IMetaTileEntity { + + + long transferHeat(byte var1, long var2, long var4, ArrayList<TileEntity> var6); + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java new file mode 100644 index 0000000000..6bf048320f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -0,0 +1,343 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces.internal; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.material.Material; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public interface IGregtech_RecipeAdder { + /** + * Adds a Coke Oven Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInputb = second Input (can be null, and respects StackSize) + * @param aFluidOutput = Output of the Creosote (not null, and respects StackSize) + * @param aFluidInput = fluid Input (can be null, and respects StackSize) + * @param aOutput = Output of the Coal/coke (can be null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + //public boolean addCokeOvenRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue); + public boolean addCokeOvenRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput, int aDuration, int aEUt); + + + public boolean addCokeOvenRecipe(int aCircuit, ItemStack aInput2, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int aDuration, int aEUt); + + + public boolean addCokeOvenRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int aDuration, int aEUt); + + + public boolean addFuel(ItemStack aInput1, ItemStack aOutput1, int aEU, int aType); + + + /** + * Adds a Matter Fabricator Recipe + * + * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) + * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addMatterFabricatorRecipe(FluidStack aFluidInput, FluidStack aFluidOutput, int aDuration, int aEUt); + + /** + * Adds a Matter Fabricator Recipe + * + * @param aItemInput = ItemStack Input, can be null I assume. + * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addMatterFabricatorRecipe(ItemStack aItemInput, FluidStack aFluidInput, FluidStack aFluidOutput, int aDuration, int aEUt); + + + + + /** + * Adds a Recipe for the Dehydrator. (up to 9 Outputs) + * + * @param aInput = Input itemstack (not null, and respects StackSize) + * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aOutputItems = Itemstack[] (not null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + + //public boolean addDehydratorRecipe(ItemStack aInput, FluidStack aFluid, ItemStack[] aOutputItems, int aDuration, int aEUt); + /*public boolean addDehydratorRecipe(FluidStack aFluid, FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int aEUt);*/ + /*public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt); + public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack aItemB, FluidStack aFluid, ItemStack[] aOutputItems, FluidStack aOutputFluid, int aDuration, int aEUt);*/ + + /** + * Adds a Recipe for the Dehydrator. (up to 9 Outputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = fluid Input (can be UU_Amp or null, and respects StackSize) + * @param aFluidOutput = Output of the UU-Matter (not null, and respects StackSize) + * @param aOutputItems = ItemStack[] (not null, and respects StackSize) + * @param aChances = Output Change (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addDehydratorRecipe(ItemStack[] aInput, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack[] aOutputItems, int[] aChances, int aDuration, int aEUt); + + + /** + * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidOutput = Output of the Molten Metal (not null, and respects StackSize) + * @param aChances = Output Chance (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aOutput, int aChance, int aDuration, int aEUt); + + /** + * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) + * @param aFluidOutput = Output of the Molten Metal (not null, and respects StackSize) + * @param aChances = Output Chance (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, int aDuration, int aEUt); + + /** + * Adds a Recipe for the Alloy Blast Smelter. (up to 9 Inputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) + * @param aFluidOutput = Output of the Molten Metal (not null, and respects StackSize) + * @param aOutputStack = Item Output (Can be null) + * @param aChances = Output Chance (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, int aDuration, int aEUt); + + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, int aDuration, int aEUt, int aSpecialValue); + + /** + * Adds a Recipe for the LFTRr. (up to 9 Inputs) + * + * @param aInput = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) + * @param aFluidOutput = Output of the Molten Salts (not null, and respects StackSize) + * @param aOutputStack = Item Output (Can be null) + * @param aChances = Output Chance (can be == 0) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @param aSpecialValue = Power produced in EU/t per dynamo + * @return true if the Recipe got added, otherwise false. + */ + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, int aDuration, int aEUt, int aSpecialValue); + + + public boolean addLFTRRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, int aDuration, int aEUt); + public boolean addLFTRRecipe(ItemStack aInput1, FluidStack aInput2, ItemStack aOutput1, FluidStack aOutput2, int aDuration, int aEUt); + public boolean addLFTRRecipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt); + + + /** + * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. + * @param aFuelItem - A Fluidstack to be consumed. + * @param aFuelValue - Fuel value in thousands (1 = 1000) + * @return - Was the Fuel added? + */ + public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue); + + /** + * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. + * @param aFuelItem - A Fluidstack to be consumed. + * @param aFuelValue - Fuel value in thousands (1 = 1000) + * @return - Was the Fuel added? + */ + public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue); + + public boolean addFissionFuel( + FluidStack aInput1, FluidStack aInput2, FluidStack aInput3, + FluidStack aInput4, FluidStack aInput5, FluidStack aInput6, + FluidStack aInput7, FluidStack aInput8, FluidStack aInput9, + FluidStack aOutput1, FluidStack aOutput2, + int aDuration, int aEUt); + + public boolean addFissionFuel( + boolean aOptimise, + FluidStack aInput1, FluidStack aInput2, FluidStack aInput3, + FluidStack aInput4, FluidStack aInput5, FluidStack aInput6, + FluidStack aInput7, FluidStack aInput8, FluidStack aInput9, + FluidStack aOutput1, FluidStack aOutput2, + int aDuration, int aEUt); + + public boolean addCyclotronRecipe(ItemStack aInput, FluidStack aFluidInput, ItemStack[] aOutputs, + FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue); + + boolean addCyclotronRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack[] aOutput, FluidStack aFluidOutput, + int[] aChances, int aDuration, int aEUt, int aSpecialValue); + + 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); + + + /** + * Adds a Recipe for the Machine Component Assembler. (up to 6 Inputs) + * + * @param aInputs = ItemStack[] (not null, and respects StackSize) + * @param aFluidInput = Input of a fluid (can be null, and respects StackSize) + * @param aOutput1 = Output ItemStack (not null, and respects StackSize) + * @param aDuration = Duration (must be >= 0) + * @param aEUt = EU per tick needed for heating up (must be >= 0) + * @return true if the Recipe got added, otherwise false. + */ + public boolean addComponentMakerRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack aOutput1, int aDuration, int aEUt); + + public boolean addMultiblockCentrifugeRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial); + + public boolean addMultiblockElectrolyzerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial); + + public boolean addAdvancedFreezerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial); + + + public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, ItemStack aOutput, int a1, int a2); + public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, FluidStack aInputFluid, ItemStack aOutput, int a1, int a2); + + public boolean addSixSlotAssemblingRecipe(ItemStack[] aInputs, FluidStack aInputFluid, ItemStack aOutput1, int aDuration, int aEUt); + /** + * Adds an Assemblyline Recipe + * + * @param aInputs must be != null, 4-16 inputs + * @param aFluidInputs 0-4 fluids + * @param aOutput1 must be != null + * @param aDuration must be > 0 + * @param aEUt should be > 0 + */ + public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt); + + /** + * Adds a Assemblyline Recipe + * + * @param aInputs elements should be: ItemStack for single item; + * ItemStack[] for multiple equivalent items; + * {OreDict, amount} for oredict. + */ + boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, Object[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput1, int aDuration, int aEUt); + + + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, int time, int eu); + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, Object object, int time, int eu); + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack object, int time); + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, int aCircuit, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time, int eu); + + public boolean addMultiblockChemicalRecipe(ItemStack[] itemStacks, FluidStack[] fluidStacks, FluidStack[] fluidStacks2, ItemStack[] outputs, int time, int eu); + + public boolean addCompressorRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt); + + public boolean addBrewingRecipe(ItemStack aIngredient, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden); + + public boolean addBrewingRecipe(int aCircuit, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden); + + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput); + + public boolean addFluidExtractionRecipe(ItemStack input, FluidStack output, int aTime, int aEu); + + public boolean addFluidExtractionRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidOut, int aTime, int aEu); + + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn); + + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut); + + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut, int aTime, int aEu); + + /** + * Adds a Fusion reactor Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInput2 = 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) + */ + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, int aFusionDurationInTicks, int aEu, int aSpecial); + /** + * Adds a Fusion reactor Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInput2 = 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) + */ + public boolean addFusionReactorRecipe(FluidStack aInputStackA, FluidStack aInputStackB, FluidStack plasma, int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial); + /** + * Adds a Fusion reactor Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInput2 = 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) + */ + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial); + + + 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); + + public boolean addChemicalPlantRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int time, long eu, int aTier); + public boolean addChemicalPlantRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int[] aChances, int time, long eu, int aTier); + + public boolean addBlastRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int time, long eu, int aHeat); + + public boolean addPyrolyseRecipe(ItemStack aInput, FluidStack aFluidInput, int intCircuit, ItemStack aOutput, FluidStack aFluidOutput, int aDuration, int aEUt); + + public boolean addExtractorRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEUt); + + public boolean addDistilleryRecipe(ItemStack aCircuit, FluidStack aInput, FluidStack aOutput, ItemStack aSolidOutput, int aDuration, int aEUt, boolean aHidden); + + public boolean addPulverisationRecipe(final ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, final ItemStack aOutput3); + + 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); + + public boolean addpackagerRecipe(ItemStack aRecipeType, ItemStack aInput1, ItemStack aInput2, ItemStack aOutputStack1); + + public boolean addFuelForRTG(ItemStack aFuelPellet, int aFuelDays, int aVoltage); + + public boolean addColdTrapRecipe(int aCircuit, ItemStack aInput, FluidStack aFluidInput, ItemStack[] aOutputs, int[] aChances, FluidStack aFluidOutput, int aTime, int aEU); + + public boolean addReactorProcessingUnitRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, ItemStack[] aOutputs, int[] aChances, FluidStack aFluidOutput, int aTime, int aEU); + + public boolean addFluidHeaterRecipe(ItemStack aCircuit, FluidStack aInput, FluidStack aOutput, int aDuration, int aEUt); + + public boolean addVacuumFreezerRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEU); + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_IconContainer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_IconContainer.java new file mode 100644 index 0000000000..b6c36483af --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_IconContainer.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces.internal; + +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +public interface Interface_IconContainer { + /** + * @return A regular Icon. + */ + public IIcon getIcon(); + + /** + * @return Icon of the Overlay (or null if there is no Icon) + */ + public IIcon getOverlayIcon(); + + /** + * @return the Default Texture File for this Icon. + */ + public ResourceLocation getTextureFile(); +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ItemBehaviour.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ItemBehaviour.java new file mode 100644 index 0000000000..e874258a7a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ItemBehaviour.java @@ -0,0 +1,42 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces.internal; + +import java.util.List; + +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import gregtech.api.enums.SubTag; + +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_Base; + +public interface Interface_ItemBehaviour<E extends Item> { + public boolean onLeftClickEntity(E aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity); + + public boolean onItemUse(E aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ); + + public boolean onItemUseFirst(E aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ); + + public ItemStack onItemRightClick(E aItem, ItemStack aStack, World aWorld, EntityPlayer aPlayer); + + public List<String> getAdditionalToolTips(E aItem, List<String> aList, ItemStack aStack); + + public void onUpdate(E aItem, ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand); + + public boolean isItemStackUsable(E aItem, ItemStack aStack); + + public boolean canDispense(E aItem, IBlockSource aSource, ItemStack aStack); + + public ItemStack onDispense(E aItem, IBlockSource aSource, ItemStack aStack); + + public boolean hasProjectile(Gregtech_MetaItem_Base aItem, SubTag aProjectileType, ItemStack aStack); + + public EntityArrow getProjectile(E aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ); + + public EntityArrow getProjectile(E aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, EntityLivingBase aEntity, float aSpeed); +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator.java new file mode 100644 index 0000000000..c997f14c9e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces.internal; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.Materials; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; + +public interface Interface_OreRecipeRegistrator { + /** + * Contains a Code Fragment, used in the OrePrefix to register Recipes. Better than using a switch/case, like I did before. + * + * @param aPrefix always != null + * @param aMaterial always != null, and can be == _NULL if the Prefix is Self Referencing or not Material based! + * @param aStack always != null + */ + public void registerOre(GregtechOrePrefixes aPrefix, GT_Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack); + + public void registerOre(GregtechOrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, ItemStack copyAmount); +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator_GT.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator_GT.java new file mode 100644 index 0000000000..6037424d1f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_OreRecipeRegistrator_GT.java @@ -0,0 +1,18 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces.internal; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.OrePrefixes; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; + +public interface Interface_OreRecipeRegistrator_GT { + /** + * Contains a Code Fragment, used in the OrePrefix to register Recipes. Better than using a switch/case, like I did before. + * + * @param aPrefix always != null + * @param aMaterial always != null, and can be == _NULL if the Prefix is Self Referencing or not Material based! + * @param aStack always != null + */ + public void registerOre(OrePrefixes aPrefix, GT_Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack); +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_Texture.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_Texture.java new file mode 100644 index 0000000000..74c996d116 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_Texture.java @@ -0,0 +1,20 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces.internal; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; + +public interface Interface_Texture { + public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + + public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + + public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + + public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + + public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + + public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ); + + public boolean isValidTexture(); +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ToolStats.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ToolStats.java new file mode 100644 index 0000000000..ca167e4c7f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/Interface_ToolStats.java @@ -0,0 +1,193 @@ +package gtPlusPlus.xmod.gregtech.api.interfaces.internal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +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.DamageSource; + +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.IToolStats; +import gregtech.api.items.GT_MetaGenerated_Tool; + +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; +import net.minecraftforge.event.world.BlockEvent; + +/** + * The Stats for GT Tools. Not including any Material Modifiers. + * <p/> + * And this is supposed to not have any ItemStack Parameters as these are generic Stats. + */ +public interface Interface_ToolStats extends IToolStats{ + /** + * Called when aPlayer crafts this Tool + */ + @Override + public void onToolCrafted(ItemStack aStack, EntityPlayer aPlayer); + + /** + * Called when this gets added to a Tool Item + */ + public void onStatsAddedToTool(Gregtech_MetaTool gregtech_MetaTool, int aID); + + /** + * @return Damage the Tool receives when breaking a Block. 100 is one Damage Point (or 100 EU). + */ + @Override + public int getToolDamagePerBlockBreak(); + + /** + * @return Damage the Tool receives when converting the drops of a Block. 100 is one Damage Point (or 100 EU). + */ + @Override + public int getToolDamagePerDropConversion(); + + /** + * @return Damage the Tool receives when being used as Container Item. 100 is one use, however it is usually 8 times more than normal. + */ + @Override + public int getToolDamagePerContainerCraft(); + + /** + * @return Damage the Tool receives when being used as Weapon, 200 is the normal Value, 100 for actual Weapons. + */ + @Override + public int getToolDamagePerEntityAttack(); + + /** + * @return Basic Quality of the Tool, 0 is normal. If increased, it will increase the general quality of all Tools of this Type. Decreasing is also possible. + */ + @Override + public int getBaseQuality(); + + /** + * @return The Damage Bonus for this Type of Tool against Mobs. 1.0F is normal punch. + */ + @Override + public float getBaseDamage(); + + /** + * @return This gets the Hurt Resistance time for Entities getting hit. (always does 1 as minimum) + */ + @Override + public int getHurtResistanceTime(int aOriginalHurtResistance, Entity aEntity); + + /** + * @return This is a multiplier for the Tool Speed. 1.0F = no special Speed. + */ + @Override + public float getSpeedMultiplier(); + + /** + * @return This is a multiplier for the Tool Speed. 1.0F = no special Durability. + */ + @Override + public float getMaxDurabilityMultiplier(); + + @Override + public DamageSource getDamageSource(EntityLivingBase aPlayer, Entity aEntity); + + @Override + public String getMiningSound(); + + @Override + public String getCraftingSound(); + + @Override + public String getEntityHitSound(); + + @Override + public String getBreakingSound(); + + @Override + public Enchantment[] getEnchantments(ItemStack aStack); + + @Override + public int[] getEnchantmentLevels(ItemStack aStack); + + /** + * @return If this Tool can be used for blocking Damage like a Sword. + */ + @Override + public boolean canBlock(); + + /** + * @return If this Tool can be used as an RC Crowbar. + */ + @Override + public boolean isCrowbar(); + + /** + * @return If this Tool can be used as an BC Wrench. + */ + public boolean isWrench(); + + /** + * @return If this Tool can be used as Weapon i.e. if that is the main purpose. + */ + @Override + public boolean isWeapon(); + + /** + * @return If this Tool is a Ranged Weapon. Return false at isWeapon unless you have a Blade attached to your Bow/Gun or something + */ + @Override + public boolean isRangedWeapon(); + + /** + * @return If this Tool can be used as Weapon i.e. if that is the main purpose. + */ + @Override + public boolean isMiningTool(); + + /** + * aBlock.getHarvestTool(aMetaData) can return the following Values for example. + * "axe", "pickaxe", "sword", "shovel", "hoe", "grafter", "saw", "wrench", "crowbar", "file", "hammer", "plow", "plunger", "scoop", "screwdriver", "sense", "scythe", "softhammer", "cutter", "plasmatorch" + * + * @return If this is a minable Block. Tool Quality checks (like Diamond Tier or something) are separate from this check. + */ + @Override + public boolean isMinableBlock(Block aBlock, byte aMetaData); + + /** + * This lets you modify the Drop List, when this type of Tool has been used. + * + * @return the Amount of modified Items. + */ + @Override + public int convertBlockDrops(List<ItemStack> aDrops, ItemStack aStack, EntityPlayer aPlayer, Block aBlock, int aX, int aY, int aZ, byte aMetaData, int aFortune, boolean aSilkTouch, BlockEvent.HarvestDropsEvent aEvent); + + /** + * @return Returns a broken Version of the Item. + */ + @Override + public ItemStack getBrokenItem(ItemStack aStack); + + /** + * @return the Damage actually done to the Mob. + */ + @Override + public float getNormalDamageAgainstEntity(float aOriginalDamage, Entity aEntity, ItemStack aStack, EntityPlayer aPlayer); + + /** + * @return the Damage actually done to the Mob. + */ + @Override + public float getMagicDamageAgainstEntity(float aOriginalDamage, Entity aEntity, ItemStack aStack, EntityPlayer aPlayer); + + @Override + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack); + + @Override + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack); + + /** + * Called when this gets added to a Tool Item + */ + @Override + public void onStatsAddedToTool(GT_MetaGenerated_Tool aItem, int aID); +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_Generic_Item.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_Generic_Item.java new file mode 100644 index 0000000000..43998577c9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_Generic_Item.java @@ -0,0 +1,192 @@ +package gtPlusPlus.xmod.gregtech.api.items; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockDispenser; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.dispenser.*; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IProjectile; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gregtech.api.enums.SubTag; +import gregtech.api.interfaces.IProjectileItem; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; + +/** + * Extended by most Items, also used as a fallback Item, to prevent the accidental deletion when Errors occur. + */ +public class Gregtech_Generic_Item extends Item implements IProjectileItem { + private final String mName, mTooltip; + protected IIcon mIcon; + + public Gregtech_Generic_Item(final String aUnlocalized, final String aEnglish, final String aEnglishTooltip) { + this(aUnlocalized, aEnglish, aEnglishTooltip, true); + } + + public Gregtech_Generic_Item(final String aUnlocalized, final String aEnglish, final String aEnglishTooltip, final boolean aWriteToolTipIntoLangFile) { + super(); + this.mName = aUnlocalized; + GT_LanguageManager.addStringLocalization(this.mName + ".name", aEnglish); + if (GT_Utility.isStringValid(aEnglishTooltip)) { + GT_LanguageManager.addStringLocalization(this.mTooltip = this.mName + ".tooltip_main", aEnglishTooltip, aWriteToolTipIntoLangFile); + } else { + this.mTooltip = null; + } + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerItem(this, this.mName, CORE.MODID); + BlockDispenser.dispenseBehaviorRegistry.putObject(this, new GT_Item_Dispense()); + } + + @Override + public final Item setUnlocalizedName(final String aName) { + return this; + } + + @Override + public final String getUnlocalizedName() { + return this.mName; + } + + @Override + public String getUnlocalizedName(final ItemStack aStack) { + return this.getHasSubtypes() ? this.mName + "." + this.getDamage(aStack) : this.mName; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister aIconRegister) { + this.mIcon = aIconRegister.registerIcon(CORE.MODID+":"+this.mName); + } + + @Override + public boolean doesSneakBypassUse(final World aWorld, final int aX, final int aY, final int aZ, final EntityPlayer aPlayer) { + return true; + } + + @Override + public IIcon getIconFromDamage(final int par1) { + return this.mIcon; + } + + public int getTier(final ItemStack aStack) { + return 0; + } + + @Override + public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { + if ((this.getMaxDamage() > 0) && !this.getHasSubtypes()) { + aList.add((aStack.getMaxDamage() - this.getDamage(aStack)) + " / " + aStack.getMaxDamage()); + } + if (this.mTooltip != null) { + aList.add(GT_LanguageManager.getTranslation(this.mTooltip)); + } + if (GT_ModHandler.isElectricItem(aStack)) { + aList.add("Tier: " + this.getTier(aStack)); + } + this.addAdditionalToolTips(aList, aStack); + } + + protected void addAdditionalToolTips(final List aList, final ItemStack aStack) { + // + } + + @Override + public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + this.isItemStackUsable(aStack); + } + + public boolean isItemStackUsable(final ItemStack aStack) { + return true; + } + + public ItemStack onDispense(final IBlockSource aSource, final ItemStack aStack) { + final EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); + final IPosition iposition = BlockDispenser.func_149939_a(aSource); + final ItemStack itemstack1 = aStack.splitStack(1); + BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition); + return aStack; + } + + @Override + public EntityArrow getProjectile(final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final double aX, final double aY, final double aZ) { + return null; + } + + @Override + public EntityArrow getProjectile(final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final EntityLivingBase aEntity, final float aSpeed) { + return null; + } + + @Override + public boolean hasProjectile(final SubTag aProjectileType, final ItemStack aStack) { + return false; + } + + @Override + public ItemStack getContainerItem(final ItemStack aStack) { + return null; + } + + @Override + public boolean hasContainerItem(final ItemStack aStack) { + return this.getContainerItem(aStack) != null; + } + + public static class GT_Item_Dispense extends BehaviorProjectileDispense { + @Override + public ItemStack dispenseStack(final IBlockSource aSource, final ItemStack aStack) { + return ((Gregtech_Generic_Item) aStack.getItem()).onDispense(aSource, aStack); + } + + @Override + protected IProjectile getProjectileEntity(final World aWorld, final IPosition aPosition) { + return null; + } + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + if (stack.getDisplayName().contains("LuV")){ + HEX_OxFFFFFF = 0xffffcc; + } + else if (stack.getDisplayName().contains("ZPM")){ + HEX_OxFFFFFF = 0xace600; + } + else if (stack.getDisplayName().contains("UV")){ + HEX_OxFFFFFF = 0xffff00; + } + else if (stack.getDisplayName().contains("MAX")){ + HEX_OxFFFFFF = 0xff0000; + } + else if (stack.getDisplayName().contains("Sodium")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(0, 0, 150); + } + else if (stack.getDisplayName().contains("Cadmium")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(50, 50, 60); + } + else if (stack.getDisplayName().contains("Lithium")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(225, 220, 255); + } + else { + HEX_OxFFFFFF = 0xffffff; + } + return HEX_OxFFFFFF; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem.java new file mode 100644 index 0000000000..12b90c9a6c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem.java @@ -0,0 +1,345 @@ +package gtPlusPlus.xmod.gregtech.api.items; + +import static gregtech.api.enums.GT_Values.D1; + +import java.util.*; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.interfaces.IFoodStat; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ItemBehaviour; + +public abstract class Gregtech_MetaItem extends Gregtech_MetaItem_Base { + /** + * All instances of this Item Class are listed here. + * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. + * <p/> + * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. + */ + public static final HashMap<String, Gregtech_MetaItem> sInstances = new HashMap<>(); + + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + + public final short mOffset, mItemAmount; + public final BitSet mEnabledItems; + public final BitSet mVisibleItems; + public final IIcon[][] mIconList; + + public final HashMap<Short, IFoodStat> mFoodStats = new HashMap<>(); + public final HashMap<Short, Long[]> mElectricStats = new HashMap<>(); + public final HashMap<Short, Long[]> mFluidContainerStats = new HashMap<>(); + public final HashMap<Short, Short> mBurnValues = new HashMap<>(); + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + */ + public Gregtech_MetaItem(final String aUnlocalized, final short aOffset, final short aItemAmount) { + super(aUnlocalized); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.mEnabledItems = new BitSet(aItemAmount); + this.mVisibleItems = new BitSet(aItemAmount); + + this.mOffset = (short) Math.min(32766, aOffset); + this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset); + this.mIconList = new IIcon[aItemAmount][1]; + + sInstances.put(this.getUnlocalizedName(), this); + } + + /** + * This adds a Custom Item to the ending Range. + * + * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset) + * @param aEnglish The Default Localized Name of the created Item + * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip + * @param aFoodBehavior The Food Value of this Item. Can be null aswell. Just a convenience thing. + * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things. + * @return An ItemStack containing the newly created Item. + */ + public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) { + if (aToolTip == null) { + aToolTip = ""; + } + if ((aID >= 0) && (aID < this.mItemAmount)) { + final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID); + this.mEnabledItems.set(aID); + this.mVisibleItems.set(aID); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); + final List<TC_AspectStack> tAspects = new ArrayList<>(); + // Important Stuff to do first + for (final Object tRandomData : aRandomData) { + if (tRandomData instanceof SubTag) { + if (tRandomData == SubTag.INVISIBLE) { + this.mVisibleItems.set(aID, false); + continue; + } + if (tRandomData == SubTag.NO_UNIFICATION) { + GT_OreDictUnificator.addToBlacklist(rStack); + continue; + } + } + } + // now check for the rest + for (final Object tRandomData : aRandomData) { + if (tRandomData != null) { + boolean tUseOreDict = true; + + if (tRandomData instanceof Interface_ItemBehaviour) { + this.addItemBehavior(this.mOffset + aID, (Interface_ItemBehaviour<Gregtech_MetaItem_Base>) tRandomData); + tUseOreDict = false; + } + if (tRandomData instanceof IItemContainer) { + ((IItemContainer) tRandomData).set(rStack); + tUseOreDict = false; + } + if (tRandomData instanceof SubTag) { + continue; + } + if (tRandomData instanceof TC_AspectStack) { + ((TC_AspectStack) tRandomData).addToAspectList(tAspects); + continue; + } + if (tRandomData instanceof ItemData) { + if (GT_Utility.isStringValid(tRandomData)) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } else { + GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); + } + continue; + } + if (tUseOreDict) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + continue; + } + } + } + if (GregTech_API.sThaumcraftCompat != null) { + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + return rStack; + } + return null; + } + + /** + * Sets the Furnace Burn Value for the Item. + * + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aValue 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU) + * @return the Item itself for convenience in constructing. + */ + public final Gregtech_MetaItem setBurnValue(final int aMetaValue, final int aValue) { + if ((aMetaValue < 0) || (aMetaValue >= (this.mOffset + this.mEnabledItems.length())) || (aValue < 0)) { + return this; + } + if (aValue == 0) { + this.mBurnValues.remove((short) aMetaValue); + } else { + this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue); + } + return this; + } + + /** + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) + * @param aTransferLimit Transfer Limit. + * @param aTier The electric Tier. + * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). + * Use -1 if you want to make this Battery chargeable (the use and canUse Functions will still discharge if you just use this) + * Use -2 if you want to make this Battery dischargeable. + * Use -3 if you want to make this Battery charge/discharge-able. + * @return the Item itself for convenience in constructing. + */ + public final Gregtech_MetaItem setElectricStats(final int aMetaValue, final long aMaxCharge, final long aTransferLimit, final long aTier, final long aSpecialData, final boolean aUseAnimations) { + if ((aMetaValue < 0) || (aMetaValue >= (this.mOffset + this.mEnabledItems.length()))) { + return this; + } + if (aMaxCharge == 0) { + this.mElectricStats.remove((short) aMetaValue); + } else { + this.mElectricStats.put((short) aMetaValue, new Long[]{aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData}); + if ((aMetaValue >= this.mOffset) && aUseAnimations) { + this.mIconList[aMetaValue - this.mOffset] = Arrays.copyOf(this.mIconList[aMetaValue - this.mOffset], Math.max(9, this.mIconList[aMetaValue - this.mOffset].length)); + } + } + return this; + } + + /** + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) + * @param aTransferLimit Transfer Limit. + * @param aTier The electric Tier. + * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). + * Use -1 if you want to make this Battery chargeable (the use and canUse Functions will still discharge if you just use this) + * Use -2 if you want to make this Battery dischargeable. + * Use -3 if you want to make this Battery charge/discharge-able. + * @return the Item itself for convenience in constructing. + */ + public final Gregtech_MetaItem setFluidContainerStats(final int aMetaValue, final long aCapacity, final long aStacksize) { + if ((aMetaValue < 0) || (aMetaValue >= (this.mOffset + this.mEnabledItems.length()))) { + return this; + } + if (aCapacity < 0) { + this.mElectricStats.remove((short) aMetaValue); + } else { + this.mFluidContainerStats.put((short) aMetaValue, new Long[]{aCapacity, Math.max(1, aStacksize)}); + } + return this; + } + + /** + * @return if this MetaGenerated Item should use my Default Renderer System. + */ + public boolean useStandardMetaItemRenderer() { + return true; + } + + /** + * @return the Color Modulation the Material is going to be rendered with. + */ + public short[] getRGBa(final ItemStack aStack) { + return Materials._NULL.getRGBA(); + } + + /** + * @return the Icon the Material is going to be rendered with. + */ + public IIconContainer getIconContainer(final int aMetaData) { + return null; + } + + /* ---------- INTERNAL OVERRIDES ---------- */ + + @Override + public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + return super.onItemRightClick(aStack, aWorld, aPlayer); + } + + @Override + public int getMaxItemUseDuration(final ItemStack aStack) { + return this.mFoodStats.get((short) this.getDamage(aStack)) == null ? 0 : 32; + } + + @Override + public EnumAction getItemUseAction(final ItemStack aStack) { + return EnumAction.none; + } + + @Override + public final ItemStack onEaten(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IFoodStat tStat = this.mFoodStats.get((short) this.getDamage(aStack)); + if (tStat != null) { + + } + return aStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { + for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) { + if (this.mVisibleItems.get(i) || (D1 && this.mEnabledItems.get(i))) { + final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i)); + if ((tStats != null) && (tStats[3] < 0)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.setCharge(tStack, Math.abs(tStats[0])); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + if ((tStats == null) || (tStats[3] != -2)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(final IIconRegister aIconRegister) { + for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) { + if (this.mEnabledItems.get(i)) { + for (byte k = 1; k < this.mIconList[i].length; k++) { + this.mIconList[i][k] = aIconRegister.registerIcon(CORE.MODID+":"+this.getUnlocalizedName() + "/" + i + "/" + k); + } + this.mIconList[i][0] = aIconRegister.registerIcon(CORE.MODID+":"+this.getUnlocalizedName() + "/" + i); + } + } + } + + @Override + public final Long[] getElectricStats(final ItemStack aStack) { + return this.mElectricStats.get((short) aStack.getItemDamage()); + } + + @Override + public final Long[] getFluidContainerStats(final ItemStack aStack) { + return this.mFluidContainerStats.get((short) aStack.getItemDamage()); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + if (stack.getDisplayName().contains("LuV")){ + HEX_OxFFFFFF = 0xffffcc; + } + else if (stack.getDisplayName().contains("ZPM")){ + HEX_OxFFFFFF = 0xace600; + } + else if (stack.getDisplayName().contains("UV")){ + HEX_OxFFFFFF = 0xffff00; + } + else if (stack.getDisplayName().contains("MAX")){ + HEX_OxFFFFFF = 0xff0000; + } + else { + HEX_OxFFFFFF = 0xffffff; + } + return HEX_OxFFFFFF; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java new file mode 100644 index 0000000000..ec1c90186a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_Base.java @@ -0,0 +1,675 @@ +package gtPlusPlus.xmod.gregtech.api.items; + +import static gregtech.api.enums.GT_Values.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.inventory.Container; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import gregtech.api.enums.SubTag; +import gregtech.api.util.*; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ItemBehaviour; +import ic2.api.item.*; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; + +public abstract class Gregtech_MetaItem_Base extends Gregtech_Generic_Item implements ISpecialElectricItem, IElectricItemManager, IFluidContainerItem { + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + private final HashMap<Short, ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>>> mItemBehaviors = new HashMap<>(); + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + * @param aGeneratedPrefixList The OreDict Prefixes you want to have generated. + */ + public Gregtech_MetaItem_Base(final String aUnlocalized) { + super(aUnlocalized, "Generated Item", null, false); + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + /** + * Adds a special Item Behaviour to the Item. + * <p/> + * Note: the boolean Behaviours sometimes won't be executed if another boolean Behaviour returned true before. + * + * @param aMetaValue the Meta Value of the Item you want to add it to. [0 - 32765] + * @param aBehavior the Click Behavior you want to add. + * @return the Item itself for convenience in constructing. + */ + public final Gregtech_MetaItem_Base addItemBehavior(final int aMetaValue, final Interface_ItemBehaviour<Gregtech_MetaItem_Base> aBehavior) { + if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) { + return this; + } + ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) aMetaValue); + if (tList == null) { + tList = new ArrayList<>(1); + this.mItemBehaviors.put((short) aMetaValue, tList); + } + tList.add(aBehavior); + return this; + } + + public abstract Long[] getElectricStats(ItemStack aStack); + + public abstract Long[] getFluidContainerStats(ItemStack aStack); + + @Override + public boolean hasProjectile(final SubTag aProjectileType, final ItemStack aStack) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + if (tBehavior.hasProjectile(this, aProjectileType, aStack)) { + return true; + } + } + } + return super.hasProjectile(aProjectileType, aStack); + } + + @Override + public EntityArrow getProjectile(final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final double aX, final double aY, final double aZ) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + final EntityArrow rArrow = tBehavior.getProjectile(this, aProjectileType, aStack, aWorld, aX, aY, aZ); + if (rArrow != null) { + return rArrow; + } + } + } + return super.getProjectile(aProjectileType, aStack, aWorld, aX, aY, aZ); + } + + @Override + public EntityArrow getProjectile(final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final EntityLivingBase aEntity, final float aSpeed) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + final EntityArrow rArrow = tBehavior.getProjectile(this, aProjectileType, aStack, aWorld, aEntity, aSpeed); + if (rArrow != null) { + return rArrow; + } + } + } + return super.getProjectile(aProjectileType, aStack, aWorld, aEntity, aSpeed); + } + + @Override + public ItemStack onDispense(final IBlockSource aSource, final ItemStack aStack) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + if (tBehavior.canDispense(this, aSource, aStack)) { + return tBehavior.onDispense(this, aSource, aStack); + } + } + } + return super.onDispense(aSource, aStack); + } + + @Override + public boolean isItemStackUsable(final ItemStack aStack) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + if (!tBehavior.isItemStackUsable(this, aStack)) { + return false; + } + } + } + return super.isItemStackUsable(aStack); + } + + @Override + public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { + this.use(aStack, 0, aPlayer); + this.isItemStackUsable(aStack); + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + try { + if (tBehavior.onLeftClickEntity(this, aStack, aPlayer, aEntity)) { + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + return false; + } + } catch (final Throwable e) { + if (D1) { + e.printStackTrace(GT_Log.err); + } + } + } + } + return false; + } + + @Override + public boolean onItemUse(final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { + this.use(aStack, 0, aPlayer); + this.isItemStackUsable(aStack); + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + try { + if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + return false; + } + } catch (final Throwable e) { + if (D1) { + e.printStackTrace(GT_Log.err); + } + } + } + } + return false; + } + + @Override + public boolean onItemUseFirst(final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { + this.use(aStack, 0, aPlayer); + this.isItemStackUsable(aStack); + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + try { + if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + return false; + } + } catch (final Throwable e) { + if (D1) { + e.printStackTrace(GT_Log.err); + } + } + } + } + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + this.use(aStack, 0, aPlayer); + this.isItemStackUsable(aStack); + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + try { + aStack = tBehavior.onItemRightClick(this, aStack, aWorld, aPlayer); + } catch (final Throwable e) { + if (D1) { + e.printStackTrace(GT_Log.err); + } + } + } + } + return aStack; + } + + @Override + public final void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { + final String tKey = this.getUnlocalizedName(aStack) + ".tooltip", tString = GT_LanguageManager.getTranslation(tKey); + if (GT_Utility.isStringValid(tString) && !tKey.equals(tString)) { + aList.add(tString); + } + + Long[] + tStats = this.getElectricStats(aStack); + if (tStats != null) { + if (tStats[3] > 0) { + aList.add(EnumChatFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " + (tStats[2] >= 0 ? tStats[2] : 0) + EnumChatFormatting.GRAY); + } else { + final long tCharge = this.getRealCharge(aStack); + if ((tStats[3] == -2) && (tCharge <= 0)) { + aList.add(EnumChatFormatting.AQUA + "Empty. You should recycle it properly." + EnumChatFormatting.GRAY); + } else { + aList.add(EnumChatFormatting.AQUA + "" + GT_Utility.formatNumbers(tCharge) + " / " + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] + EnumChatFormatting.GRAY); + } + } + } + + tStats = this.getFluidContainerStats(aStack); + if ((tStats != null) && (tStats[0] > 0)) { + final FluidStack tFluid = this.getFluidContent(aStack); + aList.add(EnumChatFormatting.BLUE + ((tFluid == null ? "No Fluids Contained" : GT_Utility.getFluidName(tFluid, true))) + EnumChatFormatting.GRAY); + aList.add(EnumChatFormatting.BLUE + ((tFluid == null ? 0 : tFluid.amount) + "L / " + tStats[0] + "L") + EnumChatFormatting.GRAY); + } + + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + aList = tBehavior.getAdditionalToolTips(this, aList, aStack); + } + } + + this.addAdditionalToolTips(aList, aStack); + } + + @Override + public void onUpdate(final ItemStack aStack, final World aWorld, final Entity aPlayer, final int aTimer, final boolean aIsInHand) { + final ArrayList<Interface_ItemBehaviour<Gregtech_MetaItem_Base>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final Interface_ItemBehaviour<Gregtech_MetaItem_Base> tBehavior : tList) { + tBehavior.onUpdate(this, aStack, aWorld, aPlayer, aTimer, aIsInHand); + } + } + } + + @Override + public final boolean canProvideEnergy(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return false; + } + return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3))); + } + + @Override + public final double getMaxCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.abs(tStats[0]); + } + + @Override + public final double getTransferLimit(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.max(tStats[1], tStats[3]); + } + + @Override + public final double charge(final ItemStack aStack, final double aCharge, final int aTier, final boolean aIgnoreTransferLimit, final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[2] > aTier) || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE))) || (aStack.stackSize != 1)) { + return 0; + } + final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : Math.min(Math.abs(tStats[0]), tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tNewCharge - tChargeBefore; + } + + @Override + public final double discharge(final ItemStack aStack, final double aCharge, final int aTier, final boolean aIgnoreTransferLimit, final boolean aBatteryAlike, final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[2] > aTier)) { + return 0; + } + if (aBatteryAlike && !this.canProvideEnergy(aStack)) { + return 0; + } + if (tStats[3] > 0) { + if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) { + return 0; + } + if (!aSimulate) { + aStack.stackSize--; + } + return tStats[3]; + } + final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = Math.max(0, tChargeBefore - (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tChargeBefore - tNewCharge; + } + + @Override + public final double getCharge(final ItemStack aStack) { + return this.getRealCharge(aStack); + } + + @Override + public final boolean canUse(final ItemStack aStack, final double aAmount) { + return this.getRealCharge(aStack) >= aAmount; + } + + @Override + public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) { + this.chargeFromArmor(aStack, aPlayer); + if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) { + return true; + } + final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); + if (tTransfer == aAmount) { + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return true; + } + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return false; + } + + @Override + public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) { + if ((aPlayer == null) || aPlayer.worldObj.isRemote) { + return; + } + for (int i = 1; i < 5; i++) { + final ItemStack tArmor = aPlayer.getEquipmentInSlot(i); + if (GT_ModHandler.isElectricItem(tArmor)) { + final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem(); + if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) { + final double tCharge = ElectricItem.manager.discharge(tArmor, this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true), Integer.MAX_VALUE, true, true, false); + if (tCharge > 0) { + this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false); + if (aPlayer instanceof EntityPlayer) { + final Container tContainer = ((EntityPlayer) aPlayer).openContainer; + if (tContainer != null) { + tContainer.detectAndSendChanges(); + } + } + } + } + } + } + } + + public final long getRealCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + if (tStats[3] > 0) { + return (int) (long) tStats[3]; + } + final NBTTagCompound tNBT = aStack.getTagCompound(); + return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge"); + } + + public final boolean setCharge(final ItemStack aStack, long aCharge) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[3] > 0)) { + return false; + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + tNBT.removeTag("GT.ItemCharge"); + aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0])); + if (aCharge > 0) { + aStack.setItemDamage(this.getChargedMetaData(aStack)); + tNBT.setLong("GT.ItemCharge", aCharge); + } else { + aStack.setItemDamage(this.getEmptyMetaData(aStack)); + } + if (tNBT.hasNoTags()) { + aStack.setTagCompound(null); + } else { + aStack.setTagCompound(tNBT); + } + this.isItemStackUsable(aStack); + return true; + } + + public short getChargedMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + public short getEmptyMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + @Override + public FluidStack getFluid(final ItemStack aStack) { + return this.getFluidContent(aStack); + } + + @Override + public int getCapacity(final ItemStack aStack) { + final Long[] tStats = this.getFluidContainerStats(aStack); + return tStats == null ? 0 : (int) Math.max(0, tStats[0]); + } + + @Override + public int fill(final ItemStack aStack, final FluidStack aFluid, final boolean doFill) { + if ((aStack == null) || (aStack.stackSize != 1)) { + return 0; + } + + final ItemStack tStack = GT_Utility.fillFluidContainer(aFluid, aStack, false, false); + if (tStack != null) { + aStack.setItemDamage(tStack.getItemDamage()); + aStack.func_150996_a(tStack.getItem()); + return GT_Utility.getFluidForFilledItem(tStack, false).amount; + } + + final Long[] tStats = this.getFluidContainerStats(aStack); + if ((tStats == null) || (tStats[0] <= 0) || (aFluid == null) || (aFluid.getFluid().getID() <= 0) || (aFluid.amount <= 0)) { + return 0; + } + + FluidStack tFluid = this.getFluidContent(aStack); + + if ((tFluid == null) || (tFluid.getFluid().getID() <= 0)) { + if (aFluid.amount <= tStats[0]) { + if (doFill) { + this.setFluidContent(aStack, aFluid); + } + return aFluid.amount; + } + if (doFill) { + tFluid = aFluid.copy(); + tFluid.amount = (int) (long) tStats[0]; + this.setFluidContent(aStack, tFluid); + } + return (int) (long) tStats[0]; + } + + if (!tFluid.isFluidEqual(aFluid)) { + return 0; + } + + final int space = (int) (long) tStats[0] - tFluid.amount; + if (aFluid.amount <= space) { + if (doFill) { + tFluid.amount += aFluid.amount; + this.setFluidContent(aStack, tFluid); + } + return aFluid.amount; + } + if (doFill) { + tFluid.amount = (int) (long) tStats[0]; + this.setFluidContent(aStack, tFluid); + } + return space; + } + + @Override + public FluidStack drain(final ItemStack aStack, final int maxDrain, final boolean doDrain) { + if ((aStack == null) || (aStack.stackSize != 1)) { + return null; + } + + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aStack, false); + if ((tFluid != null) && (maxDrain >= tFluid.amount)) { + final ItemStack tStack = GT_Utility.getContainerItem(aStack, false); + if (tStack == null) { + aStack.stackSize = 0; + return tFluid; + } + aStack.setItemDamage(tStack.getItemDamage()); + aStack.func_150996_a(tStack.getItem()); + return tFluid; + } + + final Long[] tStats = this.getFluidContainerStats(aStack); + if ((tStats == null) || (tStats[0] <= 0)) { + return null; + } + + tFluid = this.getFluidContent(aStack); + if (tFluid == null) { + return null; + } + + int used = maxDrain; + if (tFluid.amount < used) { + used = tFluid.amount; + } + if (doDrain) { + tFluid.amount -= used; + this.setFluidContent(aStack, tFluid); + } + + final FluidStack drained = tFluid.copy(); + drained.amount = used; + return drained; + } + + public FluidStack getFluidContent(final ItemStack aStack) { + final Long[] tStats = this.getFluidContainerStats(aStack); + if ((tStats == null) || (tStats[0] <= 0)) { + return GT_Utility.getFluidForFilledItem(aStack, false); + } + final NBTTagCompound tNBT = aStack.getTagCompound(); + return tNBT == null ? null : FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("GT.FluidContent")); + } + + public void setFluidContent(final ItemStack aStack, final FluidStack aFluid) { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } else { + tNBT.removeTag("GT.FluidContent"); + } + if ((aFluid != null) && (aFluid.amount > 0)) { + tNBT.setTag("GT.FluidContent", aFluid.writeToNBT(new NBTTagCompound())); + } + if (tNBT.hasNoTags()) { + aStack.setTagCompound(null); + } else { + aStack.setTagCompound(tNBT); + } + this.isItemStackUsable(aStack); + } + + @Override + public int getItemStackLimit(final ItemStack aStack) { + Long[] tStats = this.getElectricStats(aStack); + if ((tStats != null) && ((tStats[3] == -1) || (tStats[3] == -3)) && (this.getRealCharge(aStack) > 0)) { + return 1; + } + tStats = this.getFluidContainerStats(aStack); + if (tStats != null) { + return (int) (long) tStats[1]; + } + return 64; + } + + @Override + public final Item getChargedItem(final ItemStack itemStack) { + return this; + } + + @Override + public final Item getEmptyItem(final ItemStack itemStack) { + return this; + } + + @Override + public final int getTier(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]); + } + + @Override + public final String getToolTip(final ItemStack aStack) { + return null; + } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up at this Point + + @Override + public final IElectricItemManager getManager(final ItemStack aStack) { + return this; + } // We are our own Manager + + @Override + public final boolean getShareTag() { + return true; + } // just to be sure. + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + if (stack.getDisplayName().contains("LuV")){ + HEX_OxFFFFFF = 0xffffcc; + } + else if (stack.getDisplayName().contains("ZPM")){ + HEX_OxFFFFFF = 0xace600; + } + else if (stack.getDisplayName().contains("UV")){ + HEX_OxFFFFFF = 0xffff00; + } + else if (stack.getDisplayName().contains("MAX")){ + HEX_OxFFFFFF = 0xff0000; + } + else if (stack.getDisplayName().contains("Sodium")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(0, 0, 150); + } + else if (stack.getDisplayName().contains("Cadmium")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(50, 50, 60); + } + else if (stack.getDisplayName().contains("Lithium")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(225, 220, 255); + } + else { + HEX_OxFFFFFF = 0xffffff; + } + return HEX_OxFFFFFF; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_X32.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_X32.java new file mode 100644 index 0000000000..a5430846a9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaItem_X32.java @@ -0,0 +1,243 @@ +package gtPlusPlus.xmod.gregtech.api.items; + +import java.util.Arrays; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; + +/** + * @author Gregorius Techneticies + * <p/> + * One Item for everything! + * <p/> + * This brilliant Item Class is used for automatically generating all possible variations of Material Items, like Dusts, Ingots, Gems, Plates and similar. + * It saves me a ton of work, when adding Items, because I always have to make a new Item SubType for each OreDict Prefix, when adding a new Material. + * <p/> + * As you can see, up to 32766 Items can be generated using this Class. And the last 766 Items can be custom defined, just to save space and MetaData. + * <p/> + * These Items can also have special RightClick abilities, electric Charge or even be set to become a Food alike Item. + */ +public abstract class Gregtech_MetaItem_X32 extends Gregtech_MetaItem { + + protected final OrePrefixes[] mGeneratedPrefixList; + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + * @param aGeneratedPrefixList The OreDict Prefixes you want to have generated. + */ + public Gregtech_MetaItem_X32(final String aUnlocalized, final OrePrefixes... aGeneratedPrefixList) { + super(aUnlocalized, (short) 32000, (short) 766); + this.mGeneratedPrefixList = Arrays.copyOf(aGeneratedPrefixList, 32); + + for (int i = 0; i < 32000; i++) { + final OrePrefixes tPrefix = this.mGeneratedPrefixList[i / 1000]; + if (tPrefix == null) { + continue; + } + final Materials tMaterial = GregTech_API.sGeneratedMaterials[i % 1000]; + if (tMaterial == null) { + continue; + } + if (this.doesMaterialAllowGeneration(tPrefix, tMaterial)) { + final ItemStack tStack = new ItemStack(this, 1, i); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(tStack) + ".name", this.getDefaultLocalization(tPrefix, tMaterial, i)); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(tStack) + ".tooltip", tMaterial.getToolTip(tPrefix.mMaterialAmount / GT_Values.M)); + if (tPrefix.mIsUnificatable) { + GT_OreDictUnificator.set(tPrefix, tMaterial, tStack); + } else { + GT_OreDictUnificator.registerOre(tPrefix.get(tMaterial), tStack); + } + if (((tPrefix == OrePrefixes.stick) || (tPrefix == OrePrefixes.wireFine)) && ((tMaterial == Materials.Lead) || (tMaterial == Materials.Tin) || (tMaterial == Materials.SolderingAlloy))) { + GregTech_API.sSolderingMetalList.add(tStack); + } + } + } + } + + /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ + + /** + * @return the Color Modulation the Material is going to be rendered with. + */ + @Override + public short[] getRGBa(final ItemStack aStack) { + final Materials tMaterial = GregTech_API.sGeneratedMaterials[this.getDamage(aStack) % 1000]; + return tMaterial == null ? Materials._NULL.mRGBa : tMaterial.mRGBa; + } + + /** + * @param aPrefix this can be null, you have to return false in that case + * @param aMaterial this can be null, you have to return false in that case + * @return if this Item should be generated and visible. + */ + public boolean doesMaterialAllowGeneration(final OrePrefixes aPrefix, final Materials aMaterial) { + // You have to check for at least these Conditions in every Case! So add a super Call like the following for this before executing your Code: + // if (!super.doesMaterialAllowGeneration(aPrefix, aMaterial)) return false; + return (aPrefix != null) && (aMaterial != null) && aPrefix.doGenerateItem(aMaterial); + } + + /* ---------- OVERRIDEABLE FUNCTIONS ---------- */ + + /** + * @param aPrefix the OreDict Prefix + * @param aMaterial the Material + * @param aMetaData a Index from [0 - 31999] + * @return the Localized Name when default LangFiles are used. + */ + public String getDefaultLocalization(final OrePrefixes aPrefix, final Materials aMaterial, final int aMetaData) { + return aPrefix.getDefaultLocalNameForItem(aMaterial); + } + + /** + * @param aMetaData a Index from [0 - 31999] + * @param aMaterial the Material + * @return an Icon Container for the Item Display. + */ + public final IIconContainer getIconContainer(final int aMetaData, final Materials aMaterial) { + return (this.mGeneratedPrefixList[aMetaData / 1000] != null) && (this.mGeneratedPrefixList[aMetaData / 1000].mTextureIndex >= 0) ? aMaterial.mIconSet.mTextures[this.mGeneratedPrefixList[aMetaData / 1000].mTextureIndex] : null; + } + + /** + * @param aPrefix always != null + * @param aMaterial always != null + * @param aDoShowAllItems this is the Configuration Setting of the User, if he wants to see all the Stuff like Tiny Dusts or Crushed Ores as well. + * @return if this Item should be visible in NEI or Creative + */ + public boolean doesShowInCreative(final OrePrefixes aPrefix, final Materials aMaterial, final boolean aDoShowAllItems) { + return true; + } + + /* ---------- INTERNAL OVERRIDES ---------- */ + + @Override + public ItemStack getContainerItem(final ItemStack aStack) { + final int aDamage = aStack.getItemDamage(); + if ((aDamage < 32000) && (aDamage >= 0)) { + final Materials aMaterial = GregTech_API.sGeneratedMaterials[aDamage % 1000]; + if ((aMaterial != null) && (aMaterial != Materials.Empty) && (aMaterial != Materials._NULL)) { + final OrePrefixes aPrefix = this.mGeneratedPrefixList[aDamage / 1000]; + if (aPrefix != null) { + return GT_Utility.copyAmount(1, aPrefix.mContainerItem); + } + } + } + return null; + } + + @Override + public final IIconContainer getIconContainer(final int aMetaData) { + return GregTech_API.sGeneratedMaterials[aMetaData % 1000] == null ? null : this.getIconContainer(aMetaData, GregTech_API.sGeneratedMaterials[aMetaData % 1000]); + } + + @Override + @SideOnly(Side.CLIENT) + public final void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { + for (int i = 0; i < 32000; i++) { + if (this.doesMaterialAllowGeneration(this.mGeneratedPrefixList[i / 1000], GregTech_API.sGeneratedMaterials[i % 1000]) && this.doesShowInCreative(this.mGeneratedPrefixList[i / 1000], GregTech_API.sGeneratedMaterials[i % 1000], GregTech_API.sDoShowAllItemsInCreative)) { + final ItemStack tStack = new ItemStack(this, 1, i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + super.getSubItems(var1, aCreativeTab, aList); + } + + @Override + public final IIcon getIconFromDamage(final int aMetaData) { + if (aMetaData < 0) { + return null; + } + if (aMetaData < 32000) { + final Materials tMaterial = GregTech_API.sGeneratedMaterials[aMetaData % 1000]; + if (tMaterial == null) { + return null; + } + final IIconContainer tIcon = this.getIconContainer(aMetaData, tMaterial); + if (tIcon != null) { + return tIcon.getIcon(); + } + return null; + } + return (aMetaData - 32000) < this.mIconList.length ? this.mIconList[aMetaData - 32000][0] : null; + } + + @Override + public int getItemStackLimit(final ItemStack aStack) { + final int tDamage = this.getDamage(aStack); + if ((tDamage < 32000) && (this.mGeneratedPrefixList[tDamage / 1000] != null)) { + return Math.min(super.getItemStackLimit(aStack), this.mGeneratedPrefixList[tDamage / 1000].mDefaultStackSize); + } + return super.getItemStackLimit(aStack); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + + int aMeta = stack.getItemDamage(); + if (stack.getDisplayName().contains("Sodium")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(90, 90, 255); + } + else if (stack.getDisplayName().contains("Cadmium")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(150, 150, 80); + } + else if (stack.getDisplayName().contains("Lithium")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(225, 220, 255); + } + else if (stack.getDisplayName().contains("Wrought")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 180, 180); + } + else if (stack.getDisplayName().contains("Bronze")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 128, 0); + } + else if (stack.getDisplayName().contains("Brass")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 180, 0); + } + else if (stack.getDisplayName().contains("Invar")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(180, 180, 120); + } + else { + if (aMeta > 50 && aMeta != 150) { + HEX_OxFFFFFF = 0xffffff; + } + else if (stack.getDisplayName().contains("ULV")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 180, 180); + } + else if (stack.getDisplayName().contains("LuV")){ + HEX_OxFFFFFF = 0xffffcc; + } + else if (stack.getDisplayName().contains("ZPM")){ + HEX_OxFFFFFF = 0xffe600; + } + else if (stack.getDisplayName().contains("UV")){ + HEX_OxFFFFFF = 0xffb300; + } + else if (stack.getDisplayName().contains("MAX")){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(MathUtils.randInt(220, 250), MathUtils.randInt(221, 251), MathUtils.randInt(220, 250)); + } + else { + HEX_OxFFFFFF = 0xffffff; + } + } + return HEX_OxFFFFFF; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java new file mode 100644 index 0000000000..ae84afb056 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/Gregtech_MetaTool.java @@ -0,0 +1,503 @@ +package gtPlusPlus.xmod.gregtech.api.items; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; + +import cpw.mods.fml.common.Optional; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatList; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import gregtech.api.enchants.Enchantment_Radioactivity; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.IDamagableItem; +import gregtech.api.interfaces.IToolStats; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; + +import buildcraft.api.tools.IToolWrench; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; +import mods.railcraft.api.core.items.IToolCrowbar; +import net.minecraftforge.event.world.BlockEvent; + +/** + * This is an example on how you can create a Tool ItemStack, in this case a Bismuth Wrench: + * GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(16, 1, Materials.Bismuth, Materials.Bismuth, null); + */ +@Optional.InterfaceList({@Optional.Interface(iface = "forestry.api.arboriculture.IToolGrafter", modid = "Forestry"), + @Optional.Interface(iface = "mods.railcraft.api.core.items.IToolCrowbar", modid = "Railcraft"), + @Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraft"), + @Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO")}) +public abstract class Gregtech_MetaTool extends GT_MetaGenerated_Tool implements IDamagableItem, IToolCrowbar, IToolWrench { + /** + * All instances of this Item Class are listed here. + * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. + * <p/> + * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. + */ + public static final HashMap<String, Gregtech_MetaTool> sInstances = new HashMap<>(); + + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + + public final HashMap<Short, IToolStats> mToolStats = new HashMap<>(); + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + */ + public Gregtech_MetaTool(final String aUnlocalized) { + super(aUnlocalized); + GT_ModHandler.registerBoxableItemToToolBox(this); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setMaxStackSize(1); + sInstances.put(this.getUnlocalizedName(), this); + } + + /** + * Called by the Block Harvesting Event within the GT_Proxy + */ + @Override + public void onHarvestBlockEvent(final ArrayList<ItemStack> aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { + final IToolStats tStats = this.getToolStats(aStack); + if (this.isItemStackUsable(aStack) && (this.getDigSpeed(aStack, aBlock, aMetaData) > 0.0F)) { + this.doDamage(aStack, tStats.convertBlockDrops(aDrops, aStack, aPlayer, aBlock, aX, aY, aZ, aMetaData, aFortune, aSilkTouch, aEvent) * tStats.getToolDamagePerDropConversion()); + } + } + + @Override + public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats == null) || !this.isItemStackUsable(aStack)) { + return true; + } + GT_Utility.doSoundAtClient(tStats.getEntityHitSound(), 1, 1.0F); + if (super.onLeftClickEntity(aStack, aPlayer, aEntity)) { + return true; + } + if (aEntity.canAttackWithItem() && !aEntity.hitByEntity(aPlayer)) { + final float tMagicDamage = tStats.getMagicDamageAgainstEntity(aEntity instanceof EntityLivingBase ? EnchantmentHelper.getEnchantmentModifierLiving(aPlayer, (EntityLivingBase) aEntity) : 0.0F, aEntity, aStack, aPlayer); + float tDamage = tStats.getNormalDamageAgainstEntity((float) aPlayer.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() + this.getToolCombatDamage(aStack), aEntity, aStack, aPlayer); + if ((tDamage + tMagicDamage) > 0.0F) { + final boolean tCriticalHit = (aPlayer.fallDistance > 0.0F) && !aPlayer.onGround && !aPlayer.isOnLadder() && !aPlayer.isInWater() && !aPlayer.isPotionActive(Potion.blindness) && (aPlayer.ridingEntity == null) && (aEntity instanceof EntityLivingBase); + if (tCriticalHit && (tDamage > 0.0F)) { + tDamage *= 1.5F; + } + tDamage += tMagicDamage; + if (aEntity.attackEntityFrom(tStats.getDamageSource(aPlayer, aEntity), tDamage)) { + if (aEntity instanceof EntityLivingBase) { + aEntity.setFire(EnchantmentHelper.getFireAspectModifier(aPlayer) * 4); + } + final int tKnockcack = (aPlayer.isSprinting() ? 1 : 0) + (aEntity instanceof EntityLivingBase ? EnchantmentHelper.getKnockbackModifier(aPlayer, (EntityLivingBase) aEntity) : 0); + if (tKnockcack > 0) { + aEntity.addVelocity(-MathHelper.sin((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F, 0.1D, MathHelper.cos((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F); + aPlayer.motionX *= 0.6D; + aPlayer.motionZ *= 0.6D; + aPlayer.setSprinting(false); + } + if (tCriticalHit) { + aPlayer.onCriticalHit(aEntity); + } + if (tMagicDamage > 0.0F) { + aPlayer.onEnchantmentCritical(aEntity); + } + if (tDamage >= 18.0F) { + aPlayer.triggerAchievement(AchievementList.overkill); + } + aPlayer.setLastAttacker(aEntity); + if (aEntity instanceof EntityLivingBase) { + EnchantmentHelper.func_151384_a((EntityLivingBase) aEntity, aPlayer); + } + EnchantmentHelper.func_151385_b(aPlayer, aEntity); + if (aEntity instanceof EntityLivingBase) { + aPlayer.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F)); + } + aEntity.hurtResistantTime = Math.max(1, tStats.getHurtResistanceTime(aEntity.hurtResistantTime, aEntity)); + aPlayer.addExhaustion(0.3F); + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + + @Override + public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats != null) && tStats.canBlock()) { + aPlayer.setItemInUse(aStack, 72000); + } + return super.onItemRightClick(aStack, aWorld, aPlayer); + } + + + @SuppressWarnings("unchecked") + public void addAdditionalToolTips(final List aList, final ItemStack aStack) { + final long tMaxDamage = getToolMaxDamage(aStack); + final Materials tMaterial = getPrimaryMaterial(aStack); + final IToolStats tStats = this.getToolStats(aStack); + final int tOffset = this.getElectricStats(aStack) != null ? 2 : 1; + if (tStats != null) { + final String name = aStack.getUnlocalizedName(); + if (name.equals("gt.metatool.01.170") || name.equals("gt.metatool.01.172") || name.equals("gt.metatool.01.174") || name.equals("gt.metatool.01.176")) { + aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); + aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); + aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Turbine Efficency: " + EnumChatFormatting.BLUE + (50.0F + (10.0F * this.getToolCombatDamage(aStack))) + EnumChatFormatting.GRAY); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Steam flow: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "L/sec"); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Gas flow(EU burnvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 25) + EnumChatFormatting.GRAY + "EU/t"); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Plasma flow(Plasma energyvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "EU/t"); + + } else { + aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); + aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); + aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Attack Damage: " + EnumChatFormatting.BLUE + this.getToolCombatDamage(aStack) + EnumChatFormatting.GRAY); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Mining Speed: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) + EnumChatFormatting.GRAY); + } + } + } + + @SuppressWarnings("unchecked") + public void addAdditionalToolTips(final List aList, final ItemStack aStack, final EntityPlayer aPlayer) { + final long tMaxDamage = getToolMaxDamage(aStack); + final Materials tMaterial = getPrimaryMaterial(aStack); + final IToolStats tStats = this.getToolStats(aStack); + final int tOffset = this.getElectricStats(aStack) != null ? 2 : 1; + if (tStats != null) { + final String name = aStack.getUnlocalizedName(); + if (name.equals("gt.metatool.01.170") || name.equals("gt.metatool.01.172") || name.equals("gt.metatool.01.174") || name.equals("gt.metatool.01.176")) { + aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); + aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); + aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Turbine Efficency: " + EnumChatFormatting.BLUE + (50.0F + (10.0F * this.getToolCombatDamage(aStack))) + EnumChatFormatting.GRAY); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Steam flow: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "L/sec"); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Gas flow(EU burnvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 50) + EnumChatFormatting.GRAY + "EU/t"); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Plasma flow(Plasma energyvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "EU/t"); + + } else { + aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY); + aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + this.getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY); + aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Attack Damage: " + EnumChatFormatting.BLUE + this.getToolCombatDamage(aStack) + EnumChatFormatting.GRAY); + aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Mining Speed: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) + EnumChatFormatting.GRAY); + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if ((aNBT != null) && aNBT.hasKey("Heat")){ + int tHeat = aNBT.getInteger("Heat"); + final long tWorldTime = aPlayer.getEntityWorld().getWorldTime(); + if(aNBT.hasKey("HeatTime")){ + final long tHeatTime = aNBT.getLong("HeatTime"); + if(tWorldTime>(tHeatTime+10)){ + tHeat = (int) (tHeat - ((tWorldTime-tHeatTime)/10)); + if((tHeat<300)&&(tHeat>-10000)) { + tHeat=300; + } + } + aNBT.setLong("HeatTime", tWorldTime); + if(tHeat>-10000) { + aNBT.setInteger("Heat", tHeat); + } + } + + aList.add(tOffset + 3, EnumChatFormatting.RED + "Heat: " + aNBT.getInteger("Heat")+" K" + EnumChatFormatting.GRAY); + } + } + } + } + } + + @Override + public Long[] getFluidContainerStats(final ItemStack aStack) { + return null; + } + + @Override + public Long[] getElectricStats(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if ((aNBT != null) && aNBT.getBoolean("Electric")) { + return new Long[]{aNBT.getLong("MaxCharge"), aNBT.getLong("Voltage"), aNBT.getLong("Tier"), aNBT.getLong("SpecialData")}; + } + } + return new Long[] {}; + } + + @Override + public float getToolCombatDamage(final ItemStack aStack) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return 0; + } + return tStats.getBaseDamage() + getPrimaryMaterial(aStack).mToolQuality; + } + + @Override + public float getDigSpeed(final ItemStack aStack, final Block aBlock, final int aMetaData) { + if (!this.isItemStackUsable(aStack)) { + return 0.0F; + } + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats == null) || (Math.max(0, this.getHarvestLevel(aStack, "")) < aBlock.getHarvestLevel(aMetaData))) { + return 0.0F; + } + return tStats.isMinableBlock(aBlock, (byte) aMetaData) ? Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) : 0.0F; + } + + @Override + public boolean onBlockDestroyed(final ItemStack aStack, final World aWorld, final Block aBlock, final int aX, final int aY, final int aZ, final EntityLivingBase aPlayer) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return false; + } + GT_Utility.doSoundAtClient(tStats.getMiningSound(), 1, 1.0F); + this.doDamage(aStack, (int) Math.max(1, aBlock.getBlockHardness(aWorld, aX, aY, aZ) * tStats.getToolDamagePerBlockBreak())); + return this.getDigSpeed(aStack, aBlock, aWorld.getBlockMetadata(aX, aY, aZ)) > 0.0F; + } + + private ItemStack getContainerItem(ItemStack aStack, final boolean playSound) { + if (!this.isItemStackUsable(aStack)) { + return null; + } + aStack = GT_Utility.copyAmount(1, aStack); + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return null; + } + this.doDamage(aStack, tStats.getToolDamagePerContainerCraft()); + aStack = aStack.stackSize > 0 ? aStack : null; + if (playSound) { + //String sound = (aStack == null) ? tStats.getBreakingSound() : tStats.getCraftingSound(); + //GT_Utility.doSoundAtClient(sound, 1, 1.0F); + } + return aStack; + } + + @Override + public Interface_ToolStats getToolStats(final ItemStack aStack) { + this.isItemStackUsable(aStack); + return this.getToolStatsInternal(aStack); + } + + private Interface_ToolStats getToolStatsInternal(final ItemStack aStack) { + return (Interface_ToolStats) (aStack == null ? null : this.mToolStats.get((short) aStack.getItemDamage())); + } + + @Override + public boolean canWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public boolean canWrench(final EntityPlayer player, final int x, final int y, final int z) { + //System.out.println("canWrench"); + if(player==null) { + return false; + } + if(player.getCurrentEquippedItem()==null) { + return false; + } + if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { + return false; + } + final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + return (tStats != null) && tStats.isWrench(); + } + + @Override + public void wrenchUsed(final EntityPlayer player, final int x, final int y, final int z) { + if(player==null) { + return; + } + if(player.getCurrentEquippedItem()==null) { + return; + } + final IToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + if (tStats != null) { + this.doDamage(player.getCurrentEquippedItem(), tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public boolean canLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public boolean canBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats != null) && (aPlayer != null)) { + tStats.onToolCrafted(aStack, aPlayer); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean isItemStackUsable(final ItemStack aStack) { + final IToolStats tStats = this.getToolStatsInternal(aStack); + if (((aStack.getItemDamage() % 2) == 1) || (tStats == null)) { + final NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT.removeTag("ench"); + } + return false; + } + final Materials aMaterial = getPrimaryMaterial(aStack); + final HashMap<Integer, Integer> tMap = new HashMap<>(), tResult = new HashMap<>(); + if (aMaterial.mEnchantmentTools != null) { + tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); + if (aMaterial.mEnchantmentTools == Enchantment.fortune) { + tMap.put(Enchantment.looting.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + if (aMaterial.mEnchantmentTools == Enchantment.knockback) { + tMap.put(Enchantment.power.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + if (aMaterial.mEnchantmentTools == Enchantment.fireAspect) { + tMap.put(Enchantment.flame.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + } + final Enchantment[] tEnchants = tStats.getEnchantments(aStack); + final int[] tLevels = tStats.getEnchantmentLevels(aStack); + for (int i = 0; i < tEnchants.length; i++) { + if (tLevels[i] > 0) { + final Integer tLevel = tMap.get(tEnchants[i].effectId); + tMap.put(tEnchants[i].effectId, tLevel == null ? tLevels[i] : tLevel == tLevels[i] ? tLevel + 1 : Math.max(tLevel, tLevels[i])); + } + } + for (final Entry<Integer, Integer> tEntry : tMap.entrySet()) { + if ((tEntry.getKey() == 33) || ((tEntry.getKey() == 20) && (tEntry.getValue() > 2)) || (tEntry.getKey() == Enchantment_Radioactivity.INSTANCE.effectId)) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } else { + switch (Enchantment.enchantmentsList[tEntry.getKey()].type) { + case weapon: + if (tStats.isWeapon()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + case all: + tResult.put(tEntry.getKey(), tEntry.getValue()); + break; + case armor: + case armor_feet: + case armor_head: + case armor_legs: + case armor_torso: + break; + case bow: + if (tStats.isRangedWeapon()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + case breakable: + break; + case fishing_rod: + break; + case digger: + if (tStats.isMiningTool()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + } + } + } + EnchantmentHelper.setEnchantments(tResult, aStack); + return true; + } + + @Override + public short getChargedMetaData(final ItemStack aStack) { + return (short) (aStack.getItemDamage() - (aStack.getItemDamage() % 2)); + } + + @Override + public short getEmptyMetaData(final ItemStack aStack) { + final NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT.removeTag("ench"); + } + return (short) ((aStack.getItemDamage() + 1) - (aStack.getItemDamage() % 2)); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java new file mode 100644 index 0000000000..6f4202fdd8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/tools/GT_MetaGenTool.java @@ -0,0 +1,546 @@ +package gtPlusPlus.xmod.gregtech.api.items.tools; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatList; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; +import gregtech.api.enchants.Enchantment_Radioactivity; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.interfaces.IToolStats; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.*; + +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; +import net.minecraftforge.event.world.BlockEvent; + +/** + * This is an example on how you can create a Tool ItemStack, in this case a Bismuth Wrench: + * GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(16, 1, Materials.Bismuth, Materials.Bismuth, null); + */ +public abstract class GT_MetaGenTool extends GT_MetaGenerated_Tool { + /** + * All instances of this Item Class are listed here. + * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. + * <p/> + * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. + */ + public static final HashMap<String, GT_MetaGenTool> sInstances = new HashMap<>(); + + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + + public final HashMap<Short, IToolStats> mToolStats = new HashMap<>(); + + /** + * Creates the Item using these Parameters. + * + * @param aUnlocalized The Unlocalized Name of this Item. + */ + public GT_MetaGenTool(final String aUnlocalized) { + super(aUnlocalized); + GT_ModHandler.registerBoxableItemToToolBox(this); + this.setCreativeTab(GregTech_API.TAB_GREGTECH); + this.setMaxStackSize(1); + sInstances.put(this.getUnlocalizedName(), this); + } + + /* ---------- FOR ADDING CUSTOM ITEMS INTO THE REMAINING 766 RANGE ---------- */ + + public static final Materials getPrimaryMaterialEx(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if (aNBT != null) { + return Materials.getRealMaterial(aNBT.getString("PrimaryMaterial")); + } + } + return Materials._NULL; + } + + public static final Materials getSecondaryMaterialEx(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if (aNBT != null) { + return Materials.getRealMaterial(aNBT.getString("SecondaryMaterial")); + } + } + return Materials._NULL; + } + + /** + * This adds a Custom Item to the ending Range. + * + * @param aID The Id of the assigned Tool Class [0 - 32765] (only even Numbers allowed! Uneven ID's are empty electric Items) + * @param aEnglish The Default Localized Name of the created Item + * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip + * @param aToolStats The Food Value of this Item. Can be null as well. + * @param aOreDictNamesAndAspects The OreDict Names you want to give the Item. Also used to assign Thaumcraft Aspects. + * @return An ItemStack containing the newly created Item, but without specific Stats. + */ + public final ItemStack addToolEx(final int aID, final String aEnglish, String aToolTip, final IToolStats aToolStats, final Object... aOreDictNamesAndAspects) { + if (aToolTip == null) { + aToolTip = ""; + } + if ((aID >= 0) && (aID < 32766) && ((aID % 2) == 0)) { + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + aID + ".name", aEnglish); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + aID + ".tooltip", aToolTip); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + (aID + 1) + ".name", aEnglish + " (Empty)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + (aID + 1) + ".tooltip", "You need to recharge it"); + this.mToolStats.put((short) aID, aToolStats); + this.mToolStats.put((short) (aID + 1), aToolStats); + aToolStats.onStatsAddedToTool(this, aID); + final ItemStack rStack = new ItemStack(this, 1, aID); + final List<TC_AspectStack> tAspects = new ArrayList<>(); + for (final Object tOreDictNameOrAspect : aOreDictNamesAndAspects) { + if (tOreDictNameOrAspect instanceof TC_AspectStack) { + ((TC_AspectStack) tOreDictNameOrAspect).addToAspectList(tAspects); + } else { + GT_OreDictUnificator.registerOre(tOreDictNameOrAspect, rStack); + } + } + if (GregTech_API.sThaumcraftCompat != null) { + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + return rStack; + } + return null; + } + + /** + * This Function gets an ItemStack Version of this Tool + * + * @param aToolID the ID of the Tool Class + * @param aAmount Amount of Items (well normally you only need 1) + * @param aPrimaryMaterial Primary Material of this Tool + * @param aSecondaryMaterial Secondary (Rod/Handle) Material of this Tool + * @param aElectricArray The Electric Stats of this Tool (or null if not electric) + */ + public final ItemStack getToolWithStatsEx(final int aToolID, final int aAmount, final Materials aPrimaryMaterial, final Materials aSecondaryMaterial, final long[] aElectricArray) { + final ItemStack rStack = new ItemStack(this, aAmount, aToolID); + final IToolStats tToolStats = this.getToolStats(rStack); + if (tToolStats != null) { + final NBTTagCompound tMainNBT = new NBTTagCompound(), tToolNBT = new NBTTagCompound(); + if (aPrimaryMaterial != null) { + tToolNBT.setString("PrimaryMaterial", aPrimaryMaterial.toString()); + tToolNBT.setLong("MaxDamage", 100L * (long) (aPrimaryMaterial.mDurability * tToolStats.getMaxDurabilityMultiplier())); + } + if (aSecondaryMaterial != null) { + tToolNBT.setString("SecondaryMaterial", aSecondaryMaterial.toString()); + } + + if (aElectricArray != null) { + tToolNBT.setBoolean("Electric", true); + tToolNBT.setLong("MaxCharge", aElectricArray[0]); + tToolNBT.setLong("Voltage", aElectricArray[1]); + tToolNBT.setLong("Tier", aElectricArray[2]); + tToolNBT.setLong("SpecialData", aElectricArray[3]); + } + + tMainNBT.setTag("GT.ToolStats", tToolNBT); + rStack.setTagCompound(tMainNBT); + } + this.isItemStackUsable(rStack); + return rStack; + } + + /** + * Called by the Block Harvesting Event within the GT_Proxy + */ + @Override + public void onHarvestBlockEvent(final ArrayList<ItemStack> aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { + final IToolStats tStats = this.getToolStats(aStack); + if (this.isItemStackUsable(aStack) && (this.getDigSpeed(aStack, aBlock, aMetaData) > 0.0F)) { + this.doDamage(aStack, tStats.convertBlockDrops(aDrops, aStack, aPlayer, aBlock, aX, aY, aZ, aMetaData, aFortune, aSilkTouch, aEvent) * tStats.getToolDamagePerDropConversion()); + } + } + + @Override + public boolean onLeftClickEntity(final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats == null) || !this.isItemStackUsable(aStack)) { + return true; + } + GT_Utility.doSoundAtClient(tStats.getEntityHitSound(), 1, 1.0F); + if (super.onLeftClickEntity(aStack, aPlayer, aEntity)) { + return true; + } + if (aEntity.canAttackWithItem() && !aEntity.hitByEntity(aPlayer)) { + final float tMagicDamage = tStats.getMagicDamageAgainstEntity(aEntity instanceof EntityLivingBase ? EnchantmentHelper.getEnchantmentModifierLiving(aPlayer, (EntityLivingBase) aEntity) : 0.0F, aEntity, aStack, aPlayer); + float tDamage = tStats.getNormalDamageAgainstEntity((float) aPlayer.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() + this.getToolCombatDamage(aStack), aEntity, aStack, aPlayer); + if ((tDamage + tMagicDamage) > 0.0F) { + final boolean tCriticalHit = (aPlayer.fallDistance > 0.0F) && !aPlayer.onGround && !aPlayer.isOnLadder() && !aPlayer.isInWater() && !aPlayer.isPotionActive(Potion.blindness) && (aPlayer.ridingEntity == null) && (aEntity instanceof EntityLivingBase); + if (tCriticalHit && (tDamage > 0.0F)) { + tDamage *= 1.5F; + } + tDamage += tMagicDamage; + if (aEntity.attackEntityFrom(tStats.getDamageSource(aPlayer, aEntity), tDamage)) { + if (aEntity instanceof EntityLivingBase) { + aEntity.setFire(EnchantmentHelper.getFireAspectModifier(aPlayer) * 4); + } + final int tKnockcack = (aPlayer.isSprinting() ? 1 : 0) + (aEntity instanceof EntityLivingBase ? EnchantmentHelper.getKnockbackModifier(aPlayer, (EntityLivingBase) aEntity) : 0); + if (tKnockcack > 0) { + aEntity.addVelocity(-MathHelper.sin((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F, 0.1D, MathHelper.cos((aPlayer.rotationYaw * (float) Math.PI) / 180.0F) * tKnockcack * 0.5F); + aPlayer.motionX *= 0.6D; + aPlayer.motionZ *= 0.6D; + aPlayer.setSprinting(false); + } + if (tCriticalHit) { + aPlayer.onCriticalHit(aEntity); + } + if (tMagicDamage > 0.0F) { + aPlayer.onEnchantmentCritical(aEntity); + } + if (tDamage >= 18.0F) { + aPlayer.triggerAchievement(AchievementList.overkill); + } + aPlayer.setLastAttacker(aEntity); + if (aEntity instanceof EntityLivingBase) { + EnchantmentHelper.func_151384_a((EntityLivingBase) aEntity, aPlayer); + } + EnchantmentHelper.func_151385_b(aPlayer, aEntity); + if (aEntity instanceof EntityLivingBase) { + aPlayer.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F)); + } + aEntity.hurtResistantTime = Math.max(1, tStats.getHurtResistanceTime(aEntity.hurtResistantTime, aEntity)); + aPlayer.addExhaustion(0.3F); + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return true; + } + + @Override + public ItemStack onItemRightClick(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats != null) && tStats.canBlock()) { + aPlayer.setItemInUse(aStack, 72000); + } + return super.onItemRightClick(aStack, aWorld, aPlayer); + } + + + @Override + public Long[] getFluidContainerStats(final ItemStack aStack) { + return null; + } + + @Override + public Long[] getElectricStats(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GT.ToolStats"); + if ((aNBT != null) && aNBT.getBoolean("Electric")) { + return new Long[]{aNBT.getLong("MaxCharge"), aNBT.getLong("Voltage"), aNBT.getLong("Tier"), aNBT.getLong("SpecialData")}; + } + } + return null; + } + + @Override + public float getToolCombatDamage(final ItemStack aStack) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return 0; + } + return tStats.getBaseDamage() + getPrimaryMaterial(aStack).mToolQuality; + } + + @Override + public float getDigSpeed(final ItemStack aStack, final Block aBlock, final int aMetaData) { + if (!this.isItemStackUsable(aStack)) { + return 0.0F; + } + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats == null) || (Math.max(0, this.getHarvestLevel(aStack, "")) < aBlock.getHarvestLevel(aMetaData))) { + return 0.0F; + } + return tStats.isMinableBlock(aBlock, (byte) aMetaData) ? Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed) : 0.0F; + } + + @Override + public boolean onBlockDestroyed(final ItemStack aStack, final World aWorld, final Block aBlock, final int aX, final int aY, final int aZ, final EntityLivingBase aPlayer) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return false; + } + GT_Utility.doSoundAtClient(tStats.getMiningSound(), 1, 1.0F); + this.doDamage(aStack, (int) Math.max(1, aBlock.getBlockHardness(aWorld, aX, aY, aZ) * tStats.getToolDamagePerBlockBreak())); + return this.getDigSpeed(aStack, aBlock, aWorld.getBlockMetadata(aX, aY, aZ)) > 0.0F; + } + + private ItemStack getContainerItem(ItemStack aStack, final boolean playSound) { + if (!this.isItemStackUsable(aStack)) { + return null; + } + aStack = GT_Utility.copyAmount(1, aStack); + final IToolStats tStats = this.getToolStats(aStack); + if (tStats == null) { + return null; + } + this.doDamage(aStack, tStats.getToolDamagePerContainerCraft()); + aStack = aStack.stackSize > 0 ? aStack : null; + if (playSound) { + //String sound = (aStack == null) ? tStats.getBreakingSound() : tStats.getCraftingSound(); + //GT_Utility.doSoundAtClient(sound, 1, 1.0F); + } + return aStack; + } + + @Override + public Interface_ToolStats getToolStats(final ItemStack aStack) { + this.isItemStackUsable(aStack); + return this.getToolStatsInternal(aStack); + } + + private Interface_ToolStats getToolStatsInternal(final ItemStack aStack) { + return (Interface_ToolStats) (aStack == null ? null : this.mToolStats.get((short) aStack.getItemDamage())); + } + + @Override + public float getSaplingModifier(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) { + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isGrafter() ? Math.min(100.0F, (1 + this.getHarvestLevel(aStack, "")) * 20.0F) : 0.0F; + } + + @Override + public boolean canWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onWhack(final EntityPlayer aPlayer, final ItemStack aStack, final int aX, final int aY, final int aZ) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + public boolean canWrench(final EntityPlayer player, final int x, final int y, final int z) { + System.out.println("canWrench"); + if(player==null) { + return false; + } + if(player.getCurrentEquippedItem()==null) { + return false; + } + if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { + return false; + } + final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + return (tStats != null) && tStats.isWrench(); + } + + public void wrenchUsed(final EntityPlayer player, final int x, final int y, final int z) { + if(player==null) { + return; + } + if(player.getCurrentEquippedItem()==null) { + return; + } + final IToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + if (tStats != null) { + this.doDamage(player.getCurrentEquippedItem(), tStats.getToolDamagePerEntityAttack()); + } + } + + public boolean canUse(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z){ + return this.canWrench(player, x, y, z); + } + + public void used(final ItemStack stack, final EntityPlayer player, final int x, final int y, final int z){ + this.wrenchUsed(player, x, y, z); + } + + public boolean shouldHideFacades(final ItemStack stack, final EntityPlayer player) { + if(player==null) { + return false; + } + if(player.getCurrentEquippedItem()==null) { + return false; + } + if (!this.isItemStackUsable(player.getCurrentEquippedItem())) { + return false; + } + final Interface_ToolStats tStats = this.getToolStats(player.getCurrentEquippedItem()); + return tStats.isWrench(); + } + + @Override + public boolean canLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onLink(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public boolean canBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + if (!this.isItemStackUsable(aStack)) { + return false; + } + final IToolStats tStats = this.getToolStats(aStack); + return (tStats != null) && tStats.isCrowbar(); + } + + @Override + public void onBoost(final EntityPlayer aPlayer, final ItemStack aStack, final EntityMinecart cart) { + final IToolStats tStats = this.getToolStats(aStack); + if (tStats != null) { + this.doDamage(aStack, tStats.getToolDamagePerEntityAttack()); + } + } + + @Override + public void onCreated(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + final IToolStats tStats = this.getToolStats(aStack); + if ((tStats != null) && (aPlayer != null)) { + tStats.onToolCrafted(aStack, aPlayer); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean isItemStackUsable(final ItemStack aStack) { + final IToolStats tStats = this.getToolStatsInternal(aStack); + if (((aStack.getItemDamage() % 2) == 1) || (tStats == null)) { + final NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT.removeTag("ench"); + } + return false; + } + final Materials aMaterial = getPrimaryMaterial(aStack); + final HashMap<Integer, Integer> tMap = new HashMap<>(), tResult = new HashMap<>(); + if (aMaterial.mEnchantmentTools != null) { + tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); + if (aMaterial.mEnchantmentTools == Enchantment.fortune) { + tMap.put(Enchantment.looting.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + if (aMaterial.mEnchantmentTools == Enchantment.knockback) { + tMap.put(Enchantment.power.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + if (aMaterial.mEnchantmentTools == Enchantment.fireAspect) { + tMap.put(Enchantment.flame.effectId, (int) aMaterial.mEnchantmentToolsLevel); + } + } + final Enchantment[] tEnchants = tStats.getEnchantments(aStack); + final int[] tLevels = tStats.getEnchantmentLevels(aStack); + for (int i = 0; i < tEnchants.length; i++) { + if (tLevels[i] > 0) { + final Integer tLevel = tMap.get(tEnchants[i].effectId); + tMap.put(tEnchants[i].effectId, tLevel == null ? tLevels[i] : tLevel == tLevels[i] ? tLevel + 1 : Math.max(tLevel, tLevels[i])); + } + } + for (final Entry<Integer, Integer> tEntry : tMap.entrySet()) { + if ((tEntry.getKey() == 33) || ((tEntry.getKey() == 20) && (tEntry.getValue() > 2)) || (tEntry.getKey() == Enchantment_Radioactivity.INSTANCE.effectId)) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } else { + switch (Enchantment.enchantmentsList[tEntry.getKey()].type) { + case weapon: + if (tStats.isWeapon()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + case all: + tResult.put(tEntry.getKey(), tEntry.getValue()); + break; + case armor: + case armor_feet: + case armor_head: + case armor_legs: + case armor_torso: + break; + case bow: + if (tStats.isRangedWeapon()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + case breakable: + break; + case fishing_rod: + break; + case digger: + if (tStats.isMiningTool()) { + tResult.put(tEntry.getKey(), tEntry.getValue()); + } + break; + } + } + } + EnchantmentHelper.setEnchantments(tResult, aStack); + return true; + } + + @Override + public short getChargedMetaData(final ItemStack aStack) { + return (short) (aStack.getItemDamage() - (aStack.getItemDamage() % 2)); + } + + @Override + public short getEmptyMetaData(final ItemStack aStack) { + final NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT.removeTag("ench"); + } + return (short) ((aStack.getItemDamage() + 1) - (aStack.getItemDamage() % 2)); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java new file mode 100644 index 0000000000..cefd72332b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Base.java @@ -0,0 +1,85 @@ +package gtPlusPlus.xmod.gregtech.api.items.types; + +import java.util.List; + +import net.minecraft.block.BlockDispenser; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.dispenser.IPosition; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +import gregtech.api.enums.SubTag; + +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ItemBehaviour; +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_Base; + +public class ToolType_Base implements Interface_ItemBehaviour<Gregtech_MetaItem_Base> { + @Override + public boolean onLeftClickEntity(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final EntityPlayer aPlayer, final Entity aEntity) { + return false; + } + + @Override + public boolean onItemUse(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { + return false; + } + + @Override + public boolean onItemUseFirst(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { + return false; + } + + @Override + public ItemStack onItemRightClick(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + return aStack; + } + + @Override + public List<String> getAdditionalToolTips(final Gregtech_MetaItem_Base aItem, final List<String> aList, final ItemStack aStack) { + return aList; + } + + @Override + public void onUpdate(final Gregtech_MetaItem_Base aItem, final ItemStack aStack, final World aWorld, final Entity aPlayer, final int aTimer, final boolean aIsInHand) { + } + + @Override + public boolean isItemStackUsable(final Gregtech_MetaItem_Base aItem, final ItemStack aStack) { + return true; + } + + @Override + public boolean canDispense(final Gregtech_MetaItem_Base aItem, final IBlockSource aSource, final ItemStack aStack) { + return false; + } + + @Override + public ItemStack onDispense(final Gregtech_MetaItem_Base aItem, final IBlockSource aSource, final ItemStack aStack) { + final EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); + final IPosition iposition = BlockDispenser.func_149939_a(aSource); + final ItemStack itemstack1 = aStack.splitStack(1); + BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition); + return aStack; + } + + @Override + public boolean hasProjectile(final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, final ItemStack aStack) { + return false; + } + + @Override + public EntityArrow getProjectile(final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final double aX, final double aY, final double aZ) { + return null; + } + + @Override + public EntityArrow getProjectile(final Gregtech_MetaItem_Base aItem, final SubTag aProjectileType, final ItemStack aStack, final World aWorld, final EntityLivingBase aEntity, final float aSpeed) { + return null; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java new file mode 100644 index 0000000000..d4f5a87006 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_HardHammer.java @@ -0,0 +1,125 @@ +package gtPlusPlus.xmod.gregtech.api.items.types; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +import gregtech.common.blocks.GT_Block_Ores; +import gregtech.common.blocks.GT_TileEntity_Ores; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.IFluidBlock; + +public class ToolType_HardHammer +extends ToolType_Base { + private final int mVanillaCosts; + private final int mEUCosts; + private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.prospecting", "Usable for Prospecting"); + + public ToolType_HardHammer(final int aVanillaCosts, final int aEUCosts) { + this.mVanillaCosts = aVanillaCosts; + this.mEUCosts = aEUCosts; + } + + public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { + if (aWorld.isRemote) { + return false; + } + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + + + ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(aBlock, 1, aMeta)); + if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { + GT_Utility.sendChatToPlayer(aPlayer, "This is " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); + return true; + } + if ((aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone))) { + if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); + int tX = aX; + int tY = aY; + int tZ = aZ; + int tMetaID = 0; + final int tQuality = (aItem instanceof GT_MetaGenerated_Tool) ? ((GT_MetaGenerated_Tool) aItem).getHarvestLevel(aStack, "") : 0; + + int i = 0; + for (final int j = 6 + tQuality; i < j; i++) { + tX -= ForgeDirection.getOrientation(aSide).offsetX; + tY -= ForgeDirection.getOrientation(aSide).offsetY; + tZ -= ForgeDirection.getOrientation(aSide).offsetZ; + + final Block tBlock = aWorld.getBlock(tX, tY, tZ); + if ((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) { + GT_Utility.sendChatToPlayer(aPlayer, "There is Lava behind this Rock."); + break; + } + if ((tBlock == Blocks.water) || (tBlock == Blocks.flowing_water) || ((tBlock instanceof IFluidBlock))) { + GT_Utility.sendChatToPlayer(aPlayer, "There is a Liquid behind this Rock."); + break; + } + if ((tBlock == Blocks.monster_egg) || (!GT_Utility.hasBlockHitBox(aWorld, tX, tY, tZ))) { + GT_Utility.sendChatToPlayer(aPlayer, "There is an Air Pocket behind this Rock."); + break; + } + if (tBlock != aBlock) { + if (i >= 4) { + break; + } + GT_Utility.sendChatToPlayer(aPlayer, "Material is changing behind this Rock."); + break; + } + } + final Random tRandom = new Random(aX ^ aY ^ aZ ^ aSide); + i = 0; + for (final int j = 9 + (2 * tQuality); i < j; i++) { + tX = (aX - 4 - tQuality) + tRandom.nextInt(j); + tY = (aY - 4 - tQuality) + tRandom.nextInt(j); + tZ = (aZ - 4 - tQuality) + tRandom.nextInt(j); + final Block tBlock = aWorld.getBlock(tX, tY, tZ); + if ((tBlock instanceof GT_Block_Ores)) { + final TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + final Materials tMaterial = GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)]; + if ((tMaterial != null) && (tMaterial != Materials._NULL)) { + GT_Utility.sendChatToPlayer(aPlayer, "Found traces of " + tMaterial.mDefaultLocalName + " Ore."); + return true; + } + } + } else { + tMetaID = aWorld.getBlockMetadata(tX, tY, tZ); + tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); + if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { + GT_Utility.sendChatToPlayer(aPlayer, "Found traces of " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); + return true; + } + } + } + GT_Utility.sendChatToPlayer(aPlayer, "No Ores found."); + } + return true; + } + return false; + } + + public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { + aList.add(this.mTooltip); + return aList; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java new file mode 100644 index 0000000000..f62d9e5cfa --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Pump.java @@ -0,0 +1,150 @@ +package gtPlusPlus.xmod.gregtech.api.items.types; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; + +import ic2.api.tile.IWrenchable; +import net.minecraftforge.common.util.ForgeDirection; + +public class ToolType_Pump +extends ToolType_Base { + private final int mCosts; + private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.pump", "Sucks in Machine Input Fluid tank contents on Rightclick"); + + public ToolType_Pump(final int aCosts) { + this.mCosts = aCosts; + } + + public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { + if (aWorld.isRemote) { + return false; + } + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + final byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ); + final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + /*try { + if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable))) { + if (((IWrenchable) aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + ((IWrenchable) aTileEntity).setFacing(aTargetSide); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (((IWrenchable) aTileEntity).wrenchCanRemove(aPlayer)) { + final int tDamage = ((IWrenchable) aTileEntity).getWrenchDropRate() < 1.0F ? 10 : 3; + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, tDamage * this.mCosts))) { + ItemStack tOutput = ((IWrenchable) aTileEntity).getWrenchDrop(aPlayer); + for (final ItemStack tStack : aBlock.getDrops(aWorld, aX, aY, aZ, aMeta, 0)) { + if (tOutput == null) { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tStack)); + } else { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tOutput)); + tOutput = null; + } + } + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + return true; + } + } catch (final Throwable e) { + } + if ((aBlock == Blocks.log) || (aBlock == Blocks.log2) || (aBlock == Blocks.hay_block)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, (aMeta + 4) % 12, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.powered_repeater) || (aBlock == Blocks.unpowered_repeater)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.powered_comparator) || (aBlock == Blocks.unpowered_comparator)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.crafting_table) || (aBlock == Blocks.bookshelf)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, aMeta))); + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (aMeta == aTargetSide) { + if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.trapped_chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.hopper)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, 0))); + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + } else { + if ((aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper)) { + if ((aMeta < 6) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.trapped_chest)) { + if ((aTargetSide > 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (aBlock == Blocks.hopper) { + if ((aTargetSide != 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + } + if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ)).contains(ForgeDirection.getOrientation(aTargetSide))) && + ((aPlayer.capabilities.isCreativeMode) || (!GT_ModHandler.isElectricItem(aStack)) || (GT_ModHandler.canUseElectricItem(aStack, this.mCosts))) && + (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aTargetSide)))) { + if (!aPlayer.capabilities.isCreativeMode) { + ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); + } + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + }*/ + return false; + } + + public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { + aList.add(this.mTooltip); + return aList; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java new file mode 100644 index 0000000000..d0ef6a535c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/items/types/ToolType_Wrench.java @@ -0,0 +1,150 @@ +package gtPlusPlus.xmod.gregtech.api.items.types; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; + +import ic2.api.tile.IWrenchable; +import net.minecraftforge.common.util.ForgeDirection; + +public class ToolType_Wrench +extends ToolType_Base { + private final int mCosts; + private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.wrench", "Rotates Blocks on Rightclick"); + + public ToolType_Wrench(final int aCosts) { + this.mCosts = aCosts; + } + + public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { + if (aWorld.isRemote) { + return false; + } + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + final byte aTargetSide = GT_Utility.determineWrenchingSide((byte) aSide, hitX, hitY, hitZ); + final TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + try { + if ((aTileEntity != null) && ((aTileEntity instanceof IWrenchable))) { + if (((IWrenchable) aTileEntity).wrenchCanSetFacing(aPlayer, aTargetSide)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + ((IWrenchable) aTileEntity).setFacing(aTargetSide); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (((IWrenchable) aTileEntity).wrenchCanRemove(aPlayer)) { + final int tDamage = ((IWrenchable) aTileEntity).getWrenchDropRate() < 1.0F ? 10 : 3; + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, tDamage * this.mCosts))) { + ItemStack tOutput = ((IWrenchable) aTileEntity).getWrenchDrop(aPlayer); + for (final ItemStack tStack : aBlock.getDrops(aWorld, aX, aY, aZ, aMeta, 0)) { + if (tOutput == null) { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tStack)); + } else { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, tOutput)); + tOutput = null; + } + } + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + return true; + } + } catch (final Throwable e) { + } + if ((aBlock == Blocks.log) || (aBlock == Blocks.log2) || (aBlock == Blocks.hay_block)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, (aMeta + 4) % 12, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.powered_repeater) || (aBlock == Blocks.unpowered_repeater)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.powered_comparator) || (aBlock == Blocks.unpowered_comparator)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, ((aMeta / 4) * 4) + (((aMeta % 4) + 1) % 4), 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.crafting_table) || (aBlock == Blocks.bookshelf)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, aMeta))); + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (aMeta == aTargetSide) { + if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.trapped_chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.hopper)) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + aWorld.spawnEntityInWorld(new EntityItem(aWorld, aX + 0.5D, aY + 0.5D, aZ + 0.5D, new ItemStack(aBlock, 1, 0))); + aWorld.setBlockToAir(aX, aY, aZ); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + } else { + if ((aBlock == Blocks.piston) || (aBlock == Blocks.sticky_piston) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper)) { + if ((aMeta < 6) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.pumpkin) || (aBlock == Blocks.lit_pumpkin) || (aBlock == Blocks.furnace) || (aBlock == Blocks.lit_furnace) || (aBlock == Blocks.chest) || (aBlock == Blocks.ender_chest) || (aBlock == Blocks.trapped_chest)) { + if ((aTargetSide > 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if (aBlock == Blocks.hopper) { + if ((aTargetSide != 1) && ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, aTargetSide, 3); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + } + if ((Arrays.asList(aBlock.getValidRotations(aWorld, aX, aY, aZ)).contains(ForgeDirection.getOrientation(aTargetSide))) && + ((aPlayer.capabilities.isCreativeMode) || (!GT_ModHandler.isElectricItem(aStack)) || (GT_ModHandler.canUseElectricItem(aStack, this.mCosts))) && + (aBlock.rotateBlock(aWorld, aX, aY, aZ, ForgeDirection.getOrientation(aTargetSide)))) { + if (!aPlayer.capabilities.isCreativeMode) { + ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); + } + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(100)), 1.0F, -1.0F, aX, aY, aZ); + } + return false; + } + + public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { + aList.add(this.mTooltip); + return aList; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java new file mode 100644 index 0000000000..6967c8eb33 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -0,0 +1,197 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.metatileentity.BaseMetaTileEntity; +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.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import ic2.api.Direction; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class BaseCustomTileEntity extends BaseMetaTileEntity { + + protected NBTTagCompound mRecipeStuff2; + private static final Field ENTITY_ITEM_HEALTH_FIELD_2; + + static { + Field f = null; + try { + f = EntityItem.class.getDeclaredField("field_70291_e"); + f.setAccessible(true); + } catch (Exception var4) { + try { + f = EntityItem.class.getDeclaredField("health"); + f.setAccessible(true); + } catch (Exception var3) { + var4.printStackTrace(); + var3.printStackTrace(); + } + } + + ENTITY_ITEM_HEALTH_FIELD_2 = f; + } + + public BaseCustomTileEntity() { + super(); + Logger.MACHINE_INFO("Created new BaseCustomTileEntity"); + } + + public void writeToNBT(NBTTagCompound aNBT) { + try { + super.writeToNBT(aNBT); + } catch (Throwable arg7) { + GT_Log.err.println( + "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould\'ve been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + arg7.printStackTrace(GT_Log.err); + } + + try { + if (!aNBT.hasKey("ModVersion")) + aNBT.setString("ModVersion", CORE.VERSION); + } catch (Throwable arg6) { + GT_Log.err.println( + "Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould\'ve been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + arg6.printStackTrace(GT_Log.err); + } + } + + public void doEnergyExplosion() { + if (this.getUniversalEnergyCapacity() > 0L + && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5L) { + this.doExplosion( + this.getOutput() * (long) (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() ? 4 + : (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 2L ? 2 : 1))); + GT_Mod arg9999 = GT_Mod.instance; + GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.getOwnerName()), + "electricproblems"); + } + + } + + public void doExplosion(long aAmount) { + if (this.canAccessData()) { + if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) { + try { + this.mReleaseEnergy = true; + Util.emitEnergyToNetwork(GT_Values.V[5], Math.max(1L, this.getStoredEU() / GT_Values.V[5]), this); + } catch (Exception arg4) { + ; + } + } + + this.mReleaseEnergy = false; + this.mMetaTileEntity.onExplosion(); + int i; + + boolean aExplosionDropItem = false; + Object aProxyField = StaticFields59.getFieldFromGregtechProxy(false, "mExplosionItemDrop"); + if (boolean.class.isInstance(aProxyField) || Boolean.class.isInstance(aProxyField)) { + aExplosionDropItem = (boolean) aProxyField; + } + + if (aExplosionDropItem) { + for (i = 0; i < this.getSizeInventory(); ++i) { + ItemStack tItem = this.getStackInSlot(i); + if (tItem != null && tItem.stackSize > 0 && this.isValidSlot(i)) { + this.dropItems(tItem); + this.setInventorySlotContents(i, (ItemStack) null); + } + } + } + + if (this.mRecipeStuff2 != null) { + for (i = 0; i < 9; ++i) { + this.dropItems(GT_Utility.loadItem(this.mRecipeStuff2, "Ingredient." + i)); + } + } + + PollutionUtils.addPollution(this, 100000); + this.mMetaTileEntity.doExplosion(aAmount); + } + + } + + + public void dropItems(ItemStack tItem) { + if (tItem != null) { + Random tRandom = new Random(); + EntityItem tItemEntity = new EntityItem(this.worldObj, + (double) ((float) this.xCoord + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) this.yCoord + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) this.zCoord + tRandom.nextFloat() * 0.8F + 0.1F), + new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); + if (tItem.hasTagCompound()) { + tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); + } + + tItemEntity.motionX = tRandom.nextGaussian() * 0.0500000007450581D; + tItemEntity.motionY = tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D; + tItemEntity.motionZ = tRandom.nextGaussian() * 0.0500000007450581D; + tItemEntity.hurtResistantTime = 999999; + tItemEntity.lifespan = 60000; + + try { + if (ENTITY_ITEM_HEALTH_FIELD_2 != null) { + ENTITY_ITEM_HEALTH_FIELD_2.setInt(tItemEntity, 99999999); + } + } catch (Exception var5) { + ; + } + + this.worldObj.spawnEntityInWorld(tItemEntity); + tItem.stackSize = 0; + } + } + + public ArrayList<ItemStack> getDrops() { + ArrayList<ItemStack> aDrops = new ArrayList<ItemStack>(); + ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, this.getMetaTileID()); + // Currently not using my custom block. + // ItemStack rStack = new ItemStack(Meta_GT_Proxy.sBlockMachines, 1, + // this.getMetaTileID()); + boolean fail = true; + + ArrayList<ItemStack> aSuperDrops = super.getDrops(); + if (aSuperDrops != null && !aSuperDrops.isEmpty()) { + ItemStack aSuperStack = super.getDrops().get(0); + if (aSuperStack != null && aSuperStack.hasTagCompound()) { + NBTTagCompound aSuperNBT = aSuperStack.getTagCompound(); + if (aSuperNBT != null && !aSuperNBT.hasNoTags()) { + NBTTagCompound tNBT = (NBTTagCompound) aSuperNBT.copy(); + if (tNBT != null && !tNBT.hasNoTags()) { + if (this.hasValidMetaTileEntity()) { + this.mMetaTileEntity.setItemNBT(tNBT); + rStack.setTagCompound(tNBT); + fail = false; + aDrops.add(rStack); + } + } + } + + } + } + if (fail) { + aDrops.add(rStack); + } + return aDrops; + } + + public boolean isTeleporterCompatible(Direction aSide) { + return this.canAccessData() && this.mMetaTileEntity.isTeleporterCompatible(); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java new file mode 100644 index 0000000000..a4440114e8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java @@ -0,0 +1,280 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; +import ic2.api.Direction; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class BaseCustomPower_MTE extends BaseCustomTileEntity { + + public BaseCustomPower_MTE() { + super(); + Logger.MACHINE_INFO("Created new BaseCustomPower_MTE"); + } + + public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + if (mMetaTileEntity == null) { + Logger.MACHINE_INFO("Bad Tile"); + } + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.inputEnergyFrom(aSide) && aAmperage > 0L + && aVoltage > 0L && this.getStoredEU() < this.getEUCapacity() + && this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage()) { + Logger.MACHINE_INFO("Injecting Energy Units"); + return super.injectEnergyUnits(aSide, aVoltage, aAmperage); + } else { + Logger.MACHINE_INFO("canAccessData(): "+canAccessData()); + Logger.MACHINE_INFO("isElectric(): "+this.mMetaTileEntity.isElectric()); + Logger.MACHINE_INFO("InputEnergyFromSide("+aSide+"): "+this.inputEnergyFrom(aSide)); + Logger.MACHINE_INFO("aAmperage: "+aAmperage); + Logger.MACHINE_INFO("aVoltage: "+aVoltage); + Logger.MACHINE_INFO("this.getStoredEU() < this.getEUCapacity(): "+(this.getStoredEU() < this.getEUCapacity())); + Logger.MACHINE_INFO("this.mMetaTileEntity.maxAmperesIn() >= this.mAcceptedAmperes: "+(this.mMetaTileEntity.maxAmperesIn() >= this.getInputAmperage())); + Logger.MACHINE_INFO("this.mMetaTileEntity.maxAmperesIn(): "+(this.mMetaTileEntity.maxAmperesIn())); + Logger.MACHINE_INFO("this.mAcceptedAmperes: "+(this.getInputAmperage())); + return 0L; + } + } + + public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { + Logger.MACHINE_INFO("Draining Energy Units 4"); + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.outputsEnergyTo(aSide) + && this.getStoredEU() - aVoltage * aAmperage >= this.mMetaTileEntity.getMinimumStoredEU()) { + if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { + this.mAverageEUOutput[this.mAverageEUOutputIndex] = (int) ((long) this.mAverageEUOutput[this.mAverageEUOutputIndex] + + aVoltage * aAmperage); + return true; + } else { + return false; + } + } else { + return false; + } + } + + @Override + public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { + Logger.MACHINE_INFO("Draining Energy Units 3"); + // TODO Auto-generated method stub + return super.decreaseStoredEnergyUnits(aEnergy, aIgnoreTooLessEnergy); + } + + @Override + public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) { + // TODO Auto-generated method stub + return super.increaseStoredEnergyUnits(aEnergy, aIgnoreTooMuchEnergy); + } + + @Override + public boolean inputEnergyFrom(byte aSide) { + // TODO Auto-generated method stub + return super.inputEnergyFrom(aSide); + } + + @Override + public boolean outputsEnergyTo(byte aSide) { + Logger.MACHINE_INFO("Draining Energy Units 2"); + // TODO Auto-generated method stub + return super.outputsEnergyTo(aSide); + } + + @Override + public long getOutputAmperage() { + // TODO Auto-generated method stub + return super.getOutputAmperage(); + } + + @Override + public long getOutputVoltage() { + // TODO Auto-generated method stub + return super.getOutputVoltage(); + } + + @Override + public long getInputAmperage() { + // TODO Auto-generated method stub + return super.getInputAmperage(); + } + + @Override + public long getInputVoltage() { + // TODO Auto-generated method stub + return super.getInputVoltage(); + } + + @Override + public long getUniversalEnergyStored() { + // TODO Auto-generated method stub + return super.getUniversalEnergyStored(); + } + + @Override + public long getUniversalEnergyCapacity() { + // TODO Auto-generated method stub + return super.getUniversalEnergyCapacity(); + } + + @Override + public long getStoredEU() { + // TODO Auto-generated method stub + return super.getStoredEU(); + } + + @Override + public long getEUCapacity() { + // TODO Auto-generated method stub + return super.getEUCapacity(); + } + + @Override + public boolean setStoredEU(long aEnergy) { + // TODO Auto-generated method stub + return super.setStoredEU(aEnergy); + } + + @Override + public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { + Logger.MACHINE_INFO("Draining Energy Units 1"); + // TODO Auto-generated method stub + return super.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy); + } + + @Override + public boolean decreaseStoredSteam(long aEnergy, boolean aIgnoreTooLessEnergy) { + // TODO Auto-generated method stub + return super.decreaseStoredSteam(aEnergy, aIgnoreTooLessEnergy); + } + + @Override + public void doEnergyExplosion() { + // TODO Auto-generated method stub + super.doEnergyExplosion(); + } + + @Override + public void doExplosion(long aAmount) { + // TODO Auto-generated method stub + super.doExplosion(aAmount); + } + + @Override + public byte getLightValue() { + // TODO Auto-generated method stub + return super.getLightValue(); + } + + @Override + public long getAverageElectricInput() { + // TODO Auto-generated method stub + return super.getAverageElectricInput(); + } + + @Override + public long getAverageElectricOutput() { + // TODO Auto-generated method stub + return super.getAverageElectricOutput(); + } + + @Override + public double getOutputEnergyUnitsPerTick() { + // TODO Auto-generated method stub + return super.getOutputEnergyUnitsPerTick(); + } + + @Override + public double demandedEnergyUnits() { + // TODO Auto-generated method stub + return super.demandedEnergyUnits(); + } + + @Override + public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) { + // TODO Auto-generated method stub + return super.injectEnergyUnits(aDirection, aAmount); + } + + @Override + public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) { + // TODO Auto-generated method stub + return super.acceptsEnergyFrom(aEmitter, aDirection); + } + + @Override + public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) { + // TODO Auto-generated method stub + return super.emitsEnergyTo(aReceiver, aDirection); + } + + @Override + public double getOfferedEnergy() { + // TODO Auto-generated method stub + return super.getOfferedEnergy(); + } + + @Override + public void drawEnergy(double amount) { + // TODO Auto-generated method stub + super.drawEnergy(amount); + } + + @Override + public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) { + // TODO Auto-generated method stub + return super.injectEnergy(aForgeDirection, aAmount); + } + + @Override + public int addEnergy(int aEnergy) { + // TODO Auto-generated method stub + return super.addEnergy(aEnergy); + } + + @Override + public boolean isAddedToEnergyNet() { + // TODO Auto-generated method stub + return super.isAddedToEnergyNet(); + } + + @Override + public int demandsEnergy() { + // TODO Auto-generated method stub + return super.demandsEnergy(); + } + + @Override + public int getMaxSafeInput() { + // TODO Auto-generated method stub + return super.getMaxSafeInput(); + } + + @Override + public int getMaxEnergyOutput() { + // TODO Auto-generated method stub + return super.getMaxEnergyOutput(); + } + + @Override + public int injectEnergy(Direction aDirection, int aAmount) { + // TODO Auto-generated method stub + return super.injectEnergy(aDirection, aAmount); + } + + @Override + public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) { + // TODO Auto-generated method stub + return super.acceptsEnergyFrom(aReceiver, aDirection); + } + + @Override + public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) { + // TODO Auto-generated method stub + return super.emitsEnergyTo(aReceiver, aDirection); + } + + @Override + public boolean isUniversalEnergyStored(long aEnergyAmount) { + // TODO Auto-generated method stub + return super.isUniversalEnergyStored(aEnergyAmount); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java new file mode 100644 index 0000000000..e1b329c07f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java @@ -0,0 +1,313 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import java.util.Collection; +import java.util.Iterator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank { + public GTPP_MTE_BasicLosslessGenerator(int aID, String aName, String aNameRegional, int aTier, String aDescription, + ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + } + + public GTPP_MTE_BasicLosslessGenerator(int aID, String aName, String aNameRegional, int aTier, + String[] aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + } + + public GTPP_MTE_BasicLosslessGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + public GTPP_MTE_BasicLosslessGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[10][17][]; + + for (byte i = -1; i < 16; ++i) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + + return rTextures; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing + ? 0 + : (aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : (aSide == 0 ? 2 : (aSide == 1 ? 3 : 4))))][aColorIndex + 1]; + } + + public String[] getDescription() { + String[] desc = new String[this.mDescriptionArray.length + 1]; + System.arraycopy(this.mDescriptionArray, 0, desc, 0, this.mDescriptionArray.length); + desc[this.mDescriptionArray.length] = "Fuel Efficiency: " + this.getEfficiency() + "%"; + return desc; + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + Logger.WARNING("Right Clicked"); + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + + public ITexture[] getFront(byte aColor) { + return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBack(byte aColor) { + return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getTop(byte aColor) { + return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getSides(byte aColor) { + return new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(byte aColor) { + return this.getSides(aColor); + } + + public boolean isFacingValid(byte aSide) { + return aSide > 1; + } + + public boolean isSimpleMachine() { + return false; + } + + public boolean isValidSlot(int aIndex) { + return aIndex < 2; + } + + public boolean isEnetOutput() { + return true; + } + + public boolean isOutputFacing(byte aSide) { + return true; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public long maxEUOutput() { + return this.getBaseMetaTileEntity().isAllowedToWork() ? GT_Values.V[this.mTier] : 0L; + } + + public long maxEUStore() { + return Math.max(this.getEUVar(), GT_Values.V[this.mTier] * 40L + this.getMinimumStoredEU()); + } + + public boolean doesFillContainers() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + public boolean doesEmptyContainers() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + public boolean canTankBeFilled() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + public boolean canTankBeEmptied() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + public boolean displaysItemStack() { + return true; + } + + public boolean displaysStackSize() { + return false; + } + + public boolean isFluidInputAllowed(FluidStack aFluid) { + int aVal = this.getFuelValue(aFluid); + Logger.WARNING("Fuel Value: "+aVal); + return aVal > 0; + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { + int tFuelValue; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + tFuelValue = this.getFuelValue(this.mFluid); + int tConsumed = this.consumedFluidPerOperation(this.mFluid); + if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { + long tFluidAmountToUse = Math.min((long) (this.mFluid.amount / tConsumed), + (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); + if (tFluidAmountToUse > 0L && aBaseMetaTileEntity + .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + this.mFluid.amount = (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); + } + } + } + + if (this.mInventory[this.getInputSlot()] != null + && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + + this.getMinimumStoredEU() + && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { + tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + Logger.WARNING("Ticking Servside"); + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity + .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); + } + + } + + public abstract int getPollution(); + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid != null && this.getRecipes() != null) { + Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; + if (tRecipeList != null) { + Logger.WARNING("Fuels: "+tRecipeList.size()); + Iterator<GT_Recipe> var4 = tRecipeList.iterator(); + + while (var4.hasNext()) { + GT_Recipe tFuel = (GT_Recipe) var4.next(); + FluidStack tLiquid; + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null + && aLiquid.isFluidEqual(tLiquid)) { + Logger.WARNING("Fuel Ok"); + return (int) ((long) tFuel.mSpecialValue * (long) this.getEfficiency() + * (long) this.consumedFluidPerOperation(tLiquid) / 100L); + } + if ((tLiquid = tFuel.getRepresentativeFluidInput(0)) != null + && aLiquid.isFluidEqual(tLiquid)) { + Logger.WARNING("Fuel Ok"); + return (int) ((long) tFuel.mSpecialValue * (long) this.getEfficiency() + * (long) this.consumedFluidPerOperation(tLiquid) / 100L); + } + } + } + + return 0; + } else { + return 0; + } + } + + public int getFuelValue(ItemStack aStack) { + if (!GT_Utility.isStackInvalid(aStack) && this.getRecipes() != null) { + Logger.WARNING("Fuel Item OK"); + GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, + (FluidStack[]) null, new ItemStack[]{aStack}); + return tFuel != null ? (int) ((long) tFuel.mSpecialValue * 1000L * (long) this.getEfficiency() / 100L) : 0; + } else { + return 0; + } + } + + public ItemStack getEmptyContainer(ItemStack aStack) { + if (!GT_Utility.isStackInvalid(aStack) && this.getRecipes() != null) { + GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, + (FluidStack[]) null, new ItemStack[]{aStack}); + return tFuel != null + ? GT_Utility.copy(new Object[]{tFuel.getOutput(0)}) + : GT_Utility.getContainerItem(aStack, true); + } else { + return null; + } + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (this.getFuelValue(aStack) > 0 + || this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); + } + + public int getCapacity() { + return 16000; + } + + public int getTankPressure() { + return -100; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java new file mode 100644 index 0000000000..2eb1d36791 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java @@ -0,0 +1,860 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_BasicMachine; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.random.XSTR; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +import java.util.Arrays; + +import static gregtech.api.enums.GT_Values.V; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * This is the main construct for my Basic Machines such as the Automatic Extractor + * Extend this class to make a simple Machine + */ +public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { + /** + * return values for checkRecipe() + */ + protected static final int + DID_NOT_FIND_RECIPE = 0, + FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, + FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; + public static final int OTHER_SLOT_COUNT = 4; + public final ItemStack[] mOutputItems; + public final int mInputSlotCount, mAmperage; + public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; + public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; + public FluidStack mOutputFluid; + public String mGUIName = "", mNEIName = ""; + public GT_MetaTileEntity_MultiBlockBase mCleanroom; + /** + * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered + */ + protected GT_Recipe mLastRecipe = null; + private FluidStack mFluidOut; + + /** + * @param aOverlays 0 = SideFacingActive + * 1 = SideFacingInactive + * 2 = FrontFacingActive + * 3 = FrontFacingInactive + * 4 = TopFacingActive + * 5 = TopFacingInactive + * 6 = BottomFacingActive + * 7 = BottomFacingInactive + * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays ----- + * 8 = BottomFacingPipeActive + * 9 = BottomFacingPipeInactive + * 10 = TopFacingPipeActive + * 11 = TopFacingPipeInactive + * 12 = SideFacingPipeActive + * 13 = SideFacingPipeInactive + */ + public GTPP_MTE_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { + super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public GTPP_MTE_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String[] aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { + super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public GTPP_MTE_BasicMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public GTPP_MTE_BasicMachine(String aName, int aTier, int aAmperage, String[] aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + protected boolean isValidMainFacing(byte aSide) { + return aSide > 1; + } + + public boolean setMainFacing(byte aSide){ + if (!isValidMainFacing(aSide)) return false; + mMainFacing = aSide; + if(getBaseMetaTileEntity().getFrontFacing() == mMainFacing){ + getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aSide)); + } + onFacingChange(); + onMachineBlockUpdate(); + return true; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + aTextures = Arrays.copyOf(aTextures, 14); + + for (int i = 0; i < aTextures.length; i++) + if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { + if (rTextures[i][c + 1] == null) + rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; + } + + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return mMainFacing > 1 || aFacing > 1; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public boolean isLiquidOutput(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 16; + } + + @Override + public long maxEUStore() { + return V[mTier] * 64; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxSteamStore() { + return maxEUStore(); + } + + @Override + public long maxAmperesIn() { + return (mEUt * 2) / V[mTier] + 1; + } + + @Override + public int getInputSlot() { + return OTHER_SLOT_COUNT; + } + + @Override + public int getOutputSlot() { + return OTHER_SLOT_COUNT + mInputSlotCount; + } + + @Override + public int getStackDisplaySlot() { + return 2; + } + + @Override + public int rechargerSlotStartIndex() { + return 1; + } + + @Override + public int dechargerSlotStartIndex() { + return 1; + } + + @Override + public int rechargerSlotCount() { + return mCharge ? 1 : 0; + } + + @Override + public int dechargerSlotCount() { + return mDecharge ? 1 : 0; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + mProgresstime += aProgress; + return mMaxProgresstime - mProgresstime; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); + } + + @Override + public boolean isFluidChangingAllowed() { + return true; + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return true; + } + + @Override + public FluidStack getDisplayedFluid() { + return displaysOutputFluid() ? getDrainableStack() : null; + } + + @Override + public FluidStack getDrainableStack() { + return mFluidOut; + } + + @Override + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluidOut = aFluid; + return mFluidOut; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); + } + + @Override + public void initDefaultModes(NBTTagCompound aNBT) { + mMainFacing = -1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mFluidTransfer", mFluidTransfer); + aNBT.setBoolean("mItemTransfer", mItemTransfer); + aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); + aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mMainFacing", mMainFacing); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); + if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound())); + + for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) + aNBT.setTag("mOutputItem" + i, mOutputItems[i].writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluidTransfer = aNBT.getBoolean("mFluidTransfer"); + mItemTransfer = aNBT.getBoolean("mItemTransfer"); + mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); + mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); + mEUt = aNBT.getInteger("mEUt"); + mMainFacing = aNBT.getInteger("mMainFacing"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); + mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut")); + + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide()) { + mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; + mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; + + doDisplayThings(); + + boolean tSucceeded = false; + + if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { + aBaseMetaTileEntity.setActive(true); + if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) { + if (++mProgresstime >= mMaxProgresstime) { + for (int i = 0; i < mOutputItems.length; i++) + for (int j = 0; j < mOutputItems.length; j++) + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) + break; + if (mOutputFluid != null) + if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); + else if (mOutputFluid.isFluidEqual(getDrainableStack())) + getDrainableStack().amount += mOutputFluid.amount; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + mEUt = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mStuttering = false; + tSucceeded = true; + endProcess(); + } + if (mProgresstime > 5) mStuttering = false; + XSTR aXSTR = new XSTR(); + //Dumb April Fools Shit + // if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + } else { + if (!mStuttering) { + stutterProcess(); + if (canHaveInsufficientEnergy()) mProgresstime = -100; + mStuttering = true; + } + } + } else { + aBaseMetaTileEntity.setActive(false); + } + + boolean tRemovedOutputFluid = false; + + if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); + if (tTank != null) { + FluidStack tDrained = drain(1000, false); + if (tDrained != null) { + int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + if (tFilledAmount > 0) + tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); + } + } + if (getDrainableStack() == null) tRemovedOutputFluid = true; + } + + if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { + TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); + for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { + tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); + } + } + + if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; + else mOutputBlocked++; + + if (allowToCheckRecipe()) { + if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { + if (checkRecipe() == 2) { + if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + for (int i = 0; i < mOutputItems.length; i++) { + mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); + if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) + mOutputItems[i].stackSize = 64; + mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); + } + if (mFluid != null && mFluid.amount <= 0) mFluid = null; + mMaxProgresstime = Math.max(1, mMaxProgresstime); + if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) { + mEUt = mMaxProgresstime = 1; + } + startProcess(); + } else { + mMaxProgresstime = 0; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + } + } + } else { + if (!mStuttering) { + stutterProcess(); + mStuttering = true; + } + } + } + } + + protected void doDisplayThings() { + if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { + mMainFacing = getBaseMetaTileEntity().getFrontFacing(); + } + if (mMainFacing >= 2 && !mHasBeenUpdated) { + mHasBeenUpdated = true; + getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); + } + + if (displaysInputFluid()) { + int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + if (getFillableStack() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) + mInventory[tDisplayStackSlot] = null; + } else { + mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); + } + } + } + + protected boolean hasEnoughEnergyToCheckRecipe() { + return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2); + } + + protected boolean drainEnergyForProcess(long aEUt) { + return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false); + } + + protected void calculateOverclockedNess(GT_Recipe aRecipe) { + calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration); + } + + protected void calculateOverclockedNess(int aEUt, int aDuration) { + if (aEUt <= 16) { + mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); + mMaxProgresstime = aDuration / (1 << (mTier - 1)); + } else { + mEUt = aEUt; + mMaxProgresstime = aDuration; + while (mEUt <= V[mTier - 1] * mAmperage) { + mEUt *= 4; + mMaxProgresstime /= 2; + } + } + } + + protected ItemStack getSpecialSlot() { + return mInventory[3]; + } + + protected ItemStack getOutputAt(int aIndex) { + return mInventory[getOutputSlot() + aIndex]; + } + + protected ItemStack[] getAllOutputs() { + ItemStack[] rOutputs = new ItemStack[mOutputItems.length]; + for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i); + return rOutputs; + } + + protected boolean canOutput(GT_Recipe aRecipe) { + return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); + } + + protected boolean canOutput(ItemStack... aOutputs) { + if (aOutputs == null) return true; + ItemStack[] tOutputSlots = getAllOutputs(); + for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) + if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { + mOutputBlocked++; + return false; + } + return true; + } + + protected boolean canOutput(FluidStack aOutput) { + return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); + } + + protected ItemStack getInputAt(int aIndex) { + return mInventory[getInputSlot() + aIndex]; + } + + protected ItemStack[] getAllInputs() { + ItemStack[] rInputs = new ItemStack[mInputSlotCount]; + for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); + return rInputs; + } + + protected boolean isOutputEmpty() { + boolean rIsEmpty = true; + for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; + return rIsEmpty; + } + + protected boolean displaysInputFluid() { + return true; + } + + protected boolean displaysOutputFluid() { + return true; + } + + @Override + public void onValueUpdate(byte aValue) { + mMainFacing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) mMainFacing; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + super.doSound(aIndex, aX, aY, aZ); + if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); + } + + public boolean doesAutoOutput() { + return mItemTransfer; + } + + public boolean doesAutoOutputFluids() { + return mFluidTransfer; + } + + public boolean allowToCheckRecipe() { + return true; + } + + public boolean showPipeFacing() { + return true; + } + + /** + * Called whenever the Machine successfully started a Process, useful for Sound Effects + */ + public void startProcess() { + // + } + + /** + * Called whenever the Machine successfully finished a Process, useful for Sound Effects + */ + public void endProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process, useful for Sound Effects + */ + public void abortProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects + */ + public void stutterProcess() { + if (useStandardStutterSound()) sendSound((byte) 8); + } + + /** + * If this Machine can have the Insufficient Energy Line Problem + */ + public boolean canHaveInsufficientEnergy() { + return true; + } + + public boolean useStandardStutterSound() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{ + mNEIName, + "Progress:", (mProgresstime / 20) + " secs", + (mMaxProgresstime / 20) + " secs", + "Stored Energy:", + getBaseMetaTileEntity().getStoredEU() + "EU", + getBaseMetaTileEntity().getEUCapacity() + "EU"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { + mAllowInputFromOutputSide = !mAllowInputFromOutputSide; + GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? "Input from Output Side allowed" : "Input from Output Side forbidden"); + } + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) + return false; + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; + return true; + } + + /** + * @return the Recipe List which is used for this Machine, this is a useful Default Handler + */ + public GT_Recipe_Map getRecipeList() { + return null; + } + + /** + * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case + * <p/> + * I thought about Enum too, but Enum doesn't add support for people adding other return Systems. + * <p/> + * Funny how Eclipse marks the word Enum as not correctly spelled. + * + * @return see constants above + */ + public int checkRecipe() { + return checkRecipe(false); + } + + public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId){ + return //TODO check or get a better solution + DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") || + DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); + } + + + /** + * + * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method... + * @return + */ + public int checkRecipe(boolean skipOC){ + GT_Recipe_Map tMap = getRecipeList(); + if (tMap == null) return DID_NOT_FIND_RECIPE; + GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); + if (tRecipe == null) return DID_NOT_FIND_RECIPE; + + if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; + if (!canOutput(tRecipe)) { + mOutputBlocked++; + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + if (tRecipe.mSpecialValue == -200 && (mCleanroom == null || mCleanroom.mEfficiency == 0)) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < mOutputItems.length; i++) + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) + mOutputItems[i] = tRecipe.getOutput(i); + if (tRecipe.mSpecialValue == -200) + for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > mCleanroom.mEfficiency) + mOutputItems[i] = null; + mOutputFluid = tRecipe.getFluidOutput(0); + calculateOverclockedNess(tRecipe); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java new file mode 100644 index 0000000000..9c6840e33c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicTank.java @@ -0,0 +1,266 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power; + +import gregtech.api.enums.ItemList; +import gregtech.api.gui.GT_Container_BasicTank; +import gregtech.api.gui.GT_GUIContainer_BasicTank; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.api.gui.power.CONTAINER_BasicTank; +import gtPlusPlus.xmod.gregtech.api.gui.power.GUI_BasicTank; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually + */ +public abstract class GTPP_MTE_BasicTank extends GTPP_MTE_TieredMachineBlock { + + public FluidStack mFluid; + + /** + * @param aInvSlotCount should be 3 + */ + public GTPP_MTE_BasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GTPP_MTE_BasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GTPP_MTE_BasicTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GTPP_MTE_BasicTank(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex != getStackDisplaySlot(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + } + + public abstract boolean doesFillContainers(); + + public abstract boolean doesEmptyContainers(); + + public abstract boolean canTankBeFilled(); + + public abstract boolean canTankBeEmptied(); + + public abstract boolean displaysItemStack(); + + public abstract boolean displaysStackSize(); + + public int getInputSlot() { + return 0; + } + + public int getOutputSlot() { + return 1; + } + + public int getStackDisplaySlot() { + return 2; + } + + public boolean isFluidInputAllowed(FluidStack aFluid) { + return true; + } + + public boolean isFluidChangingAllowed() { + return true; + } + + public FluidStack getFillableStack() { + return mFluid; + } + + public FluidStack setFillableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; + } + + public FluidStack getDrainableStack() { + return mFluid; + } + + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; + } + + public FluidStack getDisplayedFluid() { + return getDrainableStack(); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_BasicTank(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) + setFillableStack(null); + + if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { + if (getDisplayedFluid() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) + mInventory[getStackDisplaySlot()] = null; + } else { + mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); + } + } + + if (doesEmptyContainers()) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); + if (tFluid != null && isFluidInputAllowed(tFluid)) { + if (getFillableStack() == null) { + if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + setFillableStack(tFluid.copy()); + this.onEmptyingContainerWhenEmpty(); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + getFillableStack().amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + } + + if (doesFillContainers()) { + ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); + if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + if (tFluid != null) getDrainableStack().amount -= tFluid.amount; + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null); + } + } + } + } + + @Override + public FluidStack getFluid() { + return getDrainableStack(); + } + + @Override + public int getFluidAmount() { + return getDrainableStack() != null ? getDrainableStack().amount : 0; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) + return 0; + + if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { + if (aFluid.amount <= getCapacity()) { + if (doFill) { + setFillableStack(aFluid.copy()); + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + setFillableStack(aFluid.copy()); + getFillableStack().amount = getCapacity(); + getBaseMetaTileEntity().markDirty(); + } + return getCapacity(); + } + + if (!getFillableStack().isFluidEqual(aFluid)) + return 0; + + int space = getCapacity() - getFillableStack().amount; + if (aFluid.amount <= space) { + if (doFill) { + getFillableStack().amount += aFluid.amount; + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) + getFillableStack().amount = getCapacity(); + return space; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + if (getDrainableStack() == null || !canTankBeEmptied()) return null; + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { + setDrainableStack(null); + getBaseMetaTileEntity().markDirty(); + return null; + } + + int used = maxDrain; + if (getDrainableStack().amount < used) + used = getDrainableStack().amount; + + if (doDrain) { + getDrainableStack().amount -= used; + getBaseMetaTileEntity().markDirty(); + } + + FluidStack drained = getDrainableStack().copy(); + drained.amount = used; + + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { + setDrainableStack(null); + getBaseMetaTileEntity().markDirty(); + } + + return drained; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getOutputSlot(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getInputSlot(); + } + + protected void onEmptyingContainerWhenEmpty(){ + //Do nothing + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java new file mode 100644 index 0000000000..785c4698db --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_TieredMachineBlock.java @@ -0,0 +1,100 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power; + +import static gregtech.api.enums.GT_Values.GT; + +import gregtech.api.interfaces.ITexture; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; + +public abstract class GTPP_MTE_TieredMachineBlock extends MetaTileEntityCustomPower { + /** + * Value between [0 - 9] to describe the Tier of this Machine. + */ + public final byte mTier; + + @Deprecated + public final String mDescription; + + /** + * A simple Description. + */ + public final String[] mDescriptionArray; + + /** + * Contains all Textures used by this Block. + */ + public final ITexture[][][] mTextures; + + public GTPP_MTE_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aInvSlotCount); + mTier = (byte) Math.max(0, Math.min(aTier, 9)); + mDescriptionArray = aDescription == null ? new String[0] : new String[]{aDescription}; + mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; + // must always be the last call! + if (GT.isClientSide()) mTextures = getTextureSet(aTextures); + else mTextures = null; + } + + public GTPP_MTE_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aInvSlotCount); + mTier = (byte) Math.max(0, Math.min(aTier, 9)); + mDescriptionArray = aDescription == null ? new String[0] : aDescription; + mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; + + // must always be the last call! + if (GT.isClientSide()) mTextures = getTextureSet(aTextures); + else mTextures = null; + } + + public GTPP_MTE_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aInvSlotCount); + mTier = (byte) aTier; + mDescriptionArray = aDescription == null ? new String[0] : new String[]{aDescription}; + mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; + mTextures = aTextures; + } + + public GTPP_MTE_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aInvSlotCount); + mTier = (byte) aTier; + mDescriptionArray = aDescription == null ? new String[0] : aDescription; + mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; + mTextures = aTextures; + } + + @Override + public byte getTileEntityBaseType() { + return 12; + } + + @Override + public long getInputTier() { + return mTier; + } + + @Override + public long getOutputTier() { + return mTier; + } + + @Override + public String[] getDescription() { + + AutoMap<String> aTooltip = new AutoMap<String>(); + String []s1 = null; + s1 = new String[aTooltip.size()]; + int u = 0; + for (String s : aTooltip) { + s1[u] = s; + } + return s1; + } + + /** + * Used Client Side to get a Texture Set for this Block. + * Called after setting the Tier and the Description so that those two are accessible. + * + * @param aTextures is the optional Array you can give to the Constructor. + */ + public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java new file mode 100644 index 0000000000..8b7ccc202a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java @@ -0,0 +1,91 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.CustomMetaTileBase; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public abstract class MetaTileEntityCustomPower extends CustomMetaTileBase { + + public MetaTileEntityCustomPower(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { + super(aID, aBasicName, aRegionalName, aInvSlotCount); + this.setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower()); + } + + public MetaTileEntityCustomPower(String aStack, int aInvSlotCount) { + super(aStack, aInvSlotCount); + } + + public long getMinimumStoredEU() { + return 0L; + } + + public void doExplosion(long aExplosionPower) { + + if (MathUtils.randInt(1, 10) > 0) { + //Logger.INFO("Machine tried to explode, let's stop that. xo"); + return; + } + + float tStrength = aExplosionPower < GT_Values.V[0] + ? 1.0F + : (aExplosionPower < GT_Values.V[1] + ? 2.0F + : (aExplosionPower < GT_Values.V[2] + ? 3.0F + : (aExplosionPower < GT_Values.V[3] + ? 4.0F + : (aExplosionPower < GT_Values.V[4] + ? 5.0F + : (aExplosionPower < GT_Values.V[4] * 2L + ? 6.0F + : (aExplosionPower < GT_Values.V[5] + ? 7.0F + : (aExplosionPower < GT_Values.V[6] + ? 8.0F + : (aExplosionPower < GT_Values.V[7] + ? 9.0F + : 10.0F)))))))); + int tX = this.getBaseMetaTileEntity().getXCoord(); + short tY = this.getBaseMetaTileEntity().getYCoord(); + int tZ = this.getBaseMetaTileEntity().getZCoord(); + World tWorld = this.getBaseMetaTileEntity().getWorld(); + GT_Utility.sendSoundToPlayers(tWorld, (String) GregTech_API.sSoundList.get(Integer.valueOf(209)), 1.0F, -1.0F, + tX, tY, tZ); + tWorld.setBlock(tX, tY, tZ, Blocks.air); + if (GregTech_API.sMachineExplosions) { + tWorld.createExplosion((Entity) null, (double) tX + 0.5D, (double) tY + 0.5D, (double) tZ + 0.5D, tStrength, + true); + } + + } + + @Override + public void onExplosion() { + + if (MathUtils.randInt(1, 10) > 0) { + //Logger.INFO("Machine tried to explode, let's stop that. xo"); + return; + } + // TODO Auto-generated method stub + super.onExplosion(); + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public long getEUVar() { + // TODO Auto-generated method stub + return super.getEUVar(); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java new file mode 100644 index 0000000000..e6bf4b8486 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBreaker.java @@ -0,0 +1,283 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.GT_Container_4by4; +import gregtech.api.gui.GT_GUIContainer_4by4; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.GTPP_MTE_TieredMachineBlock; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_BasicBreaker extends GTPP_MTE_TieredMachineBlock { + + public boolean mCharge = false; + public boolean mDecharge = false; + public int mBatteryCount = 0; + public int mChargeableCount = 0; + private long count = 0L; + private long mStored = 0L; + private long mMax = 0L; + + public GT_MetaTileEntity_BasicBreaker(int aID, String aName, String aNameRegional, int aTier, + String aDescription, int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription, new ITexture[0]); + } + + public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String aDescription, ITexture[][][] aTextures, + int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_BasicBreaker(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures, int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + public String[] getDescription() { + String []s1 = super.getDescription(); + s1 = new String[0]; + return s1; + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[2][17][]; + + for (byte i = -1; i < 16; ++i) { + rTextures[0][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + this.mInventory.length > 4 + ? BlockIcons.OVERLAYS_ENERGY_IN_MULTI[Math.min(12, mTier)] + : BlockIcons.OVERLAYS_ENERGY_IN[Math.min(12, mTier)]}; + + rTextures[1][i + 1] = new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], + this.mInventory.length > 4 + ? BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + : BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + } + + return rTextures; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_BasicBreaker(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, + this.mInventory.length); + } + + public boolean isSimpleMachine() { + return false; + } + + public boolean isElectric() { + return true; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return true; + } + + public boolean isEnetInput() { + return true; + } + + public boolean isEnetOutput() { + return true; + } + + public boolean isInputFacing(byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + public boolean isOutputFacing(byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + public boolean isTeleporterCompatible() { + return false; + } + + public long getMinimumStoredEU() { + return GT_Values.V[this.mTier] * 16L * 16; + } + + public long maxEUStore() { + return GT_Values.V[this.mTier] * 64L * 16; + } + + public long maxEUInput() { + return GT_Values.V[this.mTier] * 16; + } + + public long maxEUOutput() { + return GT_Values.V[this.mTier]; + } + + public long maxAmperesIn() { + return (long) (1); + } + + public long maxAmperesOut() { + return (long) 16; + } + + public int rechargerSlotStartIndex() { + return 0; + } + + public int dechargerSlotStartIndex() { + return 0; + } + + public int rechargerSlotCount() { + return 0; + } + + public int dechargerSlotCount() { + return 0; + } + + public int getProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + public int maxProgresstime() { + return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public void saveNBTData(NBTTagCompound aNBT) { + } + + public void loadNBTData(NBTTagCompound aNBT) { + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + /*this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L; + this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3L; + this.mBatteryCount = 0; + this.mChargeableCount = 0; + ItemStack[] arg3 = this.mInventory; + int arg4 = arg3.length; + + for (int arg5 = 0; arg5 < arg4; ++arg5) { + ItemStack tStack = arg3[arg5]; + if (GT_ModHandler.isElectricItem(tStack, this.mTier)) { + if (GT_ModHandler.isChargerItem(tStack)) { + ++this.mBatteryCount; + } + + ++this.mChargeableCount; + } + }*/ + } + + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + public int getInventoryStackLimit() { + return 1; + } + + public long[] getStoredEnergy() { + boolean scaleOverflow = false; + boolean storedOverflow = false; + long tScale = this.getBaseMetaTileEntity().getEUCapacity(); + long tStored = this.getBaseMetaTileEntity().getStoredEU(); + long tStep = 0L; + if (this.mInventory != null) { + ItemStack[] arg8 = this.mInventory; + int arg9 = arg8.length; + + for (int arg10 = 0; arg10 < arg9; ++arg10) { + ItemStack aStack = arg8[arg10]; + if (GT_ModHandler.isElectricItem(aStack)) { + if (aStack.getItem() instanceof GT_MetaBase_Item) { + Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack); + if (stats != null) { + if (stats[0].longValue() > 4611686018427387903L) { + scaleOverflow = true; + } + + tScale += stats[0].longValue(); + tStep = ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack); + if (tStep > 4611686018427387903L) { + storedOverflow = true; + } + + tStored += tStep; + } + } else if (aStack.getItem() instanceof IElectricItem) { + tStored += (long) ElectricItem.manager.getCharge(aStack); + tScale += (long) ((IElectricItem) aStack.getItem()).getMaxCharge(aStack); + } + } + } + } + + if (scaleOverflow) { + tScale = Long.MAX_VALUE; + } + + if (storedOverflow) { + tStored = Long.MAX_VALUE; + } + + return new long[]{tStored, tScale}; + } + + public String[] getInfoData() { + return new String[]{}; + } + + public boolean isGivingInformation() { + return true; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java new file mode 100644 index 0000000000..18665538d0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java @@ -0,0 +1,38 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; + +public class GT_MetaTileEntity_BasicMachine_GTPP_Recipe extends GT_MetaTileEntity_BasicMachine_GT_Recipe { + + public GT_MetaTileEntity_BasicMachine_GTPP_Recipe(int aID, String aName, String aNameRegional, int aTier, + String aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, + int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, + boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) { + super(aID, aName, aNameRegional, aTier, aDescription, aRecipes, aInputSlots, aOutputSlots, aTankCapacity, + aGUIParameterA, aGUIParameterB, aGUIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect, + aOverlays, aRecipe); + } + + public GT_MetaTileEntity_BasicMachine_GTPP_Recipe(String aName, int aTier, String aDescription, + GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, + int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, + String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { + super(aName, aTier, aDescription, aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, + aGUIParameterB, aTextures, aGUIName, aNEIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect); + } + + public GT_MetaTileEntity_BasicMachine_GTPP_Recipe(String aName, int aTier, String[] aDescription, + GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, + int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, + String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { + super(aName, aTier, aDescription[0], aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, + aGUIParameterB, aTextures, aGUIName, aNEIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect); + } + + + + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Dehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Dehydrator.java new file mode 100644 index 0000000000..aebf188fc0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Dehydrator.java @@ -0,0 +1,163 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; + +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons.CustomIcon; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_GT_Recipe; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.lib.CORE; + +@SuppressWarnings("deprecation") +public class GT_MetaTileEntity_Dehydrator extends GT_MetaTileEntity_BasicMachine_GT_Recipe { + + private static final CustomIcon[] sDehydratorOverlays = new CustomIcon[10]; + static { + sDehydratorOverlays[0] = new CustomIcon("basicmachines/microwave/OVERLAY_FRONT"); + sDehydratorOverlays[2] = new CustomIcon("basicmachines/plasma_arc_furnace/OVERLAY_BOTTOM"); + sDehydratorOverlays[3] = new CustomIcon("basicmachines/fluid_heater/OVERLAY_SIDE"); + sDehydratorOverlays[4] = new CustomIcon("basicmachines/chemical_bath/OVERLAY_FRONT"); + sDehydratorOverlays[5] = new CustomIcon("basicmachines/microwave/OVERLAY_FRONT_ACTIVE"); + sDehydratorOverlays[7] = new CustomIcon("basicmachines/plasma_arc_furnace/OVERLAY_BOTTOM_ACTIVE"); + sDehydratorOverlays[8] = new CustomIcon("basicmachines/fluid_heater/OVERLAY_SIDE_ACTIVE"); + sDehydratorOverlays[9] = new CustomIcon("basicmachines/chemical_bath/OVERLAY_FRONT_ACTIVE"); + //3 8 + } + + private GT_Recipe_Map xRecipes; + private int xTankCapacity; + + public GT_MetaTileEntity_Dehydrator(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aTankCapacity) { + super(aID, aName, aNameRegional, aTier, aDescription, GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes, 2, 9, aTankCapacity, 2, 5, "Dehydrator.png", "UNBOXINATOR", false, false, 0, "", null); + xRecipes = GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes; + xTankCapacity = aTankCapacity; + } + + public GT_MetaTileEntity_Dehydrator(String aName, int aTier, String[] aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aTankCapacity, int aAmperage, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, aDescription, aRecipes, 2, 9, aTankCapacity, aAmperage, 2, 5, aTextures, aGUIName, aNEIName, "", false, false, 0); + + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Dehydrator(this.mName, this.mTier, this.mDescriptionArray, this.xRecipes, this.xTankCapacity, this.mAmperage, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public String[] getDescription() { + String[] S = super.getDescription(); + final String[] desc = new String[S.length + 1]; + System.arraycopy(S, 0, desc, 0, S.length); + desc[S.length] = CORE.GT_Tooltip; + return desc; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[15][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = getSideFacingActive(i); + rTextures[1][i + 1] = getSideFacingInactive(i); + rTextures[2][i + 1] = getFrontFacingActive(i); + rTextures[3][i + 1] = getFrontFacingInactive(i); + rTextures[4][i + 1] = getTopFacingActive(i); + rTextures[5][i + 1] = getTopFacingInactive(i); + rTextures[6][i + 1] = getBottomFacingActive(i); + rTextures[7][i + 1] = getBottomFacingInactive(i); + rTextures[8][i + 1] = getBottomFacingPipeActive(i); + rTextures[9][i + 1] = getBottomFacingPipeInactive(i); + rTextures[10][i + 1] = getTopFacingPipeActive(i); + rTextures[11][i + 1] = getTopFacingPipeInactive(i); + rTextures[12][i + 1] = getSideFacingPipeActive(i); + rTextures[13][i + 1] = getSideFacingPipeInactive(i); + } + return rTextures; + } + + + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return super.getTexture(aBaseMetaTileEntity, aSide, aFacing, aColorIndex, aActive, aRedstone); + //return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + @Override + public ITexture[] getFrontFacingInactive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[0])}; + } + + @Override + public ITexture[] getBottomFacingInactive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[2])}; + } + + @Override + public ITexture[] getTopFacingInactive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[3])}; + } + + @Override + public ITexture[] getSideFacingInactive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[4])}; + } + + @Override + public ITexture[] getFrontFacingActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[5])}; + } + + @Override + public ITexture[] getBottomFacingActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[7])}; + } + + @Override + public ITexture[] getTopFacingActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[8])}; + } + + @Override + public ITexture[] getSideFacingActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(sDehydratorOverlays[9])}; + } + + @Override + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + } + + @Override + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + } + + @Override + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + } + + @Override + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + } + + @Override + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + } + + @Override + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java new file mode 100644 index 0000000000..79238240d2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java @@ -0,0 +1,862 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.V; + +import java.util.Arrays; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_BasicMachine; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.random.XSTR; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * This is the main construct for my Basic Machines such as the Automatic Extractor + * Extend this class to make a simple Machine + */ +public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_DeluxeTank { + /** + * return values for checkRecipe() + */ + protected static final int + DID_NOT_FIND_RECIPE = 0, + FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, + FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; + public static final int OTHER_SLOT_COUNT = 4; + public final ItemStack[] mOutputItems; + public final int mInputSlotCount, mAmperage; + public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; + public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; + public FluidStack mOutputFluid; + public String mGUIName = "", mNEIName = ""; + /** + * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered + */ + protected GT_Recipe mLastRecipe = null; + private FluidStack mFluidOut; + + /** + * @param aOverlays 0 = SideFacingActive + * 1 = SideFacingInactive + * 2 = FrontFacingActive + * 3 = FrontFacingInactive + * 4 = TopFacingActive + * 5 = TopFacingInactive + * 6 = BottomFacingActive + * 7 = BottomFacingInactive + * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays ----- + * 8 = BottomFacingPipeActive + * 9 = BottomFacingPipeInactive + * 10 = TopFacingPipeActive + * 11 = TopFacingPipeInactive + * 12 = SideFacingPipeActive + * 13 = SideFacingPipeInactive + */ + public GT_MetaTileEntity_DeluxeMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { + super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public GT_MetaTileEntity_DeluxeMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public boolean setMainFacing(byte aDirection){ + mMainFacing = aDirection; + if(getBaseMetaTileEntity().getFrontFacing() == mMainFacing){ + getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aDirection)); + } + onFacingChange(); + onMachineBlockUpdate(); + return true; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + aTextures = Arrays.copyOf(aTextures, 14); + + for (int i = 0; i < aTextures.length; i++) + if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { + if (rTextures[i][c + 1] == null) + rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; + } + + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return mMainFacing > 1 || aFacing > 1; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public boolean isLiquidOutput(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 16; + } + + @Override + public long maxEUStore() { + return V[mTier] * 64; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxSteamStore() { + return maxEUStore(); + } + + @Override + public long maxAmperesIn() { + return (mEUt * 2) / V[mTier] + 1; + } + + @Override + public int getInputSlot() { + return OTHER_SLOT_COUNT; + } + + @Override + public int getOutputSlot() { + return OTHER_SLOT_COUNT + mInputSlotCount; + } + + @Override + public int getStackDisplaySlot() { + return 2; + } + + @Override + public int rechargerSlotStartIndex() { + return 1; + } + + @Override + public int dechargerSlotStartIndex() { + return 1; + } + + @Override + public int rechargerSlotCount() { + return mCharge ? 1 : 0; + } + + @Override + public int dechargerSlotCount() { + return mDecharge ? 1 : 0; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + mProgresstime += aProgress; + return mMaxProgresstime - mProgresstime; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); + } + + @Override + public boolean isFluidChangingAllowed() { + return true; + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return true; + } + + @Override + public FluidStack getDisplayedFluid() { + return displaysOutputFluid() ? getDrainableStack() : null; + } + + @Override + public FluidStack getDrainableStack() { + return mFluidOut; + } + + @Override + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluidOut = aFluid; + return mFluidOut; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + if(!false) { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + for(byte i=0;i < 6; i++){ + if(aBaseMetaTileEntity.getAirAtSide(i)){ + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + GT_Utility.sendChatToPlayer(aPlayer,"No free Side!"); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); + } + + @Override + public void initDefaultModes(NBTTagCompound aNBT) { + mMainFacing = -1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mFluidTransfer", mFluidTransfer); + aNBT.setBoolean("mItemTransfer", mItemTransfer); + aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); + aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mMainFacing", mMainFacing); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); + if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound())); + + for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) + aNBT.setTag("mOutputItem" + i, mOutputItems[i].writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluidTransfer = aNBT.getBoolean("mFluidTransfer"); + mItemTransfer = aNBT.getBoolean("mItemTransfer"); + mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); + mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); + mEUt = aNBT.getInteger("mEUt"); + mMainFacing = aNBT.getInteger("mMainFacing"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); + mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut")); + + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide()) { + + //Utils.LOG_WARNING("Ticking Tank."); + mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; + mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; + + doDisplayThings(); + + boolean tSucceeded = false; + + if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { + aBaseMetaTileEntity.setActive(true); + if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) { + if (++mProgresstime >= mMaxProgresstime) { + for (int i = 0; i < mOutputItems.length; i++) + for (int j = 0; j < mOutputItems.length; j++) + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) + break; + if (mOutputFluid != null) + if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); + else if (mOutputFluid.isFluidEqual(getDrainableStack())) + getDrainableStack().amount += mOutputFluid.amount; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + mEUt = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mStuttering = false; + tSucceeded = true; + endProcess(); + } + if (mProgresstime > 5) mStuttering = false; + XSTR aXSTR = new XSTR(); + if(false && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + } else { + if (!mStuttering) { + stutterProcess(); + if (canHaveInsufficientEnergy()) mProgresstime = -100; + mStuttering = true; + } + } + } else { + aBaseMetaTileEntity.setActive(false); + } + + boolean tRemovedOutputFluid = false; + Logger.WARNING("R0"); + + if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); + if (tTank != null) { + FluidStack tDrained = drain(1000, false); + if (tDrained != null) { + int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + if (tFilledAmount > 0) + tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); + } + } + if (getDrainableStack() == null) tRemovedOutputFluid = true; + } + + if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { + TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); + for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { + tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); + } + } + + if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; + else mOutputBlocked++; + Logger.WARNING("R1"); + if (allowToCheckRecipe()) { + Logger.WARNING("R2--------------------------------------------------"); + Logger.WARNING("R2: (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe())"); + Logger.WARNING("R2--------------------------------------------------"); + Logger.WARNING("R2-mMaxProgresstime: "+mMaxProgresstime); + Logger.WARNING("R2-isAllowedToWork(): "+aBaseMetaTileEntity.isAllowedToWork()); + Logger.WARNING("R2--------------------------------------------------"); + Logger.WARNING("R2-tRemovedOutputFluid: "+tRemovedOutputFluid); + Logger.WARNING("R2-tSucceeded: "+tSucceeded); + Logger.WARNING("R2-hasInventoryBeenModified(): "+aBaseMetaTileEntity.hasInventoryBeenModified()); + Logger.WARNING("R2-(aTick % 600 == 0): "+(aTick % 600 == 0)); + Logger.WARNING("R2-hasWorkJustBeenEnabled(): "+aBaseMetaTileEntity.hasWorkJustBeenEnabled()); + Logger.WARNING("R2--------------------------------------------------"); + Logger.WARNING("R2-hasEnoughEnergyToCheckRecipe(): "+hasEnoughEnergyToCheckRecipe()); + Logger.WARNING("R2--------------------------------------------------"); + if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { + Logger.WARNING("R3"); + if (checkRecipe() == 2) { + if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; + Logger.WARNING("R4"); + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + for (int i = 0; i < mOutputItems.length; i++) { + mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); + if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) + mOutputItems[i].stackSize = 64; + mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); + } + if (mFluid != null && mFluid.amount <= 0) mFluid = null; + mMaxProgresstime = Math.max(1, mMaxProgresstime); + if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) { + mEUt = mMaxProgresstime = 1; + } + startProcess(); + } else { + mMaxProgresstime = 0; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + } + } + } else { + if (!mStuttering) { + stutterProcess(); + mStuttering = true; + } + } + } + } + + protected void doDisplayThings() { + if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { + mMainFacing = getBaseMetaTileEntity().getFrontFacing(); + } + if (mMainFacing >= 2 && !mHasBeenUpdated) { + mHasBeenUpdated = true; + //getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); + } + + if (displaysInputFluid()) { + int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + if (getFillableStack() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) + mInventory[tDisplayStackSlot] = null; + } else { + mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); + } + } + } + + protected boolean hasEnoughEnergyToCheckRecipe() { + return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2); + } + + protected boolean drainEnergyForProcess(long aEUt) { + return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false); + } + + protected void calculateOverclockedNess(GT_Recipe aRecipe) { + calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration); + } + + protected void calculateOverclockedNess(int aEUt, int aDuration) { + if (aEUt <= 16) { + mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); + mMaxProgresstime = aDuration / (1 << (mTier - 1)); + } else { + mEUt = aEUt; + mMaxProgresstime = aDuration; + while (mEUt <= V[mTier - 1] * mAmperage) { + mEUt *= 4; + mMaxProgresstime /= 2; + } + } + } + + protected ItemStack getSpecialSlot() { + return mInventory[3]; + } + + protected ItemStack getOutputAt(int aIndex) { + return mInventory[getOutputSlot() + aIndex]; + } + + protected ItemStack[] getAllOutputs() { + ItemStack[] rOutputs = new ItemStack[mOutputItems.length]; + for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i); + return rOutputs; + } + + protected boolean canOutput(GT_Recipe aRecipe) { + return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); + } + + protected boolean canOutput(ItemStack... aOutputs) { + if (aOutputs == null) return true; + ItemStack[] tOutputSlots = getAllOutputs(); + for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) + if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { + mOutputBlocked++; + return false; + } + return true; + } + + protected boolean canOutput(FluidStack aOutput) { + return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); + } + + protected ItemStack getInputAt(int aIndex) { + return mInventory[getInputSlot() + aIndex]; + } + + protected ItemStack[] getAllInputs() { + ItemStack[] rInputs = new ItemStack[mInputSlotCount]; + for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); + return rInputs; + } + + protected boolean isOutputEmpty() { + boolean rIsEmpty = true; + for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; + return rIsEmpty; + } + + protected boolean displaysInputFluid() { + return true; + } + + protected boolean displaysOutputFluid() { + return true; + } + + @Override + public void onValueUpdate(byte aValue) { + mMainFacing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) mMainFacing; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + super.doSound(aIndex, aX, aY, aZ); + if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); + } + + public boolean doesAutoOutput() { + return mItemTransfer; + } + + public boolean doesAutoOutputFluids() { + return mFluidTransfer; + } + + public boolean allowToCheckRecipe() { + return true; + } + + public boolean showPipeFacing() { + return true; + } + + /** + * Called whenever the Machine successfully started a Process, useful for Sound Effects + */ + public void startProcess() { + // + } + + /** + * Called whenever the Machine successfully finished a Process, useful for Sound Effects + */ + public void endProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process, useful for Sound Effects + */ + public void abortProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects + */ + public void stutterProcess() { + if (useStandardStutterSound()) sendSound((byte) 8); + } + + /** + * If this Machine can have the Insufficient Energy Line Problem + */ + public boolean canHaveInsufficientEnergy() { + return true; + } + + public boolean useStandardStutterSound() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{ + mNEIName, + "Progress:", (mProgresstime / 20) + " secs", + (mMaxProgresstime / 20) + " secs", + "Stored Energy:", + getBaseMetaTileEntity().getStoredEU() + "EU", + getBaseMetaTileEntity().getEUCapacity() + "EU"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { + mAllowInputFromOutputSide = !mAllowInputFromOutputSide; + GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? ("Input from Output Side allowed") : ("Input from Output Side forbidden")); + } + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) + return false; + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; + return true; + } + + /** + * @return the Recipe List which is used for this Machine, this is a useful Default Handler + */ + public GT_Recipe_Map getRecipeList() { + return null; + } + + /** + * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case + * <p/> + * I thought about Enum too, but Enum doesn't add support for people adding other return Systems. + * <p/> + * Funny how Eclipse marks the word Enum as not correctly spelled. + * + * @return see constants above + */ + public int checkRecipe() { + return checkRecipe(false); + } + + public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId){ + return //TODO check or get a better solution + DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") || + DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); + } + + + /** + * + * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method... + * @return + */ + public int checkRecipe(boolean skipOC){ + GT_Recipe_Map tMap = getRecipeList(); + if (tMap == null) return DID_NOT_FIND_RECIPE; + GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); + if (tRecipe == null) return DID_NOT_FIND_RECIPE; + + if (false && tRecipe.mSpecialValue == -100 && + !isValidForLowGravity(tRecipe,getBaseMetaTileEntity().getWorld().provider.dimensionId)) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; + if (!canOutput(tRecipe)) { + mOutputBlocked++; + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < mOutputItems.length; i++) + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) + mOutputItems[i] = tRecipe.getOutput(i); + mOutputFluid = tRecipe.getFluidOutput(0); + calculateOverclockedNess(tRecipe); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java new file mode 100644 index 0000000000..1e367d4f15 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java @@ -0,0 +1,345 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.enums.ItemList; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_DeluxeTank; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_DeluxeTank; +import net.minecraftforge.fluids.FluidStack; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually + */ +public abstract class GT_MetaTileEntity_DeluxeTank extends GT_MetaTileEntity_BasicTank { + + public FluidStack mFluid2; + + /** + * @param aInvSlotCount should be 3 + */ + public GT_MetaTileEntity_DeluxeTank(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_DeluxeTank(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex != this.getStackDisplaySlot(); + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + if (this.mFluid != null) { + aNBT.setTag("mFluid", this.mFluid.writeToNBT(new NBTTagCompound())); + } + if (this.mFluid2 != null) { + aNBT.setTag("mFluid2", this.mFluid2.writeToNBT(new NBTTagCompound())); + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + this.mFluid2 = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid2")); + } + + @Override + public abstract boolean doesFillContainers(); + + @Override + public abstract boolean doesEmptyContainers(); + + @Override + public abstract boolean canTankBeFilled(); + + @Override + public abstract boolean canTankBeEmptied(); + + @Override + public abstract boolean displaysItemStack(); + + @Override + public abstract boolean displaysStackSize(); + + @Override + public int getInputSlot() { + return 0; + } + + @Override + public int getOutputSlot() { + return 1; + } + + @Override + public int getStackDisplaySlot() { + return 2; + } + + public int getStackDisplaySlot2() { + return 3; + } + + @Override + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return true; + } + + @Override + public boolean isFluidChangingAllowed() { + return true; + } + + @Override + public FluidStack getFillableStack() { + return this.getFillableStackEx(1); + } + + public FluidStack getFillableStackEx(final int stackID) { + if (stackID <= 1){ + return this.mFluid; + } + return this.mFluid2; + } + + @Override + public FluidStack setFillableStack(final FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + public FluidStack setFillableStack2(final FluidStack aFluid) { + this.mFluid2 = aFluid; + return this.mFluid2; + } + + @Override + public FluidStack getDrainableStack() { + return this.getDrainableStackEx(1); + } + + public FluidStack getDrainableStackEx(final int stackID) { + if (stackID <= 1){ + return this.mFluid; + } + return this.mFluid2; + } + + @Override + public FluidStack setDrainableStack(final FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + @Override + public FluidStack getDisplayedFluid() { + return this.getDrainableStack(); + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + @Override + public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.isFluidChangingAllowed() && (this.getFillableStack() != null) && (this.getFillableStack().amount <= 0)) { + this.setFillableStack(null); + } + + if (this.displaysItemStack() && (this.getStackDisplaySlot() >= 0) && (this.getStackDisplaySlot() < this.mInventory.length)) { + if (this.getDisplayedFluid() == null) { + if (ItemList.Display_Fluid.isStackEqual(this.mInventory[this.getStackDisplaySlot()], true, true)) { + this.mInventory[this.getStackDisplaySlot()] = null; + } + } else { + this.mInventory[this.getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(this.getDisplayedFluid(), this.displaysStackSize()); + } + } + + if (this.displaysItemStack() && (this.getStackDisplaySlot2() >= 0) && (this.getStackDisplaySlot2() < this.mInventory.length)) { + if (this.getDrainableStackEx(2) == null) { + if (ItemList.Display_Fluid.isStackEqual(this.mInventory[this.getStackDisplaySlot2()], true, true)) { + this.mInventory[this.getStackDisplaySlot2()] = null; + } + } else { + this.mInventory[this.getStackDisplaySlot2()] = GT_Utility.getFluidDisplayStack(this.getDrainableStackEx(2), this.displaysStackSize()); + } + } + + if (this.doesEmptyContainers()) { + final FluidStack tFluid = GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true); + if ((tFluid != null) && this.isFluidInputAllowed(tFluid)) { + + if (tFluid.isFluidEqual(this.getDrainableStackEx(1)) || (this.getDrainableStackEx(1) == null)){ + if (this.getFillableStackEx(1) == null) { + if (this.isFluidInputAllowed(tFluid) && (tFluid.amount <= this.getCapacity())) { + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { + this.setFillableStack(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(this.getFillableStack()) && ((tFluid.amount + this.getFillableStack().amount) <= this.getCapacity())) { + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { + this.getFillableStack().amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } + } + else if (tFluid.isFluidEqual(this.getDrainableStackEx(2)) || (this.getDrainableStackEx(2) == null)){ + if (this.getFillableStackEx(2) == null) { + if (this.isFluidInputAllowed(tFluid) && (tFluid.amount <= this.getCapacity())) { + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { + this.setFillableStack2(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(this.getFillableStackEx(2)) && ((tFluid.amount + this.getFillableStackEx(2).amount) <= this.getCapacity())) { + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), GT_Utility.getContainerItem(this.mInventory[this.getInputSlot()], true), 1)) { + this.getFillableStackEx(2).amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } + } + else { + Logger.INFO("Something broke when trying to empty cells between two fluid tank areas."); + } + } + } + + if (this.doesFillContainers()) { + final ItemStack tOutput = GT_Utility.fillFluidContainer(this.getDrainableStack(), this.mInventory[this.getInputSlot()], false, true); + if ((tOutput != null) && aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tOutput, 1)) { + final FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + if (tFluid != null) { + this.getDrainableStack().amount -= tFluid.amount; + } + if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { + this.setDrainableStack(null); + } + } + } + } + } + + @Override + public FluidStack getFluid() { + return this.getDrainableStack(); + } + + @Override + public int getFluidAmount() { + return this.getDrainableStack() != null ? this.getDrainableStack().amount : 0; + } + + @Override + public int fill(final FluidStack aFluid, final boolean doFill) { + if ((aFluid == null) || (aFluid.getFluid().getID() <= 0) || (aFluid.amount <= 0) || !this.canTankBeFilled() || !this.isFluidInputAllowed(aFluid)) { + return 0; + } + + if ((this.getFillableStack() == null) || (this.getFillableStack().getFluid().getID() <= 0)) { + if (aFluid.amount <= this.getCapacity()) { + if (doFill) { + this.setFillableStack(aFluid.copy()); + this.getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + this.setFillableStack(aFluid.copy()); + this.getFillableStack().amount = this.getCapacity(); + this.getBaseMetaTileEntity().markDirty(); + } + return this.getCapacity(); + } + + if (!this.getFillableStack().isFluidEqual(aFluid)) { + return 0; + } + + final int space = this.getCapacity() - this.getFillableStack().amount; + if (aFluid.amount <= space) { + if (doFill) { + this.getFillableStack().amount += aFluid.amount; + this.getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + this.getFillableStack().amount = this.getCapacity(); + } + return space; + } + + @Override + public FluidStack drain(final int maxDrain, final boolean doDrain) { + if ((this.getDrainableStack() == null) || !this.canTankBeEmptied()) { + return null; + } + if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { + this.setDrainableStack(null); + this.getBaseMetaTileEntity().markDirty(); + return null; + } + + int used = maxDrain; + if (this.getDrainableStack().amount < used) { + used = this.getDrainableStack().amount; + } + + if (doDrain) { + this.getDrainableStack().amount -= used; + this.getBaseMetaTileEntity().markDirty(); + } + + final FluidStack drained = this.getDrainableStack().copy(); + drained.amount = used; + + if ((this.getDrainableStack().amount <= 0) && this.isFluidChangingAllowed()) { + this.setDrainableStack(null); + this.getBaseMetaTileEntity().markDirty(); + } + + return drained; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aIndex == this.getOutputSlot(); + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aIndex == this.getInputSlot(); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java new file mode 100644 index 0000000000..5fb3b11d08 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java @@ -0,0 +1,303 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import java.lang.reflect.Field; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_Input { + + private static XSTR floatGen; + public int mProgresstime = 0, mMaxProgresstime = 0; + + public GT_MetaTileEntity_Hatch_AirIntake(final int aID, final String aName, final String aNameRegional, + final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_AirIntake(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + /*public GT_MetaTileEntity_Hatch_AirIntake(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + }*/ + + private static String[] S; + private static Field F; + + public synchronized String[] getDescription() { + try { + if (F == null || S == null) { + Field t = ReflectionUtils.getField(this.getClass(), "mDescriptionArray"); + if (t != null) { + F = t; + } + else { + F = ReflectionUtils.getField(this.getClass(), "mDescription"); + } + if (S == null && F != null) { + Object o = F.get(this); + if (o instanceof String[]) { + S = (String[]) o; + } + else if (o instanceof String) { + S = new String[] {(String) o}; + } + } + + } + } + catch (Throwable t) { + + } + if (S != null) { + final String[] desc = new String[S.length + 4]; + System.arraycopy(S, 0, desc, 0, S.length); + desc[S.length] = "DO NOT OBSTRUCT THE INPUT!"; + desc[S.length + 1] = "Draws in Air from the surrounding environment"; + desc[S.length + 2] = "Creates 1000L of Air every 4 ticks"; + desc[S.length + 3] = CORE.GT_Tooltip; + return desc; + } + else { + return new String[] {"DO NOT OBSTRUCT THE INPUT!", "Draws in Air from the surrounding environment", "Creates 1000L of Air every 4 ticks", CORE.GT_Tooltip}; + } + + + } + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_MUFFLER)}; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_MUFFLER)}; + } + + public boolean isSimpleMachine() { + return true; + } + + public boolean isFacingValid(final byte aFacing) { + return true; + } + + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + public boolean isValidSlot(final int aIndex) { + return false; + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_AirIntake(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (!aBaseMetaTileEntity.isAllowedToWork()) { + aBaseMetaTileEntity.setActive(false); + mProgresstime = 0; + mMaxProgresstime = 0; + } + else { + aBaseMetaTileEntity.setActive(true); + mMaxProgresstime = 4; + if (++mProgresstime >= mMaxProgresstime) { + addAirToHatch(aTick); + mProgresstime = 0; + } + } + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + mProgresstime += aProgress; + return mMaxProgresstime - mProgresstime; + } + + public void pollutionParticles(final World aWorld, final String name) { + if (this.getBaseMetaTileEntity().isServerSide()) { + return; + } + final float ran1 = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); + float ran2 = 0.0f; + float ran3 = 0.0f; + ran2 = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); + ran3 = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); + + final IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); + final ForgeDirection aDir = ForgeDirection.getOrientation((int) aMuffler.getFrontFacing()); + final float xPos = aDir.offsetX * 0.76f + aMuffler.getXCoord() + 0.25f; + float yPos = aDir.offsetY * 0.76f + aMuffler.getYCoord() + 0.65f; + final float zPos = aDir.offsetZ * 0.76f + aMuffler.getZCoord() + 0.25f; + float ySpd = aDir.offsetY * 0.1f + 0.2f + 0.1f * GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat(); + float xSpd; + float zSpd; + if (aDir.offsetY == -1) { + //Logger.INFO("Y = -1"); + final float temp = GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 2.0f * CORE.PI; + xSpd = (float) Math.sin(temp) * 0.1f; + zSpd = (float) Math.cos(temp) * 0.1f; + ySpd = -ySpd; + yPos = yPos - 0.8f; + } + else { + xSpd = aDir.offsetX * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat()); + zSpd = aDir.offsetZ * (0.1f + 0.2f * GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat()); + + xSpd = -xSpd; + zSpd = -zSpd; + } + + aWorld.spawnParticle(name, (double) (xPos + ran1 * 0.5f), + (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), + (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), (double) xSpd, + (double) -ySpd, (double) zSpd); + aWorld.spawnParticle(name, (double) (xPos + ran2 * 0.5f), + (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), + (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), (double) xSpd, + (double) -ySpd, (double) zSpd); + aWorld.spawnParticle(name, (double) (xPos + ran3 * 0.5f), + (double) (yPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), + (double) (zPos + GT_MetaTileEntity_Hatch_AirIntake.floatGen.nextFloat() * 0.5f), (double) xSpd, + (double) -ySpd, (double) zSpd); + } + + static { + GT_MetaTileEntity_Hatch_AirIntake.floatGen = new XSTR(); + } + + public int getTankPressure() { + return 100; + } + + public int getCapacity() { + return 128000; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + private static Fluid AIR; + + public boolean isAirInHatch() { + if (this.mFluid != null) { + if (AIR == null) { + AIR = FluidUtils.getAir(1).getFluid(); + } + if (AIR == this.mFluid.getFluid()) { + return true; + } + } + return false; + } + + public boolean addAirToHatch(long aTick) { + if (!this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing())) { + return false; + } + boolean didFill = this.fill(FluidUtils.getAir(1000), true) > 0; + if (didFill) { + this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), "cloud"); + } + return didFill; + } + + @Override + public boolean canTankBeFilled() { + if (this.mFluid == null || (this.mFluid != null && (this.mFluid.amount <= this.getCapacity()))) { + return true; + } + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + return false; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return 0; + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + return 0; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + super.loadNBTData(aNBT); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java new file mode 100644 index 0000000000..5347b2e4f7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java @@ -0,0 +1,148 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.gui.*; +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.item.general.ItemControlCore; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch { + + public GT_Recipe_Map mRecipeMap = null; + + public BlockPos mControllerLocation; + + public GT_MetaTileEntity_Hatch_ControlCore(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Core determines maximum tier machine will operate at"); + } + + public GT_MetaTileEntity_Hatch_ControlCore(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_ControlCore(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription[0], aTextures); + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Control_Core)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Control_Core)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_ControlCore(mName, mTier, StaticFields59.getDescriptionArray(this), mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, "Control Core Module"); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; 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); + } + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() && (aStack != null && aStack.getItem() instanceof ItemControlCore); + } + + public boolean setOwner(TileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } + else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } + + public boolean setOwner(IGregTechTileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } + else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java new file mode 100644 index 0000000000..39f477b173 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java @@ -0,0 +1,84 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.ITexture; + +public class GT_MetaTileEntity_Hatch_DynamoBuffer extends GT_MetaTileEntity_Hatch_Dynamo { + public GT_MetaTileEntity_Hatch_DynamoBuffer(final int aID, final String aName, final String aNameRegional, + final int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_DynamoBuffer(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + /*public GT_MetaTileEntity_Hatch_DynamoBuffer(final String aName, final int aTier, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + }*/ + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, TexturesGtBlock.OVERLAYS_ENERGY_OUT_MULTI_BUFFER[this.mTier]}; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, TexturesGtBlock.OVERLAYS_ENERGY_OUT_MULTI_BUFFER[this.mTier]}; + } + + @Override + public long getMinimumStoredEU() { + return 0L; + } + + @Override + public long maxEUStore() { + return 512L + GT_Values.V[this.mTier + 1] * 2048L; + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (MetaTileEntity) new GT_MetaTileEntity_Hatch_DynamoBuffer(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public String[] getDescription() { + String[] g; + if (CORE.GTNH || (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechVersionAsInt() >= 50932)) { + g = new String[]{ + "Dynamo with internal storage and additional Amp capacity", + "Does not accept more than "+(this.maxEUOutput() * this.maxAmperesIn())+"EU/t as input", + CORE.GT_Tooltip}; + + } + else { + g = new String[]{ + "Dynamo with internal storage and additional Amp capacity", + "Stores "+maxEUStore()+"EU", + "Amperage In: 4", + "Amperage Out: 4", + "Does not accept more than "+(this.maxEUOutput() * this.maxAmperesIn())+"EU/t as input", + "Large Turbines only supply 1A to this, other Multiblocks can inject more amps", + CORE.GT_Tooltip}; + } + return g; + } + + @Override + public long maxAmperesIn() { + return 4; + } + + @Override + public long maxAmperesOut() { + return 4; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java new file mode 100644 index 0000000000..a892346463 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ElementalDataOrbHolder.java @@ -0,0 +1,149 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import java.util.ArrayList; + +import gregtech.api.gui.GT_Container_4by4; +import gregtech.api.gui.GT_GUIContainer_4by4; +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_Hatch_ElementalDataOrbHolder extends GT_MetaTileEntity_Hatch { + public GT_Recipe_Map mRecipeMap = null; + + public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 16, new String[]{ + "Holds Data Orbs for the Elemental Duplicator", + CORE.GT_Tooltip + }); + } + + public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 16, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 16, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Cyber_Interface)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Cyber_Interface)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Data Orb Repository"); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] != null && mInventory[i].stackSize <= 0) { + mInventory[i] = null; + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + + } + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + } + + public ArrayList<ItemStack> getInventory(){ + ArrayList<ItemStack> aContents = new ArrayList<ItemStack>(); + for (int i=0;i<this.getSizeInventory();i++) { + aContents.add(this.getStackInSlot(i)); + } + return aContents; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java new file mode 100644 index 0000000000..93e6274508 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java @@ -0,0 +1,287 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.V; + +import java.lang.reflect.Constructor; +import java.util.HashMap; + +import gregtech.api.gui.GT_Container_3by3; +import gregtech.api.gui.GT_GUIContainer_3by3; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.InventoryUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_Hatch_Energy_RTG extends GT_MetaTileEntity_Hatch_Energy { + + public GT_MetaTileEntity_Hatch_Energy_RTG(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_Energy_RTG(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Energy_RTG(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + String[] S = super.getDescription(); + final String[] desc = new String[S.length + 1]; + System.arraycopy(S, 0, desc, 0, S.length); + desc[S.length] = CORE.GT_Tooltip; + return desc; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, TexturesGtBlock.getTextureFromIcon(TexturesGtBlock.Overlay_Hatch_RTG_On, new short[] {220, 220, 220, 0})}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, TexturesGtBlock.getTextureFromIcon(TexturesGtBlock.Overlay_Hatch_RTG_Off, new short[] {220, 220, 220, 0})}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE / (Short.MAX_VALUE * Byte.MAX_VALUE) ; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + Constructor aCon = ReflectionUtils.getConstructor(this.getClass(), new Class[] {String.class, int.class, int.class, String[].class, ITexture[][][].class}); + Object aInst = ReflectionUtils.createNewInstanceFromConstructor(aCon, new Object[] {mName, mTier, 9, mDescriptionArray, mTextures}); + if (GT_MetaTileEntity_Hatch_Energy_RTG.class.isInstance(aInst)) { + return (MetaTileEntity) aInst; + } + Logger.INFO("Created bad sized RTG hatch."); + return new GT_MetaTileEntity_Hatch_Energy_RTG(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, "RTG Power Unit"); + } + + private static class Dat { + + protected final String mUniqueDataTag; + private final ItemStack mStack; + private final NBTTagCompound mNBT; + + public Dat(ItemStack aStack) { + mStack = aStack; + mNBT = (aStack.getTagCompound() != null ? aStack.getTagCompound() : new NBTTagCompound()); + mUniqueDataTag = ""+Item.getIdFromItem(aStack.getItem())+""+aStack.getItemDamage()+""+1+""+mNBT.getId(); + } + + public int getKey() { + return Item.getIdFromItem(mStack.getItem())+mStack.getItemDamage(); + } + + } + + private static final HashMap<String, ItemStack> mFuelInstanceMap = new HashMap<String, ItemStack>(); + private static final HashMap<String, Long> mFuelValueMap = new HashMap<String, Long>(); + private static final HashMap<String, Integer> mFuelTypeMap = new HashMap<String, Integer>(); + private static final HashMap<Integer, String> mFuelTypeMapReverse = new HashMap<Integer, String>(); + + public static boolean registerPelletForHatch(ItemStack aStack, long aFuelValue) { + if (!ItemUtils.checkForInvalidItems(aStack)) { + return false; + } + ItemStack aTemp = aStack.copy(); + aTemp.stackSize = 1; + Dat aDat = new Dat(aTemp); + String aKey = aDat.mUniqueDataTag; + mFuelInstanceMap.put(aKey, aTemp); + mFuelValueMap.put(aKey, aFuelValue); + mFuelTypeMap.put(aKey, aDat.getKey()); + mFuelTypeMapReverse.put(aDat.getKey(), aKey); + Logger.INFO("RTG Hatch: Registered Fuel Pellet: "+ItemUtils.getItemName(aTemp)+", Fuel Value: "+aFuelValue+", Key: "+aKey+", Key2: "+aDat.getKey()); + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + InventoryUtils.sortInventoryItems(this); + } + if (aTimer % 100 == 0 && aBaseMetaTileEntity.isServerSide()) { + if (hasPellet(this)) { + Logger.INFO("Has Pellet"); + tryConsumePellet(this); + } + } + } + + private static void tryConsumePellet(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { + ItemStack aPellet = getPelletToConsume(aTile); + if (aPellet != null) { + Logger.INFO("Found Pellet"); + long aFuel = getFuelValueOfPellet(aPellet); + if (aFuel > 0) { + Logger.INFO("Has Fuel Value: "+aFuel); + if (hasSpaceForEnergy(aTile, aFuel)) { + Logger.INFO("Can buffer"); + aPellet.stackSize = 0; + Logger.INFO("Stack set to 0"); + aPellet = null; + Logger.INFO("null stack"); + addEnergyToInternalStorage(aTile, aFuel); + Logger.INFO("Consumed"); + } + } + } + aTile.updateSlots(); + Logger.INFO("updating slots"); + } + + private static void addEnergyToInternalStorage(GT_MetaTileEntity_Hatch_Energy_RTG aTile, long aFuel) { + aTile.getBaseMetaTileEntity().increaseStoredEnergyUnits(aFuel, true); + } + + public static boolean hasSpaceForEnergy(GT_MetaTileEntity_Hatch_Energy_RTG aTile, long aAmount) { + long aMax = aTile.maxEUStore(); + long aCurrent = aTile.getEUVar(); + if ((aMax - aCurrent) >= aAmount) { + return true; + } + return false; + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] != null && mInventory[i].stackSize <= 0) { + mInventory[i] = null; + } + } + InventoryUtils.sortInventoryItems(this); + } + + public static boolean hasPellet(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { + for (ItemStack o : aTile.mInventory) { + if (o != null ) { + for (ItemStack i : mFuelInstanceMap.values()) { + if (ItemUtils.areItemsEqual(o, i)) { + return true; + } + } + } + } + return false; + } + + public static String getPelletType(ItemStack o) { + if (o == null) { + return "error"; + } + Dat aDat = new Dat(o); + return mFuelTypeMapReverse.get(aDat.getKey()); + } + + public static long getFuelValueOfPellet(ItemStack aPellet) { + String aType = getPelletType(aPellet); + if (mFuelValueMap.containsKey(aType)) { + return mFuelValueMap.get(aType); + } + return 0; + } + + public static ItemStack getPelletToConsume(GT_MetaTileEntity_Hatch_Energy_RTG aTile) { + for (ItemStack o : aTile.mInventory) { + if (o != null ) { + for (ItemStack i : mFuelInstanceMap.values()) { + if (ItemUtils.areItemsEqual(o, i)) { + return o; + } + } + } + } + return null; + } + + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java new file mode 100644 index 0000000000..57f8b722c3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBattery.java @@ -0,0 +1,258 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.V; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GT_Values; +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.*; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT_MetaTileEntity_Hatch_InputBattery +extends +GT_MetaTileEntity_Hatch { + public final GT_Recipe_Map mRecipeMap = null; + + public GT_MetaTileEntity_Hatch_InputBattery(int aID, String aName, + String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Chargeable Item Bus for Multiblocks"); + } + + public GT_MetaTileEntity_Hatch_InputBattery(String aName, int aTier, + String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, + aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 4 : 16, + aDescription, aTextures); + } + + @Override + public String[] getDescription() { + int mSlots = 0; + if (this.mTier == 2) { + mSlots = 4; + } + else if (this.mTier == 4) { + mSlots = 16; + } + else { + mSlots = 16; + } + return new String[]{ + this.mDescription, + "Capacity: " + mSlots + " slots", + CORE.GT_Tooltip}; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return 512 + V[mTier + 1] * 16; + } + + @Override + public long maxAmperesIn() { + return 4; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Charger)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Charger)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_InputBattery(mName, mTier, + mDescription, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, + EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, + IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + case 2 : + return new CONTAINER_Electric_2by2(aPlayerInventory, + aBaseMetaTileEntity); + case 4 : + return new CONTAINER_Electric_4by4(aPlayerInventory, + aBaseMetaTileEntity); + default : + return new CONTAINER_Electric_4by4(aPlayerInventory, + aBaseMetaTileEntity); + } + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, + IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + case 2 : + return new GUI_Electric_2by2(aPlayerInventory, + aBaseMetaTileEntity, "Charging Bus"); + case 4 : + return new GUI_Electric_4by4(aPlayerInventory, + aBaseMetaTileEntity, "Charging Bus"); + default : + return new GUI_Electric_4by4(aPlayerInventory, + aBaseMetaTileEntity, "Charging Bus"); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() + && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + if (aBaseMetaTileEntity.isServerSide()){ + if (aBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) { + MetaTileEntity mMetaTileEntity = (MetaTileEntity) aBaseMetaTileEntity.getMetaTileEntity(); + if (mMetaTileEntity.rechargerSlotCount() > 0 && aBaseMetaTileEntity.getStoredEU() > 0) { + for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { + if (aBaseMetaTileEntity.getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { + for (int u=0;u<10;u++){ + aBaseMetaTileEntity.decreaseStoredEnergyUnits(GT_ModHandler.chargeElectricItem(mMetaTileEntity.mInventory[i], (int) Math.min(V[this.mTier] * 15, aBaseMetaTileEntity.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, GT_Values.V[u]), false, false), true); + if (mMetaTileEntity.mInventory[i].stackSize <= 0){ + mMetaTileEntity.mInventory[i] = null; + } + } + } + } + } + else { + //Utils.LOG_INFO("reCharger Slot Count = "+mMetaTileEntity.rechargerSlotCount()); + //Utils.LOG_INFO("getStoredEU = "+aBaseMetaTileEntity.getStoredEU()); + //Utils.LOG_INFO("getEUVar = "+mMetaTileEntity.getEUVar()); + } + } + } + super.onPostTick(aBaseMetaTileEntity, aTimer); + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) + mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; 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); + } + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, + int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() + && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, + int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() + && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + switch (mTier) { + case 2 : + return 4; + case 4 : + return 16; + default : + return 16; + } + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java new file mode 100644 index 0000000000..ba4e394114 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java @@ -0,0 +1,329 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.general.ItemAirFilter; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_Hatch_Muffler_Advanced; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_Hatch_Muffler_Advanced; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch_Muffler { + + protected int SLOT_FILTER = 0; + + @Override + public void onConfigLoad(GT_Config aConfig) { + super.onConfigLoad(aConfig); + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + try { + Integer a1 = (int) StaticFields59.getFieldFromGregtechProxy("mPollutionSmogLimit"); + if (a1 != null && a1 > 0) { + mPollutionSmogLimit = a1; + } + } + catch (Throwable t) { + mPollutionSmogLimit = 500000; + } + } + } + + private int mPollutionSmogLimit = 500000; + + public GT_MetaTileEntity_Hatch_Muffler_Adv(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); + } + + public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); + } + + public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription[0], aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); + } + + public String[] getDescription() { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + String[] mDescArray = StaticFields59.getDescriptionArray(this); + String[] desc = new String[mDescArray.length + 7]; + System.arraycopy(mDescArray, 0, desc, 0, mDescArray.length); + desc[mDescArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; + desc[mDescArray.length + 1] = "Requires 3 Air on the exhaust face"; + desc[mDescArray.length + 2] = "Requires Air Filters"; + desc[mDescArray.length + 3] = "Mufflers require T2 Filters from IV-"+GT_Values.VN[9]; + desc[mDescArray.length + 4] = "Reduces Pollution to " + this.calculatePollutionReductionForTooltip(100) + "%"; + desc[mDescArray.length + 5] = "Recovers " + (105 - this.calculatePollutionReductionForTooltip(100)) + "% of CO2/CO/SO2"; + desc[mDescArray.length + 6] = CORE.GT_Tooltip; + return desc; + } + else { + return new String[] {}; + } + } + + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Muffler_Adv)}; + } + + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Muffler_Adv)}; + } + + public boolean isValidSlot(int aIndex) { + return aIndex == SLOT_FILTER; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Muffler_Adv(this.mName, this.mTier, StaticFields59.getDescriptionArray(this), this.mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, + EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity, "Advanced Muffler", "machine_Charger.png"); + } + + private boolean airCheck() { + if ( + this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()) && + this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 1) && + this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 2) + ) { + return true; + } + return false; + } + + public boolean polluteEnvironment() { + if (airCheck() && damageAirFilter()) { + int aEmission = this.calculatePollutionReduction(10000); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), aEmission); + //Logger.INFO("Outputting "+aEmission+"gbl"); + return true; + } else { + //Logger.INFO("Failed to output pollution"); + return false; + } + } + + + public int calculatePollutionReductionForTooltip(int aPollution) { + return (int) (aPollution * Math.pow(0.64D, (double) (this.mTier - 1))); + } + + public int calculatePollutionReduction(int aPollution) { + double aVal1 = aPollution * Math.pow(0.64D, (double) (this.mTier - 1)); + int aVal2 = (int) aVal1; + if (!hasValidFilter()) { + aVal2 = (int) ((double) aPollution * Math.pow(0.7D, (double) (this.mTier - 1)));; + } + return aVal2; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aIndex == this.SLOT_FILTER) { + if (isAirFilter(aStack)) { + return true; + } + } + return false; + } + + private ItemStack getInventoryStack() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length-1 >= this.SLOT_FILTER) { + return this.mInventory[this.SLOT_FILTER]; + } + } + return null; + } + + private void breakAirFilter() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length-1 >= this.SLOT_FILTER) { + Logger.INFO("Breaking Filter"); + this.mInventory[this.SLOT_FILTER] = null; + } + } + } + + public boolean hasValidFilter() { + return isAirFilter(getInventoryStack()); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + + //Logger.INFO("A1"); + + super.onPostTick(aBaseMetaTileEntity, aTick); + + //Logger.INFO("A2"); + + String aParticleName; + if ((aTick % 2) == 0){ + aParticleName = "cloud"; + } + else { + aParticleName = "smoke"; + } + + //Logger.INFO("A3"); + + if (aBaseMetaTileEntity.isClientSide()) { + //Logger.INFO("B1"); + if (this.getBaseMetaTileEntity().isActive()) { + //Logger.INFO("C1"); + this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); + } + //return; + } + else { + //Logger.INFO("B2"); + if (this.getInventoryStack() == null) { + //Logger.INFO("D1"); + //Logger.INFO("Empty - "+this.mInventory.length); + } + else { + //Logger.INFO("D2"); + } + } + //Logger.INFO("A4"); + + + + } + + public boolean isAirFilter(ItemStack filter){ + if (filter == null) { + return false; + } + if (filter.getItem() instanceof ItemAirFilter){ + + if (this.mTier < 5) { + return true; + } + else { + if (filter.getItemDamage() == 1) { + return true; + } + } + } + return false; + } + + public boolean damageAirFilter(){ + ItemStack filter = getInventoryStack(); + if (filter == null) { + return false; + } + + if (isAirFilter(filter)){ + long currentUse = ItemAirFilter.getFilterDamage(filter); + Logger.INFO("Filter Damage: "+currentUse); + //Remove broken Filter + if ((filter.getItemDamage() == 0 && currentUse >= 50-1) || (filter.getItemDamage() == 1 && currentUse >= 2500-1)){ + breakAirFilter(); + return true; + } + else { + //Do Damage + ItemAirFilter.setFilterDamage(filter, currentUse+1); + Logger.INFO("Filter Damage now: "+currentUse); + return true; + } + } + return false; + } + + public void pollutionParticles(World aWorld, String name) { + float ran1 = CORE.RANDOM.nextFloat(); + float ran2 = 0.0F; + float ran3 = 0.0F; + boolean chk1 = ran1 * 100.0F < (float) this.calculatePollutionReduction(100); + boolean chk2; + boolean chk3; + int aPollutionAmount = PollutionUtils.getPollution(getBaseMetaTileEntity()); + if (aPollutionAmount >= mPollutionSmogLimit) { + ran2 = CORE.RANDOM.nextFloat(); + ran3 = CORE.RANDOM.nextFloat(); + chk2 = ran2 * 100.0F < (float) this.calculatePollutionReduction(100); + chk3 = ran3 * 100.0F < (float) this.calculatePollutionReduction(100); + if (!chk1 && !chk2 && !chk3) { + return; + } + } else { + if (!chk1) { + return; + } + + chk3 = false; + chk2 = false; + } + + IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); + ForgeDirection aDir = ForgeDirection.getOrientation(aMuffler.getFrontFacing()); + float xPos = (float) aDir.offsetX * 0.76F + (float) aMuffler.getXCoord() + 0.25F; + float yPos = (float) aDir.offsetY * 0.76F + (float) aMuffler.getYCoord() + 0.25F; + float zPos = (float) aDir.offsetZ * 0.76F + (float) aMuffler.getZCoord() + 0.25F; + float ySpd = (float) aDir.offsetY * 0.1F + 0.2F + 0.1F * CORE.RANDOM.nextFloat(); + float xSpd; + float zSpd; + if (aDir.offsetY == -1) { + float temp = CORE.RANDOM.nextFloat() * 2.0F * CORE.PI; + xSpd = (float) Math.sin((double) temp) * 0.1F; + zSpd = (float) Math.cos((double) temp) * 0.1F; + } else { + xSpd = (float) aDir.offsetX * (0.1F + 0.2F * CORE.RANDOM.nextFloat()); + zSpd = (float) aDir.offsetZ * (0.1F + 0.2F * CORE.RANDOM.nextFloat()); + } + + if (chk1) { + aWorld.spawnParticle(name, (double) (xPos + ran1 * 0.5F), (double) (yPos + CORE.RANDOM.nextFloat() * 0.5F), + (double) (zPos + CORE.RANDOM.nextFloat() * 0.5F), (double) xSpd, (double) ySpd, (double) zSpd); + } + + if (chk2) { + aWorld.spawnParticle(name, (double) (xPos + ran2 * 0.5F), (double) (yPos + CORE.RANDOM.nextFloat() * 0.5F), + (double) (zPos + CORE.RANDOM.nextFloat() * 0.5F), (double) xSpd, (double) ySpd, (double) zSpd); + } + + if (chk3) { + aWorld.spawnParticle(name, (double) (xPos + ran3 * 0.5F), (double) (yPos + CORE.RANDOM.nextFloat() * 0.5F), + (double) (zPos + CORE.RANDOM.nextFloat() * 0.5F), (double) xSpd, (double) ySpd, (double) zSpd); + } + + } + + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java new file mode 100644 index 0000000000..d0f1d8e03f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java @@ -0,0 +1,208 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import java.lang.reflect.Field; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_Hatch_Naquadah extends GT_MetaTileEntity_Hatch_Input { + + public final FluidStack[] mFluidsToUse = new FluidStack[3]; + public final int mFluidCapacity; + + public GT_MetaTileEntity_Hatch_Naquadah(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 6); + mFluidCapacity = 32000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Naquadah(final String aName, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, 6, aDescription, aTextures); + mFluidCapacity = 32000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Naquadah(final String aName, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, 6, aDescription[0], aTextures); + mFluidCapacity = 32000; + initHatch(); + } + + private void initHatch() { + if (mFluidsToUse[0] == null) { + mFluidsToUse[0] = Materials.Naquadah.getMolten(1); + } + if (mFluidsToUse[1] == null) { + mFluidsToUse[1] = Materials.NaquadahEnriched.getMolten(1); + } + if (mFluidsToUse[2] == null) { + mFluidsToUse[2] = Materials.Naquadria.getMolten(1); + } + } + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) }; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) }; + } + + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { + for (FluidStack f : mFluidsToUse) { + if (f != null) { + if (GT_Utility.getFluidForFilledItem(aStack, true).getFluid() == f.getFluid()) { + return true; + } + } + } + } + return false; + } + + public boolean isFluidInputAllowed(final FluidStack aFluid) { + for (FluidStack f : mFluidsToUse) { + if (f != null) { + if (aFluid.getFluid() == f.getFluid()) { + return true; + } + } + } + return false; + } + + public int getCapacity() { + return this.mFluidCapacity; + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (MetaTileEntity) new GT_MetaTileEntity_Hatch_Naquadah(this.mName, this.mDescription, this.mTextures); + } + + @Override + public String[] getDescription() { + if (aDescCache[0] == null || aDescCache[0].contains(".name") || aDescCache[0].contains("fluid.")) { + aDescCache[0] = formatFluidString(this.mFluidsToUse[0]); + } + if (aDescCache[1] == null || aDescCache[1].contains(".name") || aDescCache[1].contains("fluid.")) { + aDescCache[1] = formatFluidString(this.mFluidsToUse[1]); + } + if (aDescCache[2] == null || aDescCache[2].contains(".name") || aDescCache[2].contains("fluid.")) { + aDescCache[2] = formatFluidString(this.mFluidsToUse[2]); + } + String aNaq = aDescCache[0]; + String aEnrNaq = aDescCache[1]; + String aNaquad = aDescCache[2]; + String[] s2 = new String[]{ + "Fluid Input for Multiblocks", + "Capacity: " + getCapacity()+"L", + "Accepted Fluid: " + aNaq, + "Accepted Fluid: " + aEnrNaq, + "Accepted Fluid: " + aNaquad, + CORE.GT_Tooltip + }; + return s2; + } + + private static String[] aDescCache = new String[3]; + private String formatFluidString(FluidStack f) { + FluidStack mLockedStack = f; + Integer mLockedTemp = 0;; + String mTempMod = ""+EnumChatFormatting.RESET; + mLockedTemp = mLockedStack.getFluid().getTemperature(); + if (mLockedTemp != null) { + if (mLockedTemp <= -3000) { + mTempMod = ""+EnumChatFormatting.DARK_PURPLE; + } + else if (mLockedTemp >= -2999 && mLockedTemp <= -500) { + mTempMod = ""+EnumChatFormatting.DARK_BLUE; + } + else if (mLockedTemp >= -499 && mLockedTemp <= -50) { + mTempMod = ""+EnumChatFormatting.BLUE; + } + else if (mLockedTemp >= 30 && mLockedTemp <= 300) { + mTempMod = ""+EnumChatFormatting.AQUA; + } + else if (mLockedTemp >= 301 && mLockedTemp <= 800) { + mTempMod = ""+EnumChatFormatting.YELLOW; + } + else if (mLockedTemp >= 801 && mLockedTemp <= 1500) { + mTempMod = ""+EnumChatFormatting.GOLD; + } + else if (mLockedTemp >= 1501) { + mTempMod = ""+EnumChatFormatting.RED; + } + } + return mTempMod + mLockedStack.getLocalizedName(); + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + // TODO Auto-generated method stub + return super.getTextureSet(aTextures); + } + + private Field F1, F2; + + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + byte a1 = 0, a2 = 0; + try { + if (F1 == null) { + F1 = ReflectionUtils.getField(getClass(), "actualTexture"); + } + if (F2 == null) { + F2 = ReflectionUtils.getField(getClass(), "mTexturePage"); + } + + if (F1 != null) { + a1 = F1.getByte(this); + } + if (F2 != null) { + a2 = F2.getByte(this); + } + } + catch (IllegalArgumentException | IllegalAccessException n) {} + + int textureIndex = a1 | a2 << 7; + byte texturePointer = (byte) (a1 & 127); + + + + if (aSide == 1 || aSide == 0) { + ITexture g = textureIndex > 0 ? StaticFields59.getCasingTexturePages(a2, texturePointer) : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; + + return new ITexture[] {g, new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_TOP_ACTIVE) }; + } + + return aSide != aFacing ? + (textureIndex > 0 ? new ITexture[] { StaticFields59.getCasingTexturePages(a2, texturePointer) } : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }) + : (textureIndex > 0 ? (aActive ? this.getTexturesActive(StaticFields59.getCasingTexturePages(a2, texturePointer)) : this.getTexturesInactive(StaticFields59.getCasingTexturePages(a2, texturePointer))) + : (aActive ? this.getTexturesActive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]) : this.getTexturesInactive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]))); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java new file mode 100644 index 0000000000..ba97cc38eb --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBattery.java @@ -0,0 +1,236 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.V; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.charge.*; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT_MetaTileEntity_Hatch_OutputBattery +extends +GT_MetaTileEntity_Hatch { + public GT_MetaTileEntity_Hatch_OutputBattery(int aID, String aName, + String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier), + "Dischargeable Item Bus for Multiblocks"); + } + + public GT_MetaTileEntity_Hatch_OutputBattery(String aName, int aTier, + String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, + aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, + aDescription, aTextures); + } + + + @Override + public String[] getDescription() { + int mSlots = 0; + if (this.mTier == 2) { + mSlots = 4; + } + else if (this.mTier == 4) { + mSlots = 16; + } + else { + mSlots = 16; + } + return new String[]{ + this.mDescription, + "Capacity: " + mSlots + " slots", + CORE.GT_Tooltip}; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUOutput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return 512 + V[mTier + 1] * 8; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Discharger)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture(TexturesGtBlock.Overlay_Hatch_Discharger)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_OutputBattery(mName, mTier, + mDescription, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, + EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, + IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + case 2 : + return new CONTAINER_Electric_2by2(aPlayerInventory, + aBaseMetaTileEntity); + case 4 : + return new CONTAINER_Electric_4by4(aPlayerInventory, + aBaseMetaTileEntity); + default : + return new CONTAINER_Electric_4by4(aPlayerInventory, + aBaseMetaTileEntity); + } + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, + IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + case 2 : + return new GUI_Electric_2by2(aPlayerInventory, + aBaseMetaTileEntity, "Discharging Bus"); + case 4 : + return new GUI_Electric_4by4(aPlayerInventory, + aBaseMetaTileEntity, "Discharging Bus"); + default : + return new GUI_Electric_4by4(aPlayerInventory, + aBaseMetaTileEntity, "Discharging Bus"); + } + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, + int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, + int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) + mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; 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); + } + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 0; + } + + @Override + public int dechargerSlotStartIndex() { + return 0; + } + + @Override + public int dechargerSlotCount() { + return mTier == 2 ? 4 : 16; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() + && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + + if (aBaseMetaTileEntity.isServerSide()){ + if (aBaseMetaTileEntity.getMetaTileEntity() instanceof MetaTileEntity) { + MetaTileEntity mMetaTileEntity = (MetaTileEntity) aBaseMetaTileEntity.getMetaTileEntity(); + if (mMetaTileEntity.dechargerSlotCount() > 0 && mMetaTileEntity.getEUVar() < aBaseMetaTileEntity.getEUCapacity()) { + for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { + if (mMetaTileEntity.mInventory[i] != null && mMetaTileEntity.getEUVar() < aBaseMetaTileEntity.getEUCapacity()) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(mMetaTileEntity.mInventory[i], (int) Math.min(V[mTier] * 15, aBaseMetaTileEntity.getEUCapacity() - aBaseMetaTileEntity.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), true, false, false), true); + if (mMetaTileEntity.mInventory[i].stackSize <= 0) + mMetaTileEntity.mInventory[i] = null; + } + } + } + } + } + super.onPostTick(aBaseMetaTileEntity, aTimer); + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java new file mode 100644 index 0000000000..1251c42ae3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -0,0 +1,219 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import java.lang.reflect.Field; + +import com.google.common.collect.BiMap; + +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Output { + + public final AutoMap<Fluid> mFluidsToUse = new AutoMap<Fluid>(); + public final int mFluidCapacity; + private int mTotalPlasmaSupported = -1; + + public GT_MetaTileEntity_Hatch_Plasma(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 6); + mFluidCapacity = 256000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Plasma(final String aName, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, 6, aDescription, aTextures); + mFluidCapacity = 256000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Plasma(final String aName, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, 6, aDescription[0], aTextures); + mFluidCapacity = 256000; + initHatch(); + } + + private void initHatch() { + + //Get all Plasmas, but the easiest way to do this is to just ask the Fluid Registry what exists and filter through them lazily. + Field fluidNameCache; + + fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); + + AutoMap<String> mValidPlasmaNameCache = new AutoMap<String>(); + if (fluidNameCache != null) { + try { + Object fluidNames = fluidNameCache.get(null); + if (fluidNames != null) { + try { + @SuppressWarnings("unchecked") + BiMap<Integer, String> fluidNamesMap = (BiMap<Integer, String>) fluidNames; + if (fluidNamesMap != null) { + for (String g : fluidNamesMap.values()) { + if (g.toLowerCase().contains("plasma")) { + mValidPlasmaNameCache.put(g); + } + } + } + } catch (ClassCastException e) { + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + + AutoMap<Fluid> mPlasmaCache = new AutoMap<Fluid>(); + if (!mValidPlasmaNameCache.isEmpty()) { + for (String y : mValidPlasmaNameCache) { + Fluid t = FluidRegistry.getFluid(y); + if (t != null) { + if (t.getTemperature() > 1000) { + mPlasmaCache.put(t); + } + } + } + } + + if (!mPlasmaCache.isEmpty()) { + for (Fluid w : mPlasmaCache) { + mFluidsToUse.put(w); + } + } + + + + + + } + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture }; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture }; + } + + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { + for (Fluid f : mFluidsToUse) { + if (f != null) { + if (GT_Utility.getFluidForFilledItem(aStack, true).getFluid() == f) { + return true; + } + } + } + } + return false; + } + + public boolean isFluidInputAllowed(final FluidStack aFluid) { + for (Fluid f : mFluidsToUse) { + if (f != null) { + if (aFluid.getFluid() == f) { + return true; + } + } + } + return false; + } + + public int getCapacity() { + return this.mFluidCapacity; + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (MetaTileEntity) new GT_MetaTileEntity_Hatch_Plasma(this.mName, this.mDescription, this.mTextures); + } + + @Override + public String[] getDescription() { + + if (mTotalPlasmaSupported < 0) { + if (mFluidsToUse.isEmpty()) { + mTotalPlasmaSupported = 0; + } + else { + mTotalPlasmaSupported = mFluidsToUse.size(); + } + } + + String aX = EnumChatFormatting.GRAY+""; + String a1 = EnumChatFormatting.GOLD+"Refined containment"+aX; + String a2 = EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.DARK_AQUA+getCapacity()+"L"+aX; + String a3 = EnumChatFormatting.GOLD+"Supports "+EnumChatFormatting.DARK_RED+mTotalPlasmaSupported+EnumChatFormatting.GOLD+" types of plasma"+aX; + + + + String[] s2 = new String[]{ + a1, a2, a3, CORE.GT_Tooltip + }; + return s2; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + // TODO Auto-generated method stub + return super.getTextureSet(aTextures); + } + + private Field F1, F2; + + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + byte a1 = 0, a2 = 0; + try { + if (F1 == null) { + F1 = ReflectionUtils.getField(getClass(), "actualTexture"); + } + if (F2 == null) { + F2 = ReflectionUtils.getField(getClass(), "mTexturePage"); + } + + if (F1 != null) { + a1 = F1.getByte(this); + } + if (F2 != null) { + a2 = F2.getByte(this); + } + } + catch (IllegalArgumentException | IllegalAccessException n) {} + + int textureIndex = a1 | a2 << 7; + byte texturePointer = (byte) (a1 & 127); + + + + if (aSide == 1 || aSide == 0) { + ITexture g = textureIndex > 0 ? StaticFields59.getCasingTexturePages(a2, texturePointer) : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; + + return new ITexture[] {g}; + } + + return aSide != aFacing ? + (textureIndex > 0 ? new ITexture[] { StaticFields59.getCasingTexturePages(a2, texturePointer) } : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }) + : (textureIndex > 0 ? (aActive ? this.getTexturesActive(StaticFields59.getCasingTexturePages(a2, texturePointer)) : this.getTexturesInactive(StaticFields59.getCasingTexturePages(a2, texturePointer))) + : (aActive ? this.getTexturesActive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]) : this.getTexturesInactive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]))); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java new file mode 100644 index 0000000000..f1dd131a67 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusInput.java @@ -0,0 +1,234 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_2by2; +import gregtech.api.gui.GT_GUIContainer_2by2; +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.lib.CORE; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_Hatch_Steam_BusInput extends GT_MetaTileEntity_Hatch { + public GT_Recipe_Map mRecipeMap = null; + public boolean disableSort; + + public GT_MetaTileEntity_Hatch_Steam_BusInput(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{ + "Item Input for Steam Multiblocks", + "Shift + right click with screwdriver to toggle automatic item shuffling", + "Capacity: 4 stacks", + "Does not work with non-steam multiblocks", + CORE.GT_Tooltip}); + } + + public GT_MetaTileEntity_Hatch_Steam_BusInput(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Steam_BusInput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Steam_BusInput(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Steam Input Bus"); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + } + } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + if (disableSort) { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) + mInventory[i] = null; + } else { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; 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); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("disableSort", disableSort); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + disableSort = aNBT.getBoolean("disableSort"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + disableSort = !disableSort; + GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Automatic Item Shuffling: " + (disableSort ? "Disabled" : "Enabled"))); + } + } + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + } + + + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java new file mode 100644 index 0000000000..2fb3fea084 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Steam_BusOutput.java @@ -0,0 +1,175 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_2by2; +import gregtech.api.gui.GT_GUIContainer_2by2; +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.objects.GT_RenderedTexture; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Hatch_Steam_BusOutput extends GT_MetaTileEntity_Hatch { + public GT_MetaTileEntity_Hatch_Steam_BusOutput(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 4, new String[]{"Item Output for Steam Multiblocks", + "Capacity: 4 stacks", + "Does not work with non-steam multiblocks", + CORE.GT_Tooltip}); + } + + public GT_MetaTileEntity_Hatch_Steam_BusOutput(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Steam_BusOutput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Steam_BusOutput(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Steam Output Bus"); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE)}; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP)}; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM)}; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM : Textures.BlockIcons.MACHINE_BRONZE_BOTTOM), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP : Textures.BlockIcons.MACHINE_BRONZE_TOP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{new GT_RenderedTexture(mTier == 1 ? Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE : Textures.BlockIcons.MACHINE_BRONZE_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java new file mode 100644 index 0000000000..a9cd179214 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java @@ -0,0 +1,316 @@ +/* +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_1by1_Turbine; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_1by1_Turbine; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.turbine.LargeTurbineTextureHandler; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.GregtechMetaTileEntity_LargerTurbineBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { + + public boolean mHasController = false; + public boolean mUsingAnimation = true; + private String mControllerLocation; + + public GT_MetaTileEntity_Hatch_Turbine(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 16, "Turbine Rotor holder for XL Turbines"); + } + + public GT_MetaTileEntity_Hatch_Turbine(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_Turbine(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription[0], aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, getFrontFacingTurbineTexture()}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, getFrontFacingTurbineTexture()}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Turbine(mName, mTier, StaticFields59.getDescriptionArray(this), mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + //aBaseMetaTileEntity.openGUI(aPlayer); + PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Using Animations? "+usingAnimations()); + PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Has Controller? "+this.mHasController); + if (mHasController) { + PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Controller Location: "+BlockPos.generateBlockPos(mControllerLocation).getLocationString()); + PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Controller Active? "+this.isControllerActive()); + } + PlayerUtils.messagePlayer(aPlayer, "[Turbine Assembly Data] Is Active? "+this.getBaseMetaTileEntity().isActive()); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + default: + return new CONTAINER_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity); + } + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + switch (mTier) { + default: + return new GUI_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity, "Turbine Rotor Hatch"); + } + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mHasController", mHasController); + aNBT.setBoolean("mUsingAnimation", mUsingAnimation); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mHasController = aNBT.getBoolean("mHasController"); + mUsingAnimation = aNBT.getBoolean("mUsingAnimation"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + this.mUsingAnimation = Utils.invertBoolean(mUsingAnimation); + if (this.mUsingAnimation) { + PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture."); + } + PlayerUtils.messagePlayer(aPlayer, "Has Controller: "+this.mHasController); + if (mHasController) { + PlayerUtils.messagePlayer(aPlayer, "Controller Location: "+this.mControllerLocation); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.mHasController) { + if (aTick % 20 == 0) { + if (isControllerActive()) { + this.getBaseMetaTileEntity().setActive(true); + } + else { + this.getBaseMetaTileEntity().setActive(false); + } + } + } + else if (!this.mHasController && this.mControllerLocation != null) { + //Weird Invalid State + if (setController(BlockPos.generateBlockPos(mControllerLocation))) { + //Valid + } + } + else { + //No Controller + } + } + + public boolean isControllerActive() { + GregtechMetaTileEntity_LargerTurbineBase x = getController(); + if (x != null) { + Logger.INFO("Checking Status of Controller."); + return x.isMachineRunning(); + } + Logger.INFO("Status of Controller failed, controller is null."); + return false; + } + + public GregtechMetaTileEntity_LargerTurbineBase getController() { + if (this.mHasController && this.mControllerLocation != null && this.mControllerLocation.length() > 0) { + BlockPos p = BlockPos.generateBlockPos(mControllerLocation); + if (p != null) { + //Logger.INFO(p.getLocationString()); + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntity(p.xPos, p.yPos, + p.zPos); + if (tTileEntity != null && tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_LargerTurbineBase) { + return (GregtechMetaTileEntity_LargerTurbineBase) tTileEntity.getMetaTileEntity(); + } + else { + if (tTileEntity == null) { + Logger.INFO("Controller MTE is null, somehow?"); + } + else { + Logger.INFO("Controller is a different MTE to expected"); + } + } + } + } + //Logger.INFO("Failed to Get Controller."); + return null; + } + + public boolean canSetNewController() { + if ((mControllerLocation != null && mControllerLocation.length() > 0) || this.mHasController) { + return false; + } + return true; + } + + public boolean setController(BlockPos aPos) { + clearController(); + if (canSetNewController()) { + mControllerLocation = aPos.getUniqueIdentifier(); + mHasController = true; + Logger.INFO("Successfully injected controller into this Turbine Assembly Hatch."); + } + return mHasController; + } + + public void clearController() { + this.mControllerLocation = null; + this.mHasController = false; + } + + public boolean usingAnimations() { + return mUsingAnimation; + } + + private ITexture getFrontFacingTurbineTexture() { + if (!mHasController) { + return this.getBaseMetaTileEntity().isActive() ? new GT_RenderedTexture(LargeTurbineTextureHandler.frontFaceHPActive_4) : new GT_RenderedTexture(LargeTurbineTextureHandler.frontFace_4 ); + } + else { + if (usingAnimations()) { + if (isControllerActive()) { + return getController().frontFaceActive; + } + } + return getController().frontFace; + } + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int aSide) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + return false; + } + + @Override + public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, + float aZ) { + // TODO Auto-generated method stub + return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, + float aY, float aZ) { + //Do Super + boolean aSuper = super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + // Do Things + if (this.getBaseMetaTileEntity().isServerSide()) { + ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem != null) { + if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)) { + if (mControllerLocation != null && mControllerLocation.length() > 0) { + if (setController(BlockPos.generateBlockPos(mControllerLocation))) { + if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { + String tChat = "Trying to Reset linked Controller"; + IGregTechTileEntity g = this.getBaseMetaTileEntity(); + GT_Utility.sendChatToPlayer(aPlayer, tChat); + GT_Utility.sendSoundToPlayers(g.getWorld(), GregTech_API.sSoundList.get(101), 1.0F, -1, + g.getXCoord(), g.getYCoord(), g.getZCoord()); + } + } + } + } + } + } + return aSuper; + } + + public void setActive(boolean b) { + this.getBaseMetaTileEntity().setActive(b); + } + + + + + +}*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java new file mode 100644 index 0000000000..0b84f676f4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java @@ -0,0 +1,220 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_1by1_Turbine; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_1by1_Turbine; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +public class GT_MetaTileEntity_Hatch_TurbineProvider extends GT_MetaTileEntity_Hatch_InputBus { + + public GT_MetaTileEntity_Hatch_TurbineProvider(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_TurbineProvider(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_TurbineProvider(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription[0], aTextures); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_TurbineProvider(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity, "Turbine Housing"); + } + + @Override + public String[] getDescription() { + return new String[]{ + "An automation port for Large Turbines", + "Will attempt once per 1200 ticks to fill the turbine slot of it's parent turbine", + "You may adjust this with a screwdriver", + "Hold shift to adjust in finer amounts", + "Hold control to adjust direction", + "Left Click with Screwdriver to reset", + "This module assumes the entire turbine is in the same Chunk", + CORE.GT_Tooltip}; + } + + + private GT_MetaTileEntity_LargeTurbine mParent = null; + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + super.onPostTick(aBaseMetaTileEntity, aTimer); + if (aTimer % mRefreshTime == 0 && this.getBaseMetaTileEntity().isServerSide()) { + tryRefillTurbine(); + } + } + + private final void tryFindParentTurbine() { + Logger.INFO("This turbine housing has no parent, searching world."); + IGregTechTileEntity T = this.getBaseMetaTileEntity(); + World W = T.getWorld(); + Chunk C = W.getChunkFromBlockCoords(T.getXCoord(), T.getZCoord()); + for (Object o : C.chunkTileEntityMap.values()) { + if (o instanceof IGregTechTileEntity) { + IGregTechTileEntity G = (IGregTechTileEntity) o; + final IMetaTileEntity aMetaTileEntity = G.getMetaTileEntity(); + if (aMetaTileEntity == null) { + continue; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine) { + GT_MetaTileEntity_LargeTurbine aTurb = (GT_MetaTileEntity_LargeTurbine) aMetaTileEntity; + for (GT_MetaTileEntity_Hatch_InputBus ee : aTurb.mInputBusses) { + if (ee.equals(this)) { + mParent = aTurb; + Logger.INFO("Found a Parent to attach to this housing."); + return; + } + } + } + } + } + } + + private final void tryRefillTurbine() { + if (mParent == null) { + tryFindParentTurbine(); + } + if (mParent != null && mParent.mInventory[1] == null) { + for (ItemStack aStack : this.mInventory) { + if (isItemStackTurbine(aStack)) { + setGUIItemStack(aStack); + } + } + } + } + + protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { + boolean result = false; + if (mParent.mInventory[1] == null) { + mParent.mInventory[1] = aNewGuiSlotContents != null ? aNewGuiSlotContents.copy() : null; + mParent.depleteInput(aNewGuiSlotContents); + mParent.updateSlots(); + this.updateSlots(); + result = true; + } + return result; + } + + public boolean isItemStackTurbine(ItemStack aStack) { + if (aStack.getItem() instanceof GT_MetaGenerated_Tool) { + if (aStack.getItemDamage() >= 170 && aStack.getItemDamage() <= 176) { + return true; + } + } + return false; + } + + public boolean isItemStackScrewdriver(ItemStack aStack) { + if (aStack.getItem() instanceof GT_MetaGenerated_Tool) { + if (aStack.getItemDamage() == 22 || aStack.getItemDamage() == 150) { + return true; + } + } + return false; + } + + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return isItemStackTurbine(aStack); + } + + private int mRefreshTime = 1200; + private boolean mDescending = true; + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mRefreshTime", mRefreshTime); + aNBT.setBoolean("mDescending", mDescending); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mRefreshTime = aNBT.getInteger("mRefreshTime"); + mDescending = aNBT.getBoolean("mDescending"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer != null) { + if (KeyboardUtils.isCtrlKeyDown()) { + mDescending = Utils.invertBoolean(mDescending); + PlayerUtils.messagePlayer(aPlayer, "Direction: "+(mDescending ? "DOWN" : "UP")); + } + else { + int aAmount = 0; + if (KeyboardUtils.isShiftKeyDown()) { + aAmount = 10; + } + else { + aAmount = 100; + } + if (mDescending) { + mRefreshTime -= aAmount; + if (mRefreshTime < 0) { + mRefreshTime = 1200; + } + } + else { + mRefreshTime += aAmount; + if (mRefreshTime > 1200) { + mRefreshTime = 0; + } + } + PlayerUtils.messagePlayer(aPlayer, "Set check time to be every "+mRefreshTime+" ticks."); + } + } + } + + @Override + public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + boolean aDidScrewdriver = false; + if (aPlayer != null) { + if (aPlayer.getHeldItem() != null) { + if (isItemStackScrewdriver(aPlayer.getHeldItem())) { + aDidScrewdriver = true; + mRefreshTime = 1200; + PlayerUtils.messagePlayer(aPlayer, "Reset check time to "+mRefreshTime+" ticks."); + } + } + } + if (!aDidScrewdriver) { + super.onLeftclick(aBaseMetaTileEntity, aPlayer); + } + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java new file mode 100644 index 0000000000..b27cb95ca4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java @@ -0,0 +1,230 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.extensions.ArrayExt; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_InputBus { + public GT_MetaTileEntity_SuperBus_Input(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, getSlots(aTier)); + } + + public GT_MetaTileEntity_SuperBus_Input(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, getSlots(aTier), aDescription, aTextures); + } + + /** + * Returns a factor of 16 based on tier. + * + * @param aTier The tier of this bus. + * @return (1 + aTier) * 16 + */ + public static int getSlots(int aTier) { + return (1 + aTier) * 16; + } + + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE_IN)}; + } + + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(BlockIcons.OVERLAY_PIPE_IN)}; + } + + public boolean isSimpleMachine() { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return true; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_SuperBus_Input(this.mName, this.mTier, ArrayExt.of(this.mDescription), this.mTextures); + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + this.fillStacksIntoFirstSlots(); + } + + } + + public void updateSlots() { + for (int i = 0; i < this.mInventory.length; ++i) { + if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) { + this.mInventory[i] = null; + } + } + + this.fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < this.mInventory.length; ++i) { + for (int j = i + 1; j < this.mInventory.length; ++j) { + if (this.mInventory[j] != null && (this.mInventory[i] == null + || GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB((IInventory) this.getBaseMetaTileEntity(), (IInventory) this.getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing() + && (this.mRecipeMap == null || this.mRecipeMap.containsInput(aStack)); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public String[] getDescription() { + String[] aDesc = new String[] { + "Item Input for Multiblocks", + "This bus has no GUI, but can have items extracted", + ""+getSlots(this.mTier)+" Slots", + CORE.GT_Tooltip + }; + return aDesc; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, + float aY, float aZ) { + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + //Logger.INFO("Trying to display Super Input Bus contents."); + displayBusContents(aPlayer); + return true; + } + } + + public void displayBusContents(EntityPlayer aPlayer) { + String STRIP = "Item Array: "; + String aNameString = ItemUtils.getArrayStackNames(getRealInventory()); + aNameString = aNameString.replace(STRIP, ""); + + String[] aNames; + if (aNameString.length() < 1) { + aNames = null; + } + else { + aNames = aNameString.split(","); + } + + if (aNames == null || aNames.length <= 0) { + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) is Empty. Total Slots: "+getSlots(this.mTier)); + return; + } + + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (I) contains: ["+getRealInventory().length+"]"); + + if (aNames.length <= 12) { + for (String s : aNames) { + if (s.startsWith(" ")) { + s = s.substring(1); + } + //Logger.INFO("Trying to display Super Input Bus contents. "+s); + PlayerUtils.messagePlayer(aPlayer, s); + } + } + else { + + String superString = ""; + + for (String s : aNames) { + if (s.startsWith(" ")) { + s = s.substring(1); + } + superString += (s+", "); + } + PlayerUtils.messagePlayer(aPlayer, superString); + } + + + } + + @Override + public int getMaxItemCount() { + // TODO Auto-generated method stub + return super.getMaxItemCount(); + } + + @Override + public int getSizeInventory() { + // TODO Auto-generated method stub + return super.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int aIndex) { + // TODO Auto-generated method stub + return super.getStackInSlot(aIndex); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + // TODO Auto-generated method stub + return super.canInsertItem(aIndex, aStack, aSide); + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + // TODO Auto-generated method stub + return super.canExtractItem(aIndex, aStack, aSide); + } + + @Override + public ItemStack[] getRealInventory() { + // TODO Auto-generated method stub + return super.getRealInventory(); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java new file mode 100644 index 0000000000..37aa57298a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java @@ -0,0 +1,180 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.extensions.ArrayExt; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_OutputBus { + + public GT_MetaTileEntity_SuperBus_Output(int id, String name, String nameRegional, int tier) { + super(id, name, nameRegional, tier, getSlots(tier)); + } + + public GT_MetaTileEntity_SuperBus_Output(String name, int tier, String[] description, ITexture[][][] textures) { + super(name, tier, getSlots(tier), description, textures); + } + + /** + * Returns a factor of 16 based on tier. + * + * @param aTier The tier of this bus. + * @return (1 + aTier) * 16 + */ + public static int getSlots(int aTier) { + return (1 + aTier) * 16; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_SuperBus_Output(this.mName, this.mTier, ArrayExt.of(this.mDescription), this.mTextures); + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + this.fillStacksIntoFirstSlots(); + } + super.onPostTick(aBaseMetaTileEntity, aTimer); + } + + public void updateSlots() { + for (int i = 0; i < this.mInventory.length; ++i) { + if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) { + this.mInventory[i] = null; + } + } + this.fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < this.mInventory.length; ++i) { + for (int j = i + 1; j < this.mInventory.length; ++j) { + if (this.mInventory[j] != null && (this.mInventory[i] == null + || GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB((IInventory) this.getBaseMetaTileEntity(), (IInventory) this.getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public String[] getDescription() { + String[] aDesc = new String[] { + "Item Output for Multiblocks", + "This bus has no GUI", + ""+getSlots(this.mTier)+" Slots", + CORE.GT_Tooltip + }; + return aDesc; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, + float aY, float aZ) { + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + displayBusContents(aPlayer); + return true; + } + } + + public void displayBusContents(EntityPlayer aPlayer) { + String STRIP = "Item Array: "; + String aNameString = ItemUtils.getArrayStackNames(getRealInventory()); + aNameString = aNameString.replace(STRIP, ""); + + String[] aNames; + if (aNameString.length() < 1) { + aNames = null; + } + else { + aNames = aNameString.split(","); + } + + if (aNames == null || aNames.length <= 0) { + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) is Empty. Total Slots: "+getSlots(this.mTier)); + return; + } + + PlayerUtils.messagePlayer(aPlayer, "This Super Bus (O) contains:"); + for (String s : aNames) { + if (s.startsWith(" ")) { + s = s.substring(1); + } + //Logger.INFO("Trying to display Super Output Bus contents. "+s); + PlayerUtils.messagePlayer(aPlayer, s); + } + } + + @Override + public int getMaxItemCount() { + // TODO Auto-generated method stub + return super.getMaxItemCount(); + } + + @Override + public int getSizeInventory() { + // TODO Auto-generated method stub + return super.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int aIndex) { + // TODO Auto-generated method stub + return super.getStackInSlot(aIndex); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + // TODO Auto-generated method stub + return super.canInsertItem(aIndex, aStack, aSide); + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + // TODO Auto-generated method stub + return super.canExtractItem(aIndex, aStack, aSide); + } + + @Override + public ItemStack[] getRealInventory() { + // TODO Auto-generated method stub + return super.getRealInventory(); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java new file mode 100644 index 0000000000..f6e778f989 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java @@ -0,0 +1,119 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; +import gregtech.api.render.TextureFactory; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.util.EnumChatFormatting; + +public class GregtechMetaPipeEntityFluid extends GT_MetaPipeEntity_Fluid { + + + public static final boolean mGt6Pipe; + + static { + mGt6Pipe = StaticFields59.mGT6StylePipes; + } + + public final GT_Materials mMaterial; + private boolean mCheckConnections; + + + public GregtechMetaPipeEntityFluid(int aID, String aName, String aNameRegional, float aThickNess, GT_Materials aMaterial, + int aCapacity, int aHeatResistance, boolean aGasProof) { + this(aID, aName, aNameRegional, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1); + } + + public GregtechMetaPipeEntityFluid(final String aName, final float aThickNess, final GT_Materials aMaterial, final int aCapacity, final int aHeatResistance, final boolean aGasProof) { + this(aName, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1); + } + + public GregtechMetaPipeEntityFluid(int aID, String aName, String aNameRegional, float aThickNess, GT_Materials aMaterial, + int aCapacity, int aHeatResistance, boolean aGasProof, int aFluidTypes) { + super(aID, aName, aNameRegional, aThickNess, null, aCapacity, aHeatResistance, aGasProof); + this.mLastReceivedFrom = 0; + this.oLastReceivedFrom = 0; + this.mCheckConnections = !mGt6Pipe; + this.mMaterial = aMaterial; + } + + + + public GregtechMetaPipeEntityFluid(String aName, float aThickNess, GT_Materials aMaterial, int aCapacity, + int aHeatResistance, boolean aGasProof, int aFluidTypes) { + super(aName, aThickNess, null, aCapacity, aHeatResistance, aGasProof); + this.mLastReceivedFrom = 0; + this.oLastReceivedFrom = 0; + this.mCheckConnections = !mGt6Pipe; + this.mMaterial = aMaterial; + } + + + @Override + public byte getTileEntityBaseType() { + return this.mMaterial == null ? 4 : (byte) ((this.mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, this.mMaterial.mToolQuality))); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPipeEntityFluid(this.mName, this.mThickNess, this.mMaterial, this.mCapacity, this.mHeatResistance, this.mGasProof); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { + float tThickNess = getThickNess(); + if (mDisableInput == 0) + return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; + byte tMask = 0; + byte[][] sRestrictionArray = { + {2, 3, 5, 4}, + {2, 3, 4, 5}, + {1, 0, 4, 5}, + {1, 0, 4, 5}, + {1, 0, 2, 3}, + {1, 0, 2, 3} + }; + if (aSide >= 0 && aSide < 6) { + for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; + //Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate + if (aSide == 5 || aSide == 2) + if (tMask > 3 && tMask < 12) + tMask = (byte) (tMask ^ 12); + } + return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), getRestrictorTexture(tMask)}; + } + + protected static ITexture getBaseTexture(float aThickNess, int aPipeAmount, GT_Materials aMaterial, byte aColorIndex) { + if (aPipeAmount >= 9) + return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeNonuple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aPipeAmount >= 4) + return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeQuadruple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.124F) + return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.374F) + return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.499F) + return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.749F) + return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + if (aThickNess < 0.874F) + return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + } + + @Override + public String[] getDescription() { + return new String[]{ + EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + (mCapacity * 20) + "%%% L/sec" + EnumChatFormatting.GRAY, + EnumChatFormatting.RED + "Heat Limit: %%%" + mHeatResistance + "%%% K" + EnumChatFormatting.GRAY, + EnumChatFormatting.DARK_GREEN + "Gas Proof: " + (this.mGasProof) + EnumChatFormatting.GRAY, + //CORE.GT_Tooltip + }; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java new file mode 100644 index 0000000000..98722a2b96 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntity_Cable.java @@ -0,0 +1,165 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.VN; +import static gtPlusPlus.core.lib.CORE.GTNH; + +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.enums.*; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.metatileentity.IMetaTileEntityCable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.lib.CORE; + +public class GregtechMetaPipeEntity_Cable extends GT_MetaPipeEntity_Cable implements IMetaTileEntityCable { + private static Textures.BlockIcons INSULATION_MEDIUM_PLUS; + static{ + if(GTNH) { + try { + INSULATION_MEDIUM_PLUS = (Textures.BlockIcons) GT_Utility.getField(Textures.BlockIcons.class, "INSULATION_MEDIUM_PLUS").get(null); + } catch (IllegalAccessException | NullPointerException e) { + throw new Error(e); + } + } + } + + private short[] vRGB = null; + + public GregtechMetaPipeEntity_Cable(final int aID, final String aName, final String aNameRegional, final float aThickNess, final Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock, final short[] aRGB) { + super(aID, aName, aNameRegional, aThickNess, aMaterial, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock); + this.vRGB = aRGB==null || aRGB.length!=4?Materials.Iron.mRGBa:aRGB; + } + + public GregtechMetaPipeEntity_Cable(final String aName, final float aThickNess, final Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock, final short[] aRGB) { + super(aName, aThickNess, aMaterial, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock); + this.vRGB = aRGB==null || aRGB.length!=4?Materials.Iron.mRGBa:aRGB; + } + + public GregtechMetaPipeEntity_Cable(final int aID, final String aName, final String aNameRegional, final float aThickNess, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock, final short[] aRGB) { + this(aID, aName, aNameRegional, aThickNess, null, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock,aRGB); + } + + public GregtechMetaPipeEntity_Cable(final String aName, final float aThickNess, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock, final short[] aRGB) { + this(aName, aThickNess, null, aCableLossPerMeter, aAmperage, aVoltage, aInsulated, aCanShock,aRGB); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPipeEntity_Cable(this.mName, this.mThickNess, this.mMaterial, this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock, this.vRGB); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Max Voltage: %%%" + EnumChatFormatting.GREEN + mVoltage + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY, + "Max Amperage: %%%" + EnumChatFormatting.YELLOW + mAmperage + EnumChatFormatting.GRAY, + "Loss/Meter/Ampere: %%%" + EnumChatFormatting.RED + mCableLossPerMeter + EnumChatFormatting.GRAY + "%%% EU-Volt", + //CORE.GT_Tooltip + }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { + return GTNH? + getTextureGTNH(aBaseMetaTileEntity,aSide,aConnections,aColorIndex,aConnected,aRedstone): + getTexturePure(aBaseMetaTileEntity,aSide,aConnections,aColorIndex,aConnected,aRedstone); + } + + private ITexture[] getTextureGTNH(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, + byte aColorIndex, boolean aConnected, boolean aRedstone) { + + Materials wireMaterial=mMaterial; + if (wireMaterial == null){ + wireMaterial = Materials.Iron; + } + + if (!mInsulated) + return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(aColorIndex, vRGB) )}; + if (aConnected) { + float tThickNess = getThickNess(); + if (tThickNess < 0.124F) + return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + if (tThickNess < 0.374F)//0.375 x1 + return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + if (tThickNess < 0.499F)//0.500 x2 + return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + if (tThickNess < 0.624F)//0.625 x4 + return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + if (tThickNess < 0.749F)//0.750 x8 + return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(INSULATION_MEDIUM_PLUS, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + if (tThickNess < 0.874F)//0.825 x12 + return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[]{new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], vRGB), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + } + return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + } + + private ITexture[] getTexturePure(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, + byte aColorIndex, boolean aConnected, boolean aRedstone) { + + //if (this.vRGB == null || this.vRGB.length < 3 || this.vRGB.length > 4){ + // this.vRGB = new short[]{200, 0, 200, 0}; + //} + //if (this.vRGB.length != 4){ + // short[] tempRGB = this.vRGB; + // this.vRGB = new short[]{tempRGB[0], tempRGB[1], tempRGB[2], 0}; + //} + // + //Materials wireMaterial = this.mMaterial; + // + //if (wireMaterial == null){ + // wireMaterial = Materials.Iron; + //} + + //With the code in constructors it should work + Materials wireMaterial=mMaterial; + if (wireMaterial == null){ + wireMaterial = Materials.Iron; + } + + if (!(this.mInsulated)) + return new ITexture[] { new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], + Dyes.getModulation(aColorIndex, this.vRGB)) }; + if (aConnected) { + float tThickNess = getThickNess(); + if (tThickNess < 0.124F) + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + if (tThickNess < 0.374F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + if (tThickNess < 0.499F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + if (tThickNess < 0.624F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + if (tThickNess < 0.749F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + if (tThickNess < 0.874F) + return new ITexture[] { + new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + return new ITexture[] { new GT_RenderedTexture(wireMaterial.mIconSet.mTextures[69], this.vRGB), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + } + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaTreeFarmerStructural.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaTreeFarmerStructural.java new file mode 100644 index 0000000000..d05a254bf7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaTreeFarmerStructural.java @@ -0,0 +1,56 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import net.minecraft.nbt.NBTTagCompound; + +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 gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaTreeFarmerBase; + +public class GregtechMetaTreeFarmerStructural +extends GregtechMetaTreeFarmerBase { + + @Override + public String[] getDescription() { + return new String[] {this.mDescription}; + } + + public GregtechMetaTreeFarmerStructural(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 0, "Structural Blocks for the Tree Farmer."); + } + + public GregtechMetaTreeFarmerStructural(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GregtechMetaTreeFarmerStructural(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTreeFarmerStructural(this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures); + } + + @Override + public ITexture getOverlayIcon() { + return new GT_RenderedTexture(Textures.BlockIcons.VOID); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound paramNBTTagCompound) { + } + + @Override + public void loadNBTData(final NBTTagCompound paramNBTTagCompound) { + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java new file mode 100644 index 0000000000..422837fa46 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/CustomMetaTileBase.java @@ -0,0 +1,60 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; + +import java.util.Locale; + +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import net.minecraft.item.ItemStack; + +public abstract class CustomMetaTileBase extends MetaTileEntity { + + public CustomMetaTileBase(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { + super(aID, aBasicName, aRegionalName, aInvSlotCount); + GT_LanguageManager.addStringLocalization("gtpp.blockmachines." + aBasicName.replaceAll(" ", "_").toLowerCase(Locale.ENGLISH) + ".name", aRegionalName); + this.setBaseMetaTileEntity(Meta_GT_Proxy.constructBaseMetaTileEntity()); + this.getBaseMetaTileEntity().setMetaTileID((short) aID); + } + + public CustomMetaTileBase(String aName, int aInvSlotCount) { + super(aName, aInvSlotCount); + } + + public ItemStack getStackForm(long aAmount) { + return new ItemStack(Meta_GT_Proxy.sBlockMachines, (int) aAmount, this.getBaseMetaTileEntity().getMetaTileID()); + } + + public String getLocalName() { + return GT_LanguageManager.getTranslation("gtpp.blockmachines." + this.mName + ".name"); + } + + /** + * This determines the BaseMetaTileEntity belonging to this MetaTileEntity by using the Meta ID of the Block itself. + * <p/> + * 0 = BaseMetaTileEntity, Wrench lvl 0 to dismantlee + * 1 = BaseMetaTileEntity, Wrench lvl 1 to dismantle + * 2 = BaseMetaTileEntity, Wrench lvl 2 to dismantle + * 3 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + * 4 = BaseMetaPipeEntity, Wrench lvl 0 to dismantle + * 5 = BaseMetaPipeEntity, Wrench lvl 1 to dismantle + * 6 = BaseMetaPipeEntity, Wrench lvl 2 to dismantle + * 7 = BaseMetaPipeEntity, Wrench lvl 3 to dismantle + * 8 = BaseMetaPipeEntity, Cutter lvl 0 to dismantle + * 9 = BaseMetaPipeEntity, Cutter lvl 1 to dismantle + * 10 = BaseMetaPipeEntity, Cutter lvl 2 to dismantle + * 11 = BaseMetaPipeEntity, Cutter lvl 3 to dismantle + * + * == Reserved for Alk now + * + * 12 = BaseMetaPipeEntity, Wrench lvl 0 to dismantle + * 13 = BaseMetaPipeEntity, Wrench lvl 1 to dismantle + * 14 = BaseMetaPipeEntity, Wrench lvl 2 to dismantle + * 15 = BaseMetaPipeEntity, Wrench lvl 3 to dismantle + */ + @Override + public byte getTileEntityBaseType() { + return 12; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java new file mode 100644 index 0000000000..124f8695f5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MetaTileEntity_Hatch_CustomFluidBase.java @@ -0,0 +1,131 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; + +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; + +public class GT_MetaTileEntity_Hatch_CustomFluidBase extends GT_MetaTileEntity_Hatch_Input { + + public final Fluid mLockedFluid; + public final int mFluidCapacity; + + public GT_MetaTileEntity_Hatch_CustomFluidBase(Fluid aFluid, int aAmount, final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 6); + this.mRecipeMap = null; + this.mLockedFluid = aFluid; + this.mFluidCapacity = aAmount; + } + + public GT_MetaTileEntity_Hatch_CustomFluidBase(Fluid aFluid, int aAmount, final String aName, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, 6, aDescription, aTextures); + this.mRecipeMap = null; + this.mLockedFluid = aFluid; + this.mFluidCapacity = aAmount; + } + + public GT_MetaTileEntity_Hatch_CustomFluidBase(Fluid aFluid, int aAmount, final String aName, final String[] aDescription, final ITexture[][][] aTextures) { + super(aName, 6, aDescription[0], aTextures); + this.mRecipeMap = null; + this.mLockedFluid = aFluid; + this.mFluidCapacity = aAmount; + } + + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { + if (this.mRecipeMap == null) + return true; + FluidStack fs = GT_Utility.getFluidForFilledItem(aStack, true); + if (fs != null && fs.getFluid() == this.mLockedFluid) + return true; + } + return false; + } + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_PUMP)}; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, + new GT_RenderedTexture((IIconContainer) Textures.BlockIcons.OVERLAY_PUMP)}; + } + + public int getCapacity() { + return this.mFluidCapacity; + } + + protected FluidStack mLockedStack = null; + protected Integer mLockedTemp = null; + protected String mTempMod = null; + + @Override + public String[] getDescription() { + if (mLockedStack == null) { + mLockedStack = FluidUtils.getFluidStack(mLockedFluid, 1); + } + int aFluidTemp = 0; + boolean isSteam = false; + if (mLockedFluid != null) { + aFluidTemp = mLockedFluid.getTemperature(); + mTempMod = mLockedFluid.getName(); + } + if (mTempMod.toLowerCase().equals("steam")) { + isSteam = true; + } + + + EnumChatFormatting aColour = EnumChatFormatting.BLUE; + if (aFluidTemp <= -3000) { + aColour = EnumChatFormatting.DARK_PURPLE; + } + else if (aFluidTemp >= -2999 && aFluidTemp <= -500) { + aColour = EnumChatFormatting.DARK_BLUE; + } + else if (aFluidTemp >= -499 && aFluidTemp <= -50) { + aColour = EnumChatFormatting.BLUE; + } + else if (aFluidTemp >= 30 && aFluidTemp <= 300) { + aColour = EnumChatFormatting.AQUA; + } + else if (aFluidTemp >= 301 && aFluidTemp <= 800) { + aColour = EnumChatFormatting.YELLOW; + } + else if (aFluidTemp >= 801 && aFluidTemp <= 1500) { + aColour = EnumChatFormatting.GOLD; + } + else if (aFluidTemp >= 1501) { + aColour = EnumChatFormatting.RED; + } + String aFluidName = "Accepted Fluid: " + aColour + (mLockedStack != null ? mLockedStack.getLocalizedName() : "Empty") + EnumChatFormatting.RESET; + String[] s2 = new String[]{ + "Fluid Input for "+(isSteam ? "Steam " : "")+"Multiblocks", + "Capacity: " + getCapacity()+"L", + aFluidName, + CORE.GT_Tooltip + }; + return s2; + } + + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return aFluid.getFluid() == this.mLockedFluid; + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (MetaTileEntity) new GT_MetaTileEntity_Hatch_CustomFluidBase(this.mLockedFluid, this.mFluidCapacity, this.mName, this.mDescription, this.mTextures); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java new file mode 100644 index 0000000000..4dd5bf25d6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java @@ -0,0 +1,468 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; + +import static gregtech.api.enums.GT_Values.VN; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; + +import cofh.api.energy.IEnergyReceiver; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.metatileentity.IMetaTileEntityCable; +import gregtech.api.interfaces.tileentity.IColoredTileEntity; +import gregtech.api.interfaces.tileentity.IEnergyConnected; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Proxy; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import ic2.api.energy.tile.IEnergySink; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements IMetaTileEntityCable { + public final float mThickNess; + public final GT_Materials mMaterial; + public final long mCableLossPerMeter, mAmperage, mVoltage; + public final boolean mInsulated, mCanShock; + public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0; + public long mRestRF; + public short mOverheat; + public final int mWireHeatingTicks; + + public GregtechMetaPipeEntityBase_Cable(final int aID, final String aName, final String aNameRegional, + final float aThickNess, final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, + final long aVoltage, final boolean aInsulated, final boolean aCanShock) { + super(aID, aName, aNameRegional, 0); + this.mThickNess = aThickNess; + this.mMaterial = aMaterial; + this.mAmperage = aAmperage; + this.mVoltage = aVoltage; + this.mInsulated = aInsulated; + this.mCanShock = aCanShock; + this.mCableLossPerMeter = aCableLossPerMeter; + this.mWireHeatingTicks = this.getGT5Var(); + } + + public GregtechMetaPipeEntityBase_Cable(final String aName, final float aThickNess, final GT_Materials aMaterial, + final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, + final boolean aCanShock) { + super(aName, 0); + this.mThickNess = aThickNess; + this.mMaterial = aMaterial; + this.mAmperage = aAmperage; + this.mVoltage = aVoltage; + this.mInsulated = aInsulated; + this.mCanShock = aCanShock; + this.mCableLossPerMeter = aCableLossPerMeter; + this.mWireHeatingTicks = this.getGT5Var(); + } + + private int getGT5Var() { + final Class<? extends GT_Proxy> clazz = GT_Mod.gregtechproxy.getClass(); + final String lookingForValue = "mWireHeatingTicks"; + int temp = 4; + Field field; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + field = clazz.getClass().getField(lookingForValue); + final Class<?> clazzType = field.getType(); + if (clazzType.toString().equals("int")) { + temp = (field.getInt(clazz)); + } else { + temp = 4; + } + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + // Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES + // - PLEASE REPORT THIS."); + Logger.WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + Logger.ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + temp = 4; + } + } + return temp; + } + + @Override + public byte getTileEntityBaseType() { + return (byte) (this.mInsulated ? 9 : 8); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPipeEntityBase_Cable(this.mName, this.mThickNess, this.mMaterial, + this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, + final byte aConnections, final byte aColorIndex, final boolean aConnected, final boolean aRedstone) { + if (!this.mInsulated) { + return new ITexture[] { new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa) }; + } + if (aConnected) { + final float tThickNess = this.getThickNess(); + if (tThickNess < 0.37F) { + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + } + if (tThickNess < 0.49F) { + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + } + if (tThickNess < 0.74F) { + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + } + if (tThickNess < 0.99F) { + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + } + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + } + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; + } + + @Override + public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ, + final Entity aEntity) { + if (this.mCanShock && ((((BaseMetaPipeEntity) this.getBaseMetaTileEntity()).mConnections & -128) == 0) + && (aEntity instanceof EntityLivingBase)) { + GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, this.mTransferredVoltageLast20, + this.mTransferredAmperageLast20); + } + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(final World aWorld, final int aX, final int aY, final int aZ) { + if (!this.mCanShock) { + return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, + aZ + 0.875D); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public final boolean renderInside(final byte aSide) { + return false; + } + + @Override + public int getProgresstime() { + return (int) this.mTransferredAmperage * 64; + } + + @Override + public int maxProgresstime() { + return (int) this.mAmperage * 64; + } + + @Override + public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { + if (!this.getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, + this.getBaseMetaTileEntity().getCoverIDAtSide(aSide), + this.getBaseMetaTileEntity().getCoverDataAtSide(aSide), this.getBaseMetaTileEntity())) { + return 0; + } + return this.transferElectricity(aSide, aVoltage, aAmperage, + new ArrayList<>(Arrays.asList((TileEntity) this.getBaseMetaTileEntity()))); + } + + + /** + * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d + */ + public long transferElectricity(byte arg0, long arg1, long arg2, HashSet<TileEntity> arg3) { + ArrayList<TileEntity> aTiles = new ArrayList<TileEntity>(); + for (TileEntity y : arg3) { + aTiles.add(y); + } + return transferElectricity(arg0, arg1, arg2, aTiles); + } + + @Override + public long transferElectricity(final byte aSide, long aVoltage, final long aAmperage, + final ArrayList<TileEntity> aAlreadyPassedTileEntityList) { + long rUsedAmperes = 0; + aVoltage -= this.mCableLossPerMeter; + if (aVoltage > 0) { + for (byte i = 0; (i < 6) && (aAmperage > rUsedAmperes); i++) { + if ((i != aSide) && ((this.mConnections & (1 << i)) != 0) + && this.getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, + this.getBaseMetaTileEntity().getCoverIDAtSide(i), + this.getBaseMetaTileEntity().getCoverDataAtSide(i), this.getBaseMetaTileEntity())) { + final TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide(i); + if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) { + aAlreadyPassedTileEntityList.add(tTileEntity); + if (tTileEntity instanceof IEnergyConnected) { + if (this.getBaseMetaTileEntity().getColorization() >= 0) { + final byte tColor = ((IEnergyConnected) tTileEntity).getColorization(); + if ((tColor >= 0) && (tColor != this.getBaseMetaTileEntity().getColorization())) { + continue; + } + } + if ((tTileEntity instanceof IGregTechTileEntity) + && (((IGregTechTileEntity) tTileEntity) + .getMetaTileEntity() instanceof IMetaTileEntityCable) + && ((IGregTechTileEntity) tTileEntity) + .getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)) + .letsEnergyIn(GT_Utility.getOppositeSide(i), + ((IGregTechTileEntity) tTileEntity) + .getCoverIDAtSide(GT_Utility.getOppositeSide(i)), + ((IGregTechTileEntity) tTileEntity) + .getCoverDataAtSide(GT_Utility.getOppositeSide(i)), + ((IGregTechTileEntity) tTileEntity))) { + if (((IGregTechTileEntity) tTileEntity).getTimer() > 50) { + rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity) + .getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i), + aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedTileEntityList); + } + } else { + rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits( + GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes); + } + // } else if (tTileEntity instanceof IEnergySink) { + // ForgeDirection tDirection = + // ForgeDirection.getOrientation(i).getOpposite(); + // if + // (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), + // tDirection)) { + // if + // (((IEnergySink)tTileEntity).demandedEnergyUnits() + // > 0 && + // ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, + // aVoltage) < aVoltage) rUsedAmperes++; + // } + } else if (tTileEntity instanceof IEnergySink) { + final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); + if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) this.getBaseMetaTileEntity(), + tDirection)) { + if ((((IEnergySink) tTileEntity).getDemandedEnergy() > 0) + && (((IEnergySink) tTileEntity).injectEnergy(tDirection, aVoltage, + aVoltage) < aVoltage)) { + rUsedAmperes++; + } + } + } else if (GregTech_API.mOutputRF && (tTileEntity instanceof IEnergyReceiver)) { + final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); + final int rfOut = (int) ((aVoltage * GregTech_API.mEUtoRF) / 100); + if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) { + ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); + rUsedAmperes++; + } else if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) > 0) { + if (this.mRestRF == 0) { + final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, + false); + rUsedAmperes++; + this.mRestRF = rfOut - RFtrans; + } else { + final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, + (int) this.mRestRF, false); + this.mRestRF = this.mRestRF - RFtrans; + } + } + if (GregTech_API.mRFExplosions && (((IEnergyReceiver) tTileEntity) + .getMaxEnergyStored(tDirection) < (rfOut * 600))) { + if (rfOut > ((32 * GregTech_API.mEUtoRF) / 100)) { + this.doExplosion(rfOut); + } + } + } + } + } + } + } + + this.mTransferredAmperage += rUsedAmperes; + this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage); + this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage); + + if ((aVoltage > this.mVoltage) || (this.mTransferredAmperage > this.mAmperage)) { + // GT 5.09 + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (this.mOverheat > (this.mWireHeatingTicks * 100)) { + this.getBaseMetaTileEntity().setToFire(); + } else { + this.mOverheat += 100; + } + return aAmperage; + } + // GT 5.08 + else { + this.getBaseMetaTileEntity().setToFire(); + return aAmperage; + } + } + + return rUsedAmperes; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + this.mTransferredAmperage = 0; + if (this.mOverheat > 0) { + this.mOverheat--; + } + + if ((aTick % 20) == 0) { + this.mTransferredVoltageLast20 = 0; + this.mTransferredAmperageLast20 = 0; + this.mConnections = 0; + for (byte i = 0, j = 0; i < 6; i++) { + j = GT_Utility.getOppositeSide(i); + if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, + aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), + aBaseMetaTileEntity) + || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i, + aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), + aBaseMetaTileEntity) + || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i, + aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), + aBaseMetaTileEntity)) { + final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); + if (tTileEntity instanceof IColoredTileEntity) { + if (aBaseMetaTileEntity.getColorization() >= 0) { + final byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); + if ((tColor >= 0) && (tColor != aBaseMetaTileEntity.getColorization())) { + continue; + } + } + } + if ((tTileEntity instanceof IEnergyConnected) + && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j) + || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) { + this.mConnections |= (1 << i); + continue; + } + if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity) + .getMetaTileEntity() instanceof IMetaTileEntityCable)) { + if (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, + ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), + ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), + ((IGregTechTileEntity) tTileEntity)) + || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j, + ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), + ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), + ((IGregTechTileEntity) tTileEntity)) + || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j, + ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), + ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), + ((IGregTechTileEntity) tTileEntity))) { + this.mConnections |= (1 << i); + continue; + } + } + if ((tTileEntity instanceof IEnergySink) && ((IEnergySink) tTileEntity).acceptsEnergyFrom( + (TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { + this.mConnections |= (1 << i); + continue; + } + if (GregTech_API.mOutputRF && (tTileEntity instanceof IEnergyReceiver) + && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) { + this.mConnections |= (1 << i); + continue; + } + /* + * if (tTileEntity instanceof IEnergyEmitter && + * ((IEnergyEmitter)tTileEntity).emitsEnergyTo(( + * TileEntity)aBaseMetaTileEntity, + * ForgeDirection.getOrientation(j))) { mConnections |= + * (1<<i); continue; } + */ + } + } + } + } + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + @Override + public String[] getDescription() { + return new String[] { + "Max Voltage: " + EnumChatFormatting.GREEN + this.mVoltage + " (" + + VN[GT_Utility.getTier(this.mVoltage)] + ")" + EnumChatFormatting.GRAY, + "Max Amperage: " + EnumChatFormatting.YELLOW + this.mAmperage + EnumChatFormatting.GRAY, + "Loss/Meter/Ampere: " + EnumChatFormatting.RED + this.mCableLossPerMeter + EnumChatFormatting.GRAY + + " EU-Volt" }; + } + + @Override + public float getThickNess() { + return this.mThickNess; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + // + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + // + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java new file mode 100644 index 0000000000..c9201471a4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTileEntity.java @@ -0,0 +1,77 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; + +import static gregtech.api.enums.GT_Values.GT; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.metatileentity.MetaTileEntity; + +import gtPlusPlus.core.lib.CORE; + +public abstract class GregtechMetaTileEntity extends MetaTileEntity { + /** + * Value between [0 - 9] to describe the Tier of this Machine. + */ + protected byte mTier; + + /** + * A simple Description. + */ + protected final String mDescription; + + /** + * Contains all Textures used by this Block. + */ + public final ITexture[][][] mTextures; + + public GregtechMetaTileEntity(final int aID, final String aName, final String aNameRegional, final int aTier, + final int aInvSlotCount, final String aDescription, final ITexture... aTextures) { + super(aID, aName, aNameRegional, aInvSlotCount); + this.mTier = (byte) Math.max(0, Math.min(aTier, 9)); + this.mDescription = aDescription; + + // must always be the last call! + if (GT.isClientSide()) { + this.mTextures = this.getTextureSet(aTextures); + } else { + this.mTextures = null; + } + } + + public GregtechMetaTileEntity(final String aName, final int aTier, final int aInvSlotCount, + final String aDescription, final ITexture[][][] aTextures) { + super(aName, aInvSlotCount); + this.mTier = (byte) aTier; + this.mDescription = aDescription; + this.mTextures = aTextures; + + } + + @Override + public byte getTileEntityBaseType() { + return (byte) (Math.min(3, this.mTier <= 0 ? 0 : 1 + ((this.mTier - 1) / 4))); + } + + @Override + public long getInputTier() { + return this.mTier; + } + + @Override + public long getOutputTier() { + return this.mTier; + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription }; + } + + /** + * Used Client Side to get a Texture Set for this Block. Called after + * setting the Tier and the Description so that those two are accessible. + * + * @param aTextures + * is the optional Array you can give to the Constructor. + */ + public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java new file mode 100644 index 0000000000..768a57f8b2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaTransformerHiAmp.java @@ -0,0 +1,115 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +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_Transformer; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class GregtechMetaTransformerHiAmp extends GT_MetaTileEntity_Transformer { + + private boolean mHalfMode = false; + + public GregtechMetaTransformerHiAmp(int aID, String aName, String aNameRegional, int aTier, String aDescription) { + super(aID, aName, aNameRegional, aTier, aDescription); + } + + public GregtechMetaTransformerHiAmp(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public long maxEUStore() { + return ((512L + gregtech.api.enums.GT_Values.V[(this.mTier + 1)] * 2L) * 8); + } + + @Override + public long maxAmperesOut() { + if (this.mHalfMode) { + return ((getBaseMetaTileEntity().isAllowedToWork()) ? 8L : 2L); + } + return ((getBaseMetaTileEntity().isAllowedToWork()) ? 16L : 4L); + } + + @Override + public long maxAmperesIn() { + if (this.mHalfMode) { + return ((getBaseMetaTileEntity().isAllowedToWork()) ? 2L : 8L); + } + return ((getBaseMetaTileEntity().isAllowedToWork()) ? 4L : 16L); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[12][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; + rTextures[1][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; + rTextures[2][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; + rTextures[3][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier + 1] }; + rTextures[4][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier + 1] }; + rTextures[5][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier + 1] }; + rTextures[6][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] }; + rTextures[7][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] }; + rTextures[8][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] }; + rTextures[9][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier + 1] }; + rTextures[10][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier + 1] }; + rTextures[11][i + 1] = new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier + 1] }; + } + return rTextures; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTransformerHiAmp(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, + "Accepts 4A and outputs 16A", + CORE.GT_Tooltip}; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mHalfMode", this.mHalfMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mHalfMode = aNBT.getBoolean("mHalfMode"); + super.loadNBTData(aNBT); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + this.mHalfMode = Utils.invertBoolean(mHalfMode); + if (this.mHalfMode) { + PlayerUtils.messagePlayer(aPlayer, "Transformer is now running at 2A:8A in/out Ratio."); + } else { + + PlayerUtils.messagePlayer(aPlayer, "Transformer is now running at 4A:16A in/out Ratio."); + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java new file mode 100644 index 0000000000..356f96f7cc --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -0,0 +1,2678 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.gui.GT_Container_MultiMachine; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.*; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.CORE_Preloader; +import gtPlusPlus.preloader.asm.AsmConfig; +import gtPlusPlus.xmod.gregtech.api.gui.*; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_AirIntake; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ControlCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusInput; +import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.apache.commons.lang3.ArrayUtils; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.function.BiConsumer; +import java.util.function.BiPredicate; +import java.util.function.Function; + +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +// Glee8e - 11/12/21 - 2:15pm +// Yeah, now I see what's wrong. Someone inherited from GregtechMeta_MultiBlockBase instead of GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_IndustrialDehydrator> as it should have been +// so any method in GregtechMetaTileEntity_IndustrialDehydrator would see generic field declared in GregtechMeta_MultiBlockBase without generic parameter + +public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_EnhancedMultiBlockBase<T>> extends GT_MetaTileEntity_EnhancedMultiBlockBase<T> { + + public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; + + static { + + Method a08 = findRecipe08 = ReflectionUtils.getMethod(GT_Recipe_Map.class, "findRecipe", IHasWorldObjectAndCoords.class, GT_Recipe.class, boolean.class, long.class, FluidStack[].class, ItemStack.class, ItemStack[].class); + Method a09 = findRecipe09 = ReflectionUtils.getMethod(GT_Recipe_Map.class, "findRecipe", IHasWorldObjectAndCoords.class, GT_Recipe.class, boolean.class, boolean.class, long.class, FluidStack[].class, ItemStack.class, ItemStack[].class); + Logger.MACHINE_INFO("Found .08 findRecipe method? "+(a08 != null)); + Logger.MACHINE_INFO("Found .09 findRecipe method? "+(a09 != null)); + + try { + calculatePollutionReduction = GT_MetaTileEntity_Hatch_Muffler.class.getDeclaredMethod("calculatePollutionReduction", int.class); + } + catch (NoSuchMethodException | SecurityException e) {} + + } + + //Find Recipe Methods + private static final Method findRecipe08; + private static final Method findRecipe09; + + public GT_Recipe mLastRecipe; + private MultiblockRequirements mRequirements; + private boolean mInternalCircuit = false; + protected long mTotalRunTime = 0; + protected boolean mVoidExcess = false; + + public ArrayList<GT_MetaTileEntity_Hatch_ControlCore> mControlCoreBus = new ArrayList<GT_MetaTileEntity_Hatch_ControlCore>(); + public ArrayList<GT_MetaTileEntity_Hatch_AirIntake> mAirIntakes = new ArrayList<GT_MetaTileEntity_Hatch_AirIntake>(); + public ArrayList<GT_MetaTileEntity_Hatch_InputBattery> mChargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_InputBattery>(); + public ArrayList<GT_MetaTileEntity_Hatch_OutputBattery> mDischargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_OutputBattery>(); + public ArrayList<GT_MetaTileEntity_Hatch> mAllEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); + public ArrayList<GT_MetaTileEntity_Hatch> mAllDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); + + // Custom Behaviour Map + private static final HashMap<String, SpecialMultiBehaviour> mCustomBehviours = new HashMap<String, SpecialMultiBehaviour>(); + + + public GregtechMeta_MultiBlockBase(final int aID, final String aName, + final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMeta_MultiBlockBase(final String aName) { + super(aName); + } + + public static boolean isValidMetaTileEntity( + final MetaTileEntity aMetaTileEntity) { + return (aMetaTileEntity.getBaseMetaTileEntity() != null) + && (aMetaTileEntity.getBaseMetaTileEntity() + .getMetaTileEntity() == aMetaTileEntity) + && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); + } + + public abstract boolean hasSlotInGUI(); + + public long getTotalRuntimeInTicks() { + return this.mTotalRunTime; + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + if (hasSlotInGUI()) { + return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } + else { + String aCustomGUI = getCustomGUIResourceName(); + if (aCustomGUI == null) { + return new CONTAINER_MultiMachine_NoPlayerInventory(aPlayerInventory, aBaseMetaTileEntity); + } + else { + return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } + } + } + + public abstract String getCustomGUIResourceName(); + + public boolean requiresVanillaGtGUI() { + return false; + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + String aCustomGUI = getCustomGUIResourceName(); + aCustomGUI = aCustomGUI != null ? aCustomGUI : hasSlotInGUI() ? "MultiblockDisplay" : "MultiblockDisplay_Generic"; + aCustomGUI = aCustomGUI + ".png"; + if (hasSlotInGUI()) { + if (!requiresVanillaGtGUI()) { + return new GUI_Multi_Basic_Slotted(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } + else { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } + } + else { + if (getCustomGUIResourceName() == null && !hasSlotInGUI()) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } + else { + return new GUI_MultiMachine_Default(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), aCustomGUI); + } + } + } + + public abstract String getMachineType(); + + public String getMachineTooltip() { + return "Machine Type: " + EnumChatFormatting.YELLOW + getMachineType() + EnumChatFormatting.RESET; + } + + public String[] getExtraInfoData() { + return new String[0]; + }; + + @Override + public final String[] getInfoData() { + ArrayList<String> mInfo = new ArrayList<String>(); + if (!this.getMetaName().equals("")) { + mInfo.add(this.getMetaName()); + } + + String[] extra = getExtraInfoData(); + + if (extra == null) { + extra = new String[0]; + } + if (extra.length > 0) { + for (String s : extra) { + mInfo.add(s); + } + } + + long seconds = (this.mTotalRunTime/20); + int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); + int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); + long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks); + long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); + + int mPollutionReduction = getPollutionReductionForAllMufflers(); + long storedEnergy = getStoredEnergyInAllEnergyHatches(); + long maxEnergy = getMaxEnergyStorageOfAllEnergyHatches(); + int tTier = this.getControlCoreTier(); + mInfo.add(getMachineTooltip()); + + + + //Lets borrow the GTNH handling + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.progress")+": "+ + EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ + EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s"); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.energy")+": "+ + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU"); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.usage")+": "+ + EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t"); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.mei")+": "+ + EnumChatFormatting.YELLOW+Long.toString(getMaxInputVoltage())+EnumChatFormatting.RESET+ " EU/t(*2A) "+StatCollector.translateToLocal("GTPP.machines.tier")+": "+ + EnumChatFormatting.YELLOW+GT_Values.VN[GT_Utility.getTier(getMaxInputVoltage())]+ EnumChatFormatting.RESET); + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.problems")+": "+ + EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ + " "+StatCollector.translateToLocal("GTPP.multiblock.efficiency")+": "+ + EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %"); + + + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollution")+": "+ EnumChatFormatting.RED + this.getPollutionPerTick(null)*20+ EnumChatFormatting.RESET+"/sec"); + mInfo.add(StatCollector.translateToLocal("GTPP.multiblock.pollutionreduced")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %"); + + + mInfo.add(StatCollector.translateToLocal("GTPP.CC.machinetier")+": "+ + EnumChatFormatting.GREEN+tTier+EnumChatFormatting.RESET); + + mInfo.add(StatCollector.translateToLocal("GTPP.CC.discount")+": "+ + EnumChatFormatting.GREEN+(getEuDiscountForParallelism())+EnumChatFormatting.RESET + "%"); + + mInfo.add(StatCollector.translateToLocal("GTPP.CC.parallel")+": "+EnumChatFormatting.GREEN+(getMaxParallelRecipes())+EnumChatFormatting.RESET); + + + mInfo.add("Total Time Since Built: " + EnumChatFormatting.DARK_GREEN + Integer.toString(weeks)+EnumChatFormatting.RESET+" Weeks, " + EnumChatFormatting.DARK_GREEN+ Integer.toString(days) +EnumChatFormatting.RESET+ " Days, "); + mInfo.add(EnumChatFormatting.DARK_GREEN + Long.toString(hours) +EnumChatFormatting.RESET + " Hours, " + EnumChatFormatting.DARK_GREEN+ Long.toString(minutes) +EnumChatFormatting.RESET+ " Minutes, " + EnumChatFormatting.DARK_GREEN+ Long.toString(second) +EnumChatFormatting.RESET+ " Seconds."); + mInfo.add("Total Time in ticks: " + EnumChatFormatting.DARK_GREEN + Long.toString(this.mTotalRunTime)); + + + String[] mInfo2 = new String[mInfo.size()]; + mInfo.toArray(mInfo2); + return mInfo2; + + + + } + + public int getPollutionReductionForAllMufflers() { + int mPollutionReduction=0; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + mPollutionReduction=Math.max(calculatePollutionReductionForHatch(tHatch, 100),mPollutionReduction); + } + } + return mPollutionReduction; + } + + public long getStoredEnergyInAllEnergyHatches() { + long storedEnergy=0; + for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); + } + } + return storedEnergy; + } + + public long getMaxEnergyStorageOfAllEnergyHatches() { + long maxEnergy=0; + for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + return maxEnergy; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + private String[] aCachedToolTip; + + /*private final String aRequiresMuffler = "1x Muffler Hatch"; + private final String aRequiresCoreModule = "1x Core Module"; + private final String aRequiresMaint = "1x Maintanence Hatch";*/ + + public final static String TAG_HIDE_HATCHES = "TAG_HIDE_HATCHES"; + public final static String TAG_HIDE_MAINT = "TAG_HIDE_MAINT"; + public final static String TAG_HIDE_POLLUTION = "TAG_HIDE_POLLUTION"; + public final static String TAG_HIDE_MACHINE_TYPE = "TAG_HIDE_MACHINE_TYPE"; + + public synchronized final MultiblockRequirements getRequirements() { + return mRequirements; + } + + //public abstract MultiblockRequirements setRequirements(); + + public synchronized final void setRequirementsInternal() { + //this.mRequirements = setRequirements(); + this.mRequirements = null; + } + + public int getAmountOfOutputs() { + return 1; + } + + public abstract int getMaxParallelRecipes(); + public abstract int getEuDiscountForParallelism(); + + @Override + public boolean isCorrectMachinePart(final ItemStack paramItemStack) { + return true; + } + + @Override + public int getDamageToComponent(final ItemStack paramItemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack p0) { + return false; + } + + @Override + public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient(getSound(), 10, 1.0F, aX, aY, aZ); + } + } + + public void startProcess() { + if(GT_Utility.isStringValid(getSound())) this.sendLoopStart((byte) 1); + } + + public String getSound() { return ""; } + + + public int canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) { + return canBufferOutputs(aRecipe, aParallelRecipes, true); + } + + public int canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes, boolean aAllow16SlotWithoutCheck) { + if (mVoidExcess) return aParallelRecipes; + log("Determining if we have space to buffer outputs. Parallel: "+aParallelRecipes); + + // Null recipe or a recipe with lots of outputs? + // E.G. Gendustry custom comb with a billion centrifuge outputs? + // Do it anyway, provided the multi allows it. Default behaviour is aAllow16SlotWithoutCheck = true. + if (aRecipe == null || aRecipe.mOutputs.length > 16) { + if (aRecipe == null) { + return 0; + } + else if (aRecipe.mOutputs.length > 16) { + if (aAllow16SlotWithoutCheck) { + return aParallelRecipes; + } + else { + // Do nothing, we want to check this recipe properly. + } + } + } + + // Do we even need to check for item outputs? + boolean aDoesOutputItems = aRecipe.mOutputs.length > 0; + // Do we even need to check for fluid outputs? + boolean aDoesOutputFluids = aRecipe.mFluidOutputs.length > 0; + + + + /* ======================================== + * Item Management + * ======================================== + */ + + if (aDoesOutputItems) { + log("We have items to output."); + + // How many slots are free across all the output buses? + int aInputBusSlotsFree = 0; + + /* + * Create Variables for Item Output + */ + + AutoMap<FlexiblePair<ItemStack, Integer>> aItemMap = new AutoMap<FlexiblePair<ItemStack, Integer>>(); + AutoMap<ItemStack> aOutputs = new AutoMap<ItemStack>(aRecipe.mOutputs); + + for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + final IInventory tBusInv = tBus.getBaseMetaTileEntity(); + for (int i = 0; i < tBusInv.getSizeInventory(); i++) { + if (tBus.getStackInSlot(i) == null) { + aInputBusSlotsFree++; + } + else { + ItemStack aT = tBus.getStackInSlot(i); + int aSize = aT.stackSize; + aT = aT.copy(); + aT.stackSize = 0; + aItemMap.put(new FlexiblePair<ItemStack, Integer>(aT, aSize)); + } + } + } + + // Count the slots we need, later we can check if any are able to merge with existing stacks + int aRecipeSlotsRequired = 0; + + // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the recipe outputs. + ConcurrentSet<FlexiblePair<ItemStack, Integer>> aInputMap = new ConcurrentHashSet<FlexiblePair<ItemStack, Integer>>(); + + // Iterate over the outputs, calculating require stack spacing they will require. + for (int i=0;i<aOutputs.size();i++) { + ItemStack aY = aOutputs.get(i); + if (aY == null) { + continue; + } + else { + int aStackSize = aY.stackSize * aParallelRecipes; + if (aStackSize > 64) { + int aSlotsNeedsForThisStack = (int) Math.ceil((double) ((float) aStackSize / 64f)); + // Should round up and add as many stacks as required nicely. + aRecipeSlotsRequired += aSlotsNeedsForThisStack; + for (int o=0;o<aRecipeSlotsRequired;o++) { + int aStackToRemove = (aStackSize -= 64) > 64 ? 64 : aStackSize; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackToRemove)); + } + } + else { + // Only requires one slot + aRecipeSlotsRequired++; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackSize)); + } + } + } + + // We have items to add to the output buses. See if any are not full stacks and see if we can make them full. + if (aInputMap.size() > 0) { + // Iterate over the current stored items in the Output busses, if any match and are not full, we can try account for merging. + busItems: for (FlexiblePair<ItemStack, Integer> y : aItemMap) { + // Iterate over the 'inputs', we can safely remove these as we go. + outputItems: for (FlexiblePair<ItemStack, Integer> u : aInputMap) { + // Create local vars for readability. + ItemStack aOutputBusStack = y.getKey(); + ItemStack aOutputStack = u.getKey(); + // Stacks match, including NBT. + if (GT_Utility.areStacksEqual(aOutputBusStack, aOutputStack, false)) { + // Stack Matches, but it's full, continue. + if (aOutputBusStack.stackSize >= 64) { + // This stack is full, no point checking it. + continue busItems; + } + else { + // We can merge these two stacks without any hassle. + if ((aOutputBusStack.stackSize + aOutputStack.stackSize) <= 64) { + // Update the stack size in the bus storage map. + y.setValue(aOutputBusStack.stackSize + aOutputStack.stackSize); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + continue outputItems; + } + // Stack merging is too much, so we fill this stack, leave the remainder. + else { + int aRemainder = (aOutputBusStack.stackSize + aOutputStack.stackSize) - 64; + // Update the stack size in the bus storage map. + y.setValue(64); + // Create a new object to iterate over later, with the remainder data; + FlexiblePair<ItemStack, Integer> t = new FlexiblePair<ItemStack, Integer>(u.getKey(), aRemainder); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + // Add the remainder stack. + aInputMap.add(t); + continue outputItems; + } + } + } + else { + continue outputItems; + } + } + } + } + + // We have stacks that did not merge, do we have space for them? + if (aInputMap.size() > 0) { + if (aInputMap.size() > aInputBusSlotsFree) { + aParallelRecipes = (int) Math.floor((double) aInputBusSlotsFree/aInputMap.size() * aParallelRecipes); + // We do not have enough free slots in total to accommodate the remaining managed stacks. + log(" Free: "+aInputBusSlotsFree+", Required: "+aInputMap.size()); + if(aParallelRecipes == 0) { + log("Failed to find enough space for all item outputs."); + return 0; + } + + } + } + + /* + * End Item Management + */ + + } + + + + + + /* ======================================== + * Fluid Management + * ======================================== + */ + + + + if (aDoesOutputFluids) { + log("We have Fluids to output."); + // How many slots are free across all the output buses? + int aFluidHatches = 0; + int aEmptyFluidHatches = 0; + int aFullFluidHatches = 0; + // Create Map for Fluid Output + ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>> aOutputHatches = new ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>>(); + for (final GT_MetaTileEntity_Hatch_Output tBus : this.mOutputHatches) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + aFluidHatches++; + // Map the Hatch with the space left for easy checking later. + if (tBus.getFluid() == null) { + aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, null, tBus.getCapacity())); + } + else { + int aSpaceLeft = tBus.getCapacity() - tBus.getFluidAmount(); + aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, tBus.getFluid(), aSpaceLeft)); + } + } + // Create a map of all the fluids we would like to output, we can iterate over this and see how many we can merge into existing hatch stacks. + ArrayList<FluidStack> aOutputFluids = new ArrayList<FluidStack>(); + // Ugly ass boxing + aOutputFluids.addAll(new AutoMap<FluidStack>(aRecipe.mFluidOutputs)); + // Iterate the Hatches, updating their 'stored' data. + //for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aHatchData : aOutputHatches) { + for (int i = 0;i<aOutputHatches.size();i++) { + // The Hatch Itself + GT_MetaTileEntity_Hatch_Output aHatch = aOutputHatches.get(i).getValue_1(); + // Fluid in the Hatch + FluidStack aHatchStack = aOutputHatches.get(i).getValue_2(); + // Space left in Hatch + int aSpaceLeftInHatch = aHatch.getCapacity() - aHatch.getFluidAmount(); + // Hatch is full, + if (aSpaceLeftInHatch <= 0) { + aFullFluidHatches++; + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + continue; + } + // Hatch has space + else { + // Check if any fluids match + //aFluidMatch: for (FluidStack aOutputStack : aOutputFluids) { + for(int j = 0;j<aOutputFluids.size();j++) { + //log(" aHatchStack "+aHatchStack.getLocalizedName()+" aOutput stack "+aOutputStack.getLocalizedName()); + if (GT_Utility.areFluidsEqual(aHatchStack, aOutputFluids.get(j))) { + int aFluidToPutIntoHatch = aOutputFluids.get(j).amount * aParallelRecipes; + // Not Enough space to insert all of the fluid. + // We fill this hatch and add a smaller Fluidstack back to the iterator. + if (aSpaceLeftInHatch < aFluidToPutIntoHatch) { + // Copy existing Hatch Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + aNewHatchStack.amount = 0; + // Copy existing Hatch Stack again + FluidStack aNewOutputStack = aHatchStack.copy(); + aNewOutputStack.amount = 0; + // How much fluid do we have left after we fill the hatch? + int aFluidLeftAfterInsert = aFluidToPutIntoHatch - aSpaceLeftInHatch; + // Set new stacks to appropriate values + aNewHatchStack.amount = aHatch.getCapacity(); + aNewOutputStack.amount = aFluidLeftAfterInsert; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Add remaining Fluid to Output list + aOutputFluids.add(aNewOutputStack); + // Re-add hatch to hatch list, with new data. + //Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); + //aOutputHatches.add(aNewHatchData); + break; + } + // We can fill this hatch perfectly (rare case), may as well add it directly to the full list. + else if (aSpaceLeftInHatch == aFluidToPutIntoHatch) { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + break; + } + // We have more space than we need to merge, so we remove the stack from the output list and update the hatch list. + else { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + // Check next fluid + continue; + } + + } + else { + continue; + } + } + } + } + + for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aFreeHatchCheck : aOutputHatches) { + // Free Hatch + if (aFreeHatchCheck.getValue_2() == null || aFreeHatchCheck.getValue_3() == 0 || aFreeHatchCheck.getValue_1().getFluid() == null) { + aEmptyFluidHatches++; + } + } + + // We have Fluid Stacks we did not merge. Do we have space? + log("fluids to output "+aOutputFluids.size()+" empty hatches "+aEmptyFluidHatches); + if (aOutputFluids.size() > 0) { + // Not enough space to add fluids. + if (aOutputFluids.size() > aEmptyFluidHatches) { + aParallelRecipes = (int) Math.floor((double) aEmptyFluidHatches/aOutputFluids.size() * aParallelRecipes); + log("Failed to find enough space for all fluid outputs. Free: "+aEmptyFluidHatches+", Required: "+aOutputFluids.size()); + return 0; + + } + } + + /* + * End Fluid Management + */ + } + + return aParallelRecipes; + } + + /** + * A Static {@link Method} object which holds the current status of logging. + */ + public static Method aLogger = null; + + public void log(String s) { + if (!AsmConfig.disableAllLogging) { + if (CORE_Preloader.DEBUG_MODE) { + Logger.INFO(s); + } else { + Logger.MACHINE_INFO(s); + } + } + } + + public boolean checkRecipeGeneric() { + return checkRecipeGeneric(1, 100, 0); + } + + public boolean checkRecipeGeneric(int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent) { + return checkRecipeGeneric(aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, 10000); + } + + public boolean checkRecipeGeneric(int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll); + } + + public boolean checkRecipeGeneric(GT_Recipe aRecipe, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, boolean isPerfectOC) { + if (aRecipe == null) { + return false; + } + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe, isPerfectOC); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll) { + return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null, false); + } + + public boolean checkRecipeGeneric(GT_Recipe aRecipe, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll) { + if (aRecipe == null) { + return false; + } + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric(tItemInputs, tFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe, false); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, boolean isPerfectOC) { + return checkRecipeGeneric(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, null, isPerfectOC); + } + + + /* + * 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. + * + * + * if (this.doesMachineBoostOutput()) { log("Boosting."); return + * checkRecipeBoostedOutputs(aItemInputs, aFluidInputs, aMaxParallelRecipes, + * aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); } + * + * + * //Control Core to control the Multiblocks behaviour. int aControlCoreTier = + * getControlCoreTier(); + * + * //If no core, return false; if (aControlCoreTier > 0) { + * log("Control core found."); } + * + * + * // 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)); log("Running checkRecipeGeneric(0)"); + * + * //Check to see if Voltage Tier > Control Core Tier if (tTier > + * aControlCoreTier) { + * log("Control core found is lower tier than power tier. OK"); tTier = (byte) + * aControlCoreTier; } + * + * tTier = (byte) MathUtils.getValueWithinRange(tTier, 0, 9); + * + * GT_Recipe tRecipe = aRecipe != null ? aRecipe : 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; } + * + * if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { + * 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); log("EU1: "+tRecipeEUt); // Count + * recipes to do in parallel, consuming input items and fluids and considering + * input voltage limits for (; parallelRecipes < aMaxParallelRecipes && + * tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { if + * (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + * log("Broke at "+parallelRecipes+"."); break; } + * log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); tTotalEUt + * += tRecipeEUt; log("EU2: "+tTotalEUt); } + * + * if (parallelRecipes == 0) { log("BAD RETURN - 3"); return false; } + * + * log("EU3: "+tTotalEUt); + * + * // -- 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 * 10000); + * + * int aTempEu = (int) Math.floor(tTotalEUt); log("EU4: "+aTempEu); + * this.mEUt = (int) aTempEu; + * + * + * 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; } + */ + + public long getMaxInputEnergy() { + long rEnergy = 0; + if (mEnergyHatches.size() < 2) // so it only takes 1 amp is only 1 hatch is present so it works like most gt multies + return mEnergyHatches.get(0).getBaseMetaTileEntity().getInputVoltage(); + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) rEnergy += tHatch.getBaseMetaTileEntity().getInputVoltage() * tHatch.getBaseMetaTileEntity().getInputAmperage(); + return rEnergy; + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isPerpectOC) { + // 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; + } + + + /* + * Check for Special Behaviours + */ + + // First populate the map if we need to. + if (mCustomBehviours.isEmpty()) { + mCustomBehviours.putAll(Multiblock_API.getSpecialBehaviourItemMap()); + } + + // We have a special slot object in the recipe + if (tRecipe.mSpecialItems != null) { + // The special slot is an item + if (tRecipe.mSpecialItems instanceof ItemStack) { + // Make an Itemstack instance of this. + ItemStack aSpecialStack = (ItemStack) tRecipe.mSpecialItems; + // Check if this item is in an input bus. + boolean aDidFindMatch = false; + for (ItemStack aInputItemsToCheck : aItemInputs) { + // If we find a matching stack, continue. + if (GT_Utility.areStacksEqual(aSpecialStack, aInputItemsToCheck, false)) { + // Iterate all special behaviour items, to see if we need to utilise one. + aDidFindMatch = true; + break; + } + } + // Try prevent needless iteration loops if we don't have the required inputs at all. + if (aDidFindMatch) { + // Iterate all special behaviour items, to see if we need to utilise one. + for (SpecialMultiBehaviour aBehaviours : mCustomBehviours.values()) { + // Found a match, let's adjust this recipe now. + if (aBehaviours.isTriggerItem(aSpecialStack)) { + // Adjust this recipe to suit special item + aMaxParallelRecipes = aBehaviours.getMaxParallelRecipes(); + aEUPercent = aBehaviours.getEUPercent(); + aSpeedBonusPercent = aBehaviours.getSpeedBonusPercent(); + aOutputChanceRoll = aBehaviours.getOutputChanceRoll(); + break; + } + } + } + } + } + + 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; + if (isPerpectOC) this.mMaxProgresstime /= 4; + else 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; + } + + + + + + /* + * Here we handle recipe boosting, which grants additional output %'s to recipes that do not have 100%. + */ + + private boolean mHasBoostedCurrentRecipe = false; + private GT_Recipe mBoostedRecipe = null; + private ItemStack[] mInputVerificationForBoosting = null; + + /** + * Does this machine boost it's output? + * @return - if true, gives additional % to output chances. + */ + protected boolean doesMachineBoostOutput() { + return false; + } + + + + private int boostOutput(int aAmount) { + if (aAmount <= 0) { + return 10000; + } + if (aAmount <= 250) { + aAmount += MathUtils.randInt(Math.max(aAmount/2, 1), aAmount*2); + } + else if (aAmount <= 500) { + aAmount += MathUtils.randInt(Math.max(aAmount/2, 1), aAmount*2); + } + else if (aAmount <= 750) { + aAmount += MathUtils.randInt(Math.max(aAmount/2, 1), aAmount*2); + } + else if (aAmount <= 1000) { + aAmount = (aAmount*2); + } + else if (aAmount <= 1500) { + aAmount = (aAmount*2); + } + else if (aAmount <= 2000) { + aAmount = (int) (aAmount*1.5); + } + else if (aAmount <= 3000) { + aAmount = (int) (aAmount*1.5); + } + else if (aAmount <= 4000) { + aAmount = (int) (aAmount*1.2); + } + else if (aAmount <= 5000) { + aAmount = (int) (aAmount*1.2); + } + else if (aAmount <= 7000) { + aAmount = (int) (aAmount*1.2); + } + else if (aAmount <= 9000) { + aAmount = (int) (aAmount*1.1); + } + return Math.min(10000, aAmount); + } + + public GT_Recipe generateAdditionalOutputForRecipe(GT_Recipe aRecipe) { + AutoMap<Integer> aNewChances = new AutoMap<Integer>(); + for (int chance : aRecipe.mChances) { + aNewChances.put(boostOutput(chance)); + } + GT_Recipe aClone = aRecipe.copy(); + int[] aTemp = new int[aNewChances.size()]; + int slot = 0; + for (int g : aNewChances) { + aTemp[slot] = g; + slot++; + } + aClone.mChances = aTemp; + return aClone; + } + + + /** + * Processes recipes but provides a bonus to the output % of items if they are < 100%. + * + * @param aItemInputs + * @param aFluidInputs + * @param aMaxParallelRecipes + * @param aEUPercent + * @param aSpeedBonusPercent + * @param aOutputChanceRoll + * @param aRecipe + * @return + */ + public boolean checkRecipeBoostedOutputs( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + log("Running checkRecipeGeneric(1)"); + + //First we check whether or not we have an input cached for boosting. + //If not, we set it to the current recipe. + //If we do, we compare it against the current recipe, if thy are the same, we try return a boosted recipe, if not, we boost a new recipe. + boolean isRecipeInputTheSame = false; + + //No cached recipe inputs, assume first run. + if (mInputVerificationForBoosting == null) { + mInputVerificationForBoosting = tRecipe.mInputs; + isRecipeInputTheSame = true; + } + //If the inputs match, we are good. + else { + if (tRecipe.mInputs == mInputVerificationForBoosting) { + isRecipeInputTheSame = true; + } + else { + isRecipeInputTheSame = false; + } + } + + //Inputs are the same, let's see if there's a boosted version. + if (isRecipeInputTheSame) { + //Yes, let's just set that as the recipe + if (mHasBoostedCurrentRecipe && mBoostedRecipe != null) { + tRecipe = mBoostedRecipe; + } + //We have yet to generate a new boosted recipe + else { + GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); + if (aBoostedRecipe != null) { + mBoostedRecipe = aBoostedRecipe; + mHasBoostedCurrentRecipe = true; + tRecipe = mBoostedRecipe; + } + //Bad boost + else { + mBoostedRecipe = null; + mHasBoostedCurrentRecipe = false; + } + } + } + //We have changed inputs, so we should generate a new boosted recipe + else { + GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); + if (aBoostedRecipe != null) { + mBoostedRecipe = aBoostedRecipe; + mHasBoostedCurrentRecipe = true; + tRecipe = mBoostedRecipe; + } + //Bad boost + else { + mBoostedRecipe = null; + mHasBoostedCurrentRecipe = false; + } + } + + //Bad modify, let's just use the original recipe. + if (!mHasBoostedCurrentRecipe || mBoostedRecipe == null) { + tRecipe = aRecipe != null ? aRecipe : findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + } + + // 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; + + 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; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + public boolean isMachineRunning() { + boolean aRunning = this.getBaseMetaTileEntity().isActive(); + log("Queried Multiblock is currently running: "+aRunning); + return aRunning; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, + final long aTick) { + + //Time Counter + if (aBaseMetaTileEntity.isServerSide()){ + this.mTotalRunTime++; + } + + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mChargeHatches.clear(); + this.mDischargeHatches.clear(); + this.mControlCoreBus.clear(); + this.mAirIntakes.clear(); + this.mTecTechEnergyHatches.clear(); + this.mTecTechDynamoHatches.clear(); + this.mAllEnergyHatches.clear(); + this.mAllDynamoHatches.clear(); + } + } + + + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void explodeMultiblock() { + MetaTileEntity tTileEntity; + for (final Iterator<GT_MetaTileEntity_Hatch_InputBattery> localIterator = this.mChargeHatches + .iterator(); localIterator.hasNext(); tTileEntity + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + tTileEntity = null; + for (final Iterator<GT_MetaTileEntity_Hatch_OutputBattery> localIterator = this.mDischargeHatches + .iterator(); localIterator.hasNext(); tTileEntity + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + tTileEntity = null; + for (final Iterator<GT_MetaTileEntity_Hatch> localIterator = this.mTecTechDynamoHatches + .iterator(); localIterator.hasNext(); tTileEntity + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + tTileEntity = null; + for (final Iterator<GT_MetaTileEntity_Hatch> localIterator = this.mTecTechEnergyHatches + .iterator(); localIterator.hasNext(); tTileEntity + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } + + + + super.explodeMultiblock(); + } + + protected int getGUICircuit(ItemStack[] t) { + Item g = CI.getNumberedCircuit(0).getItem(); + ItemStack guiSlot = this.mInventory[1]; + int mMode = -1; + if (guiSlot != null && guiSlot.getItem() == g) { + this.mInternalCircuit = true; + return guiSlot.getItemDamage(); + } + else { + this.mInternalCircuit = false; + } + + if (!this.mInternalCircuit) { + for (ItemStack j : t) { + if (j.getItem() == g) { + mMode = j.getItemDamage(); + break; + } + } + } + return mMode; + } + + protected ItemStack getGUIItemStack() { + ItemStack guiSlot = this.mInventory[1]; + return guiSlot; + } + + protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { + boolean result = false; + if (this.mInventory[1] == null) { + this.mInventory[1] = aNewGuiSlotContents != null ? aNewGuiSlotContents.copy() : null; + this.depleteInput(aNewGuiSlotContents); + this.updateSlots(); + result = true; + } + return result; + } + + protected boolean clearGUIItemSlot() { + return setGUIItemStack(null); + } + + + public ItemStack findItemInInventory(Item aSearchStack) { + return findItemInInventory(aSearchStack, 0); + } + + public ItemStack findItemInInventory(Item aSearchStack, int aMeta) { + return findItemInInventory(ItemUtils.simpleMetaStack(aSearchStack, aMeta, 1)); + } + + public ItemStack findItemInInventory(ItemStack aSearchStack) { + if (aSearchStack != null && this.mInputBusses.size() > 0) { + for (GT_MetaTileEntity_Hatch_InputBus bus : this.mInputBusses) { + if (bus != null) { + for (ItemStack uStack : bus.mInventory) { + if (uStack != null) { + if (aSearchStack.getClass().isInstance(uStack.getItem())) { + return uStack; + } + } + } + } + } + } + return null; + } + + @Override + public void updateSlots() { + for (final GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) { + if (isValidMetaTileEntity(tHatch)) { + tHatch.updateSlots(); + } + } + for (final GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) { + if (isValidMetaTileEntity(tHatch)) { + tHatch.updateSlots(); + } + } + super.updateSlots(); + } + + public boolean isToolCreative(ItemStack mStack){ + Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(mStack); + Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(mStack); + if (t1 == Materials._NULL && t2 == Materials._NULL){ + return true; + } + return false; + } + + /** + * Causes a Random Maint. Issue. + * @return {@link boolean} - Returns whether or not an issue was caused, should always be true. + */ + public boolean causeMaintenanceIssue() { + boolean b = false; + switch (this.getBaseMetaTileEntity().getRandomNumber(6)) { + case 0 : { + this.mWrench = false; + b = true; + break; + } + case 1 : { + this.mScrewdriver = false; + b = true; + break; + } + case 2 : { + this.mSoftHammer = false; + b = true; + break; + } + case 3 : { + this.mHardHammer = false; + b = true; + break; + } + case 4 : { + this.mSolderingTool = false; + b = true; + break; + } + case 5 : { + this.mCrowbar = false; + b = true; + break; + } + } + return b; + } + + public void fixAllMaintenanceIssue() { + this.mCrowbar = true; + this.mWrench = true; + this.mHardHammer = true; + this.mSoftHammer = true; + this.mSolderingTool = true; + this.mScrewdriver = true; + } + + public boolean checkHatch() { + return mMaintenanceHatches.size() <= 1 && !mMufflerHatches.isEmpty(); + } + + public <E> boolean addToMachineListInternal(ArrayList<E> aList, final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + return addToMachineListInternal(aList, getMetaTileEntity(aTileEntity), aBaseCasingIndex); + } + + public <E> boolean addToMachineListInternal(ArrayList<E> aList, final IMetaTileEntity aTileEntity, final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + + //Check type + /* + * Class <?> aHatchType = ReflectionUtils.getTypeOfGenericObject(aList); if + * (!aHatchType.isInstance(aTileEntity)) { return false; } + */ + + // Try setRecipeMap + + try { + if (aTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + resetRecipeMapForHatch((GT_MetaTileEntity_Hatch) aTileEntity, getRecipeMap()); + } + if (aTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + resetRecipeMapForHatch((GT_MetaTileEntity_Hatch) aTileEntity, getRecipeMap()); + } + } + catch (Throwable t) { + t.printStackTrace(); + } + + if (aList.isEmpty()) { + if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Adding " + aTileEntity.getInventoryName() + " at " + new BlockPos(aTileEntity.getBaseMetaTileEntity()).getLocationString()); + } + updateTexture(aTileEntity, aBaseCasingIndex); + return aList.add((E) aTileEntity); + } + } + else { + IGregTechTileEntity aCur = aTileEntity.getBaseMetaTileEntity(); + if (aList.contains(aTileEntity)) { + log("Found Duplicate "+aTileEntity.getInventoryName()+" @ " + new BlockPos(aCur).getLocationString()); + return false; + } + BlockPos aCurPos = new BlockPos(aCur); + boolean aExists = false; + for (E m : aList) { + IGregTechTileEntity b = ((IMetaTileEntity) m).getBaseMetaTileEntity(); + if (b != null) { + BlockPos aPos = new BlockPos(b); + if (aPos != null) { + if (aCurPos.equals(aPos)) { + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Found Duplicate "+b.getInventoryName()+" at " + aPos.getLocationString()); + } + return false; + } + } + } + } + if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Adding " + aCur.getInventoryName() + " at " + aCurPos.getLocationString()); + } + updateTexture(aTileEntity, aBaseCasingIndex); + return aList.add((E) aTileEntity); + } + } + return false; + } + + public int getControlCoreTier() { + + //Always return best tier if config is off. + /*boolean aCoresConfig = gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; + if (!aCoresConfig) { + return 10; + }*/ + + if (mControlCoreBus.isEmpty()) { + log("No Control Core Modules Found."); + return 0; + } + GT_MetaTileEntity_Hatch_ControlCore i = getControlCoreBus(); + if (i != null) { + ItemStack x = i.mInventory[0]; + if (x != null) { + return x.getItemDamage(); + } + } + log("Control Core Module was null."); + return 0; + } + + public GT_MetaTileEntity_Hatch_ControlCore getControlCoreBus() { + if (this.mControlCoreBus == null || this.mControlCoreBus.isEmpty()) { + return null; + } + GT_MetaTileEntity_Hatch_ControlCore x = this.mControlCoreBus.get(0); + if (x != null) { + log("getControlCore(ok)"); + return x; + } + log("getControlCore(bad)"); + return null; + } + + //mControlCoreBus + public boolean addControlCoreToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + if (!mControlCoreBus.isEmpty()) { + log("Tried to add a secondary control core module."); + return false; + } + GT_MetaTileEntity_Hatch_ControlCore Module = (GT_MetaTileEntity_Hatch_ControlCore) getMetaTileEntity(aTileEntity); + if (Module != null) { + if (Module.setOwner(aTileEntity)) { + log("Adding control core module."); + return addToMachineListInternal(mControlCoreBus, Module, aBaseCasingIndex); + } + } + return false; + } + + private IMetaTileEntity getMetaTileEntity(final IGregTechTileEntity aTileEntity) { + if (aTileEntity == null) { + return null; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + return aMetaTileEntity; + } + + + @Override + public boolean addToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + return addToMachineList(getMetaTileEntity(aTileEntity), aBaseCasingIndex); + } + + public boolean addToMachineList(final IMetaTileEntity aMetaTileEntity, final int aBaseCasingIndex) { + if (aMetaTileEntity == null) { + return false; + } + + //Use this to determine the correct value, then update the hatch texture after. + boolean aDidAdd = false; + + //Handle Custom Hatches + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ControlCore) { + log("Found GT_MetaTileEntity_Hatch_ControlCore"); + if (!mControlCoreBus.isEmpty()) { + log("Tried to add a secondary control core module."); + return false; + } + aDidAdd = addToMachineListInternal(this.mControlCoreBus, aMetaTileEntity, aBaseCasingIndex); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) { + log("Found GT_MetaTileEntity_Hatch_InputBattery"); + aDidAdd = addToMachineListInternal(mChargeHatches, aMetaTileEntity, aBaseCasingIndex); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) { + log("Found GT_MetaTileEntity_Hatch_OutputBattery"); + aDidAdd = addToMachineListInternal(mDischargeHatches, aMetaTileEntity, aBaseCasingIndex); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_AirIntake) { + aDidAdd = addToMachineListInternal(mAirIntakes, aMetaTileEntity, aBaseCasingIndex); + } + + //Handle TT Multi-A Energy Hatches + else if (LoadedMods.TecTech && isThisHatchMultiEnergy(aMetaTileEntity)) { + log("Found isThisHatchMultiEnergy"); + aDidAdd = addToMachineListInternal(mTecTechEnergyHatches, aMetaTileEntity, aBaseCasingIndex); + updateMasterEnergyHatchList(aMetaTileEntity); + } + + //Handle TT Multi-A Dynamos + else if (LoadedMods.TecTech && isThisHatchMultiDynamo(aMetaTileEntity)) { + log("Found isThisHatchMultiDynamo"); + aDidAdd = addToMachineListInternal(mTecTechDynamoHatches, aMetaTileEntity, aBaseCasingIndex); + updateMasterDynamoHatchList(aMetaTileEntity); + } + + //Handle Fluid Hatches using seperate logic + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) + aDidAdd = addToMachineListInternal(mInputHatches, aMetaTileEntity, aBaseCasingIndex); + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) + aDidAdd = addToMachineListInternal(mOutputHatches, aMetaTileEntity, aBaseCasingIndex); + + //Process Remaining hatches using Vanilla GT Logic + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) + aDidAdd = addToMachineListInternal(mInputBusses, aMetaTileEntity, aBaseCasingIndex); + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) + aDidAdd = addToMachineListInternal(mOutputBusses, aMetaTileEntity, aBaseCasingIndex); + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + aDidAdd = addToMachineListInternal(mEnergyHatches, aMetaTileEntity, aBaseCasingIndex); + updateMasterEnergyHatchList(aMetaTileEntity); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + aDidAdd = addToMachineListInternal(mDynamoHatches, aMetaTileEntity, aBaseCasingIndex); + updateMasterDynamoHatchList(aMetaTileEntity); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) + aDidAdd = addToMachineListInternal(mMaintenanceHatches, aMetaTileEntity, aBaseCasingIndex); + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) + aDidAdd = addToMachineListInternal(mMufflerHatches, aMetaTileEntity, aBaseCasingIndex); + + //return super.addToMachineList(aTileEntity, aBaseCasingIndex); + return aDidAdd; + } + + + + @Override + public boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + @Override + public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + @Override + public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + @Override + public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean addAirIntakeToMachineList(final IGregTechTileEntity aMetaTileEntity, final int aBaseCasingIndex) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_AirIntake) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean addFluidInputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + return addFluidInputToMachineList(getMetaTileEntity(aTileEntity), aBaseCasingIndex); + } + + public boolean addFluidInputToMachineList(final IMetaTileEntity aMetaTileEntity, final int aBaseCasingIndex) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean clearRecipeMapForAllInputHatches() { + return resetRecipeMapForAllInputHatches(null); + } + + public boolean resetRecipeMapForAllInputHatches() { + return resetRecipeMapForAllInputHatches(this.getRecipeMap()); + } + + public boolean resetRecipeMapForAllInputHatches(GT_Recipe_Map aMap) { + int cleared = 0; + for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { + if (resetRecipeMapForHatch(g, aMap)) { + cleared++; + } + } + for (GT_MetaTileEntity_Hatch_InputBus g : this.mInputBusses) { + if (resetRecipeMapForHatch(g, aMap)) { + cleared++; + } + } + return cleared > 0; + } + public boolean resetRecipeMapForHatch(IGregTechTileEntity aTileEntity, GT_Recipe_Map aMap) { + try { + final IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { + return resetRecipeMapForHatch((GT_MetaTileEntity_Hatch)aMetaTileEntity, aMap); + } + else { + return false; + } + } + catch (Throwable t) { + t.printStackTrace(); + return false; + } + } + + public boolean resetRecipeMapForHatch(GT_MetaTileEntity_Hatch aTileEntity, GT_Recipe_Map aMap) { + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input){ + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = null; + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = aMap; + if (aMap != null && aMap.mNEIName != null) { + log("Remapped Input Hatch to "+aMap.mNEIName+"."); + } + else { + log("Cleared Input Hatch."); + } + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = null; + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = aMap; + if (aMap != null && aMap.mNEIName != null) { + log("Remapped Input Bus to "+aMap.mNEIName+"."); + } + else { + log("Cleared Input Bus."); + } + } + else { + ((GT_MetaTileEntity_Hatch_Steam_BusInput) aMetaTileEntity).mRecipeMap = null; + ((GT_MetaTileEntity_Hatch_Steam_BusInput) aMetaTileEntity).mRecipeMap = aMap; + if (aMap != null && aMap.mNEIName != null) { + log("Remapped Input Bus to "+aMap.mNEIName+"."); + } + else { + log("Cleared Input Bus."); + } + } + return true; + } + else { + return false; + } + } + + @Override + public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + clearRecipeMapForAllInputHatches(); + onModeChangeByScrewdriver(aSide, aPlayer, aX, aY, aZ); + resetRecipeMapForAllInputHatches(); + } + + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + + } + + + + + + /** + * Enable Texture Casing Support if found in GT 5.09 + */ + + public boolean updateTexture(final IGregTechTileEntity aTileEntity, int aCasingID){ + return updateTexture(getMetaTileEntity(aTileEntity), aCasingID); + } + + /** + * Enable Texture Casing Support if found in GT 5.09 + */ + + @SuppressWarnings("deprecation") + public boolean updateTexture(final IMetaTileEntity aTileEntity, int aCasingID){ + try { //gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch.updateTexture(int) + + final IMetaTileEntity aMetaTileEntity = aTileEntity; + if (aMetaTileEntity == null) { + return false; + } + Method mProper = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); + if (mProper != null){ + if (GT_MetaTileEntity_Hatch.class.isInstance(aMetaTileEntity)){ + mProper.setAccessible(true); + mProper.invoke(aMetaTileEntity, aCasingID); + //log("Good Method Call for updateTexture."); + return true; + } + } + else { + log("Bad Method Call for updateTexture."); + if (GT_MetaTileEntity_Hatch.class.isInstance(aMetaTileEntity)){ + if (aCasingID <= Byte.MAX_VALUE) { + ((GT_MetaTileEntity_Hatch) aTileEntity).mMachineBlock = (byte) aCasingID; + log("Good Method Call for updateTexture. Used fallback method of setting mMachineBlock as casing id was <= 128."); + return true; + } + else { + log("updateTexture returning false. 1.2"); + } + } + else { + log("updateTexture returning false. 1.3"); + } + } + log("updateTexture returning false. 1"); + return false; + } + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + log("updateTexture returning false."); + log("updateTexture returning false. 2"); + e.printStackTrace(); + return false; + } + + } + + + + + + + + + + /** + * TecTech Support + */ + + + /** + * This is the array Used to Store the Tectech Multi-Amp Dynamo hatches. + */ + + public ArrayList<GT_MetaTileEntity_Hatch> mTecTechDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); + + /** + * This is the array Used to Store the Tectech Multi-Amp Energy hatches. + */ + + public ArrayList<GT_MetaTileEntity_Hatch> mTecTechEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); + + /** + * TecTech Multi-Amp Dynamo Support + * @param aTileEntity - The Dynamo Hatch + * @param aBaseCasingIndex - Casing Texture + * @return + */ + + public boolean addMultiAmpDynamoToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex){ + final IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity == null) { + return false; + } + if (isThisHatchMultiDynamo(aTileEntity)) { + return addToMachineListInternal(mTecTechDynamoHatches, aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean isThisHatchMultiDynamo(IGregTechTileEntity aTileEntity){ + return isThisHatchMultiDynamo(getMetaTileEntity(aTileEntity)); + } + + public boolean isThisHatchMultiDynamo(IMetaTileEntity aMetaTileEntity){ + Class<?> mDynamoClass; + mDynamoClass = ReflectionUtils.getClass("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); + if (mDynamoClass != null){ + if (mDynamoClass.isInstance(aMetaTileEntity)){ + return true; + } + } + return false; + } + + @Override + public boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo || isThisHatchMultiDynamo(aMetaTileEntity)) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + private boolean updateMasterDynamoHatchList(IMetaTileEntity aMetaTileEntity) { + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + GT_MetaTileEntity_Hatch aHatch = (GT_MetaTileEntity_Hatch) aMetaTileEntity; + return mAllDynamoHatches.add(aHatch); + } + return false; + } + + + /** + * TecTech Multi-Amp Energy Hatch Support + * @param aTileEntity - The Energy Hatch + * @param aBaseCasingIndex - Casing Texture + * @return + */ + + public boolean addMultiAmpEnergyToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex){ + final IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity == null) { + return false; + } + if (isThisHatchMultiEnergy(aMetaTileEntity)) { + return addToMachineListInternal(mTecTechEnergyHatches, aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + public boolean isThisHatchMultiEnergy(IGregTechTileEntity aTileEntity){ + return isThisHatchMultiEnergy(getMetaTileEntity(aTileEntity)); + } + + public boolean isThisHatchMultiEnergy(IMetaTileEntity aMetaTileEntity){ + Class<?> mDynamoClass; + mDynamoClass = ReflectionUtils.getClass("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti"); + if (mDynamoClass != null){ + if (mDynamoClass.isInstance(aMetaTileEntity)){ + return true; + } + } + return false; + } + + @Override + public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + IMetaTileEntity aMetaTileEntity = getMetaTileEntity(aTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy || isThisHatchMultiEnergy(aMetaTileEntity)) { + return addToMachineList(aMetaTileEntity, aBaseCasingIndex); + } + return false; + } + + private boolean updateMasterEnergyHatchList(IMetaTileEntity aMetaTileEntity) { + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + GT_MetaTileEntity_Hatch aHatch = (GT_MetaTileEntity_Hatch) aMetaTileEntity; + return mAllEnergyHatches.add(aHatch); + } + return false; + } + + + /** + * Pollution Management + */ + + private static Method calculatePollutionReduction = null; + public int calculatePollutionReductionForHatch(GT_MetaTileEntity_Hatch_Muffler i , int g) { + if (calculatePollutionReduction != null) { + try { + return (int) calculatePollutionReduction.invoke(i, g); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + + } + } + return 0; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setLong("mTotalRunTime", this.mTotalRunTime); + aNBT.setBoolean("mVoidExcess", this.mVoidExcess); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mTotalRunTime = aNBT.getLong("mTotalRunTime"); + this.mVoidExcess = aNBT.getBoolean("mVoidExcess"); + super.loadNBTData(aNBT); + } + + + + + + + + + + + + + + /** + * Custom Find Recipe with Debugging + */ + + + public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final boolean aNotUnificated, + final boolean aDontCheckStackSizes, final long aVoltage, final FluidStack[] aFluids, + final ItemStack... aInputs) { + return this.findRecipe(aTileEntity, null, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, + (ItemStack) null, aInputs); + } + + public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final boolean aNotUnificated, + final long aVoltage, final FluidStack[] aFluids, final ItemStack... aInputs) { + return this.findRecipe(aTileEntity, null, aNotUnificated, aVoltage, aFluids, (ItemStack) null, aInputs); + } + + public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final GT_Recipe aRecipe, + final boolean aNotUnificated, final boolean aDontCheckStackSizes, final long aVoltage, + final FluidStack[] aFluids, final ItemStack... aInputs) { + return this.findRecipe(aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, + (ItemStack) null, aInputs); + } + + public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final GT_Recipe aRecipe, + final boolean aNotUnificated, final long aVoltage, final FluidStack[] aFluids, + final ItemStack... aInputs) { + return this.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, (ItemStack) null, aInputs); + } + + public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final GT_Recipe aRecipe, + final boolean aNotUnificated, final long aVoltage, final FluidStack[] aFluids, + final ItemStack aSpecialSlot, final ItemStack... aInputs) { + return this.findRecipe(aTileEntity, aRecipe, aNotUnificated, true, aVoltage, aFluids, aSpecialSlot, + aInputs); + } + + public GT_Recipe findRecipe(final IHasWorldObjectAndCoords aTileEntity, final GT_Recipe aRecipe, + final boolean aNotUnificated, final boolean aDontCheckStackSizes, final long aVoltage, + final FluidStack[] aFluids, final ItemStack aSpecialSlot, ItemStack... aInputs) { + if (this.getRecipeMap().mRecipeList.isEmpty()) { + log("No Recipes in Map to search through."); + return null; + } + GT_Recipe mRecipeResult = null; + try { + if (GregTech_API.sPostloadFinished) { + if (this.getRecipeMap().mMinimalInputFluids > 0) { + if (aFluids == null) { + log("aFluids == null && minFluids > 0"); + return null; + } + int tAmount = 0; + for (final FluidStack aFluid : aFluids) { + if (aFluid != null) { + ++tAmount; + } + } + if (tAmount < this.getRecipeMap().mMinimalInputFluids) { + log("Not enough fluids?"); + return null; + } + } + if (this.getRecipeMap().mMinimalInputItems > 0) { + if (aInputs == null) { + log("No inputs and minItems > 0"); + return null; + } + int tAmount = 0; + for (final ItemStack aInput : aInputs) { + if (aInput != null) { + ++tAmount; + } + } + if (tAmount < this.getRecipeMap().mMinimalInputItems) { + log("Not enough items?"); + return null; + } + } + } + else { + log("Game Not Loaded properly for recipe lookup."); + } + if (aNotUnificated) { + aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); + } + if (aRecipe != null && !aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered + && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + mRecipeResult = (aRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= aRecipe.mEUt*/) ? aRecipe : null; + log("x) Found Recipe? "+(mRecipeResult != null ? "true" : "false")); + if (mRecipeResult != null) { + return mRecipeResult; + } + } + if (mRecipeResult == null && this.getRecipeMap().mUsualInputCount >= 0 && aInputs != null && aInputs.length > 0) { + for (final ItemStack tStack : aInputs) { + if (tStack != null) { + Collection<GT_Recipe> tRecipes = this.getRecipeMap().mRecipeItemMap.get(new GT_ItemStack(tStack)); + if (tRecipes != null) { + for (final GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + mRecipeResult = (tRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/) + ? tRecipe + : null; + log("1) Found Recipe? "+(mRecipeResult != null ? "true" : "false")); + //return mRecipeResult; + } + } + } + + //TODO - Investigate if this requires to be in it's own block + tRecipes = this.getRecipeMap().mRecipeItemMap + .get(new GT_ItemStack(GT_Utility.copyMetaData(32767L, new Object[]{tStack}))); + if (tRecipes != null) { + for (final GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + mRecipeResult = (tRecipe.mEnabled /*&& aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/) + ? tRecipe + : null; + log("2) Found Recipe? "+(mRecipeResult != null ? "true" : "false")); + //return mRecipeResult; + } + } + } + } + } + } + if (mRecipeResult == null && this.getRecipeMap().mMinimalInputItems == 0 && aFluids != null && aFluids.length > 0) { + for (final FluidStack aFluid2 : aFluids) { + if (aFluid2 != null) { + final Collection<GT_Recipe> tRecipes = this.getRecipeMap().mRecipeFluidMap.get(aFluid2.getFluid()); + if (tRecipes != null) { + for (final GT_Recipe tRecipe : tRecipes) { + if (!tRecipe.mFakeRecipe + && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { + mRecipeResult = (tRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/) + ? tRecipe + : null; + log("3) Found Recipe? "+(mRecipeResult != null ? "true" : "false")); + //return mRecipeResult; + } + } + } + } + } + } + } + catch (Throwable t) { + log("Invalid recipe lookup."); + } + + + if (mRecipeResult == null) { + log("Invalid recipe, Fallback lookup. "+this.getRecipeMap().mRecipeList.size()+" | "+this.getRecipeMap().mNEIName); + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + return (GT_Recipe) findRecipe08.invoke(getRecipeMap(), aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + return null; + } + } + else { + try { + return (GT_Recipe) findRecipe09.invoke(getRecipeMap(), aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, aSpecialSlot, aInputs); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + return null; + } + } + } + else { + return mRecipeResult; + } + + + + + } + + + + + /** + * Custom Tool Handling + */ + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, + float aY, float aZ) { + // Do Things + if (this.getBaseMetaTileEntity().isServerSide()) { + //Logger.INFO("Right Clicked Controller."); + ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem != null) { + //Logger.INFO("Holding Item."); + if (tCurrentItem.getItem() instanceof GT_MetaGenerated_Tool) { + //Logger.INFO("Is GT_MetaGenerated_Tool."); + int[] aOreID = OreDictionary.getOreIDs(tCurrentItem); + for (int id : aOreID) { + // Plunger + if (OreDictionary.getOreName(id).equals("craftingToolPlunger")) { + //Logger.INFO("Is Plunger."); + return onPlungerRightClick(aPlayer, aSide, aX, aY, aZ); + } + } + } + } + } + //Do Super + boolean aSuper = super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + return aSuper; + } + + public boolean onPlungerRightClick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + int aHatchIndex = 0; + PlayerUtils.messagePlayer(aPlayer, "Trying to clear "+mOutputHatches.size()+" output hatches."); + for (GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { + if (hatch.mFluid != null) { + PlayerUtils.messagePlayer(aPlayer, "Clearing "+hatch.mFluid.amount+"L of "+hatch.mFluid.getLocalizedName()+" from hatch "+aHatchIndex+"."); + hatch.mFluid = null; + } + aHatchIndex++; + } + return aHatchIndex > 0; + } + + @Override + public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + boolean tSuper = super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + if (aPlayer.isSneaking()) + return tSuper; + mVoidExcess = !mVoidExcess; + aPlayer.addChatMessage(new ChatComponentTranslation(mVoidExcess ? "interaction.voidexcess.enabled" : "interaction.voidexcess.disabled")); + return true; + } + + public boolean isValidBlockForStructure(IGregTechTileEntity aBaseMetaTileEntity, int aCasingID, boolean canBeHatch, + Block aFoundBlock, int aFoundMeta, Block aExpectedBlock, int aExpectedMeta) { + boolean isHatch = false; + if (aBaseMetaTileEntity != null) { + + // Unsure why this check exists? + /*if (aCasingID < 64) { + aCasingID = TAE.GTPP_INDEX(aCasingID); + }*/ + + isHatch = this.addToMachineList(aBaseMetaTileEntity, aCasingID); + if (isHatch) { + return true; + } + else { + int aMetaTileID = aBaseMetaTileEntity.getMetaTileID(); + //Found a controller + if (aMetaTileID >= 750 && aMetaTileID < 1000 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + //Vanilla Hatches/Busses + else if (aMetaTileID >= 10 && aMetaTileID <= 99 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + //Adv Mufflers + else if (aMetaTileID >= 30001 && aMetaTileID <= 30009 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + //Control Core, Super IO + else if (aMetaTileID >= 30020 && aMetaTileID <= 30040 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + //Auto maint + else if (aMetaTileID == 111 && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + //Data Ports + else if ((aMetaTileID == 131 || aMetaTileID == 132) && aFoundBlock == GregTech_API.sBlockMachines) { + return true; + } + else { + log("Found meta Tile: "+aMetaTileID); + } + } + } + if (!isHatch) { + if (aFoundBlock == aExpectedBlock && aFoundMeta == aExpectedMeta) { + return true; + } + else if (aFoundBlock != aExpectedBlock) { + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("A1 - Found: "+aFoundBlock.getLocalizedName()+":"+aFoundMeta+", Expected: "+aExpectedBlock.getLocalizedName()+":"+aExpectedMeta); + //log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); + } + return false; + } + else if (aFoundMeta != aExpectedMeta) { + log("A2"); + return false; + } + + } + log("A3"); + return false; + } + + @Override + public boolean depleteInput(final FluidStack aLiquid) { + if (aLiquid == null) { + return false; + } + for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + tHatch.mRecipeMap = this.getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid == null || !tLiquid.isFluidEqual(aLiquid) || tLiquid.amount < aLiquid.amount) { + continue; + } + tLiquid = tHatch.drain(aLiquid.amount, false); + if (tLiquid != null && tLiquid.amount >= aLiquid.amount) { + tLiquid = tHatch.drain(aLiquid.amount, true); + return tLiquid != null && tLiquid.amount >= aLiquid.amount; + } + continue; + } + } + return false; + } + + @Override + public void onServerStart() { + super.onServerStart(); + tryTickWaitTimerDown(); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + tryTickWaitTimerDown(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + tryTickWaitTimerDown(); + } + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + super.onCreated(aStack, aWorld, aPlayer); + tryTickWaitTimerDown(); + } + + private final void tryTickWaitTimerDown() { + /*if (mStartUpCheck > 10) { + mStartUpCheck = 10; + }*/ + } + + //Only support to use meta to tier + public static <T> IStructureElement<T> addTieredBlock(Block aBlock, BiConsumer<T, Integer> aSetTheFuckingMeta, Function<T, Integer> aGetTheFuckingMeta, int maxMeta) { + return addTieredBlock(aBlock, (t, i) -> { + aSetTheFuckingMeta.accept(t, i); + return true; + }, aGetTheFuckingMeta, 0, maxMeta + ); + } + + public static <T> IStructureElement<T> addTieredBlock(Block aBlock, BiConsumer<T, Integer> aSetTheFuckingMeta, Function<T, Integer> aGetTheFuckingMeta, int minMeta, int maxMeta) { + return addTieredBlock(aBlock, (t, i) -> { + aSetTheFuckingMeta.accept(t, i); + return true; + }, aGetTheFuckingMeta, minMeta, maxMeta + ); + } + + public static <T> IStructureElement<T> addTieredBlock(Block aBlock, BiPredicate<T, Integer> aSetTheFuckingMeta, Function<T, Integer> aGetTheFuckingMeta, int minMeta, int maxMeta) { + + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + Block tBlock = world.getBlock(x, y, z); + if (aBlock == tBlock) { + Integer currentMeta = aGetTheFuckingMeta.apply(t); + int newMeta = tBlock.getDamageValue(world, x, y, z) + 1; + if (newMeta > maxMeta || newMeta < minMeta + 1) return false; + if (currentMeta == 0) { + return aSetTheFuckingMeta.test(t, newMeta); + } else { + return currentMeta == newMeta; + } + } + return false; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, aBlock, getMeta(trigger)); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return world.setBlock(x, y, z, aBlock, getMeta(trigger), 3); + } + + private int getMeta(ItemStack trigger) { + int meta = trigger.stackSize; + if (meta <= 0) meta = minMeta; + if (meta + minMeta >= maxMeta) meta = maxMeta - 1 - minMeta; + return meta + minMeta; + } + }; + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java new file mode 100644 index 0000000000..7bc8e4733d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java @@ -0,0 +1,802 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; + +import static gregtech.api.enums.GT_Values.V; +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.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.*; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusInput; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusOutput; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GregtechMeta_SteamMultiBase extends GregtechMeta_MultiBlockBase { + + public ArrayList<GT_MetaTileEntity_Hatch_Steam_BusInput> mSteamInputs = new ArrayList<GT_MetaTileEntity_Hatch_Steam_BusInput>(); + public ArrayList<GT_MetaTileEntity_Hatch_Steam_BusOutput> mSteamOutputs = new ArrayList<GT_MetaTileEntity_Hatch_Steam_BusOutput>(); + public ArrayList<GT_MetaTileEntity_Hatch_CustomFluidBase> mSteamInputFluids = new ArrayList<GT_MetaTileEntity_Hatch_CustomFluidBase>(); + + public GregtechMeta_SteamMultiBase(String aName) { + super(aName); + } + + public GregtechMeta_SteamMultiBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()), aActive ? getFrontOverlayActive() : getFrontOverlay()}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex())}; + } + + protected abstract GT_RenderedTexture getFrontOverlay(); + + protected abstract GT_RenderedTexture getFrontOverlayActive(); + + private int getCasingTextureIndex() { + return 10; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkRecipe(ItemStack arg0) { + + + log("Running checkRecipeGeneric(0)"); + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + GT_Recipe_Map tMap = this.getRecipeMap(); + if (tMap == null) { + return false; + } + ItemStack[] aItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] aFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[1], null, null, aItemInputs); + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + int aEUPercent = 100; + int aSpeedBonusPercent = 0; + int aOutputChanceRoll = 10000; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + + int aMaxParallelRecipes = canBufferOutputs(tRecipe.mOutputs, tRecipe.mFluidOutputs, this.getMaxParallelRecipes()); + 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("tRecipeEUt: "+tRecipeEUt); + + + + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (32 - 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 * 1.5f); + + this.mEUt = (int)Math.ceil(tTotalEUt*1.33f); + + //this.mEUt = (3 * tRecipe.mEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = getOutputFluids(tRecipe, parallelRecipes); + + // Collect output item types + ItemStack[] tOutputItems = getOutputItems(tRecipe); + + // 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; + + } + + public ArrayList<FluidStack> getAllSteamStacks(){ + ArrayList<FluidStack> aFluids = new ArrayList<FluidStack>(); + FluidStack aSteam = FluidUtils.getSteam(1); + for (FluidStack aFluid : this.getStoredFluids()) { + if (aFluid.isFluidEqual(aSteam)) { + aFluids.add(aFluid); + } + } + return aFluids; + } + + public int getTotalSteamStored() { + int aSteam = 0; + for (FluidStack aFluid : getAllSteamStacks()) { + aSteam += aFluid.amount; + } + return aSteam; + } + + public boolean tryConsumeSteam(int aAmount) { + if (getTotalSteamStored() <= 0) { + return false; + } + else { + return this.depleteInput(FluidUtils.getSteam(aAmount)); + } + } + + @Override + public int getMaxEfficiency(ItemStack arg0) { + return 0; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mSteamInputs.clear(); + this.mSteamOutputs.clear(); + this.mSteamInputFluids.clear(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + /** + * Called every tick the Machine runs + */ + public boolean onRunningTick(ItemStack aStack) { + fixAllMaintenanceIssue(); + if (mEUt < 0) { + long aSteamVal = (((long) -mEUt * 10000) / Math.max(1000, mEfficiency)); + //Logger.INFO("Trying to drain "+aSteamVal+" steam per tick."); + if (!tryConsumeSteam((int) aSteamVal)) { + stopMachine(); + return false; + } + } + return true; + } + + @Override + public boolean addToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + if (aTileEntity == null) { + log("Invalid IGregTechTileEntity"); + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + log("Invalid IMetaTileEntity"); + return false; + } + + //Use this to determine the correct value, then update the hatch texture after. + boolean aDidAdd = false; + + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase) { + log("Adding Steam Input Hatch"); + aDidAdd = addToMachineListInternal(mSteamInputFluids, aMetaTileEntity, aBaseCasingIndex); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput) { + log("Trying to set recipe map. Type: "+(getRecipeMap() != null ? getRecipeMap().mNEIName : "Null")); + this.resetRecipeMapForHatch(aTileEntity, getRecipeMap()); + log("Adding Steam Input Bus"); + aDidAdd = addToMachineListInternal(mSteamInputs, aMetaTileEntity, aBaseCasingIndex); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusOutput) { + log("Adding Steam Output Bus"); + aDidAdd = addToMachineListInternal(mSteamOutputs, aMetaTileEntity, aBaseCasingIndex); + } + + return aDidAdd; + } + + + + + @Override + public void stopMachine() { + super.stopMachine(); + } + + public FluidStack[] getOutputFluids(GT_Recipe aRecipe, int parallelRecipes) { + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[aRecipe.mFluidOutputs.length]; + for (int h = 0; h < aRecipe.mFluidOutputs.length; h++) { + if (aRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = aRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + return tOutputFluids; + } + + public ItemStack[] getOutputItems(GT_Recipe aRecipe) { + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[aRecipe.mOutputs.length]; + for (int h = 0; h < aRecipe.mOutputs.length; h++) { + if (aRecipe.getOutput(h) != null) { + tOutputItems[h] = aRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + return tOutputItems; + } + + public int getOutputCount(ItemStack[] aOutputs) { + return aOutputs.length; + } + public int getOutputFluidCount(FluidStack[] aOutputs) { + return aOutputs.length; + } + + public int canBufferOutputs(final ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aParallelRecipes) { + + log("Determining if we have space to buffer outputs. Parallel: "+aParallelRecipes); + + // Null recipe or a recipe with lots of outputs? + // E.G. Gendustry custom comb with a billion centrifuge outputs? + // Do it anyway, provided the multi allows it. Default behaviour is aAllow16SlotWithoutCheck = true. + if (aOutputs == null && aFluidOutputs == null) { + return 0; + } + + // Do we even need to check for item outputs? + boolean aDoesOutputItems = aOutputs != null ? aOutputs.length > 0 : false; + // Do we even need to check for fluid outputs? + boolean aDoesOutputFluids = aFluidOutputs != null ? aFluidOutputs.length > 0 : false; + + if (!aDoesOutputItems && !aDoesOutputFluids) { + return 0; + } + + /* ======================================== + * Item Management + * ======================================== + */ + + if (aDoesOutputItems) { + log("We have items to output."); + + // How many slots are free across all the output buses? + int aInputBusSlotsFree = 0; + + /* + * Create Variables for Item Output + */ + + AutoMap<FlexiblePair<ItemStack, Integer>> aItemMap = new AutoMap<FlexiblePair<ItemStack, Integer>>(); + AutoMap<ItemStack> aItemOutputs = new AutoMap<ItemStack>(aOutputs); + + for (final GT_MetaTileEntity_Hatch_Steam_BusOutput tBus : this.mSteamOutputs) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + final IInventory tBusInv = tBus.getBaseMetaTileEntity(); + for (int i = 0; i < tBusInv.getSizeInventory(); i++) { + if (tBus.getStackInSlot(i) == null) { + aInputBusSlotsFree++; + } + else { + ItemStack aT = tBus.getStackInSlot(i); + int aSize = aT.stackSize; + aT = aT.copy(); + aT.stackSize = 0; + aItemMap.put(new FlexiblePair<ItemStack, Integer>(aT, aSize)); + } + } + } + + // Count the slots we need, later we can check if any are able to merge with existing stacks + int aRecipeSlotsRequired = 0; + + // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the recipe outputs. + ConcurrentSet<FlexiblePair<ItemStack, Integer>> aInputMap = new ConcurrentHashSet<FlexiblePair<ItemStack, Integer>>(); + + // Iterate over the outputs, calculating require stack spacing they will require. + for (int i=0;i<getOutputCount(aOutputs);i++) { + ItemStack aY = aItemOutputs.get(i); + if (aY == null) { + continue; + } + else { + int aStackSize = aY.stackSize * aParallelRecipes; + if (aStackSize > 64) { + int aSlotsNeedsForThisStack = (int) Math.ceil((double) ((float) aStackSize / 64f)); + // Should round up and add as many stacks as required nicely. + aRecipeSlotsRequired += aSlotsNeedsForThisStack; + for (int o=0;o<aRecipeSlotsRequired;o++) { + int aStackToRemove = (aStackSize -= 64) > 64 ? 64 : aStackSize; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackToRemove)); + } + } + else { + // Only requires one slot + aRecipeSlotsRequired++; + aY = aY.copy(); + aY.stackSize = 0; + aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackSize)); + } + } + } + + // We have items to add to the output buses. See if any are not full stacks and see if we can make them full. + if (aInputMap.size() > 0) { + // Iterate over the current stored items in the Output busses, if any match and are not full, we can try account for merging. + busItems: for (FlexiblePair<ItemStack, Integer> y : aItemMap) { + // Iterate over the 'inputs', we can safely remove these as we go. + outputItems: for (FlexiblePair<ItemStack, Integer> u : aInputMap) { + // Create local vars for readability. + ItemStack aOutputBusStack = y.getKey(); + ItemStack aOutputStack = u.getKey(); + // Stacks match, including NBT. + if (GT_Utility.areStacksEqual(aOutputBusStack, aOutputStack, false)) { + // Stack Matches, but it's full, continue. + if (aOutputBusStack.stackSize >= 64) { + // This stack is full, no point checking it. + continue busItems; + } + else { + // We can merge these two stacks without any hassle. + if ((aOutputBusStack.stackSize + aOutputStack.stackSize) <= 64) { + // Update the stack size in the bus storage map. + y.setValue(aOutputBusStack.stackSize + aOutputStack.stackSize); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + continue outputItems; + } + // Stack merging is too much, so we fill this stack, leave the remainder. + else { + int aRemainder = (aOutputBusStack.stackSize + aOutputStack.stackSize) - 64; + // Update the stack size in the bus storage map. + y.setValue(64); + // Create a new object to iterate over later, with the remainder data; + FlexiblePair<ItemStack, Integer> t = new FlexiblePair<ItemStack, Integer>(u.getKey(), aRemainder); + // Remove the 'input' stack from the recipe outputs, so we don't try count it again. + aInputMap.remove(u); + // Add the remainder stack. + aInputMap.add(t); + continue outputItems; + } + } + } + else { + continue outputItems; + } + } + } + } + + // We have stacks that did not merge, do we have space for them? + if (aInputMap.size() > 0) { + if (aInputMap.size() > aInputBusSlotsFree) { + aParallelRecipes = (int) Math.floor((double) aInputBusSlotsFree/aInputMap.size() * aParallelRecipes); + // We do not have enough free slots in total to accommodate the remaining managed stacks. + log(" Free: "+aInputBusSlotsFree+", Required: "+aInputMap.size()); + if(aParallelRecipes == 0) { + log("Failed to find enough space for all item outputs."); + return 0; + } + + } + } + + /* + * End Item Management + */ + + } + + + + + + /* ======================================== + * Fluid Management + * ======================================== + */ + + + + if (aDoesOutputFluids) { + log("We have Fluids to output."); + // How many slots are free across all the output buses? + int aFluidHatches = 0; + int aEmptyFluidHatches = 0; + int aFullFluidHatches = 0; + // Create Map for Fluid Output + ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>> aOutputHatches = new ArrayList<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>>(); + for (final GT_MetaTileEntity_Hatch_Output tBus : this.mOutputHatches) { + if (!isValidMetaTileEntity(tBus)) { + continue; + } + aFluidHatches++; + // Map the Hatch with the space left for easy checking later. + if (tBus.getFluid() == null) { + aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, null, tBus.getCapacity())); + } + else { + int aSpaceLeft = tBus.getCapacity() - tBus.getFluidAmount(); + aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, tBus.getFluid(), aSpaceLeft)); + } + } + // Create a map of all the fluids we would like to output, we can iterate over this and see how many we can merge into existing hatch stacks. + ArrayList<FluidStack> aOutputFluids = new ArrayList<FluidStack>(); + // Ugly ass boxing + aOutputFluids.addAll(new AutoMap<FluidStack>(aFluidOutputs)); + // Iterate the Hatches, updating their 'stored' data. + //for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aHatchData : aOutputHatches) { + for (int i = 0;i<aOutputHatches.size();i++) { + // The Hatch Itself + GT_MetaTileEntity_Hatch_Output aHatch = aOutputHatches.get(i).getValue_1(); + // Fluid in the Hatch + FluidStack aHatchStack = aOutputHatches.get(i).getValue_2(); + // Space left in Hatch + int aSpaceLeftInHatch = aHatch.getCapacity() - aHatch.getFluidAmount(); + // Hatch is full, + if (aSpaceLeftInHatch <= 0) { + aFullFluidHatches++; + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + continue; + } + // Hatch has space + else { + // Check if any fluids match + //aFluidMatch: for (FluidStack aOutputStack : aOutputFluids) { + for(int j = 0;j<getOutputFluidCount(aFluidOutputs);j++) { + //log(" aHatchStack "+aHatchStack.getLocalizedName()+" aOutput stack "+aOutputStack.getLocalizedName()); + if (GT_Utility.areFluidsEqual(aHatchStack, aOutputFluids.get(j))) { + int aFluidToPutIntoHatch = aOutputFluids.get(j).amount * aParallelRecipes; + // Not Enough space to insert all of the fluid. + // We fill this hatch and add a smaller Fluidstack back to the iterator. + if (aSpaceLeftInHatch < aFluidToPutIntoHatch) { + // Copy existing Hatch Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + aNewHatchStack.amount = 0; + // Copy existing Hatch Stack again + FluidStack aNewOutputStack = aHatchStack.copy(); + aNewOutputStack.amount = 0; + // How much fluid do we have left after we fill the hatch? + int aFluidLeftAfterInsert = aFluidToPutIntoHatch - aSpaceLeftInHatch; + // Set new stacks to appropriate values + aNewHatchStack.amount = aHatch.getCapacity(); + aNewOutputStack.amount = aFluidLeftAfterInsert; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Add remaining Fluid to Output list + aOutputFluids.add(aNewOutputStack); + // Re-add hatch to hatch list, with new data. + //Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); + //aOutputHatches.add(aNewHatchData); + break; + } + // We can fill this hatch perfectly (rare case), may as well add it directly to the full list. + else if (aSpaceLeftInHatch == aFluidToPutIntoHatch) { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + break; + } + // We have more space than we need to merge, so we remove the stack from the output list and update the hatch list. + else { + // Copy Old Stack + FluidStack aNewHatchStack = aHatchStack.copy(); + // Add in amount from output stack + aNewHatchStack.amount += aFluidToPutIntoHatch; + // Remove fluid from output list, merge success + aOutputFluids.remove(aOutputFluids.get(j)); + j--; + // Remove hatch from hatch list, data is now invalid. + aOutputHatches.remove(aOutputHatches.get(i)); + i--; + // Re-add hatch to hatch list, with new data. + Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount); + aOutputHatches.add(aNewHatchData); + // Check next fluid + continue; + } + + } + else { + continue; + } + } + } + } + + for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aFreeHatchCheck : aOutputHatches) { + // Free Hatch + if (aFreeHatchCheck.getValue_2() == null || aFreeHatchCheck.getValue_3() == 0 || aFreeHatchCheck.getValue_1().getFluid() == null) { + aEmptyFluidHatches++; + } + } + + // We have Fluid Stacks we did not merge. Do we have space? + log("fluids to output "+aOutputFluids.size()+" empty hatches "+aEmptyFluidHatches); + if (aOutputFluids.size() > 0) { + // Not enough space to add fluids. + if (aOutputFluids.size() > aEmptyFluidHatches) { + aParallelRecipes = (int) Math.floor((double) aEmptyFluidHatches/aOutputFluids.size() * aParallelRecipes); + log("Failed to find enough space for all fluid outputs. Free: "+aEmptyFluidHatches+", Required: "+aOutputFluids.size()); + return 0; + + } + } + + /* + * End Fluid Management + */ + } + + return aParallelRecipes; + } + + + /* + * Handle I/O with custom hatches + */ + + @Override + public boolean depleteInput(FluidStack aLiquid) { + if (aLiquid == null) return false; + for (GT_MetaTileEntity_Hatch_Input tHatch : mSteamInputFluids) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(aLiquid)) { + tLiquid = tHatch.drain(aLiquid.amount, false); + if (tLiquid != null && tLiquid.amount >= aLiquid.amount) { + tLiquid = tHatch.drain(aLiquid.amount, true); + return tLiquid != null && tLiquid.amount >= aLiquid.amount; + } + } + } + } + return false; + } + + @Override + public boolean depleteInput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); + if (aLiquid != null) return depleteInput(aLiquid); + for (GT_MetaTileEntity_Hatch_Input tHatch : mSteamInputFluids) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + for (GT_MetaTileEntity_Hatch_Steam_BusInput tHatch : mSteamInputs) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + } + return false; + } + + @Override + public ArrayList<FluidStack> getStoredFluids() { + ArrayList<FluidStack> rList = new ArrayList<FluidStack>(); + for (GT_MetaTileEntity_Hatch_Input tHatch : mSteamInputFluids) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { + rList.add(tHatch.getFillableStack()); + } + } + return rList; + } + + @Override + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + for (GT_MetaTileEntity_Hatch_Steam_BusInput tHatch : mSteamInputs) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + } + return rList; + } + + @Override + public boolean addOutput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + aStack = GT_Utility.copy(aStack); + boolean outputSuccess = true; + while (outputSuccess && aStack.stackSize > 0) { + outputSuccess = false; + ItemStack single = aStack.splitStack(1); + for (GT_MetaTileEntity_Hatch_Steam_BusOutput tHatch : mSteamOutputs) { + if (!outputSuccess && isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getSizeInventory() - 1; i >= 0 && !outputSuccess; i--) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, single)) outputSuccess = true; + } + } + } + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (!outputSuccess && isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, single)) outputSuccess = true; + } + } + } + return outputSuccess; + } + + @Override + public ArrayList<ItemStack> getStoredOutputs() { + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + for (GT_MetaTileEntity_Hatch_Steam_BusOutput tHatch : mSteamOutputs) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } + + @Override + public void updateSlots() { + for (GT_MetaTileEntity_Hatch_Input tHatch : mSteamInputFluids) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + for (GT_MetaTileEntity_Hatch_Steam_BusInput tHatch : mSteamInputs) + if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java new file mode 100644 index 0000000000..287d2105ac --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java @@ -0,0 +1,428 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators; + +import static gregtech.api.enums.GT_Values.V; + +import java.util.Collection; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GregtechDoubleFuelGeneratorBase extends GT_MetaTileEntity_DeluxeTank { + + private boolean useFuel = false; + + public GregtechDoubleFuelGeneratorBase(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 4, aDescription, aTextures); + } + + public GregtechDoubleFuelGeneratorBase(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, "Fuel Efficiency: " + this.getEfficiency() + "%"}; + } + + + /* @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + }*/ + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + Logger.WARNING("Entity is Client side, simply returning true"); + return true; + } + Logger.WARNING("Entity is not Client side, opening entity Container and by extension, it's GUI, then returning true"); + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public boolean isFacingValid(final byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return true; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return this.getBaseMetaTileEntity().isAllowedToWork() ? V[this.mTier] : 0; + } + + @Override + public long maxEUStore() { + return Math.max(this.getEUVar(), (V[this.mTier] * 115) + this.getMinimumStoredEU()); + } + + @Override + public boolean doesFillContainers() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean doesEmptyContainers() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeFilled() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeEmptied() { + return this.getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return this.getFuelValue(aFluid) > 0; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + if ((this.mFluid != null) && (this.mFluid2 != null)){ + final int tFuelValue = this.getFuelValue(this.mFluid), tConsumed = this.consumedFluidPerOperation(this.mFluid); + final int tFuelValue2 = this.getFuelValue(this.mFluid2), tConsumed2 = this.consumedFluidPerOperation(this.mFluid2); + if (((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed))/* && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)*/) { + + Logger.WARNING("tFuelValue: "+tFuelValue); + Logger.WARNING("tConsumed: "+tConsumed); + Logger.WARNING("mFluid.name: "+this.mFluid.getFluid().getName()); + Logger.WARNING("mFluid.amount: "+this.mFluid.amount); + Logger.WARNING("mFluid.amount > tConsumed: "+(this.mFluid.amount > tConsumed)); + + Logger.WARNING("========================================================="); + + Logger.WARNING("tFuelValue2: "+tFuelValue2); + Logger.WARNING("tConsumed2: "+tConsumed2); + Logger.WARNING("mFluid2.name: "+this.mFluid2.getFluid().getName()); + Logger.WARNING("mFluid2.amount: "+this.mFluid2.amount); + Logger.WARNING("mFluid2.amount > tConsumed2: "+(this.mFluid2.amount > tConsumed2)); + long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, (((this.maxEUOutput() * 30) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + long tFluidAmountToUse2 = Math.min(this.mFluid2.amount / tConsumed2, (((this.maxEUOutput() * 30) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2); + + if (tFluidAmountToUse <= 0){ + /*if ((mFluid.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse = 1; + }*/ + + if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ + tFluidAmountToUse = 1; + Logger.WARNING("========================================================="); + Logger.WARNING("tFluidAmountToUse - Updated: "+tFluidAmountToUse); + Logger.WARNING("========================================================="); + } + } + + if (tFluidAmountToUse2 <= 0){ + /*if ((mFluid2.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse2 = 1; + }*/ + if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ + tFluidAmountToUse2 = 1; + Logger.WARNING("========================================================="); + Logger.WARNING("tFluidAmountToUse2 - Updated: "+tFluidAmountToUse2); + Logger.WARNING("========================================================="); + } + } + + Logger.WARNING("========================================================="); + Logger.WARNING("tFluidAmountToUse: "+tFluidAmountToUse); + Logger.WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid.amount / tConsumed: "+("fluidAmount:"+mFluid.amount)+(" tConsumed:"+tConsumed)+" | "+(mFluid.amount / tConsumed)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue: "+(tFuelValue)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue)); + */ + + Logger.WARNING("========================================================="); + Logger.WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); + Logger.WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid2.amount / tConsumed2: "+("fluidAmount2:"+mFluid2.amount)+(" tConsumed2:"+tConsumed2)+" | "+(mFluid2.amount / tConsumed2)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue2: "+(tFuelValue2)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2)); + */ + if (((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) && ((tFluidAmountToUse2 > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse2 * tFuelValue2, true))){ + + Logger.WARNING("tFuelValue: "+tFuelValue); + Logger.WARNING("tConsumed: "+tConsumed); + Logger.WARNING("mFluid.name: "+this.mFluid.getFluid().getName()); + Logger.WARNING("mFluid.amount: "+this.mFluid.amount); + Logger.WARNING("mFluid.amount > tConsumed: "+(this.mFluid.amount > tConsumed)); + + Logger.WARNING("========================================================="); + + Logger.WARNING("tFuelValue2: "+tFuelValue2); + Logger.WARNING("tConsumed2: "+tConsumed2); + Logger.WARNING("mFluid2.name: "+this.mFluid2.getFluid().getName()); + Logger.WARNING("mFluid2.amount: "+this.mFluid2.amount); + Logger.WARNING("mFluid2.amount > tConsumed2: "+(this.mFluid2.amount > tConsumed2)); + + if (this.useFuel){ + this.mFluid.amount -= tFluidAmountToUse * tConsumed; + this.mFluid2.amount -= tFluidAmountToUse2 * tConsumed2; + this.useFuel = false; + } + else { + this.useFuel = true; + } + + } + else { + Logger.WARNING("========================================================="); + Logger.WARNING("Either tFluidAmountToUse1 <= 0, power cannot be increased of tFluidAmountToUse2 <= 0"); + Logger.WARNING("tFluidAmountToUse1: "+tFluidAmountToUse); + Logger.WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); + } + } + else { + /*Utils.LOG_WARNING("(tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)"); + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); */ + } + } + else { + Logger.WARNING("One mFluid is null"); + if (this.mFluid != null) { + Logger.WARNING("mFluid1 is not null"); + } + if (this.mFluid2 != null) { + Logger.WARNING("mFluid2 is not null"); + } + } + } + if ((this.mInventory[this.getInputSlot()] != null) && (aBaseMetaTileEntity.getUniversalEnergyStored() < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())) && (GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null)) { + final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && (aBaseMetaTileEntity.getUniversalEnergyStored() >= (this.maxEUOutput() + this.getMinimumStoredEU()))); + } + } + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(final FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(final FluidStack aLiquid) { + if ((aLiquid == null) || (this.getRecipes() == null)) { + return 0; + } + FluidStack tLiquid; + final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; + if (tRecipeList != null) { + for (final GT_Recipe tFuel : tRecipeList) { + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) { + if (aLiquid.isFluidEqual(tLiquid)) { + return (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * this.consumedFluidPerOperation(tLiquid)) / 100); + } + } + } + } + return 0; + } + + public int getFuelValue(final ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { + return 0; + } + final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) { + return (int) ((tFuel.mSpecialValue * 1000L * this.getEfficiency()) / 100); + } + return 0; + } + + public ItemStack getEmptyContainer(final ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { + return null; + } + final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) { + return GT_Utility.copy(tFuel.getOutput(0)); + } + return GT_Utility.getContainerItem(aStack, true); + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && ((this.getFuelValue(aStack) > 0) || (this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public int getTankPressure() { + return -100; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java new file mode 100644 index 0000000000..99ad81a4a9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaBoilerBase.java @@ -0,0 +1,382 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public abstract class GregtechMetaBoilerBase extends GT_MetaTileEntity_BasicTank +{ + public int mTemperature = 20; + public int mProcessingEnergy = 0; + public int mLossTimer = 0; + public FluidStack mSteam = null; + public boolean mHadNoWater = false; + public long RI = MathUtils.randLong(5L, 30L); + + public GregtechMetaBoilerBase(final int aID, final String aName, final String aNameRegional, final String aDescription, final ITexture... aTextures) + { + super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); + } + + public GregtechMetaBoilerBase(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) + { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) + { + ITexture[] tmp = this.mTextures[aSide >= 2 ? aSide != aFacing ? 2 : ((byte)(aActive ? 4 : 3)) : aSide][aColorIndex + 1]; + //mTextures[(aSide==aFacing?(aActive?4:3):aSide==GT_Utility.getOppositeSide(aFacing)?2:aSide==0?0:aSide==1?1:2)][aColorIndex+1]; + if((aSide!=aFacing)&&(tmp.length==2)){ + tmp = new ITexture[]{tmp[0]}; + } + return tmp; + } + + @Override + public boolean isElectric() + { + return false; + } + + @Override + public boolean isPneumatic() + { + return false; + } + + @Override + public boolean isSteampowered() + { + return false; + } + + @Override + public boolean isSimpleMachine() + { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) + { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) + { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) + { + return true; + } + + @Override + public int getProgresstime() + { + return this.mTemperature; + } + + @Override + public int maxProgresstime() + { + return 500; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) + { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + if (aPlayer != null) { + if (GT_Utility.areStacksEqual(aPlayer.getCurrentEquippedItem(), new ItemStack(Items.water_bucket, 1))) + { + this.fill(Materials.Water.getFluid(1000 * aPlayer.getCurrentEquippedItem().stackSize), true); + aPlayer.getCurrentEquippedItem().func_150996_a(Items.bucket); + } + else + { + aBaseMetaTileEntity.openGUI(aPlayer); + } + } + return true; + } + + @Override + public boolean doesFillContainers() + { + return true; + } + + @Override + public boolean doesEmptyContainers() + { + return true; + } + + @Override + public boolean canTankBeFilled() + { + return true; + } + + @Override + public boolean canTankBeEmptied() + { + return true; + } + + @Override + public boolean displaysItemStack() + { + return false; + } + + @Override + public boolean displaysStackSize() + { + return false; + } + + @Override + public boolean isFluidInputAllowed(final FluidStack aFluid) + { + return GT_ModHandler.isWater(aFluid); + } + + @Override + public FluidStack getDrainableStack() + { + return this.mSteam; + } + + @Override + public FluidStack setDrainableStack(final FluidStack aFluid) + { + this.mSteam = aFluid; + return this.mSteam; + } + + @Override + public boolean isDrainableStackSeparate() { + return true; + } + + @Override + public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCover) + { + return GregTech_API.getCoverBehavior(aCover.toStack()).isSimpleCover(); + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) + { + super.saveNBTData(aNBT); + aNBT.setInteger("mLossTimer", this.mLossTimer); + aNBT.setInteger("mTemperature", this.mTemperature); + aNBT.setInteger("mProcessingEnergy", this.mProcessingEnergy); + if (this.mSteam != null) { + try + { + aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound())); + } + catch (final Throwable e) {} + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) + { + super.loadNBTData(aNBT); + this.mLossTimer = aNBT.getInteger("mLossTimer"); + this.mTemperature = aNBT.getInteger("mTemperature"); + this.mProcessingEnergy = aNBT.getInteger("mProcessingEnergy"); + this.mSteam = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mSteam")); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) + { + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) + { + if (this.mTemperature <= 20) + { + this.mTemperature = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 40) + { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { + if (i != aBaseMetaTileEntity.getFrontFacing()) + { + final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) + { + final FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) + { + final int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); + } + } + } + } + } + if ((aTick % 10L) == 0L) { + if (this.mTemperature > 100) + { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) + { + this.mHadNoWater = true; + } + else + { + if (this.mHadNoWater) + { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(150L); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += 150; + } else { + this.mSteam = GT_ModHandler.getSteam(150L); + } + } + } + else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && + (this.mSteam.amount > getSteamCapacity())) + { + this.sendSound((byte)1); + this.mSteam.amount = getSteamCapacity() * 3 / 4; + } + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && + (this.mInventory[2] != null)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal)))) + { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal))) + { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } + else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke")) + { + this.mProcessingEnergy += 640; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(2) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } + else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite)))) + { + this.mProcessingEnergy += 40; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(8) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + } + if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && ((aTick % 12L) == 0L)) + { + this.mProcessingEnergy -= 2; + this.mTemperature += 1; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } + + @Override + // Since this type of machine can have different water and steam capacities, we need to override getTankInfo() to + // support returning those different capacities. + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + return new FluidTankInfo[]{ + new FluidTankInfo(this.mFluid, getCapacity()), + new FluidTankInfo(this.mSteam, getSteamCapacity()) + }; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) + { + return (aIndex == 1) || (aIndex == 3); + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) + { + return aIndex == 2; + } + + @Override + public void doSound(final byte aIndex, final double aX, final double aY, final double aZ) + { + if (aIndex == 1) + { + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(4)), 2, 1.0F, aX, aY, aZ); + for (int l = 0; l < 8; l++) { + this.getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", (aX - 0.5D) + Math.random(), aY, (aZ - 0.5D) + Math.random(), 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + public int getCapacity() + { + return 16000; + } + + // This type of machine can have different water and steam capacities. + public int getSteamCapacity() + { + return 32000; + } + + @Override + public int getTankPressure() + { + return 100; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java new file mode 100644 index 0000000000..e692530963 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechMetaSolarGenerator.java @@ -0,0 +1,215 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators; + +import static gregtech.api.enums.GT_Values.V; + +import net.minecraft.entity.player.EntityPlayer; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.util.GT_Utility; + +public abstract class GregtechMetaSolarGenerator extends GT_MetaTileEntity_BasicTank { + + public int mEfficiency; + public int mProcessingEnergy = 0; + public int mSolarCharge = 20; + public int mLossTimer = 0; + public static int sEnergyPerTick = 16; + + public GregtechMetaSolarGenerator(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + } + + public GregtechMetaSolarGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, "Efficiency: " + this.getEfficiency() + "%"}; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public boolean isFacingValid(final byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return true; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return this.getBaseMetaTileEntity().isAllowedToWork() ? V[this.mTier] : 0; + } + + @Override + public long maxEUStore() { + return Math.max(this.getEUVar(), (V[this.mTier] * 40) + this.getMinimumStoredEU()); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick > 20L) + && (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + aBaseMetaTileEntity.getEUCapacity()))) { + + if (this.mSolarCharge <= 20) { + this.mSolarCharge = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 45) { + this.mSolarCharge -= 1; + this.mLossTimer = 0; + } + + if ((aTick % 25L) == 0L) { + if (this.mSolarCharge > 100) { + if ((this.mProcessingEnergy > 0) && (aBaseMetaTileEntity.isAllowedToWork()) && ((aTick % 256L) == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering() && (aBaseMetaTileEntity.getUniversalEnergyStored() < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())))) { + this.getBaseMetaTileEntity().increaseStoredEnergyUnits((sEnergyPerTick * this.getEfficiency()) / 10, false); + } + } + } + + if ((this.mSolarCharge < 500) && (this.mProcessingEnergy > 0) && ((aTick % 12L) == 0L)) { + this.mProcessingEnergy -= 1; + this.mSolarCharge += 1; + } + + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && ((aTick % 256L) == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { + final boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && (aBaseMetaTileEntity.getBiome().rainfall > 0.0F); + this.mProcessingEnergy += (bRain && (aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4)) || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; + } + + if (aBaseMetaTileEntity.isServerSide()){ + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && (aBaseMetaTileEntity.getUniversalEnergyStored() >= (this.maxEUOutput() + this.getMinimumStoredEU()))); + } + } + } + + public abstract int getEfficiency(); + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java new file mode 100644 index 0000000000..f9105dceb1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java @@ -0,0 +1,372 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators; + +import static gregtech.api.enums.GT_Values.V; + +import java.util.Collection; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_BasicTank { + + private boolean useFuel = false; + protected int pollMin, pollMax; + + public GregtechRocketFuelGeneratorBase(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); + int pollMin = (int)(CORE.ConfigSwitches.baseMinPollutionPerSecondRocketFuelGenerator * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); + int pollMax = (int)(CORE.ConfigSwitches.baseMaxPollutionPerSecondRocketFuelGenerator * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); + } + + public GregtechRocketFuelGeneratorBase(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + int pollMin = (int)(CORE.ConfigSwitches.baseMinPollutionPerSecondRocketFuelGenerator * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); + int pollMax = (int)(CORE.ConfigSwitches.baseMaxPollutionPerSecondRocketFuelGenerator * CORE.ConfigSwitches.pollutionReleasedByTierRocketFuelGenerator[mTier]); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + @Override + public String[] getDescription() { + String aPollution = "Causes between "+pollMin+" and "+pollMax+ " Pollution per second"; + return new String[]{ + this.mDescription, + "Fuel Efficiency: " + this.getEfficiency() + "%", + aPollution, + CORE.GT_Tooltip}; + } + + + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public boolean isFacingValid(final byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return this.getBaseMetaTileEntity().getFrontFacing() == aSide; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return V[this.mTier]; + } + + @Override + public long maxEUStore() { + return Math.max(this.getEUVar(), (V[this.mTier] * 500) + this.getMinimumStoredEU()); + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(final FluidStack aFluid) { + return this.getFuelValue(aFluid) > 0; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + + + //super.onPostTick(aBaseMetaTileEntity, aTick); + + /*if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { + int tFuelValue; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + tFuelValue = this.getFuelValue(this.mFluid); + int tConsumed = this.consumedFluidPerOperation(this.mFluid); + if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { + long tFluidAmountToUse = Math.min((long) (this.mFluid.amount / tConsumed), + (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); + if (tFluidAmountToUse > 0L && aBaseMetaTileEntity + .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + this.mFluid.amount = (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); + } + } + } + + if (this.mInventory[this.getInputSlot()] != null + && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + + this.getMinimumStoredEU() + && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { + tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity + .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); + }*/ + + + + + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + final int tFuelValue = this.getFuelValue(this.mFluid), tConsumed = this.consumedFluidPerOperation(this.mFluid); + if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount >= tConsumed)) { + final long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, (((this.maxEUOutput() * 20) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + if ((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ + int aSafeFloor = (int) Math.max(((tFluidAmountToUse * tConsumed)/3), 1); + this.mFluid.amount -= (int) aSafeFloor; + PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution()); + } + } + } + if ((this.mInventory[this.getInputSlot()] != null) && (aBaseMetaTileEntity.getUniversalEnergyStored() < ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())) && (GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null)) { + final int tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + final ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution()); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && (aBaseMetaTileEntity.getUniversalEnergyStored() >= (this.maxEUOutput() + this.getMinimumStoredEU()))); + } + } + + public int getPollution() { + return MathUtils.randInt(pollMin, pollMax); + } + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(final FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(final FluidStack aLiquid) { + if ((aLiquid == null) || (this.getRecipes() == null)) { + return 0; + } + FluidStack tLiquid; + final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; + if (tRecipeList != null) { + //Logger.INFO("Step A"); + for (final GT_Recipe tFuel : tRecipeList) { + //Logger.INFO("Step B"); + if ((tLiquid = tFuel.mFluidInputs[0]) != null) { + //Logger.INFO("Step C"); + if (aLiquid.isFluidEqual(tLiquid)) { + //Logger.INFO("Found some fuel?"); + int aperOp = this.consumedFluidPerOperation(tLiquid); + int aConsume = (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * aperOp) / 100); + //Logger.INFO("Fuel Value: "+tFuel.mSpecialValue); + //Logger.INFO("Efficiency: "+getEfficiency()); + //Logger.INFO("Consumed per op: "+aperOp); + //Logger.INFO("Consuming "+aConsume); + return aConsume; + } + } + } + } + //Logger.INFO("No Fuel Value | Valid? "+(aLiquid != null)); + return 0; + } + + public int getFuelValue(final ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { + return 0; + } + final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) { + return (int) ((tFuel.mSpecialValue * 1000L * this.getEfficiency()) / 100); + } + return 0; + } + + public ItemStack getEmptyContainer(final ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || (this.getRecipes() == null)) { + return null; + } + final GT_Recipe tFuel = this.getRecipes().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) { + return GT_Utility.copy(tFuel.getOutput(0)); + } + return GT_Utility.getContainerItem(aStack, true); + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && ((this.getFuelValue(aStack) > 0) || (this.getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public int getTankPressure() { + return -100; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java new file mode 100644 index 0000000000..34b3e86c70 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java @@ -0,0 +1,291 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines; + +import static gregtech.api.enums.GT_Values.V; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.player.PlayerCache; + +public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_TieredMachineBlock { + public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false; + public int mSuccess = 0, mTargetStackSize = 0; + public UUID ownerUUID; + //UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); + private boolean value_last = false, value_current = false; + + public GregtechMetaSafeBlockBase(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GregtechMetaSafeBlockBase(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[6][17][]; + final ITexture tIcon = this.getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST), tUp = new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT); + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tUp, tIcon}; //Back + rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon}; // Right, Strangely The top side as well when facing East? + rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon}; // Top And Bottom, When Facing South (What the hell?) + rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon}; // Left, Top if facing West and Bottom if facing east? + rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tIcon}; // Top and Bottom when Facing North.. + rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][i + 1], tOut}; // Front + } + return rTextures; + + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return this.mTextures[5][aColorIndex + 1]; + } + if (GT_Utility.getOppositeSide(aSide) == aFacing) { + return this.mTextures[0][aColorIndex + 1]; + } + switch (aFacing) { + case 0: + return this.mTextures[4][aColorIndex + 1]; + case 1: + return this.mTextures[2][aColorIndex + 1]; + case 2: + switch (aSide) { + case 0: + return this.mTextures[2][aColorIndex + 1]; + case 1: + return this.mTextures[2][aColorIndex + 1]; + case 4: + return this.mTextures[1][aColorIndex + 1]; + case 5: + return this.mTextures[3][aColorIndex + 1]; + } + case 3: + switch (aSide) { + case 0: + return this.mTextures[4][aColorIndex + 1]; + case 1: + return this.mTextures[4][aColorIndex + 1]; + case 4: + return this.mTextures[3][aColorIndex + 1]; + case 5: + return this.mTextures[1][aColorIndex + 1]; + } + case 4: + switch (aSide) { + case 0: + return this.mTextures[3][aColorIndex + 1]; + case 1: + return this.mTextures[1][aColorIndex + 1]; + case 2: + return this.mTextures[3][aColorIndex + 1]; + case 3: + return this.mTextures[1][aColorIndex + 1]; + } + case 5: + switch (aSide) { + case 0: + return this.mTextures[1][aColorIndex + 1]; + case 1: + return this.mTextures[3][aColorIndex + 1]; + case 2: + return this.mTextures[1][aColorIndex + 1]; + case 3: + return this.mTextures[3][aColorIndex + 1]; + } + } + return this.mTextures[5][aColorIndex + 1]; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < (this.mInventory.length - 1); + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return !this.isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return this.getBaseMetaTileEntity().getBackFacing() == aSide; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public long maxEUStore() { + return 512 + (V[this.mTier] * 50); + } + + @Override + public long maxEUInput() { + return V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return this.bOutput ? V[this.mTier] : 0; + } + + @Override + public long maxAmperesIn() { + return 1; + } + + @Override + public long maxAmperesOut() { + return 1; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + public abstract ITexture getOverlayIcon(); + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + + if (aBaseMetaTileEntity.isClientSide()) { + //Utils.LOG_WARNING("Clicky Clicky."); + return true; + + } + if (aPlayer != null) { + final UUID tempUUID = aPlayer.getUniqueID(); + /*if (!aPlayer.worldObj.isRemote){ + //PlayerCache.appendParamChanges(aPlayer.getDisplayName(), aPlayer.getUniqueID().toString()); + }*/ + //Utils.LOG_INFO("test"); + if (this.ownerUUID == null){ + Logger.INFO("No owner yet for this block."); + } + else { + //Utils.LOG_INFO("test"); + Logger.INFO("Current Owner: "+PlayerCache.lookupPlayerByUUID(this.ownerUUID)+" - UUID: "+this.ownerUUID); + } + Logger.WARNING("Is ownerUUID Null"); + if (this.ownerUUID == null){ + Logger.WARNING("OwnerUUID is Null, let's set it."); + Logger.WARNING("Accessing Players UUID is: "+tempUUID); + this.ownerUUID = tempUUID; + //Utils.messagePlayer(aPlayer, "Owner of this safe, now set. Try accessing it again."); + Logger.WARNING("Block Owner is now set to: "+this.ownerUUID); + } + Logger.WARNING("No, it is not."); + Logger.WARNING("Checking ownerUUID."); + if (this.ownerUUID != null){ + Logger.WARNING("ownerUUID != Null, if accessor == owner."); + Logger.WARNING("Accessing is: "+PlayerCache.lookupPlayerByUUID(tempUUID)); + if (this.ownerUUID.equals(tempUUID)){ + Logger.WARNING("Owner's UUID: "+this.ownerUUID); + aBaseMetaTileEntity.openGUI(aPlayer); + //Utils.LOG_WARNING("GUI should now be open for you sir."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Access Denied, This does not belong to you."); + PlayerUtils.messagePlayer(aPlayer, "it is owned by: "+PlayerCache.lookupPlayerByUUID(this.ownerUUID)); + Logger.WARNING("Expecting Player : "+PlayerCache.lookupPlayerByUUID(this.ownerUUID)); + Logger.ERROR("Access Denied."); + return true; + } + + } + + /*else { + Utils.LOG_ERROR("This is NOT good. Tell Draknyte1 your safe broke."); + }*/ + /*Utils.LOG_WARNING("Clicky Clicky."); + Utils.messagePlayer(aPlayer, "Owner of this safe, now set."); + aBaseMetaTileEntity.openGUI(aPlayer); */ + + } + return true; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setBoolean("bUnbreakable", this.bUnbreakable); + aNBT.setBoolean("bOutput", this.bOutput); + aNBT.setBoolean("bRedstoneIfFull", this.bRedstoneIfFull); + aNBT.setInteger("mTargetStackSize", this.mTargetStackSize); + if (this.ownerUUID != null) { + aNBT.setString("ownerUUID", this.ownerUUID.toString()); + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.bUnbreakable = aNBT.getBoolean("bUnbreakable"); + this.bOutput = aNBT.getBoolean("bOutput"); + this.bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull"); + this.mTargetStackSize = aNBT.getInteger("mTargetStackSize"); + if (aNBT.hasKey("ownerUUID")) { + this.ownerUUID = UUID.fromString(aNBT.getString("ownerUUID")); + } + } + + @Override + public void setItemNBT(final NBTTagCompound aNBT) { + super.setItemNBT(aNBT); + if (this.mTargetStackSize > 0) { + aNBT.setInteger("mTargetStackSize", this.mTargetStackSize); + } + } + + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aSide != aBaseMetaTileEntity.getBackFacing(); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java new file mode 100644 index 0000000000..df838f012a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaTreeFarmerBase.java @@ -0,0 +1,176 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public abstract class GregtechMetaTreeFarmerBase extends GT_MetaTileEntity_TieredMachineBlock { + public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false; + public int mSuccess = 0, mTargetStackSize = 0; + + public GregtechMetaTreeFarmerBase(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GregtechMetaTreeFarmerBase(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return !this.isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return this.getBaseMetaTileEntity().getBackFacing() == aSide; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return false; + } + + public abstract ITexture getOverlayIcon(); + + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Podzol)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java new file mode 100644 index 0000000000..5e0918059d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java @@ -0,0 +1,71 @@ +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.lib.CORE; +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, 0, 16, "Dedicated Catalyst Storage", false); + } + + public GT_MetaTileEntity_Hatch_Catalysts(String aName, String aDescription, ITexture[][][] aTextures) { + super(aName, 0, 16, aDescription, false, aTextures); + } + + public GT_MetaTileEntity_Hatch_Catalysts(String aName, String[] aDescription, ITexture[][][] aTextures) { + super(aName, 0, 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 String[] getDescription() { + return new String[]{ + this.mDescription, + CORE.GT_Tooltip}; + } + + @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/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java new file mode 100644 index 0000000000..7514855a2c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java @@ -0,0 +1,71 @@ +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.lib.CORE; +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 String[] getDescription() { + return new String[]{ + this.mDescription, + CORE.GT_Tooltip}; + } + + @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/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java new file mode 100644 index 0000000000..56dff1b1e3 --- /dev/null +++ b/src/main/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, 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); + } + } + } + } + + public 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/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechFluid.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechFluid.java new file mode 100644 index 0000000000..9cc0e3a315 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechFluid.java @@ -0,0 +1,28 @@ +package gtPlusPlus.xmod.gregtech.api.objects; + +import gregtech.api.GregTech_API; + +import gtPlusPlus.core.lib.CORE; +import net.minecraftforge.fluids.Fluid; + +public class GregtechFluid extends Fluid implements Runnable { + public final String mTextureName; + private final short[] mRGBa; + + public GregtechFluid(final String aName, final String aTextureName, final short[] aRGBa) { + super(aName); + this.mRGBa = aRGBa; + this.mTextureName = aTextureName; + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public int getColor() { + return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8) | Math.max(0, Math.min(255, this.mRGBa[2])); + } + + @Override + public void run() { + this.setIcons(GregTech_API.sBlockIcons.registerIcon(CORE.MODID+ ":" + "fluids/fluid." + this.mTextureName)); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechItemData.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechItemData.java new file mode 100644 index 0000000000..eb5939caca --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechItemData.java @@ -0,0 +1,144 @@ +package gtPlusPlus.xmod.gregtech.api.objects; + +import java.util.*; + +import net.minecraft.item.ItemStack; + +import gregtech.api.objects.GT_ArrayList; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; + +public class GregtechItemData { + private static final GregtechMaterialStack[] EMPTY_GT_MaterialStack_ARRAY = new GregtechMaterialStack[0]; + + public final List<Object> mExtraData = new GT_ArrayList<>(false, 1); + public final GregtechOrePrefixes mPrefix; + public final GregtechMaterialStack mMaterial; + public final GregtechMaterialStack[] mByProducts; + public boolean mBlackListed = false; + public ItemStack mUnificationTarget = null; + + public GregtechItemData(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final boolean aBlackListed) { + this.mPrefix = aPrefix; + this.mMaterial = aMaterial == null ? null : new GregtechMaterialStack(aMaterial, aPrefix.mMaterialAmount); + this.mBlackListed = aBlackListed; + this.mByProducts = (aPrefix.mSecondaryMaterial == null) || (aPrefix.mSecondaryMaterial.mMaterial == null) ? EMPTY_GT_MaterialStack_ARRAY : new GregtechMaterialStack[]{aPrefix.mSecondaryMaterial.clone()}; + } + + public GregtechItemData(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial) { + this(aPrefix, aMaterial, false); + } + + public GregtechItemData(final GregtechMaterialStack aMaterial, final GregtechMaterialStack... aByProducts) { + this.mPrefix = null; + this.mMaterial = aMaterial.mMaterial == null ? null : aMaterial.clone(); + this.mBlackListed = true; + if (aByProducts == null) { + this.mByProducts = EMPTY_GT_MaterialStack_ARRAY; + } else { + final GregtechMaterialStack[] tByProducts = aByProducts.length < 1 ? EMPTY_GT_MaterialStack_ARRAY : new GregtechMaterialStack[aByProducts.length]; + int j = 0; + for (int i = 0; i < aByProducts.length; i++) { + if ((aByProducts[i] != null) && (aByProducts[i].mMaterial != null)) { + tByProducts[j++] = aByProducts[i].clone(); + } + } + this.mByProducts = j > 0 ? new GregtechMaterialStack[j] : EMPTY_GT_MaterialStack_ARRAY; + for (int i = 0; i < this.mByProducts.length; i++) { + this.mByProducts[i] = tByProducts[i]; + } + } + } + + public GregtechItemData(final GT_Materials aMaterial, final long aAmount, final GregtechMaterialStack... aByProducts) { + this(new GregtechMaterialStack(aMaterial, aAmount), aByProducts); + } + + public GregtechItemData(final GT_Materials aMaterial, final long aAmount, final GT_Materials aByProduct, final long aByProductAmount) { + this(new GregtechMaterialStack(aMaterial, aAmount), new GregtechMaterialStack(aByProduct, aByProductAmount)); + } + + public GregtechItemData(final GregtechItemData... aData) { + this.mPrefix = null; + this.mBlackListed = true; + + final ArrayList<GregtechMaterialStack> aList = new ArrayList<>(), rList = new ArrayList<>(); + + for (final GregtechItemData tData : aData) { + if (tData != null) { + if (tData.hasValidMaterialData() && (tData.mMaterial.mAmount > 0)) { + aList.add(tData.mMaterial.clone()); + } + for (final GregtechMaterialStack tMaterial : tData.mByProducts) { + if (tMaterial.mAmount > 0) { + aList.add(tMaterial.clone()); + } + } + } + } + + for (final GregtechMaterialStack aMaterial : aList) { + boolean temp = true; + for (final GregtechMaterialStack tMaterial : rList) { + if (aMaterial.mMaterial == tMaterial.mMaterial) { + tMaterial.mAmount += aMaterial.mAmount; + temp = false; + break; + } + } + if (temp) { + rList.add(aMaterial.clone()); + } + } + + Collections.sort(rList, new Comparator<GregtechMaterialStack>() { + @Override + public int compare(final GregtechMaterialStack a, final GregtechMaterialStack b) { + return a.mAmount == b.mAmount ? 0 : a.mAmount > b.mAmount ? -1 : +1; + } + }); + + if (rList.isEmpty()) { + this.mMaterial = null; + } else { + this.mMaterial = rList.get(0); + rList.remove(0); + } + + this.mByProducts = rList.toArray(new GregtechMaterialStack[rList.size()]); + } + + public boolean hasValidPrefixMaterialData() { + return (this.mPrefix != null) && (this.mMaterial != null) && (this.mMaterial.mMaterial != null); + } + + public boolean hasValidPrefixData() { + return this.mPrefix != null; + } + + public boolean hasValidMaterialData() { + return (this.mMaterial != null) && (this.mMaterial.mMaterial != null); + } + + public ArrayList<GregtechMaterialStack> getAllGT_MaterialStacks() { + final ArrayList<GregtechMaterialStack> rList = new ArrayList<GregtechMaterialStack>(); + if (this.hasValidMaterialData()) { + rList.add(this.mMaterial); + } + rList.addAll(Arrays.asList(this.mByProducts)); + return rList; + } + + public GregtechMaterialStack getByProduct(final int aIndex) { + return (aIndex >= 0) && (aIndex < this.mByProducts.length) ? this.mByProducts[aIndex] : null; + } + + @Override + public String toString() { + if ((this.mPrefix == null) || (this.mMaterial == null) || (this.mMaterial.mMaterial == null)) { + return ""; + } + return this.mPrefix.name() + this.mMaterial.mMaterial.name(); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechMaterialStack.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechMaterialStack.java new file mode 100644 index 0000000000..6ec5907256 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/GregtechMaterialStack.java @@ -0,0 +1,49 @@ +package gtPlusPlus.xmod.gregtech.api.objects; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; + +public class GregtechMaterialStack implements Cloneable { + public long mAmount; + public GT_Materials mMaterial; + + public GregtechMaterialStack(final GT_Materials aMaterial, final long aAmount) { + this.mMaterial = aMaterial == null ? GT_Materials._NULL : aMaterial; + this.mAmount = aAmount; + } + + public GregtechMaterialStack copy(final long aAmount) { + return new GregtechMaterialStack(this.mMaterial, aAmount); + } + + @Override + public GregtechMaterialStack clone() { + return new GregtechMaterialStack(this.mMaterial, this.mAmount); + } + + @Override + public boolean equals(final Object aObject) { + if (aObject == this) { + return true; + } + if (aObject == null) { + return false; + } + if (aObject instanceof GT_Materials) { + return aObject == this.mMaterial; + } + if (aObject instanceof GregtechMaterialStack) { + return (((GregtechMaterialStack) aObject).mMaterial == this.mMaterial) && ((this.mAmount < 0) || (((GregtechMaterialStack) aObject).mAmount < 0) || (((GregtechMaterialStack) aObject).mAmount == this.mAmount)); + } + return false; + } + + @Override + public String toString() { + return ((this.mMaterial.mMaterialList.size() > 1) && (this.mAmount > 1) ? "(" : "") + this.mMaterial.getToolTip(true) + ((this.mMaterial.mMaterialList.size() > 1) && (this.mAmount > 1) ? ")" : "") + (this.mAmount > 1 ? this.mAmount : ""); + } + + @Override + public int hashCode() { + return this.mMaterial.hashCode(); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockBlueprint.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockBlueprint.java new file mode 100644 index 0000000000..7af6af2ffd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockBlueprint.java @@ -0,0 +1,469 @@ +package gtPlusPlus.xmod.gregtech.api.objects; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.xmod.gregtech.api.objects.MultiblockLayer.LayerBlockData; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class MultiblockBlueprint { + + private final MultiblockLayer[] mBlueprintData; + + public final int height; + public final int width; + public final int depth; + public final int mMinimumCasingCount; + public final int mTextureID; + + /** + * Cached Matrix of the Multiblock, which makes future structural checks far quicker. + */ + private final BlockPos[][][] StructureMatrix; + + /** + * Has {@value StructureMatrix} been set yet? + */ + @SuppressWarnings("unused") + private boolean mGeneratedMatrix = false; + + /** + * A detailed class which will contain blueprints for a Multiblock. + * Values are not relative to the controller, but in total. + * @param x - Overall width + * @param y - Overall height + * @param z - Overall depth + * @param aMinimumCasings - The lowest amount of casings required + * @param aTextureID - The texture ID used by hatches. + */ + public MultiblockBlueprint(final int x, final int y, final int z, final int aMinimumCasings, final int aTextureID) { + mBlueprintData = new MultiblockLayer[y]; + height = y; + width = x; + depth = z; + mMinimumCasingCount = aMinimumCasings; + mTextureID = aTextureID; + StructureMatrix = new BlockPos[width][height][depth]; + //Logger.INFO("Created new Blueprint."); + } + + /** + * + * @param aY - The Y level of the layer to return, where 0 is the bottom and N is the top. + * @return - A {@link MultiblockLayer} object. + */ + public MultiblockLayer getLayer(int aY) { + return mBlueprintData[aY]; + } + + /** + * + * @param aLayer - A {@link MultiblockLayer} object. + * @param aY - The Y level of the layer, where 0 is the bottom and N is the top. + * + */ + public void setLayer(MultiblockLayer aLayer, int aY) { + mBlueprintData[aY] = aLayer; + } + + public MultiblockLayer getControllerLayer() { + for (MultiblockLayer u : mBlueprintData) { + if (u.hasController()) { + return u; + } + } + return null; + } + + public int getControllerY() { + int i = 0; + for (MultiblockLayer u : mBlueprintData) { + if (u.hasController()) { + return i; + } + i++; + } + return 0; + } + + @SuppressWarnings({ "unused", "rawtypes" }) + public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity) { + //Check for Nulls + if (aBaseMetaTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + GT_MetaTileEntity_MultiBlockBase aControllerObject = null; + if (aMetaTileEntity instanceof GT_MetaTileEntity_MultiBlockBase) { + aControllerObject = (GT_MetaTileEntity_MultiBlockBase) aMetaTileEntity; + } + if (aControllerObject == null) { + return false; + } + + //Get some Vars + int xOffSetMulti = ((this.getControllerLayer().width-1)/2); + int zOffSetMulti = ((this.getControllerLayer().depth-1)/2); + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * xOffSetMulti; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * zOffSetMulti; + ForgeDirection aDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); + int tAmount = 0; + + int contX = aControllerObject.getBaseMetaTileEntity().getXCoord(), contY = aControllerObject.getBaseMetaTileEntity().getYCoord(), contZ = aControllerObject.getBaseMetaTileEntity().getZCoord(); + + Logger.INFO("Controller is located at ["+contX+", "+contY+", "+contZ+"]"); + + boolean debugCacheDataVisually = true; + + + if (/*!mGeneratedMatrix || StructureMatrix == null*/ true) { + //Try Fancy Cache Stuff + BlockPos aPos = getOffsetRelativeToGridPosition(aBaseMetaTileEntity, 0, 0, 0); + for (int Y = 0; Y < height; Y++) { + for (int Z = 0; Z < depth; Z++) { + for (int X = 0; X < width; X++) { + int offsetX, offsetZ; + Pair<Integer, Integer> j = MultiblockLayer.rotateOffsetValues(aDir, X, Z); + offsetX = j.getKey(); + offsetZ = j.getValue(); + + Logger.INFO("Pre-Rotated Offsets ["+X+", "+(aPos.yPos + Y)+", "+Z+"] | "+aDir.name()); + Logger.INFO("Rotated Offsets ["+offsetX+", "+(aPos.yPos + Y)+", "+offsetZ+"]"); + + // Resolve Negatives + int negTestX, negTestZ; + if (aPos.xPos < 0) { + int testA = aPos.xPos; + testA -= -offsetX; + negTestX = testA; + } else { + negTestX = offsetX + aPos.xPos; + } + if (aPos.zPos < 0) { + int testA = aPos.zPos; + testA -= -offsetZ; + negTestZ = testA; + } else { + negTestZ = offsetZ + aPos.zPos; + } + Logger.INFO("Caching With Offset ["+negTestX+", "+(aPos.yPos + Y)+", "+negTestZ+"]"); + StructureMatrix[X][Y][Z] = new BlockPos(negTestX, (aPos.yPos + Y), negTestZ, aPos.world); + + if (debugCacheDataVisually) { + aBaseMetaTileEntity.getWorld().setBlock(negTestX, (aPos.yPos + Y), negTestZ, Blocks.glass); + } + } + } + } + Logger.INFO("Cached blueprint matrix."); + mGeneratedMatrix = true; + } + else { + Logger.INFO("Found cached blueprint matrix."); + } + + if (StructureMatrix == null) { + Logger.INFO("Error caching blueprint matrix."); + return false; + } + + + int a1, a2, a3; + a1 = StructureMatrix.length; + a2 = StructureMatrix[0].length; + a3 = StructureMatrix[0][0].length; + + Logger.INFO("Matrix Size ["+a1+", "+a2+", "+a3+"]"); + + for (int H = 0; H < a2; H++) { + + MultiblockLayer currentLayer = this.getLayer(H); + for (int W = 0; W < a1; W++) { + for (int D = 0; D < a3; D++) { + + BlockPos aToCheck = StructureMatrix[W][H][D]; + if (aToCheck == null) { + Logger.INFO("Found bad data stored at X: "+W+", Y: "+H+", Z: "+D); + continue; + } + else { + //Logger.INFO("Found data stored at X: "+W+", Y: "+H+", Z: "+D); + Logger.INFO("Checking "+aToCheck.getLocationString()); + } + + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntity(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos); + final Block tBlock = aBaseMetaTileEntity.getBlock(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos); + final int tMeta = aBaseMetaTileEntity.getMetaID(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos); + + + LayerBlockData g1 = currentLayer.getDataFromCoordsWithDirection(aDir, W, D); + if (g1 == null) { + Logger.INFO("Failed to find LayerBlockData. Using AIR_FALLBACK"); + //return false;*/ + g1 = LayerBlockData.FALLBACK_AIR_CHECK; + } + else { + if (g1.isController) { + Logger.INFO("Controller is at X: "+W+", Y: "+H+", Z: "+D); + } + } + + boolean isMatch = g1.match(tBlock, tMeta); + + + if (!isMatch) { + Logger.INFO("Checking ["+aToCheck.xPos+", "+ aToCheck.yPos +", "+ aToCheck.zPos+"]"); + Logger.INFO("Checking Position relative to Grid. X: "+W+", Y: "+H+", Z: "+D); + Logger.INFO("Found "+tBlock.getLocalizedName()+" : "+tMeta + " | Bad ["+W+", "+D+"]"); + + LayerBlockData g = currentLayer.getDataFromCoordsWithDirection(aDir, W, D); + + if (g == null) { + Logger.INFO("Expected "+" BAD DATA - Possibly Unset Area in Blueprint."); + + } + else { + Logger.INFO("Expected "+g.mBlock.getLocalizedName()+" : "+g.mMeta + ""); + } + aBaseMetaTileEntity.getWorld().setBlock(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos, g.mBlock); + aBaseMetaTileEntity.getWorld().setBlockMetadataWithNotify(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos, g.mMeta, 4); + //return false; + } + else { + + LayerBlockData g = currentLayer.getDataFromCoordsWithDirection(aDir, W, D); + + + + + + + + + + + + + + + + + + + + boolean isHatchValidType = false; + if (g != null) { + if (g.canBeHatch && !g.isController && tTileEntity != null) { + IMetaTileEntity aMetaTileEntity2 = tTileEntity.getMetaTileEntity(); + if (aMetaTileEntity2 != null) { + if (aMetaTileEntity2 instanceof GT_MetaTileEntity_MultiBlockBase) { + isHatchValidType = true; + break; + } + else { + for (Class c : g.mHatchClass) { + if (c != null) { + if (c.isInstance(aMetaTileEntity2)) { + isHatchValidType = true; + break; + } + } + } + } + } + } + } + + if (!isHatchValidType && !g.isController && tTileEntity != null) { + Logger.INFO("Checking ["+aToCheck.xPos+", "+ aToCheck.yPos +", "+ aToCheck.zPos+"]"); + Logger.INFO("Hatch Type did not match allowed types. "+tTileEntity.getClass().getSimpleName()); + return false; + } + if (!aControllerObject.addToMachineList(tTileEntity, mTextureID)) { + tAmount++; + } + + + } + } + } + } + + boolean hasCorrectHatches = ( + aControllerObject.mInputBusses.size() >= this.getMinimumInputBus() && + aControllerObject.mOutputBusses.size() >= this.getMinimumOutputBus() && + aControllerObject.mInputHatches.size() >= this.getMinimumInputHatch() && + aControllerObject.mOutputHatches.size() >= this.getMinimumOutputHatch() && + aControllerObject.mDynamoHatches.size() >= this.getMinimumOutputEnergy() && + aControllerObject.mEnergyHatches.size() >= this.getMinimumInputEnergy() && + aControllerObject.mMaintenanceHatches.size() >= this.getMinimumMaintHatch() && + aControllerObject.mMufflerHatches.size() >= this.getMinimumMufflers()); + + + Logger.INFO("mInputBusses: "+aControllerObject.mInputBusses.size()); + Logger.INFO("mOutputBusses: "+aControllerObject.mOutputBusses.size()); + Logger.INFO("mInputHatches: "+aControllerObject.mInputHatches.size()); + Logger.INFO("mOutputHatches: "+aControllerObject.mOutputHatches.size()); + Logger.INFO("mEnergyHatches: "+aControllerObject.mEnergyHatches.size()); + Logger.INFO("mDynamoHatches: "+aControllerObject.mDynamoHatches.size()); + Logger.INFO("mMaintenanceHatches: "+aControllerObject.mMaintenanceHatches.size()); + Logger.INFO("mMufflerHatches: "+aControllerObject.mMufflerHatches.size()); + + boolean built = hasCorrectHatches && tAmount >= mMinimumCasingCount; + Logger.INFO("Built? "+built); + Logger.INFO("hasCorrectHatches? "+hasCorrectHatches); + Logger.INFO("tAmount? "+tAmount); + return built; + } + + public BlockPos getOffsetRelativeToGridPosition(final IGregTechTileEntity aBaseMetaTileEntity, final int x, final int y, final int z) { + + if (aBaseMetaTileEntity == null) { + return null; + } + + int controllerX, controllerY, controllerZ; + MultiblockLayer layerController = this.getControllerLayer(); + + if (layerController == null) { + return null; + } + + int controllerYRelative = this.getControllerY(); + Pair<Integer, Integer> controllerLocationRelativeToGrid = layerController.getControllerLocation(); + + if (controllerLocationRelativeToGrid == null) { + return null; + } + + controllerX = aBaseMetaTileEntity.getXCoord(); + controllerY = aBaseMetaTileEntity.getYCoord(); + controllerZ = aBaseMetaTileEntity.getZCoord(); + + Logger.INFO("Controller is at ["+controllerX+", "+controllerY+", "+controllerZ+"]"); + + ForgeDirection aDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); + Logger.INFO("Controller is facing "+aDir.name()); + + //Find Bottom Left corner of Structure + // 0, 0, 0 + + int offsetX, offsetY, offsetZ; + int X = controllerLocationRelativeToGrid.getKey(), Z = controllerLocationRelativeToGrid.getValue(); + Logger.INFO("Attempting to translate offsets ["+X+", "+Z+"]"); + if (aDir == ForgeDirection.NORTH) { + offsetX = -X; + offsetZ = -Z; + } + + else if (aDir == ForgeDirection.EAST) { + offsetX = Z; + offsetZ = -X; + } + + else if (aDir == ForgeDirection.SOUTH) { + offsetX = X; + offsetZ = Z; + } + + else if (aDir == ForgeDirection.WEST) { + offsetX = -Z; + offsetZ = X; + } + else { + offsetX = -X; + offsetZ = -Z; + } + + offsetY = -controllerYRelative; + + Logger.INFO("Attempting to use offsets ["+offsetX+", "+offsetY+", "+offsetZ+"]"); + + //Resolve Negatives + int negTestX, negTestZ; + if (controllerX < 0) { + Logger.INFO("Found Negative X Pos."); + int testA = controllerX; + testA -= offsetX; + Logger.INFO("Adding Inverted Offset of "+offsetX+", making "+testA); + negTestX = testA; + } + else { + negTestX = offsetX + controllerX; + } + if (controllerZ < 0) { + Logger.INFO("Found Negative Z Pos."); + int testA = controllerZ; + testA -= -offsetZ; + Logger.INFO("Adding Inverted Offset of "+offsetZ+", making "+testA); + negTestZ = testA; + } + else { + negTestZ = offsetZ + controllerZ; + } + + + //} + //Bottom left Corner position + BlockPos p = new BlockPos(negTestX, offsetY+controllerY, negTestZ, aBaseMetaTileEntity.getWorld()); + + Logger.INFO("World XYZ for Bottom left Corner Block of structure ["+p.xPos+", "+p.yPos+", "+p.zPos+"]"); + + //Add the xyz relative to the grid. + BlockPos offsetPos = new BlockPos(p.xPos+x, p.yPos+y, p.zPos+z, aBaseMetaTileEntity.getWorld()); + Logger.INFO("World XYZ for Target Check Block in structure ["+offsetPos.xPos+", "+offsetPos.yPos+", "+offsetPos.zPos+"]"); + + return p; + } + + + public IGregTechTileEntity getTileAtOffset(final IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z){ + BlockPos aPos = getOffsetRelativeToGridPosition(aBaseMetaTileEntity, x, y, z); + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(aPos.xPos, aPos.yPos, aPos.zPos); + //aBaseMetaTileEntity.getWorld().setBlock(xh, yh, zh, Blocks.gold_ore); + return tTileEntity; + } + + public Pair<Block, Integer> getBlockAtOffset(final IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z){ + BlockPos aPos = getOffsetRelativeToGridPosition(aBaseMetaTileEntity, x, y, z); + final Block tBlock = aBaseMetaTileEntity.getBlockOffset(aPos.xPos, aPos.yPos, aPos.zPos); + final int tMeta = aBaseMetaTileEntity.getMetaIDOffset(aPos.xPos, aPos.yPos, aPos.zPos); + return new Pair<Block, Integer>(tBlock, tMeta); + } + + public Triplet<Integer, Integer, Integer> getOffsetFromControllerTo00(){ + MultiblockLayer l = this.getControllerLayer(); + if (l == null) { + return null; + } + int yOffset = this.getControllerY(); + Pair<Integer, Integer> cl = l.getControllerLocation(); + + if (cl == null) { + return null; + } + + return new Triplet<Integer, Integer, Integer> (cl.getKey(), yOffset, cl.getValue()); + //return new Triplet<Integer, Integer, Integer> (cl.getKey(), yOffset, cl.getValue()); + + } + + public abstract int getMinimumInputBus(); + public abstract int getMinimumInputHatch(); + public abstract int getMinimumOutputBus(); + public abstract int getMinimumOutputHatch(); + public abstract int getMinimumInputEnergy(); + public abstract int getMinimumOutputEnergy(); + public abstract int getMinimumMaintHatch(); + public abstract int getMinimumMufflers(); + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java new file mode 100644 index 0000000000..c5554a6679 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java @@ -0,0 +1,643 @@ +package gtPlusPlus.xmod.gregtech.api.objects; + +import java.util.HashMap; + +import gregtech.api.GregTech_API; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.init.Blocks; +import net.minecraftforge.common.util.ForgeDirection; + +public class MultiblockLayer { + + public final int width; + public final int depth; + + private boolean mFinalised; + + + /** + * WARNING!! May be {@link null}. + */ + private Pair<Integer, Integer> mControllerLocation; + + /** + * Holds the North facing Orientation data. + */ + public final LayerBlockData[][] mLayerData; + public final AutoMap<LayerBlockData[][]> mVariantOrientations = new AutoMap<LayerBlockData[][]>(); + + /** + * A detailed class which will contain a single x/z Layer for a {@link MultiblockBlueprint}. + * Values are not relative, but in total. + * @param x - Overall width + * @param z - Overall depth + */ + public MultiblockLayer(final int x, final int z) { + width = x; + depth = z; + mLayerData = new LayerBlockData[x][z]; + //Logger.INFO("Created new Blueprint Layer."); + } + + /** + * A detailed class which will contain a single x/z Layer for a {@link MultiblockBlueprint}. + * Values are not relative, but in total. + */ + public MultiblockLayer(final LayerBlockData[][] aData) { + width = aData.length; + depth = aData[0].length; + mLayerData = aData; + } + + /** + * + * @param aBlock - The block expected as this location. + * @param aMeta - The meta for the block above. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @param canBeHatch - is this location able to be substituted for any hatch? + * @return - Is this data added to the layer data map? + */ + public boolean addBlockForPos(Block aBlock, int aMeta, int x, int z, boolean canBeHatch) { + return addBlockForPos(aBlock, aMeta, x, z, canBeHatch, new Class[] {}); + } + + /** + * + * @param aBlock - The block expected as this location. + * @param aMeta - The meta for the block above. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @param canBeHatch - is this location able to be substituted for a hatch? + * @param aHatchTypeClass - Specify the class for the hatch if you want it explicit. Use base classes to allow custom hatches which extend. + * @return - Is this data added to the layer data map? + */ + public boolean addBlockForPos(Block aBlock, int aMeta, int x, int z, boolean canBeHatch, Class aHatchTypeClass) { + return addBlockForPos(aBlock, aMeta, x, z, canBeHatch, new Class[] {aHatchTypeClass}); + } + + /** + * + * @param aBlock - The block expected as this location. + * @param aMeta - The meta for the block above. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @param canBeHatch - is this location able to be substituted for a hatch? + * @param aHatchTypeClass - Specify the class for the hatch if you want it explicit. Use base classes to allow custom hatches which extend. + * @return - Is this data added to the layer data map? + */ + public boolean addBlockForPos(Block aBlock, int aMeta, int x, int z, boolean canBeHatch, Class[] aHatchTypeClass) { + if (x > width -1) { + return false; + } + if (z > depth - 1) { + return false; + } + + if (canBeHatch && (aHatchTypeClass == null || aHatchTypeClass.length <= 0)){ + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + aHatchTypeClass = new Class[] { + GT_MetaTileEntity_Hatch_Dynamo.class, + GT_MetaTileEntity_Hatch_Energy.class, + GT_MetaTileEntity_Hatch_Input.class, + GT_MetaTileEntity_Hatch_InputBus.class, + GT_MetaTileEntity_Hatch_Maintenance.class, + GT_MetaTileEntity_Hatch_Muffler.class, + GT_MetaTileEntity_Hatch_Output.class, + GT_MetaTileEntity_Hatch_OutputBus.class, + GT_MetaTileEntity_Hatch.class + }; + } + else { + Class aDataHatch = ReflectionUtils.getClass("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess"); + if (aDataHatch != null) { + aHatchTypeClass = new Class[] { + aDataHatch, + GT_MetaTileEntity_Hatch_Dynamo.class, + GT_MetaTileEntity_Hatch_Energy.class, + GT_MetaTileEntity_Hatch_Input.class, + GT_MetaTileEntity_Hatch_InputBus.class, + GT_MetaTileEntity_Hatch_Maintenance.class, + GT_MetaTileEntity_Hatch_Muffler.class, + GT_MetaTileEntity_Hatch_Output.class, + GT_MetaTileEntity_Hatch_OutputBus.class, + GT_MetaTileEntity_Hatch.class + }; + } else { + aHatchTypeClass = new Class[] { + GT_MetaTileEntity_Hatch_Dynamo.class, + GT_MetaTileEntity_Hatch_Energy.class, + GT_MetaTileEntity_Hatch_Input.class, + GT_MetaTileEntity_Hatch_InputBus.class, + GT_MetaTileEntity_Hatch_Maintenance.class, + GT_MetaTileEntity_Hatch_Muffler.class, + GT_MetaTileEntity_Hatch_Output.class, + GT_MetaTileEntity_Hatch_OutputBus.class, + GT_MetaTileEntity_Hatch.class + }; + } + } + } + + + + mLayerData[x][z] = new LayerBlockData(aBlock, aMeta, canBeHatch, aHatchTypeClass); + return true; + } + + /** + * Adds a controller to the layer at the designated location, Details about the controller do not need to be specified. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addController(int x, int z) { + setControllerLocation(new Pair<Integer, Integer>(x, z)); + return addBlockForPos(GregTech_API.sBlockMachines, 0, x, z, true, GT_MetaTileEntity_MultiBlockBase.class); + } + + + /** + * Adds a Muffler to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addMuffler(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Muffler.class); + } + + + /** + * Adds a Maint Hatch to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addMaintHatch(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Maintenance.class); + } + + + /** + * Adds ah Input to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addInputBus(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_InputBus.class); + } + + + /** + * Adds an Output to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addOutputBus(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_OutputBus.class); + } + + /** + * Adds ah Input to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addInputHatch(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Input.class); + } + + + /** + * Adds an Output to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addOutputHatch(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Output.class); + } + + /** + * Adds ah Input to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addInput(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, new Class[] {GT_MetaTileEntity_Hatch_Input.class, GT_MetaTileEntity_Hatch_InputBus.class}); + } + + + /** + * Adds an Output to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addOutput(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, new Class[] {GT_MetaTileEntity_Hatch_Output.class, GT_MetaTileEntity_Hatch_OutputBus.class}); + } + + /** + * Adds ah Input to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addEnergyInput(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Energy.class); + } + + + /** + * Adds an Output to the layer at the designated location. + * @param x - The X location, where 0 is the top left corner & counts upwards, moving right. + * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down. + * @return - Is this controller added to the layer data map? + */ + public boolean addEnergyOutput(Block aBlock, int aMeta, int x, int z) { + return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Dynamo.class); + } + + /** + * + * @param aBlock - The block you expect. + * @param aMeta - The meta you expect. + * @param x - the non-relative x location you expect it. + * @param z - the non-relative z location you expect it. + * @param aDir - The direction the controller is facing. + * @return - True if the correct Block was found. May also return true if a hatch is found when allowed or it's the controller. + */ + public boolean getBlockForPos(Block aBlock, int aMeta, int x, int z, ForgeDirection aDir) { + //Logger.INFO("Grid Index X: "+x+" | Z: "+z + " | "+aDir.name()); + LayerBlockData g; + if (aDir == ForgeDirection.SOUTH) { + g = mVariantOrientations.get(2)[x][z]; + } + else if (aDir == ForgeDirection.WEST) { + g = mVariantOrientations.get(3)[x][z]; + } + else if (aDir == ForgeDirection.NORTH) { + LayerBlockData[][] aData = mVariantOrientations.get(0); + if (aData != null) { + //Logger.INFO("Found Valid Orientation Data. "+aData.length + ", "+aData[0].length); + g = aData[x][z]; + } + else { + //Logger.INFO("Did not find valid orientation data."); + g = null; + } + } + else if (aDir == ForgeDirection.EAST) { + g = mVariantOrientations.get(1)[x][z]; + } + else { + g = mLayerData[x][z]; + } + if (g == null) { + Logger.INFO("Failed to find LayerBlockData. Using AIR_FALLBACK"); + //return false;*/ + g = LayerBlockData.FALLBACK_AIR_CHECK; + } + + return g.match(aBlock, aMeta); + } + + + + /** + * Is this layer final? + * @return - If true, layer data cannot be edited. + */ + public final boolean isLocked() { + return mFinalised; + } + + /** + * Used to finalize the layer, after which all four Orientations are then generated. + * Cannot be set to false, useful for not locking the layer if an error occurs. + * @param lockData + */ + public final void lock(boolean lockData) { + if (!lockData) { + Logger.INFO("Failed to lock layer"); + return; + } + //Logger.INFO("Trying to lock layer"); + this.mFinalised = true; + generateOrientations(); + //Logger.INFO("Trying to Build Blueprint Layer [Constructed orietations & finalized]"); + } + + private void generateOrientations() { + try { + + //Logger.INFO("Trying to gen orients for layer"); + //North + mVariantOrientations.put(mLayerData); + LayerBlockData[][] val; + //Logger.INFO("1 done"); + //East + val = rotateArrayClockwise(mLayerData); + mVariantOrientations.put((LayerBlockData[][]) val); + //Logger.INFO("2 done"); + //South + val = rotateArrayClockwise(mLayerData); + mVariantOrientations.put((LayerBlockData[][]) val); + //Logger.INFO("3 done"); + //West + val = rotateArrayClockwise(mLayerData); + mVariantOrientations.put((LayerBlockData[][]) val); + //Logger.INFO("4 done"); + + } + catch (Throwable t) { + t.printStackTrace(); + } + } + + public static LayerBlockData[][] rotateArrayClockwise(LayerBlockData[][] mat) { + //Logger.INFO("Rotating Layer 90' Clockwise"); + try { + final int M = mat.length; + final int N = mat[0].length; + //Logger.INFO("Dimension X: "+M); + //Logger.INFO("Dimension Z: "+N); + LayerBlockData[][] ret = new LayerBlockData[N][M]; + for (int r = 0; r < M; r++) { + for (int c = 0; c < N; c++) { + ret[c][M-1-r] = mat[r][c]; + } + } + //Logger.INFO("Returning Rotated Layer"); + return ret; + } + catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + public boolean hasController() { + if (getControllerLocation() == null) { + return false; + } + return true; + } + + public Pair<Integer, Integer> getControllerLocation() { + return mControllerLocation; + } + + public void setControllerLocation(Pair<Integer, Integer> mControllerLocation) { + if (hasController()) { + return; + } + this.mControllerLocation = mControllerLocation; + } + + public LayerBlockData getDataFromCoordsWithDirection(ForgeDirection aDir, int W, int D) { + LayerBlockData g; + if (aDir == ForgeDirection.SOUTH) { + g = this.mVariantOrientations.get(2)[W][D]; + } + else if (aDir == ForgeDirection.WEST) { + g = this.mVariantOrientations.get(3)[W][D]; + } + else if (aDir == ForgeDirection.NORTH) { + g = this.mVariantOrientations.get(0)[W][D]; + } + else if (aDir == ForgeDirection.EAST) { + g = this.mVariantOrientations.get(1)[W][D]; + } + else { + g = this.mLayerData[W][D]; + } + return g; + } + + public static Pair<Integer, Integer> rotateOffsetValues(ForgeDirection aDir, int X, int Z) { + int offsetX, offsetZ; + + if (aDir == ForgeDirection.NORTH) { + offsetX = X; + offsetZ = Z; + } + + else if (aDir == ForgeDirection.EAST) { + offsetX = -X; + offsetZ = Z; + } + + else if (aDir == ForgeDirection.SOUTH) { + offsetX = -X; + offsetZ = -Z; + } + + else if (aDir == ForgeDirection.WEST) { + offsetX = X; + offsetZ = -Z; + } + else { + offsetX = X; + offsetZ = Z; + } + + return new Pair<Integer, Integer>(offsetX, offsetZ); + } + + + + + + + + + + + + + + + + /** + * Generates a complete {@link MultiblockLayer} from String data. + * @param aDataMap - A {@link HashMap} containing single character {@link String}s, which map to {@link Pair}<{@link Block}, {@link Integer}>s contains pairs of Blocks & Meta. + * @param aHorizontalStringRows - The horizontal rows used to map blocks to a grid. Each array slot is one vertical row going downwards as the index increases. + * @return + */ + public static MultiblockLayer generateLayerFromData(HashMap<String, Pair<Block, Integer>> aDataMap, String[] aHorizontalStringRows) { + AutoMap<Pair<String, Pair<Block, Integer>>> x = new AutoMap<Pair<String, Pair<Block, Integer>>>(); + + for (String u : aDataMap.keySet()) { + Pair<Block, Integer> r = aDataMap.get(u); + if (r != null) { + x.put(new Pair<String, Pair<Block, Integer>>(u, r)); + } + } + + //String aFreeLetters = "abdefgijklmnopqrstuvwxyz"; + /*for (Pair<Block, Integer> h : aDataMap.values()) { + String y = aFreeLetters.substring(0, 0); + aFreeLetters = aFreeLetters.replace(y.toLowerCase(), ""); + Pair<String, Pair<Block, Integer>> t = new Pair<String, Pair<Block, Integer>>(y, h); + x.put(t); + }*/ + return generateLayerFromData(x, aHorizontalStringRows); + } + + + /** + * Generates a complete {@link MultiblockLayer} from String data. + * @param aDataMap - An {@link AutoMap} which contains {@link Pair}s. These Pairs hold a single character {@link String} and another Pair. This inner pair holds a {@link Block} and an {@link Integer}. + * @param aHorizontalStringRows - An array which holds the horizontal (X/Width) string data for the layer. + * @return A complete Multiblock Layer. + */ + public static MultiblockLayer generateLayerFromData(AutoMap<Pair<String, Pair<Block, Integer>>> aDataMap, String[] aHorizontalStringRows) { + int width = aHorizontalStringRows[0].length(); + int depth = aHorizontalStringRows.length; + MultiblockLayer L = new MultiblockLayer(width, depth); + HashMap<String, Pair<Block, Integer>> K = new HashMap<String, Pair<Block, Integer>>(); + + //24 Free Letters + //C = Controller + //H = Hatch + String aFreeLetters = "abdefgijklmnopqrstuvwxyz"; + AutoMap<Pair<String, Pair<Block, Integer>>> j = new AutoMap<Pair<String, Pair<Block, Integer>>>(); + + //Map the keys to a Hashmap + for (Pair<String, Pair<Block, Integer>> t : aDataMap) { + String aKeyTemp = t.getKey(); + if (aKeyTemp.toUpperCase().equals("C")){ + j.put(t); + } + else if (aKeyTemp.toUpperCase().equals("H")){ + j.put(t); + } + else { + K.put(aKeyTemp.toLowerCase(), t.getValue()); + aFreeLetters.replace(aKeyTemp.toLowerCase(), ""); + } + } + + //Map any Invalid Characters to new ones, in case someone uses C/H. + if (j.size() > 0) { + for (Pair<String, Pair<Block, Integer>> h : j) { + String newKey = aFreeLetters.substring(0, 0); + K.put(newKey.toLowerCase(), h.getValue()); + aFreeLetters.replace(newKey.toLowerCase(), ""); + } + } + + int xPos = 0; + int zPos = 0; + + //Vertical Iterator + for (String s : aHorizontalStringRows) { + //Horizontal Iterator + for (int q = 0; q < s.length(); q++) { + //Get char as a String at index q. + String c = s.substring(q, q); + //if the character at c matches the character in this row, we add it to the map. + if (c.toLowerCase().equals(s.toLowerCase())) { + Pair<Block, Integer> p = K.get(c); + if (c.toLowerCase().equals("c")) { + L.addController(xPos, zPos); + } + else if (c.toLowerCase().equals("h")) { + L.addBlockForPos(p.getKey(), p.getValue(), xPos, zPos, true); + } + else { + L.addBlockForPos(p.getKey(), p.getValue(), xPos, zPos, false); + } + } + xPos++; + } + xPos = 0; + zPos++; + } + L.lock(true); + return L; + } + + + + + public static class LayerBlockData{ + + public static final LayerBlockData FALLBACK_AIR_CHECK = new LayerBlockData(Blocks.air, 0, false); + + public final Block mBlock; + public final int mMeta; + public final boolean canBeHatch; + public final Class[] mHatchClass; + + public final boolean isController; + + + public LayerBlockData(Block aBlock, int aMeta, boolean aHatch) { + this(aBlock, aMeta, aHatch, new Class[] {}); + } + + public LayerBlockData(Block aBlock, int aMeta, boolean aHatch, Class clazz) { + this(aBlock, aMeta, aHatch, new Class[] {clazz}); + } + + public LayerBlockData(Block aBlock, int aMeta, boolean aHatch, Class[] clazz) { + mBlock = aBlock; + mMeta = aMeta; + canBeHatch = aHatch; + mHatchClass = clazz; + if (clazz != null && clazz.length > 0 && clazz[0].equals(GT_MetaTileEntity_MultiBlockBase.class)) { + isController = true; + } + else { + isController = false; + } + } + + public boolean match(Block blockToTest, int metaToTest) { + + //If Both are some kind of Air Block, good enough. + if (blockToTest instanceof BlockAir && mBlock instanceof BlockAir) { + return true; + } + + if (isController && blockToTest == GregTech_API.sBlockMachines) { + return true; + } + + if (canBeHatch && blockToTest == GregTech_API.sBlockMachines) { + return true; + } + + if (blockToTest == mBlock && metaToTest == mMeta) { + return true; + } + + return false; + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java new file mode 100644 index 0000000000..10909081d1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java @@ -0,0 +1,108 @@ +package gtPlusPlus.xmod.gregtech.api.objects; + +public class MultiblockRequirements { + + public int mInputBusMinimum = 0; + public int mInputHatchMinimum = 0; + + public int mOutputBusMinimum = 0; + public int mOutputHatchMinimum = 0; + + public int mMaintMinimum = 1; + + public int mEnergyHatchMinimum = 1; + public int mDynamoHatchMinimum = 0; + + public final int mMinimumCasingCount; + + public final MultiblockBlueprint mBlueprint; + + //public static final int mControlCoreMinimum = 1; + /** + * + * @param aInputBusses + * @param aOutputBusses + * @param aInputHatches + * @param aOutputHatches + * @param aEnergyHatches + * @param aDynamoHatches + * @param aMaintHatches + * @param aBlueprint - A data object containing the structural data for this Multiblock + */ + public MultiblockRequirements(int aCasingCount, MultiblockBlueprint aBlueprint) { + mMinimumCasingCount = aCasingCount; + mBlueprint = aBlueprint; + } + + public final int getInputBusMinimum() { + return this.mInputBusMinimum; + } + + public final MultiblockRequirements setInputBusMinimum(int mInputBusMinimum) { + this.mInputBusMinimum = mInputBusMinimum; + return this; + } + + public final int getInputHatchMinimum() { + return this.mInputHatchMinimum; + } + + public final MultiblockRequirements setInputHatchMinimum(int mInputHatchMinimum) { + this.mInputHatchMinimum = mInputHatchMinimum; + return this; + } + + public final int getOutputBusMinimum() { + return this.mOutputBusMinimum; + } + + public final MultiblockRequirements setOutputBusMinimum(int mOutputBusMinimum) { + this.mOutputBusMinimum = mOutputBusMinimum; + return this; + } + + public final int getOutputHatchMinimum() { + return this.mOutputHatchMinimum; + } + + public final MultiblockRequirements setOutputHatchMinimum(int mOutputHatchMinimum) { + this.mOutputHatchMinimum = mOutputHatchMinimum; + return this; + } + + public final int getMaintMinimum() { + return this.mMaintMinimum; + } + + public final MultiblockRequirements setMaintMinimum(int mMaintMinimum) { + this.mMaintMinimum = mMaintMinimum; + return this; + } + + public final int getEnergyHatchMinimum() { + return this.mEnergyHatchMinimum; + } + + public final MultiblockRequirements setEnergyHatchMinimum(int mEnergyHatchMinimum) { + this.mEnergyHatchMinimum = mEnergyHatchMinimum; + return this; + } + + public final int getDynamoHatchMinimum() { + return this.mDynamoHatchMinimum; + } + + public final MultiblockRequirements setDynamoHatchMinimum(int mDynamoHatchMinimum) { + this.mDynamoHatchMinimum = mDynamoHatchMinimum; + return this; + } + + public final MultiblockBlueprint getBlueprint() { + return this.mBlueprint; + } + + public final int getMinimumCasingCount() { + return this.mMinimumCasingCount; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/recipe/ProcessingSkookumChoocherToolRecipes.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/recipe/ProcessingSkookumChoocherToolRecipes.java new file mode 100644 index 0000000000..976f21c329 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/recipe/ProcessingSkookumChoocherToolRecipes.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.api.recipe; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.ToolDictNames; +import gregtech.api.interfaces.IOreRecipeRegistrator; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; + +public class ProcessingSkookumChoocherToolRecipes implements IOreRecipeRegistrator { + public ProcessingSkookumChoocherToolRecipes() { + //GregtechOrePrefixes.toolSkookumChoocher.add(this); + } + + @Override + public void registerOre(final OrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { + GT_ModHandler.addShapelessCraftingRecipe(MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(7734, 1, aMaterial, aMaterial, null), new Object[]{aOreDictName, OrePrefixes.stick.get(aMaterial), OrePrefixes.screw.get(aMaterial), ToolDictNames.craftingToolScrewdriver}); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java new file mode 100644 index 0000000000..dcdc1220d0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java @@ -0,0 +1,100 @@ +package gtPlusPlus.xmod.gregtech.api.util; + +import static gregtech.api.enums.GT_Values.E; + +import net.minecraft.item.ItemStack; + +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; + +public class GTPP_Config implements Runnable { + public static boolean troll = false; + + public static Configuration sConfigFileIDs; + public final Configuration mConfig; + + public GTPP_Config(Configuration aConfig) { + mConfig = aConfig; + mConfig.load(); + mConfig.save(); + } + + public static int addIDConfig(Object aCategory, String aName, int aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = sConfigFileIDs.get(aCategory.toString().replaceAll("\\|", "."), aName.replaceAll("\\|", "."), aDefault); + int rResult = tProperty.getInt(aDefault); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sConfigFileIDs.save(); + return rResult; + } + + public static String getStackConfigName(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return E; + Object rName = GT_OreDictUnificator.getAssociation(aStack); + if (rName != null) return rName.toString(); + try { + if (GT_Utility.isStringValid(rName = aStack.getUnlocalizedName())) return rName.toString(); + } catch (Throwable e) {/*Do nothing*/} + String sName = aStack.getItem().toString(); + String[] tmp = sName.split("@"); + if (tmp.length > 0) sName = tmp[0]; + return sName + "." + aStack.getItemDamage(); + } + + public boolean get(Object aCategory, ItemStack aStack, boolean aDefault) { + String aName = getStackConfigName(aStack); + return get(aCategory, aName, aDefault); + } + + public boolean get(Object aCategory, String aName, boolean aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + boolean rResult = tProperty.getBoolean(aDefault); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); + return rResult; + } + + public int get(Object aCategory, ItemStack aStack, int aDefault) { + return get(aCategory, getStackConfigName(aStack), aDefault); + } + + public int get(Object aCategory, String aName, int aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + int rResult = tProperty.getInt(aDefault); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); + return rResult; + } + + public double get(Object aCategory, ItemStack aStack, double aDefault) { + return get(aCategory, getStackConfigName(aStack), aDefault); + } + + public double get(Object aCategory, String aName, double aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + double rResult = tProperty.getDouble(aDefault); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); + return rResult; + } + + public String get(Object aCategory, ItemStack aStack, String aDefault) { + return get(aCategory, getStackConfigName(aStack), aDefault); + } + + public String get(Object aCategory, String aName, String aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + String rResult = tProperty.getString(); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); + return rResult; + } + + @Override + public void run() { + mConfig.save(); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java new file mode 100644 index 0000000000..3e0084139e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java @@ -0,0 +1,402 @@ +package gtPlusPlus.xmod.gregtech.api.util; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.objects.GT_HashSet; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.ItemData; +import gregtech.api.objects.MaterialStack; +import gregtech.api.util.*; + +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import static gregtech.api.enums.GT_Values.*; + +public class GregtechOreDictUnificator { + + + private static final Map<String, ItemStack> sName2StackMap = new HashMap<String, ItemStack>(); + private static final Map<GT_ItemStack, ItemData> sItemStack2DataMap = new HashMap<GT_ItemStack, ItemData>(); + private static final Map<GT_ItemStack, List<ItemStack>> sUnificationTable = new HashMap<GT_ItemStack, List<ItemStack>>(); + private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<GT_ItemStack>(); + + + private static int isRegisteringOre = 0, isAddingOre = 0; + private static boolean mRunThroughTheList = true; + + static { + if (ReflectionUtils.getField(GT_OreDictUnificator.class, "sUnificationTable") == null) { + GregTech_API.sItemStackMappings.add(sUnificationTable); + } + } + + /** + * The Blacklist just prevents the Item from being unificated into something else. + * Useful if you have things like the Industrial Diamond, which is better than regular Diamond, but also usable in absolutely all Diamond Recipes. + */ + public static void addToBlacklist(ItemStack aStack) { + if (GT_Utility.isStackValid(aStack) && !GT_Utility.isStackInList(aStack, sNoUnificationList)) + sNoUnificationList.add(aStack); + } + + public static boolean isBlacklisted(ItemStack aStack) { + return GT_Utility.isStackInList(aStack, sNoUnificationList); + } + + public static void add(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack) { + set(aPrefix, aMaterial, aStack, false, false); + } + + public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack) { + set(aPrefix, aMaterial, aStack, true, false); + } + + public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aOverwrite, boolean aAlreadyRegistered) { + if (aMaterial == null || aPrefix == null || GT_Utility.isStackInvalid(aStack) || Items.feather.getDamage(aStack) == W) + return; + isAddingOre++; + aStack = GT_Utility.copyAmount(1, aStack); + if (!aAlreadyRegistered) registerOre(aPrefix.get(aMaterial), aStack); + addAssociation(aPrefix, aMaterial, aStack, isBlacklisted(aStack)); + if (aOverwrite || GT_Utility.isStackInvalid(sName2StackMap.get(aPrefix.get(aMaterial).toString()))) + sName2StackMap.put(aPrefix.get(aMaterial).toString(), aStack); + isAddingOre--; + } + + public static ItemStack getFirstOre(Object aName, long aAmount) { + if (GT_Utility.isStringInvalid(aName)) return null; + ItemStack tStack = sName2StackMap.get(aName.toString()); + if (GT_Utility.isStackValid(tStack)) return GT_Utility.copyAmount(aAmount, tStack); + return GT_Utility.copyAmount(aAmount, getOres(aName).toArray()); + } + + public static ItemStack get(Object aName, long aAmount) { + return get(aName, null, aAmount, true, true); + } + + public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount) { + return get(aName, aReplacement, aAmount, true, true); + } + + public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, long aAmount) { + return get(aPrefix, aMaterial, null, aAmount); + } + + public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, ItemStack aReplacement, long aAmount) { + //if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) aPrefix.mDynamicItems.add((Materials) aMaterial); + if (StaticFields59.geOrePrefixesBooleanPreventableComponents().contains(aPrefix) && StaticFields59.getOrePrefixesBooleanDisabledItems().contains(aMaterial)) return aReplacement; + return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); + } + + public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount, boolean aMentionPossibleTypos, boolean aNoInvalidAmounts) { + if (aNoInvalidAmounts && aAmount < 1) return null; + if (!sName2StackMap.containsKey(aName.toString()) && aMentionPossibleTypos) + GT_Log.err.println("Unknown Key for Unification, Typo? " + aName); + return GT_Utility.copyAmount(aAmount, sName2StackMap.get(aName.toString()), getFirstOre(aName, aAmount), aReplacement); + } + + public static ItemStack[] setStackArray(boolean aUseBlackList, ItemStack... aStacks) { + for (int i = 0; i < aStacks.length; i++) aStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i])); + return aStacks; + } + + public static ItemStack[] getStackArray(boolean aUseBlackList, Object... aStacks) { + ItemStack[] rStacks = new ItemStack[aStacks.length]; + for (int i = 0; i < aStacks.length; i++) rStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i])); + return rStacks; + } + + public static ItemStack setStack(ItemStack aStack) { + return setStack(true, aStack); + } + + public static ItemStack setStack(boolean aUseBlackList, ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return aStack; + ItemStack tStack = get(aUseBlackList, aStack); + if (GT_Utility.areStacksEqual(aStack, tStack)) return aStack; + aStack.func_150996_a(tStack.getItem()); + Items.feather.setDamage(aStack, Items.feather.getDamage(tStack)); + return aStack; + } + + public static ItemStack get(ItemStack aStack) { + return get(true, aStack); + } + + public static ItemStack get(boolean aUseBlackList, ItemStack aStack) { + return get(aUseBlackList, aStack, false); + } + + public static ItemStack get(boolean aUseBlackList, ItemStack aStack, boolean aOnUnificationTableCreation) { + if (GT_Utility.isStackInvalid(aStack)) return null; + ItemData tPrefixMaterial = getAssociation(aStack); + ItemStack rStack = null; + if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed)) + return GT_Utility.copy(aStack); + if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { + tPrefixMaterial.mBlackListed = true; + return GT_Utility.copy(aStack); + } + if (tPrefixMaterial.mUnificationTarget == null) { + tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); + if (!aOnUnificationTableCreation) sUnificationTable.clear(); + } + rStack = tPrefixMaterial.mUnificationTarget; + if (GT_Utility.isStackInvalid(rStack)) return GT_Utility.copy(aStack); + assert rStack != null; + rStack.setTagCompound(aStack.getTagCompound()); + return GT_Utility.copyAmount(aStack.stackSize, rStack); + } + + public static List<ItemStack> getNonUnifiedStacks(Object obj) { + synchronized (sUnificationTable) { + if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) { + for (GT_ItemStack tGTStack0 : sItemStack2DataMap.keySet()) { + ItemStack tStack0 = tGTStack0.toStack(); + ItemStack tStack1 = get(false, tStack0, true); + if (tStack0 != null && tStack1 != null && !GT_Utility.areStacksEqual(tStack0, tStack1)) { + GT_ItemStack tGTStack1 = new GT_ItemStack(tStack1); + List<ItemStack> list = sUnificationTable.get(tGTStack1); + if (list == null) sUnificationTable.put(tGTStack1, list = new ArrayList<ItemStack>()); + if (!list.contains(tStack0)) list.add(tStack0); + } + } + } + } + ItemStack[] aStacks = {}; + if (obj instanceof ItemStack) aStacks = new ItemStack[]{(ItemStack) obj}; + else if (obj instanceof ItemStack[]) aStacks = (ItemStack[]) obj; + else if (obj instanceof List) aStacks = (ItemStack[]) ((List)obj).toArray(new ItemStack[0]); + List<ItemStack> rList = new ArrayList<ItemStack>(); + for (ItemStack aStack : aStacks) { + rList.add(aStack); + List<ItemStack> tList = sUnificationTable.get(new GT_ItemStack(aStack)); + if (tList != null) { + for (ItemStack tStack : tList) { + ItemStack tStack1 = GT_Utility.copyAmount(aStack.stackSize, tStack); + tStack1.setTagCompound(aStack.getTagCompound()); + rList.add(tStack1); + } + } + } + return rList; + } + + public static void addItemData(ItemStack aStack, ItemData aData) { + if (GT_Utility.isStackValid(aStack) && getItemData(aStack) == null && aData != null) setItemData(aStack, aData); + } + + public static void setItemData(ItemStack aStack, ItemData aData) { + if (GT_Utility.isStackInvalid(aStack) || aData == null) return; + ItemData tData = getItemData(aStack); + if (tData == null || !tData.hasValidPrefixMaterialData()) { + if (tData != null) for (Object tObject : tData.mExtraData) + if (!aData.mExtraData.contains(tObject)) aData.mExtraData.add(tObject); + if (aStack.stackSize > 1) { + if (aData.mMaterial != null) aData.mMaterial.mAmount /= aStack.stackSize; + for (MaterialStack tMaterial : aData.mByProducts) tMaterial.mAmount /= aStack.stackSize; + aStack = GT_Utility.copyAmount(1, aStack); + } + sItemStack2DataMap.put(new GT_ItemStack(aStack), aData); + if (aData.hasValidMaterialData()) { + long tValidMaterialAmount = aData.mMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : aData.mMaterial.mAmount >= 0 ? aData.mMaterial.mAmount : M; + for (MaterialStack tMaterial : aData.mByProducts) + tValidMaterialAmount += tMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : tMaterial.mAmount >= 0 ? tMaterial.mAmount : M; + if (tValidMaterialAmount < M) GT_ModHandler.addToRecyclerBlackList(aStack); + } + if (mRunThroughTheList) { + if (GregTech_API.sLoadStarted) { + mRunThroughTheList = false; + for (Entry<GT_ItemStack, ItemData> tEntry : sItemStack2DataMap.entrySet()) + if (!tEntry.getValue().hasValidPrefixData() || tEntry.getValue().mPrefix.mAllowNormalRecycling) + GT_RecipeRegistrator.registerMaterialRecycling(tEntry.getKey().toStack(), tEntry.getValue()); + } + } else { + if (!aData.hasValidPrefixData() || aData.mPrefix.mAllowNormalRecycling) + GT_RecipeRegistrator.registerMaterialRecycling(aStack, aData); + } + } else { + for (Object tObject : aData.mExtraData) + if (!tData.mExtraData.contains(tObject)) tData.mExtraData.add(tObject); + } + } + + public static void addAssociation(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aBlackListed) { + if (aPrefix == null || aMaterial == null || GT_Utility.isStackInvalid(aStack)) return; + if (Items.feather.getDamage(aStack) == W) for (byte i = 0; i < 16; i++) + setItemData(GT_Utility.copyAmountAndMetaData(1, i, aStack), new ItemData(aPrefix, aMaterial, aBlackListed)); + setItemData(aStack, new ItemData(aPrefix, aMaterial, aBlackListed)); + } + + public static ItemData getItemData(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return null; + ItemData rData = sItemStack2DataMap.get(new GT_ItemStack(aStack)); + if (rData == null) rData = sItemStack2DataMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack))); + return rData; + } + + public static ItemData getAssociation(ItemStack aStack) { + ItemData rData = getItemData(aStack); + return rData != null && rData.hasValidPrefixMaterialData() ? rData : null; + } + + public static boolean isItemStackInstanceOf(ItemStack aStack, Object aName) { + if (GT_Utility.isStringInvalid(aName) || GT_Utility.isStackInvalid(aStack)) return false; + for (ItemStack tOreStack : getOres(aName.toString())) + if (GT_Utility.areStacksEqual(tOreStack, aStack, true)) return true; + return false; + } + + public static boolean isItemStackDye(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + for (Dyes tDye : Dyes.VALUES) if (isItemStackInstanceOf(aStack, tDye.toString())) return true; + return false; + } + + public static boolean registerOre(OrePrefixes aPrefix, Object aMaterial, ItemStack aStack) { + return registerOre(aPrefix.get(aMaterial), aStack); + } + + public static boolean registerOre(Object aName, ItemStack aStack) { + if (aName == null || GT_Utility.isStackInvalid(aStack)) return false; + String tName = aName.toString(); + if (GT_Utility.isStringInvalid(tName)) return false; + ArrayList<ItemStack> tList = getOres(tName); + for (int i = 0; i < tList.size(); i++) if (GT_Utility.areStacksEqual(tList.get(i), aStack, true)) return false; + isRegisteringOre++; + OreDictionary.registerOre(tName, GT_Utility.copyAmount(1, aStack)); + isRegisteringOre--; + return true; + } + + public static boolean isRegisteringOres() { + return isRegisteringOre > 0; + } + + public static boolean isAddingOres() { + return isAddingOre > 0; + } + + public static void resetUnificationEntries() { + for (ItemData tPrefixMaterial : sItemStack2DataMap.values()) tPrefixMaterial.mUnificationTarget = null; + sUnificationTable.clear(); + } + + public static ItemStack getGem(MaterialStack aMaterial) { + return aMaterial == null ? null : getGem(aMaterial.mMaterial, aMaterial.mAmount); + } + + public static ItemStack getGem(Materials aMaterial, OrePrefixes aPrefix) { + return aMaterial == null ? null : getGem(aMaterial, aPrefix.mMaterialAmount); + } + + public static ItemStack getGem(Materials aMaterial, long aMaterialAmount) { + ItemStack rStack = null; + if (((aMaterialAmount >= M))) + rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M); + if (rStack == null) { + if ((((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16)) + rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M); + if ((((aMaterialAmount * 4) >= M))) + rStack = get(OrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / M); + } + return rStack; + } + + public static ItemStack getDust(MaterialStack aMaterial) { + return aMaterial == null ? null : getDust(aMaterial.mMaterial, aMaterial.mAmount); + } + + public static ItemStack getDust(Materials aMaterial, OrePrefixes aPrefix) { + return aMaterial == null ? null : getDust(aMaterial, aPrefix.mMaterialAmount); + } + + public static ItemStack getDust(Materials aMaterial, long aMaterialAmount) { + if (aMaterialAmount <= 0) return null; + ItemStack rStack = null; + if (((aMaterialAmount % M == 0) || aMaterialAmount >= M * 16)) + rStack = get(OrePrefixes.dust, aMaterial, aMaterialAmount / M); + if (rStack == null && (((aMaterialAmount * 4) % M == 0) || aMaterialAmount >= M * 8)) + rStack = get(OrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M); + if (rStack == null && (((aMaterialAmount * 9) >= M))) + rStack = get(OrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M); + return rStack; + } + + public static ItemStack getIngot(MaterialStack aMaterial) { + return aMaterial == null ? null : getIngot(aMaterial.mMaterial, aMaterial.mAmount); + } + + public static ItemStack getIngot(Materials aMaterial, OrePrefixes aPrefix) { + return aMaterial == null ? null : getIngot(aMaterial, aPrefix.mMaterialAmount); + } + + public static ItemStack getIngot(Materials aMaterial, long aMaterialAmount) { + if (aMaterialAmount <= 0) return null; + ItemStack rStack = null; + if (((aMaterialAmount % (M * 9) == 0 && aMaterialAmount / (M * 9) > 1) || aMaterialAmount >= M * 72)) + rStack = get(OrePrefixes.block, aMaterial, aMaterialAmount / (M * 9)); + if (rStack == null && ((aMaterialAmount % M == 0) || aMaterialAmount >= M * 8)) + rStack = get(OrePrefixes.ingot, aMaterial, aMaterialAmount / M); + if (rStack == null && (((aMaterialAmount * 9) >= M))) + rStack = get(OrePrefixes.nugget, aMaterial, (aMaterialAmount * 9) / M); + return rStack; + } + + public static ItemStack getIngotOrDust(Materials aMaterial, long aMaterialAmount) { + if (aMaterialAmount <= 0) return null; + ItemStack rStack = getIngot(aMaterial, aMaterialAmount); + if (rStack == null) rStack = getDust(aMaterial, aMaterialAmount); + return rStack; + } + + public static ItemStack getIngotOrDust(MaterialStack aMaterial) { + ItemStack rStack = getIngot(aMaterial); + if(aMaterial!=null&&aMaterial.mMaterial!=null&&(aMaterial.mMaterial==Materials.Naquadah||aMaterial.mMaterial==Materials.NaquadahEnriched))rStack = getDust(aMaterial); + if (rStack == null) rStack = getDust(aMaterial); + return rStack; + } + + public static ItemStack getDustOrIngot(Materials aMaterial, long aMaterialAmount) { + if (aMaterialAmount <= 0) return null; + ItemStack rStack = getDust(aMaterial, aMaterialAmount); + if (rStack == null) rStack = getIngot(aMaterial, aMaterialAmount); + return rStack; + } + + public static ItemStack getDustOrIngot(MaterialStack aMaterial) { + ItemStack rStack = getDust(aMaterial); + if (rStack == null) rStack = getIngot(aMaterial); + return rStack; + } + + /** + * @return a Copy of the OreDictionary.getOres() List + */ + public static ArrayList<ItemStack> getOres(OrePrefixes aPrefix, Object aMaterial) { + return getOres(aPrefix.get(aMaterial)); + } + + /** + * @return a Copy of the OreDictionary.getOres() List + */ + public static ArrayList<ItemStack> getOres(Object aOreName) { + String aName = aOreName == null ? E : aOreName.toString(); + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + if (GT_Utility.isStringValid(aName)) rList.addAll(OreDictionary.getOres(aName)); + return rList; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java new file mode 100644 index 0000000000..74655fb744 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java @@ -0,0 +1,35 @@ +package gtPlusPlus.xmod.gregtech.api.util; + +import java.util.HashMap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +public class SpecialBehaviourTooltipHandler { + + private static final HashMap<ItemStack, String> mTooltipCache = new HashMap<ItemStack, String>(); + + public static void addTooltipForItem(ItemStack aStack, String aTooltip) { + mTooltipCache.put(aStack, aTooltip); + } + + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event){ + if (event != null) { + if (event.itemStack != null) { + for (ItemStack aKey : mTooltipCache.keySet()) { + if (GT_Utility.areStacksEqual(aKey, event.itemStack, false)) { + String s = mTooltipCache.get(aKey); + if (s != null && s.length() > 0) { + event.toolTip.add(EnumChatFormatting.RED+s); + } + } + } + } + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java new file mode 100644 index 0000000000..795fd18826 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java @@ -0,0 +1,61 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import static gtPlusPlus.xmod.gregtech.HANDLER_GT.sCustomWorldgenFile; + +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +public abstract class GTPP_Worldgen{ + + public final String mWorldGenName; + public final boolean mEnabled; + private final Map<String, Boolean> mDimensionMap = new ConcurrentHashMap<String, Boolean>(); + + public GTPP_Worldgen(String aName, List aList, boolean aDefault) { + mWorldGenName = aName; + mEnabled = sCustomWorldgenFile.get("worldgen", mWorldGenName, aDefault); + if (mEnabled) aList.add(this); + } + + /** + * @param aWorld The World Object + * @param aRandom The Random Generator to use + * @param aBiome The Name of the Biome (always != null) + * @param aDimensionType The Type of Worldgeneration to add. -1 = Nether, 0 = Overworld, +1 = End + * @param aChunkX xCoord of the Chunk + * @param aChunkZ zCoord of the Chunk + * @return if the Worldgeneration has been successfully completed + */ + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + return false; + } + + /** + * @param aWorld The World Object + * @param aRandom The Random Generator to use + * @param aBiome The Name of the Biome (always != null) + * @param aDimensionType The Type of Worldgeneration to add. -1 = Nether, 0 = Overworld, +1 = End + * @param aChunkX xCoord of the Chunk + * @param aChunkZ zCoord of the Chunk + * @return if the Worldgeneration has been successfully completed + */ + public boolean executeCavegen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + return false; + } + + public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) { + String aDimName = aWorld.provider.getDimensionName(); + Boolean tAllowed = mDimensionMap.get(aDimName); + if (tAllowed == null) { + boolean tValue = sCustomWorldgenFile.get("worldgen.dimensions." + mWorldGenName, aDimName, aDimensionType == aAllowedDimensionType); + mDimensionMap.put(aDimName, tValue); + return tValue; + } + return tAllowed; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java new file mode 100644 index 0000000000..ca78a72e04 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java @@ -0,0 +1,77 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import java.util.Collection; +import java.util.Random; + +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +public class GTPP_Worldgen_Boulder extends GTPP_Worldgen_Ore { + public GTPP_Worldgen_Boulder(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) { + super(aName, aDefault, aBlock, aBlockMeta, aDimensionType, aAmount, aSize, aProbability, aMinY, aMaxY, aBiomeList, aAllowToGenerateinVoid); + } + + @Override + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + if (isGenerationAllowed(aWorld, aDimensionType, mDimensionType) && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome)) && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) { + for (int i = 0; i < mAmount; i++) { + int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); + Block tBlock = aWorld.getBlock(tX, tY - 7, tZ); + if (tBlock != null && tBlock.isOpaqueCube() && aWorld.getBlock(tX, tY - 6, tZ).isAir(aWorld, tX, tY - 6, tZ)) { + float math_pi = CORE.PI; + float var6 = aRandom.nextFloat() * math_pi; + float var1b = mSize / 8.0F; + float var3b = MathHelper.sin(var6) * var1b; float var4b = MathHelper.cos(var6) * var1b; + float var8b = -2*var3b;float var9b = -2*var4b; + int var10b = (tX + 8);int var11b = (tZ + 8); + float var7 = (var10b + var3b); + float var11 = (var11b + var4b); + int var5b = aRandom.nextInt(3);int var6b = aRandom.nextInt(3);int var7b = var6b - var5b; + float var15 = (tY + var5b - 2); + float var12b = math_pi / mSize; + + for (int var19 = 0; var19 <= mSize; ++var19) { + float var2b = var19 / mSize; + float var20 = var7 + var8b * var2b; + float var22 = var15 + var7b * var2b; + float var24 = var11 + var9b * var2b; + float var26 = aRandom.nextFloat() * mSize / 16.0F; + float var28 = ((MathHelper.sin(var19 * var12b) + 1.0F) * var26 + 1.0F) / 2.0F; + int var32 = MathHelper.floor_float(var20 - var28); + int var33 = MathHelper.floor_float(var22 - var28); + int var34 = MathHelper.floor_float(var24 - var28); + int var35 = MathHelper.floor_float(var20 + var28); + int var36 = MathHelper.floor_float(var22 + var28); + int var37 = MathHelper.floor_float(var24 + var28); + + for (int var38 = var32; var38 <= var35; ++var38) { + float var39 = (var38 + 0.5F - var20) / (var28); + float var13b = var39 * var39; + if (var13b < 1.0F) { + for (int var41 = var33; var41 <= var36; ++var41) { + float var42 = (var41 + 0.5F - var22) / (var28); + float var14b = var13b + var42 * var42; + if (var14b < 1.0F) { + for (int var44 = var34; var44 <= var37; ++var44) { + float var45 = (var44 + 0.5F - var24) / (var28); + Block block = aWorld.getBlock(var38, var41, var44); + if (var14b + var45 * var45 < 1.0F && ((mAllowToGenerateinVoid && aWorld.getBlock(var38, var41, var44).isAir(aWorld, var38, var41, var44)) || (block != null && !(block instanceof BlockContainer)))) { + aWorld.setBlock(var38, var41, var44, mBlock, mBlockMeta, 0); + } + } + } + } + } + } + } + } + } + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java new file mode 100644 index 0000000000..7cd215aa4e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java @@ -0,0 +1,167 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import static gtPlusPlus.xmod.gregtech.HANDLER_GT.sCustomWorldgenFile; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.common.blocks.GT_TileEntity_Ores; +import gregtech.loaders.misc.GT_Achievements; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; + +public class GTPP_Worldgen_GT_Ore_Layer +extends GTPP_Worldgen { + public static ArrayList<GTPP_Worldgen_GT_Ore_Layer> sList = new ArrayList<GTPP_Worldgen_GT_Ore_Layer>(); + public static int sWeight = 0; + public final short mMinY; + public final short mMaxY; + public final short mWeight; + public final short mDensity; + public final short mSize; + public short mPrimaryMeta; + public short mSecondaryMeta; + public short mBetweenMeta; + public short mSporadicMeta; + public final String mRestrictBiome; + public final boolean mDarkWorld; + public final String aTextWorldgen = "worldgen.gtpp."; + + public GTPP_Worldgen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, boolean aOverworld, Materials aPrimary, Materials aSecondary, Materials aBetween, Materials aSporadic) { + super(aName, sList, aDefault); + this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); + this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); + this.mMaxY = ((short) Math.max(this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); + this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); + this.mPrimaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); + this.mSecondaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); + this.mBetweenMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); + this.mSporadicMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); + this.mRestrictBiome = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); + + if (this.mEnabled) { + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + sWeight += this.mWeight; + } + } + + public GTPP_Worldgen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, + int aSize, Material aPrimary, Material aSecondary, Material aBetween, + Material aSporadic) { + super(aName, sList, aDefault); + this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Darkworld", true); + this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); + this.mMaxY = ((short) Math.max(this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); + this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); + /*this.mPrimaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); + this.mSecondaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); + this.mBetweenMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); + this.mSporadicMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); + */this.mRestrictBiome = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); + + if (this.mEnabled) { + /* GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + */ sWeight += this.mWeight; + } + } + + @Override + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { + return false; //Not the correct biome for ore mix + } + if (!isGenerationAllowed(aWorld, aDimensionType, ((aDimensionType == -1) && (false)) || ((aDimensionType == 0) && (this.mDarkWorld)) || ((aDimensionType == 1) && (false)) || ((aWorld.provider.getDimensionName().equals("Moon")) && (false)) || ((aWorld.provider.getDimensionName().equals("Mars")) && (false)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) { + return false; + } + int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5); + + int cX = aChunkX - aRandom.nextInt(this.mSize); + int eX = aChunkX + 16 + aRandom.nextInt(this.mSize); + for (int tX = cX; tX <= eX; tX++) { + int cZ = aChunkZ - aRandom.nextInt(this.mSize); + int eZ = aChunkZ + 16 + aRandom.nextInt(this.mSize); + for (int tZ = cZ; tZ <= eZ; tZ++) { + if (this.mSecondaryMeta > 0) { + for (int i = tMinY - 1; i < tMinY + 2; i++) { + if ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { + setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); + } + } + } + if ((this.mBetweenMeta > 0) && ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0))) { + setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); + } + if (this.mPrimaryMeta > 0) { + for (int i = tMinY + 3; i < tMinY + 6; i++) { + if ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { + setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); + } + } + } + if ((this.mSporadicMeta > 0) && ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0))) { + setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); + } + } + } + if (GT_Values.D1) { + System.out.println("Generated Orevein: " + this.mWorldGenName+" "+aChunkX +" "+ aChunkZ); + } + return true; + } + private Method mSetOre = null; + private boolean setOreBlock(World world, int x, int y, int z, int secondarymeta, boolean bool){ + + if (mSetOre == null){ + try { + mSetOre = GT_TileEntity_Ores.class.getMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class, boolean.class); + } + catch (SecurityException | NoSuchMethodException e) { + try { + mSetOre = GT_TileEntity_Ores.class.getMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class); + } + catch (SecurityException | NoSuchMethodException r) {} + } + } + + if (mSetOre != null) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + try { + return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta, bool); + } + catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { + return false; + } + } + else { + try { + return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta); + } + catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { + return false;} + } + } + else { + return false; + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java new file mode 100644 index 0000000000..aae3bdd48a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java @@ -0,0 +1,41 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import static gtPlusPlus.xmod.gregtech.api.world.WorldGenUtils.mOresToRegister; + +import gtPlusPlus.core.material.Material; + +public class GTPP_Worldgen_Handler implements Runnable{ + + + + @Override + public void run() { + + for (GT_OreVein_Object ore : mOresToRegister){ + generateNewVein(ore); + } + + } + + + + private final GTPP_Worldgen_GT_Ore_Layer generateNewVein(final GT_OreVein_Object ore){ + return generateNewVein(ore.mOreMixName, ore.minY, ore.maxY, ore.weight, ore.density, ore.size, ore.aPrimary, ore.aSecondary, ore.aBetween, ore.aSporadic); + } + + private final GTPP_Worldgen_GT_Ore_Layer generateNewVein(String mOreMixName, int minY, int maxY, int weight, int density, int size, + Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic){ + return new GTPP_Worldgen_GT_Ore_Layer( + "ore.mix."+mOreMixName, //String aName, + true, //boolean aDefault, + minY, maxY, //int aMinY, int aMaxY, + weight, //int aWeight, + density, //int aDensity, + size, //int aSize, + aPrimary, //Materials aPrimary, + aSecondary, //Materials aSecondary, + aBetween, //Materials aBetween, + aSporadic); //Materials aSporadic + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java new file mode 100644 index 0000000000..2d7f817060 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java @@ -0,0 +1,33 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import static gtPlusPlus.xmod.gregtech.HANDLER_GT.sCustomWorldgenFile; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.block.Block; + +import gtPlusPlus.xmod.gregtech.HANDLER_GT; + +public abstract class GTPP_Worldgen_Ore extends GTPP_Worldgen { + public final int mBlockMeta, mAmount, mSize, mMinY, mMaxY, mProbability, mDimensionType; + public final Block mBlock; + public final Collection<String> mBiomeList; + public final boolean mAllowToGenerateinVoid; + private final String aTextWorldgen = "worldgen."; + + public GTPP_Worldgen_Ore(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) { + super(aName, HANDLER_GT.sCustomWorldgenList, aDefault); + mDimensionType = aDimensionType; + mBlock = aBlock; + mBlockMeta = Math.min(Math.max(aBlockMeta, 0), 15); + mProbability = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "Probability", aProbability); + mAmount = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "Amount", aAmount); + mSize = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "Size", aSize); + mMinY = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "MinHeight", aMinY); + mMaxY = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "MaxHeight", aMaxY); + if (aBiomeList == null) mBiomeList = new ArrayList<String>(); + else mBiomeList = aBiomeList; + mAllowToGenerateinVoid = aAllowToGenerateinVoid; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java new file mode 100644 index 0000000000..e66106ad4a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java @@ -0,0 +1,75 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import java.util.Collection; +import java.util.Random; + +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +public class GTPP_Worldgen_Ore_Normal extends GTPP_Worldgen_Ore { + public GTPP_Worldgen_Ore_Normal(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) { + super(aName, aDefault, aBlock, aBlockMeta, aDimensionType, aAmount, aSize, aProbability, aMinY, aMaxY, aBiomeList, aAllowToGenerateinVoid); + } + + @Override + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + if (isGenerationAllowed(aWorld, aDimensionType, mDimensionType) && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome)) && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) { + for (int i = 0; i < mAmount; i++) { + int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); + if (mAllowToGenerateinVoid || aWorld.getBlock(tX, tY, tZ).isAir(aWorld, tX, tY, tZ)) { + float math_pi = CORE.PI;float var1b = mSize / 8.0F; + float var6 = aRandom.nextFloat() * math_pi; + float var3b = MathHelper.sin(var6) * var1b; float var4b = MathHelper.cos(var6) * var1b; + float var8b = -2*var3b;float var9b = -2*var4b; + int var10b = (tX + 8);int var11b = (tZ + 8); + float var7 = (var10b + var3b); + float var11 = (var11b + var4b); + int var5b = aRandom.nextInt(3);int var6b = aRandom.nextInt(3);int var7b = var6b - var5b; + float var15 = (tY + var5b - 2); + float var12b = math_pi / mSize; + + for (int var19 = 0; var19 <= mSize; ++var19) { + float var2b = var19 / mSize; + float var20 = var7 + var8b * var2b; + float var22 = var15 + var7b * var2b; + float var24 = var11 + var9b * var2b; + float var26 = aRandom.nextFloat() * mSize / 16.0F; + float var28 = ((MathHelper.sin(var19 * var12b) + 1.0F) * var26 + 1.0F) / 2.0F; + int var32 = MathHelper.floor_float(var20 - var28); + int var33 = MathHelper.floor_float(var22 - var28); + int var34 = MathHelper.floor_float(var24 - var28); + int var35 = MathHelper.floor_float(var20 + var28); + int var36 = MathHelper.floor_float(var22 + var28); + int var37 = MathHelper.floor_float(var24 + var28); + + for (int var38 = var32; var38 <= var35; ++var38) { + float var39 = (var38 + 0.5F - var20) / (var28); + float var13b = var39 * var39; + if (var13b < 1.0F) { + for (int var41 = var33; var41 <= var36; ++var41) { + float var42 = (var41 + 0.5F - var22) / (var28); + float var14b = var13b + var42 * var42; + if (var14b < 1.0F) { + for (int var44 = var34; var44 <= var37; ++var44) { + float var45 = (var44 + 0.5F - var24) / (var28); + Block block = aWorld.getBlock(var38, var41, var44); + if (var14b + var45 * var45 < 1.0F && ((mAllowToGenerateinVoid && aWorld.getBlock(var38, var41, var44).isAir(aWorld, var38, var41, var44)) || (block != null && (block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.end_stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.netherrack))))) { + aWorld.setBlock(var38, var41, var44, mBlock, mBlockMeta, 0); + } + } + } + } + } + } + } + } + } + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java new file mode 100644 index 0000000000..770083fee8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java @@ -0,0 +1,31 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import gtPlusPlus.core.material.Material; + +public class GT_OreVein_Object { + + final String mOreMixName; //String aName, + final int minY, maxY; //int aMinY, int aMaxY, + final int weight; //int aWeight, + final int density; //int aDensity, + final int size; //int aSize, + final Material aPrimary; //Materials aPrimary, + final Material aSecondary; //Materials aSecondary, + final Material aBetween; //Materials aBetween, + final Material aSporadic; //Materials aSporadic + + GT_OreVein_Object(String mOreMixName, int minY, int maxY, int weight, int density, int size, + Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic){ + this.mOreMixName = mOreMixName; + this.minY = minY; + this.maxY = maxY; + this.weight = weight; + this.density = density; + this.size = size; + this.aPrimary = aPrimary; + this.aSecondary = aSecondary; + this.aBetween = aBetween; + this.aSporadic = aSporadic; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java new file mode 100644 index 0000000000..fd0738596a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java @@ -0,0 +1,23 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import java.util.ArrayList; +import java.util.List; + +import gtPlusPlus.core.material.Material; + +public class WorldGenUtils { + + static List<GT_OreVein_Object> mOresToRegister = new ArrayList<GT_OreVein_Object>(); + + public static final void addNewOreMixForWorldgen(GT_OreVein_Object newVein){ + mOresToRegister.add(newVein); + } + + public static boolean generateNewOreVeinObject(String mOreMixName, int minY, int maxY, int weight, int density, int size, + Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic){ + GT_OreVein_Object newVein = new GT_OreVein_Object(mOreMixName, minY, maxY, weight, density, size, aPrimary, aSecondary, aBetween, aSporadic); + addNewOreMixForWorldgen(newVein); + return true; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java new file mode 100644 index 0000000000..091ee734e6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -0,0 +1,631 @@ +package gtPlusPlus.xmod.gregtech.common; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.*; + +import org.apache.commons.lang3.ArrayUtils; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.*; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.util.*; +import gregtech.common.GT_Proxy; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.FormattedTooltipString; +import gtPlusPlus.core.handler.AchievementHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.*; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; +import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.BaseCustomPower_MTE; +import gtPlusPlus.xmod.gregtech.common.covers.CoverManager; +import gtPlusPlus.xmod.gregtech.common.helpers.MachineUpdateHandler; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_WorldAccelerator; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class Meta_GT_Proxy { + + static { + Logger.INFO("GT_PROXY - initialized."); + sDoesVolumetricFlaskExist = ReflectionUtils.doesClassExist("gregtech.common.items.GT_VolumetricFlask"); + } + + public static List<Runnable> GT_BlockIconload = new ArrayList<>(); + public static List<Runnable> GT_ItemIconload = new ArrayList<>(); + + public static AutoMap<Integer> GT_ValidHeatingCoilMetas = new AutoMap<Integer>(); + + private static Class<BaseCustomTileEntity> sBaseMetaTileEntityClass; + private static Class<BaseCustomPower_MTE> sBaseMetaTileEntityClass2; + + public static AchievementHandler mAssemblyAchievements; + + public static final Map<String, FormattedTooltipString> mCustomGregtechMetaTooltips = new LinkedHashMap<String, FormattedTooltipString>(); + + /** + * Does this feature exist within GT? Saves loading useless content if not. + */ + public static final boolean sDoesVolumetricFlaskExist; + + @SideOnly(Side.CLIENT) + public static IIconRegister sBlockIcons, sItemIcons; + + public Meta_GT_Proxy() { + + } + + public static Block sBlockMachines; + + public static void preInit() { + + //New GT++ Block, yay! (Progress) + //sBlockMachines = new GTPP_Block_Machines(); + fixIC2FluidNames(); + + GT_Log.out.println("GT++ Mod: Register TileEntities."); + BaseMetaTileEntity tBaseMetaTileEntity = constructBaseMetaTileEntity(); + BaseMetaTileEntity tBaseMetaTileEntity2 = constructBaseMetaTileEntityCustomPower(); + + GT_Log.out.println("GT++ Mod: Testing BaseMetaTileEntity."); + if (tBaseMetaTileEntity == null || tBaseMetaTileEntity2 == null) { + GT_Log.out.println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + throw new RuntimeException(""); + } + + //Gotta set it here so that we don't try call gregtech too early. + //Must set on the correct side + + if (ReflectionUtils.doesFieldExist(GT_Proxy.class, "gt6Pipe")) { + StaticFields59.mGT6StylePipes = (boolean) StaticFields59.getFieldFromGregtechProxy("gt6Pipe"); + } + else { + StaticFields59.mGT6StylePipes = false; + } + + GT_Log.out.println("GT++ Mod: Registering the BaseMetaTileEntity."); + GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntity_GTPP"); + GameRegistry.registerTileEntity(tBaseMetaTileEntity2.getClass(), "BaseMetaTileEntity_GTPP2"); + CoverManager.generateCustomCovers(); + } + + public static void init() { + setValidHeatingCoilMetas(); + PollutionUtils.setPollutionFluids(); + fixIC2FluidNames(); + Utils.registerEvent(new MachineUpdateHandler()); + } + + public static void postInit() { + mAssemblyAchievements = new AchievementHandler(); + fixIC2FluidNames(); + + // Finalise TAE + TAE.finalizeTAE(); + } + + @SuppressWarnings("deprecation") + public static void fixIC2FluidNames() { + //Fix IC2 Hot Water name + try { + String aNewHeatedWaterName = "Heated Water"; + Logger.INFO("Renaming [IC2 Hotspring Water] --> ["+aNewHeatedWaterName+"].");LanguageRegistry.instance().addStringLocalization("fluidHotWater", "Heated Water"); + LanguageRegistry.instance().addStringLocalization("fluidHotWater", aNewHeatedWaterName); + LanguageRegistry.instance().addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName); + + Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater); + if (b != null) { + LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName); + LanguageRegistry.instance().addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName); + } + Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater); + if (f != null) { + LanguageRegistry.instance().addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName); + int aDam = FluidRegistry.getFluidID(f); + ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam); + if (s != null) { + LanguageRegistry.addName(s, aNewHeatedWaterName); + } + } + + String[] aLangs = new String[] { + "de_DE", + "en_US", + "en_GB", + "en_IC", + "es_AR", + "es_ES", + "es_MX", + "es_UY", + "es_VE", + "fr_CA", + "fr_FR", + "it_IT", + "ko_KR", + "pt_BR", + "pt_PT", + "ru_RU", + "sv_SE", + "tr_TR", + "zh_CN", + "zh_TW", + }; + String[] aLangValues = new String[] { + "Erhitztes Wasser", + "Heated Water", + "Heated Water", + "Heated Water", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Agua caliente", + "Eau chauffée", + "Eau chauffée", + "Acqua riscaldata", + "온수", + "Água aquecida", + "Água aquecida", + "Вода с подогревом", + "Uppvärmt vatten", + "Isıtılmış Su", + "热水", + "热水", + + }; + for (int i=0;i<aLangs.length;i++) { + Logger.REFLECTION("Trying to inject new lang data for "+aLangs[i]+", using value: "+aLangValues[i]); + LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "fluidHotWater", aLangValues[i]); + LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "ic2.fluidHotWater", aLangValues[i]); + } + } + + catch (Throwable t) { + + } + } + + public static boolean generatePlasmaRecipesForAdvVacFreezer() { + + AutoMap<GT_Recipe> aFreezerMapRebaked = new AutoMap<GT_Recipe>(); + AutoMap<GT_Recipe> aRemovedRecipes = new AutoMap<GT_Recipe>(); + + //Find recipes containing Plasma and map them + for (GT_Recipe y : GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList) { + if (y.mFluidInputs.length > 0) { + for (FluidStack r : y.mFluidInputs) { + if (r.getUnlocalizedName().toLowerCase().contains("plasma")) { + aRemovedRecipes.put(y); + continue; + } + } + aFreezerMapRebaked.put(y); + } + } + + AutoMap<GTPP_Recipe> aNewRecipes = new AutoMap<GTPP_Recipe>(); + int aAtomicMass = 0; + int aAtomicTier = 0; + + final FluidStack NULL_PLASMA = Materials._NULL.getPlasma(1); + + for (String s : ELEMENT.NAMES) { + + aAtomicMass++; + aAtomicTier = (aAtomicMass/30)+1; + FluidStack aMoltenFluid = null; + FluidStack aPlasma = null; + + //Try Get Material via Gregtech + Materials aGregMaterial = MaterialUtils.getMaterial(s); + if (aGregMaterial != null) { + aMoltenFluid = aGregMaterial.getMolten(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getFluid(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getGas(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getSolid(1); + } + } + } + aPlasma = aGregMaterial.getPlasma(100); + } + + //Just wildcard values + if (aMoltenFluid == null || aPlasma == null) { + if (aMoltenFluid == null) { + aMoltenFluid = FluidUtils.getWildcardFluidStack(s, 1); + } + if (aPlasma == null) { + aPlasma = FluidUtils.getFluidStack("plasma."+s.toLowerCase(), 1); + } + } + + //Skip this material + if (aMoltenFluid == null || aPlasma == null || aPlasma.isFluidEqual(NULL_PLASMA)) { + Logger.INFO("Could not generate Advanced Vacuum Freezer recipe. Cooling "+s+" plasma. Molten Form Exists? "+(aMoltenFluid != null)+" | Plasma Exists? "+(aPlasma != null)); + continue; + } + else { + //Build a new plasma recipe + int aTotalTickTime = (20 * 1 + (aAtomicMass)); + GTPP_Recipe aTempRecipe = new GTPP_Recipe(true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {10000}, + new FluidStack[] { + aPlasma, + FluidUtils.getFluidStack("cryotheum", aTotalTickTime) + }, + new FluidStack[] { + aMoltenFluid + }, + aTotalTickTime, + (int) GT_Values.V[4+aAtomicTier], + aAtomicMass); + + //Add it to the map if it's valid + if (aTempRecipe != null) { + aNewRecipes.put(aTempRecipe); + } + } + + } + + + //Add the new recipes to the map we will rebake over the original + for (GTPP_Recipe w : aNewRecipes) { + aFreezerMapRebaked.put(w); + } + + //Best not touch the original map if we don't have a valid map to override it with. + if (aFreezerMapRebaked.size() > 0) { + + int aOriginalCount = GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.size(); + + //Empty the original map + GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.clear(); + + //Rebake the real map + for (GT_Recipe w : aFreezerMapRebaked) { + GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.add(w); + } + + return GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mRecipeList.size() >= aOriginalCount; + } + + return false; + } + + public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { + if (aMeta == 12) { + return Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower(); + } + else { + return Meta_GT_Proxy.constructBaseMetaTileEntity(); + } + } + + public static BaseCustomTileEntity constructBaseMetaTileEntity() { + if (sBaseMetaTileEntityClass == null) { + try { + sBaseMetaTileEntityClass = BaseCustomTileEntity.class; + return (BaseCustomTileEntity) BaseCustomTileEntity.class.newInstance(); + } catch (Throwable arg1) { + try { + Constructor<?> g = BaseCustomTileEntity.class.getConstructors()[0]; + g.setAccessible(true); + return (BaseCustomTileEntity) g.newInstance(); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | SecurityException e) { + } + } + } + try { + return (BaseCustomTileEntity) ((BaseCustomTileEntity) sBaseMetaTileEntityClass.newInstance()); + } catch (Throwable arg0) { + arg0.printStackTrace(GT_Log.err); + try { + Constructor<?> g = BaseCustomTileEntity.class.getConstructors()[0]; + g.setAccessible(true); + return (BaseCustomTileEntity) g.newInstance(); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | SecurityException e) { + GT_Log.err + .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + e.printStackTrace(GT_Log.err); + throw new RuntimeException(e); + } + } + } + + public static BaseCustomPower_MTE constructBaseMetaTileEntityCustomPower() { + if (sBaseMetaTileEntityClass2 == null) { + try { + sBaseMetaTileEntityClass2 = BaseCustomPower_MTE.class; + return (BaseCustomPower_MTE) BaseCustomPower_MTE.class.newInstance(); + } catch (Throwable arg1) { + try { + Constructor<?> g = BaseCustomPower_MTE.class.getConstructors()[0]; + g.setAccessible(true); + return (BaseCustomPower_MTE) g.newInstance(); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | SecurityException e) { + // e.printStackTrace(); + } + } + } + + try { + return (BaseCustomPower_MTE) ((BaseCustomPower_MTE) sBaseMetaTileEntityClass2.newInstance()); + } catch (Throwable arg0) { + arg0.printStackTrace(GT_Log.err); + try { + Constructor<?> g = BaseCustomPower_MTE.class.getConstructors()[0]; + g.setAccessible(true); + return (BaseCustomPower_MTE) g.newInstance(); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | SecurityException e) { + GT_Log.err + .println("GT++ Mod: Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + e.printStackTrace(GT_Log.err); + throw new RuntimeException(e); + } + } + } + + + + + + public static boolean setTileEntityClassAsBlacklistedInWorldAccelerator(String aClassName) { + if (CORE.GTNH) { + Class aMainModClass = ReflectionUtils.getClass("com.dreammaster.main.MainRegistry"); + Class aCoreModConfig = ReflectionUtils.getClass("com.dreammaster.config"); + if (aMainModClass != null && aCoreModConfig != null) { + Field aCoreConfig = ReflectionUtils.getField(aMainModClass, "CoreConfig"); + if (aCoreConfig != null) { + Field aBlackList = ReflectionUtils.getField(aCoreModConfig, "BlacklistedTileEntiyClassNames"); + Object aInstance = ReflectionUtils.getFieldValue(aCoreConfig); + if (aBlackList != null && aInstance != null) { + String[] aBlackListValue = (String[]) ReflectionUtils.getFieldValue(aBlackList, aInstance); + if (aBlackListValue != null) { + aBlackListValue = ArrayUtils.add(aBlackListValue, aClassName); + ReflectionUtils.setField(aInstance, aBlackList, aBlackListValue); + return true; + } + } + } + } + } + else { + GT_MetaTileEntity_WorldAccelerator.BlacklistedTileEntiyClassNames = ArrayUtils.add(GT_MetaTileEntity_WorldAccelerator.BlacklistedTileEntiyClassNames, aClassName); + return true; + } + return false; + } + + + + public static void setValidHeatingCoilMetas() { + for (int i = 0; i <= 6; i++ ) { + GT_ValidHeatingCoilMetas.put(i); + } + if (CORE.GTNH) { + for (int i = 7; i <= 8; i++ ) { + GT_ValidHeatingCoilMetas.put(i); + } + } + } + + public static boolean areWeUsingGregtech5uExperimental(){ + final int version = GregTech_API.VERSION; + if ((version == 508) || (version == 507)){ + return false; + } + else if (version == 509){ + return true; + } + else { + return false; + } + } + + static GT_Proxy[] mProxies = new GT_Proxy[2]; + + /** + * @deprecated Use {@link StaticFields59#getFieldFromGregtechProxy(boolean,String)} instead + */ + public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { + return StaticFields59.getFieldFromGregtechProxy(client, fieldName); + } + + public static void setCustomGregtechTooltip(String aNbtTagName, FormattedTooltipString aData) { + mCustomGregtechMetaTooltips.put(aNbtTagName, aData); + } + + public static void conStructGtTileBlockTooltip(ItemStack aStack, EntityPlayer aPlayer, List<Object> aList, boolean par4) { + try { + int tDamage = aStack.getItemDamage(); + if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { + return; + } + + if (GregTech_API.METATILEENTITIES[tDamage] != null) { + IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); + if (tTileEntity.getDescription() != null) { + int i = 0; + for (String tDescription : tTileEntity.getDescription()) { + if (GT_Utility.isStringValid(tDescription)) { + if(tDescription.contains("%%%")){ + String[] tString = tDescription.split("%%%"); + if(tString.length>=2){ + StringBuffer tBuffer = new StringBuffer(); + Object tRep[] = new String[tString.length / 2]; + for (int j = 0; j < tString.length; j++) + if (j % 2 == 0) tBuffer.append(tString[j]); + else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} + aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished), tRep)); + } + }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); + aList.add(tTranslated.equals("") ? tDescription : tTranslated);} + }else i++; + } + } + + + + if (tTileEntity.getEUCapacity() > 0L) { + + final long tVoltage = tTileEntity.getInputVoltage(); + byte tTier = (byte) ((byte) Math.max(1, GT_Utility.getTier(tVoltage))); + + //Custom handling + if (tDamage < 30500 && tDamage >= 30400) { + int aOffset = tDamage - 30400; + if ((aOffset) <= 10) { + tTier -= 2; + aList.add(EnumChatFormatting.BOLD+"16"+" Fuse Slots"+EnumChatFormatting.GRAY); + aList.add("Per each fuse, you may insert "+EnumChatFormatting.YELLOW+(GT_Values.V[tTier])+EnumChatFormatting.GRAY+" EU/t"); + aList.add("However this "+EnumChatFormatting.ITALIC+EnumChatFormatting.RED+"MUST"+EnumChatFormatting.GRAY+" be in a single Amp"); + aList.add("This machine can accept upto a single amp of "+GT_Values.VN[Math.min(tTier+2, 12)]+" as a result"); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Breaker_Loss", "Breaker Loss: "+EnumChatFormatting.RED+""+(GT_Values.V[Math.max(tTier-1, 0)]/10)+EnumChatFormatting.GRAY+" EU/t", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + } + + + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Special_Power_1", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_2", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_3", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + } + + + if (tTileEntity.getInputVoltage() > 0L) { + String inA = "0"; + if (tTileEntity.getInputAmperage() >= 1L) { + inA = " at " + EnumChatFormatting.YELLOW + tTileEntity.getInputAmperage() + EnumChatFormatting.GRAY +" Amps"; + } + else { + inA = " at " + EnumChatFormatting.WHITE + tTileEntity.getInputAmperage() + EnumChatFormatting.GRAY +" Amps"; + } + String a1 = "Voltage IN: "+EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + + EnumChatFormatting.GRAY + inA; + aList.add(a1); + } + + if (tTileEntity.getOutputVoltage() > 0L) { + String outA = "0"; + if (tTileEntity.getOutputAmperage() >= 1L) { + outA = " at " + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY +" Amps"; + } + else { + outA = " at " + EnumChatFormatting.WHITE + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY +" Amps"; + } + String a1 = "Voltage OUT: "+EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" + + EnumChatFormatting.GRAY + outA; + aList.add(a1); + } + + + if (tTileEntity.getOutputVoltage() > 0L) { + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Lossess_EU", "Transmission Loss: "+EnumChatFormatting.DARK_BLUE+""+(tDamage < 30500 && tDamage >= 30400 ? 0 : 1), !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + } + + if (tTileEntity.getEUCapacity() > 0) { + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE2", + "Internal Capacity: ", !GregTech_API.sPostloadFinished) + EnumChatFormatting.BLUE + + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY + " EU"); + } + } + + /*if (tTileEntity.getEUCapacity() > 0L) { + if (tTileEntity.getInputVoltage() > 0L) { + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + EnumChatFormatting.GRAY); + } + if (tTileEntity.getOutputVoltage() > 0L) { + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" + EnumChatFormatting.GRAY); + } + if (tTileEntity.getOutputAmperage() > 1L) { + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY); + } + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY); + }*/ + + } + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + if (aNBT.getBoolean("mMuffler")) { + aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished )); + } + if (aNBT.getBoolean("mSteamConverter")) { + aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade", !GregTech_API.sPostloadFinished )); + } + int tAmount = 0; + if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) { + aList.add(tAmount + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades", !GregTech_API.sPostloadFinished )); + } + + FluidStack afluid = net.minecraftforge.fluids.FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + if (afluid != null) { + int tFluidAmount = afluid.amount; + if (tFluidAmount > 0) { + aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_FLUIDTANK", "Tank Fluid: "+tFluidAmount+"L "+afluid.getLocalizedName()+"", !GregTech_API.sPostloadFinished )); + } + } + + } + + //Add Custom Here + + //Add Custom Tooltips + for (String s : mCustomGregtechMetaTooltips.keySet()) { + if (aNBT.hasKey(s)) { + String aTip = mCustomGregtechMetaTooltips.get(s).getTooltip(aNBT.getString(s)); + aList.add(aTip); + } + } + + //Add GT++ Stuff + + if (tDamage >= 30400 && tDamage < 30500) { + aList.add(EnumChatFormatting.UNDERLINE+"Special GT++ Machine"); + } + if ((tDamage >= 750 && tDamage < 1000) || (tDamage >= 30000 && tDamage < 31000)) { + aList.add(CORE.GT_Tooltip); + } + + + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java new file mode 100644 index 0000000000..44c580fe4f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -0,0 +1,303 @@ +package gtPlusPlus.xmod.gregtech.common; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.common.GT_Proxy; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ProxyFinder; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +public class StaticFields59 { + + + public static boolean mGT6StylePipes; + + public static final Field mGtBlockCasings5; + public static final Field mPreventableComponents; + public static final Field mDisabledItems; + public static final Field mMultiblockChemicalRecipes; + public static final Field mPyrolyseRecipes; + public static final Field mDescriptionArray; + public static final Field mCasingTexturePages; + public static final Field mAssLineVisualMapNEI; + public static final GT_Recipe_Map sAssemblylineVisualRecipes; + + public static final Method mCalculatePollutionReduction; + public static final Method mAddFurnaceRecipe; + + private static final Map<String, Materials> mMaterialCache = new LinkedHashMap<String, Materials>(); + + + //OrePrefixes + + static { + Logger.INFO("[SH] Creating Static Helper for various fields which require reflective access."); + + mGtBlockCasings5 = getField(GregTech_API.class, "sBlockCasings5"); + Logger.INFO("[SH] Got Field: sBlockCasings5"); + mPreventableComponents = getField(OrePrefixes.class, "mPreventableComponents"); + Logger.INFO("[SH] Got Field: mPreventableComponents"); + mDisabledItems = getField(OrePrefixes.class, "mDisabledItems"); + Logger.INFO("[SH] Got Field: mDisabledItems"); + mDescriptionArray = getField(GT_MetaTileEntity_TieredMachineBlock.class, "mDescriptionArray"); + Logger.INFO("[SH] Got Field: mDescriptionArray"); + mCasingTexturePages = getField(BlockIcons.class, "casingTexturePages"); + Logger.INFO("[SH] Got Field: casingTexturePages"); + + mAssLineVisualMapNEI = getField(GT_Recipe_Map.class, "sAssemblylineVisualRecipes"); + Logger.INFO("[SH] Got Field: mAssLineVisualMapNEI"); + GT_Recipe_Map aTemp; + if (mAssLineVisualMapNEI != null) { + try { + aTemp = (GT_Recipe_Map) mAssLineVisualMapNEI.get(null); + Logger.INFO("[SH] Got Field: sAssemblylineVisualRecipes"); + } catch (IllegalArgumentException | IllegalAccessException e) { + aTemp = null; + } + } else { + aTemp = null; + } + + sAssemblylineVisualRecipes = aTemp; + + mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); + Logger.INFO("[SH] Got Field: sMultiblockChemicalRecipes"); + if (ReflectionUtils.doesFieldExist(GT_Recipe.GT_Recipe_Map.class, "sPyrolyseRecipes")) { + mPyrolyseRecipes = getField(GT_Recipe_Map.class, "sPyrolyseRecipes"); + Logger.INFO("[SH] Got Field: sPyrolyseRecipes"); + } + else { + mPyrolyseRecipes = null; + } + + mCalculatePollutionReduction = getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", + int.class); + Logger.INFO("[SH] Got Method: calculatePollutionReduction"); + + // Yep... + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, + ItemStack.class); + Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); + } else { + mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, + ItemStack.class, boolean.class); + Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); + } + + } + + public static synchronized final Block getBlockCasings5() { + try { + return (Block) mGtBlockCasings5.get(GregTech_API.class); + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } + } + + public static int calculatePollutionReducation(GT_MetaTileEntity_Hatch_Muffler h, int i) { + try { + return (int) mCalculatePollutionReduction.invoke(h, i); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return 0; + } + } + + public static Field getField(Class a, String b) { + return ReflectionUtils.getField(a, b); + } + + public static Method getMethod(Class a, String b, Class... params) { + return ReflectionUtils.getMethod(a, b, params); + } + + public static synchronized final Collection<Materials> getOrePrefixesBooleanDisabledItems() { + try { + return (Collection<Materials>) mDisabledItems.get(OrePrefixes.class); + } catch (IllegalArgumentException | IllegalAccessException e) { + return new ArrayList<Materials>(); + } + } + + + public static synchronized final List<OrePrefixes> geOrePrefixesBooleanPreventableComponents() { + try { + return (List<OrePrefixes>) mPreventableComponents.get(OrePrefixes.class); + } catch (IllegalArgumentException | IllegalAccessException e) { + return new ArrayList<OrePrefixes>(); + } + } + + public static synchronized final GT_Recipe_Map getLargeChemicalReactorRecipeMap() { + try { + return (GT_Recipe_Map) mMultiblockChemicalRecipes.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } + } + + public static synchronized final GT_Recipe_Map getPyrolyseRecipeMap() { + try { + return mPyrolyseRecipes != null ? (GT_Recipe_Map) mPyrolyseRecipes.get(null) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } + } + + public static Materials getMaterial(String aMaterialName) { + Materials m = mMaterialCache.get(aMaterialName); + if (m != null) { + return m; + } + else { + m = Materials.get(aMaterialName); + if (m != null) { + mMaterialCache.put(aMaterialName, m); + return m; + } + return null; + } + } + + public static String[] getDescriptionArray(GT_MetaTileEntity_TieredMachineBlock aTile) { + try { + return (String[]) mDescriptionArray.get(aTile); + } catch (IllegalArgumentException | IllegalAccessException e) { + return new String[] {aTile.mDescription}; + } + } + + public static ITexture getCasingTexturePages(int a, int b) { + try { + ITexture[][] g = (ITexture[][]) mCasingTexturePages.get(null); + if (g != null) { + return g[a][b]; + } + } + catch (Throwable t) { + + } + return null; + } + + + public static Object getFieldFromGregtechProxy(String fieldName) { + return getFieldFromGregtechProxy(Utils.isServer() ? false : true, fieldName); + } + + public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { + Object proxyGT; + + if (Meta_GT_Proxy.mProxies[0] != null && client) { + proxyGT = Meta_GT_Proxy.mProxies[0]; + } else if (Meta_GT_Proxy.mProxies[1] != null && !client) { + proxyGT = Meta_GT_Proxy.mProxies[1]; + } else { + try { + proxyGT = (client ? ProxyFinder.getClientProxy(GT_Mod.instance) + : ProxyFinder.getServerProxy(GT_Mod.instance)); + } catch (final ReflectiveOperationException e1) { + proxyGT = null; + Logger.INFO("Failed to obtain instance of GT " + (client ? "Client" : "Server") + " proxy."); + } + if (Meta_GT_Proxy.mProxies[0] == null && client) { + Meta_GT_Proxy.mProxies[0] = (GT_Proxy) proxyGT; + } else if (Meta_GT_Proxy.mProxies[1] == null && !client) { + Meta_GT_Proxy.mProxies[1] = (GT_Proxy) proxyGT; + } + } + + if (proxyGT != null && proxyGT instanceof GT_Proxy) { + try { + return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + return null; + } + + + + public static int getTierForCoil(Block aBlock, int aMeta) { + if (aBlock == GregTech_API.sBlockCasings1 && (aMeta >= 12 && aMeta <= 14)) { + return aMeta == 12 ? 1 : aMeta == 13 ? 2 : 3; + } + else if (aBlock == getBlockCasings5() && (aMeta >= 0 && aMeta <= 10)) { + return aMeta; + } + return 0; + } + + public static int getHeatingCapacityForCoil(Block aBlock, int aMeta) { + int aTier = getTierForCoil(aBlock, aMeta); + return aTier > 0 ? getHeatingCapacityForCoilTier(aTier) : 0; + } + + public static int getHeatingCapacityForCoilTier(int aCoilTier) { + int mHeatingCapacity = 0; + switch (aCoilTier) { + case 0: + mHeatingCapacity = 1800; + break; + case 1: + mHeatingCapacity = 2700; + break; + case 2: + mHeatingCapacity = 3600; + break; + case 3: + mHeatingCapacity = 4500; + break; + case 4: + mHeatingCapacity = 5400; + break; + case 5: + mHeatingCapacity = 7200; + break; + case 6: + mHeatingCapacity = 9000; + break; + case 7: + mHeatingCapacity = 9900; + break; + case 8: + mHeatingCapacity = 10800; + break; + case 9: + mHeatingCapacity = 6300; + break; + case 10: + mHeatingCapacity = 9000; + break; + default: + Logger.INFO("Heating Coils are bad."); + mHeatingCapacity = 0; + } + if (CORE.GTNH && aCoilTier <= 10) { + mHeatingCapacity += 1; + } + return mHeatingCapacity; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java new file mode 100644 index 0000000000..01f655c355 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java @@ -0,0 +1,534 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import java.util.ArrayList; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.IDebugableBlock; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_Generic_Block; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.BaseTileEntity; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Utility; +import gregtech.common.blocks.GT_Item_Machines; +import gregtech.common.blocks.GT_Material_Machines; +import gregtech.common.render.GT_Renderer_Block; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class GTPP_Block_Machines extends GT_Generic_Block implements IDebugableBlock, ITileEntityProvider { + public static ThreadLocal<IGregTechTileEntity> mTemporaryTileEntity = new ThreadLocal<IGregTechTileEntity>(); + + public GTPP_Block_Machines() { + super(GTPP_Item_Machines.class, "gtpp.blockmachines", new GT_Material_Machines()); + GregTech_API.registerMachineBlock(this, -1); + this.setHardness(1.0F); + this.setResistance(10.0F); + this.setStepSound(soundTypeMetal); + this.setCreativeTab(GregTech_API.TAB_GREGTECH); + this.isBlockContainer = true; + } + + public String getHarvestTool(int aMeta) { + switch (aMeta / 4) { + case 0 : + return "wrench"; + case 1 : + return "wrench"; + case 2 : + return "cutter"; + case 3 : + return "axe"; + default : + return "wrench"; + } + } + + public int getHarvestLevel(int aMeta) { + return aMeta % 4; + } + + protected boolean canSilkHarvest() { + return false; + } + + public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseTileEntity) { + ((BaseTileEntity) tTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ); + } + + } + + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + super.onBlockAdded(aWorld, aX, aY, aZ); + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + + } + + public String getUnlocalizedName() { + int tDamage = 0; + String aUnlocalName = (tDamage >= 0 && tDamage < GregTech_API.METATILEENTITIES.length) + ? (GregTech_API.METATILEENTITIES[tDamage] != null + ? ("gtpp.blockmachines.name" + "." + GregTech_API.METATILEENTITIES[tDamage].getMetaName()) + : ("gtpp.blockmachines.name")) : ""; + + Logger.INFO("Unlocal Name: "+aUnlocalName); + return aUnlocalName; + } + + public String getLocalizedName() { + String aName = StatCollector.translateToLocal(this.getUnlocalizedName() + ".name");; + if (aName.toLowerCase().contains(".name")) { + aName = StatCollector.translateToLocal(getUnlocalizedName() + ".name"); + } + if (aName.toLowerCase().contains(".name")) { + aName = StatCollector.translateToLocal("gt.blockmachines" + ".name"); + } + if (aName.toLowerCase().contains(".name")) { + aName = "BAD"; + } + Logger.INFO("Name: "+aName); + return aName; + } + + public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return 0; + } + + public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return GregTech_API.sMachineFlammable && aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 100 : 0; + } + + public int getRenderType() { + return GTPP_Render_MachineBlock.INSTANCE == null ? super.getRenderType() : GTPP_Render_MachineBlock.INSTANCE.mRenderID; + } + + public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { + return GregTech_API.sMachineFlammable && aWorld.getBlockMetadata(aX, aY, aZ) == 0; + } + + public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return GregTech_API.sMachineFlammable && aWorld.getBlockMetadata(aX, aY, aZ) == 0; + } + + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + public boolean canConnectRedstone(IBlockAccess var1, int var2, int var3, int var4, int var5) { + return true; + } + + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + public boolean hasTileEntity(int aMeta) { + return true; + } + + public boolean hasComparatorInputOverride() { + return true; + } + + public boolean renderAsNormalBlock() { + return false; + } + + public boolean canProvidePower() { + return true; + } + + public boolean isOpaqueCube() { + return false; + } + + public TileEntity createNewTileEntity(World aWorld, int aMeta) { + return this.createTileEntity(aWorld, aMeta); + } + + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + return BlockIcons.MACHINE_LV_SIDE.getIcon(); + } + + public IIcon getIcon(int aSide, int aMeta) { + return BlockIcons.MACHINE_LV_SIDE.getIcon(); + } + + public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { + super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity != null ? tTileEntity.receiveClientEvent(aData1, aData2) : false; + } + + public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, + Entity collider) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { + ((IGregTechTileEntity) tTileEntity).addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, + collider); + } else { + super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + } + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null + ? ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) + : super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null + ? ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) + : super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { + TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { + AxisAlignedBB bbb = ((IGregTechTileEntity) tTileEntity) + .getCollisionBoundingBoxFromPool(((IGregTechTileEntity) tTileEntity).getWorld(), 0, 0, 0); + this.minX = bbb.minX; + this.minY = bbb.minY; + this.minZ = bbb.minZ; + this.maxX = bbb.maxX; + this.maxY = bbb.maxY; + this.maxZ = bbb.maxZ; + } else { + super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); + } + } + + public void setBlockBoundsForItemRender() { + super.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { + ((IGregTechTileEntity) tTileEntity).onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); + } else { + super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister aIconRegister) { + + } + + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return super.getBlockHardness(aWorld, aX, aY, aZ); + } + + public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof BaseMetaTileEntity && ((BaseMetaTileEntity) tTileEntity).privateAccess() + && !((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true) + ? -1.0F + : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); + } + + public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float par1, + float par2, float par3) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity == null) { + return false; + } else { + if (aPlayer.isSneaking()) { + ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem == null) { + return false; + } + + if (!GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) + && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { + return false; + } + } + + return tTileEntity instanceof IGregTechTileEntity + ? (((IGregTechTileEntity) tTileEntity).getTimer() < 50L + ? false + : (!aWorld.isRemote && !((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer) + ? true + : ((IGregTechTileEntity) tTileEntity).onRightclick(aPlayer, (byte) aSide, par1, + par2, par3))) + : false; + } + } + + public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer); + } + + } + + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity ? ((IGregTechTileEntity) tTileEntity).getMetaTileID() : 0; + } + + public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseMetaTileEntity) { + ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + } + + super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); + } + + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; + XSTR tRandom = new XSTR(); + mTemporaryTileEntity.set(tGregTechTileEntity); + + for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); ++i) { + ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); + if (tItem != null && tItem.stackSize > 0 && tGregTechTileEntity.isValidSlot(i)) { + EntityItem tItemEntity = new EntityItem(aWorld, + (double) ((float) aX + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) aY + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) aZ + tRandom.nextFloat() * 0.8F + 0.1F), + new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); + if (tItem.hasTagCompound()) { + tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); + } + + tItemEntity.motionX = tRandom.nextGaussian() * 0.0500000007450581D; + tItemEntity.motionY = tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D; + tItemEntity.motionZ = tRandom.nextGaussian() * 0.0500000007450581D; + aWorld.spawnEntityInWorld(tItemEntity); + tItem.stackSize = 0; + tGregTechTileEntity.setInventorySlotContents(i, (ItemStack) null); + } + } + } + + super.breakBlock(aWorld, aX, aY, aZ, par5, par6); + aWorld.removeTileEntity(aX, aY, aZ); + } + + public ArrayList<ItemStack> getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getDrops() + : (mTemporaryTileEntity.get() == null + ? new ArrayList() + : ((IGregTechTileEntity) mTemporaryTileEntity.get()).getDrops()); + } + + public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide) + : 0; + } + + public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + if (aSide >= 0 && aSide <= 5) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)) + : 0; + } else { + return 0; + } + } + + public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + if (aSide >= 0 && aSide <= 5) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity) + .getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)) + : 0; + } else { + return 0; + } + } + + public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int par5, float chance, int par7) { + if (!aWorld.isRemote) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null && chance < 1.0F) { + if (tTileEntity instanceof BaseMetaTileEntity && GregTech_API.sMachineNonWrenchExplosions) { + ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + } + } else { + super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, par5, chance, par7); + } + } + + } + + public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) { + if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { + return true; + } else { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null) { + if (tTileEntity instanceof BaseMetaTileEntity) { + return true; + } + + if (tTileEntity instanceof BaseMetaPipeEntity + && (((BaseMetaPipeEntity) tTileEntity).mConnections & -64) != 0) { + return true; + } + + if (tTileEntity instanceof ICoverable + && ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide.ordinal()) != 0) { + return true; + } + } + + return false; + } + } + + public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity == null + ? 0 + : (tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getLightOpacity() + : (aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 255 : 0)); + } + + public int getLightValue(IBlockAccess aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof BaseMetaTileEntity ? ((BaseMetaTileEntity) tTileEntity).getLightValue() : 0; + } + + public TileEntity createTileEntity(World aWorld, int aMeta) { + return (TileEntity) (aMeta >= 4 ? Meta_GT_Proxy.constructBaseMetaTileEntity() : Meta_GT_Proxy.constructBaseMetaTileEntityCustomPower()); + } + + public float getExplosionResistance(Entity par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, + double explosionY, double explosionZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6) + : 10.0F; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < 100; ++i) { + if (GregTech_API.METATILEENTITIES[(30400 + i)] != null) { + par3List.add(new ItemStack(par1, 1, i)); + } + } + + } + + public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBase aPlayer, ItemStack aStack) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null) { + if (tTileEntity instanceof IGregTechTileEntity) { + IGregTechTileEntity var6 = (IGregTechTileEntity) tTileEntity; + if (aPlayer == null) { + var6.setFrontFacing((byte) 1); + } else { + int var7 = MathHelper.floor_double((double) (aPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int var8 = Math.round(aPlayer.rotationPitch); + if (var8 >= 65 && var6.isValidFacing((byte) 1)) { + var6.setFrontFacing((byte) 1); + } else if (var8 <= -65 && var6.isValidFacing((byte) 0)) { + var6.setFrontFacing((byte) 0); + } else { + switch (var7) { + case 0 : + var6.setFrontFacing((byte) 2); + break; + case 1 : + var6.setFrontFacing((byte) 5); + break; + case 2 : + var6.setFrontFacing((byte) 3); + break; + case 3 : + var6.setFrontFacing((byte) 4); + } + } + } + } + + } + } + + public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { + TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof BaseMetaTileEntity + ? ((BaseMetaTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel) + : (tTileEntity instanceof BaseMetaPipeEntity + ? ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel) + : null); + } + + public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection aSide, int aColor) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) (~aColor & 15)) { + return false; + } else { + ((IGregTechTileEntity) tTileEntity).setColorization((byte) (~aColor & 15)); + return true; + } + } else { + return false; + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Item_Machines.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Item_Machines.java new file mode 100644 index 0000000000..ba3b05ff8e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Item_Machines.java @@ -0,0 +1,229 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_ItsNotMyFaultException; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; + +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class GTPP_Item_Machines extends ItemBlock { + public GTPP_Item_Machines(Block par1) { + super(par1); + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.setCreativeTab(GregTech_API.TAB_GREGTECH); + } + + @SuppressWarnings("unchecked") + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4) { + try { + int e = this.getDamage(aStack) + 30400; //Add Offset + if (e <= 0 || e >= GregTech_API.METATILEENTITIES.length) { + return; + } + + if (GregTech_API.METATILEENTITIES[e] != null) { + + IGregTechTileEntity aNBT = GregTech_API.METATILEENTITIES[e].getBaseMetaTileEntity(); + + final long tVoltage = aNBT.getInputVoltage(); + byte tTier = (byte) ((byte) Math.max(1, GT_Utility.getTier(tVoltage))); + + /*if (aNBT.getDescription() != null) { + int tAmount = 0; + String[] arg7 = aNBT.getDescription(); + int arg8 = arg7.length-1; + + if (arg7 != null && arg7.length > 0) { + for (String t : arg7) { + aList.add(t); + } + + } + else { + aList.add("ERROR"); + } + + for (int y = 0; y < arg8; y++) { + String tDescription = arg7[y]; + + if (tDescription != null) { + aList.add(tDescription+"|"+arg8); + continue; + } + else { + continue; + } + } + }*/ + + if (aNBT.getEUCapacity() > 0L) { + + //Custom handling + if ((e - 30400) <= 100) { + + + if ((e - 30400) <= 10) { + tTier -= 2; + aList.add(EnumChatFormatting.BOLD+"16"+" Fuse Slots"+EnumChatFormatting.GRAY); + aList.add("Per each fuse, you may insert "+EnumChatFormatting.YELLOW+(GT_Values.V[tTier])+EnumChatFormatting.GRAY+" EU/t"); + aList.add("However this "+EnumChatFormatting.ITALIC+EnumChatFormatting.RED+"MUST"+EnumChatFormatting.GRAY+" be in a single Amp"); + aList.add("This machine can accept upto a single amp of "+GT_Values.VN[Math.min(tTier+2, 12)]+" as a result"); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Breaker_Loss", "Breaker Loss: "+EnumChatFormatting.RED+""+(GT_Values.V[Math.max(tTier-1, 0)]/10)+EnumChatFormatting.GRAY+" EU/t", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + } + + + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Special_Power_1", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_2", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + //aList.add(GT_LanguageManager.addStringLocalization("TileEntity_BreakerBox_3", EnumChatFormatting.RED+"Special Power Handling, please read manual", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + } + + + if (aNBT.getInputVoltage() > 0L) { + String inA = "0"; + if (aNBT.getInputAmperage() >= 1L) { + inA = " at " + EnumChatFormatting.YELLOW + aNBT.getInputAmperage() + EnumChatFormatting.GRAY +" Amps"; + } + else { + inA = " at " + EnumChatFormatting.WHITE + aNBT.getInputAmperage() + EnumChatFormatting.GRAY +" Amps"; + } + String a1 = "Voltage IN: "+EnumChatFormatting.GREEN + aNBT.getInputVoltage() + + " (" + GT_Values.VN[GT_Utility.getTier(aNBT.getInputVoltage())] + ")" + + EnumChatFormatting.GRAY + inA; + aList.add(a1); + } + + if (aNBT.getOutputVoltage() > 0L) { + String outA = "0"; + if (aNBT.getOutputAmperage() >= 1L) { + outA = " at " + EnumChatFormatting.YELLOW + aNBT.getOutputAmperage() + EnumChatFormatting.GRAY +" Amps"; + } + else { + outA = " at " + EnumChatFormatting.WHITE + aNBT.getOutputAmperage() + EnumChatFormatting.GRAY +" Amps"; + } + String a1 = "Voltage OUT: "+EnumChatFormatting.GREEN + aNBT.getOutputVoltage() + + " (" + GT_Values.VN[GT_Utility.getTier(aNBT.getOutputVoltage())] + ")" + + EnumChatFormatting.GRAY + outA; + aList.add(a1); + } + + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_Lossess_EU", "Transmission Loss: "+EnumChatFormatting.DARK_BLUE+"0", !GregTech_API.sPostloadFinished) + EnumChatFormatting.GRAY); + + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE2", "Internal Capacity: ", + !GregTech_API.sPostloadFinished) + EnumChatFormatting.BLUE + aNBT.getEUCapacity() + + EnumChatFormatting.GRAY + " EU"); + } + } + + NBTTagCompound arg16 = aStack.getTagCompound(); + if (arg16 != null) { + if (arg16.getBoolean("mMuffler")) { + aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", + !GregTech_API.sPostloadFinished)); + } + + if (arg16.getBoolean("mSteamConverter")) { + aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", + "has Steam Upgrade", !GregTech_API.sPostloadFinished)); + } + + boolean arg17 = false; + byte arg18; + if ((arg18 = arg16.getByte("mSteamTanks")) > 0) { + aList.add(arg18 + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", + "Steam Tank Upgrades", !GregTech_API.sPostloadFinished)); + } + } + + + aList.add(EnumChatFormatting.UNDERLINE+"Special GT++ Machine"); + + } catch (Throwable arg15) { + arg15.printStackTrace(GT_Log.err); + } + + } + + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, + float hitX, float hitY, float hitZ) { + return false; + } + + public String getUnlocalizedName(ItemStack aStack) { + short tDamage = (short) (this.getDamage(aStack) + 30400); //Add Offset; + return tDamage >= 0 && tDamage < GregTech_API.METATILEENTITIES.length + ? (GregTech_API.METATILEENTITIES[tDamage] != null + ? "gtpp.blockmachines" + "." + GregTech_API.METATILEENTITIES[tDamage].getMetaName() + : "") + : ""; + } + + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + super.onCreated(aStack, aWorld, aPlayer); + short tDamage = (short) ((short) this.getDamage(aStack) + 30400); //Add Offset; + if (tDamage < 0 + || tDamage >= GregTech_API.METATILEENTITIES.length && GregTech_API.METATILEENTITIES[tDamage] != null) { + GregTech_API.METATILEENTITIES[tDamage].onCreated(aStack, aWorld, aPlayer); + } + + } + + public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, + float hitX, float hitY, float hitZ, int aMeta) { + short tDamage = (short) ((short) this.getDamage(aStack) + 30400); //Add Offset; + if (tDamage > 0) { + if (GregTech_API.METATILEENTITIES[tDamage] == null) { + return false; + } + + byte tMetaData = 32; + //byte tMetaData = GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType(); + Logger.INFO("Using Meta: "+tMetaData+" for ID "+tDamage+" | "+GregTech_API.METATILEENTITIES[tDamage].getInventoryName()); + if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tMetaData, 3)) { + return false; + } + + if (aWorld.getBlock(aX, aY, aZ) != this.field_150939_a) { + throw new GT_ItsNotMyFaultException( + "Failed to place Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don\'t report this Bug to me, I don\'t know how to fix it."); + } + + if (aWorld.getBlockMetadata(aX, aY, aZ) != tMetaData) { + throw new GT_ItsNotMyFaultException( + "Failed to set the MetaValue of the Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don\'t report this Bug to me, I don\'t know how to fix it."); + } + + IGregTechTileEntity tTileEntity = (IGregTechTileEntity) aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null) { + tTileEntity.setInitialValuesAsNBT(tTileEntity.isServerSide() ? aStack.getTagCompound() : null, tDamage); + if (aPlayer != null) { + tTileEntity.setOwnerName(aPlayer.getDisplayName()); + } + + tTileEntity.getMetaTileEntity().initDefaultModes(aStack.getTagCompound()); + } + } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) { + return false; + } + + if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { + this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); + this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage); + } + + return true; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java new file mode 100644 index 0000000000..c4b2e4f738 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks.java @@ -0,0 +1,78 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import gregtech.api.enums.TAE; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Material_Casings; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler; + +public class GregtechMetaCasingBlocks +extends GregtechMetaCasingBlocksAbstract { + + CasingTextureHandler TextureHandler = new CasingTextureHandler(); + + public GregtechMetaCasingBlocks() { + super(GregtechMetaCasingItems.class, "miscutils.blockcasings", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + if (i == 2 || i == 3 || i == 4) { + continue; + } + TAE.registerTexture(0, i, new GT_CopiedBlockTexture(this, 6, i)); + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Centrifuge Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Structural Coke Oven Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Heat Resistant Coke Oven Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Heat Proof Coke Oven Casing"); //60 + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Material Press Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Electrolyzer Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Wire Factory Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Maceration Stack Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Matter Generation Coil"); //65 + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Matter Fabricator Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Iron Plated Bricks"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Multitank Exterior Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Hastelloy-N Reactor Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Zeron-100 Reactor Shielding"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Blast Smelter Heat Containment Coil "); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Blast Smelter Casing Block"); + GregtechItemList.Casing_Centrifuge1.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_CokeOven.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_CokeOven_Coil1.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_CokeOven_Coil2.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_MaterialPress.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_Electrolyzer.set(new ItemStack(this, 1, 5)); + GregtechItemList.Casing_WireFactory.set(new ItemStack(this, 1, 6)); + GregtechItemList.Casing_MacerationStack.set(new ItemStack(this, 1, 7)); + GregtechItemList.Casing_MatterGen.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_MatterFab.set(new ItemStack(this, 1, 9)); + GregtechItemList.Casing_IronPlatedBricks.set(new ItemStack(this, 1, 10)); + GregtechItemList.Casing_MultitankExterior.set(new ItemStack(this, 1, 11)); + GregtechItemList.Casing_Reactor_I.set(new ItemStack(this, 1, 12)); + GregtechItemList.Casing_Reactor_II.set(new ItemStack(this, 1, 13)); + GregtechItemList.Casing_Coil_BlastSmelter.set(new ItemStack(this, 1, 14)); + GregtechItemList.Casing_BlastSmelter.set(new ItemStack(this, 1, 15)); + } + + @Override + public IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] + return CasingTextureHandler.getIcon(aSide, aMeta); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { + final GregtechMetaCasingBlocks i = this; + return CasingTextureHandler.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, i); + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java new file mode 100644 index 0000000000..596643e06c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -0,0 +1,89 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import gregtech.api.enums.TAE; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Material_Casings; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler2; + +import java.util.List; + +public class GregtechMetaCasingBlocks2 +extends GregtechMetaCasingBlocksAbstract { + + CasingTextureHandler2 TextureHandler = new CasingTextureHandler2(); + + public static class GregtechMetaCasingItemBlocks2 extends GregtechMetaCasingItems { + + public GregtechMetaCasingItemBlocks2(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int meta = aStack.getItemDamage(); + int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); + if (meta == 7 && tier > 0) { + long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); + aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + + public GregtechMetaCasingBlocks2() { + super(GregtechMetaCasingItemBlocks2.class, "gtplusplus.blockcasings.2", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + if (i == 4 || i == 10 || i == 11 || i == 12 || i == 14) { + continue; + } + TAE.registerTexture(1, i, new GT_CopiedBlockTexture(this, 6, i)); + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Thermal Processing Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Hastelloy-N Sealant Block"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Hastelloy-X Structural Block"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Incoloy-DS Fluid Containment Block"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Wash Plant Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Industrial Sieve Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Large Sieve Grate"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (EV)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Sub-Station External Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Cyclotron Coil"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Cyclotron Outer Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Thermal Containment Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Autocrafter Frame"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cutting Factory Frame"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Sterile Farm Casing"); //Tree Farmer Textures + GregtechItemList.Casing_ThermalCentrifuge.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Refinery_External.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Refinery_Structural.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_Refinery_Internal.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_WashPlant.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_Sifter.set(new ItemStack(this, 1, 5)); + GregtechItemList.Casing_SifterGrate.set(new ItemStack(this, 1, 6)); + GregtechItemList.Casing_Vanadium_Redox.set(new ItemStack(this, 1, 7)); + GregtechItemList.Casing_Power_SubStation.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_Cyclotron_Coil.set(new ItemStack(this, 1, 9)); + GregtechItemList.Casing_Cyclotron_External.set(new ItemStack(this, 1, 10)); + GregtechItemList.Casing_ThermalContainment.set(new ItemStack(this, 1, 11)); + GregtechItemList.Casing_Autocrafter.set(new ItemStack(this, 1, 12)); + GregtechItemList.Casing_CuttingFactoryFrame.set(new ItemStack(this, 1, 13)); + //GregtechItemList.Casing_TeslaTower.set(new ItemStack(this, 1, 14)); + GregtechItemList.Casing_PLACEHOLDER_TreeFarmer.set(new ItemStack(this, 1, 15)); //Tree Farmer Textures + } + + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return CasingTextureHandler2.getIcon(aSide, aMeta); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java new file mode 100644 index 0000000000..8cd6dd0ca8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java @@ -0,0 +1,366 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.TAE; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; +import gregtech.common.blocks.GT_Material_Casings; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler3; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +public class GregtechMetaCasingBlocks3 +extends GregtechMetaCasingBlocksAbstract { + + public static boolean mConnectedMachineTextures = false; + CasingTextureHandler3 TextureHandler = new CasingTextureHandler3(); + + public static class GregtechMetaCasingItemBlocks3 extends GregtechMetaCasingItems { + + public GregtechMetaCasingItemBlocks3(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int meta = aStack.getItemDamage(); + int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); + if (tier > 0) { + long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); + aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + + public GregtechMetaCasingBlocks3() { + super(GregtechMetaCasingItemBlocks3.class, "gtplusplus.blockcasings.3", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + TAE.registerTexture(2, i, new GT_CopiedBlockTexture(this, 6, i)); + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Aquatic Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel Reinforced Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Multi-Use Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Trinium Plated Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Vanadium Redox Power Cell (IV)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Vanadium Redox Power Cell (LuV)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Vanadium Redox Power Cell (ZPM)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (UV)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Vanadium Redox Power Cell (MAX)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Supply Depot Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Advanced Cryogenic Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Volcanus Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Fusion Machine Casing MK III"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Advanced Fusion Coil"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Unnamed"); // Can Use, don't change texture (Used for Fusion MK4) + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Containment Casing"); + GregtechItemList.Casing_FishPond.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Extruder.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Multi_Use.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_BedrockMiner.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_Vanadium_Redox_IV.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_Vanadium_Redox_LuV.set(new ItemStack(this, 1, 5)); + GregtechItemList.Casing_Vanadium_Redox_ZPM.set(new ItemStack(this, 1, 6)); + GregtechItemList.Casing_Vanadium_Redox_UV.set(new ItemStack(this, 1, 7)); + GregtechItemList.Casing_Vanadium_Redox_MAX.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_AmazonWarehouse.set(new ItemStack(this, 1, 9)); + GregtechItemList.Casing_AdvancedVacuum.set(new ItemStack(this, 1, 10)); + GregtechItemList.Casing_Adv_BlastFurnace.set(new ItemStack(this, 1, 11)); + GregtechItemList.Casing_Fusion_External.set(new ItemStack(this, 1, 12)); + GregtechItemList.Casing_Fusion_Internal.set(new ItemStack(this, 1, 13)); + GregtechItemList.Casing_Containment.set(new ItemStack(this, 1, 15)); + } + + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return CasingTextureHandler3.getIcon(aSide, aMeta); + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, + final int aSide) { + final Block thisBlock = aWorld.getBlock(xCoord, yCoord, zCoord); + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if ((tMeta != 12)|| !GregtechMetaCasingBlocks3.mConnectedMachineTextures) { + return getIcon(aSide, tMeta); + } + final int tStartIndex = 0; + if (tMeta == 12) { + final boolean[] tConnectedSides = { + aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock + && aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta, + aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock + && aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta, + aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock + && aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta, + aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock + && aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta, + aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock + && aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta, + aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock + && aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta}; + switch (aSide) { + case 0 : { + if (tConnectedSides[0]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[2]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + if (!tConnectedSides[5] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + } + case 1 : { + if (tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[5] && tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (tConnectedSides[4] && tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (!tConnectedSides[4] && tConnectedSides[5] && tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (!tConnectedSides[4] && !tConnectedSides[5] && !tConnectedSides[2] && !tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[4]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + if (!tConnectedSides[3] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + } + case 2 : { + if (tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[4]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + } + case 3 : { + if (tConnectedSides[3]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[0] && tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (tConnectedSides[2] && tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (!tConnectedSides[2] && tConnectedSides[0] && tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[0] && !tConnectedSides[4] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[2] && !tConnectedSides[4]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + } + case 4 : { + if (tConnectedSides[4]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + if (!tConnectedSides[3] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + } + case 5 : { + if (tConnectedSides[2]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 6].getIcon(); + } + if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 5].getIcon(); + } + if (tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 2].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 3].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 4].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[3] && tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 11].getIcon(); + } + if (tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 8].getIcon(); + } + if (tConnectedSides[0] && tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 9].getIcon(); + } + if (!tConnectedSides[0] && tConnectedSides[3] && tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 10].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[3] && !tConnectedSides[1] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + if (!tConnectedSides[0] && !tConnectedSides[1]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 0].getIcon(); + } + if (!tConnectedSides[3] && !tConnectedSides[5]) { + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 1].getIcon(); + } + break; + } + } + return TexturesGtBlock.CONNECTED_FUSION_HULLS[tStartIndex + 7].getIcon(); + } + return CasingTextureHandler3.getIcon(aSide, tMeta); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java new file mode 100644 index 0000000000..419b5f3d30 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java @@ -0,0 +1,115 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Material_Casings; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + + +public class GregtechMetaCasingBlocks4 +extends GregtechMetaCasingBlocksAbstract { + + public GregtechMetaCasingBlocks4() { + super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.4", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + if (i == 2 || i == 4 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9 || i == 12 || i == 13 || i == 14 || i == 15) { + continue; + } + TAE.registerTexture(3, i, new GT_CopiedBlockTexture(this, 6, i)); + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Naquadah Reactor Base"); //48 + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Reactor Piping"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Naquadah Containment Chamber"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Tempered Arc Furnace Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Vacuum Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Turbodyne Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused + GregtechItemList.Casing_Naq_Reactor_A.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Naq_Reactor_B.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Naq_Reactor_C.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_Industrial_Arc_Furnace.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_Vacuum_Furnace.set(new ItemStack(this, 1, 10)); + GregtechItemList.Casing_RocketEngine.set(new ItemStack(this, 1, 11)); + } + + //private static final LargeTurbineTextureHandler mTurbineTextures = new LargeTurbineTextureHandler(); + + /*@Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { + final GregtechMetaCasingBlocks4 i = this; + return mTurbineTextures.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, i); + }*/ + + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return getStaticIcon((byte) aSide, (byte) aMeta); + } + + public static IIcon getStaticIcon(final byte aSide, final byte aMeta) { + //Texture ID's. case 0 == ID[57] + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0: + return TexturesGtBlock.Casing_Trinium_Titanium.getIcon(); + case 1: + return TexturesGtBlock.TEXTURE_TECH_C.getIcon(); + case 2: + return TexturesGtBlock.TEXTURE_ORGANIC_PANEL_A_GLOWING.getIcon(); + case 3: + return TexturesGtBlock.TEXTURE_METAL_PANEL_A.getIcon(); + case 4: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 5: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 6: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 7: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 8: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 9: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 10: + if (aSide <2) { + return TexturesGtBlock.TEXTURE_STONE_RED_B.getIcon(); + } + else { + return TexturesGtBlock.TEXTURE_STONE_RED_A.getIcon(); + } + case 11: + return TexturesGtBlock.TEXTURE_CASING_ROCKETDYNE.getIcon(); + case 12: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 13: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 14: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 15: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + default: + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + + } + } + return TexturesGtBlock._PlaceHolder.getIcon(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java new file mode 100644 index 0000000000..61c71ba552 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks5.java @@ -0,0 +1,83 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Material_Casings; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGrinderMultiblock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + + +public class GregtechMetaCasingBlocks5 +extends GregtechMetaCasingBlocksAbstract { + + //Free Indexes within TAE: 90, 91, 92, 94, 114, 116, 117, 118, 119, 120, 121, 124, 125, 126, 127 + private static final TexturesGrinderMultiblock mGrinderOverlayHandler = new TexturesGrinderMultiblock(); + + public GregtechMetaCasingBlocks5() { + super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.5", GT_Material_Casings.INSTANCE); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "IsaMill Exterior Casing"); // IsaMill Casing + TAE.registerTexture(0, 2, new GT_CopiedBlockTexture(this, 6, 0)); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "IsaMill Piping"); // IsaMill Pipe + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "IsaMill Gearbox"); // IsaMill Gearbox + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Elemental Confinement Shell"); // Duplicator Casing + TAE.registerTexture(0, 3, new GT_CopiedBlockTexture(this, 6, 3)); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Sparge Tower Exterior Casing"); // Sparge Tower Casing + TAE.registerTexture(0, 4, new GT_CopiedBlockTexture(this, 6, 4)); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused + + GregtechItemList.Casing_IsaMill_Casing.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_IsaMill_Pipe.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_IsaMill_Gearbox.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_ElementalDuplicator.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_Sparge_Tower_Exterior.set(new ItemStack(this, 1, 4)); + } + + @Override + public IIcon getIcon(final int aSide, final int aMeta) { + return getStaticIcon(aSide, aMeta); + } + + + public static IIcon getStaticIcon(final int aSide, final int aMeta) { + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0: + return TexturesGtBlock.TEXTURE_PIPE_GRINDING_MILL.getIcon(); + case 1: + return TexturesGtBlock.TEXTURE_CASING_GRINDING_MILL.getIcon(); + case 2: + return TexturesGtBlock.TEXTURE_GEARBOX_GRINDING_MILL.getIcon(); + case 3: + return TexturesGtBlock.TEXTURE_TECH_PANEL_D.getIcon(); + case 4: + return TexturesGtBlock.Casing_Machine_Metal_Sheet_H.getIcon(); + } + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide) { + final GregtechMetaCasingBlocks5 i = this; + return mGrinderOverlayHandler.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, i); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java new file mode 100644 index 0000000000..ea59eb50ba --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocksAbstract.java @@ -0,0 +1,150 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Block_Casings_Abstract; + +import gtPlusPlus.core.creative.AddToCreativeTab; + +public abstract class GregtechMetaCasingBlocksAbstract +extends GT_Block_Casings_Abstract { + public GregtechMetaCasingBlocksAbstract(final Class<? extends ItemBlock> aItemClass, final String aName, final Material aMaterial) { + super(aItemClass, aName, aMaterial); + this.setStepSound(soundTypeMetal); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GregTech_API.registerMachineBlock(this, -1); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this"); + } + + @Override + public String getHarvestTool(final int aMeta) { + return "wrench"; + } + + @Override + public int getHarvestLevel(final int aMeta) { + return 2; + } + + @Override + public float getBlockHardness(final World aWorld, final int aX, final int aY, final int aZ) { + return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); + } + + @Override + public float getExplosionResistance(final Entity aTNT) { + return Blocks.iron_block.getExplosionResistance(aTNT); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public void onBlockAdded(final World aWorld, final int aX, final int aY, final int aZ) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public String getUnlocalizedName() { + return this.mUnlocalizedName; + } + + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); + } + + @Override + public boolean canBeReplacedByLeaves(final IBlockAccess aWorld, final int aX, final int aY, final int aZ) { + return false; + } + + @Override + public boolean isNormalCube(final IBlockAccess aWorld, final int aX, final int aY, final int aZ) { + return true; + } + + @Override + public boolean renderAsNormalBlock() { + return true; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public void breakBlock(final World aWorld, final int aX, final int aY, final int aZ, final Block aBlock, final int aMetaData) { + if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int damageDropped(final int par1) { + return par1; + } + + @Override + public int getDamageValue(final World par1World, final int par2, final int par3, final int par4) { + return par1World.getBlockMetadata(par2, par3, par4); + } + + @Override + public int quantityDropped(final Random par1Random) { + return 1; + } + + @Override + public Item getItemDropped(final int par1, final Random par2Random, final int par3) { + return Item.getItemFromBlock(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister aIconRegister) { + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(final Item aItem, final CreativeTabs par2CreativeTabs, final List aList) { + for (int i = 0; i < 16; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingItems.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingItems.java new file mode 100644 index 0000000000..de51cb164b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingItems.java @@ -0,0 +1,10 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import net.minecraft.block.Block; + +public class GregtechMetaCasingItems +extends GregtechMetaItemCasingsAbstract { + public GregtechMetaCasingItems(final Block par1) { + super(par1); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasings1.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasings1.java new file mode 100644 index 0000000000..7fb344a4ec --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasings1.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class GregtechMetaItemCasings1 +extends GregtechMetaItemCasingsAbstract { + public GregtechMetaItemCasings1(final Block par1) { + super(par1); + } + + @Override + public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + switch (this.getDamage(aStack)) { + case 0: + aList.add(this.mCasing_Centrifuge); + break; + case 1: + aList.add(this.mCasing_CokeOven); + break; + case 2: + aList.add(this.mCasing_CokeCoil1); + break; + case 3: + aList.add(this.mCasing_CokeCoil2); + break; + default: + aList.add(this.mCasing_CokeCoil2); + break; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java new file mode 100644 index 0000000000..62e0f0acdf --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaItemCasingsAbstract.java @@ -0,0 +1,61 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +import gregtech.api.util.GT_LanguageManager; + +public abstract class GregtechMetaItemCasingsAbstract +extends ItemBlock { + + protected final String mCasing_Centrifuge = GT_LanguageManager.addStringLocalization("mu.centrifugecasing", "Warning! Standing in the Centrifuge not recommended"); + protected final String mCasing_CokeOven = GT_LanguageManager.addStringLocalization("mu.cokeoven", "Sturdy and Strong"); + protected final String mCasing_CokeCoil1 = GT_LanguageManager.addStringLocalization("mu.coil01tooltip", "Base Heating Capacity = 1350 Kelvin"); + protected final String mCasing_CokeCoil2 = GT_LanguageManager.addStringLocalization("mu.coil02tooltip", "Base Heating Capacity = 2275 Kelvin"); + protected final String mNoMobsToolTip = GT_LanguageManager.addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + protected final String mNoTileEntityToolTip = GT_LanguageManager.addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); + + public GregtechMetaItemCasingsAbstract(final Block par1) { + super(par1); + this.setMaxDamage(0); + this.setHasSubtypes(true); + //setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public int getMetadata(final int aMeta) { + return aMeta; + } + + @Override + public String getUnlocalizedName(final ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); + } + + @Override + public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + switch (this.getDamage(aStack)) { + case 0: + //aList.add(this.mCasing_Centrifuge); + break; + case 1: + //aList.add(this.mCasing_CokeOven); + break; + case 2: + //aList.add(this.mCasing_CokeCoil1); + break; + case 3: + //aList.add(this.mCasing_CokeCoil2); + break; + default: + break; + } + aList.add(this.mNoMobsToolTip); + aList.add(this.mNoTileEntityToolTip); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java new file mode 100644 index 0000000000..8f5dff592a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMachineCasings.java @@ -0,0 +1,81 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import java.util.List; + +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Material_Casings; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +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.util.IIcon; + + +public class GregtechMetaSpecialMachineCasings extends GregtechMetaCasingBlocksAbstract { + + + public static class SpecialCasingItemBlock extends GregtechMetaCasingItems { + + public SpecialCasingItemBlock(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int aMeta = aStack.getItemDamage(); + if (aMeta < 10) { + //aList.add("Tier: "+GT_Values.VN[aMeta]); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + + public GregtechMetaSpecialMachineCasings() { + super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.2", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + //TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); + // Don't register these Textures, They already exist within vanilla GT. (May not exist in 5.08) + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Strong Bronze Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Sturdy Aluminium Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Vigorous Laurenium Machine Casing"); + TAE.registerTexture(84, new GT_CopiedBlockTexture(this, 6, 2)); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Rugged Botmium Machine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused + + GregtechItemList.Casing_Machine_Custom_1.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Machine_Custom_2.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Machine_Custom_3.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_Machine_Custom_4.set(new ItemStack(this, 1, 3)); + } + + public IIcon getIcon(int aSide, int aMeta) { + switch (aMeta) { + case 0: + return Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); + case 1: + return Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); + case 2: + return TexturesGtBlock.Casing_Material_Laurenium.getIcon(); + case 3: + return Textures.BlockIcons.MACHINE_HEATPROOFCASING.getIcon(); + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java new file mode 100644 index 0000000000..5a5c923d10 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java @@ -0,0 +1,103 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import java.util.List; + +import gregtech.api.enums.Textures; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.blocks.GT_Material_Casings; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +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.util.IIcon; + + +public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbstract { + + + public static class SpecialCasingItemBlock extends GregtechMetaCasingItems { + + public SpecialCasingItemBlock(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int aMeta = aStack.getItemDamage(); + if (aMeta < 10) { + //aList.add("Tier: "+GT_Values.VN[aMeta]); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + + public GregtechMetaSpecialMultiCasings() { + super(SpecialCasingItemBlock.class, "gtplusplus.blockspecialcasings.1", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + //TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); + // Don't register these Textures, They already exist within vanilla GT. (May not exist in 5.08) + } + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Turbine Shaft"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Reinforced Steam Turbine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Reinforced HP Steam Turbine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Reinforced Gas Turbine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Reinforced Plasma Turbine Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Tesla Containment Casing"); + 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", "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 + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", ""); // Unused + + GregtechItemList.Casing_Turbine_Shaft.set(new ItemStack(this, 1, 0)); + GregtechItemList.Casing_Turbine_LP.set(new ItemStack(this, 1, 1)); + GregtechItemList.Casing_Turbine_HP.set(new ItemStack(this, 1, 2)); + GregtechItemList.Casing_Turbine_Gas.set(new ItemStack(this, 1, 3)); + GregtechItemList.Casing_Turbine_Plasma.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_TeslaTower.set(new ItemStack(this, 1, 5)); + 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_Flotation_Cell.set(new ItemStack(this, 1, 9)); + GregtechItemList.Casing_Reinforced_Engine_Casing.set(new ItemStack(this, 1, 10)); + } + + public IIcon getIcon(int aSide, int aMeta) { + + switch (aMeta) { + + case 0: + return TexturesGtBlock.Casing_Redox_1.getIcon(); + case 1: + return Textures.BlockIcons.MACHINE_CASING_TURBINE.getIcon(); + case 2: + return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); + case 3: + return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + case 4: + return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 5: + return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); + case 6: + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + case 7: + 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(); + + } + + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java new file mode 100644 index 0000000000..cbd585e50d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaTieredCasingBlocks1.java @@ -0,0 +1,110 @@ +package gtPlusPlus.xmod.gregtech.common.blocks; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; +import gregtech.common.blocks.GT_Material_Casings; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; + + +public class GregtechMetaTieredCasingBlocks1 extends GregtechMetaCasingBlocksAbstract { + + + public static class TieredCasingItemBlock extends GregtechMetaCasingItems { + + public TieredCasingItemBlock(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + int aMeta = aStack.getItemDamage(); + if (aMeta < 10) { + aList.add("Tier: "+GT_Values.VN[aMeta]); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + + public GregtechMetaTieredCasingBlocks1() { + super(TieredCasingItemBlock.class, "gtplusplus.blocktieredcasings.1", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + //TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); + // Don't register these Textures, Hatches should never need to use their Textures. + } + int aIndex = 0; + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Integral Encasement I"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Integral Encasement II"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Integral Encasement III"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Integral Encasement IV"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Integral Encasement V"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Integral Framework I"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Integral Framework II"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Integral Framework III"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Integral Framework IV"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Integral Framework V"); + //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Vacuum Casing"); + //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Turbodyne Casing"); + //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); + //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); + //GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", ""); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Placeholder Block"); + + GregtechItemList.GTPP_Casing_ULV.set(new ItemStack(this, 1, 0)); + GregtechItemList.GTPP_Casing_LV.set(new ItemStack(this, 1, 1)); + GregtechItemList.GTPP_Casing_MV.set(new ItemStack(this, 1, 2)); + GregtechItemList.GTPP_Casing_HV.set(new ItemStack(this, 1, 3)); + GregtechItemList.GTPP_Casing_EV.set(new ItemStack(this, 1, 4)); + GregtechItemList.GTPP_Casing_IV.set(new ItemStack(this, 1, 5)); + GregtechItemList.GTPP_Casing_LuV.set(new ItemStack(this, 1, 6)); + GregtechItemList.GTPP_Casing_ZPM.set(new ItemStack(this, 1, 7)); + GregtechItemList.GTPP_Casing_UV.set(new ItemStack(this, 1, 8)); + GregtechItemList.GTPP_Casing_MAX.set(new ItemStack(this, 1, 9)); + + //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 10)); + //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 11)); + //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 12)); + //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 13)); + //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 14)); + //GregtechItemList.Casing_LV.set(new ItemStack(this, 1, 15)); + } + + public IIcon getIcon(int aSide, int aMeta) { + if (aMeta < 10) { + return TexturesGtBlock.TIERED_MACHINE_HULLS[aMeta].getIcon(); + } + switch (aMeta) { + case 10: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 11: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 12: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 13: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 14: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 15: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java new file mode 100644 index 0000000000..3e4b9a3fee --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/fluid/GregtechFluidHandler.java @@ -0,0 +1,111 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.fluid; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; + +public class GregtechFluidHandler { + + protected static int cellID = 0; + + public static void run(){ + start(); + } + + private static void start(){ + + /* Meta_GT_Proxy.addFluid("lubricant", "Lubricant", Materials.Lubricant, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Lubricant, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("creosote", "Creosote Oil", Materials.Creosote, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Creosote, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("seedoil", "Seed Oil", Materials.SeedOil, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.SeedOil, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("fishoil", "Fish Oil", Materials.FishOil, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.FishOil, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("oil", "Oil", Materials.Oil, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Oil, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("fuel", "Diesel", Materials.Fuel, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Fuel, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("for.honey", "Honey", Materials.Honey, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Honey, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("biomass", "Biomass", Materials.Biomass, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Biomass, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("bioethanol", "Bio Ethanol", Materials.Ethanol, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Ethanol, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("sulfuricacid", "Sulfuric Acid", Materials.SulfuricAcid, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.SulfuricAcid, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("milk", "Milk", Materials.Milk, 1, 290, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Milk, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("mcguffium", "Mc Guffium 239", Materials.McGuffium239, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.McGuffium239, 1L), ItemUtils.getEmptyCell(), 1000); + Meta_GT_Proxy.addFluid("glue", "Glue", Materials.Glue, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Glue, 1L), ItemUtils.getEmptyCell(), 1000); + */ + + if (!LoadedMods.ThermalFoundation){ + + Logger.INFO("Adding in our own GT versions of Thermal Foundation Fluids if they do not already exist."); + if (!FluidRegistry.isFluidRegistered("cryotheum")) { + FluidUtils.addGtFluid("cryotheum", "Gelid Cryotheum", GT_Materials.Cryotheum, 4, -1200, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Cryotheum, 1L), ItemUtils.getEmptyCell(), 1000); + } + if (!FluidRegistry.isFluidRegistered("pyrotheum")) { + FluidUtils.addGtFluid("pyrotheum", "Blazing Pyrotheum", GT_Materials.Pyrotheum, 4, 4000, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Pyrotheum, 1L), ItemUtils.getEmptyCell(), 1000); + } + if (!FluidRegistry.isFluidRegistered("ender")) { + FluidUtils.addGtFluid("ender", "Resonant Ender", GT_Materials.Ender, 4, 4000, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.Ender, 1L), ItemUtils.getEmptyCell(), 1000); + } + + } + + if (LoadedMods.IndustrialCraft2){ + Logger.INFO("Adding in GT Fluids for various nuclear related content."); + + FluidUtils.addGtFluid("hydrofluoricAcid", "Industrial Strength Hydrofluoric Acid", GT_Materials.HydrofluoricAcid, 1, 120, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrofluoricAcid, 1L), ItemUtils.getEmptyCell(), 1000, false); + generateIC2FluidCell("HydrofluoricAcid"); + + FluidUtils.generateFluidNoPrefix("SulfurDioxide", "High Quality Sulfur Dioxide", 263, GT_Materials.SulfurDioxide.mRGBa); + + FluidUtils.addGtFluid("sulfurousAcid", "Sulfurous Acid", GT_Materials.SulfurousAcid, 4, 75, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfurousAcid, 1L), ItemUtils.getEmptyCell(), 1000, false); + generateIC2FluidCell("SulfurousAcid"); + + FluidUtils.addGtFluid("sulfuricApatite", "Sulfuric Apatite Mix", GT_Materials.SulfuricApatite, 4, 500, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricApatite, 1L), ItemUtils.getEmptyCell(), 1000, false); + generateIC2FluidCell("SulfuricApatite"); + + + //Check for IHL Hydrogen Chloride + if (!LoadedMods.IHL || (ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenChloride", 1) == null)){ + if (FluidUtils.getFluidStack("hydrogenchloride", 1) == null){ + if (LoadedMods.IHL){ + Logger.INFO("IHL Loaded but hydrogen chloride could not be found for some reason. How about we add our own."); + } + else { + Logger.INFO("No Suitable versions of Hydrogen Chloride available, adding our own."); + } + FluidUtils.addGtFluid("hydrogenChloride", "Industrial Strength Hydrogen Chloride", GT_Materials.HydrogenChloride, 4, 75, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.HydrogenChloride, 1L), ItemUtils.getEmptyCell(), 1000, false); + generateIC2FluidCell("HydrogenChloride"); + } + } + + + FluidUtils.addGtFluid("sulfuricLithium", "Sulfuric Lithium Mix", GT_Materials.SulfuricLithium, 4, 280, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.SulfuricLithium, 1L), ItemUtils.getEmptyCell(), 1000, false); + generateIC2FluidCell("SulfuricLithium"); + + FluidUtils.addGtFluid("lithiumHydroxide", "Lithium Hydroxide", GT_Materials.LithiumHydroxide, 4, 500, GT_OreDictUnificator.get(OrePrefixes.cell, GT_Materials.LithiumHydroxide, 1L), ItemUtils.getEmptyCell(), 1000, false); + generateIC2FluidCell("LithiumHydroxide"); + + + } + } + + private static ItemStack generateIC2FluidCell(final String fluidNameWithCaps){ + Logger.INFO("Adding a Cell for "+fluidNameWithCaps); + if (LoadedMods.IndustrialCraft2 && !LoadedMods.IndustrialCraft2Classic){ + return Utils.createInternalNameAndFluidCell(fluidNameWithCaps); + } + return null; + } + + private static ItemStack generateIC2FluidCellNoOreDict(final String fluidNameWithCaps){ + Logger.INFO("Adding a Cell for "+fluidNameWithCaps); + if (LoadedMods.IndustrialCraft2 && !LoadedMods.IndustrialCraft2Classic){ + return Utils.createInternalNameAndFluidCellNoOreDict(fluidNameWithCaps); + } + return null; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java new file mode 100644 index 0000000000..123df8fe0f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler.java @@ -0,0 +1,82 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import gregtech.api.enums.Textures; + +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; + +public class CasingTextureHandler { + + //private static final TexturesGregtech59 gregtech59 = new TexturesGregtech59(); + //private static final TexturesGregtech58 gregtech58 = new TexturesGregtech58(); + private static final TexturesCentrifugeMultiblock gregtechX = new TexturesCentrifugeMultiblock(); + + public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + //Centrifuge + case 0: + return TexturesGtBlock.Casing_Material_Centrifuge.getIcon(); + //Coke Oven Frame + case 1: + return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); + //Coke Oven Casing Tier 1 + case 2: + return Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon(); + //Coke Oven Casing Tier 2 + case 3: + return Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon(); + //Material Press Casings + case 4: + return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + //Electrolyzer Casings + case 5: + return TexturesGtBlock.Casing_Material_Potin.getIcon(); + //Broken Blue Fusion Casings + case 6: + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + //Maceration Stack Casings + case 7: + return TexturesGtBlock.Casing_Material_Tumbaga.getIcon(); + //Broken Pink Fusion Casings + case 8: + return TexturesGtBlock.TEXTURE_ORGANIC_PANEL_A_GLOWING.getIcon(); + //Matter Fabricator Casings + case 9: + return TexturesGtBlock.TEXTURE_METAL_PANEL_F.getIcon(); + //Iron Blast Fuance Textures + case 10: + return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + //Multitank Exterior Casing + case 11: + return TexturesGtBlock.Casing_Material_Grisium.getIcon(); + //Reactor Casing I + case 12: + return TexturesGtBlock.Casing_Material_Stellite.getIcon(); + //Reactor Casing II + case 13: + return TexturesGtBlock.Casing_Material_Zeron100.getIcon(); + case 14: + return TexturesGtBlock.Casing_Staballoy_Firebox.getIcon(); + case 15: + return TexturesGtBlock.Casing_Material_ZirconiumCarbide.getIcon(); + + default: + return Textures.BlockIcons.MACHINE_CASING_RADIOACTIVEHAZARD.getIcon(); + + } + } + return Textures.BlockIcons.MACHINE_CASING_GEARBOX_TUNGSTENSTEEL.getIcon(); + } + + + public static IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { + /*if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + return gregtech59.handleCasingsGT59(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } + return gregtech58.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock);*/ + return gregtechX.handleCasingsGT(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java new file mode 100644 index 0000000000..c980997c64 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java @@ -0,0 +1,57 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import net.minecraft.util.IIcon; + +import gregtech.api.enums.Textures; + +public class CasingTextureHandler2 { + + public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0: + return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); + case 1: + return TexturesGtBlock.Casing_Material_HastelloyX.getIcon(); + case 2: + return TexturesGtBlock.Casing_Material_HastelloyN.getIcon(); + case 3: + return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon(); + case 4: + return TexturesGtBlock.Casing_Material_Grisium.getIcon(); + case 5: + return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon(); + case 6: + return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon(); + case 7: + return TexturesGtBlock.Casing_Redox_1.getIcon(); + case 8: + return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon(); + case 9: + return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon(); + case 10: + return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); + case 11: + return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); + case 12: + return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + case 13: + if (aSide <2) { + return TexturesGtBlock.TEXTURE_TECH_A.getIcon(); + } + else { + return TexturesGtBlock.TEXTURE_TECH_B.getIcon(); + } + case 14: + return Textures.BlockIcons.RENDERING_ERROR.getIcon(); + case 15: + return TexturesGtBlock.Casing_Machine_Acacia_Log.getIcon(); + default: + return TexturesGtBlock.Overlay_UU_Matter.getIcon(); + + } + } + return TexturesGtBlock._PlaceHolder.getIcon(); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java new file mode 100644 index 0000000000..019a432013 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java @@ -0,0 +1,68 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import net.minecraft.util.IIcon; +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks3; + +public class CasingTextureHandler3 { + + public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0: + //Aquatic Casing + return TexturesGtBlock.TEXTURE_METAL_PANEL_B.getIcon(); + case 1: + //Inconel Reinforced Casing + return TexturesGtBlock.TEXTURE_METAL_PANEL_D.getIcon(); + case 2: + //Multi-Use Casing + return TexturesGtBlock.TEXTURE_METAL_PANEL_C.getIcon(); + case 3: + //Trinium Plated Mining Platform Casing + return TexturesGtBlock.Casing_Trinium_Naquadah_Vent.getIcon(); + case 4: + //Vanadium Redox IV + return TexturesGtBlock.Casing_Redox_2.getIcon(); + case 5: + //Vanadium Redox LuV + return TexturesGtBlock.Casing_Redox_3.getIcon(); + case 6: + //Vanadium Redox ZPM + return TexturesGtBlock.Casing_Redox_4.getIcon(); + case 7: + //Vanadium Redox UV + return TexturesGtBlock.Casing_Redox_5.getIcon(); + case 8: + //Vanadium Redox MAX + return TexturesGtBlock.Casing_Redox_6.getIcon(); + case 9: + //Amazon Warehouse Casing + return TexturesGtBlock.TEXTURE_CASING_AMAZON.getIcon(); + case 10: + //Adv. Vac. Freezer + return TexturesGtBlock.TEXTURE_CASING_ADVANCED_CRYOGENIC.getIcon(); + case 11: + //Adv. EBF + return TexturesGtBlock.TEXTURE_CASING_ADVANCED_VOLCNUS.getIcon(); + case 12: + return TexturesGtBlock.TEXTURE_CASING_FUSION_COIL_II.getIcon(); + case 13: + return TexturesGtBlock.TEXTURE_CASING_FUSION_COIL_II_INNER.getIcon(); + case 14: + return TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_ULTRA.getIcon(); + case 15: + return TexturesGtBlock.TEXTURE_MAGIC_PANEL_A.getIcon(); + + default: + return TexturesGtBlock._PlaceHolder.getIcon(); + + } + } + return TexturesGtBlock._PlaceHolder.getIcon(); + } + + static { + GregtechMetaCasingBlocks3.mConnectedMachineTextures = true; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java new file mode 100644 index 0000000000..6326dd2c29 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesCentrifugeMultiblock.java @@ -0,0 +1,166 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialCentrifuge; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +public class TexturesCentrifugeMultiblock { + + private static CustomIcon GT8_1_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE1"); + private static CustomIcon GT8_1 = new CustomIcon("iconsets/LARGECENTRIFUGE1"); + private static CustomIcon GT8_2_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE2"); + private static CustomIcon GT8_2 = new CustomIcon("iconsets/LARGECENTRIFUGE2"); + private static CustomIcon GT8_3_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE3"); + private static CustomIcon GT8_3 = new CustomIcon("iconsets/LARGECENTRIFUGE3"); + private static CustomIcon GT8_4_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE4"); + private static CustomIcon GT8_4 = new CustomIcon("iconsets/LARGECENTRIFUGE4"); + private static CustomIcon GT8_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static CustomIcon GT8_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); + private static CustomIcon GT8_6_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE6"); + private static CustomIcon GT8_6 = new CustomIcon("iconsets/LARGECENTRIFUGE6"); + private static CustomIcon GT8_7_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE7"); + private static CustomIcon GT8_7 = new CustomIcon("iconsets/LARGECENTRIFUGE7"); + private static CustomIcon GT8_8_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE8"); + private static CustomIcon GT8_8 = new CustomIcon("iconsets/LARGECENTRIFUGE8"); + private static CustomIcon GT8_9_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE9"); + private static CustomIcon GT8_9 = new CustomIcon("iconsets/LARGECENTRIFUGE9"); + + private static CustomIcon frontFace_0 = (GT8_1); + private static CustomIcon frontFaceActive_0 = (GT8_1_Active); + private static CustomIcon frontFace_1 = (GT8_2); + private static CustomIcon frontFaceActive_1 = (GT8_2_Active); + private static CustomIcon frontFace_2 = (GT8_3); + private static CustomIcon frontFaceActive_2 = (GT8_3_Active); + private static CustomIcon frontFace_3 = (GT8_4); + private static CustomIcon frontFaceActive_3 = (GT8_4_Active); + private static CustomIcon frontFace_4 = (GT8_5); + private static CustomIcon frontFaceActive_4 = (GT8_5_Active); + private static CustomIcon frontFace_5 = (GT8_6); + private static CustomIcon frontFaceActive_5 = (GT8_6_Active); + private static CustomIcon frontFace_6 = (GT8_7); + private static CustomIcon frontFaceActive_6 = (GT8_7_Active); + private static CustomIcon frontFace_7 = (GT8_8); + private static CustomIcon frontFaceActive_7 = (GT8_8_Active); + private static CustomIcon frontFace_8 = (GT8_9); + private static CustomIcon frontFaceActive_8 = (GT8_9_Active); + + CustomIcon[] CENTRIFUGE = new CustomIcon[]{ + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; + + CustomIcon[] CENTRIFUGE_ACTIVE = new CustomIcon[]{ + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; + + public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { + return this.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } + + private static int isCentrifugeControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; + IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; + if (tTile.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialCentrifuge && tTile.getFrontFacing() == aSide) + return tTile.isActive() ? 1 : 2; + return 0; + } + + public IIcon handleCasingsGT58(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (tMeta != 0) { + return CasingTextureHandler.getIcon(aSide, tMeta); + } + int tInvertLeftRightMod = aSide % 2 * 2 - 1; + switch (aSide / 2) { + case 0: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) + continue; + if (isCentrifugeControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord + j, yCoord, zCoord + i)).getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 - i * 3 - j); + } + } + } + break; + case 1: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) + continue; + if (isCentrifugeControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord + j, yCoord + i, zCoord)).getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 + i * 3 - j * tInvertLeftRightMod); + } + } + } + break; + case 2: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) + continue; + if (isCentrifugeControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord, yCoord + i, zCoord + j)).getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 + i * 3 + j * tInvertLeftRightMod); + } + } + } + break; + } + return TexturesGtBlock.Casing_Material_Centrifuge.getIcon(); + } + + public boolean isCentrifugeRunning(IMetaTileEntity aTile) { + if (aTile == null) { + return false; + } + else { + return aTile.getBaseMetaTileEntity().isActive(); + } + + + } + + public boolean isUsingAnimatedTexture(IMetaTileEntity aMetaTileEntity) { + if (aMetaTileEntity != null) { + if (aMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge) { + return ((GregtechMetaTileEntity_IndustrialCentrifuge) aMetaTileEntity).usingAnimations(); + } + } + return false; + } + + public IIcon getIconByIndex(IMetaTileEntity aMetaTileEntity, int aIndex) { + if (isUsingAnimatedTexture(aMetaTileEntity)) { + if (isCentrifugeRunning(aMetaTileEntity)) { + return this.CENTRIFUGE_ACTIVE[aIndex].getIcon(); + } + } + return this.CENTRIFUGE[aIndex].getIcon(); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java new file mode 100644 index 0000000000..e772f0f48c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech58.java @@ -0,0 +1,443 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialCentrifuge; + +public class TexturesGregtech58 { + + private static Textures.BlockIcons.CustomIcon GT8_1_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE1"); + private static Textures.BlockIcons.CustomIcon GT8_1 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE1"); + private static Textures.BlockIcons.CustomIcon GT8_2_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE2"); + private static Textures.BlockIcons.CustomIcon GT8_2 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE2"); + private static Textures.BlockIcons.CustomIcon GT8_3_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE3"); + private static Textures.BlockIcons.CustomIcon GT8_3 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE3"); + private static Textures.BlockIcons.CustomIcon GT8_4_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE4"); + private static Textures.BlockIcons.CustomIcon GT8_4 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE4"); + private static Textures.BlockIcons.CustomIcon GT8_5_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE5"); + private static Textures.BlockIcons.CustomIcon GT8_5 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE5"); + private static Textures.BlockIcons.CustomIcon GT8_6_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE6"); + private static Textures.BlockIcons.CustomIcon GT8_6 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE6"); + private static Textures.BlockIcons.CustomIcon GT8_7_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE7"); + private static Textures.BlockIcons.CustomIcon GT8_7 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE7"); + private static Textures.BlockIcons.CustomIcon GT8_8_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE8"); + private static Textures.BlockIcons.CustomIcon GT8_8 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE8"); + private static Textures.BlockIcons.CustomIcon GT8_9_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE9"); + private static Textures.BlockIcons.CustomIcon GT8_9 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE9"); + + private static Textures.BlockIcons.CustomIcon frontFace_0 = (GT8_1); + private static Textures.BlockIcons.CustomIcon frontFaceActive_0 = (GT8_1_Active); + private static Textures.BlockIcons.CustomIcon frontFace_1 = (GT8_2); + private static Textures.BlockIcons.CustomIcon frontFaceActive_1 = (GT8_2_Active); + private static Textures.BlockIcons.CustomIcon frontFace_2 = (GT8_3); + private static Textures.BlockIcons.CustomIcon frontFaceActive_2 = (GT8_3_Active); + private static Textures.BlockIcons.CustomIcon frontFace_3 = (GT8_4); + private static Textures.BlockIcons.CustomIcon frontFaceActive_3 = (GT8_4_Active); + private static Textures.BlockIcons.CustomIcon frontFace_4 = (GT8_5); + private static Textures.BlockIcons.CustomIcon frontFaceActive_4 = (GT8_5_Active); + private static Textures.BlockIcons.CustomIcon frontFace_5 = (GT8_6); + private static Textures.BlockIcons.CustomIcon frontFaceActive_5 = (GT8_6_Active); + private static Textures.BlockIcons.CustomIcon frontFace_6 = (GT8_7); + private static Textures.BlockIcons.CustomIcon frontFaceActive_6 = (GT8_7_Active); + private static Textures.BlockIcons.CustomIcon frontFace_7 = (GT8_8); + private static Textures.BlockIcons.CustomIcon frontFaceActive_7 = (GT8_8_Active); + private static Textures.BlockIcons.CustomIcon frontFace_8 = (GT8_9); + private static Textures.BlockIcons.CustomIcon frontFaceActive_8 = (GT8_9_Active); + + Textures.BlockIcons.CustomIcon[] TURBINE = new Textures.BlockIcons.CustomIcon[]{ + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; + + Textures.BlockIcons.CustomIcon[] TURBINE_ACTIVE = new Textures.BlockIcons.CustomIcon[]{ + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; + + + public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { + return this.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } + + + public IIcon handleCasingsGT58(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (((tMeta != 6) && (tMeta != 8) && (tMeta != 0))) { + return CasingTextureHandler.getIcon(aSide, tMeta); + } + final int tStartIndex = tMeta == 6 ? 1 : 13; + if (tMeta == 0) { + if ((aSide == 2) || (aSide == 3)) { + TileEntity tTileEntity; + IMetaTileEntity tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[0].getIcon(); + } + return this.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[3].getIcon(); + } + return this.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[6].getIcon(); + } + return this.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[1].getIcon(); + } + return this.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[7].getIcon(); + } + return this.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[8].getIcon(); + } + return this.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[5].getIcon(); + } + return this.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[2].getIcon(); + } + return this.TURBINE[2].getIcon(); + } + } else if ((aSide == 4) || (aSide == 5)) { + TileEntity tTileEntity; + Object tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[0].getIcon(); + } + return this.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[3].getIcon(); + } + return this.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[6].getIcon(); + } + return this.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[1].getIcon(); + } + return this.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[7].getIcon(); + } + return this.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[8].getIcon(); + } + return this.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[5].getIcon(); + } + return this.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[2].getIcon(); + } + return this.TURBINE[2].getIcon(); + } + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + final boolean[] tConnectedSides = {(aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta)}; + switch (aSide) { + case 0: + if (tConnectedSides[0]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 1: + if (tConnectedSides[1]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 2: + if (tConnectedSides[5]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 3: + if (tConnectedSides[3]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 4: + if (tConnectedSides[4]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + case 5: + if (tConnectedSides[2]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + break; + } + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java new file mode 100644 index 0000000000..ac721d81c3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGregtech59.java @@ -0,0 +1,444 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialCentrifuge; + +public class TexturesGregtech59 { + + private static Textures.BlockIcons.CustomIcon GT8_1_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE1"); + private static Textures.BlockIcons.CustomIcon GT8_1 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST1"); + private static Textures.BlockIcons.CustomIcon GT8_2_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE2"); + private static Textures.BlockIcons.CustomIcon GT8_2 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST2"); + private static Textures.BlockIcons.CustomIcon GT8_3_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE3"); + private static Textures.BlockIcons.CustomIcon GT8_3 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST3"); + private static Textures.BlockIcons.CustomIcon GT8_4_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE4"); + private static Textures.BlockIcons.CustomIcon GT8_4 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST4"); + private static Textures.BlockIcons.CustomIcon GT8_5_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE5"); + private static Textures.BlockIcons.CustomIcon GT8_5 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST5"); + private static Textures.BlockIcons.CustomIcon GT8_6_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE6"); + private static Textures.BlockIcons.CustomIcon GT8_6 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST6"); + private static Textures.BlockIcons.CustomIcon GT8_7_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE7"); + private static Textures.BlockIcons.CustomIcon GT8_7 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST7"); + private static Textures.BlockIcons.CustomIcon GT8_8_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE8"); + private static Textures.BlockIcons.CustomIcon GT8_8 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST8"); + private static Textures.BlockIcons.CustomIcon GT8_9_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE9"); + private static Textures.BlockIcons.CustomIcon GT8_9 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST9"); + + private static Textures.BlockIcons.CustomIcon frontFace_0 = (GT8_1); + private static Textures.BlockIcons.CustomIcon frontFaceActive_0 = (GT8_1_Active); + private static Textures.BlockIcons.CustomIcon frontFace_1 = (GT8_2); + private static Textures.BlockIcons.CustomIcon frontFaceActive_1 = (GT8_2_Active); + private static Textures.BlockIcons.CustomIcon frontFace_2 = (GT8_3); + private static Textures.BlockIcons.CustomIcon frontFaceActive_2 = (GT8_3_Active); + private static Textures.BlockIcons.CustomIcon frontFace_3 = (GT8_4); + private static Textures.BlockIcons.CustomIcon frontFaceActive_3 = (GT8_4_Active); + private static Textures.BlockIcons.CustomIcon frontFace_4 = (GT8_5); + private static Textures.BlockIcons.CustomIcon frontFaceActive_4 = (GT8_5_Active); + private static Textures.BlockIcons.CustomIcon frontFace_5 = (GT8_6); + private static Textures.BlockIcons.CustomIcon frontFaceActive_5 = (GT8_6_Active); + private static Textures.BlockIcons.CustomIcon frontFace_6 = (GT8_7); + private static Textures.BlockIcons.CustomIcon frontFaceActive_6 = (GT8_7_Active); + private static Textures.BlockIcons.CustomIcon frontFace_7 = (GT8_8); + private static Textures.BlockIcons.CustomIcon frontFaceActive_7 = (GT8_8_Active); + private static Textures.BlockIcons.CustomIcon frontFace_8 = (GT8_9); + private static Textures.BlockIcons.CustomIcon frontFaceActive_8 = (GT8_9_Active); + + Textures.BlockIcons.CustomIcon[] TURBINE = new Textures.BlockIcons.CustomIcon[]{ + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; + + Textures.BlockIcons.CustomIcon[] TURBINE_ACTIVE = new Textures.BlockIcons.CustomIcon[]{ + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; + + + public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { + return this.handleCasingsGT59(aWorld, xCoord, yCoord, zCoord, aSide, thisBlock); + } + + + public IIcon handleCasingsGT59(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks thisBlock) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (((tMeta != 6) && (tMeta != 8) && (tMeta != 0))) { + return CasingTextureHandler.getIcon(aSide, tMeta); + } + final int tStartIndex = tMeta == 6 ? 1 : 13; + if (tMeta == 0) { + if ((aSide == 2) || (aSide == 3)) { + TileEntity tTileEntity; + IMetaTileEntity tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[0].getIcon(); + } + return this.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[3].getIcon(); + } + return this.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[6].getIcon(); + } + return this.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[1].getIcon(); + } + return this.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[7].getIcon(); + } + return this.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[8].getIcon(); + } + return this.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[5].getIcon(); + } + return this.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[2].getIcon(); + } + return this.TURBINE[2].getIcon(); + } + } else if ((aSide == 4) || (aSide == 5)) { + TileEntity tTileEntity; + Object tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[0].getIcon(); + } + return this.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[3].getIcon(); + } + return this.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[6].getIcon(); + } + return this.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[1].getIcon(); + } + return this.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[7].getIcon(); + } + return this.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[8].getIcon(); + } + return this.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[5].getIcon(); + } + return this.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GregtechMetaTileEntity_IndustrialCentrifuge))) { + if (((IGregTechTileEntity) tTileEntity).isActive()) { + return this.TURBINE_ACTIVE[2].getIcon(); + } + return this.TURBINE[2].getIcon(); + } + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + final boolean[] tConnectedSides = {(aWorld.getBlock(xCoord, yCoord - 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == thisBlock) && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == thisBlock) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta)}; + switch (aSide) { + case 0: + if (tConnectedSides[0]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 1: + if (tConnectedSides[1]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 2: + if (tConnectedSides[5]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 3: + if (tConnectedSides[3]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 4: + if (tConnectedSides[4]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + case 5: + if (tConnectedSides[2]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + break; + } + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java new file mode 100644 index 0000000000..b254fdbc1e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGrinderMultiblock.java @@ -0,0 +1,150 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks5; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IsaMill; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +public class TexturesGrinderMultiblock { + + private static CustomIcon GT8_1_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE1"); + private static CustomIcon GT8_1 = new CustomIcon("iconsets/Grinder/GRINDER1"); + private static CustomIcon GT8_2_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE2"); + private static CustomIcon GT8_2 = new CustomIcon("iconsets/Grinder/GRINDER2"); + private static CustomIcon GT8_3_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE3"); + private static CustomIcon GT8_3 = new CustomIcon("iconsets/Grinder/GRINDER3"); + private static CustomIcon GT8_4_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE4"); + private static CustomIcon GT8_4 = new CustomIcon("iconsets/Grinder/GRINDER4"); + private static CustomIcon GT8_5_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE5"); + private static CustomIcon GT8_5 = new CustomIcon("iconsets/Grinder/GRINDER5"); + private static CustomIcon GT8_6_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE6"); + private static CustomIcon GT8_6 = new CustomIcon("iconsets/Grinder/GRINDER6"); + private static CustomIcon GT8_7_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE7"); + private static CustomIcon GT8_7 = new CustomIcon("iconsets/Grinder/GRINDER7"); + private static CustomIcon GT8_8_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE8"); + private static CustomIcon GT8_8 = new CustomIcon("iconsets/Grinder/GRINDER8"); + private static CustomIcon GT8_9_Active = new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE9"); + private static CustomIcon GT8_9 = new CustomIcon("iconsets/Grinder/GRINDER9"); + + private static CustomIcon frontFace_0 = (GT8_1); + private static CustomIcon frontFaceActive_0 = (GT8_1_Active); + private static CustomIcon frontFace_1 = (GT8_2); + private static CustomIcon frontFaceActive_1 = (GT8_2_Active); + private static CustomIcon frontFace_2 = (GT8_3); + private static CustomIcon frontFaceActive_2 = (GT8_3_Active); + private static CustomIcon frontFace_3 = (GT8_4); + private static CustomIcon frontFaceActive_3 = (GT8_4_Active); + private static CustomIcon frontFace_4 = (GT8_5); + private static CustomIcon frontFaceActive_4 = (GT8_5_Active); + private static CustomIcon frontFace_5 = (GT8_6); + private static CustomIcon frontFaceActive_5 = (GT8_6_Active); + private static CustomIcon frontFace_6 = (GT8_7); + private static CustomIcon frontFaceActive_6 = (GT8_7_Active); + private static CustomIcon frontFace_7 = (GT8_8); + private static CustomIcon frontFaceActive_7 = (GT8_8_Active); + private static CustomIcon frontFace_8 = (GT8_9); + private static CustomIcon frontFaceActive_8 = (GT8_9_Active); + + CustomIcon[] GRINDER = new CustomIcon[]{ + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; + + CustomIcon[] GRINDER_ACTIVE = new CustomIcon[]{ + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; + + private static int isIsaControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; + IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; + if (tTile.getMetaTileEntity() instanceof GregtechMetaTileEntity_IsaMill && tTile.getFrontFacing() == aSide) + return tTile.isActive() ? 1 : 2; + return 0; + } + + public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks5 ii) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (tMeta != 1) { + return GregtechMetaCasingBlocks5.getStaticIcon(aSide, tMeta); + } + int tInvertLeftRightMod = aSide % 2 * 2 - 1; + switch (aSide / 2) { + case 0: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) + continue; + if (isIsaControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord + j, yCoord, zCoord + i)).getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 - i * 3 - j); + } + } + } + break; + case 1: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) + continue; + if (isIsaControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord + j, yCoord + i, zCoord)).getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 + i * 3 - j * tInvertLeftRightMod); + } + } + } + break; + case 2: + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) + continue; + if (isIsaControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide) != 0) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld.getTileEntity(xCoord, yCoord + i, zCoord + j)).getMetaTileEntity(); + return getIconByIndex(tMetaTileEntity, 4 + i * 3 + j * tInvertLeftRightMod); + } + } + } + break; + } + return TexturesGtBlock.TEXTURE_CASING_GRINDING_MILL.getIcon(); + } + + public boolean isCentrifugeRunning(IMetaTileEntity aTile) { + if (aTile == null) { + return false; + } + else { + return aTile.getBaseMetaTileEntity().isActive(); + } + } + + public IIcon getIconByIndex(IMetaTileEntity aMetaTileEntity, int aIndex) { + if (isCentrifugeRunning(aMetaTileEntity)) { + return this.GRINDER_ACTIVE[aIndex].getIcon(); + } + + return this.GRINDER[aIndex].getIcon(); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java new file mode 100644 index 0000000000..518ffe0eae --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -0,0 +1,652 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_RenderedTexture; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; + +public class TexturesGtBlock { + + private static AutoMap<Runnable> mCustomiconMap = new AutoMap<Runnable>(); + + static { + + } + + //public static ITexture[] CASING_BLOCKS_GTPP = new ITexture[256]; + + /* + * Handles Custom Textures. + */ + + public static class CustomIcon implements IIconContainer, Runnable { + protected IIcon mIcon; + protected String mIconName; + protected String mModID; + + public CustomIcon(final String aIconName) { + this(CORE.MODID, aIconName); + } + + public CustomIcon(final String aModID, final String aIconName) { + this.mIconName = aIconName; + this.mModID = aModID; + mCustomiconMap.put(this); + Logger.WARNING("Constructing a Custom Texture. " + this.mIconName); + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sBlockIcons.registerIcon(this.mModID + ":" + this.mIconName); + Logger.WARNING("FIND ME _ Processing texture: "+this.getTextureFile().getResourcePath()); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + } + + + public static class VanillaIcon implements IIconContainer, Runnable { + protected IIcon mIcon; + protected String mIconName; + + public VanillaIcon(final String aIconName) { + this.mIconName = aIconName; + mCustomiconMap.put(this); + Logger.WARNING("Constructing a Custom Texture. " + this.mIconName); + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sBlockIcons.registerIcon("minecraft" + ":" + this.mIconName); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationBlocksTexture; + } + } + + public static GT_RenderedTexture getTextureFromIcon(CustomIcon aIcon, short[] aRGB) { + return new GT_RenderedTexture(aIcon, aRGB); + } + + /* + * Add Some Custom Textures below. + * I am not sure whether or not I need to declare them as such, but better to be safe than sorry. + * Right? + */ + + //Vanilla Textures + public static final VanillaIcon VanillaIcon_OakPlanks = new VanillaIcon("planks_oak"); + + + + //PlaceHolder Texture + private static final CustomIcon Internal_PlaceHolder = new CustomIcon("TileEntities/_PlaceHolder"); + public static final CustomIcon _PlaceHolder = Internal_PlaceHolder; + + //Energy overlays + public static final CustomIcon OVERLAY_ENERGY_OUT_BUFFER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_BUFFER"); + public static final CustomIcon OVERLAY_ENERGY_OUT_MULTI_BUFFER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_MULTI_BUFFER"); + + //Wooden Shelf and Compartment Overlays + public static final CustomIcon OVERLAY_WOODEN_SHELF_FRONT = new CustomIcon("TileEntities/Compartment/wood_shelf"); + public static final CustomIcon OVERLAY_WOODEN_SHELF_CANS_FRONT = new CustomIcon("TileEntities/Compartment/wood_shelf_cans"); + public static final CustomIcon OVERLAY_WOODEN_SHELF_PAPER_FRONT = new CustomIcon("TileEntities/Compartment/wood_shelf_paper"); + public static final CustomIcon OVERLAY_CABINET_1 = new CustomIcon("TileEntities/Compartment/0"); + public static final CustomIcon OVERLAY_CABINET_2 = new CustomIcon("TileEntities/Compartment/1"); + public static final CustomIcon OVERLAY_CABINET_3 = new CustomIcon("TileEntities/Compartment/2"); + public static final CustomIcon OVERLAY_CABINET_4 = new CustomIcon("TileEntities/Compartment/3"); + public static final CustomIcon OVERLAY_CABINET_5 = new CustomIcon("TileEntities/Compartment/4"); + public static final CustomIcon OVERLAY_CABINET_6 = new CustomIcon("TileEntities/Compartment/5"); + public static final CustomIcon OVERLAY_CABINET_7 = new CustomIcon("TileEntities/Compartment/6"); + public static final CustomIcon OVERLAY_CABINET_8 = new CustomIcon("TileEntities/Compartment/7"); + public static final CustomIcon OVERLAY_CABINET_9 = new CustomIcon("TileEntities/Compartment/8"); + public static final CustomIcon OVERLAY_CABINET_10 = new CustomIcon("TileEntities/Compartment/9"); + public static final CustomIcon OVERLAY_CABINET_11 = new CustomIcon("TileEntities/Compartment/10"); + public static final CustomIcon OVERLAY_CABINET_12 = new CustomIcon("TileEntities/Compartment/11"); + public static final CustomIcon OVERLAY_CABINET_13 = new CustomIcon("TileEntities/Compartment/12"); + public static final CustomIcon OVERLAY_CABINET_14 = new CustomIcon("TileEntities/Compartment/13"); + public static final CustomIcon OVERLAY_CABINET_15 = new CustomIcon("TileEntities/Compartment/14"); + public static final CustomIcon OVERLAY_CABINET_16 = new CustomIcon("TileEntities/Compartment/15"); + public static final CustomIcon OVERLAY_COMPARTMENT_1 = new CustomIcon("TileEntities/Compartment/16"); + public static final CustomIcon OVERLAY_COMPARTMENT_2 = new CustomIcon("TileEntities/Compartment/17"); + public static final CustomIcon OVERLAY_COMPARTMENT_3 = new CustomIcon("TileEntities/Compartment/18"); + public static final CustomIcon OVERLAY_COMPARTMENT_4 = new CustomIcon("TileEntities/Compartment/19"); + public static final CustomIcon OVERLAY_COMPARTMENT_5 = new CustomIcon("TileEntities/Compartment/20"); + public static final CustomIcon OVERLAY_COMPARTMENT_6 = new CustomIcon("TileEntities/Compartment/21"); + public static final CustomIcon OVERLAY_COMPARTMENT_7 = new CustomIcon("TileEntities/Compartment/22"); + public static final CustomIcon OVERLAY_COMPARTMENT_8 = new CustomIcon("TileEntities/Compartment/23"); + public static final CustomIcon OVERLAY_COMPARTMENT_9 = new CustomIcon("TileEntities/Compartment/24"); + public static final CustomIcon OVERLAY_COMPARTMENT_10 = new CustomIcon("TileEntities/Compartment/25"); + public static final CustomIcon OVERLAY_COMPARTMENT_11 = new CustomIcon("TileEntities/Compartment/26"); + public static final CustomIcon OVERLAY_COMPARTMENT_12 = new CustomIcon("TileEntities/Compartment/27"); + public static final CustomIcon OVERLAY_COMPARTMENT_13 = new CustomIcon("TileEntities/Compartment/28"); + public static final CustomIcon OVERLAY_COMPARTMENT_14 = new CustomIcon("TileEntities/Compartment/29"); + public static final CustomIcon OVERLAY_COMPARTMENT_15 = new CustomIcon("TileEntities/Compartment/30"); + public static final CustomIcon OVERLAY_COMPARTMENT_16 = new CustomIcon("TileEntities/Compartment/31"); + + //Controllers + private static final CustomIcon Internal_Casing_Fusion_Simple_Front = new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT"); + public static final CustomIcon Casing_Fusion_Simple_Front = Internal_Casing_Fusion_Simple_Front; + private static final CustomIcon Internal_Casing_Fusion_Simple_Front_Active = new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE"); + public static final CustomIcon Casing_Fusion_Simple_Front_Active = Internal_Casing_Fusion_Simple_Front_Active; + + //Machine Casings + //Simple + private static final CustomIcon Internal_Casing_Machine_Simple_Top = new CustomIcon("TileEntities/machine_top"); + public static final CustomIcon Casing_Machine_Simple_Top = Internal_Casing_Machine_Simple_Top; + private static final CustomIcon Internal_Casing_Machine_Simple_Bottom = new CustomIcon("TileEntities/machine_bottom"); + public static final CustomIcon Casing_Machine_Simple_Bottom = Internal_Casing_Machine_Simple_Bottom; + //Advanced and Ultra + private static final CustomIcon Internal_Casing_Machine_Advanced = new CustomIcon("TileEntities/high_adv_machine"); + public static final CustomIcon Casing_Machine_Advanced = Internal_Casing_Machine_Advanced; + private static final CustomIcon Internal_Casing_Machine_Ultra = new CustomIcon("TileEntities/adv_machine_lesu"); + public static final CustomIcon Casing_Machine_Ultra = Internal_Casing_Machine_Ultra; + //Dimensional - Non Overlay + private static final CustomIcon Internal_Casing_Machine_Dimensional = new CustomIcon("TileEntities/adv_machine_dimensional"); + public static final CustomIcon Casing_Machine_Dimensional = Internal_Casing_Machine_Dimensional; + private static final CustomIcon Internal_Casing_Machine_Dimensional_Adv = new CustomIcon("TileEntities/high_adv_machine_dimensional"); + public static final CustomIcon Casing_Machine_Dimensional_Adv = Internal_Casing_Machine_Dimensional_Adv; + + //Material Casings + private static final CustomIcon Internal_Casing_Tantalloy61 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TANTALLOY61"); + public static final CustomIcon Casing_Material_Tantalloy61 = Internal_Casing_Tantalloy61; + private static final CustomIcon Internal_Casing_MaragingSteel = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_MARAGINGSTEEL"); + public static final CustomIcon Casing_Material_MaragingSteel = Internal_Casing_MaragingSteel; + private static final CustomIcon Internal_Casing_Stellite = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_STELLITE"); + public static final CustomIcon Casing_Material_Stellite = Internal_Casing_Stellite; + private static final CustomIcon Internal_Casing_Talonite = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TALONITE"); + public static final CustomIcon Casing_Material_Talonite = Internal_Casing_Talonite; + private static final CustomIcon Internal_Casing_Tumbaga = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TUMBAGA"); + public static final CustomIcon Casing_Material_Tumbaga = Internal_Casing_Tumbaga; + private static final CustomIcon Internal_Casing_Zeron100 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZERON100"); + public static final CustomIcon Casing_Material_Zeron100 = Internal_Casing_Zeron100; + private static final CustomIcon Internal_Casing_Potin = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_POTIN"); + public static final CustomIcon Casing_Material_Potin = Internal_Casing_Potin; + + private static final CustomIcon Internal_Casing_Grisium = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_GRISIUM"); + public static final CustomIcon Casing_Material_Grisium = Internal_Casing_Grisium; + private static final CustomIcon Internal_Casing_RedSteel = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_RED_STEEL"); + public static final CustomIcon Casing_Material_RedSteel = Internal_Casing_RedSteel; + private static final CustomIcon Internal_Casing_Incoloy020 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_020"); + public static final CustomIcon Casing_Material_Incoloy020 = Internal_Casing_Incoloy020; + private static final CustomIcon Internal_Casing_IncoloyDS = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_DS"); + public static final CustomIcon Casing_Material_IncoloyDS = Internal_Casing_IncoloyDS; + private static final CustomIcon Internal_Casing_IncoloyMA956 = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_INCOLOY_MA956"); + public static final CustomIcon Casing_Material_IncoloyMA956 = Internal_Casing_IncoloyMA956; + private static final CustomIcon Internal_Casing_ZirconiumCarbide = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_ZIRCONIUM_CARBIDE"); + public static final CustomIcon Casing_Material_ZirconiumCarbide = Internal_Casing_ZirconiumCarbide; + + + private static final CustomIcon Internal_Casing_HastelloyX = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_HASTELLOY_X"); + public static final CustomIcon Casing_Material_HastelloyX = Internal_Casing_HastelloyX; + private static final CustomIcon Internal_Casing_HastelloyN = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_HASTELLOY_N"); + public static final CustomIcon Casing_Material_HastelloyN = Internal_Casing_HastelloyN; + private static final CustomIcon Internal_Casing_Fluid_IncoloyDS = new CustomIcon("TileEntities/MACHINE_CASING_FLUID_INCOLOY_DS"); + public static final CustomIcon Casing_Material_Fluid_IncoloyDS = Internal_Casing_Fluid_IncoloyDS; + + private static final CustomIcon Internal_Casing_Laurenium = new CustomIcon("TileEntities/MACHINE_CASING_LAURENIUM"); + public static final CustomIcon Casing_Material_Laurenium = Internal_Casing_Laurenium; + + //Trinium Alloys + public static final CustomIcon Casing_Trinium_Titanium = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_TITANIUM"); + public static final CustomIcon Casing_Trinium_Naquadah = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_NAQUADAH"); + public static final CustomIcon Casing_Trinium_Naquadah_Vent = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_NAQUADAH_VENT"); + public static final CustomIcon Casing_Trinium_Naquadah_Carbon = new CustomIcon("TileEntities/MACHINE_CASING_STABLE_TRINIUM_NAQUADAH_CARBON"); + + //Material Machine/Firebox Casings + private static final CustomIcon Internal_Casing_Staballoy_Firebox = new CustomIcon("TileEntities/MACHINE_CASING_FIREBOX_STABALLOY"); + public static final CustomIcon Casing_Staballoy_Firebox = Internal_Casing_Staballoy_Firebox; + + //Misc Casings + private static final CustomIcon Internal_Casing_Machine_Redstone_Off = new CustomIcon("TileEntities/cover_redstone_conductor"); + public static final CustomIcon Casing_Machine_Redstone_Off = Internal_Casing_Machine_Redstone_Off; + private static final CustomIcon Internal_Casing_Machine_Redstone_On = new CustomIcon("TileEntities/cover_redstone_emitter"); + public static final CustomIcon Casing_Machine_Redstone_On = Internal_Casing_Machine_Redstone_On; + + //Redox Cells + public static final CustomIcon Casing_Redox_1 = new CustomIcon("redox/redox1"); + public static final CustomIcon Casing_Redox_2 = new CustomIcon("redox/redox2"); + public static final CustomIcon Casing_Redox_3 = new CustomIcon("redox/redox3"); + public static final CustomIcon Casing_Redox_4 = new CustomIcon("redox/redox4"); + public static final CustomIcon Casing_Redox_5 = new CustomIcon("redox/redox5"); + public static final CustomIcon Casing_Redox_6 = new CustomIcon("redox/redox6"); + //public static final CustomIcon Casing_Redox_7 = new CustomIcon("redox/redox7"); + //public static final CustomIcon Casing_Redox_8 = new CustomIcon("redox/redox8"); + + //Centrifuge Casing + private static final CustomIcon Internal_Casing_Centrifuge = new CustomIcon("TileEntities/MACHINE_CASING_CENTRIFUGE"); + public static final CustomIcon Casing_Material_Centrifuge = Internal_Casing_Centrifuge; + + //MACHINE_CASING_FARM_MANAGER_STRUCTURAL + //Farm Manager Casings + private static final CustomIcon Internal_Casing_Machine_Farm_Manager = new CustomIcon("TileEntities/MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); + public static final CustomIcon Casing_Machine_Farm_Manager = Internal_Casing_Machine_Farm_Manager; + //Acacia_Log + private static final CustomIcon Internal_Casing_Machine_Acacia_Log = new CustomIcon("TileEntities/log_acacia_top"); + public static final CustomIcon Casing_Machine_Acacia_Log = Internal_Casing_Machine_Acacia_Log; + //Podzol Top + private static final CustomIcon Internal_Casing_Machine_Podzol = new CustomIcon("TileEntities/dirt_podzol_top"); + public static final CustomIcon Casing_Machine_Podzol = Internal_Casing_Machine_Podzol; + + //Structural Blocks + private static final CustomIcon Internal_Casing_Machine_Metal_Grate_A = new CustomIcon("chrono/MetalGrate"); + public static final CustomIcon Casing_Machine_Metal_Grate_A = Internal_Casing_Machine_Metal_Grate_A; + private static final CustomIcon Internal_Casing_Machine_Metal_Grate_A_Solid = new CustomIcon("chrono/MetalGrateA_Solid"); + public static final CustomIcon Casing_Machine_Metal_Grate_A_Solid = Internal_Casing_Machine_Metal_Grate_A_Solid; + private static final CustomIcon Internal_Casing_Machine_Metal_Grate_B = new CustomIcon("chrono/MetalGrate2"); + public static final CustomIcon Casing_Machine_Metal_Grate_B = Internal_Casing_Machine_Metal_Grate_B; + private static final CustomIcon Internal_Casing_Machine_Metal_Panel_A = new CustomIcon("chrono/MetalPanel"); + public static final CustomIcon Casing_Machine_Metal_Panel_A = Internal_Casing_Machine_Metal_Panel_A; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_A = new CustomIcon("chrono/MetalSheet"); + public static final CustomIcon Casing_Machine_Metal_Sheet_A = Internal_Casing_Machine_Metal_Sheet_A; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_B = new CustomIcon("chrono/MetalSheet2"); + public static final CustomIcon Casing_Machine_Metal_Sheet_B = Internal_Casing_Machine_Metal_Sheet_B; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_C = new CustomIcon("chrono/MetalSheet3"); + public static final CustomIcon Casing_Machine_Metal_Sheet_C = Internal_Casing_Machine_Metal_Sheet_C; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_D = new CustomIcon("chrono/MetalSheet4"); + public static final CustomIcon Casing_Machine_Metal_Sheet_D = Internal_Casing_Machine_Metal_Sheet_D; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_E = new CustomIcon("chrono/MetalSheet5"); + public static final CustomIcon Casing_Machine_Metal_Sheet_E = Internal_Casing_Machine_Metal_Sheet_E; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_F = new CustomIcon("chrono/MetalSheet6"); + public static final CustomIcon Casing_Machine_Metal_Sheet_F = Internal_Casing_Machine_Metal_Sheet_F; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_G = new CustomIcon("chrono/MetalSheet7"); + public static final CustomIcon Casing_Machine_Metal_Sheet_G = Internal_Casing_Machine_Metal_Sheet_G; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_H = new CustomIcon("chrono/MetalSheet8"); + public static final CustomIcon Casing_Machine_Metal_Sheet_H = Internal_Casing_Machine_Metal_Sheet_H; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_I = new CustomIcon("chrono/MetalSheet9"); + public static final CustomIcon Casing_Machine_Metal_Sheet_I = Internal_Casing_Machine_Metal_Sheet_I; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_J = new CustomIcon("chrono/MetalSheet10"); + public static final CustomIcon Casing_Machine_Metal_Sheet_J = Internal_Casing_Machine_Metal_Sheet_J; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_K = new CustomIcon("chrono/MetalSheet11"); + public static final CustomIcon Casing_Machine_Metal_Sheet_K = Internal_Casing_Machine_Metal_Sheet_K; + private static final CustomIcon Internal_Casing_Machine_Metal_Sheet_L = new CustomIcon("chrono/MetalSheet12"); + public static final CustomIcon Casing_Machine_Metal_Sheet_L = Internal_Casing_Machine_Metal_Sheet_L; + private static final CustomIcon Internal_Overlay_Machine_Cyber_A = new CustomIcon("chrono/CyberPanel"); + public static final CustomIcon Overlay_Machine_Cyber_A = Internal_Overlay_Machine_Cyber_A; + private static final CustomIcon Internal_Overlay_Machine_Cyber_B = new CustomIcon("chrono/CyberPanel2"); + public static final CustomIcon Overlay_Machine_Cyber_B = Internal_Overlay_Machine_Cyber_B; + + + public static final CustomIcon TEXTURE_CASING_AMAZON = new CustomIcon("TileEntities/CASING_AMAZON"); + public static final CustomIcon TEXTURE_CASING_ADVANCED_CRYOGENIC = new CustomIcon("TileEntities/MACHINE_CASING_ADVANCED_CRYOGENIC"); + 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"); + + // Custom Gearboxes + public static final CustomIcon TEXTURE_GEARBOX_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_GEARBOX_T1"); + + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II = new CustomIcon("iconsets/MACHINE_CASING_FUSION_3"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_INNER = new CustomIcon("iconsets/MACHINE_CASING_FUSION_COIL_II"); + public static final CustomIcon TEXTURE_CASING_FUSION_CASING_ULTRA = new CustomIcon("iconsets/MACHINE_CASING_FUSION_GLASS_ULTRA"); + // + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_1 = new CustomIcon("iconsets/FUSIONIII_1"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_2 = new CustomIcon("iconsets/FUSIONIII_2"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_3 = new CustomIcon("iconsets/FUSIONIII_3"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_4 = new CustomIcon("iconsets/FUSIONIII_4"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_5 = new CustomIcon("iconsets/FUSIONIII_5"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_6 = new CustomIcon("iconsets/FUSIONIII_6"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_7 = new CustomIcon("iconsets/FUSIONIII_7"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_8 = new CustomIcon("iconsets/FUSIONIII_8"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_9 = new CustomIcon("iconsets/FUSIONIII_9"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_10 = new CustomIcon("iconsets/FUSIONIII_10"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_11 = new CustomIcon("iconsets/FUSIONIII_11"); + public static final CustomIcon TEXTURE_CASING_FUSION_COIL_II_12 = new CustomIcon("iconsets/FUSIONIII_12"); + + //Overlays + //Fan Textures + private static final CustomIcon Internal_Overlay_Machine_Vent = new CustomIcon("TileEntities/machine_top_vent_rotating"); + public static final CustomIcon Overlay_Machine_Vent = Internal_Overlay_Machine_Vent; + private static final CustomIcon Internal_Overlay_Machine_Vent_Fast = new CustomIcon("TileEntities/machine_top_vent_rotating_fast"); + public static final CustomIcon Overlay_Machine_Vent_Fast = Internal_Overlay_Machine_Vent_Fast; + private static final CustomIcon Internal_Overlay_Machine_Vent_Adv = new CustomIcon("TileEntities/adv_machine_vent_rotating"); + public static final CustomIcon Overlay_Machine_Vent_Adv = Internal_Overlay_Machine_Vent_Adv; + private static final CustomIcon Internal_Overlay_Machine_Turbine_Active = new CustomIcon("TileEntities/STEAM_TURBINE_SIDE_ACTIVE"); + public static final CustomIcon Overlay_Machine_Turbine_Active = Internal_Overlay_Machine_Turbine_Active; + //Grate Texture + public static final CustomIcon OVERLAY_GRATE_A = new CustomIcon("metro/OVERLAY_GRATE_A"); + //Speaker Texture + private static final CustomIcon Internal_Overlay_Machine_Sound = new CustomIcon("TileEntities/audio_out"); + public static final CustomIcon Overlay_Machine_Sound = Internal_Overlay_Machine_Sound; + private static final CustomIcon Internal_Overlay_Machine_Sound_Active = new CustomIcon("TileEntities/audio_out_active"); + public static final CustomIcon Overlay_Machine_Sound_Active = Internal_Overlay_Machine_Sound_Active; + //Diesel Engines + private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical = new CustomIcon("TileEntities/machine_top_dieselmotor"); + public static final CustomIcon Overlay_Machine_Diesel_Vertical = Internal_Overlay_Machine_Diesel_Vertical; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal = new CustomIcon("TileEntities/machine_top_dieselmotor2"); + public static final CustomIcon Overlay_Machine_Diesel_Horizontal = Internal_Overlay_Machine_Diesel_Horizontal; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Vertical_Active = new CustomIcon("TileEntities/machine_top_dieselmotor_active"); + public static final CustomIcon Overlay_Machine_Diesel_Vertical_Active = Internal_Overlay_Machine_Diesel_Vertical_Active; + private static final CustomIcon Internal_Overlay_Machine_Diesel_Horizontal_Active = new CustomIcon("TileEntities/machine_top_dieselmotor2_active"); + public static final CustomIcon Overlay_Machine_Diesel_Horizontal_Active = Internal_Overlay_Machine_Diesel_Horizontal_Active; + //Computer Screens + private static final CustomIcon Internal_Casing_Machine_Screen_1 = new CustomIcon("TileEntities/adv_machine_screen_random1"); + public static final CustomIcon Casing_Machine_Screen_1 = Internal_Casing_Machine_Screen_1; + private static final CustomIcon Internal_Casing_Machine_Screen_2 = new CustomIcon("TileEntities/adv_machine_screen_random2"); + public static final CustomIcon Casing_Machine_Screen_2 = Internal_Casing_Machine_Screen_2; + private static final CustomIcon Internal_Casing_Machine_Screen_3 = new CustomIcon("TileEntities/adv_machine_screen_random3"); + public static final CustomIcon Casing_Machine_Screen_3 = Internal_Casing_Machine_Screen_3; + private static final CustomIcon Internal_Casing_Machine_Screen_Frequency = new CustomIcon("TileEntities/adv_machine_screen_frequency"); + public static final CustomIcon Casing_Machine_Screen_Frequency = Internal_Casing_Machine_Screen_Frequency; + private static final CustomIcon Internal_Overlay_Machine_Screen_Logo = new CustomIcon("TileEntities/adv_machine_screen_logo"); + public static final CustomIcon Overlay_Machine_Screen_Logo = Internal_Overlay_Machine_Screen_Logo; + private static final CustomIcon Internal_Overlay_Machine_Cyber_Interface = new CustomIcon("chrono/Overlay_Cyber"); + public static final CustomIcon Overlay_Machine_Cyber_Interface = Internal_Overlay_Machine_Cyber_Interface; + + //Machine Controller Overlays + private static final CustomIcon Internal_Overlay_Machine_Controller_Default = new CustomIcon("iconsets/OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ANIMATED"); + public static final CustomIcon Overlay_Machine_Controller_Default = Internal_Overlay_Machine_Controller_Default; + private static final CustomIcon Internal_Overlay_Machine_Controller_Default_Active = new CustomIcon("iconsets/OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ANIMATED_ACTIVE"); + public static final CustomIcon Overlay_Machine_Controller_Default_Active = Internal_Overlay_Machine_Controller_Default_Active; + + private static final CustomIcon Internal_Overlay_Machine_Controller_Advanced = new CustomIcon("iconsets/OVERLAY_FRONT_ADVANCED_MULTIBLOCK_ANIMATED"); + public static final CustomIcon Overlay_Machine_Controller_Advanced = Internal_Overlay_Machine_Controller_Advanced; + private static final CustomIcon Internal_Overlay_Machine_Controller_Advanced_Active = new CustomIcon("iconsets/OVERLAY_FRONT_ADVANCED_MULTIBLOCK_ANIMATED_ACTIVE"); + public static final CustomIcon Overlay_Machine_Controller_Advanced_Active = Internal_Overlay_Machine_Controller_Advanced_Active; + + //Fluid Reactor Overlays + public static final CustomIcon Overlay_FluidReactor_Front = new CustomIcon("TileEntities/FluidReactor/OVERLAY_FRONT"); + public static final CustomIcon Overlay_FluidReactor_Side = new CustomIcon("TileEntities/FluidReactor/OVERLAY_SIDE"); + public static final CustomIcon Overlay_FluidReactor_Top = new CustomIcon("TileEntities/FluidReactor/OVERLAY_TOP"); + public static final CustomIcon Overlay_FluidReactor_Front_Active = new CustomIcon("TileEntities/FluidReactor/OVERLAY_FRONT_ACTIVE"); + public static final CustomIcon Overlay_FluidReactor_Side_Active = new CustomIcon("TileEntities/FluidReactor/OVERLAY_SIDE_ACTIVE"); + public static final CustomIcon Overlay_FluidReactor_Top_Active = new CustomIcon("TileEntities/FluidReactor/OVERLAY_TOP_ACTIVE"); + + //Crafting Overlays + private static final CustomIcon Internal_Overlay_Crafting_Bronze = new CustomIcon("TileEntities/bronze_top_crafting"); + public static final CustomIcon Overlay_Crafting_Bronze = Internal_Overlay_Crafting_Bronze; + private static final CustomIcon Internal_Overlay_Crafting_Steel = new CustomIcon("TileEntities/cover_crafting"); + public static final CustomIcon Overlay_Crafting_Steel = Internal_Overlay_Crafting_Steel; + + //Covers + private static final CustomIcon Internal_Overlay_Overflow_Valve = new CustomIcon("iconsets/OVERLAY_OVERFLOW_VALVE"); + public static final CustomIcon Overlay_Overflow_Valve = Internal_Overlay_Overflow_Valve; + + + //Hatch Overlays + //Charger Texture + private static final CustomIcon Internal_Overlay_Hatch_Charger = new CustomIcon("TileEntities/cover_charger"); + public static final CustomIcon Overlay_Hatch_Charger = Internal_Overlay_Hatch_Charger; + //Discharger Texture + private static final CustomIcon Internal_Overlay_Hatch_Discharger = new CustomIcon("TileEntities/cover_discharge"); + public static final CustomIcon Overlay_Hatch_Discharger = Internal_Overlay_Hatch_Discharger; + //Advanced Muffler + private static final CustomIcon Internal_Overlay_Hatch_Muffler_Adv = new CustomIcon("iconsets/OVERLAY_MUFFLER_ADV"); + public static final CustomIcon Overlay_Hatch_Muffler_Adv = Internal_Overlay_Hatch_Muffler_Adv; + //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; + // RTG Hatch + private static final CustomIcon Internal_Overlay_Hatch_RTG_Off = new CustomIcon("iconsets/OVERLAY_ENERGY_RTG_OFF"); + public static final CustomIcon Overlay_Hatch_RTG_Off = Internal_Overlay_Hatch_RTG_Off; + private static final CustomIcon Internal_Overlay_Hatch_RTG_On = new CustomIcon("iconsets/OVERLAY_ENERGY_RTG_ON"); + public static final CustomIcon Overlay_Hatch_RTG_On = Internal_Overlay_Hatch_RTG_On; + + //Dimensional + private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); + public static final CustomIcon Overlay_Machine_Dimensional_Blue = Internal_Overlay_Machine_Dimensional_Blue; + private static final CustomIcon Internal_Overlay_Machine_Dimensional_Orange = new CustomIcon("TileEntities/adv_machine_dimensional_cover_orange"); + public static final CustomIcon Overlay_Machine_Dimensional_Orange = Internal_Overlay_Machine_Dimensional_Orange; + //Icons + private static final CustomIcon Internal_Overlay_MatterFab = new CustomIcon("TileEntities/adv_machine_matterfab"); + public static final CustomIcon Overlay_MatterFab = Internal_Overlay_MatterFab; + private static final CustomIcon Internal_Overlay_MatterFab_Active = new CustomIcon("TileEntities/adv_machine_matterfab_active"); + public static final CustomIcon Overlay_MatterFab_Active = Internal_Overlay_MatterFab_Active; + + private static final CustomIcon Internal_Overlay_MatterFab_Animated = new CustomIcon("TileEntities/adv_machine_matterfab_animated"); + public static final CustomIcon Overlay_MatterFab_Animated = Internal_Overlay_MatterFab_Animated; + private static final CustomIcon Internal_Overlay_MatterFab_Active_Animated = new CustomIcon("TileEntities/adv_machine_matterfab_active_animated"); + public static final CustomIcon Overlay_MatterFab_Active_Animated = Internal_Overlay_MatterFab_Active_Animated; + + private static final CustomIcon Internal_Overlay_Oil = new CustomIcon("TileEntities/adv_machine_oil"); + public static final CustomIcon Overlay_Oil = Internal_Overlay_Oil; + private static final CustomIcon Internal_Overlay_UU_Matter = new CustomIcon("TileEntities/adv_machine_uum"); + public static final CustomIcon Overlay_UU_Matter = Internal_Overlay_UU_Matter; + + // GT++ Tiered Hulls + public static final CustomIcon TEXTURE_CASING_TIERED_ULV = new CustomIcon("iconsets/TieredHulls/CASING_ULV"); + public static final CustomIcon TEXTURE_CASING_TIERED_LV = new CustomIcon("iconsets/TieredHulls/CASING_LV"); + public static final CustomIcon TEXTURE_CASING_TIERED_MV = new CustomIcon("iconsets/TieredHulls/CASING_MV"); + public static final CustomIcon TEXTURE_CASING_TIERED_HV = new CustomIcon("iconsets/TieredHulls/CASING_HV"); + public static final CustomIcon TEXTURE_CASING_TIERED_EV = new CustomIcon("iconsets/TieredHulls/CASING_EV"); + public static final CustomIcon TEXTURE_CASING_TIERED_IV = new CustomIcon("iconsets/TieredHulls/CASING_IV"); + public static final CustomIcon TEXTURE_CASING_TIERED_LuV = new CustomIcon("iconsets/TieredHulls/CASING_LuV"); + public static final CustomIcon TEXTURE_CASING_TIERED_ZPM = new CustomIcon("iconsets/TieredHulls/CASING_ZPM"); + public static final CustomIcon TEXTURE_CASING_TIERED_UV = new CustomIcon("iconsets/TieredHulls/CASING_UV"); + public static final CustomIcon TEXTURE_CASING_TIERED_MAX = new CustomIcon("iconsets/TieredHulls/CASING_MAX"); + + //Metroid related + public static final CustomIcon TEXTURE_METAL_PANEL_A = new CustomIcon("metro/TEXTURE_METAL_PANEL_A"); + public static final CustomIcon TEXTURE_METAL_PANEL_B = new CustomIcon("metro/TEXTURE_METAL_PANEL_B"); + public static final CustomIcon TEXTURE_METAL_PANEL_C = new CustomIcon("metro/TEXTURE_METAL_PANEL_C"); + public static final CustomIcon TEXTURE_METAL_PANEL_D = new CustomIcon("metro/TEXTURE_METAL_PANEL_D"); + public static final CustomIcon TEXTURE_METAL_PANEL_E = new CustomIcon("metro/TEXTURE_METAL_PANEL_E"); + public static final CustomIcon TEXTURE_METAL_PANEL_F = new CustomIcon("metro/TEXTURE_METAL_PANEL_F"); + public static final CustomIcon TEXTURE_METAL_PANEL_G = new CustomIcon("metro/TEXTURE_METAL_PANEL_G"); + public static final CustomIcon TEXTURE_METAL_PANEL_H = new CustomIcon("metro/TEXTURE_METAL_PANEL_H"); + public static final CustomIcon TEXTURE_METAL_PANEL_I = new CustomIcon("metro/TEXTURE_METAL_PANEL_I"); + + public static final CustomIcon TEXTURE_MAGIC_PANEL_A = new CustomIcon("metro/TEXTURE_MAGIC_A"); + + public static final CustomIcon TEXTURE_ORGANIC_PANEL_A = new CustomIcon("metro/TEXTURE_ORGANIC_PANEL_A"); + public static final CustomIcon TEXTURE_ORGANIC_PANEL_A_GLOWING = new CustomIcon("metro/TEXTURE_ORGANIC_PANEL_A_GLOWING"); + + public static final CustomIcon TEXTURE_STONE_BIRD_A = new CustomIcon("metro/TEXTURE_STONE_BIRD_A"); + public static final CustomIcon TEXTURE_STONE_BIRD_A_LEFT = new CustomIcon("metro/TEXTURE_STONE_BIRD_A_LEFT"); + public static final CustomIcon TEXTURE_STONE_BIRD_A_RIGHT = new CustomIcon("metro/TEXTURE_STONE_BIRD_A_RIGHT"); + public static final CustomIcon TEXTURE_STONE_RED_A = new CustomIcon("metro/TEXTURE_STONE_RED_A"); + public static final CustomIcon TEXTURE_STONE_RED_B = new CustomIcon("metro/TEXTURE_STONE_RED_B"); + public static final CustomIcon TEXTURE_STONE_BLUE_A = new CustomIcon("metro/TEXTURE_STONE_BLUE_A"); + public static final CustomIcon TEXTURE_STONE_GREEN_A = new CustomIcon("metro/TEXTURE_STONE_GREEN_A"); + public static final CustomIcon TEXTURE_STONE_TABLET_A = new CustomIcon("metro/TEXTURE_STONE_TABLET_A"); + public static final CustomIcon TEXTURE_STONE_TABLET_B = new CustomIcon("metro/TEXTURE_STONE_TABLET_B"); + + public static final CustomIcon TEXTURE_TECH_A = new CustomIcon("metro/TEXTURE_TECH_A"); + public static final CustomIcon TEXTURE_TECH_B = new CustomIcon("metro/TEXTURE_TECH_B"); + public static final CustomIcon TEXTURE_TECH_C = new CustomIcon("metro/TEXTURE_TECH_C"); + + public static final CustomIcon TEXTURE_TECH_PANEL_A = new CustomIcon("metro/TEXTURE_TECH_PANEL_A"); + public static final CustomIcon TEXTURE_TECH_PANEL_B = new CustomIcon("metro/TEXTURE_TECH_PANEL_B"); + public static final CustomIcon TEXTURE_TECH_PANEL_C = new CustomIcon("metro/TEXTURE_TECH_PANEL_C"); + public static final CustomIcon TEXTURE_TECH_PANEL_D = new CustomIcon("metro/TEXTURE_TECH_PANEL_D"); + + public static final CustomIcon TEXTURE_TECH_PANEL_RADIOACTIVE = new CustomIcon("TileEntities/DecayablesChest_bottom"); + public static final CustomIcon TEXTURE_TECH_PANEL_RADIOACTIVE_ALT = new CustomIcon("TileEntities/DecayablesChest_top"); + + // LFTR Single blocks + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_FRONT = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_FRONT"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_FRONT_ACTIVE = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_FRONT_ACTIVE"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_SIDE = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_SIDE"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_SIDE_ACTIVE = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_SIDE_ACTIVE"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_TOP = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_TOP"); + public static final CustomIcon OVERLAY_REACTOR_COLDTRAP_TOP_ACTIVE = new CustomIcon("TileEntities/ReactorColdTrap/OVERLAY_TOP_ACTIVE"); + + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_FRONT = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_FRONT"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_FRONT_ACTIVE = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_FRONT_ACTIVE"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_SIDE = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_SIDE"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_SIDE_ACTIVE = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_SIDE_ACTIVE"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_TOP = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_TOP"); + public static final CustomIcon OVERLAY_REACTOR_PROCESSINGUNIT_TOP_ACTIVE = new CustomIcon("TileEntities/ReactorProcessingUnit/OVERLAY_TOP_ACTIVE"); + + + //Overlay Arrays + public static ITexture[] OVERLAYS_ENERGY_OUT_BUFFER = new ITexture[]{ + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{220, 220, 220, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{220, 220, 220, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{255, 100, 0, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{255, 255, 30, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{128, 128, 128, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_BUFFER, + new short[]{240, 240, 245, 0})}; + + public static ITexture[] OVERLAYS_ENERGY_OUT_MULTI_BUFFER = new ITexture[]{ + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{220, 220, 220, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{220, 220, 220, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{255, 100, 0, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{255, 255, 30, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{128, 128, 128, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{240, 240, 245, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_ENERGY_OUT_MULTI_BUFFER, + new short[]{240, 240, 245, 0})}; + + public static ITexture[] OVERLAYS_CABINET_FRONT = new ITexture[]{ + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_1, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_2, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_3, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_4, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_5, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_6, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_7, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_8, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_9, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_10, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_11, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_12, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_13, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_14, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_15, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_CABINET_16, + new short[]{255, 255, 255, 0}),}; + + public static ITexture[] OVERLAYS_COMPARTMENT_FRONT = new ITexture[]{ + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_1, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_2, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_3, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_4, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_5, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_6, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_7, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_8, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_9, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_10, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_11, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_12, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_13, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_14, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_15, + new short[]{255, 255, 255, 0}), + new GT_RenderedTexture((IIconContainer) OVERLAY_COMPARTMENT_16, + new short[]{255, 255, 255, 0}),}; + + public static IIconContainer[] CONNECTED_FUSION_HULLS = new IIconContainer[]{ + TEXTURE_CASING_FUSION_COIL_II_1, TEXTURE_CASING_FUSION_COIL_II_2, TEXTURE_CASING_FUSION_COIL_II_3, + TEXTURE_CASING_FUSION_COIL_II_4, TEXTURE_CASING_FUSION_COIL_II_5, TEXTURE_CASING_FUSION_COIL_II_6, + TEXTURE_CASING_FUSION_COIL_II_7, TEXTURE_CASING_FUSION_COIL_II_8, TEXTURE_CASING_FUSION_COIL_II_9, + TEXTURE_CASING_FUSION_COIL_II_10, TEXTURE_CASING_FUSION_COIL_II_11, TEXTURE_CASING_FUSION_COIL_II_12}; + + public static IIconContainer[] TIERED_MACHINE_HULLS = new IIconContainer[]{ + TEXTURE_CASING_TIERED_ULV, + TEXTURE_CASING_TIERED_LV, + TEXTURE_CASING_TIERED_MV, + TEXTURE_CASING_TIERED_HV, + TEXTURE_CASING_TIERED_EV, + TEXTURE_CASING_TIERED_IV, + TEXTURE_CASING_TIERED_LuV, + TEXTURE_CASING_TIERED_ZPM, + TEXTURE_CASING_TIERED_UV, + TEXTURE_CASING_TIERED_MAX}; + + + public static Object Casing_Material_Turbine; + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java new file mode 100644 index 0000000000..cc5cf3d55e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java @@ -0,0 +1,32 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class TexturesGtCutomCovers { + + public static final CustomIcon[] TEXTURE_ZTONES_AGON = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_ISZM = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_KORP = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_JELT = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_BITT = new CustomIcon[16]; + + public static void init() { + generateZTones(); + } + + private static void generateZTones() { + // ZTONES + String[] aZtoneCoverTextureNames = new String[] { "agon", "iszm", "korp", "jelt", "bitt" }; + int aArrayIndex = 0; + CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, + TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT }; + + for (CustomIcon[] t : aArrays) { + for (int s = 0; s < 16; s++) { + t[s] = new CustomIcon("Ztones", "sets/" + aZtoneCoverTextureNames[aArrayIndex] + "/"+aZtoneCoverTextureNames[aArrayIndex]+"_ (" + s + ")"); + } + aArrayIndex++; + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java new file mode 100644 index 0000000000..ee104eaca3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtTools.java @@ -0,0 +1,61 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; + +public final class TexturesGtTools { + + public final static CustomIcon SKOOKUM_CHOOCHER = new CustomIcon("iconsets/SKOOKUMCHOOCHER"); + public final static CustomIcon ANGLE_GRINDER = new CustomIcon("iconsets/ANGLE_GRINDER"); + public final static CustomIcon ELECTRIC_SNIPS = new CustomIcon("iconsets/ELECTRIC_SNIPS"); + public final static CustomIcon ELECTRIC_LIGHTER = new CustomIcon("iconsets/ELECTRIC_LIGHTER"); + public final static CustomIcon ELECTRIC_BUTCHER_KNIFE = new CustomIcon("iconsets/ELECTRIC_BUTCHER_KNIFE"); + + + + + + + + + public final static class CustomIcon implements IIconContainer, Runnable { + protected IIcon mIcon, mOverlay; + protected final String mIconName; + + public CustomIcon(final String aIconName) { + this.mIconName = aIconName; + Logger.INFO("Constructing a Custom Texture. " + this.mIconName); + GregTech_API.sGTItemIconload.add(this); + } + + @Override + public IIcon getIcon() { + return this.mIcon; + } + + @Override + public IIcon getOverlayIcon() { + return this.mOverlay; + } + + @Override + public void run() { + this.mIcon = GregTech_API.sItemIcons.registerIcon(CORE.MODID + ":" + this.mIconName); + //Utils.LOG_INFO("Registering a Custom Texture. "+mIcon.g); + this.mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.MODID + ":" + this.mIconName + "_OVERLAY"); + } + + @Override + public ResourceLocation getTextureFile() { + return TextureMap.locationItemsTexture; + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java new file mode 100644 index 0000000000..c3d6a655c3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/textures/turbine/LargeTurbineTextureHandler.java @@ -0,0 +1,318 @@ +/* +package gtPlusPlus.xmod.gregtech.common.blocks.textures.turbine; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine; +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks4; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class LargeTurbineTextureHandler { + + */ +/** + * LP Turbines + *//* + + private static CustomIcon aTex1_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_ACTIVE_1"); + private static CustomIcon aTex1 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_1"); + private static CustomIcon aTex2_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_ACTIVE_2"); + private static CustomIcon aTex2 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_2"); + private static CustomIcon aTex3_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_ACTIVE_3"); + private static CustomIcon aTex3 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_3"); + private static CustomIcon aTex4_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_ACTIVE_4"); + private static CustomIcon aTex4 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_4"); + private static CustomIcon aTex5_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_ACTIVE_5"); + private static CustomIcon aTex5 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_5"); + private static CustomIcon aTex6_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_ACTIVE_6"); + private static CustomIcon aTex6 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_6"); + private static CustomIcon aTex7_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_ACTIVE_7"); + private static CustomIcon aTex7 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_7"); + private static CustomIcon aTex8_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_ACTIVE_8"); + private static CustomIcon aTex8 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_8"); + private static CustomIcon aTex9_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_ACTIVE_9"); + private static CustomIcon aTex9 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_LP_9"); + + private static CustomIcon frontFace_0 = (aTex1); + private static CustomIcon frontFaceActive_0 = (aTex1_Active); + private static CustomIcon frontFace_1 = (aTex2); + private static CustomIcon frontFaceActive_1 = (aTex2_Active); + private static CustomIcon frontFace_2 = (aTex3); + private static CustomIcon frontFaceActive_2 = (aTex3_Active); + private static CustomIcon frontFace_3 = (aTex4); + private static CustomIcon frontFaceActive_3 = (aTex4_Active); + public static CustomIcon frontFace_4 = (aTex5); + public static CustomIcon frontFaceActive_4 = (aTex5_Active); + private static CustomIcon frontFace_5 = (aTex6); + private static CustomIcon frontFaceActive_5 = (aTex6_Active); + private static CustomIcon frontFace_6 = (aTex7); + private static CustomIcon frontFaceActive_6 = (aTex7_Active); + private static CustomIcon frontFace_7 = (aTex8); + private static CustomIcon frontFaceActive_7 = (aTex8_Active); + private static CustomIcon frontFace_8 = (aTex9); + private static CustomIcon frontFaceActive_8 = (aTex9_Active); + + CustomIcon[] OVERLAY_LP_TURBINE = new CustomIcon[]{ + frontFace_0, + frontFace_1, + frontFace_2, + frontFace_3, + frontFace_4, + frontFace_5, + frontFace_6, + frontFace_7, + frontFace_8 + }; + + CustomIcon[] OVERLAY_LP_TURBINE_ACTIVE = new CustomIcon[]{ + frontFaceActive_0, + frontFaceActive_1, + frontFaceActive_2, + frontFaceActive_3, + frontFaceActive_4, + frontFaceActive_5, + frontFaceActive_6, + frontFaceActive_7, + frontFaceActive_8 + }; + + + */ +/** + * HP Turbines + *//* + + private static CustomIcon aTexHP1_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_ACTIVE_1"); + private static CustomIcon aTexHP1 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_1"); + private static CustomIcon aTexHP2_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_ACTIVE_2"); + private static CustomIcon aTexHP2 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_2"); + private static CustomIcon aTexHP3_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_ACTIVE_3"); + private static CustomIcon aTexHP3 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_3"); + private static CustomIcon aTexHP4_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_ACTIVE_4"); + private static CustomIcon aTexHP4 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_4"); + private static CustomIcon aTexHP5_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_ACTIVE_5"); + private static CustomIcon aTexHP5 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_5"); + private static CustomIcon aTexHP6_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_ACTIVE_6"); + private static CustomIcon aTexHP6 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_6"); + private static CustomIcon aTexHP7_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_ACTIVE_7"); + private static CustomIcon aTexHP7 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_7"); + private static CustomIcon aTexHP8_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_ACTIVE_8"); + private static CustomIcon aTexHP8 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_8"); + private static CustomIcon aTexHP9_Active = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_ACTIVE_9"); + private static CustomIcon aTexHP9 = new CustomIcon("iconsets/BigTurbine/LARGE_TURBINE_HP_9"); + + private static CustomIcon frontFaceHP_0 = (aTexHP1); + private static CustomIcon frontFaceHPActive_0 = (aTexHP1_Active); + private static CustomIcon frontFaceHP_1 = (aTexHP2); + private static CustomIcon frontFaceHPActive_1 = (aTexHP2_Active); + private static CustomIcon frontFaceHP_2 = (aTexHP3); + private static CustomIcon frontFaceHPActive_2 = (aTexHP3_Active); + private static CustomIcon frontFaceHP_3 = (aTexHP4); + private static CustomIcon frontFaceHPActive_3 = (aTexHP4_Active); + public static CustomIcon frontFaceHP_4 = (aTexHP5); + public static CustomIcon frontFaceHPActive_4 = (aTexHP5_Active); + private static CustomIcon frontFaceHP_5 = (aTexHP6); + private static CustomIcon frontFaceHPActive_5 = (aTexHP6_Active); + private static CustomIcon frontFaceHP_6 = (aTexHP7); + private static CustomIcon frontFaceHPActive_6 = (aTexHP7_Active); + private static CustomIcon frontFaceHP_7 = (aTexHP8); + private static CustomIcon frontFaceHPActive_7 = (aTexHP8_Active); + private static CustomIcon frontFaceHP_8 = (aTexHP9); + private static CustomIcon frontFaceHPActive_8 = (aTexHP9_Active); + + CustomIcon[] OVERLAY_HP_TURBINE = new CustomIcon[]{ + frontFaceHP_0, + frontFaceHP_1, + frontFaceHP_2, + frontFaceHP_3, + frontFaceHP_4, + frontFaceHP_5, + frontFaceHP_6, + frontFaceHP_7, + frontFaceHP_8 + }; + + CustomIcon[] OVERLAY_HP_TURBINE_ACTIVE = new CustomIcon[]{ + frontFaceHPActive_0, + frontFaceHPActive_1, + frontFaceHPActive_2, + frontFaceHPActive_3, + frontFaceHPActive_4, + frontFaceHPActive_5, + frontFaceHPActive_6, + frontFaceHPActive_7, + frontFaceHPActive_8 + }; + + + + public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord, final int aSide, final GregtechMetaCasingBlocks4 thisBlock) { + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + + //7 - shaft + //8 LP + //9 HP + + CustomIcon[] mGetCurrentTextureSet = null, mGetCurrentTextureSet_ACTIVE = null; + + + if (tMeta <= 6 || tMeta >= 10) { + return GregtechMetaCasingBlocks4.getStaticIcon((byte) aSide, (byte) tMeta); + } + else { + if (tMeta == 8) { + mGetCurrentTextureSet = OVERLAY_LP_TURBINE; + mGetCurrentTextureSet_ACTIVE = OVERLAY_LP_TURBINE_ACTIVE; + } + else if (tMeta == 9) { + mGetCurrentTextureSet = OVERLAY_HP_TURBINE; + mGetCurrentTextureSet_ACTIVE = OVERLAY_HP_TURBINE_ACTIVE; + } + if (mGetCurrentTextureSet == null || mGetCurrentTextureSet_ACTIVE == null) { + return GregtechMetaCasingBlocks4.getStaticIcon((byte) aSide, (byte) tMeta); + } + + + + if ((aSide == 2) || (aSide == 3)) { + TileEntity tTileEntity; + IMetaTileEntity tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[0].getIcon(); + } + return mGetCurrentTextureSet[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[3].getIcon(); + } + return mGetCurrentTextureSet[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[6].getIcon(); + } + return mGetCurrentTextureSet[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[1].getIcon(); + } + return mGetCurrentTextureSet[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[7].getIcon(); + } + return mGetCurrentTextureSet[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[8].getIcon(); + } + return mGetCurrentTextureSet[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[5].getIcon(); + } + return mGetCurrentTextureSet[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[2].getIcon(); + } + return mGetCurrentTextureSet[2].getIcon(); + } + } else if ((aSide == 4) || (aSide == 5)) { + TileEntity tTileEntity; + Object tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[0].getIcon(); + } + return mGetCurrentTextureSet[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[3].getIcon(); + } + return mGetCurrentTextureSet[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[6].getIcon(); + } + return mGetCurrentTextureSet[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[1].getIcon(); + } + return mGetCurrentTextureSet[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[7].getIcon(); + } + return mGetCurrentTextureSet[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[8].getIcon(); + } + return mGetCurrentTextureSet[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[5].getIcon(); + } + return mGetCurrentTextureSet[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine))) { + if (isUsingAnimatedTexture(tTileEntity)) { + return mGetCurrentTextureSet_ACTIVE[2].getIcon(); + } + return mGetCurrentTextureSet[2].getIcon(); + } + } + } + return GregtechMetaCasingBlocks4.getStaticIcon((byte) aSide, (byte) tMeta); + } + + public boolean isUsingAnimatedTexture(TileEntity tTileEntity) { + boolean aVal = true; + */ +/*IGregTechTileEntity aTile; + if (tTileEntity instanceof IGregTechTileEntity) { + aTile = (IGregTechTileEntity) tTileEntity; + if (aTile != null) { + final IMetaTileEntity aMetaTileEntity = aTile.getMetaTileEntity(); + if (aMetaTileEntity != null && aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { + aVal = ((GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity).isControllerActive(); + Logger.INFO("Returning "+aVal+" as Rotor Assembly controller status"); + } + } + } *//* + + return aVal; + } + + public GT_MetaTileEntity_Hatch_Turbine isTurbineHatch(final IGregTechTileEntity aTileEntity) { + if (aTileEntity != null) { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity != null && aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { + return (GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity; + } + } + return null; + } + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java new file mode 100644 index 0000000000..ca7cbca5f8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java @@ -0,0 +1,87 @@ +package gtPlusPlus.xmod.gregtech.common.blueprint; + +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.xmod.gregtech.api.objects.MultiblockBlueprint; +import gtPlusPlus.xmod.gregtech.api.objects.MultiblockLayer; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; + +public class Blueprint_Generic_3x3 extends MultiblockBlueprint { + + public Blueprint_Generic_3x3(Pair<Block, Integer> aCasing, int aTextureID) { + super(3, 3, 3, 10, aTextureID); + + // Top/Bottom + MultiblockLayer a0 = new MultiblockLayer(3, 3); + Block aCasingBlock_1 = aCasing.getKey(); + int aMeta = aCasing.getValue(); + a0.addBlockForPos(aCasingBlock_1, aMeta, 0, 0, true); + a0.addBlockForPos(aCasingBlock_1, aMeta, 0, 1, true); + a0.addBlockForPos(aCasingBlock_1, aMeta, 0, 2, true); + a0.addBlockForPos(aCasingBlock_1, aMeta, 1, 0, true); + a0.addBlockForPos(aCasingBlock_1, aMeta, 1, 1, true); + a0.addBlockForPos(aCasingBlock_1, aMeta, 1, 2, true); + a0.addBlockForPos(aCasingBlock_1, aMeta, 2, 0, true); + a0.addBlockForPos(aCasingBlock_1, aMeta, 2, 1, true); + a0.addBlockForPos(aCasingBlock_1, aMeta, 2, 2, true); + a0.lock(true); + + //Layer one + MultiblockLayer a1 = new MultiblockLayer(3, 3); + a1.addBlockForPos(aCasingBlock_1, aMeta, 0, 0, true); + a1.addBlockForPos(aCasingBlock_1, aMeta, 0, 1, true); + a1.addBlockForPos(aCasingBlock_1, aMeta, 0, 2, true); + a1.addBlockForPos(aCasingBlock_1, aMeta, 1, 0, true); + a1.addBlockForPos(Blocks.air, 0, 1, 1, true); + a1.addController(1, 2); + a1.addBlockForPos(aCasingBlock_1, aMeta, 2, 0, true); + a1.addBlockForPos(aCasingBlock_1, aMeta, 2, 1, true); + a1.addBlockForPos(aCasingBlock_1, aMeta, 2, 2, true); + a1.lock(true); + + this.setLayer(a0, 0); + this.setLayer(a1, 1); + this.setLayer(a0, 2); + } + + @Override + public int getMinimumInputBus() { + return 0; + } + + @Override + public int getMinimumInputHatch() { + return 0; + } + + @Override + public int getMinimumOutputBus() { + return 0; + } + + @Override + public int getMinimumOutputHatch() { + return 0; + } + + @Override + public int getMinimumInputEnergy() { + return 1; + } + + @Override + public int getMinimumOutputEnergy() { + return 0; + } + + @Override + public int getMinimumMaintHatch() { + return 1; + } + + @Override + public int getMinimumMufflers() { + return 1; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java new file mode 100644 index 0000000000..3551172904 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java @@ -0,0 +1,137 @@ +package gtPlusPlus.xmod.gregtech.common.blueprint; + +import gregtech.api.enums.TAE; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.xmod.gregtech.api.objects.MultiblockBlueprint; +import gtPlusPlus.xmod.gregtech.api.objects.MultiblockLayer; +import net.minecraft.block.Block; + +public class Blueprint_LFTR extends MultiblockBlueprint { + + public Blueprint_LFTR() { + super(7, 4, 7, 10, TAE.GTPP_INDEX(12)); + + + Block aCasingMain = ModBlocks.blockCasingsMisc; + int aMetaCasingMain = 12; + int aMetaCasingSecondary = 13; + + + + /** + * First Layer (All edges can be Hatches, controller is centered in the front) + */ + + MultiblockLayer a0 = new MultiblockLayer(7, 7); + for (int i = 0; i < 7; i++) { + a0.addBlockForPos(aCasingMain, aMetaCasingMain, i, 0, true); + } + for (int i = 0; i < 7; i++) { + for (int u = 1; u < 6; u++) { + a0.addBlockForPos(aCasingMain, aMetaCasingMain, i, u, i == 0 ? true : i == 6 ? true : false); + } + } + for (int i = 0; i < 7; i++) { + if (i != 3) { + a0.addBlockForPos(aCasingMain, aMetaCasingMain, i, 6, true); + } + else { + a0.addController(i, 6); + } + } + a0.lock(true); + + + + + /** + * Middle Layer(s) + */ + + MultiblockLayer a1 = new MultiblockLayer(7, 7); + for (int i = 0; i < 7; i++) { + a1.addBlockForPos(aCasingMain, aMetaCasingSecondary, i, 0, false); + } + for (int i = 0; i < 7; i++) { + for (int u = 1; u < 6; u++) { + if (i == 0 || i == 6) + a1.addBlockForPos(aCasingMain, aMetaCasingSecondary, i, u, false); + } + } + for (int i = 0; i < 7; i++) { + a1.addBlockForPos(aCasingMain, aMetaCasingSecondary, i, 6, false); + + } + a1.lock(true); + + + /** + * Top Layer (All edges can be Hatches, Mufflers required in inner 3x3) + */ + + MultiblockLayer a2 = new MultiblockLayer(7, 7); + for (int i = 0; i < 7; i++) { + a2.addBlockForPos(aCasingMain, aMetaCasingMain, i, 0, true); + } + for (int i = 0; i < 7; i++) { + for (int u = 1; u < 6; u++) { + if ((i == 2 || i == 3 || i == 4) && (u == 2 || u ==3 || u == 4)) { + a2.addMuffler(aCasingMain, aMetaCasingMain, i, u); + } + else { + a2.addBlockForPos(aCasingMain, aMetaCasingMain, i, u, true); + } + } + } + for (int i = 0; i < 7; i++) { + a2.addBlockForPos(aCasingMain, aMetaCasingMain, i, 6, true); + } + a2.lock(true); + + this.setLayer(a0, 0); + this.setLayer(a1, 1); + this.setLayer(a1, 2); + this.setLayer(a2, 3); + } + + @Override + public int getMinimumInputBus() { + return 0; + } + + @Override + public int getMinimumInputHatch() { + return 4; + } + + @Override + public int getMinimumOutputBus() { + return 0; + } + + @Override + public int getMinimumOutputHatch() { + return 4; + } + + @Override + public int getMinimumInputEnergy() { + return 0; + } + + @Override + public int getMinimumOutputEnergy() { + return 4; + } + + @Override + public int getMinimumMaintHatch() { + return 1; + } + + @Override + public int getMinimumMufflers() { + return 4; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java new file mode 100644 index 0000000000..2fba1b0448 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java @@ -0,0 +1,102 @@ +package gtPlusPlus.xmod.gregtech.common.covers; + +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_AGON; +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_BITT; +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_ISZM; +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_JELT; +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_KORP; + +import cpw.mods.fml.common.Loader; +import gtPlusPlus.core.lib.VanillaColours; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers; +import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem; +import gtPlusPlus.xmod.gregtech.common.items.covers.MetaItemCoverCasings; + +public class CoverManager { + + // ZTones + public static MetaCustomCoverItem Cover_Agon; + public static MetaCustomCoverItem Cover_Iszm; + public static MetaCustomCoverItem Cover_Korp; + public static MetaCustomCoverItem Cover_Jelt; + public static MetaCustomCoverItem Cover_Bitt; + + // GT + public static MetaItemCoverCasings Cover_Gt_Machine_Casing; + + public static void generateCustomCovers() { + + // init textures + TexturesGtCutomCovers.init(); + + // GT Machine Casings + Cover_Gt_Machine_Casing = new MetaItemCoverCasings(); + + if (Loader.isModLoaded("Ztones")) { + String[] aZtoneCoverTextureNames = new String[] { "agon", "iszm", "korp", "jelt", "bitt" }; + MetaCustomCoverItem[] aZtoneCoverItems = new MetaCustomCoverItem[] { Cover_Agon, Cover_Iszm, Cover_Korp, + Cover_Jelt, Cover_Bitt }; + CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, + TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT }; + short[][][] aRGB = new short[][][] { ZTONES.RGB_AGON, ZTONES.RGB_ISZM, ZTONES.RGB_KORP, ZTONES.RGB_JELT, + ZTONES.RGB_BITT }; + for (int y = 0; y < aZtoneCoverTextureNames.length; y++) { + aZtoneCoverItems[y] = new MetaCustomCoverItem("Ztones", 16, aZtoneCoverTextureNames[y], aArrays[y], + aRGB[y]); + } + } + + } + + final static class ZTONES { + + private static final short[][] RGB_AGON = new short[][] { VanillaColours.DYE_WHITE.getAsShort(), + VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_LIME.getAsShort(), + VanillaColours.DYE_GREEN.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(), + VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(), + VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(), + VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_BROWN.getAsShort(), + VanillaColours.DYE_BLACK.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_LIGHT_GRAY.getAsShort(), }; + private static final short[][] RGB_ISZM = new short[][] { VanillaColours.DYE_LIGHT_GRAY.getAsShort(), + VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(), + VanillaColours.DYE_DARK_BLUE.getAsShort(), VanillaColours.DYE_RED.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_CYAN.getAsShort(), + VanillaColours.DYE_YELLOW.getAsShort(), VanillaColours.DYE_RED.getAsShort(), + VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(), + VanillaColours.DYE_DARK_PURPLE.getAsShort(), + }; + private static final short[][] RGB_KORP = new short[][] { new short[] { 125, 125, 125 }, + VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), + VanillaColours.DYE_DARK_GRAY.getAsShort(), new short[] { 22, 156, 156 }, new short[] { 22, 156, 156 }, + VanillaColours.DYE_DARK_GRAY.getAsShort(), VanillaColours.DYE_DARK_GRAY.getAsShort(), }; + private static final short[][] RGB_JELT = new short[][] { VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_ORANGE.getAsShort(), }; + private static final short[][] RGB_BITT = new short[][] { VanillaColours.DYE_BLACK.getAsShort(), + VanillaColours.DYE_WHITE.getAsShort(), VanillaColours.DYE_YELLOW.getAsShort(), + VanillaColours.DYE_LIME.getAsShort(), VanillaColours.DYE_GREEN.getAsShort(), + VanillaColours.DYE_CYAN.getAsShort(), VanillaColours.DYE_LIGHT_BLUE.getAsShort(), + VanillaColours.DYE_LIGHT_BLUE.getAsShort(), VanillaColours.DYE_DARK_BLUE.getAsShort(), + VanillaColours.DYE_DARK_PURPLE.getAsShort(), VanillaColours.DYE_LIGHT_PURPLE.getAsShort(), + VanillaColours.DYE_PINK.getAsShort(), VanillaColours.DYE_RED.getAsShort(), + VanillaColours.DYE_RED.getAsShort(), VanillaColours.DYE_ORANGE.getAsShort(), + VanillaColours.DYE_BROWN.getAsShort(), }; + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java new file mode 100644 index 0000000000..a88fbc0d66 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow.java @@ -0,0 +1,247 @@ +package gtPlusPlus.xmod.gregtech.common.covers; + +import gregtech.api.gui.GT_GUICover; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.minecraft.LangUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; +import gregtech.api.gui.widgets.GT_GuiIntegerTextBox; +import gregtech.api.enums.GT_Values; +import gregtech.api.net.GT_Packet_TileEntityCover; + + +public class GTPP_Cover_Overflow extends GT_CoverBehavior { + + public final int mTransferRate; + public final int mInitialTransferRate; + public final int mMaxTransferRate; + + public GTPP_Cover_Overflow(int aTransferRate) { + this.mTransferRate = aTransferRate * 1000 / 10; + this.mInitialTransferRate = aTransferRate; + this.mMaxTransferRate = aTransferRate * 1000; + } + + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + long aTimer) { + if (aCoverVariable == 0) { + return aCoverVariable; + } + if ((aTileEntity instanceof IFluidHandler)) { + //Logger.INFO("Trying to Void via Overflow."); + IFluidHandler tTank1; + ForgeDirection directionFrom; + directionFrom = ForgeDirection.UNKNOWN; + tTank1 = (IFluidHandler) aTileEntity; + if (tTank1 != null) { + //Logger.INFO("Found Self. "+aSide); + //FluidStack aTankStack = tTank1.drain(ForgeDirection.UNKNOWN, 1, false); + FluidStack aTankStack = tTank1.getTankInfo(directionFrom)[0].fluid; + if (aTankStack != null) { + //Logger.INFO("Found Fluid inside self - "+aTankStack.getLocalizedName()+", overflow point set at "+aCoverVariable+"L and we have "+aTankStack.amount+"L inside."); + if (aTankStack.amount > aCoverVariable) { + int aAmountToDrain = aTankStack.amount - aCoverVariable; + //Logger.INFO("There is "+aAmountToDrain+" more fluid in the tank than we would like."); + if (aAmountToDrain > 0) { + FluidStack tLiquid = tTank1.drain(directionFrom, Math.abs(aAmountToDrain), true); + if (tLiquid != null) { + //Logger.INFO("Drained "+aAmountToDrain+"L."); + } + } + } + } + else { + //Logger.INFO("Could not simulate drain on self."); + } + } + } + return aCoverVariable; + } + + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } else { + aCoverVariable -= (mMaxTransferRate * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } + if (aCoverVariable > mMaxTransferRate) { + aCoverVariable = mInitialTransferRate; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxTransferRate; + } + GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("009", "Overflow point: ") + aCoverVariable + trans("010", "L")); + return aCoverVariable; + } + + public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + boolean aShift = aPlayer.isSneaking(); + int aAmount = aShift ? 128 : 8; + if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += aAmount; + } else { + aCoverVariable -= aAmount; + } + if (aCoverVariable > mMaxTransferRate) { + aCoverVariable = mInitialTransferRate; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxTransferRate; + } + GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("009", "Overflow point: ") + aCoverVariable + trans("010", "L")); + aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); + return true; + } + + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; + } + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return false; + } + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; + } + + public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 5; + } + + //GUI + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public Object getClientGUI(byte aSide, int aCoverID, int coverData, ICoverable aTileEntity) { + return new GTPP_Cover_Overflow.GUI(aSide, aCoverID, coverData, aTileEntity); + } + + private class GUI extends GT_GUICover { + private final byte side; + private final int coverID; + private GT_GuiIntegerTextBox tBox; + private int coverVariable; + + private static final int startX = 10; + private static final int startY = 25; + private static final int spaceX = 18; + private static final int spaceY = 18; + + private boolean warn = false; + + public GUI(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + super(aTileEntity, 176, 107, GT_Utility.intToStack(aCoverID)); + this.side = aSide; + this.coverID = aCoverID; + this.coverVariable = aCoverVariable; + + tBox = new GT_GuiIntegerTextBox(this, 2, startX + spaceX * 0, startY + spaceY * 0 + 8, spaceX * 4 - 3, 12); + tBox.setText(String.valueOf(this.coverVariable)); + tBox.setMaxStringLength(10); + } + + @Override + protected void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height) { + tBox.setFocused(true); + } + + @Override + public void drawExtras(int mouseX, int mouseY, float parTicks) { + super.drawExtras(mouseX, mouseY, parTicks); + this.getFontRenderer().drawString(trans("010", "L"), startX + spaceX * 4, 4 + startY + spaceY * 0 + 8, 0xFF555555); + if (warn) + this.getFontRenderer().drawString(trans("011","Max")+": "+coverVariable+"/"+mMaxTransferRate+" "+trans("010", "L"), startX + spaceX * 0, 4 + startY + spaceY * 1 + 6, 0xffff0000); + else + this.getFontRenderer().drawString(trans("011","Now")+": "+coverVariable+"/"+mMaxTransferRate+" "+trans("010", "L"), startX + spaceX * 0, 4 + startY + spaceY * 1 + 6, 0xFF555555); + } + @Override + public void onMouseWheel(int x, int y, int delta) { + for (GT_GuiIntegerTextBox box : textBoxes){ + if (box.isFocused()) { + int step = Math.max(1, Math.abs(delta / 120)); + step = (isShiftKeyDown() ? 50 : isCtrlKeyDown() ? 5 : 1) * (delta > 0 ? step : -step); + long i; + try { + i = Long.parseLong(box.getText()); + } catch (NumberFormatException e) { + return; + } + if (i > (Long.MAX_VALUE-1000)) + break; + + i = i + step; + if (i <= 0) + i = 0; + box.setText(String.valueOf(i)); + break; + } + } + } + + @Override + public void applyTextBox(GT_GuiIntegerTextBox box) { + long i; + String s = box.getText().trim(); + try { + i = Long.parseLong(s); + } catch (NumberFormatException e) { + resetTextBox(box); + return; + } + + warn = false; + if (box.id == 2) { + if (i > (long) mMaxTransferRate) { + i = mMaxTransferRate; + warn = true; + } else if (i < 0) { + i = 0; + } + coverVariable = (int) i; + } + box.setText(String.valueOf(i)); + GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); + } + + @Override + public void resetTextBox(GT_GuiIntegerTextBox box) { + if (box.id == 2) + box.setText(String.valueOf(coverVariable)); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java new file mode 100644 index 0000000000..0299447694 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_Overflow_Item.java @@ -0,0 +1,182 @@ +package gtPlusPlus.xmod.gregtech.common.covers; + +import java.lang.reflect.Field; +import java.util.HashMap; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_CoverBehavior; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.LangUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +public class GTPP_Cover_Overflow_Item extends GT_CoverBehavior { + + public final int mInitialCapacity; + public final int mMaxItemCapacity; + + public static final Class sQuantumChest; + public static final Class sSuperChestGTPP; + public static final Class sSuperChestGTNH; + public static HashMap<Integer, Field> mItemAmountFields = new HashMap<Integer, Field>(); + public static HashMap<Integer, Field> mItemTypeFields = new HashMap<Integer, Field>(); + + static { + sQuantumChest = ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest"); + sSuperChestGTPP = ReflectionUtils.getClass("gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest"); + if (CORE.GTNH) { + sSuperChestGTNH = ReflectionUtils.getClass("gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperChest"); + } + else { + sSuperChestGTNH = null; + } + if (sQuantumChest != null) { + mItemAmountFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemCount")); + mItemTypeFields.put(0, ReflectionUtils.getField(sQuantumChest, "mItemStack")); + } + if (sSuperChestGTPP != null) { + mItemAmountFields.put(1, ReflectionUtils.getField(sSuperChestGTPP, "mItemCount")); + mItemTypeFields.put(1, ReflectionUtils.getField(sSuperChestGTPP, "mItemStack")); + } + if (sSuperChestGTNH != null) { + mItemAmountFields.put(2, ReflectionUtils.getField(sSuperChestGTNH, "mItemCount")); + mItemTypeFields.put(2, ReflectionUtils.getField(sSuperChestGTNH, "mItemStack")); + } + } + + public GTPP_Cover_Overflow_Item(int aCapacity) { + this.mInitialCapacity = aCapacity; + this.mMaxItemCapacity = aCapacity * 1000; + } + + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + long aTimer) { + if (aCoverVariable == 0) { + return aCoverVariable; + } + + // Get the IGTTile + IGregTechTileEntity aGtTileEntity = aTileEntity.getIGregTechTileEntity(aTileEntity.getXCoord(), aTileEntity.getYCoord(), aTileEntity.getZCoord()); + if (aGtTileEntity == null) { + return aCoverVariable; + } + + // Get the MetaTile + final IMetaTileEntity aMetaTileEntity = aGtTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return aCoverVariable; + } + boolean didHandle = false; + // Special Case for everything I want to support. /facepalm + if (sQuantumChest != null && sQuantumChest.isInstance(aMetaTileEntity)) { + didHandle = handleDigitalChest(aMetaTileEntity, 0); + } + else if (sSuperChestGTPP.isInstance(aMetaTileEntity)) { + didHandle = handleDigitalChest(aMetaTileEntity, 1); + + } + else if (CORE.GTNH && sSuperChestGTNH != null && sSuperChestGTNH.isInstance(aMetaTileEntity)) { + didHandle = handleDigitalChest(aMetaTileEntity, 2); + } + + return aCoverVariable; + } + + private boolean handleDigitalChest(IMetaTileEntity aTile, int aType) { + int aItemAmount = (int) ReflectionUtils.getFieldValue(mItemAmountFields.get(aType), aTile); + ItemStack aItemType = (ItemStack) ReflectionUtils.getFieldValue(mItemTypeFields.get(aType), aTile); + + if (aItemType == null || aItemAmount <= 0) { + return false; + } + else { + if (aItemAmount > mInitialCapacity) { + int aNewItemAmount = mInitialCapacity; + ReflectionUtils.setField(aTile, mItemAmountFields.get(aType), aNewItemAmount); + } + } + return true; + } + + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += (mMaxItemCapacity * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } else { + aCoverVariable -= (mMaxItemCapacity * (aPlayer.isSneaking() ? 0.1f : 0.01f)); + } + if (aCoverVariable > mMaxItemCapacity) { + aCoverVariable = mInitialCapacity; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxItemCapacity; + } + GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("009", "Overflow point: ") + aCoverVariable + trans("010", "L")); + return aCoverVariable; + } + + public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + boolean aShift = aPlayer.isSneaking(); + int aAmount = aShift ? 128 : 8; + if (GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ)[0] >= 0.5F) { + aCoverVariable += aAmount; + } else { + aCoverVariable -= aAmount; + } + if (aCoverVariable > mMaxItemCapacity) { + aCoverVariable = mInitialCapacity; + } + if (aCoverVariable <= 0) { + aCoverVariable = mMaxItemCapacity; + } + GT_Utility.sendChatToPlayer(aPlayer, LangUtils.trans("009", "Overflow point: ") + aCoverVariable + trans("010", "L")); + aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); + return true; + } + + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; + } + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return true; + } + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return false; + } + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return true; + } + + public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 5; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java new file mode 100644 index 0000000000..65b59ce151 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java @@ -0,0 +1,186 @@ +package gtPlusPlus.xmod.gregtech.common.covers; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_CoverBehavior; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.util.minecraft.LangUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; + +public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { + + private static final Map<String, Integer> sConnectionStateForEntityMap = new ConcurrentHashMap<String, Integer>(); + private static final Map<String, String> sPrefixMap = new ConcurrentHashMap<String, String>(); + private static final int VALUE_OFF = 0; + private static final int VALUE_ON = 1; + + public static String generateUniqueKey(byte aSide, ICoverable aEntity) { + try { + BlockPos aPos = new BlockPos(aEntity.getIGregTechTileEntity(aEntity.getXCoord(), aEntity.getYCoord(), aEntity.getZCoord())); + ForgeDirection aDir = ForgeDirection.getOrientation(aSide); + String s = aEntity.getInventoryName()+"."+aPos.getUniqueIdentifier()+aDir.name(); + return s; + } + catch (Throwable t) {} + XSTR x = new XSTR(); + return "ERROR."+x.getSeed()+x.hashCode()+x.nextDouble()+".ID"; + } + + public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + PlayerUtils.messagePlayer(aPlayer, LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); + return super.onCoverRightclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); + } + + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + return super.onCoverScrewdriverclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); + } + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable); + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 1; + } + + @Override + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + long aTimer) { + try { + String aKey = generateUniqueKey(aSide, aTileEntity); + Integer b = sConnectionStateForEntityMap.get(aKey); + //Logger.INFO("Val: "+aCoverVariable); + if (b != null && aCoverVariable != b) { + aCoverVariable = b; + } + if (b == null) { + b = aCoverVariable; + sConnectionStateForEntityMap.put(aKey, b); + trySetState(aSide, b == VALUE_ON ? VALUE_ON : VALUE_OFF, aTileEntity); + } + } + catch (Throwable t) { + + } + return aCoverVariable; + } + + @Override + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + @Override + public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aCoverVariable); + } + + @Override + public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return super.alwaysLookConnected(aSide, aCoverID, aCoverVariable, aTileEntity); + } + + @Override + public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity) { + if (!getConnectionState(aCoverVariable)) { + return 0; + } + return super.getRedstoneInput(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity); + } + + @Override + public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) { + String aKey = generateUniqueKey(aSide, aTileEntity); + boolean state = getCoverConnections(aCover); + sPrefixMap.put(aKey, aCover.getUnlocalizedName()); + Logger.INFO("Mapping key "+aKey+" to "+state); + sConnectionStateForEntityMap.put(aKey, state ? VALUE_ON : VALUE_OFF); + Logger.INFO("Key Value: "+(state ? VALUE_ON : VALUE_OFF)); + //Try set cover state directly + //trySetState(aSide, state ? VALUE_ON : VALUE_OFF, aTileEntity); + super.placeCover(aSide, aCover, aTileEntity); + } + + @Override + public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + boolean aForced) { + String aKey = generateUniqueKey(aSide, aTileEntity); + sConnectionStateForEntityMap.remove(aKey); + //Logger.INFO("Unmapping key "+aKey+"."); + return true; + } + + public static boolean getConnectionState(int aCoverVar) { + return aCoverVar == VALUE_ON; + } + + private static final void trySetState(byte aSide, int aState, ICoverable aTile) { + //Try set cover state directly + if (aTile instanceof IGregTechTileEntity) { + IGregTechTileEntity gTileEntity = (IGregTechTileEntity) aTile; + if (gTileEntity != null) { + gTileEntity.setCoverDataAtSide(aSide, aState); + } + } + } + + + public static boolean getConnectionState(byte aSide, ICoverable aTile) { + String aKey = generateUniqueKey(aSide, aTile); + return getConnectionState(aKey); + } + + public static boolean getConnectionState(String aKey) { + Integer b = sConnectionStateForEntityMap.get(aKey); + //Logger.INFO("Get State: "+b+" | "+aKey); + return b != null ? b == VALUE_ON : false; + } + + public static final boolean getCoverConnections(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + return aNBT.getBoolean("AllowConnections"); + } + } + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java new file mode 100644 index 0000000000..70c7b2da23 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -0,0 +1,429 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_ModHandler; +import gregtech.common.items.GT_MetaGenerated_Item_01; +import gregtech.common.items.GT_MetaGenerated_Item_02; +import gregtech.common.items.GT_MetaGenerated_Tool_01; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; +import ic2.api.info.Info; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; + +public class ChargingHelper { + + private static Map<EntityPlayer, Pair<GregtechMetaWirelessCharger, Byte>> mValidPlayers = new HashMap<EntityPlayer, Pair<GregtechMetaWirelessCharger, Byte>>(); + protected static Map<BlockPos, GregtechMetaWirelessCharger> mChargerMap = new HashMap<BlockPos, GregtechMetaWirelessCharger>(); + private int mTickTimer = 0; + private final int mTickMultiplier = 20; + + //Called whenever the player is updated or ticked. + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerTick(LivingUpdateEvent event) { + try { + if (event.entity != null && event.entityLiving != null){ + if (event.entityLiving instanceof EntityPlayer){ + EntityPlayer mPlayerMan = (EntityPlayer) event.entityLiving; + + + if (mPlayerMan != null){ + //Utils.LOG_WARNING("Found Player."); + + if (Utils.isServer()){ + //Utils.LOG_WARNING("Found Server-Side."); + + mTickTimer++; + if (mTickTimer % mTickMultiplier == 0){ + + long mVoltage = 0; + long mEuStored = 0; + + if (!mChargerMap.isEmpty() && mValidPlayers.containsKey(mPlayerMan)){ + InventoryPlayer mPlayerInventory = mPlayerMan.inventory; + ItemStack[] mArmourContents = mPlayerInventory.armorInventory.clone(); + ItemStack[] mInventoryContents = mPlayerInventory.mainInventory.clone(); + + for (GregtechMetaWirelessCharger mEntityTemp : mChargerMap.values()){ + if (mEntityTemp != null){ + if (mPlayerMan.getEntityWorld().provider.dimensionId == mEntityTemp.getDimensionID()){ + mVoltage = mEntityTemp.maxEUInput(); + mEuStored = mEntityTemp.getEUVar(); + if (mVoltage > 0 && mEuStored >= mVoltage){ + + Map<EntityPlayer, UUID> LR = mEntityTemp.getLongRangeMap(); + Map<UUID, EntityPlayer> LO = mEntityTemp.getLocalMap(); + + long mStartingEu = mEntityTemp.getEUVar(); + long mCurrentEu = mEntityTemp.getEUVar(); + long mEuUsed = 0; + if (mEntityTemp.getMode() == 0){ + if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + } + else if (mEntityTemp.getMode() == 1){ + if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + } + else { + if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ + mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); + mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); + } + } + + if ((mEuUsed = (mStartingEu - mCurrentEu)) <= 0 && mEntityTemp != null){ + long mMaxDistance; + if (mEntityTemp.getMode() == 0){ + mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]); + } + else if (mEntityTemp.getMode() == 1){ + mMaxDistance = (mEntityTemp.getTier()*10); + } + else { + mMaxDistance = (4*GT_Values.V[mEntityTemp.getTier()]/2); + } + double mDistance = calculateDistance(mEntityTemp, mPlayerMan); + long mVoltageCost = MathUtils.findPercentageOfInt(mMaxDistance, (float) mDistance); + + if (mVoltageCost > 0){ + if (mVoltageCost > mEntityTemp.maxEUInput()){ + mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mEntityTemp.maxEUInput())); + } + else { + mEntityTemp.setEUVar((mEntityTemp.getEUVar()-mVoltageCost)); + } + } + } + } + } + } + } + } + } + } + } + } + } + } + + catch (Throwable t){ + //Utils.LOG_WARNING("State of Wireless Charger changed in an invalid way, this prevented a crash."); + + if (!mChargerMap.isEmpty()){ + for (GregtechMetaWirelessCharger r : mChargerMap.values()){ + if (r == null){ + mChargerMap.remove(r); + } + } + } + //t.printStackTrace(); + } + + + } + + public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ + if (mEntity == null){ + return false; + } + if (!mChargerMap.containsKey(mPos)){ + if (mChargerMap.put(mPos, mEntity) == null){ + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + public static boolean removeEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ + if (mEntity == null){ + return false; + } + if (mChargerMap.containsKey(mPos)){ + if (mChargerMap.remove(mPos, mEntity)){ + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + public static boolean addValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity){ + if (mEntity == null){ + return false; + } + Logger.WARNING("trying to map new player"); + if (mValidPlayers.containsKey(mPlayer)){ + Logger.WARNING("Key contains player already?"); + return false; + } + else { + Logger.WARNING("key not found, adding"); + Pair<GregtechMetaWirelessCharger, Byte> mEntry = new Pair<GregtechMetaWirelessCharger, Byte>(mEntity, (byte) mEntity.getMode()); + if (mValidPlayers.put(mPlayer, mEntry) == null){ + Logger.WARNING("Added a Player to the Tick Map."); + return true; + } + else { + Logger.WARNING("Tried to add player but it was already there?"); + return false; + } + } + } + + public static boolean removeValidPlayer(EntityPlayer mPlayer, GregtechMetaWirelessCharger mEntity){ + if (mEntity == null){ + return false; + } + Logger.WARNING("trying to remove player from map"); + if (mValidPlayers.containsKey(mPlayer)){ + Logger.WARNING("key found, removing"); + Pair<GregtechMetaWirelessCharger, Byte> mEntry = new Pair<GregtechMetaWirelessCharger, Byte>(mEntity, (byte) mEntity.getMode()); + if (mValidPlayers.remove(mPlayer, mEntry)){ + Logger.WARNING("Removed a Player to the Tick Map."); + return true; + } + else { + Logger.WARNING("Tried to remove player but it was not there?"); + return false; + } + } + else { + Logger.WARNING("Key does not contain player?"); + return false; + } + } + + public double calculateDistance(GregtechMetaWirelessCharger mEntityTemp, EntityPlayer mPlayerMan){ + if (mEntityTemp == null || mPlayerMan == null){ + return 0; + } + return mEntityTemp.getDistanceBetweenTwoPositions(mEntityTemp.getTileEntityPosition(), mEntityTemp.getPositionOfEntity(mPlayerMan)); + } + + public long chargeItems(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer){ + if (mEntity == null){ + return -100; + } + if (mItems == null || mItems.length == 0){ + return mEntity.getEUVar(); + } + long mInitialValue = mEntity.getEUVar(); + long mReturnValue = chargeItemsEx(mEntity, mItems, mPlayer); + return ((mReturnValue < mInitialValue) ? mReturnValue : mInitialValue); + } + + public long chargeItemsEx(GregtechMetaWirelessCharger mEntity, ItemStack[] mItems, EntityPlayer mPlayer){ + + //Bad Entity + if (mEntity == null){ + return -100; + } + //Bad Inventory + if (mItems == null || mItems.length == 0){ + return mEntity.getEUVar(); + } + //Set Variables to Charge + int mChargedItems = 0; + final int mTier = mEntity.getTier(); + final long mVoltage = mEntity.maxEUInput(); + long mEuStored = mEntity.getEUVar(); + final long mEuStoredOriginal = mEntity.getEUVar(); + //For Inventory Contents + + int mItemSlot = 0; + + for (ItemStack mTemp : mItems){ + mItemSlot++; + if (mTemp != null){ + Logger.WARNING("Slot "+mItemSlot+" contains "+mTemp.getDisplayName()); + } + //Is item Electrical + if (isItemValid(mTemp)){ + Logger.WARNING("1"); + + //Transfer Limit + double mItemEuTLimit = ((IElectricItem) mTemp.getItem()).getTransferLimit(mTemp); + //Check if Tile has more or equal EU to what can be transferred into the item. + if (mEuStored >= mItemEuTLimit){ + Logger.WARNING("2"); + + double mItemMaxCharge = ((IElectricItem) mTemp.getItem()).getMaxCharge(mTemp); + double mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); + + if (mitemCurrentCharge >= mItemMaxCharge){ + continue; + } + + //Try get charge direct from NBT for GT and IC2 stacks + Logger.WARNING("3"); + if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 + || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 + || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 + || ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03").isInstance(mTemp.getItem()) + || mTemp.getItem().getClass().getName().toLowerCase().equals(("gregtech.common.items.GT_MetaGenerated_Tool_01").toLowerCase())){ + if (!NBTUtils.hasKey(mTemp, "GT.ItemCharge")){ + if (!mTemp.getDisplayName().toLowerCase().contains("battery")){ + if (!GT_ModHandler.isElectricItem(mTemp)){ + continue; + } + } + else { + mitemCurrentCharge = 0; + } + } + else { + mitemCurrentCharge = NBTUtils.getLong(mTemp, "GT.ItemCharge"); + } + } + else if (mTemp.getItem() instanceof IElectricItem){ + mitemCurrentCharge = NBTUtils.getLong(mTemp, "charge"); + } + + double mVoltageIncrease; + if (mItemEuTLimit >= mVoltage){ + mVoltageIncrease = mVoltage; + } + else if (mItemEuTLimit < mVoltage){ + mVoltageIncrease = mItemEuTLimit; + } + else { + mVoltageIncrease = mItemEuTLimit; + } + + Logger.WARNING("4"); + + int mMulti; + if ((mitemCurrentCharge + (mVoltageIncrease*20)) <= (mItemMaxCharge - (mVoltageIncrease*20))){ + mMulti = 20; + } + else if ((mitemCurrentCharge + (mVoltageIncrease*10)) <= (mItemMaxCharge - (mVoltageIncrease*10))){ + mMulti = 10; + } + else if ((mitemCurrentCharge + (mVoltageIncrease*5)) <= (mItemMaxCharge - (mVoltageIncrease*5))){ + mMulti = 5; + } + else { + mMulti = 1; + } + Logger.WARNING("5"); + + + int mMultiVoltage = (int) (mMulti*mVoltageIncrease); + + if ((mitemCurrentCharge + mMultiVoltage) <= mItemMaxCharge){ + Logger.WARNING("6"); + int g = 0; + if ((g = GT_ModHandler.chargeElectricItem(mTemp, mMultiVoltage, Integer.MAX_VALUE, true, false)) > 0){ + Logger.WARNING("6.5 - "+g+" - "+mMulti); + for (int i=0; i<mMulti;i++){ + if (ElectricItem.manager.charge(mTemp, mVoltageIncrease, Integer.MAX_VALUE, false, false) > 0){ + continue; + } + } + } + if (ElectricItem.manager.getCharge(mTemp) > mitemCurrentCharge){ + Logger.WARNING("7"); + mEntity.setEUVar(mEuStored-(mVoltage*mMulti)); + mEuStored = mEntity.getEUVar(); + Logger.WARNING("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); + mChargedItems++; + } + } + + //Try top up Item Chrage + mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); + if (mitemCurrentCharge < mItemMaxCharge && mitemCurrentCharge >= (mItemMaxCharge-mVoltage)){ + int xDif = (int) (mItemMaxCharge - mitemCurrentCharge); + Logger.WARNING("8 - "+xDif); + int g = 0; + if ((g = GT_ModHandler.chargeElectricItem(mTemp, xDif, Integer.MAX_VALUE, true, false)) >= 0){ + Logger.WARNING("8.5 - "+g); + if (ElectricItem.manager.getCharge(mTemp) >= mItemMaxCharge){ + Logger.WARNING("9"); + mEntity.setEUVar(mEntity.getEUVar()-(xDif)); + mEuStored = mEntity.getEUVar(); + Logger.WARNING("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); + mChargedItems++; + } + } + } + + + } + } + else { + if (mTemp != null){ + Logger.WARNING("Found Non-Valid item. "+mTemp.getDisplayName()); + } + } + } + + //Return Values + if (mChargedItems < 1){ + return mEuStoredOriginal; + } + + return mEntity.getEUVar(); + } + + public static boolean isItemValid(final ItemStack itemstack) { + if (itemstack == null){ + return false; + } + if (GT_ModHandler.isElectricItem(itemstack)){ + return true; + } + if ((accepts(itemstack)) || (itemstack.getItem() instanceof IElectricItem)) { + return true; + } + return false; + } + + public static boolean accepts(final ItemStack stack) { + if (stack == null) { + return false; + } + else { + return false; + } + //return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/CraftingHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/CraftingHelper.java new file mode 100644 index 0000000000..e06636e168 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/CraftingHelper.java @@ -0,0 +1,42 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.helpers.autocrafter.AC_Helper_Container; +import gtPlusPlus.xmod.gregtech.common.helpers.autocrafter.AC_Helper_Utils; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_AutoCrafter; +import net.minecraftforge.common.util.FakePlayerFactory; + +public class CraftingHelper{ + + public final String mInventoryName; + public final int mPosX; + public final int mPosY; + public final int mPosZ; + public final GT4Entity_AutoCrafter crafter; + public final World world; + public final EntityPlayerMP player; + public final AC_Helper_Container inventory; + + public CraftingHelper(GT4Entity_AutoCrafter AC){ + Logger.INFO("[A-C] Created a crafting helper."); + crafter = AC; + AC_Helper_Utils.addCrafter(AC); + //Get some variables. + world = AC.getBaseMetaTileEntity().getWorld(); + mPosX = AC.getBaseMetaTileEntity().getXCoord(); + mPosY = AC.getBaseMetaTileEntity().getYCoord(); + mPosZ = AC.getBaseMetaTileEntity().getZCoord(); + //Create Fake player to handle crating. + + player = CORE.getFakePlayer(world); + //Set storage container + inventory = new AC_Helper_Container(player.inventory, world, mPosX, mPosY, mPosZ); + mInventoryName = inventory.getMatrix().getInventoryName(); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java new file mode 100644 index 0000000000..333939d800 --- /dev/null +++ b/src/main/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/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java new file mode 100644 index 0000000000..d51107bbf0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java @@ -0,0 +1,80 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; + +public class GT_MethodHelper { + + private static final Method mGetTexture; + private static final Class mITexturedTileEntity; + + static { + Class clazz = null; + Method aMeth = null; + if (ReflectionUtils.doesClassExist("gregtech.api.interfaces.tileentity.ITexturedTileEntity")) { + clazz = ReflectionUtils.getClass("gregtech.api.interfaces.tileentity.ITexturedTileEntity"); + aMeth = ReflectionUtils.getMethod(clazz, "getTexture", Block.class, byte.class); + } + mITexturedTileEntity = clazz; + mGetTexture = aMeth; + } + + + public static ITexture[] getTexture(TileEntity tTileEntity, Block aBlock, byte aSide) { + + if (mITexturedTileEntity.isInstance(tTileEntity)) { + + if (mGetTexture != null) { + try { + mGetTexture.invoke(tTileEntity, aBlock, aSide); + } + catch (IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + e.printStackTrace(); + } + } + else { + if (tTileEntity instanceof BaseMetaTileEntity) { + try { + BaseMetaTileEntity aTile = (BaseMetaTileEntity) tTileEntity; + ITexture rIcon = aTile.getCoverTexture(aSide); + Field aFacing = ReflectionUtils.getField(BaseMetaTileEntity.class, "mFacing"); + Field aColor = ReflectionUtils.getField(BaseMetaTileEntity.class, "mColor"); + Field aActive = ReflectionUtils.getField(BaseMetaTileEntity.class, "mActive"); + Field aMetaTile = ReflectionUtils.getField(BaseMetaTileEntity.class, "mMetaTileEntity"); + Method aHasValidTile = ReflectionUtils.getMethod(BaseMetaTileEntity.class, "hasValidMetaTileEntity", new Class[] {}); + + boolean hasValidTileObj = (boolean) aHasValidTile.invoke(aTile, new Object[] {}); + boolean aActiveObj = aActive.getBoolean(aTile); + byte aFacingObj = aFacing.getByte(aTile); + byte aColorObj = aColor.getByte(aTile);; + MetaTileEntity aMetaTileObj = (MetaTileEntity) aMetaTile.get(aTile); + + if (rIcon != null) { + return new ITexture[]{rIcon}; + } else { + return hasValidTileObj + ? aMetaTileObj.getTexture(aTile, aSide, aFacingObj, (byte) (aColorObj - 1), aActiveObj, + aTile.getOutputRedstoneSignal(aSide) > 0) + : BlockIcons.ERROR_RENDERING; + } + } + catch (Throwable t) { + t.printStackTrace(); + } + } + } + } + return BlockIcons.ERROR_RENDERING; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java new file mode 100644 index 0000000000..0b52560e0d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java @@ -0,0 +1,42 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.util.HashMap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.GregTech_API; +import net.minecraft.block.Block; +import net.minecraftforge.event.world.BlockEvent; + +public class MachineUpdateHandler { + + private static final HashMap<String, Block> mBlockCache = new HashMap<String, Block>(); + + public static void registerBlockToCauseMachineUpdate(String aUnlocalName, Block aBlock) { + mBlockCache.put(aUnlocalName, aBlock); + } + + @SubscribeEvent + public void onBlockEvent(BlockEvent event) { + Block aBlock = event.block; + String aUnlocalName = aBlock != null ? aBlock.getUnlocalizedName() : "NULL"; + boolean aDoUpdate = false; + if (aBlock != null && aUnlocalName != null && !aUnlocalName.equals("NULL")) { + for (String aCachedName : mBlockCache.keySet()) { + if (aCachedName.equals(aUnlocalName)) { + aDoUpdate = true; + break; + } + else { + if (aBlock == mBlockCache.get(aCachedName)) { + aDoUpdate = true; + break; + } + } + } + if (aDoUpdate) { + GregTech_API.causeMachineUpdate(event.world, event.x, event.y, event.z); + } + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java new file mode 100644 index 0000000000..2ff2712952 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -0,0 +1,1033 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableTreeFarmerParticles; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +import com.google.common.collect.Lists; + +import gnu.trove.set.hash.THashSet; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; + +import gregtech.api.enums.*; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.block.IGrowable; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.common.items.GT_MetaGenerated_Item_02; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.players.FakeFarmer; +import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.particles.BlockBreakParticles; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.BonemealEvent; +import net.minecraftforge.event.world.BlockEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +public class TreeFarmHelper { + + public static final FluidStack fertT1 = FluidUtils.getFluidStack("fluid.fertiliser", 3); + public static final FluidStack fertT2 = FluidUtils.getFluidStack("fluid.un18fertiliser", 2); + public static final FluidStack fertT3 = FluidUtils.getFluidStack("fluid.un32fertiliser", 1); + private static final int sawOreId = OreDictionary.getOreID(ToolDictNames.craftingToolSaw.name()); + + public static ITexture[][][] getTextureSet() { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = TreeFarmHelper.getFront(i); + rTextures[1][i + 1] = TreeFarmHelper.getBack(i); + rTextures[2][i + 1] = TreeFarmHelper.getBottom(i); + rTextures[3][i + 1] = TreeFarmHelper.getTop(i); + rTextures[4][i + 1] = TreeFarmHelper.getSides(i); + rTextures[5][i + 1] = TreeFarmHelper.getFrontActive(i); + rTextures[6][i + 1] = TreeFarmHelper.getBackActive(i); + rTextures[7][i + 1] = TreeFarmHelper.getBottomActive(i); + rTextures[8][i + 1] = TreeFarmHelper.getTopActive(i); + rTextures[9][i + 1] = TreeFarmHelper.getSidesActive(i); + } + return rTextures; + } + + public static ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public static ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public static ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public static ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public static ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; + } + + public static ITexture[] getFrontActive(final byte aColor) { + return getFront(aColor); + } + + public static ITexture[] getBackActive(final byte aColor) { + return getBack(aColor); + } + + public static ITexture[] getBottomActive(final byte aColor) { + return getBottom(aColor); + } + + public static ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } + + public static ITexture[] getSidesActive(final byte aColor) { + return getSides(aColor); + } + + public static boolean applyBonemeal(final EntityPlayer player, final World world, final int intX, final int intY, final int intZ, final short multiplier){ + final Block block = world.getBlock(intX, intY, intZ); + + + int roll; + int rollNeeded; + + if (multiplier==1){ + roll = MathUtils.randInt(1, 15); + rollNeeded = 15; + } + else if (multiplier==2){ + roll = MathUtils.randInt(1, 10); + rollNeeded = 10; + } + else { + roll = MathUtils.randInt(1, 5); + rollNeeded = 5; + } + + if (roll != rollNeeded){ + return false; + } + + //EntityPlayer player = FakePlayerFactory.getMinecraft((WorldServer)world); + if (!world.isRemote){ + if (enableTreeFarmerParticles){ + world.playAuxSFX(2005, intX, intY, intZ, 0); + } + } + final BonemealEvent event = new BonemealEvent(player, world, block, intX, intY, intZ); + if (MinecraftForge.EVENT_BUS.post(event)){ + Logger.MACHINE_INFO("Not sure why this returned false"); + return false; + } + if (event.getResult() == Result.ALLOW){ + if (!world.isRemote){ + world.playAuxSFX(2005, intX, intY, intZ, 0); + } + return true; + } + if (block instanceof IGrowable){ + final IGrowable igrowable = (IGrowable)block; + if (igrowable.func_149851_a(world, intX, intY, intZ, world.isRemote)){ + if (!world.isRemote){ + if (igrowable.func_149852_a(world, CORE.RANDOM, intX, intY, intZ)){ + igrowable.func_149853_b(world, CORE.RANDOM, intX, intY, intZ); + } + } + return true; + } + } + return false; + } + + public static boolean cleanUp(final IGregTechTileEntity aBaseMetaTileEntity){ + Logger.MACHINE_INFO("called cleanUp()"); + int cleanedUp = 0; + final int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 11; + final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 11; + + for (int h=1;h<175;h++){ + for (int i = -11; i <= 11; i++) { + for (int j = -11; j <= 11; j++) { + + final Block testBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + + + if + (( + ((i == -8) || (i == 8)) || + ((i == -9) || (i == 9)) || + ((i == -10) || (i == 10)) || + ((i == -11) || (i == 11)) + ) + && + ( + ((j == -8) || (j == 8)) || + ((j == -9) || (j == 9)) || + ((j == -10) || (j == 10)) || + ((j == -11) || (j == 11)) + )){ + + if (!testBlock.getUnlocalizedName().toLowerCase().contains("air") || !testBlock.getUnlocalizedName().toLowerCase().contains("pumpkin")) { + //Logger.WARNING("5:"+testBlock.getUnlocalizedName()); + } else { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord()+xDir+i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir+j, Blocks.bookshelf); + } + } + + + //If not in the middle - don't know how else to check this one without lots of != + if ( + (i != 7) && (i != -7) && (j != 7) && (j != -7) && + (i != 6) && (i != -6) && (j != 6) && (j != -6) && + (i != 5) && (i != -5) && (j != 5) && (j != -5) && + (i != 4) && (i != -4) && (j != 4) && (j != -4) && + (i != 3) && (i != -3) && (j != 3) && (j != -3) && + (i != 2) && (i != -2) && (j != 2) && (j != -2) && + (i != 1) && (i != -1) && (j != 1) && (j != -1) && + (i != 0) && (j != 0) + ){ + + if (!testBlock.getUnlocalizedName().toLowerCase().contains("air") || !testBlock.getUnlocalizedName().toLowerCase().contains("pumpkin")) { + //Logger.WARNING("0:"+testBlock.getUnlocalizedName()); + } else { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord()+xDir+i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir+j, Blocks.melon_block); + } + + + if (isLeaves(testBlock) || isWoodLog(testBlock)){ + //Logger.WARNING("1:"+testBlock.getUnlocalizedName()); + int posiX, posiY, posiZ; + posiX = aBaseMetaTileEntity.getXCoord()+xDir+i; + posiY = aBaseMetaTileEntity.getYCoord()+h; + posiZ = aBaseMetaTileEntity.getZCoord()+zDir+j; + //Utils.LOG_MACHINE_INFO("Cleaning Up some leftovers."); + cleanedUp++; + aBaseMetaTileEntity.getWorld().setBlockToAir(posiX, posiY, posiZ); + new BlockBreakParticles(aBaseMetaTileEntity.getWorld(), posiX, posiY, posiZ, Blocks.dirt); + } + else { + //Utils.LOG_WARNING("2:"+testBlock.getUnlocalizedName()); + } + } + else { + //Utils.LOG_WARNING("1"); + } + + + } + + } + } + Logger.MACHINE_INFO("cleaning up | "+cleanedUp ); + return true; + } + + public static SAWTOOL isCorrectMachinePart(final ItemStack aStack) { + if (aStack != null){ + //Utils.LOG_WARNING("Found "+aStack.getDisplayName()+" in the GUI slot."); + if ((aStack.getItem() instanceof GT_MetaGenerated_Item_02) || (aStack.getItem() instanceof GT_MetaGenerated_Tool)){ + if (OrePrefixes.craftingTool.contains(aStack)){ + if (aStack.getDisplayName().toLowerCase().contains("saw") || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01")){ + if (aStack.getItemDamage() == 10){ + return SAWTOOL.SAW; + } + else if (aStack.getItemDamage() == 140 || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.140")){ + return SAWTOOL.BUZZSAW; + } + else if (aStack.getItemDamage() == 110 || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.110")){ + return SAWTOOL.CHAINSAW; + } + else if (aStack.getItemDamage() == 112 || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.112")){ + return SAWTOOL.CHAINSAW; + } + else if (aStack.getItemDamage() == 114 || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.114")){ + return SAWTOOL.CHAINSAW; + } + else { + return SAWTOOL.NONE; + } + } + } + } + } + return SAWTOOL.NONE; + } + + public static ToolType getPartType(final ItemStack aStack) { + if (aStack != null){ + //Utils.LOG_WARNING("Found "+aStack.getDisplayName()+" in the GUI slot."); + + if (aStack.getItem() == MetaGeneratedGregtechItems.INSTANCE) { + int aDmg = aStack.getItemDamage(); + if (aDmg >= 32120 && aDmg <= 32128) { + return ToolType.Unbreakable; + } + Logger.INFO("bad Tool in Slot 2 | "+aStack.getUnlocalizedName().toLowerCase() + " | "+aDmg); + return null; + } + + if (aStack.getItem() instanceof GT_MetaGenerated_Tool) { + if (Arrays.stream(OreDictionary.getOreIDs(aStack)).anyMatch(i -> i == sawOreId)) + return ToolType.Breakable; + } + } + Logger.INFO("bad Tool in Slot 4"); + return null; + } + + public static boolean isHumusLoaded = false; + public static boolean isForestryLogsLoaded = false; + public static boolean isForestryFenceLoaded = false; + public static boolean isForestrySaplingsLoaded = false; + public static boolean isForestryLeavesLoaded = false; + public static Block blockHumus; + + public static boolean isForestryValid(){ + if (!LoadedMods.Forestry){ + return false; + } + if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ + isHumusLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockLog")){ + isForestryLogsLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockArbFence")){ + isForestryFenceLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockSapling")){ + isForestrySaplingsLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockForestryLeaves")){ + isForestryLeavesLoaded = true; + } + return true; + } + + @Optional.Method(modid = "Forestry") + public static Block getHumus(){ + if(blockHumus != null){ + return blockHumus; + } + else if (isHumusLoaded){ + final Class<?> humusClass = ReflectionUtils.getClass("forestry.core.blocks.BlockSoil"); + final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); + if (humusClass != null){ + blockHumus = Block.getBlockFromItem(humusStack.getItem()); + return Block.getBlockFromItem(humusStack.getItem()); + } + } + return null; + } + + public static boolean isWoodLog(final Block log){ + final String tTool = log.getHarvestTool(0); + + if ((log == Blocks.log) || (log == Blocks.log2)){ + return true; + } + + //Forestry/General Compat + if (log.getClass().getName().toLowerCase().contains("blocklog")){ + return true; + } + + //IC2 Rubber Tree Compat + if (log.getClass().getName().toLowerCase().contains("rubwood") || log.getClass().getName().toLowerCase().contains("rubleaves")){ + return true; + } + + return (OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe")))) || (log.getMaterial() != Material.wood) ? false : (OrePrefixes.fence.contains(new ItemStack(log, 1)) ? false : true); + } + + public static boolean isLeaves(final Block log){ + if (log.getUnlocalizedName().toLowerCase().contains("leaf")){ + return true; + } + if (log.getUnlocalizedName().toLowerCase().contains("leaves")){ + return true; + } + if (log.getLocalizedName().toLowerCase().contains("leaf")){ + return true; + } + if (log.getLocalizedName().toLowerCase().contains("leaves")){ + return true; + } + return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.leaves || OrePrefixes.treeLeaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.vine || OrePrefixes.mushroom.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.cactus; + } + + public static boolean isSapling(final Block log){ + if (log != null){ + if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){ + //Logger.WARNING(""+log.getLocalizedName()); + } + if (log.getLocalizedName().toLowerCase().contains("sapling")){ + //Logger.WARNING(""+log.getLocalizedName()); + return true; + } + } + return OrePrefixes.sapling.contains(new ItemStack(log, 1)); + } + + public static boolean isDirtBlock(final Block dirt){ + return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false)))); + } + + public static boolean isFenceBlock(final Block fence){ + return (fence == Blocks.fence ? true : (fence == Blocks.fence_gate ? true : (fence == Blocks.nether_brick_fence ? true : (OrePrefixes.fence.contains(new ItemStack(fence, 1)) ? true : false)))); + } + + public static boolean isAirBlock(final Block air){ + if (air.getLocalizedName().toLowerCase().contains("air")){ + return true; + } + if (air.getClass().getName().toLowerCase().contains("residual") || air.getClass().getName().toLowerCase().contains("heat")){ + return true; + } + return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false)); + } + + /*public static boolean isSaplingBlock(Block sapling){ + return (sapling == Blocks.sapling ? true : (sapling == Blocks.)) + }*/ + + public static BlockPos checkForLogsInGrowArea(final IGregTechTileEntity aBaseMetaTileEntity) { + final int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7; + final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7; + for (int i = -7; i <= 7; i++) { + for (int j = -7; j <= 7; j++) { + for (int h = 0; h <= 1; h++) { + //Farm Floor inner 14x14 + if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) { + if (h == 1) { + if (TreeFarmHelper.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { + Logger.INFO("Found a Log"); + return new BlockPos(aBaseMetaTileEntity.getXCoord()+xDir + i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir + j, aBaseMetaTileEntity.getWorld()); + } + } + } + } + } + } + return null; + } + + public static ItemStack[] findTreeFromBase(World world, BlockPos h) { + int HARD_LIMIT = 10000; + int mCount = 0; + Logger.INFO("Finding Rest of Tree."); + BlockPos mFirstSpot = h; + Set<BlockPos> mSearchedSpaces = new HashSet<BlockPos>(); + Set<BlockPos> mTreeSet = getConnectedBlocks(world, mFirstSpot, mSearchedSpaces); + Set<Set<BlockPos>> mTreeSet2 = new HashSet<Set<BlockPos>>(); + Set<BlockPos> mFinalTree = new HashSet<BlockPos>(); + Iterator<BlockPos> it = mTreeSet.iterator(); + + + Logger.INFO("Running first iteration."); + while(it.hasNext()){ + BlockPos G = it.next(); + mSearchedSpaces.add(G); + mTreeSet2.add(getConnectedBlocks(world, G, mSearchedSpaces)); + mCount++; + Logger.INFO("First Search: "+G.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + + mCount = 0; + Iterator<Set<BlockPos>> it2 = mTreeSet2.iterator(); + Iterator<BlockPos> it3; + Logger.INFO("Running second iteration."); + while(it2.hasNext()){ + Set<BlockPos> G = it2.next(); + it3 = G.iterator(); + while(it3.hasNext()){ + BlockPos G2 = it3.next(); + mSearchedSpaces.add(G2); + mFinalTree.add(G2); + mCount++; + Logger.INFO("Second Search: "+G2.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + + + if (mFinalTree.size() > 0) { + Logger.INFO("Queuing "+mFinalTree.size()+" to Harvest Manager."); + TreeCutter harvestManager = new TreeCutter(world); + + Iterator<BlockPos> ith = mFinalTree.iterator(); + while(ith.hasNext()){ + BlockPos G = ith.next(); + harvestManager.queue(G); + mCount++; + Logger.INFO("Queued: "+G.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + + if (harvestManager.isValid) { + ItemStack[] loot = harvestManager.getDrops(); + if (loot.length > 0) { + //Logger.INFO("Returning Drops from harvestManager Queue."); + return loot; + } + } + } + return new ItemStack[] {}; + } + + + public static Set<BlockPos> getConnectedBlocks(World W, BlockPos P, Set<BlockPos> checkedSpaces) { + int HARD_LIMIT = 1000; + int mCount = 0; + Logger.INFO("Finding blocks connected to "+P.getLocationString()+"."); + Set<BlockPos> mCheckedSpaces = checkedSpaces; + Set<BlockPos> mStartSearch = searchSixFaces(W, P, mCheckedSpaces, false); + Set<BlockPos> mSecondSearch = new HashSet<BlockPos>(); + Set<BlockPos> mThirdSearch = new HashSet<BlockPos>(); + Iterator<BlockPos> it = mStartSearch.iterator(); + while(it.hasNext()){ + Logger.INFO("Running first iteration. [II]"); + BlockPos G = it.next(); + mCheckedSpaces.add(G); + Set<BlockPos> mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); + Iterator<BlockPos> it2 = mBranchSearch.iterator(); + while(it2.hasNext()){ + Logger.INFO("Running second iteration. [II]"); + BlockPos G2 = it2.next(); + mCheckedSpaces.add(G2); + mSecondSearch.add(G2); + mCount++; + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + mCount = 0; + Iterator<BlockPos> itx = mSecondSearch.iterator(); + while(itx.hasNext()){ + BlockPos G = itx.next(); + mCheckedSpaces.add(G); + Set<BlockPos> mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); + Iterator<BlockPos> it2 = mBranchSearch.iterator(); + while(it2.hasNext()){ + BlockPos G2 = it2.next(); + mCheckedSpaces.add(G2); + mThirdSearch.add(G2); + mCount++; + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + return mThirdSearch; + } + + public static Set<BlockPos> searchSixFaces(World W, BlockPos P, Set<BlockPos> checkedSpaces, boolean checkLeaves) { + Set<BlockPos> mConnected = new HashSet<BlockPos>(); + int x = P.xPos; + int y = P.yPos; + int z = P.zPos; + if (checkLeaves) { + if (isWoodLog(W.getBlock(x-1, y, z)) || isLeaves(W.getBlock(x-1, y, z))) { + BlockPos L = new BlockPos(x-1, y, z, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x+1, y, z)) || isLeaves(W.getBlock(x+1, y, z))) { + BlockPos L = new BlockPos(x+1, y, z, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y-1, z)) || isLeaves(W.getBlock(x, y-1, z))) { + BlockPos L = new BlockPos(x, y-1, z, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y+1, z)) || isLeaves(W.getBlock(x, y+1, z))) { + BlockPos L = new BlockPos(x, y+1, z, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y, z-1)) || isLeaves(W.getBlock(x, y, z-1))) { + BlockPos L = new BlockPos(x, y, z-1, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y, z+1)) || isLeaves(W.getBlock(x, y, z+1))) { + BlockPos L = new BlockPos(x, y, z+1, W); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + } + else { + if (isWoodLog(W.getBlock(x-1, y, z))) { + BlockPos L = new BlockPos(x-1, y, z, W); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x+1, y, z))) { + BlockPos L = new BlockPos(x+1, y, z, W); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y-1, z))) { + BlockPos L = new BlockPos(x, y-1, z, W); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y+1, z))) { + BlockPos L = new BlockPos(x, y+1, z, W); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y, z-1))) { + BlockPos L = new BlockPos(x, y, z-1, W); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y, z+1))) { + BlockPos L = new BlockPos(x, y, z+1, W); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + } + return mConnected; + } + + + public enum ToolType { + Unbreakable, + Breakable + } + + + /** + * Tree Cutting + */ + + public static class TreeCutter { + + private final World mWorld; + private Map<String, BlockPos> mQueue = new ConcurrentHashMap<String, BlockPos>(); + private AutoMap<ItemStack[]> mDrops = new AutoMap<ItemStack[]>(); + private boolean isValid = true; + + public TreeCutter(World world) { + this.mWorld = world; + } + + public boolean queue(BlockPos pos) { + if (isValid && pos != null) { + //Logger.INFO("Queued: "+pos.getLocationString()); + String hash = Utils.calculateChecksumMD5(pos); + if (hash != null && !mQueue.containsKey(hash)) { + mQueue.put(hash, pos); + return true; + } + } + return false; + } + + private boolean emptyQueue() { + if (isValid) { + Logger.INFO("Emptying Queue."); + if (this.mQueue.size() > 0) { + int totalRemoved = 0; + for (BlockPos h : mQueue.values()) { + final Block block = mWorld.getBlock(h.xPos, h.yPos, h.zPos); + if (block != null) { + final int dropMeta = mWorld.getBlockMetadata(h.xPos, h.yPos, h.zPos); + final ArrayList<ItemStack> blockDrops = block.getDrops(mWorld, h.xPos, h.yPos, h.zPos, dropMeta, 0); + final ItemStack[] drops = ItemUtils.getBlockDrops(blockDrops); + mDrops.put(drops); + //Remove drop that was added to the bus. + mWorld.setBlockToAir(h.xPos, h.yPos, h.zPos); + //new BlockBreakParticles(mWorld, h.xPos, h.yPos, h.zPos, block); + totalRemoved++; + } + } + if (totalRemoved > 0 && mDrops.size() > 0) { + return true; + } + } + } + return false; + } + + public ItemStack[] getDrops() { + //If Queue is successfully cleared and drops are created, let us continue. + if (isValid && emptyQueue()) { + AutoMap<ItemStack> mCollective = new AutoMap<ItemStack>(); + //Iterate ALL of the arrays, add output to a collective. + for (ItemStack[] i : this.mDrops) { + //Array is not null. + if (i != null) { + //Iterate this array. + for (int d=0;d<i.length;d++) { + //Put Output into collective if valid + if (i[d] != null && i[d].stackSize > 0) { + mCollective.put(i[d]); + } + } + } + } + //Build an ItemStack array. + ItemStack[] drops = new ItemStack[mCollective.size()]; + for (int m=0;m<drops.length;m++) { + drops[m] = mCollective.get(m); + } + //Return drops array if it's valid. + if (drops.length > 0) { + isValid = false; + return drops; + } + } + //Invalid or no drops, return empty array. + isValid = false; + return new ItemStack[] {}; + } + + } + + + /** + * Farm AI + */ + private static EntityPlayerMP farmerAI; + public EntityPlayerMP getFakePlayer(World world) { + return farmerAI = checkFakePlayer(world); + } + + public static EntityPlayerMP checkFakePlayer(World world) { + if (farmerAI == null) { + return new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(world.provider.dimensionId)); + } + return farmerAI; + } + + public static boolean onBlockStartBreak (int x, int y, int z, World world){ + final Block wood = world.getBlock(x, y, z); + if (wood == null){ + return false; + } + if (wood.isWood(world, x, y, z) || wood.getMaterial() == Material.sponge) + if(detectTree(world, x,y,z)) { + TreeChopTask chopper = new TreeChopTask(new ChunkPosition(x, y, z), checkFakePlayer(world), 128); + FMLCommonHandler.instance().bus().register(chopper); + // custom block breaking code, don't call vanilla code + return true; + } + //return onBlockStartBreak(stack, x, y, z, player); + return false; + } + + public static boolean detectTree(World world, int pX, int pY, int pZ) { + ChunkPosition pos = null; + Stack<ChunkPosition> candidates = new Stack<>(); + candidates.add(new ChunkPosition(pX, pY, pZ)); + + while (!candidates.isEmpty()) { + ChunkPosition candidate = candidates.pop(); + int curX = candidate.chunkPosX, curY = candidate.chunkPosY, curZ = candidate.chunkPosZ; + + Block block = world.getBlock(curX, curY, curZ); + if ((pos == null || candidate.chunkPosY > pos.chunkPosY) && block.isWood(world, curX, curY, curZ)) { + pos = new ChunkPosition(curX, candidate.chunkPosY + 1, curZ); + // go up + while (world.getBlock(curX, pos.chunkPosY, curZ).isWood(world, curX, pos.chunkPosY, curZ)) { + pos = new ChunkPosition(curX, pos.chunkPosY + 1, curZ); + } + // check if we still have a way diagonally up + candidates.add(new ChunkPosition(curX + 1, pos.chunkPosY + 1, curZ )); + candidates.add(new ChunkPosition(curX , pos.chunkPosY + 1, curZ + 1)); + candidates.add(new ChunkPosition(curX - 1, pos.chunkPosY + 1, curZ )); + candidates.add(new ChunkPosition(curX , pos.chunkPosY + 1, curZ - 1)); + } + } + + // not even one match, so there were no logs. + if (pos == null) { + return false; + } + + // check if there were enough leaves around the last position + // pos now contains the block above the topmost log + // we want at least 5 leaves in the surrounding 26 blocks + int d = 3; + int leaves = 0; + for (int offX = 0; offX < d; offX++) { + for (int offY = 0; offY < d; offY++) { + for (int offZ = 0; offZ < d; offZ++) { + int xPos = pos.chunkPosX -1 + offX, yPos = pos.chunkPosY - 1 + offY, zPos = pos.chunkPosZ - 1 + offZ; + Block leaf = world.getBlock(xPos, yPos, zPos); + if (leaf != null && leaf.isLeaves(world, xPos, yPos, zPos)) { + if (++leaves >= 5) { + return true; + } + } + } + } + } + + // not enough leaves. sorreh + return false; + } + + public static class TreeChopTask { + + public final World world; + public final EntityPlayer player; + public final int blocksPerTick; + + public Queue<ChunkPosition> blocks = Lists.newLinkedList(); + public Set<ChunkPosition> visited = new THashSet<>(); + + public TreeChopTask(ChunkPosition start, EntityPlayer player, int blocksPerTick) { + this.world = player.getEntityWorld(); + this.player = player; + this.blocksPerTick = blocksPerTick; + + this.blocks.add(start); + } + + private void queueCoordinate(int x, int y, int z) { + ChunkPosition pos = new ChunkPosition(x, y, z); + if (!visited.contains(pos)) { + blocks.add(pos); + } + } + + @SubscribeEvent + public void onWorldTick(TickEvent.WorldTickEvent event) { + if (event.side.isClient()) { + finish(); + return; + } + // only if same dimension + if (event.world.provider.dimensionId != world.provider.dimensionId) { + return; + } + + // setup + int left = blocksPerTick; + //NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + + // continue running + ChunkPosition pos; + while (left > 0) { + // completely done or can't do our job anymore?! + if (blocks.isEmpty()/* || tags.getBoolean("Broken")*/) { + finish(); + return; + } + + pos = blocks.remove(); + if (!visited.add(pos)) { + continue; + } + int x = pos.chunkPosX, y = pos.chunkPosY, z = pos.chunkPosZ; + + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + // can we harvest the block and is effective? + if (!block.isWood(world, x, y, z) || !isWoodLog(block)) { + continue; + } + + // save its neighbors + queueCoordinate(x + 1, y, z ); + queueCoordinate(x, y, z + 1); + queueCoordinate(x - 1, y, z ); + queueCoordinate(x, y, z - 1); + + // also add the layer above.. stupid acacia trees + for (int offX = 0; offX < 3; offX++) { + for (int offZ = 0; offZ < 3; offZ++) { + queueCoordinate(x - 1 + offX, y + 1, z - 1 + offZ); + } + } + + // break it, wooo! + breakExtraBlock(player.worldObj, x, y, z, 0, player, x, y, z); + left--; + } + } + + private void finish() { + // goodbye cruel world + FMLCommonHandler.instance().bus().unregister(this); + } + } + + + public static void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) { + // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events + if (world.isAirBlock(x, y, z)) + return; + + // what? + if(!(playerEntity instanceof EntityPlayerMP)) + return; + EntityPlayerMP player = (EntityPlayerMP) playerEntity; + + // check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian + // or precious ores you can't harvest while mining stone + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + // only effective materials + if (!isWoodLog(block)) + return; + + Block refBlock = world.getBlock(refX, refY, refZ); + float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ); + float strength = ForgeHooks.blockStrength(block, player, world, x,y,z); + + // only harvestable blocks that aren't impossibly slow to harvest + if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f) + return; + + // send the blockbreak event + BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x,y,z); + if(event.isCanceled()) + return; + + if (player.capabilities.isCreativeMode) { + block.onBlockHarvested(world, x, y, z, meta, player); + if (block.removedByPlayer(world, player, x, y, z, false)) + block.onBlockDestroyedByPlayer(world, x, y, z, meta); + + // send update to client + if (!world.isRemote) { + player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } + return; + } + + // callback to the tool the player uses. Called on both sides. This damages the tool n stuff. + player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player); + + // server sided handling + if (!world.isRemote) { + // serverside we reproduce ItemInWorldManager.tryHarvestBlock + + // ItemInWorldManager.removeBlock + block.onBlockHarvested(world, x,y,z, meta, player); + + if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above + { + block.onBlockDestroyedByPlayer( world, x,y,z, meta); + block.harvestBlock(world, player, x,y,z, meta); + block.dropXpOnBlockBreak(world, x,y,z, event.getExpToDrop()); + } + + // always send block update to client + player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } + // client sided handling + else { + //PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController; + // clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send any new packets + // the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy. + + // following code can be found in PlayerControllerMP.onPlayerDestroyBlock + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + if(block.removedByPlayer(world, player, x,y,z, true)) + { + block.onBlockDestroyedByPlayer(world, x,y,z, meta); + } + // callback to the tool + ItemStack itemstack = player.getCurrentEquippedItem(); + if (itemstack != null) + { + itemstack.func_150999_a(world, block, x, y, z, player); + + if (itemstack.stackSize == 0) + { + player.destroyCurrentEquippedItem(); + } + } + + // send an update to the server, so we get an update back + //if(PHConstruct.extraBlockUpdates) + //Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit)); + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java new file mode 100644 index 0000000000..575e094696 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java @@ -0,0 +1,188 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public class VolumetricFlaskHelper { + + private static final Class sClassVolumetricFlask; + private static final Method sMethodGetFlaskMaxCapacity; + private static Item mFlask; + + static { + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + sClassVolumetricFlask = ReflectionUtils.getClass("gregtech.common.items.GT_VolumetricFlask"); + Method aMaxCapacity = null; + try { + aMaxCapacity = sClassVolumetricFlask.getDeclaredMethod("getMaxCapacity", new Class[] {}); + } + catch (NoSuchMethodException e) { + e.printStackTrace(); + CORE.crash("Secondary Error Obtaining instance of 'getMaxCapacity' from 'GT_VolumetricFlask'. Crashing."); + } + sMethodGetFlaskMaxCapacity = aMaxCapacity; + } + else { + sClassVolumetricFlask = null; + sMethodGetFlaskMaxCapacity = null; + } + } + + public static ItemStack getVolumetricFlask(int aAmount) { + ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", aAmount, (ItemStack) null); + return aFlask; + } + + public static ItemStack getLargeVolumetricFlask(int aAmount) { + ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_8k.get(aAmount); + return aFlask; + } + + public static ItemStack getGiganticVolumetricFlask(int aAmount) { + ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_32k.get(aAmount); + return aFlask; + } + + public static boolean isVolumetricFlask(ItemStack aStack) { + if (isNormalVolumetricFlask(aStack) || isLargeVolumetricFlask(aStack) || isGiganticVolumetricFlask(aStack)) { + return true; + } + return false; + } + + public static boolean isNormalVolumetricFlask(ItemStack aStack) { + if (mFlask == null) { + ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", 1, (ItemStack) null); + if (aFlask != null) { + mFlask = aFlask.getItem(); + } + } + if (aStack.getItem() == mFlask) { + return true; + } + return false; + } + + public static boolean isLargeVolumetricFlask(ItemStack aStack) { + if (GregtechItemList.VOLUMETRIC_FLASK_8k.getItem() == aStack.getItem()) { + return true; + } + return false; + } + + public static boolean isGiganticVolumetricFlask(ItemStack aStack) { + if (GregtechItemList.VOLUMETRIC_FLASK_32k.getItem() == aStack.getItem()) { + return true; + } + return false; + } + + public static int getMaxFlaskCapacity(ItemStack aStack) { + if (aStack != null && sMethodGetFlaskMaxCapacity != null) { + Item aItem = aStack.getItem(); + if (sClassVolumetricFlask.isInstance(aItem)) { + int aMaxCapacity = (int) ReflectionUtils.invokeNonBool(aItem, sMethodGetFlaskMaxCapacity, new Object[] {}); + return aMaxCapacity; + } + } + return 0; + } + + public static boolean isFlaskEmpty(ItemStack aStack) { + return getFlaskFluid(aStack) == null; + } + + public static FluidStack getFlaskFluid(ItemStack aStack) { + if (aStack.hasTagCompound()) { + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt.hasKey("Fluid", 10)) + return FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("Fluid")); + } + return null; + } + + public static void setFluid(ItemStack stack, FluidStack fluidStack) { + boolean removeFluid = (fluidStack == null) || (fluidStack.amount <= 0); + NBTTagCompound nbt = stack.getTagCompound(); + if (nbt == null) { + if (removeFluid) + return; + stack.setTagCompound(nbt = new NBTTagCompound()); + } + if (removeFluid) { + nbt.removeTag("Fluid"); + if (nbt.hasNoTags()) { + stack.setTagCompound(null); + } + } else { + nbt.setTag("Fluid", fluidStack.writeToNBT(new NBTTagCompound())); + } + } + + public static int getFlaskCapacity(ItemStack aStack) { + int capacity = 1000; + if (aStack.hasTagCompound()) { + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt.hasKey("Capacity", 3)) + capacity = nbt.getInteger("Capacity"); + } + return Math.min(getMaxFlaskCapacity(aStack), capacity); + } + + public static boolean setNewFlaskCapacity(ItemStack aStack, int aCapacity) { + if (aStack == null || aCapacity <= 0) { + return false; + } + aCapacity = Math.min(aCapacity, getMaxFlaskCapacity(aStack)); + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt == null) { + aStack.setTagCompound(nbt = new NBTTagCompound()); + } + nbt.setInteger("Capacity", aCapacity); + return true; + } + + public static int fillFlask(ItemStack stack, FluidStack resource, boolean doFill) { + if (stack.stackSize != 1) + return 0; + if ((resource == null) || (resource.amount <= 0)) { + return 0; + } + FluidStack fluidStack = getFlaskFluid(stack); + if (fluidStack == null) { + fluidStack = new FluidStack(resource, 0); + } else if (!fluidStack.isFluidEqual(resource)) { + return 0; + } + int amount = Math.min(getMaxFlaskCapacity(stack) - fluidStack.amount, resource.amount); + if ((doFill) && (amount > 0)) { + fluidStack.amount += amount; + setFluid(stack, fluidStack); + } + return amount; + } + + public static Item generateNewFlask(String unlocalized, String english, int maxCapacity) { + Constructor aFlask = ReflectionUtils.getConstructor(sClassVolumetricFlask, new Class[] {String.class, String.class, int.class}); + if (aFlask != null) { + Object aInstance = ReflectionUtils.createNewInstanceFromConstructor(aFlask, new Object[] {unlocalized, english, maxCapacity}); + if (aInstance != null && aInstance instanceof Item) { + Item aNewFlaskItem = (Item) aInstance; + return aNewFlaskItem; + } + } + return null; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java new file mode 100644 index 0000000000..29dabaf084 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java @@ -0,0 +1,118 @@ +package gtPlusPlus.xmod.gregtech.common.helpers.autocrafter; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.*; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.world.World; + +import gtPlusPlus.api.objects.Logger; + +public class AC_Helper_Container extends Container +{ + /** The crafting matrix inventory (3x3). */ + public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + public IInventory craftResult = new InventoryCraftResult(); + private World worldObj; + + public InventoryCrafting getMatrix(){ + return this.craftMatrix; + } + + public boolean putItemsIntoGrid(ItemStack[] inputs){ + if (inputs.length < 9){ + return false; + } + for (int i=0;i<9;i++){ + this.putStackInSlot(i, inputs[i]); + } + this.onCraftMatrixChanged(this.craftMatrix); + return true; + } + + public AC_Helper_Container(InventoryPlayer playerInventory, World world, int x, int y, int z) + { + this.worldObj = world; + this.addSlotToContainer(new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 124, 35)); + int l; + int i1; + + for (l = 0; l < 3; ++l) + { + for (i1 = 0; i1 < 3; ++i1) + { + this.addSlotToContainer(new Slot(this.craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); + } + } + + for (l = 0; l < 3; ++l) + { + for (i1 = 0; i1 < 9; ++i1) + { + this.addSlotToContainer(new Slot(playerInventory, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); + } + } + + for (l = 0; l < 9; ++l) + { + this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142)); + } + + this.onCraftMatrixChanged(this.craftMatrix); + } + + /** + * Callback for when the crafting matrix is changed. + */ + @Override + public void onCraftMatrixChanged(IInventory p_75130_1_) + { + this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); + Logger.INFO("Crafted "+this.craftResult.getStackInSlot(0)); + + } + + /** + * Called when the container is closed. + */ + @Override + public void onContainerClosed(EntityPlayer p_75134_1_) + { + super.onContainerClosed(p_75134_1_); + + if (!this.worldObj.isRemote) + { + for (int i = 0; i < 9; ++i) + { + ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); + + if (itemstack != null) + { + p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + } + } + + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) + { + return true; + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. + */ + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_){ + ItemStack itemstack = null; + return itemstack; + } + + @Override + public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) + { + return p_94530_2_.inventory != this.craftResult && super.func_94530_a(p_94530_1_, p_94530_2_); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Utils.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Utils.java new file mode 100644 index 0000000000..772ece96aa --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Utils.java @@ -0,0 +1,80 @@ +package gtPlusPlus.xmod.gregtech.common.helpers.autocrafter; + +import java.util.*; +import java.util.Map.Entry; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_AutoCrafter; + +public class AC_Helper_Utils { + + //AC maps + public static final Map<Integer, GT4Entity_AutoCrafter> sAutocrafterMap = new HashMap<Integer, GT4Entity_AutoCrafter>(); + + //Add Crafter + public final static int addCrafter(GT4Entity_AutoCrafter AC) { + if (!sAutocrafterMap.containsValue(AC)){ + int increase = sAutocrafterMap.size()+1; + sAutocrafterMap.put(increase, AC); + Logger.INFO("[A-C] "+"Added Auto-Crafter to index on position "+increase+"."); + return increase; + } + else { + Logger.INFO("[A-C] Tried adding an Auto-Crafter to Index, but found one already there."); + } + return 0; + } + + //Remove Crafter + public final static boolean removeCrafter(int frequency) { + if (!sAutocrafterMap.isEmpty()){ + if (sAutocrafterMap.containsKey(frequency)){ + sAutocrafterMap.remove(frequency); + return true; + } + } + return false; + } + + public final static boolean removeCrafter(GT4Entity_AutoCrafter AC) { + if (!sAutocrafterMap.isEmpty()){ + if (sAutocrafterMap.containsValue(AC)){ + sAutocrafterMap.remove(getIDByCrafter(AC)); + return true; + } + } + return false; + } + + //Get Crafter + public final static GT4Entity_AutoCrafter getCrafterByID(int ID) { + if (!sAutocrafterMap.isEmpty()) { + Set<Entry<Integer, GT4Entity_AutoCrafter>> players = sAutocrafterMap.entrySet(); + Iterator<Entry<Integer, GT4Entity_AutoCrafter>> i = players.iterator(); + while (i.hasNext()) { + Entry<Integer, GT4Entity_AutoCrafter> current = i.next(); + if (current.getKey().equals(ID)) { + return current.getValue(); + } + } + } + Logger.WARNING("Failed. [getCrafterByID]"); + return null; + } + + public final static int getIDByCrafter(GT4Entity_AutoCrafter AC) { + if (!sAutocrafterMap.isEmpty()) { + Set<Entry<Integer, GT4Entity_AutoCrafter>> players = sAutocrafterMap.entrySet(); + Iterator<Entry<Integer, GT4Entity_AutoCrafter>> i = players.iterator(); + while (i.hasNext()) { + Entry<Integer, GT4Entity_AutoCrafter> current = i.next(); + if (current.getValue().equals(AC)) { + return current.getKey(); + } + } + } + Logger.WARNING("Failed. [getIDByCrafter]"); + return 0; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java new file mode 100644 index 0000000000..a3a116fea6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/tesseract/TesseractHelper.java @@ -0,0 +1,263 @@ +package gtPlusPlus.xmod.gregtech.common.helpers.tesseract; + +import static gtPlusPlus.core.lib.CORE.*; + +import java.util.*; +import java.util.Map.Entry; + +import net.minecraft.entity.player.EntityPlayer; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; + +public class TesseractHelper { + + /** + * Tesseract Generator Helpers + * + * @param player + * @return + */ + + //Checks if a Generator is owned by a player. + public final static boolean isGeneratorOwnedByPlayer(EntityPlayer player, + GT_MetaTileEntity_TesseractGenerator generator) { + if (player == null){ + Logger.WARNING("Failed. [isGeneratorOwnedByPlayer]"); + return false; + } + //Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 1"); + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { + //Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 2"); + Map<Integer, GT_MetaTileEntity_TesseractGenerator> generators = getGeneratorOwnershipByPlayer(player); + Set<Entry<Integer, GT_MetaTileEntity_TesseractGenerator>> players = generators.entrySet(); + Iterator<Entry<Integer, GT_MetaTileEntity_TesseractGenerator>> i = players.iterator(); + while (i.hasNext()) { + //Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 3"); + Entry<Integer, GT_MetaTileEntity_TesseractGenerator> current = i.next(); + if (current.getValue().equals(generator)) { + //Utils.LOG_WARNING("Success. [isGeneratorOwnedByPlayer] 4"); + return true; + } + } + } + Logger.WARNING("Failed. [isGeneratorOwnedByPlayer]"); + return false; + } + + //Saves A Generator to the Players UUID map along with the Freq. + public final static boolean setGeneratorOwnershipByPlayer(EntityPlayer player, int freq, + GT_MetaTileEntity_TesseractGenerator generator) { + if (player == null){ + return false; + } + UUID playerIdentifier = player.getUniqueID(); + Logger.WARNING("Setting Generator on "+freq+" for "+player.getDisplayName()+"."); + if (playerIdentifier != null) { + Map<Integer, GT_MetaTileEntity_TesseractGenerator> playerOwned = sTesseractGeneratorOwnershipMap + .get(playerIdentifier); + if (playerOwned == null || playerOwned.isEmpty()) { + Map<Integer, GT_MetaTileEntity_TesseractGenerator> newOwnershipMap = new HashMap<Integer, GT_MetaTileEntity_TesseractGenerator>(); + newOwnershipMap.put(freq, generator); + sTesseractGeneratorOwnershipMap.put(playerIdentifier, newOwnershipMap); + Logger.WARNING("Success! [Empty Map]"); + return true; + } else if (sTesseractGeneratorOwnershipMap.containsKey(playerIdentifier)) { + Map<Integer, GT_MetaTileEntity_TesseractGenerator> ownershipMap = sTesseractGeneratorOwnershipMap + .get(playerIdentifier); + if (!ownershipMap.containsKey(freq)){ + ownershipMap.put(freq, generator); + } + ownershipMap.put(freq, generator); + sTesseractGeneratorOwnershipMap.put(playerIdentifier, ownershipMap); + Logger.WARNING("Success!"); + return true; + } + } + Logger.WARNING("Failed. [setGeneratorOwnershipByPlayer]"); + return false; + } + + //Gets Generator based on Frequency. + public final static GT_MetaTileEntity_TesseractGenerator getGeneratorByFrequency(EntityPlayer player, + int freq) { + if (player == null){ + return null; + } + UUID playerIdentifier = player.getUniqueID(); + Logger.WARNING("Getting Generator on "+freq+" for "+player.getDisplayName()+"."); + if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { + //Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 1"); + Map<Integer, GT_MetaTileEntity_TesseractGenerator> generators = getGeneratorOwnershipByPlayer(player); + Set<Entry<Integer, GT_MetaTileEntity_TesseractGenerator>> players = generators.entrySet(); + Iterator<Entry<Integer, GT_MetaTileEntity_TesseractGenerator>> i = players.iterator(); + while (i.hasNext()) { + //Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 2"); + Entry<Integer, GT_MetaTileEntity_TesseractGenerator> current = i.next(); + if (current.getKey().equals(freq)) { + //Utils.LOG_WARNING("Success. [getGeneratorByFrequency] 3"); + Logger.WARNING("Success!"); + return current.getValue(); + } + } + } + Logger.WARNING("Failed. [getGeneratorByFrequency]"); + return null; + } + + //Remove Tesseract Generator + public final static boolean removeGenerator(EntityPlayer player, int frequency) { + if (player == null){ + return false; + } + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { + sTesseractGeneratorOwnershipMap.get(playerIdentifier).remove(frequency); + return true; + } + return false; + } + + /** + * + * Tesseract Terminal Helpers + * + * @param player + * @return + */ + + //Checks if a Terminal is owned by a player. + public final static boolean isTerminalOwnedByPlayer(EntityPlayer player, + GT_MetaTileEntity_TesseractTerminal generator) { + if (player == null){ + return false; + } + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { + Map<Integer, GT_MetaTileEntity_TesseractTerminal> generators = getTerminalOwnershipByPlayer(player); + Set<Entry<Integer, GT_MetaTileEntity_TesseractTerminal>> players = generators.entrySet(); + Iterator<Entry<Integer, GT_MetaTileEntity_TesseractTerminal>> i = players.iterator(); + while (i.hasNext()) { + Entry<Integer, GT_MetaTileEntity_TesseractTerminal> current = i.next(); + if (current.getValue().equals(generator)) { + return true; + } + } + } + return false; + } + + //Saves A Terminal to the Players UUID map along with the Freq. + public final static boolean setTerminalOwnershipByPlayer(EntityPlayer player, int freq, + GT_MetaTileEntity_TesseractTerminal generator) { + if (player == null){ + return false; + } + UUID playerIdentifier = player.getUniqueID(); + if (playerIdentifier != null) { + Logger.WARNING("Setting Terminal on "+freq+" for "+player.getDisplayName()+"."); + Map<Integer, GT_MetaTileEntity_TesseractTerminal> playerOwned = sTesseractTerminalOwnershipMap + .get(playerIdentifier); + if (playerOwned == null || playerOwned.isEmpty()) { + Map<Integer, GT_MetaTileEntity_TesseractTerminal> newOwnershipMap = new HashMap<Integer, GT_MetaTileEntity_TesseractTerminal>(); + newOwnershipMap.put(freq, generator); + sTesseractTerminalOwnershipMap.put(playerIdentifier, newOwnershipMap); + Logger.WARNING("Success! [Empty Map]"); + return true; + } else if (sTesseractTerminalOwnershipMap.containsKey(playerIdentifier)) { + Map<Integer, GT_MetaTileEntity_TesseractTerminal> ownershipMap = sTesseractTerminalOwnershipMap + .get(playerIdentifier); + if (!ownershipMap.containsKey(freq)){ + ownershipMap.put(freq, generator); + } + sTesseractTerminalOwnershipMap.put(playerIdentifier, ownershipMap); + Logger.WARNING("Success!"); + return true; + } + } + Logger.WARNING("Failed. [setTerminalOwnershipByPlayer]"); + return false; + } + + //Gets Terminal based on Frequency. + public final static GT_MetaTileEntity_TesseractTerminal getTerminalByFrequency(EntityPlayer player, + int freq) { + if (player == null){ + return null; + } + UUID playerIdentifier = player.getUniqueID(); + Logger.WARNING("Getting Terminal on "+freq+" for "+player.getDisplayName()+"."); + if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { + Map<Integer, GT_MetaTileEntity_TesseractTerminal> generators = getTerminalOwnershipByPlayer(player); + Set<Entry<Integer, GT_MetaTileEntity_TesseractTerminal>> players = generators.entrySet(); + Iterator<Entry<Integer, GT_MetaTileEntity_TesseractTerminal>> i = players.iterator(); + while (i.hasNext()) { + Entry<Integer, GT_MetaTileEntity_TesseractTerminal> current = i.next(); + if (current.getKey().equals(freq)) { + Logger.WARNING("Success!"); + return current.getValue(); + } + } + } + Logger.WARNING("Failed. [getTerminalByFrequency]"); + return null; + } + + //Remove Tesseract Terminal + public final static boolean removeTerminal(EntityPlayer player, int frequency) { + if (player == null){ + return false; + } + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { + sTesseractTerminalOwnershipMap.get(playerIdentifier).remove(frequency); + return true; + } + return false; + } + + /** + * + * Internal Methods + * + */ + + private final static Map<Integer, GT_MetaTileEntity_TesseractGenerator> getGeneratorOwnershipByPlayer( + EntityPlayer player) { + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractGeneratorOwnershipMap.isEmpty() && playerIdentifier != null) { + Set<Entry<UUID, Map<Integer, GT_MetaTileEntity_TesseractGenerator>>> players = sTesseractGeneratorOwnershipMap + .entrySet(); + Iterator<Entry<UUID, Map<Integer, GT_MetaTileEntity_TesseractGenerator>>> i = players.iterator(); + while (i.hasNext()) { + Entry<UUID, Map<Integer, GT_MetaTileEntity_TesseractGenerator>> current = i.next(); + if (current.getKey().compareTo(playerIdentifier) == 0) { + return current.getValue(); + } + + } + } + return null; + } + + private final static Map<Integer, GT_MetaTileEntity_TesseractTerminal> getTerminalOwnershipByPlayer( + EntityPlayer player) { + UUID playerIdentifier = player.getUniqueID(); + if (!sTesseractTerminalOwnershipMap.isEmpty() && playerIdentifier != null) { + Set<Entry<UUID, Map<Integer, GT_MetaTileEntity_TesseractTerminal>>> players = sTesseractTerminalOwnershipMap + .entrySet(); + Iterator<Entry<UUID, Map<Integer, GT_MetaTileEntity_TesseractTerminal>>> i = players.iterator(); + while (i.hasNext()) { + Entry<UUID, Map<Integer, GT_MetaTileEntity_TesseractTerminal>> current = i.next(); + if (current.getKey().compareTo(playerIdentifier) == 0) { + return current.getValue(); + } + + } + } + return null; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java new file mode 100644 index 0000000000..bb40c9b379 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java @@ -0,0 +1,386 @@ +package gtPlusPlus.xmod.gregtech.common.helpers.treefarm; + +import java.util.Random; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.FakeBlockPos; +import gtPlusPlus.api.objects.minecraft.FakeWorld; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Direction; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraftforge.common.util.ForgeDirection; + +public class TreeGenerator { + + private static final FakeTreeInFakeWorldGenerator mTreeData; + + static { + Logger.WARNING("Created Fake Tree Generator."); + mTreeData = new FakeTreeInFakeWorldGenerator(); + } + + + public TreeGenerator() { + if (!mTreeData.hasGenerated) { + mTreeData.generate(null, CORE.RANDOM, 0, 0, 0); + } + } + + public AutoMap<ItemStack> generateOutput(int aTreeSize){ + AutoMap<ItemStack> aOutputMap = mTreeData.getOutputFromTree(); + if (aOutputMap != null && aOutputMap.size() > 0) { + Logger.WARNING("Valid tree data output"); + return aOutputMap; + } + Logger.WARNING("Invalid tree data output"); + return new AutoMap<ItemStack>(); + } + + public static class FakeTreeInFakeWorldGenerator extends WorldGenAbstractTree + { + /** The minimum height of a generated tree. */ + private final int minTreeHeight; + /** True if this tree should grow Vines. */ + private final boolean vinesGrow; + /** The metadata value of the wood to use in tree generation. */ + private final int metaWood; + /** The metadata value of the leaves to use in tree generation. */ + private final int metaLeaves; + + private final AutoMap<FakeWorld> mFakeWorld; + private final int mTreesToGenerate; + + private int mCurrentGeneratorIteration = 0; + + private boolean hasGenerated = false; + private AutoMap<ItemStack> aOutputsFromGenerator = new AutoMap<ItemStack>(); + + public FakeTreeInFakeWorldGenerator() + { + this(4, 0, 0, false, 5000); + } + + public FakeTreeInFakeWorldGenerator(int aMinHeight, int aWoodMeta, int aLeafMeta, boolean aVines, int aTreeCount) + { + super(false); + this.minTreeHeight = aMinHeight; + this.metaWood = aWoodMeta; + this.metaLeaves = aLeafMeta; + this.vinesGrow = aVines; + this.mFakeWorld = new AutoMap<FakeWorld>(); + this.mTreesToGenerate = aTreeCount; + Logger.WARNING("Created Fake Tree In Fake World Instance."); + } + + + public AutoMap<ItemStack> getOutputFromTree(){ + if (!hasGenerated) { + Logger.WARNING("Generating Tree sample data"); + generate(null, CORE.RANDOM, 0, 0, 0); + } + AutoMap<ItemStack> aOutputMap = new AutoMap<ItemStack>(); + int aRandomTreeID = MathUtils.randInt(0, this.mFakeWorld.size()-1); + FakeWorld aWorld = this.mFakeWorld.get(aRandomTreeID); + if (aWorld != null) { + //Logger.WARNING("Getting all block data from fake world"); + aOutputMap = aWorld.getAllBlocksStoredInFakeWorld(); + } + return aOutputMap; + + } + + @Override + protected boolean func_150523_a(Block p_150523_1_) + { + return p_150523_1_.getMaterial() == Material.air || p_150523_1_.getMaterial() == Material.leaves || p_150523_1_ == Blocks.grass || p_150523_1_ == Blocks.dirt || p_150523_1_ == Blocks.log || p_150523_1_ == Blocks.log2 || p_150523_1_ == Blocks.sapling || p_150523_1_ == Blocks.vine; + } + + @Override + protected boolean isReplaceable(World world, int x, int y, int z) + { + FakeWorld aWorld = getWorld(); + Block block = aWorld.getBlock(x, y, z); + return block.isAir(null, x, y, z) || block.isLeaves(null, x, y, z) || block.isWood(null, x, y, z) || func_150523_a(block); + } + + @Override + public boolean generate(World world, Random aRand, int aWorldX, int aWorldRealY, int aWorldZ){ + //Only Generate Once - This object is Cached + if (hasGenerated) { + return hasGenerated; + } + else { + for (int yy=0;yy<mTreesToGenerate;yy++) { + generateTree(0, 0, 0); + mCurrentGeneratorIteration++; + } + hasGenerated = true; + if (this.mFakeWorld.size() > 0) { + for (FakeWorld aWorld : this.mFakeWorld) { + for (ItemStack aBlockInFakeWorld : aWorld.getAllBlocksStoredInFakeWorld()) { + aOutputsFromGenerator.add(aBlockInFakeWorld); + } + } + return true; + } + else { + return false; + } + } + } + + private FakeWorld aFakeWorld; + + public FakeWorld getWorld() { + FakeWorld aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); + if (aWorld == null) { + this.mFakeWorld.set(mCurrentGeneratorIteration, new FakeWorld(200)); + aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); + } + return aWorld; + } + + public boolean generateTree(int aWorldX, int aWorldRealY, int aWorldZ) { + FakeWorld aWorld = getWorld(); + + //Set some static values + + Logger.WARNING("Stepping through generateTree [0]"); + //Dummy Value + int aWorldY = 10; + + int l = CORE.RANDOM.nextInt(3) + this.minTreeHeight; + boolean flag = true; + + if (aWorldY >= 1 && aWorldY + l + 1 <= 256) + { + Logger.WARNING("Stepping through generateTree [1]"); + byte b0; + int k1; + Block block; + + for (int i1 = aWorldY; i1 <= aWorldY + 1 + l; ++i1) + { + b0 = 1; + + if (i1 == aWorldY) + { + b0 = 0; + } + + if (i1 >= aWorldY + 1 + l - 2) + { + b0 = 2; + } + + for (int j1 = aWorldX - b0; j1 <= aWorldX + b0 && flag; ++j1) + { + for (k1 = aWorldZ - b0; k1 <= aWorldZ + b0 && flag; ++k1) + { + if (i1 >= 0 && i1 < 256) + { + block = aWorld.getBlock(j1, i1, k1); + + if (!this.isReplaceable(null, j1, i1, k1)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + Logger.WARNING("Stepping through generateTree [2]"); + return false; + } + else + { + Logger.WARNING("Stepping through generateTree [3]"); + Block block2 = aWorld.getBlock(aWorldX, aWorldY - 1, aWorldZ); + FakeBlockPos aBlockToGrowPlantOn = aWorld.getBlockAtCoords(aWorldX, aWorldY-1, aWorldZ); + + boolean isSoil = block2.canSustainPlant(aWorld, aWorldX, aWorldY - 1, aWorldZ, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (/*isSoil &&*/ aWorldY < 256 - l - 1) + { + Logger.WARNING("Stepping through generateTree [4]"); + aBlockToGrowPlantOn.onPlantGrow(aWorld, aWorldX, aWorldY - 1, aWorldZ, aWorldX, aWorldY, aWorldZ); + b0 = 3; + byte b1 = 0; + int l1; + int i2; + int j2; + int i3; + + for (k1 = aWorldY - b0 + l; k1 <= aWorldY + l; ++k1) + { + i3 = k1 - (aWorldY + l); + l1 = b1 + 1 - i3 / 2; + + for (i2 = aWorldX - l1; i2 <= aWorldX + l1; ++i2) + { + j2 = i2 - aWorldX; + + for (int k2 = aWorldZ - l1; k2 <= aWorldZ + l1; ++k2) + { + int l2 = k2 - aWorldZ; + + if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || CORE.RANDOM.nextInt(2) != 0 && i3 != 0) + { + Block block1 = aWorld.getBlock(i2, k1, k2); + + if (block1.isAir(null, i2, k1, k2) || block1.isLeaves(null, i2, k1, k2)) + { + this.setBlockAndNotifyAdequately(aWorld, i2, k1, k2, Blocks.leaves, this.metaLeaves); + } + } + } + } + } + Logger.WARNING("Stepping through generateTree [5]"); + + for (k1 = 0; k1 < l; ++k1) + { + block = aWorld.getBlock(aWorldX, aWorldY + k1, aWorldZ); + + if (block.isAir(null, aWorldX, aWorldY + k1, aWorldZ) || block.isLeaves(null, aWorldX, aWorldY + k1, aWorldZ)) + { + this.setBlockAndNotifyAdequately(aWorld, aWorldX, aWorldY + k1, aWorldZ, Blocks.log, this.metaWood); + + if (this.vinesGrow && k1 > 0) + { + if (CORE.RANDOM.nextInt(3) > 0 && aWorld.isAirBlock(aWorldX - 1, aWorldY + k1, aWorldZ)) + { + this.setBlockAndNotifyAdequately(aWorld, aWorldX - 1, aWorldY + k1, aWorldZ, Blocks.vine, 8); + } + + if (CORE.RANDOM.nextInt(3) > 0 && aWorld.isAirBlock(aWorldX + 1, aWorldY + k1, aWorldZ)) + { + this.setBlockAndNotifyAdequately(aWorld, aWorldX + 1, aWorldY + k1, aWorldZ, Blocks.vine, 2); + } + + if (CORE.RANDOM.nextInt(3) > 0 && aWorld.isAirBlock(aWorldX, aWorldY + k1, aWorldZ - 1)) + { + this.setBlockAndNotifyAdequately(aWorld, aWorldX, aWorldY + k1, aWorldZ - 1, Blocks.vine, 1); + } + + if (CORE.RANDOM.nextInt(3) > 0 && aWorld.isAirBlock(aWorldX, aWorldY + k1, aWorldZ + 1)) + { + this.setBlockAndNotifyAdequately(aWorld, aWorldX, aWorldY + k1, aWorldZ + 1, Blocks.vine, 4); + } + } + } + } + Logger.WARNING("Stepping through generateTree [6]"); + + if (this.vinesGrow) + { + Logger.WARNING("Stepping through generateTree [7]"); + for (k1 = aWorldY - 3 + l; k1 <= aWorldY + l; ++k1) + { + i3 = k1 - (aWorldY + l); + l1 = 2 - i3 / 2; + + for (i2 = aWorldX - l1; i2 <= aWorldX + l1; ++i2) + { + for (j2 = aWorldZ - l1; j2 <= aWorldZ + l1; ++j2) + { + if (aWorld.getBlock(i2, k1, j2).isLeaves(null, i2, k1, j2)) + { + if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2 - 1, k1, j2).isAir(null, i2 - 1, k1, j2)) + { + this.growVines(aWorld, i2 - 1, k1, j2, 8); + } + + if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2 + 1, k1, j2).isAir(null, i2 + 1, k1, j2)) + { + this.growVines(aWorld, i2 + 1, k1, j2, 2); + } + + if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2, k1, j2 - 1).isAir(null, i2, k1, j2 - 1)) + { + this.growVines(aWorld, i2, k1, j2 - 1, 1); + } + + if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2, k1, j2 + 1).isAir(null, i2, k1, j2 + 1)) + { + this.growVines(aWorld, i2, k1, j2 + 1, 4); + } + } + } + } + } + Logger.WARNING("Stepping through generateTree [8]"); + + if (CORE.RANDOM.nextInt(5) == 0 && l > 5) + { + for (k1 = 0; k1 < 2; ++k1) + { + for (i3 = 0; i3 < 4; ++i3) + { + if (CORE.RANDOM.nextInt(4 - k1) == 0) + { + l1 = CORE.RANDOM.nextInt(3); + this.setBlockAndNotifyAdequately(aWorld, aWorldX + Direction.offsetX[Direction.rotateOpposite[i3]], aWorldY + l - 5 + k1, aWorldZ + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa, l1 << 2 | i3); + } + } + } + } + } + Logger.WARNING("Stepping through generateTree [9]"); + return true; + } + else + { + Logger.WARNING("Stepping through generateTree [10]"); + return false; + } + } + } + else + { + Logger.WARNING("Stepping through generateTree [11]"); + return false; + } + } + + /** + * Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length + */ + private void growVines(FakeWorld aWorld, int aX, int aY, int aZ, int aMeta) + { + int aLoopSize = vinesGrow ? MathUtils.randInt(0, 4) : 0; + for (int i=0;i<aLoopSize;i++) { + this.setBlockAndNotifyAdequately(aWorld, aX, aY, aZ, Blocks.vine, aMeta); + } + } + + @Override + protected void setBlockAndNotifyAdequately(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + setBlockAndNotifyAdequately(getWorld(), aX, aY, aZ, aBlock, aMeta); + } + + protected void setBlockAndNotifyAdequately(FakeWorld aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + if (aBlock != null && (aMeta >= 0 && aMeta <= Short.MAX_VALUE)) { + Logger.WARNING("Setting block "+aX+", "+aY+", "+aZ+" | "+aBlock.getLocalizedName()+" | "+aMeta); + aWorld.setBlockAtCoords(aX, aY, aZ, aBlock, aMeta); + //aOutputsFromGenerator.put(ItemUtils.simpleMetaStack(aBlock, aMeta, 1)); + } + } + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java new file mode 100644 index 0000000000..7c3f764794 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java @@ -0,0 +1,225 @@ +package gtPlusPlus.xmod.gregtech.common.items; + +import java.util.List; + +import org.apache.commons.lang3.StringUtils; + +import cofh.core.render.IconRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_MultiTexture; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.client.renderer.CustomItemBlockRenderer; +import gtPlusPlus.core.common.CommonProxy; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_ToggleVisual; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +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; + +public class MetaCustomCoverItem extends Item { + + protected final IIcon[] icons; + private final String mModID; + private final String mTextureSetName; + protected final IIconContainer[] mTextures; + private final short[][] mRGB; + + public MetaCustomCoverItem(String aModId, int aTextureCount, String aTextureSetName, IIconContainer[] aTextures, short[][] aRGB) { + super(); + icons = new IIcon[aTextureCount]; + mModID = aModId; + mTextureSetName = Utils.sanitizeString(aTextureSetName); + mTextures = aTextures; + mRGB = aRGB; + this.setTextureName(CORE.MODID + ":" + "itemPlate"); + this.setHasSubtypes(true); + String unlocalizedName = "itemCustomMetaCover." + mModID + "." + mTextureSetName; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + GameRegistry.registerItem(this, unlocalizedName); + registerCover(); + Logger.INFO("[Covers] Generated Custom covers for "+mModID+" using "+aTextureCount+" textures from "+mTextureSetName+"."); + } + + public boolean hide() { + return true; + } + + private final void registerCover() { + //CommonProxy.registerItemRendererGlobal(this, new CustomItemBlockRenderer()); + for (int i=0;i<icons.length;i++) { + ItemStack thisStack = ItemUtils.simpleMetaStack(this, i, 1); + if (i > 0 && hide()) { + ItemUtils.hideItemFromNEI(thisStack); + } + GregTech_API.registerCover( + thisStack, + new GT_MultiTexture( + new ITexture[]{ + new GT_RenderedTexture(mTextures[i]) + }), + new GTPP_Cover_ToggleVisual()); + } + } + + /* + * @Override public void registerIcons(IIconRegister reg) { for (int i = 0; i < + * icons.length; i++) { this.icons[i] = mTextures[i].getIcon(); } } + * + * @Override public IIcon getIconFromDamage(int meta) { return this.icons[meta]; + * } + */ + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < icons.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + return StringUtils.capitalize(mTextureSetName) + " (" + tItem.getItemDamage() + ")"; //super.getItemStackDisplayName(tItem); + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagNBT.setBoolean("AllowConnections", false); + tagMain.setTag("CustomCoverMeta", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getCoverDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + return aNBT.getLong("Damage"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setCoverDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + aNBT.setLong("Damage", aDamage); + return true; + } + } + return false; + } + + public static final boolean getCoverConnections(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + return aNBT.getBoolean("AllowConnections"); + } + } else { + createNBT(aStack); + } + return false; + } + + public static final boolean setCoverConnections(final ItemStack aStack, final boolean aConnections) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("CustomCoverMeta"); + if (aNBT != null) { + aNBT.setBoolean("AllowConnections", aConnections); + return true; + } + } + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); + } + double currentDamage = getCoverDamage(stack); + double meta = stack.getItemDamage() == 0 ? 50 : 2500; + double durabilitypercent = currentDamage / meta; + return durabilitypercent; + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (KeyboardUtils.isShiftKeyDown()) { + boolean con = getCoverConnections(stack); + if (con) { + setCoverConnections(stack, false); + } else { + setCoverConnections(stack, true); + } + } + return stack; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + boolean cons = getCoverConnections(stack); + list.add(EnumChatFormatting.GRAY + "Allows Connections: "+cons); + list.add(EnumChatFormatting.GRAY + "Shift Rmb to change state before applying"); + super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public Item setFull3D() { + // TODO Auto-generated method stub + return super.setFull3D(); + } + + @Override + public boolean isFull3D() { + // TODO Auto-generated method stub + return super.isFull3D(); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.mRGB == null){ + return super.getColorFromItemStack(stack, HEX_OxFFFFFF); + } + int aMeta = stack.getItemDamage(); + return Utils.rgbtoHexValue(mRGB[aMeta][0], mRGB[aMeta][1], mRGB[aMeta][2]); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java new file mode 100644 index 0000000000..ce8b6eaf62 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -0,0 +1,453 @@ +package gtPlusPlus.xmod.gregtech.common.items; + +import static gtPlusPlus.core.util.Utils.getTcAspectStack; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TC_Aspects; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_MultiTexture; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.ItemData; +import gregtech.api.objects.MaterialStack; +import gregtech.api.util.GT_FoodStat; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GTPP_Recipe; +import gregtech.common.covers.GT_Cover_Arm; +import gregtech.common.covers.GT_Cover_Conveyor; +import gregtech.common.covers.GT_Cover_Pump; +import gregtech.common.items.behaviors.Behaviour_DataOrb; +import gregtech.common.items.behaviors.Behaviour_DataStick; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.OldCircuitHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.StringUtils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaItem_X32; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow; +import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow_Item; +import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_ToggleVisual; +import net.minecraft.item.EnumAction; +import net.minecraft.item.ItemStack; + +public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { + + public final static MetaGeneratedGregtechItems INSTANCE; + + static { + INSTANCE = new MetaGeneratedGregtechItems(); + } + + public MetaGeneratedGregtechItems() { + super("MU-metaitem.01", new OrePrefixes[]{null}); + } + + public void generateMetaItems() { + int tLastID = 0; + + registerCustomCircuits(); + OldCircuitHandler.addCircuitItems(); + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + Logger.INFO("Gregtech 5.09 not found, using fallback components. (I like how I have to add compat to something I added first and had stolen.)"); + GregtechItemList.Electric_Pump_LuV.set(this.addItem(tLastID = 0, "Electric Pump (LuV)", "163920 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Electric_Pump_ZPM.set(this.addItem(tLastID = 1, "Electric Pump (ZPM)", "655680 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.ITER, 2L), getTcAspectStack(TC_Aspects.AQUA, 2L)})); + GregtechItemList.Electric_Pump_UV.set(this.addItem(tLastID = 2, "Electric Pump (UV)", "2622720 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.ITER, 4L), getTcAspectStack(TC_Aspects.AQUA, 4L)})); + GregtechItemList.Electric_Pump_MAX.set(this.addItem(tLastID = 3, "Electric Pump (MAX)", "10490880 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.ITER, 8L), getTcAspectStack(TC_Aspects.AQUA, 8L)})); + GregTech_API.registerCover(GregtechItemList.Electric_Pump_LuV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(8196)); + GregTech_API.registerCover(GregtechItemList.Electric_Pump_ZPM.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[6][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(32768)); + GregTech_API.registerCover(GregtechItemList.Electric_Pump_UV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[7][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(131072)); + GregTech_API.registerCover(GregtechItemList.Electric_Pump_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(524288)); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), GregtechItemList.Electric_Motor_LuV, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), Character.valueOf('X'), OrePrefixes.rotor.get(Materials.Tin), Character.valueOf('S'), OrePrefixes.screw.get(Materials.Tin), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Tin), Character.valueOf('P'), OrePrefixes.pipeMedium.get(Materials.Bronze)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), GregtechItemList.Electric_Motor_ZPM, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), Character.valueOf('X'), OrePrefixes.rotor.get(Materials.Bronze), Character.valueOf('S'), OrePrefixes.screw.get(Materials.Bronze), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.AnyCopper), Character.valueOf('P'), OrePrefixes.pipeMedium.get(Materials.Steel)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), GregtechItemList.Electric_Motor_UV, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), Character.valueOf('X'), OrePrefixes.rotor.get(Materials.Steel), Character.valueOf('S'), OrePrefixes.screw.get(Materials.Steel), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Gold), Character.valueOf('P'), OrePrefixes.pipeMedium.get(Materials.StainlessSteel)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Pump_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SXO", "dPw", "OMW", Character.valueOf('M'), GregtechItemList.Electric_Motor_MAX, Character.valueOf('O'), OrePrefixes.ring.get(Materials.Rubber), Character.valueOf('X'), OrePrefixes.rotor.get(Materials.StainlessSteel), Character.valueOf('S'), OrePrefixes.screw.get(Materials.StainlessSteel), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Aluminium), Character.valueOf('P'), OrePrefixes.pipeMedium.get(Materials.Titanium)}); + tLastID = 4; + GregtechItemList.Electric_Motor_LuV.set(this.addItem(tLastID = 4, "Electric Motor (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.MOTUS, 1L)})); + GregtechItemList.Electric_Motor_ZPM.set(this.addItem(tLastID = 5, "Electric Motor (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 2L)})); + GregtechItemList.Electric_Motor_UV.set(this.addItem(tLastID = 6, "Electric Motor (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.MOTUS, 4L)})); + GregtechItemList.Electric_Motor_MAX.set(this.addItem(tLastID = 7, "Electric Motor (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.MOTUS, 8L)})); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), OrePrefixes.stick.get(Materials.IronMagnetic), Character.valueOf('R'), OrePrefixes.stick.get(Materials.AnyIron), Character.valueOf('W'), OrePrefixes.wireGt01.get(Materials.AnyCopper), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), OrePrefixes.stick.get(Materials.SteelMagnetic), Character.valueOf('R'), OrePrefixes.stick.get(Materials.Aluminium), Character.valueOf('W'), OrePrefixes.wireGt01.get(Materials.Electrum), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Silver)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), OrePrefixes.stick.get(Materials.SteelMagnetic), Character.valueOf('R'), OrePrefixes.stick.get(Materials.StainlessSteel), Character.valueOf('W'), OrePrefixes.wireGt02.get(Materials.Cupronickel), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Motor_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CWR", "WIW", "RWC", Character.valueOf('I'), OrePrefixes.stick.get(Materials.NeodymiumMagnetic), Character.valueOf('R'), OrePrefixes.stick.get(Materials.Titanium), Character.valueOf('W'), OrePrefixes.wireGt02.get(Materials.TungstenSteel), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Nichrome)}); + + tLastID = 8; + GregtechItemList.Conveyor_Module_LuV.set(this.addItem(tLastID = 8, "Conveyor Module (LuV)", "1 Stack every 20 secs (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L)})); + GregtechItemList.Conveyor_Module_ZPM.set(this.addItem(tLastID = 9, "Conveyor Module (ZPM)", "1 Stack every 5 secs (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.ITER, 2L)})); + GregtechItemList.Conveyor_Module_UV.set(this.addItem(tLastID = 10, "Conveyor Module (UV)", "1 Stack every 1 sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.ITER, 4L)})); + GregtechItemList.Conveyor_Module_MAX.set(this.addItem(tLastID = 11, "Conveyor Module (MAX)", "1 Stack every 1/5 sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.ITER, 8L)})); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), GregtechItemList.Electric_Motor_LuV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin), Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), GregtechItemList.Electric_Motor_ZPM, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.AnyCopper), Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), GregtechItemList.Electric_Motor_UV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold), Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Conveyor_Module_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"RRR", "MCM", "RRR", Character.valueOf('M'), GregtechItemList.Electric_Motor_MAX, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Aluminium), Character.valueOf('R'), OrePrefixes.plate.get(Materials.Rubber)}); + GregTech_API.registerCover(GregtechItemList.Conveyor_Module_LuV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(400)); + GregTech_API.registerCover(GregtechItemList.Conveyor_Module_ZPM.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(100)); + GregTech_API.registerCover(GregtechItemList.Conveyor_Module_UV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[3][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(20)); + GregTech_API.registerCover(GregtechItemList.Conveyor_Module_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(4)); + tLastID = 12; + GregtechItemList.Electric_Piston_LuV.set(this.addItem(tLastID = 12, "Electric Piston (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 1L)})); + GregtechItemList.Electric_Piston_ZPM.set(this.addItem(tLastID = 13, "Electric Piston (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.MOTUS, 2L)})); + GregtechItemList.Electric_Piston_UV.set(this.addItem(tLastID = 14, "Electric Piston (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.MOTUS, 4L)})); + GregtechItemList.Electric_Piston_MAX.set(this.addItem(tLastID = 15, "Electric Piston (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 16L), getTcAspectStack(TC_Aspects.MOTUS, 8L)})); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), OrePrefixes.plate.get(Materials.Steel), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Steel), Character.valueOf('G'), OrePrefixes.gearGtSmall.get(Materials.Steel), Character.valueOf('M'), GregtechItemList.Electric_Motor_LuV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), OrePrefixes.plate.get(Materials.Aluminium), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Aluminium), Character.valueOf('G'), OrePrefixes.gearGtSmall.get(Materials.Aluminium), Character.valueOf('M'), GregtechItemList.Electric_Motor_ZPM, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.AnyCopper)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), OrePrefixes.plate.get(Materials.StainlessSteel), Character.valueOf('S'), OrePrefixes.stick.get(Materials.StainlessSteel), Character.valueOf('G'), OrePrefixes.gearGtSmall.get(Materials.StainlessSteel), Character.valueOf('M'), GregtechItemList.Electric_Motor_UV, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Electric_Piston_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"PPP", "CSS", "CMG", Character.valueOf('P'), OrePrefixes.plate.get(Materials.Titanium), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Titanium), Character.valueOf('G'), OrePrefixes.gearGtSmall.get(Materials.Titanium), Character.valueOf('M'), GregtechItemList.Electric_Motor_MAX, Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Aluminium)}); + tLastID = 16; + GregtechItemList.Robot_Arm_LuV.set(this.addItem(tLastID = 16, "Robot Arm (LuV)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 1L), Utils.getTcAspectStack("COGNITIO", 1L)})); + GregtechItemList.Robot_Arm_ZPM.set(this.addItem(tLastID = 17, "Robot Arm (ZPM)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.MOTUS, 2L), getTcAspectStack("COGNITIO", 2L)})); + GregtechItemList.Robot_Arm_UV.set(this.addItem(tLastID = 18, "Robot Arm (UV)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.MOTUS, 4L), getTcAspectStack("COGNITIO", 4L)})); + GregtechItemList.Robot_Arm_MAX.set(this.addItem(tLastID = 19, "Robot Arm (MAX)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 16L), getTcAspectStack(TC_Aspects.MOTUS, 8L), getTcAspectStack("COGNITIO", 8L)})); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), OrePrefixes.stick.get(Materials.Steel), Character.valueOf('M'), GregtechItemList.Electric_Motor_LuV, Character.valueOf('P'), GregtechItemList.Electric_Piston_LuV, Character.valueOf('E'), OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Tin)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), OrePrefixes.stick.get(Materials.Aluminium), Character.valueOf('M'), GregtechItemList.Electric_Motor_ZPM, Character.valueOf('P'), GregtechItemList.Electric_Piston_ZPM, Character.valueOf('E'), OrePrefixes.circuit.get(Materials.Good), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.AnyCopper)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), OrePrefixes.stick.get(Materials.StainlessSteel), Character.valueOf('M'), GregtechItemList.Electric_Motor_UV, Character.valueOf('P'), GregtechItemList.Electric_Piston_UV, Character.valueOf('E'), OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Gold)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Robot_Arm_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"CCC", "MSM", "PES", Character.valueOf('S'), OrePrefixes.stick.get(Materials.Titanium), Character.valueOf('M'), GregtechItemList.Electric_Motor_MAX, Character.valueOf('P'), GregtechItemList.Electric_Piston_MAX, Character.valueOf('E'), OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('C'), OrePrefixes.cableGt01.get(Materials.Aluminium)}); + GregTech_API.registerCover(GregtechItemList.Robot_Arm_LuV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(400)); + GregTech_API.registerCover(GregtechItemList.Robot_Arm_ZPM.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(100)); + GregTech_API.registerCover(GregtechItemList.Robot_Arm_UV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[3][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(20)); + GregTech_API.registerCover(GregtechItemList.Robot_Arm_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(4)); + tLastID = 20; + GregtechItemList.Field_Generator_LuV.set(this.addItem(tLastID = 20, "Field Generator (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.TUTAMEN, 1L)})); + GregtechItemList.Field_Generator_ZPM.set(this.addItem(tLastID = 21, "Field Generator (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.TUTAMEN, 2L)})); + GregtechItemList.Field_Generator_UV.set(this.addItem(tLastID = 22, "Field Generator (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.TUTAMEN, 4L)})); + GregtechItemList.Field_Generator_MAX.set(this.addItem(tLastID = 23, "Field Generator (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.TUTAMEN, 8L)})); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), OrePrefixes.gem.get(Materials.EnderPearl), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('W'), OrePrefixes.wireGt01.get(Materials.Osmium)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), OrePrefixes.gem.get(Materials.EnderEye), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), OrePrefixes.wireGt02.get(Materials.Osmium)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), OrePrefixes.gem.get(Materials.NetherStar), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Osmium)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Field_Generator_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WCW", "CGC", "WCW", Character.valueOf('G'), OrePrefixes.gem.get(Materials.NetherStar), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Osmium)}); + tLastID = 24; + GregtechItemList.Emitter_LuV.set(this.addItem(tLastID = 24, "Emitter (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.LUX, 1L)})); + GregtechItemList.Emitter_ZPM.set(this.addItem(tLastID = 25, "Emitter (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.LUX, 2L)})); + GregtechItemList.Emitter_UV.set(this.addItem(tLastID = 26, "Emitter (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.LUX, 4L)})); + GregtechItemList.Emitter_MAX.set(this.addItem(tLastID = 27, "Emitter (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.LUX, 8L)})); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.Quartzite), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Brass), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Tin)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.NetherQuartz), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Electrum), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.AnyCopper)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.Emerald), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Chrome), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Gold)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Emitter_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"SSC", "WQS", "CWS", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.EnderPearl), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Platinum), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('W'), OrePrefixes.cableGt01.get(Materials.Aluminium)}); + tLastID = 28; + GregtechItemList.Sensor_LuV.set(this.addItem(tLastID = 28, "Sensor (LuV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.SENSUS, 1L)})); + GregtechItemList.Sensor_ZPM.set(this.addItem(tLastID = 29, "Sensor (ZPM)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.SENSUS, 2L)})); + GregtechItemList.Sensor_UV.set(this.addItem(tLastID = 30, "Sensor (UV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 4L), getTcAspectStack(TC_Aspects.MACHINA, 4L), getTcAspectStack(TC_Aspects.SENSUS, 4L)})); + GregtechItemList.Sensor_MAX.set(this.addItem(tLastID = 31, "Sensor (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.SENSUS, 8L)})); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_LuV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.Quartzite), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Brass), Character.valueOf('P'), OrePrefixes.plate.get(Materials.Steel), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Basic)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_ZPM.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.NetherQuartz), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Electrum), Character.valueOf('P'), OrePrefixes.plate.get(Materials.Aluminium), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Good)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_UV.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.Emerald), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Chrome), Character.valueOf('P'), OrePrefixes.plate.get(Materials.StainlessSteel), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Advanced)}); + //GT_ModHandler.addCraftingRecipe(GregtechItemList.Sensor_MAX.get(1L), //GT_ModHandler.RecipeBits.DISMANTLEABLE | //GT_ModHandler.RecipeBits.NOT_REMOVABLE | //GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"P Q", "PS ", "CPP", Character.valueOf('Q'), OrePrefixes.gem.get(Materials.EnderPearl), Character.valueOf('S'), OrePrefixes.stick.get(Materials.Platinum), Character.valueOf('P'), OrePrefixes.plate.get(Materials.Titanium), Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Elite)}); + + //Handler for ULV Components + registerComponents_ULV(); + + + } + + else { + //Simplify life. + registerComponents_ULV(); + registerComponents_MAX(); + } + + //Extruder Shape + GregtechItemList.Shape_Extruder_WindmillShaft.set(this.addItem(tLastID = 40, "Extruder Shape (Shaft)", "Extruder Shape for making Windmill Shafts")); + + //GTNH Already adds this. + if (!CORE.GTNH) { + GregtechItemList.Shape_Extruder_SmallGear.set(this.addItem(221, "Extruder Shape (Small Gear)", "Extruder Shape for making small gears")); + } + + //Batteries + GregtechItemList.Battery_RE_EV_Sodium.set(this.addItem(tLastID = 50, "Quad Cell Sodium Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L), getTcAspectStack(TC_Aspects.POTENTIA, 2L)})); + this.setElectricStats(32000 + tLastID, 3200000L, GT_Values.V[4], 4L, -3L, true); + + GregtechItemList.Battery_RE_EV_Cadmium.set(this.addItem(tLastID = 52, "Quad Cell Cadmium Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.METALLUM, 1L), getTcAspectStack(TC_Aspects.POTENTIA, 1L)})); + this.setElectricStats(32000 + tLastID, 4800000L, GT_Values.V[4], 4L, -3L, true); + + GregtechItemList.Battery_RE_EV_Lithium.set(this.addItem(tLastID = 54, "Quad Cell Lithium Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 3L), getTcAspectStack(TC_Aspects.METALLUM, 3L), getTcAspectStack(TC_Aspects.POTENTIA, 3L)})); + this.setElectricStats(32000 + tLastID, 6400000L, GT_Values.V[4], 4L, -3L, true); + + /** + * Power Gems + */ + + GregtechItemList.Battery_Gem_1.set(this.addItem(tLastID = 66, "Proton Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 24L), getTcAspectStack(TC_Aspects.POTENTIA, 16L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[6] * 20 * 300 / 4, GT_Values.V[6], 6L, -3L, false); + GregtechItemList.Battery_Gem_2.set(this.addItem(tLastID = 68, "Electron Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.METALLUM, 32L), getTcAspectStack(TC_Aspects.POTENTIA, 32L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[7] * 20 * 300 / 4, GT_Values.V[7], 7L, -3L, false); + GregtechItemList.Battery_Gem_3.set(this.addItem(tLastID = 70, "Quark Entanglement", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 32L), getTcAspectStack(TC_Aspects.METALLUM, 48L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[8] * 20 * 300 / 4, GT_Values.V[8], 8L, -3L, false); + //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_1.get(1), "batteryFutureBasic"); + //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_2.get(1), "batteryFutureGood"); + //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_3.get(1), "batteryFutureAdvanced"); + + + /*GregtechItemList.Battery_RE_EV_Sodium.set(addItem(tLastID = 50, "Quad Cell Acid Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.METALLUM, 1L), getTcAspectStack(TC_Aspects.POTENTIA, 1L)})); + setElectricStats(32000 + tLastID, 5000000L, GT_Values.V[2], 4L, -3L, true); + + GregtechItemList.Battery_RE_EV_Sodium.set(addItem(tLastID = 50, "Quad Cell Mercury Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.METALLUM, 1L), getTcAspectStack(TC_Aspects.POTENTIA, 1L)})); + setElectricStats(32000 + tLastID, 5000000L, GT_Values.V[2], 4L, -3L, true);*/ + + //RTG Pellet + GregtechItemList.Pellet_RTG_PU238.set(this.addItem(41, StringUtils.superscript("238")+"Pu Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); + GregtechItemList.Pellet_RTG_SR90.set(this.addItem(42, StringUtils.superscript("90")+"Sr Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); + GregtechItemList.Pellet_RTG_PO210.set(this.addItem(43, StringUtils.superscript("210")+"Po Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); + GregtechItemList.Pellet_RTG_AM241.set(this.addItem(44, StringUtils.superscript("241")+"Am Pellet", "", new Object[]{getTcAspectStack(TC_Aspects.RADIO, 4L), getTcAspectStack(TC_Aspects.POTENTIA, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L)})); + + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_PU238.get(1), MathUtils.roundToClosestInt(87.7f), 64); + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_SR90.get(1), MathUtils.roundToClosestInt(28.8f), 32); + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_PO210.get(1), 1, 512); + CORE.RA.addFuelForRTG(GregtechItemList.Pellet_RTG_AM241.get(1), MathUtils.roundToClosestInt(432/2), 16); + CORE.RA.addFuelForRTG(GT_ModHandler.getIC2Item("RTGPellets", 1), MathUtils.roundToClosestInt(2.6f), 8); + + //Computer Cube + GregtechItemList.Gregtech_Computer_Cube.set(this.addItem(tLastID = 55, "Gregtech Computer Cube", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[6]* 10 * 60 * 20, GT_Values.V[5], 5L, -3L, true); + + //FOOOOOOOOOOOOOOD + GregtechItemList.Food_Baked_Raisin_Bread.set(this.addItem(tLastID = 60, "Raisin Bread", "Extra Raisins, Just for ImQ009", new Object[]{new GT_FoodStat(5, 0.5F, EnumAction.eat, null, false, true, false, new int[0]), getTcAspectStack(TC_Aspects.CORPUS, 1L), getTcAspectStack(TC_Aspects.FAMES, 1L), getTcAspectStack(TC_Aspects.IGNIS, 1L)})); + + if (!CORE.GTNH) { + GregtechItemList.Fluid_Cell_144L.set(this.addItem(tLastID = 61, "144L Invar Fluid Cell", "Holds exactly one dust worth of liquid.", new Object[]{new ItemData(Materials.Invar, (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + this.setFluidContainerStats(32000 + tLastID, 144L, 64L); + + GregtechItemList.Fluid_Cell_36L.set(this.addItem(tLastID = 62, "36L Brass Fluid Cell", "Holds exactly one small dust worth of liquid.", new Object[]{new ItemData(Materials.Brass, (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + this.setFluidContainerStats(32000 + tLastID, 36L, 64L); + + GregtechItemList.Fluid_Cell_16L.set(this.addItem(tLastID = 63, "16L Bronze Fluid Cell", "Holds exactly one tiny dust / nugget worth of liquid.", new Object[]{new ItemData(Materials.Bronze, (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + this.setFluidContainerStats(32000 + tLastID, 16L, 64L); + + GregtechItemList.Fluid_Cell_1L.set(this.addItem(tLastID = 64, "1L Wrought Iron Fluid Cell", "Holds exactly one litre worth of liquid.", new Object[]{new ItemData(Materials.WroughtIron, (OrePrefixes.plate.mMaterialAmount * 8L) + (4L * OrePrefixes.ring.mMaterialAmount), new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + this.setFluidContainerStats(32000 + tLastID, 1L, 64L); + } + + + + GregtechItemList.Cover_Overflow_ULV.set(this.addItem(71, "Overflow Valve (ULV)", "Maximum void amount: 8000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_LV.set(this.addItem(72, "Overflow Valve (LV)", "Maximum void amount: 64000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_MV.set(this.addItem(73, "Overflow Valve (MV)", "Maximum void amount: 512000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_HV.set(this.addItem(74, "Overflow Valve (HV)", "Maximum void amount: 4096000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_EV.set(this.addItem(75, "Overflow Valve (EV)", "Maximum void amount: 32768000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_IV.set(this.addItem(76, "Overflow Valve (IV)", "Maximum void amount: 262144000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(8)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_LV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(64)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_MV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(512)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_HV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(4096)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_EV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(32768)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_IV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow(262144)); + + //Fusion Reactor MK4 Singularity + GregtechItemList.Compressed_Fusion_Reactor.set(this.addItem(100, "Hypervisor Matrix (Fusion)", "A memory unit containing an RI (Restricted Intelligence)")); + + + //NanoTubes + GregtechItemList.NanoTube_Base_Substrate.set(this.addItem(101, "Silicon Base Substrate", "Used in the production of Carbon Nanotubes")); + GregtechItemList.NanoTube_Finished.set(this.addItem(102, "Carbon Nanotubes", "Multi-walled Zigzag nanotubes, possibly Carbon's final form")); + GregtechItemList.Carbyne_Tube_Finished.set(this.addItem(103, "Linear Acetylenic Carbon (LAC/Carbyne)", "LAC chains grown inside Multi-walled Carbon Nanotubes, highly stable")); + GregtechItemList.Carbyne_Sheet_Finished.set(this.addItem(104, "Carbyne Composite Panel", "Nanotubes which contain LAC, arranged side by side and compressed further")); + GregtechItemList.Laser_Lens_Special.set(this.addItem(105, "Quantum Anomaly", "Probably should shoot it with lasers")); + + GregtechItemList.Battery_Casing_Gem_1.set(this.addItem(106, "Containment Unit I", "Used in crafting")); + GregtechItemList.Battery_Casing_Gem_2.set(this.addItem(107, "Containment Unit II", "Used in crafting")); + GregtechItemList.Battery_Casing_Gem_3.set(this.addItem(108, "Advanced Containment Unit", "Used in crafting")); + GregtechItemList.Battery_Casing_Gem_4.set(this.addItem(109, "Exotic Containment Unit", "Used in crafting")); + + GregtechItemList.Battery_Gem_4.set(this.addItem(tLastID = 110, "Graviton Anomaly", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 64L), getTcAspectStack(TC_Aspects.METALLUM, 64L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); + this.setElectricStats(32000 + tLastID, (64000000000L*16), GT_Values.V[9], 9L, -3L, false); + + + + /* + * Bombs + */ + GregtechItemList.Bomb_Cast.set(this.addItem(111, "Bomb Cast", "Used in the production of Bombs")); + GregtechItemList.Bomb_Cast_Molten.set(this.addItem(112, "Bomb Cast (Hot)", "Consider cooling this off")); + GregtechItemList.Bomb_Cast_Set.set(this.addItem(113, "Bomb Cast (Set)", "Break it open for the goodies inside!")); + GregtechItemList.Bomb_Cast_Broken.set(this.addItem(114, "Bomb Cast (Broken)", "This is probably just junk")); + GregtechItemList.Bomb_Cast_Mold.set(this.addItem(115, "Mold (Bomb Cast)", "Used in the production of Bombs")); + + /* + * High Tier 'Saws' for the tree Farm + */ + GregtechItemList.Farm_Processor_EV.set(this.addItem(tLastID = 120, "Farm Processor [EV]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[5]* 10 * 60 * 20, GT_Values.V[4], 4L, -3L, false); + GregtechItemList.Farm_Processor_IV.set(this.addItem(tLastID = 122, "Farm Processor [IV]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[6]* 10 * 60 * 20, GT_Values.V[5], 5L, -3L, false); + GregtechItemList.Farm_Processor_LuV.set(this.addItem(tLastID = 124, "Farm Processor [LuV]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[7]* 10 * 60 * 20, GT_Values.V[6], 6L, -3L, false); + GregtechItemList.Farm_Processor_ZPM.set(this.addItem(tLastID = 126, "Farm Processor [ZPM]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[8]* 10 * 60 * 20, GT_Values.V[7], 7L, -3L, false); + GregtechItemList.Farm_Processor_UV.set(this.addItem(tLastID = 128, "Farm Processor [UV]", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 8L), getTcAspectStack(TC_Aspects.POTENTIA, 8L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[9]* 10 * 60 * 20, GT_Values.V[8], 8L, -3L, false); + + String aTierName; + int aFirstMachineCasingID = 130; + GregtechItemList[] mMachineCasingCovers = new GregtechItemList[] { + GregtechItemList.FakeMachineCasingPlate_ULV, + GregtechItemList.FakeMachineCasingPlate_LV, + GregtechItemList.FakeMachineCasingPlate_MV, + GregtechItemList.FakeMachineCasingPlate_HV, + GregtechItemList.FakeMachineCasingPlate_EV, + GregtechItemList.FakeMachineCasingPlate_IV, + GregtechItemList.FakeMachineCasingPlate_LuV, + GregtechItemList.FakeMachineCasingPlate_ZPM, + GregtechItemList.FakeMachineCasingPlate_UV, + GregtechItemList.FakeMachineCasingPlate_MAX, + }; + for (int i=0;i<10;i++) { + if (i==10) { + break; + } + else { + aTierName = GT_Values.VN[i]; + mMachineCasingCovers[i].set(this.addItem(aFirstMachineCasingID++, aTierName+" Machine Plate Cover", "Deprecated - Shapeless Craft to new version", new Object[]{})); + GregTech_API.registerCover(mMachineCasingCovers[i].get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[i][0]}), new GTPP_Cover_ToggleVisual()); + } + } + GregtechItemList.Laser_Lens_WoodsGlass.set(this.addItem(140, "Wood's Glass Lens", "Allows UV & IF to pass through, blocks visible light spectrums")); + + int aStartID = 141; + GregtechItemList[] aTransParts = new GregtechItemList[] { + GregtechItemList.TransmissionComponent_ULV, + GregtechItemList.TransmissionComponent_LV, + GregtechItemList.TransmissionComponent_MV, + GregtechItemList.TransmissionComponent_HV, + GregtechItemList.TransmissionComponent_EV, + GregtechItemList.TransmissionComponent_IV, + GregtechItemList.TransmissionComponent_LuV, + GregtechItemList.TransmissionComponent_ZPM, + GregtechItemList.TransmissionComponent_UV, + GregtechItemList.TransmissionComponent_MAX, + }; + for (int aIndex=0;aIndex<10;aIndex++){ + aTransParts[aIndex].set(this.addItem(aStartID++, "Transmission Component ("+GT_Values.VN[aIndex]+")", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, aIndex), getTcAspectStack(TC_Aspects.MACHINA, aIndex), getTcAspectStack(TC_Aspects.MAGNETO, aIndex)})); + } + + // Distillus Chip + GregtechItemList.Distillus_Upgrade_Chip.set(this.addItem(151, "Upgrade Chip", "Used to upgrade Distillus to Tier 2")); + + + GregtechItemList.Chip_MultiNerf_NoOutputBonus.set(this.addItem(160, "No-Bonus Chip", "You won't like using this")); + GregtechItemList.Chip_MultiNerf_NoSpeedBonus.set(this.addItem(161, "No-Bonus Chip", "You won't like using this")); + GregtechItemList.Chip_MultiNerf_NoEuBonus.set(this.addItem(162, "No-Bonus Chip", "You won't like using this")); + + + /* + GregtechItemList.Cover_Overflow_Item_ULV.set(this.addItem(165, "Item Overflow Valve (ULV)", "Maximum void amount: 8000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_LV.set(this.addItem(166, "Item Overflow Valve (LV)", "Maximum void amount: 64000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_MV.set(this.addItem(167, "Item Overflow Valve (MV)", "Maximum void amount: 512000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_HV.set(this.addItem(168, "Item Overflow Valve (HV)", "Maximum void amount: 4096000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_EV.set(this.addItem(169, "Item Overflow Valve (EV)", "Maximum void amount: 32768000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Cover_Overflow_Item_IV.set(this.addItem(170, "Item Overflow Valve (IV)", "Maximum void amount: 262144000", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(8)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_LV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(64)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_MV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(512)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_HV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(4096)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_EV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(32768)); + GregTech_API.registerCover(GregtechItemList.Cover_Overflow_Item_IV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Overflow_Valve)}), new GTPP_Cover_Overflow_Item(262144)); + */ + } + + private boolean registerComponents_ULV(){ + GregtechItemList.Electric_Pump_ULV.set(this.addItem(32, "Electric Pump (ULV)", "160 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); + GregtechItemList.Electric_Motor_ULV.set(this.addItem(33, "Electric Motor (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.MOTUS, 1L)})); + GregtechItemList.Conveyor_Module_ULV.set(this.addItem(34, "Conveyor Module (ULV)", "1 Stack every 80 secs (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L)})); + GregtechItemList.Electric_Piston_ULV.set(this.addItem(35, "Electric Piston (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 1L)})); + GregtechItemList.Robot_Arm_ULV.set(this.addItem(36, "Robot Arm (ULV)", "Inserts into specific Slots (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 2L), getTcAspectStack(TC_Aspects.MOTUS, 1L), Utils.getTcAspectStack("COGNITIO", 1L)})); + GregtechItemList.Field_Generator_ULV.set(this.addItem(37, "Field Generator (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.TUTAMEN, 1L)})); + GregtechItemList.Emitter_ULV.set(this.addItem(38, "Emitter (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.LUX, 1L)})); + GregtechItemList.Sensor_ULV.set(this.addItem(39, "Sensor (ULV)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.SENSUS, 1L)})); + + GregTech_API.registerCover(GregtechItemList.Electric_Pump_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[5][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(8)); + GregTech_API.registerCover(GregtechItemList.Conveyor_Module_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(1600)); + GregTech_API.registerCover(GregtechItemList.Robot_Arm_ULV.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(1600)); + + return true; + } + + private boolean registerComponents_MAX(){ + GregtechItemList.Electric_Pump_MAX.set(this.addItem(3, "Electric Pump (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.ITER, 8L), getTcAspectStack(TC_Aspects.AQUA, 8L)})); + GregtechItemList.Electric_Motor_MAX.set(this.addItem(7, "Electric Motor (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.MOTUS, 8L)})); + GregtechItemList.Conveyor_Module_MAX.set(this.addItem(11, "Conveyor Module (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.ITER, 8L)})); + GregtechItemList.Electric_Piston_MAX.set(this.addItem(15, "Electric Piston (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 16L), getTcAspectStack(TC_Aspects.MOTUS, 8L)})); + GregtechItemList.Robot_Arm_MAX.set(this.addItem(19, "Robot Arm (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 16L), getTcAspectStack(TC_Aspects.MOTUS, 8L), getTcAspectStack("COGNITIO", 8L)})); + GregtechItemList.Field_Generator_MAX.set(this.addItem(23, "Field Generator (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.TUTAMEN, 8L)})); + GregtechItemList.Emitter_MAX.set(this.addItem(27, "Emitter (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.LUX, 8L)})); + GregtechItemList.Sensor_MAX.set(this.addItem(31, "Sensor (MAX)", "", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.MACHINA, 8L), getTcAspectStack(TC_Aspects.SENSUS, 8L)})); + + GregTech_API.registerCover(GregtechItemList.Electric_Pump_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[8][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PUMP)}), new GT_Cover_Pump(524288)); + GregTech_API.registerCover(GregtechItemList.Conveyor_Module_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_CONVEYOR)}), new GT_Cover_Conveyor(4)); + GregTech_API.registerCover(GregtechItemList.Robot_Arm_MAX.get(1L), new GT_MultiTexture(new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[4][0], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ARM)}), new GT_Cover_Arm(4)); + + + return true; + } + + public boolean registerOldCircuits(){ + //Enable Old Circuits + Logger.INFO("[Old Feature - Circuits] Enabling Pre-5.09.28 Circuits and Data Storage."); + + GregtechItemList.Old_Circuit_Primitive.set(this.addItem(200, "NAND Chip", "A very simple Circuit", new Object[]{OrePrefixes.circuit.get(Materials.Primitive)})); + GregtechItemList.Old_Circuit_Basic.set(this.addItem(201, "Basic Electronic Circuit", "A basic Circuit", new Object[]{OrePrefixes.circuit.get(Materials.Basic)})); + GregtechItemList.Old_Circuit_Good.set(this.addItem(202, "Good Electronic Circuit", "A good Circuit", new Object[]{OrePrefixes.circuit.get(Materials.Good)})); + GregtechItemList.Old_Circuit_Advanced.set(this.addItem(203, "Advanced Circuit", "An advanced Circuit", new Object[]{OrePrefixes.circuit.get(Materials.Advanced)})); + GregtechItemList.Old_Circuit_Data.set(this.addItem(204, "Data Storage Circuit", "A Data Storage Chip", new Object[]{OrePrefixes.circuit.get(Materials.Data)})); + GregtechItemList.Old_Circuit_Elite.set(this.addItem(205, "Data Control Circuit", "A Processor", new Object[]{OrePrefixes.circuit.get(Materials.Elite)})); + GregtechItemList.Old_Circuit_Master.set(this.addItem(206, "Energy Flow Circuit", "A High Voltage Processor", new Object[]{OrePrefixes.circuit.get(Materials.Master)})); + + GregtechItemList.Old_Tool_DataOrb.set(this.addItem(207, "Data Orb [GT++]", "A High Capacity Data Storage", new Object[]{OrePrefixes.circuit.get(Materials.Ultimate), SubTag.NO_UNIFICATION, new Behaviour_DataOrb()})); + GregtechItemList.Old_Circuit_Ultimate.set(GregtechItemList.Old_Tool_DataOrb.get(1L)); + GT_ModHandler.addShapelessCraftingRecipe(GregtechItemList.Old_Tool_DataOrb.get(1L), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{GregtechItemList.Old_Tool_DataOrb.get(1L)}); + + GregtechItemList.Old_Tool_DataStick.set(this.addItem(208, "Data Stick [GT++]", "A Low Capacity Data Storage", new Object[]{OrePrefixes.circuit.get(Materials.Data), SubTag.NO_UNIFICATION, new Behaviour_DataStick()})); + GT_ModHandler.addShapelessCraftingRecipe(GregtechItemList.Old_Tool_DataStick.get(1L), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{GregtechItemList.Old_Tool_DataStick.get(1L)}); + + GregtechItemList.Old_Circuit_Board_Basic.set(this.addItem(210, "Basic Circuit Board", "A basic Board")); + GregtechItemList.Old_Circuit_Board_Advanced.set(this.addItem(211, "Advanced Circuit Board", "An advanced Board")); + GregtechItemList.Old_Circuit_Board_Elite.set(this.addItem(212, "Processor Board", "A Processor Board")); + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite.set(this.addItem(213, "Engraved Crystal Chip", "Needed for Circuits")); + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master.set(this.addItem(214, "Engraved Lapotron Chip", "Needed for Circuits")); + GregtechItemList.Old_Circuit_Parts_Advanced.set(this.addItem(215, "Advanced Circuit Parts", "Advanced Circuit Parts")); + GregtechItemList.Old_Circuit_Parts_Wiring_Basic.set(this.addItem(216, "Etched Medium Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Old_Circuit_Parts_Wiring_Advanced.set(this.addItem(217, "Etched High Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Old_Circuit_Parts_Wiring_Elite.set(this.addItem(218, "Etched Extreme Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Old_Empty_Board_Basic.set(this.addItem(219, "Empty Circuit Board", "A Board Part")); + GregtechItemList.Old_Empty_Board_Elite.set(this.addItem(220, "Empty Processor Board", "A Processor Board Part")); + + return true; + } + + public boolean registerCustomCircuits() { + if (CORE.ConfigSwitches.enableCustomCircuits){ + GregtechItemList.Circuit_IV.set(this.addItem(704, "Symbiotic Circuit (IV)", "A Symbiotic Data Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Symbiotic)})); + GregtechItemList.Circuit_LuV.set(this.addItem(705, "Neutronic Circuit (LuV)", "A Neutron Particle Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Neutronic)})); + GregtechItemList.Circuit_ZPM.set(this.addItem(706, "Quantum Circuit (ZPM)", "A Singlularity Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Quantum)})); + GregtechItemList.Circuit_Board_IV.set(this.addItem(710, "IV Circuit Board", "An IV Voltage Rated Circuit Board")); + GregtechItemList.Circuit_Board_LuV.set(this.addItem(711, "LuV Circuit Board", "An LuV Voltage Rated Circuit Board")); + GregtechItemList.Circuit_Board_ZPM.set(this.addItem(712, "ZPM Processor Board", "A ZPM Voltage Rated Processor Board")); + GregtechItemList.Circuit_Parts_Crystal_Chip_IV.set(this.addItem(713, "(IV) Energized Crystal Chip", "Needed for Circuits")); + GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.set(this.addItem(714, "(LuV) Neutron based Microchip", "Needed for Circuits")); + GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.set(this.addItem(715, "(ZPM) Quantum Chip", "Needed for Circuits")); + GregtechItemList.Circuit_Parts_IV.set(this.addItem(716, "(IV) Energized Circuit Parts", "Circuit Parts")); + GregtechItemList.Circuit_Parts_LuV.set(this.addItem(717, "(LuV) Neutron-based Circuit Parts", "Circuit Parts")); + GregtechItemList.Circuit_Parts_ZPM.set(this.addItem(718, "(ZPM) Quantum Circuit Parts", "Circuit Parts")); + GregtechItemList.Circuit_Parts_Wiring_IV.set(this.addItem(719, "Etched IV Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Circuit_Parts_Wiring_LuV.set(this.addItem(720, "Etched LuV Voltage Wiring", "Part of Circuit Boards")); + GregtechItemList.Circuit_Parts_Wiring_ZPM.set(this.addItem(721, "Etched ZPM Voltage Wiring", "Part of Circuit Boards")); + ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_IV.get(1), "circuitSuperconductor"); + ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_LuV.get(1), "circuitInfinite"); + return true; + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java new file mode 100644 index 0000000000..14100d1599 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java @@ -0,0 +1,101 @@ +package gtPlusPlus.xmod.gregtech.common.items; + +import java.lang.reflect.Field; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.TC_Aspects; +import gregtech.api.enums.ToolDictNames; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.objects.GT_HashSet; +import gregtech.api.objects.GT_ItemStack; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechToolDictNames; +import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_AngleGrinder; +import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_Choocher; +import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_ElectricButcherKnife; +import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_ElectricLighter; +import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_ElectricSnips; + +public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { + + public static final short ELECTRIC_LIGHTER = 7534; + public static final short ELECTRIC_BUTCHER_KNIFE = 7634; + public static final short SKOOKUM_CHOOCHER = 7734; + public static final short ANGLE_GRINDER = 7834; + public static final short ELECTRIC_SNIPS = 7934; + public static GT_MetaGenerated_Tool INSTANCE; + + static { + INSTANCE = new MetaGeneratedGregtechTools(); + } + + public static GT_MetaGenerated_Tool getInstance() { + return INSTANCE; + } + + + private MetaGeneratedGregtechTools() { + super("plusplus.metatool.01"); + // Skookum Choocher + GregTech_API.registerTool(this.addTool(SKOOKUM_CHOOCHER, "Skookum Choocher", + "Can Really Chooch. Does a Skookum job at Hammering and Wrenching stuff.", new TOOL_Gregtech_Choocher(), + new Object[] { GregtechToolDictNames.craftingToolSkookumChoocher, ToolDictNames.craftingToolHardHammer, + ToolDictNames.craftingToolWrench, new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }), + GregTech_API.sWrenchList); + + // Electric File + this.addTool(ANGLE_GRINDER, "Angle Grinder", "Hand-held electric filing device", + new TOOL_Gregtech_AngleGrinder(), + new Object[] { GregtechToolDictNames.craftingToolAngleGrinder, ToolDictNames.craftingToolFile, + new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }); + + GT_HashSet<GT_ItemStack> aWireCutterList = new GT_HashSet<GT_ItemStack>(); + //Does not exist prior to 5.09.32, use an empty field if we can't find the existing one. + if (ReflectionUtils.doesFieldExist(GregTech_API.class, "sWireCutterList")) { + Field sWireCutterList = ReflectionUtils.getField(GregTech_API.class, "sWireCutterList"); + try { + if (sWireCutterList != null) { + Object val = sWireCutterList.get(null); + if (val != null && val instanceof GT_HashSet) { + aWireCutterList = (GT_HashSet<GT_ItemStack>) val; + } + } + + } + catch (IllegalArgumentException | IllegalAccessException e) { + // Not found, so it's GT 5.09.31 or earlier. + } + } + + // Electric Wire Cutter + GregTech_API.registerTool( + this.addTool(ELECTRIC_SNIPS, "Automatic Snips", "Hand-held electric wire cutter", + new TOOL_Gregtech_ElectricSnips(), + new Object[] { GregtechToolDictNames.craftingToolElectricSnips, ToolDictNames.craftingToolWireCutter, + new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 4L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 4L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 4L) }), aWireCutterList); + + + // Electric Lighter + this.addTool(ELECTRIC_LIGHTER, "Pyromatic 9k", "Electric Fire!", + new TOOL_Gregtech_ElectricLighter(), + new Object[] { GregtechToolDictNames.craftingToolElectricLighter, + new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }); + + // Electric Butcher Knife + this.addTool(ELECTRIC_BUTCHER_KNIFE, "Meat-o-matic", "Electric butcher knife", + new TOOL_Gregtech_ElectricButcherKnife(), + new Object[] { GregtechToolDictNames.craftingToolElectricButcherKnife, ToolDictNames.craftingToolKnife, + new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 1L), + new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java new file mode 100644 index 0000000000..f82e0e5cb0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Choocher.java @@ -0,0 +1,88 @@ +package gtPlusPlus.xmod.gregtech.common.items.behaviours; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.items.behaviors.Behaviour_None; +import gregtech.common.items.behaviors.Behaviour_Wrench; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; + +public class Behaviour_Choocher +extends Behaviour_None { + private boolean isWrench = true; + private final Behaviour_Wrench wrench = new Behaviour_Wrench(150); + private final Behaviour_Prospecting_Ex prospecting = new Behaviour_Prospecting_Ex(10, 1250); + private final String mTooltip1 = GT_LanguageManager.addStringLocalization("gt.behaviour.choochering1", "Current tool mode: "); + private final String mTooltip2 = GT_LanguageManager.addStringLocalization("gt.behaviour.choochering2", "Change tool mode using Shift+Rightclick."); + private final String mTooltipH = GT_LanguageManager.addStringLocalization("gt.behaviour.prospectingEx", "Usable for Prospecting large areas."); + private final String mTooltipW = GT_LanguageManager.addStringLocalization("gt.behaviour.wrench", "Rotates Blocks on Rightclick."); + + public Behaviour_Choocher() { + + } + + @Override + public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { + if (aWorld.isRemote) { + return false; + } + + boolean inWrenchMode; + if (NBTUtils.hasKey(aStack, "aMode")) { + inWrenchMode = NBTUtils.getBoolean(aStack, "aMode"); + } + else { + aStack.getTagCompound().setBoolean("aMode", true); + inWrenchMode = true; + } + + if (aPlayer.isSneaking()){ + boolean aModeNew = Utils.invertBoolean(inWrenchMode); + aStack.getTagCompound().setBoolean("aMode", aModeNew); + PlayerUtils.messagePlayer(aPlayer, "Mode: "+(aModeNew ? "Wrench" : "Hammer")); + return true; + } + else { + if (inWrenchMode){ + return this.wrench.onItemUseFirst(aItem, aStack, aPlayer, aWorld, aSide, aSide, aSide, aSide, hitZ, hitZ, hitZ); + } + else { + return this.prospecting.onItemUseFirst(aItem, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ); + } + } + } + + @Override + public List<String> getAdditionalToolTips(final GT_MetaBase_Item aItem, final List<String> aList, final ItemStack aStack) { + + boolean inWrenchMode; + if (NBTUtils.hasKey(aStack, "aMode")) { + inWrenchMode = NBTUtils.getBoolean(aStack, "aMode"); + } + else { + NBTUtils.setBoolean(aStack, "aMode", true); + aStack.getTagCompound().setBoolean("aMode", true); + inWrenchMode = true; + } + + + if (inWrenchMode){ + aList.add(this.mTooltip1+"Wrench"); + aList.add(this.mTooltipW); + } + else { + aList.add(this.mTooltip1+"Prospecting"); + aList.add(this.mTooltipH); + } + aList.add(this.mTooltip2); + + return aList; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java new file mode 100644 index 0000000000..422a29c34e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java @@ -0,0 +1,220 @@ +package gtPlusPlus.xmod.gregtech.common.items.behaviours; + +import java.util.List; + +import codechicken.lib.math.MathHelper; +import gregtech.api.GregTech_API; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_None; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.entity.projectile.EntityLightningAttack; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import ic2.api.item.IElectricItemManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class Behaviour_Electric_Lighter extends Behaviour_None { + + private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.tooltip", + "Can light things on Fire"); + private final String mTooltipUses = GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.uses", + "Remaining Uses:"); + private final String mTooltipUnstackable = GT_LanguageManager.addStringLocalization("gt.behaviour.unstackable", + "Not usable when stacked!"); + + public Behaviour_Electric_Lighter() { + + } + + public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) { + if (!aPlayer.worldObj.isRemote && aStack != null && aStack.stackSize == 1) { + boolean rOutput = false; + if (aEntity instanceof EntityCreeper) { + if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { + GT_Utility.sendSoundToPlayers(aPlayer.worldObj, (String) GregTech_API.sSoundList.get(6), 1.0F, 1.0F, + MathHelper.floor_double(aEntity.posX), MathHelper.floor_double(aEntity.posY), + MathHelper.floor_double(aEntity.posZ)); + ((EntityCreeper) aEntity).func_146079_cb(); + rOutput = true; + } + } + return rOutput; + } else { + return false; + } + } + + public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, + int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + if (!aWorld.isRemote && aStack != null && aStack.stackSize == 1) { + if (aPlayer.isSneaking()) { + Logger.INFO("Changing Mode"); + boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + Logger.INFO("Is currently in Fireball mode? "+aCurrentMode); + boolean aNewMode = Utils.invertBoolean(aCurrentMode); + Logger.INFO("Is now set to Fireball mode? "+aNewMode); + aStack.getTagCompound().setBoolean("aFireballMod", aNewMode); + //NBTUtils.setBoolean(aStack, "aFireballMode", aNewMode); + PlayerUtils.messagePlayer(aPlayer, "Current Mode: "+EnumChatFormatting.RED+(aNewMode ? "Projectile" : "Fire Starter")); + } + else { + boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + if (aCurrentMode) { + //Shoot Lightning Attack + aWorld.playSoundAtEntity(aPlayer, "random.bow", 0.5F, 0.4F / (CORE.RANDOM.nextFloat() * 0.4F + 0.8F)); + if (!aWorld.isRemote) { + aWorld.spawnEntityInWorld(new EntityLightningAttack(aWorld, aPlayer, hitX, hitY, hitZ)); + } + } + else { + //Lights Fires Mode + Logger.WARNING("Preparing Lighter a"); + boolean rOutput = false; + ForgeDirection tDirection = ForgeDirection.getOrientation(aSide); + aX += tDirection.offsetX; + aY += tDirection.offsetY; + aZ += tDirection.offsetZ; + if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { + Logger.WARNING("Preparing Lighter b"); + if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { + Logger.WARNING("Preparing Lighter c"); + GT_Utility.sendSoundToPlayers(aWorld, (String) GregTech_API.sSoundList.get(6), 1.0F, 1.0F, aX, aY, + aZ); + aWorld.setBlock(aX, aY, aZ, Blocks.fire); + rOutput = true; + // ItemNBT.setLighterFuel(aStack, tFuelAmount); + return rOutput; + } + } + } + } + } + Logger.WARNING("Preparing Lighter z"); + return false; + } + + public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, + int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + if (!aWorld.isRemote && aStack != null && aStack.stackSize == 1) { + if (aPlayer.isSneaking()) { + Logger.INFO("Changing Mode"); + boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + Logger.INFO("Is currently in Fireball mode? "+aCurrentMode); + boolean aNewMode = Utils.invertBoolean(aCurrentMode); + Logger.INFO("Is now set to Fireball mode? "+aNewMode); + aStack.getTagCompound().setBoolean("aFireballMode", aNewMode); + //NBTUtils.setBoolean(aStack, "aFireballMode", aNewMode); + PlayerUtils.messagePlayer(aPlayer, "Current Mode: "+EnumChatFormatting.RED+(aNewMode ? "Projectile" : "Fire Starter")); + } + else { + boolean aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + if (aCurrentMode) { + //Shoot Lightning Attack + aWorld.playSoundAtEntity(aPlayer, "random.bow", 0.5F, 0.4F / (CORE.RANDOM.nextFloat() * 0.4F + 0.8F)); + if (!aWorld.isRemote) { + aWorld.spawnEntityInWorld(new EntityLightningAttack(aWorld, aPlayer, hitX, hitY, hitZ)); + } + } + else { + //Lights Fires Mode + Logger.WARNING("Preparing Lighter a"); + boolean rOutput = false; + ForgeDirection tDirection = ForgeDirection.getOrientation(aSide); + aX += tDirection.offsetX; + aY += tDirection.offsetY; + aZ += tDirection.offsetZ; + if (GT_Utility.isBlockAir(aWorld, aX, aY, aZ) && aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { + Logger.WARNING("Preparing Lighter b"); + if (this.prepare(aStack) || aPlayer.capabilities.isCreativeMode) { + Logger.WARNING("Preparing Lighter c"); + GT_Utility.sendSoundToPlayers(aWorld, (String) GregTech_API.sSoundList.get(6), 1.0F, 1.0F, aX, aY, + aZ); + aWorld.setBlock(aX, aY, aZ, Blocks.fire); + rOutput = true; + // ItemNBT.setLighterFuel(aStack, tFuelAmount); + return rOutput; + } + } + } + } + } + Logger.WARNING("Preparing Lighter z"); + return false; + } + + private boolean prepare(ItemStack aStack) { + if (aStack != null) { + Logger.WARNING("Preparing Lighter 1"); + if (aStack.getItem() instanceof MetaGeneratedGregtechTools) { + Logger.WARNING("Preparing Lighter 2"); + if (ChargingHelper.isItemValid(aStack)) { + Logger.WARNING("Preparing Lighter 3"); + if (aStack.getItem() instanceof IElectricItemManager) { + Logger.WARNING("Preparing Lighter 4"); + IElectricItemManager aItemElec = (IElectricItemManager) aStack.getItem(); + double aCharge = aItemElec.getCharge(aStack); + long aEuCost = 4096 * 2; + if (aCharge >= aEuCost) { + Logger.WARNING("Preparing Lighter 5"); + aItemElec.discharge(aStack, aEuCost, 3, true, true, false); + return true; + } + } + } + } + } + Logger.WARNING("Preparing Lighter 0"); + return false; + } + + private void useUp(ItemStack aStack) { + + } + + public List<String> getAdditionalToolTips(GT_MetaBase_Item aItem, List<String> aList, ItemStack aStack) { + aList.add(this.mTooltip); + int aUses = 0; + if (aStack != null) { + if (aStack.getItem() instanceof MetaGeneratedGregtechTools) { + if (ChargingHelper.isItemValid(aStack)) { + if (aStack.getItem() instanceof IElectricItemManager) { + IElectricItemManager aItemElec = (IElectricItemManager) aStack.getItem(); + double aCharge = aItemElec.getCharge(aStack); + long aEuCost = 4096 * 2; + aUses = (int) (aCharge / aEuCost); + } + } + boolean aCurrentMode; + if (!NBTUtils.hasTagCompound(aStack)) { + NBTUtils.createEmptyTagCompound(aStack); + } + if (NBTUtils.hasKey(aStack, "aFireballMode")) { + aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMode"); + } + else { + aStack.getTagCompound().setBoolean("aFireballMode", false); + aCurrentMode = false; + } + aList.add("Current Mode: "+EnumChatFormatting.RED+(aCurrentMode ? "Projectile" : "Fire Starter")); + } + + } + + aList.add(this.mTooltipUses + " " + aUses); + aList.add(this.mTooltipUnstackable); + return aList; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Grinder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Grinder.java new file mode 100644 index 0000000000..9012bb8cd8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Grinder.java @@ -0,0 +1,94 @@ +package gtPlusPlus.xmod.gregtech.common.items.behaviours; + +import java.util.List; + +import gregtech.api.enums.SubTag; +import gregtech.api.interfaces.IItemBehaviour; +import gregtech.api.items.GT_MetaBase_Item; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class Behaviour_Grinder implements IItemBehaviour<GT_MetaBase_Item> { + + @Override + public boolean onLeftClickEntity(GT_MetaBase_Item var1, ItemStack var2, EntityPlayer var3, Entity var4) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean onItemUse(GT_MetaBase_Item var1, ItemStack var2, EntityPlayer var3, World var4, int var5, int var6, + int var7, int var8, float var9, float var10, float var11) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean onItemUseFirst(GT_MetaBase_Item var1, ItemStack var2, EntityPlayer var3, World var4, int var5, + int var6, int var7, int var8, float var9, float var10, float var11) { + // TODO Auto-generated method stub + return false; + } + + @Override + public ItemStack onItemRightClick(GT_MetaBase_Item var1, ItemStack var2, World var3, EntityPlayer var4) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List<String> getAdditionalToolTips(GT_MetaBase_Item var1, List<String> var2, ItemStack var3) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void onUpdate(GT_MetaBase_Item var1, ItemStack var2, World var3, Entity var4, int var5, boolean var6) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isItemStackUsable(GT_MetaBase_Item var1, ItemStack var2) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean canDispense(GT_MetaBase_Item var1, IBlockSource var2, ItemStack var3) { + // TODO Auto-generated method stub + return false; + } + + @Override + public ItemStack onDispense(GT_MetaBase_Item var1, IBlockSource var2, ItemStack var3) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean hasProjectile(GT_MetaBase_Item var1, SubTag var2, ItemStack var3) { + // TODO Auto-generated method stub + return false; + } + + @Override + public EntityArrow getProjectile(GT_MetaBase_Item var1, SubTag var2, ItemStack var3, World var4, double var5, + double var7, double var9) { + // TODO Auto-generated method stub + return null; + } + + @Override + public EntityArrow getProjectile(GT_MetaBase_Item var1, SubTag var2, ItemStack var3, World var4, + EntityLivingBase var5, float var6) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java new file mode 100644 index 0000000000..f320bfc77d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Prospecting_Ex.java @@ -0,0 +1,123 @@ +package gtPlusPlus.xmod.gregtech.common.items.behaviours; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.common.blocks.GT_Block_Ores; +import gregtech.common.blocks.GT_TileEntity_Ores; +import gregtech.common.items.behaviors.Behaviour_Prospecting; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.IFluidBlock; + +public class Behaviour_Prospecting_Ex +extends Behaviour_Prospecting { + private final int mVanillaCosts; + private final int mEUCosts; + + public Behaviour_Prospecting_Ex(final int aVanillaCosts, final int aEUCosts) { + super(aVanillaCosts, aEUCosts); + this.mVanillaCosts = aVanillaCosts; + this.mEUCosts = aEUCosts; + } + + @Override + public boolean onItemUseFirst(final GT_MetaBase_Item aItem, final ItemStack aStack, final EntityPlayer aPlayer, final World aWorld, final int aX, final int aY, final int aZ, final int aSide, final float hitX, final float hitY, final float hitZ) { + if (aWorld.isRemote) { + return false; + } + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + final byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + + + ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(aBlock, 1, aMeta)); + if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { + GT_Utility.sendChatToPlayer(aPlayer, "This is " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); + return true; + } + if ((aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) || (aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.dirt)) ||(aBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.grass)) ) { + if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { + GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(Integer.valueOf(1)), 1.0F, -1.0F, aX, aY, aZ); + int tX = aX; + int tY = aY; + int tZ = aZ; + int tMetaID = 0; + final int tQuality = ((aItem instanceof GT_MetaGenerated_Tool) ? ((GT_MetaGenerated_Tool) aItem).getHarvestLevel(aStack, "") : 0)*3; + + int i = 0; + for (final int j = 6 + tQuality; i < j; i++) { + tX -= ForgeDirection.getOrientation(aSide).offsetX; + tY -= ForgeDirection.getOrientation(aSide).offsetY; + tZ -= ForgeDirection.getOrientation(aSide).offsetZ; + + final Block tBlock = aWorld.getBlock(tX, tY, tZ); + if ((tBlock == Blocks.lava) || (tBlock == Blocks.flowing_lava)) { + GT_Utility.sendChatToPlayer(aPlayer, "There is Lava behind this Block."); + break; + } + if ((tBlock == Blocks.water) || (tBlock == Blocks.flowing_water) || ((tBlock instanceof IFluidBlock))) { + GT_Utility.sendChatToPlayer(aPlayer, "There is a Liquid behind this Block."); + break; + } + if ((tBlock == Blocks.monster_egg) || (!GT_Utility.hasBlockHitBox(aWorld, tX, tY, tZ))) { + GT_Utility.sendChatToPlayer(aPlayer, "There is an Air Pocket behind this Block."); + break; + } + if (tBlock != aBlock) { + if (i >= 4) { + break; + } + GT_Utility.sendChatToPlayer(aPlayer, "Material is changing behind this Block."); + break; + } + } + final Random tRandom = new Random(aX ^ aY ^ aZ ^ aSide); + i = 0; + for (final int j = 9 + (2 * tQuality); i < j; i++) { + tX = (aX - 4 - tQuality) + tRandom.nextInt(j); + tY = (aY - 4 - tQuality) + tRandom.nextInt(j); + tZ = (aZ - 4 - tQuality) + tRandom.nextInt(j); + final Block tBlock = aWorld.getBlock(tX, tY, tZ); + if ((tBlock instanceof GT_Block_Ores)) { + final TileEntity tTileEntity = aWorld.getTileEntity(tX, tY, tZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + final Materials tMaterial = GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)]; + if ((tMaterial != null) && (tMaterial != Materials._NULL)) { + GT_Utility.sendChatToPlayer(aPlayer, "Found traces of " + tMaterial.mDefaultLocalName + " Ore."); + return true; + } + } + } else { + tMetaID = aWorld.getBlockMetadata(tX, tY, tZ); + tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); + if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) { + GT_Utility.sendChatToPlayer(aPlayer, "Found traces of " + tAssotiation.mMaterial.mMaterial.mDefaultLocalName + " Ore."); + return true; + } + } + } + GT_Utility.sendChatToPlayer(aPlayer, "No Ores found."); + } + return true; + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java new file mode 100644 index 0000000000..7af057bc59 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/covers/MetaItemCoverCasings.java @@ -0,0 +1,40 @@ +package gtPlusPlus.xmod.gregtech.common.items.covers; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +public class MetaItemCoverCasings extends MetaCustomCoverItem { + + public MetaItemCoverCasings() { + super(CORE.MODID, Textures.BlockIcons.MACHINECASINGS_SIDE.length, "Gt Machine Casings", Textures.BlockIcons.MACHINECASINGS_SIDE, null); + } + + @Override + public void registerIcons(IIconRegister reg) { + for (int i = 0; i < icons.length; i++) { + this.icons[i] = reg.registerIcon(CORE.MODID+":"+"covers/"+i); + } + } + + public boolean hide() { + return false; + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[MathUtils.balance(meta, 0, 15)]; + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + return EnumChatFormatting.LIGHT_PURPLE + GT_Values.VOLTAGE_NAMES[MathUtils.balance(tItem.getItemDamage(), 0, GT_Values.VOLTAGE_NAMES.length-1)]+" Machine Plate Cover"; //super.getItemStackDisplayName(tItem); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java new file mode 100644 index 0000000000..49537ab559 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -0,0 +1,517 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import java.io.*; +import java.net.URL; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import org.apache.commons.io.IOUtils; +import org.lwjgl.opengl.GL11; + +import com.mojang.authlib.GameProfile; + +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.data.AES; +import gtPlusPlus.core.util.data.FileUtils; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderPlayerEvent; + +public class GTPP_CapeRenderer extends RenderPlayer { + + 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"), + }; + + private final boolean mInit; + + public GTPP_CapeRenderer() { + mInit = init(); + } + + private final boolean init() { + if (mInit) { + return false; + } + return CapeUtils.init(); + } + + private static boolean hasResourceChecked = false; + private static boolean hasSetRenderer = false; + private boolean hasCape = false; + 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; + } + } + + // Actually Render + if (hasSetRenderer) { + + // We have capes turned off, so let's not render. + if (!ConfigSwitches.enableCustomCapes) { + return; + } + + // 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; + } + } + + // 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; + } + + String aPlayerName = ClientProxy.playerName; + + // 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; + } + + if (hasResourceChecked) { + // We have met all the conditions, let's render that cape. + renderCapeOnPlayer(aEvent, aPlayer); + } + } + + } + + 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); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, 0.125F); + double d0 = aPlayer.field_71091_bM + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks + - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks); + double d1 = aPlayer.field_71096_bN + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks + - (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) * aPartialTicks); + double d2 = aPlayer.field_71097_bO + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks + - (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks); + float f6 = aPlayer.prevRenderYawOffset + + (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks; + double d3 = MathHelper.sin(f6 * CORE.PI / 180.0F); + double d4 = -MathHelper.cos(f6 * CORE.PI / 180.0F); + float f7 = (float) d1 * 10.0F; + float f8 = (float) (d0 * d3 + d2 * d4) * 100.0F; + float f9 = (float) (d0 * d4 - d2 * d3) * 100.0F; + if (f7 < -6.0F) { + f7 = -6.0F; + } + if (f7 > 32.0F) { + f7 = 32.0F; + } + if (f8 < 0.0F) { + f8 = 0.0F; + } + float f10 = aPlayer.prevCameraYaw + (aPlayer.cameraYaw - aPlayer.prevCameraYaw) * aPartialTicks; + f7 += MathHelper.sin((aPlayer.prevDistanceWalkedModified + + (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) * aPartialTicks) * 6.0F) + * 32.0F * f10; + if (aPlayer.isSneaking()) { + f7 += 25.0F; + } + GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + ((ModelBiped) this.mainModel).renderCloak(0.0625F); + GL11.glPopMatrix(); + return true; + } + } catch (Throwable e) { + + } + 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 + "."); + if (uuid != null) { + if (uuid.length() > 0) { + UUID g = UUID.fromString(uuid); + if (g != null) { + Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); + GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g); + if (profile != null) { + Logger.WARNING("[Capes++] Found for UUID check: " + profile.getName() + "."); + return profile.getName(); + } + } else { + g = UUID.fromString(uuid.replace("-", "")); + if (g != null) { + Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); + GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g); + if (profile != null) { + Logger.WARNING("[Capes++] Found for UUID check 2: " + profile.getName() + "."); + return profile.getName(); + } + } + } + } + } + if (name != null) { + if (name.length() > 0) { + Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); + GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(name); + if (profile != null) { + Logger.WARNING("[Capes++] Found for name check: " + profile.getName() + "."); + return profile.getName(); + } + } + } + Logger.WORLD("[Capes++] Failed UUID check for " + name + "."); + } catch (Throwable t) { + } + return name; + } + + + + 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 true; + } + } + return false; + } + + private static final void downloadCapeList() { + 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? + } + } + } + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java new file mode 100644 index 0000000000..1561ba9f73 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java @@ -0,0 +1,94 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.ItemList; +import gregtech.common.items.GT_VolumetricFlask; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import ic2.core.util.DrawUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.opengl.GL11; + +@SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) +public final class GTPP_FlaskRenderer implements net.minecraftforge.client.IItemRenderer { + + public GTPP_FlaskRenderer() { + MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_8k.getItem(), this); + MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_32k.getItem(), this); + } + + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.FIRST_PERSON_MAP; + } + + + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { + return type == ItemRenderType.ENTITY; + } + + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GT_VolumetricFlask cell = (GT_VolumetricFlask) item.getItem(); + + int aType = cell.getMaxCapacity() == 8000 ? 0 : 1; + IIcon icon = item.getIconIndex(); + GL11.glEnable(3042); + GL11.glEnable(3008); + if (type.equals(ItemRenderType.ENTITY)) { + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D); + GL11.glTranslated(-0.5D, -0.6D, 0.0D); + } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) { + GL11.glTranslated(1.0D, 1.0D, 0.0D); + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + } else if (type.equals(ItemRenderType.EQUIPPED)) { + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + GL11.glTranslated(-1.0D, -1.0D, 0.0D); + } + + FluidStack fs = cell.getFluid(item); + if (fs != null) { + IIcon iconWindow = cell.iconWindow; + IIcon fluidicon = fs.getFluid().getIcon(fs); + int fluidColor = fs.getFluid().getColor(fs); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(0, 1); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(iconWindow, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); + } else { + DrawUtil.renderIcon(iconWindow, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); + DrawUtil.renderIcon(iconWindow, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glBlendFunc(770, 771); + GL11.glDepthFunc(514); + GL11.glColor3ub((byte) (fluidColor >> 16), (byte) (fluidColor >> 8), (byte) fluidColor); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(fluidicon, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); + } else { + DrawUtil.renderIcon(fluidicon, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); + DrawUtil.renderIcon(fluidicon, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); + } + + GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); + GL11.glDepthFunc(515); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + } + GL11.glDisable(3008); + GL11.glDisable(3042); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java new file mode 100644 index 0000000000..35d78008c5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java @@ -0,0 +1,659 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; +import gregtech.api.interfaces.tileentity.ITexturedTileEntity; +import gregtech.common.blocks.GT_Block_Machines; +import gregtech.common.render.GT_Renderer_Block; +import gtPlusPlus.xmod.gregtech.common.blocks.GTPP_Block_Machines; +import gtPlusPlus.xmod.gregtech.common.helpers.GT_MethodHelper; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; + +public class GTPP_Render_MachineBlock extends GT_Renderer_Block { + + public static GTPP_Render_MachineBlock INSTANCE; + public final int mRenderID = RenderingRegistry.getNextAvailableRenderId(); + + public GTPP_Render_MachineBlock() { + INSTANCE = this; + RenderingRegistry.registerBlockHandler(this); + } + + private static ITexture[] getTexture(IMetaTileEntity arg0, int arg1, int arg2, int arg3, boolean arg4, boolean arg5) { + IGregTechTileEntity arg0b = arg0.getBaseMetaTileEntity(); + return arg0.getTexture(arg0b, (byte) arg1, (byte) arg2, (byte) arg3, arg4, arg5); + } + + private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { + if (aMeta > 0 && aMeta < GregTech_API.METATILEENTITIES.length) { + IMetaTileEntity tMetaTileEntity = GregTech_API.METATILEENTITIES[aMeta]; + if (tMetaTileEntity != null) { + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + if (tMetaTileEntity.getBaseMetaTileEntity() instanceof IPipeRenderedTileEntity) { + float tThickness = ((IPipeRenderedTileEntity) tMetaTileEntity.getBaseMetaTileEntity()) + .getThickNess(); + float sp = (1.0F - tThickness) / 2.0F; + aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 0, 9, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 1, 9, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 2, 9, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 3, 9, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 4, 9, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 5, 9, -1, true, false), + true); + Tessellator.instance.draw(); + } else { + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 0, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 1, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 2, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 3, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 4, 4, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, + getTexture(tMetaTileEntity, 5, 4, -1, true, false), + true); + Tessellator.instance.draw(); + } + + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + } + } + + public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + RenderBlocks aRenderer) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + + return tTileEntity instanceof ITexturedTileEntity + ? renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, + new ITexture[][]{GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 0), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 1), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 2), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 3), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 4), + GT_MethodHelper.getTexture(tTileEntity, aBlock, (byte) 5)}) + : false; + } + + public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + RenderBlocks aRenderer, ITexture[][] aTextures) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[0], true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[1], true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[2], true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[3], true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[4], true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[5], true); + return true; + } + + public static boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) { + byte aConnections = aTileEntity.getConnections(); + if ((aConnections & 192) != 0) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + float tThickness = aTileEntity.getThickNess(); + if (tThickness >= 0.99F) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + float sp = (1.0F - tThickness) / 2.0F; + byte tConnections = 0; + + for (byte tIsCovered = 0; tIsCovered < 6; ++tIsCovered) { + if ((aConnections & 1 << tIsCovered) != 0) { + tConnections = (byte) (tConnections | 1 << (tIsCovered + 2) % 6); + } + } + + boolean[] arg14 = new boolean[6]; + + for (byte tIcons = 0; tIcons < 6; ++tIcons) { + arg14[tIcons] = aTileEntity.getCoverIDAtSide(tIcons) != 0; + } + + if (arg14[0] && arg14[1] && arg14[2] && arg14[3] && arg14[4] && arg14[5]) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + ITexture[][] arg15 = new ITexture[6][]; + ITexture[][] tCovers = new ITexture[6][]; + + for (byte i = 0; i < 6; ++i) { + tCovers[i] = GT_MethodHelper.getTexture((TileEntity) aTileEntity, aBlock, i); + arg15[i] = aTileEntity.getTextureUncovered(i); + } + + if (tConnections == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + } else if (tConnections == 3) { + aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + } + } else if (tConnections == 12) { + aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, 1.0F, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + } + } else if (tConnections == 48) { + aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + } + } else { + if ((tConnections & 1) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + } else { + aBlock.setBlockBounds(0.0F, sp, sp, sp, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + } + } + + if ((tConnections & 2) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + } else { + aBlock.setBlockBounds(sp + tThickness, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + } + } + + if ((tConnections & 4) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + } else { + aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, sp, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + } + } + + if ((tConnections & 8) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + } else { + aBlock.setBlockBounds(sp, sp + tThickness, sp, sp + tThickness, 1.0F, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + } + } + + if ((tConnections & 16) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + } else { + aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, sp); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[2], false); + } + } + + if ((tConnections & 32) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + } else { + aBlock.setBlockBounds(sp, sp, sp + tThickness, sp + tThickness, sp + tThickness, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[1], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[5], false); + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, arg15[3], false); + } + } + } + + if (arg14[0]) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + } + + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); + } + } + + if (arg14[1]) { + aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + } + + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); + } + } + + if (arg14[2]) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.125F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + } + + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); + } + } + + if (arg14[3]) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + } + + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + if (!arg14[4]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + } + + if (!arg14[5]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); + } + } + + if (arg14[4]) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); + } + + if (arg14[5]) { + aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!arg14[0]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + if (!arg14[1]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + if (!arg14[2]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + if (!arg14[3]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + } + + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + return true; + } + } + } + } + + public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); + } + + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderYNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); + } + + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderYPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); + } + + aRenderer.flipTexture = !aFullBlock; + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderZNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); + } + + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderZPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); + } + + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderXNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); + } + + aRenderer.flipTexture = !aFullBlock; + if (aIcon != null) { + for (int i = 0; i < aIcon.length; ++i) { + if (aIcon[i] != null) { + aIcon[i].renderXPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { + aMeta += 30400; + if (aBlock instanceof GT_Block_Machines || aBlock instanceof GTPP_Block_Machines) { + if (aMeta > 0 && aMeta < GregTech_API.METATILEENTITIES.length + && GregTech_API.METATILEENTITIES[aMeta] != null + && !GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer)) { + renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); + } + } + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, + RenderBlocks aRenderer) { + TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return aTileEntity == null + ? false + : (aTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null + && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity().renderInWorld(aWorld, aX, aY, aZ, + aBlock, aRenderer) + ? true + : (aTileEntity instanceof IPipeRenderedTileEntity + ? renderPipeBlock(aWorld, aX, aY, aZ, aBlock, + (IPipeRenderedTileEntity) aTileEntity, aRenderer) + : renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer))); + } + + public boolean shouldRender3DInInventory(int aModel) { + return true; + } + + public int getRenderId() { + return this.mRenderID; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java new file mode 100644 index 0000000000..e53a7e4738 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java @@ -0,0 +1,11 @@ +package gtPlusPlus.xmod.gregtech.common.requirements; + +import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements; + +public class RequirementsBasicCubic extends MultiblockRequirements { + + public RequirementsBasicCubic( ) { + super(0, null); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java new file mode 100644 index 0000000000..9c856840b0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java @@ -0,0 +1,730 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import static gtPlusPlus.core.lib.CORE.*; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IDigitalChest; +import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.tesseract.TesseractHelper; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.*; + +public class GT_MetaTileEntity_TesseractGenerator extends GT_MetaTileEntity_BasicTank { + + public static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; + public static int TESSERACT_ENERGY_COST = 128; + public byte isWorking = 0; + public int oFrequency = 0; + public int mNeededEnergy = 0; + public int mFrequency = 0; + public UUID mOwner; + + public GT_MetaTileEntity_TesseractGenerator(final int aID, final String aName, final String aNameRegional, + final int aTier) { + super(aID, aName, aNameRegional, aTier, 3, ""); + } + + public GT_MetaTileEntity_TesseractGenerator(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public boolean isTransformerUpgradable() { + return true; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return this.getBaseMetaTileEntity().getEUCapacity() / 2; + } + + @Override + public long maxEUInput() { + return 512; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxEUStore() { + return 512 * 32; + } + + @Override + public long maxSteamStore() { + return this.maxEUStore(); + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean ownerControl() { + return true; + } + + @Override + public int getProgresstime() { + return (TesseractHelper.getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), + this.mFrequency) == this) && (this.isWorking >= 20) ? 999 : 0; + } + + @Override + public int maxProgresstime() { + return 1000; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mFrequency", this.mFrequency); + if (mOwner != null) + aNBT.setString("mOwner", mOwner.toString()); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFrequency = aNBT.getInteger("mFrequency"); + try { + this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); + } + catch (IllegalArgumentException i){ + + } + } + + @Override + public void onConfigLoad(final GT_Config aConfig) { + int J = 1; + if (CORE.GTNH) { + J = 4; + } + TESSERACT_ENERGY_COST = 128*J; + TESSERACT_ENERGY_COST_DIMENSIONAL = 512*J; + } + + @Override + public void onServerStart() { + sTesseractGeneratorOwnershipMap.clear(); + sTesseractTerminalOwnershipMap.clear(); + } + + public void onServerStop() { + sTesseractGeneratorOwnershipMap.clear(); + sTesseractTerminalOwnershipMap.clear(); + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, + final byte aSide, final float aX, final float aY, final float aZ) { + + if (this.mOwner == null) { + if (this.getBaseMetaTileEntity().getOwnerName() != null + && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { + if (this.getBaseMetaTileEntity().getOwnerName().toLowerCase() + .equals(aPlayer.getDisplayName().toLowerCase())) { + this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); + } + } + } + + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + Logger.WARNING("Freq. -1 | " + this.mFrequency); + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 1; + + break; + case 1: + Logger.WARNING("Freq. +1 | " + this.mFrequency); + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 1; + default: + // Utils.LOG_WARNING("Did not click the correct place."); + break; + } + if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this){ + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); + } + else { + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); + } + } else if (aPlayer.getUniqueID().compareTo(this.mOwner) != 0){ + GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); + } + } + + return true; + } + + @Override + public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, + final float aZ) { + if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 64; + break; + case 1: + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 64; + break; + case 2: + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 512; + break; + case 3: + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 512; + } + if (getGeneratorEntity(this.mFrequency) != null && getGeneratorEntity(this.mFrequency) != this){ + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + EnumChatFormatting.RED + " (Occupied)"); + } + else { + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency); + } + } + } else { + GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Generator to configure."); + } + } + + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public String[] getInfoData() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IGregTechDeviceInformation)) + && (((IGregTechDeviceInformation) tTileEntity).isGivingInformation())) { + return ((IGregTechDeviceInformation) tTileEntity).getInfoData(); + } + return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, + (getGeneratorEntity() == this) && (this.isWorking >= 20) ? "Active" : "Inactive" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public boolean isSendingInformation() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IGregTechDeviceInformation))) { + return ((IGregTechDeviceInformation) tTileEntity).isGivingInformation(); + } + return false; + } + + @Override + public boolean isDigitalChest() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest) tTileEntity).isDigitalChest(); + } + return false; + } + + @Override + public ItemStack[] getStoredItemData() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest) tTileEntity).getStoredItemData(); + } + return new ItemStack[] {}; + } + + @Override + public void setItemCount(final int aCount) { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IDigitalChest))) { + ((IDigitalChest) tTileEntity).setItemCount(aCount); + } + } + + @Override + public int getMaxItemCount() { + final TileEntity tTileEntity = this.getBaseMetaTileEntity() + .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest) tTileEntity).getMaxItemCount(); + } + return 0; + } + + @Override + public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isItemValidForSlot(aIndex, aStack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int aSide) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return new int[0]; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(aSide); + } + final int[] rArray = new int[this.getSizeInventory()]; + for (int i = 0; i < this.getSizeInventory(); i++) { + rArray[i] = i; + } + return rArray; + } + + @Override + public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory) tTileEntity).canInsertItem(aIndex, aStack, aSide); + } + return true; + } + + @Override + public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory) tTileEntity).canExtractItem(aIndex, aStack, aSide); + } + return true; + } + + @Override + public int getSizeInventory() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int aIndex) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); + } + + @Override + public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); + } + + @Override + public ItemStack decrStackSize(final int aIndex, final int aAmount) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.decrStackSize(aIndex, aAmount); + } + + @Override + public String getInventoryName() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); + } + + @Override + public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); + } + + @Override + public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); + } + + @Override + public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); + } + + @Override + public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { + final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() + .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); + } + + public boolean addEnergyConsumption(final GT_MetaTileEntity_TesseractTerminal aTerminal) { + if (!this.getBaseMetaTileEntity().isAllowedToWork()) { + return false; + } + int J = (aTerminal.getBaseMetaTileEntity().getWorld() == this.getBaseMetaTileEntity().getWorld() + ? TESSERACT_ENERGY_COST : TESSERACT_ENERGY_COST_DIMENSIONAL); + + if (CORE.GTNH) { + J *= 4; + } + + this.mNeededEnergy += J; + + return true; + } + + public boolean isValidTesseractGenerator(final String aOwnerName, final boolean aWorkIrrelevant) { + return (this.getBaseMetaTileEntity() != null) && (!this.getBaseMetaTileEntity().isInvalidTileEntity()) + && (this.getBaseMetaTileEntity().isAllowedToWork()) + && ((aOwnerName == null) || (this.getBaseMetaTileEntity().getOwnerName().equals(aOwnerName))) + && ((aWorkIrrelevant) || (this.isWorking >= 20)); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // TODO Auto-generated method stub + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + //Utils.LOG_WARNING("Ticking Generator. 0"); + if (this.getBaseMetaTileEntity().isServerSide()) { + //Utils.LOG_WARNING("Ticking Generator."); + // Set owner + if (PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()) != null) { + if (this.mOwner == null) { + Logger.WARNING("Setting Generators Owner. 1"); + this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); + } + } + + if (this.mFrequency != this.oFrequency) { + + Logger.WARNING("mFreq != oFreq"); + + if (getGeneratorEntity() == this) { + getGeneratorEntity(this.oFrequency); + this.getBaseMetaTileEntity().issueBlockUpdate(); + Logger.WARNING("this Gen == oFreq on map - do block update"); + } + Logger.WARNING("mFreq will be set to oFreq"); + this.oFrequency = this.mFrequency; + } + if ((this.getBaseMetaTileEntity().isAllowedToWork()) + && (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mNeededEnergy, false))) { + //Utils.LOG_WARNING("Can Work & Has Energy"); + if ((getGeneratorEntity(Integer.valueOf(this.mFrequency)) == null) + || (!getGeneratorEntity(Integer.valueOf(this.mFrequency)).isValidTesseractGenerator(null, + true))) { + //Utils.LOG_WARNING("storing TE I think to mFreq map?"); + TesseractHelper.setGeneratorOwnershipByPlayer(PlayerUtils.getPlayerOnServerFromUUID(mOwner), + this.mFrequency, this); + } + } else { + if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { + Logger.WARNING("this gen == mFreq on map - do block update"); + TesseractHelper.removeGenerator(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); + this.getBaseMetaTileEntity().issueBlockUpdate(); + } + this.isWorking = 0; + } + if (getGeneratorEntity(Integer.valueOf(this.mFrequency)) == this) { + //Utils.LOG_WARNING("mFreq == this - do work related things"); + if (this.isWorking < 20) { + this.isWorking = ((byte) (this.isWorking + 1)); + } + if (this.isWorking == 20) { + this.getBaseMetaTileEntity().issueBlockUpdate(); + this.isWorking = ((byte) (this.isWorking + 1)); + } + } else { + this.isWorking = 0; + } + this.mNeededEnergy = 0; + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, + "Generates a Tesseract for the attached Inventory", + "Connect with pipes to insert items", + "Consumes "+TESSERACT_ENERGY_COST+"EU/t for same dimension transfers", + "Consumes "+TESSERACT_ENERGY_COST_DIMENSIONAL+"EU/t for cross dimensional transfers", + CORE.GT_Tooltip}; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return aSide == aFacing + ? new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } + : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(Textures.BlockIcons.VOID) }; + } + + // To-Do? + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + private GT_MetaTileEntity_TesseractGenerator getGeneratorEntity() { + GT_MetaTileEntity_TesseractGenerator thisGenerator = TesseractHelper + .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), this.mFrequency); + if (thisGenerator != null) { + return thisGenerator; + } + return null; + } + + private GT_MetaTileEntity_TesseractGenerator getGeneratorEntity(int frequency) { + GT_MetaTileEntity_TesseractGenerator thisGenerator = TesseractHelper + .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), frequency); + if (thisGenerator != null) { + return thisGenerator; + } + return null; + } + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (this.getBaseMetaTileEntity().getOwnerName() != null + && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { + this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); + Logger.WARNING("Setting Generators Owner. 2"); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public void onRemoval() { + try { + CORE.sTesseractGeneratorOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + super.onRemoval(); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java new file mode 100644 index 0000000000..088a596410 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java @@ -0,0 +1,581 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.automation; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.tesseract.TesseractHelper; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + +public class GT_MetaTileEntity_TesseractTerminal extends GT_MetaTileEntity_BasicTank { + public int mFrequency = 0; + public UUID mOwner; + public boolean mDidWork = false; + public static boolean sInterDimensionalTesseractAllowed = true; + private static int TESSERACT_ENERGY_COST = 128; + private static int TESSERACT_ENERGY_COST_DIMENSIONAL = 512; + + public GT_MetaTileEntity_TesseractTerminal(final int aID, final String aName, final String aNameRegional, + final int aTier) { + super(aID, aName, aNameRegional, aTier, 3, ""); + } + + public GT_MetaTileEntity_TesseractTerminal(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractTerminal(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return (this.getBaseMetaTileEntity().getEUCapacity() / 100); + } + + @Override + public long maxEUInput() { + return TESSERACT_ENERGY_COST_DIMENSIONAL; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUStore() { + return TESSERACT_ENERGY_COST_DIMENSIONAL * 8 * 32; + } + + @Override + public long maxSteamStore() { + return this.maxEUStore(); + } + + @Override + public boolean ownerControl() { + return true; + } + + @Override + public int getProgresstime() { + return this.getTesseract(this.mFrequency, false) != null ? 999 : 0; + } + + @Override + public int maxProgresstime() { + return 1000; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mFrequency", this.mFrequency); + aNBT.setString("mOwner", mOwner.toString()); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFrequency = aNBT.getInteger("mFrequency"); + this.mOwner = UUID.fromString(aNBT.getString("mOnwer")); + } + + @Override + public void onConfigLoad(final GT_Config aConfig) { + sInterDimensionalTesseractAllowed = true; + if (CORE.GTNH) { + TESSERACT_ENERGY_COST = 512; + TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; + } + else { + TESSERACT_ENERGY_COST = 128; + TESSERACT_ENERGY_COST_DIMENSIONAL = 512; + } + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, + final byte aSide, final float aX, final float aY, final float aZ) { + + if (this.mOwner == null) { + if (this.getBaseMetaTileEntity().getOwnerName() != null + && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { + if (this.getBaseMetaTileEntity().getOwnerName().toLowerCase() + .equals(aPlayer.getDisplayName().toLowerCase())) { + this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); + } + } + } + + if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + //Utils.LOG_WARNING("Freq. -1 | " + this.mFrequency); + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 1; + break; + case 1: + //Utils.LOG_WARNING("Freq. +1 | " + this.mFrequency); + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 1; + default: + // Utils.LOG_WARNING("Did not click the correct place."); + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + break; + } + PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); + if (this.getTesseract(this.mFrequency, false) != null) { + PlayerUtils.messagePlayer(aPlayer, + new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString()); + } + } + } else if (aPlayer.getUniqueID().compareTo(this.mOwner) != 0){ + GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); + } + return true; + } + + @Override + public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, + final float aZ) { + if (aPlayer.getUniqueID().compareTo(this.mOwner) == 0) { + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 64; + break; + case 1: + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 64; + break; + case 2: + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency -= 512; + break; + case 3: + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + this.mFrequency += 512; + } + GT_Utility.sendChatToPlayer(aPlayer, + "Frequency: " + this.mFrequency + + (this.getTesseract(this.mFrequency, false) == null ? "" + : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)") + .toString())); + } + } else if (aPlayer.getUniqueID().compareTo(this.mOwner) != 0){ + GT_Utility.sendChatToPlayer(aPlayer, "This is not your Tesseract Terminal to configure."); + } + } + + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + public GT_MetaTileEntity_TesseractGenerator getTesseract(final int aFrequency, final boolean aWorkIrrelevant) { + final GT_MetaTileEntity_TesseractGenerator rTesseract = TesseractHelper + .getGeneratorByFrequency(PlayerUtils.getPlayerOnServerFromUUID(mOwner), aFrequency); + if (rTesseract == null) { + return null; + } + if (!TesseractHelper.isGeneratorOwnedByPlayer(PlayerUtils.getPlayerOnServerFromUUID(mOwner), rTesseract)) { + return null; + } + if (rTesseract.mFrequency != aFrequency) { + TesseractHelper.setTerminalOwnershipByPlayer(PlayerUtils.getPlayerOnServerFromUUID(mOwner), + Integer.valueOf(aFrequency), null); + return null; + } + if (!rTesseract.isValidTesseractGenerator(this.getBaseMetaTileEntity().getOwnerName(), aWorkIrrelevant)) { + return null; + } + if ((!sInterDimensionalTesseractAllowed) + && (rTesseract.getBaseMetaTileEntity().getWorld() != this.getBaseMetaTileEntity().getWorld())) { + return null; + } + return rTesseract; + } + + @Override + public String[] getInfoData() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity != null) && (this.getBaseMetaTileEntity().isAllowedToWork()) + && (tTileEntity.isSendingInformation())) { + return tTileEntity.getInfoData(); + } + return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, + this.getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean isDigitalChest() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isDigitalChest(); + } + + @Override + public ItemStack[] getStoredItemData() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStoredItemData(); + } + + @Override + public void setItemCount(final int aCount) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setItemCount(aCount); + } + + @Override + public int getMaxItemCount() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getMaxItemCount(); + } + + @Override + public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isItemValidForSlot(aIndex, aStack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int aSide) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return new int[0]; + } + return tTileEntity.getAccessibleSlotsFromSide(aSide); + } + + @Override + public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canInsertItem(aIndex, aStack, aSide); + } + + @Override + public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canExtractItem(aIndex, aStack, aSide); + } + + @Override + public int getSizeInventory() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int aIndex) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); + } + + @Override + public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); + } + + @Override + public ItemStack decrStackSize(final int aIndex, final int aAmount) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.decrStackSize(aIndex, aAmount); + } + + @Override + public String getInventoryName() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); + } + + @Override + public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); + } + + @Override + public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); + } + + @Override + public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); + } + + @Override + public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!this.getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if ((this.getBaseMetaTileEntity().isServerSide()) && (this.getBaseMetaTileEntity().isAllowedToWork())) { + // Set owner + if (PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()) != null) { + if (this.mOwner == null) { + this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); + } + } + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, true); + if (tTileEntity != null) { + tTileEntity.addEnergyConsumption(this); + if ((!this.mDidWork) && (this.getTesseract(this.mFrequency, false) != null)) { + this.mDidWork = true; + this.getBaseMetaTileEntity().issueBlockUpdate(); + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(128, false); + } + } else if (this.mDidWork == true) { + this.mDidWork = false; + this.getBaseMetaTileEntity().issueBlockUpdate(); + } + } + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, + "Accesses Tesseract Generators remotely", + "Connect with pipes to extract items or fluids", + "Outputs from the back face", + "Consumes "+TESSERACT_ENERGY_COST+"EU/t for same dimension transfers", + "Consumes "+TESSERACT_ENERGY_COST_DIMENSIONAL+"EU/t for cross dimensional transfers", + CORE.GT_Tooltip}; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return aSide == aFacing + ? new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } + : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(Textures.BlockIcons.VOID) }; + } + + // To-Do? + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (this.getBaseMetaTileEntity().getOwnerName() != null + && !this.getBaseMetaTileEntity().getOwnerName().equals("")) { + this.mOwner = PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); + } + super.onCreated(aStack, aWorld, aPlayer); + } + + @Override + public void onRemoval() { + try { + CORE.sTesseractTerminalOwnershipMap.get(mOwner).remove(this.mFrequency); + } catch (Throwable t) { + } + super.onRemoval(); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java new file mode 100644 index 0000000000..4173489be6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Base.java @@ -0,0 +1,296 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_AdvancedBoiler; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_AdvancedBoiler; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidTankInfo; + +public class GT_MetaTileEntity_Boiler_Base extends GT_MetaTileEntity_Boiler { + + private final int steamPerSecond; + private final int tier; + + public GT_MetaTileEntity_Boiler_Base(int aID, String aNameRegional, int tier) { + super(aID, "electricboiler." + tier + ".tier.single", aNameRegional, + "Produces " + (CORE.ConfigSwitches.boilerSteamPerSecond * tier) + "L of Steam per second"); + this.steamPerSecond = (CORE.ConfigSwitches.boilerSteamPerSecond * tier); + this.tier = tier; + } + + public GT_MetaTileEntity_Boiler_Base(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.steamPerSecond = (CORE.ConfigSwitches.boilerSteamPerSecond * aTier); + this.tier = aTier; + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + "Produces " + getPollution() + " pollution/sec", + "Consumes fuel only when temperature is less than 100C", + "Fuel with burn time greater than 500 is more efficient.", + "Doesn't explode if there's no water", + CORE.GT_Tooltip + }; + } + + public ITexture getOverlayIcon() { + return new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + protected GT_RenderedTexture getCasingTexture() { + if (this.tier == 1) { + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); + } else if (this.tier == 2) { + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); + } else { + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); + } + // return new + // GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], + this.getCasingTexture() }; + } + + public ITexture[] getBack(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getBottom(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getTop(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.tier][aColor + 1], + this.getCasingTexture() }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFront(aColor); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getSides(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isFacingValid(final byte aSide) { + return aSide > 1; + } + + // Please find out what I do. + // I do stuff within the GUI. + // this.mTemperature = Math.min(54, Math.max(0, this.mTemperature * 54 / (((GT_MetaTileEntity_Boiler) this.mTileEntity.getMetaTileEntity()).maxProgresstime() - 10))); + @Override + public int maxProgresstime() { + return 1000 + (250 * tier); + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public int getCapacity() { + return (16000 + (16000 * tier)); + } + + // This type of machine can have different water and steam capacities. + public int getSteamCapacity() { + return 2 * getCapacity(); + } + + @Override + protected int getProductionPerSecond() { + return steamPerSecond; + } + + @Override + protected int getMaxTemperature() { + return maxProgresstime(); + } + + @Override + protected int getEnergyConsumption() { + return 2; + } + + @Override + protected int getCooldownInterval() { + return 40; + } + + @Override + protected int getHeatUpRate() { + return 10; + } + + @Override + protected void updateFuel(IGregTechTileEntity tile, long ticks) { + ItemStack fuelStack = this.mInventory[2]; + if(fuelStack == null) return; + + int burnTime = getBurnTime(fuelStack); + if (burnTime > 0 && this.mTemperature <= 101) { + consumeFuel(tile, fuelStack, burnTime); + } + } + + @Override + protected void produceSteam(int aAmount) { + super.produceSteam(aAmount); + + if(mSteam.amount > getSteamCapacity()) { + sendSound(SOUND_EVENT_LET_OFF_EXCESS_STEAM); + + mSteam.amount = getSteamCapacity(); + } + } + + @Override + // Since this type of machine can have different water and steam capacities, we need to override getTankInfo() to + // support returning those different capacities. + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + return new FluidTankInfo[]{ + new FluidTankInfo(this.mFluid, getCapacity()), + new FluidTankInfo(this.mSteam, getSteamCapacity()) + }; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 1 || aIndex == 3; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 2; + } + + @Override + protected int getPollution() { + return (int) (CORE.ConfigSwitches.basePollutionPerSecondBoiler*CORE.ConfigSwitches.pollutionReleasedByTierBoiler[this.tier]); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity, "AdvancedBoiler.png"); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Base(this.mName, tier, this.mDescription, this.mTextures); + } + + @Override + protected void onDangerousWaterLack(IGregTechTileEntity tile, long ticks) { + // Smart boilers don't explode! + } + + /** + * Returns burn time if the stack is a valid fuel, otherwise return 0. + */ + private static int getBurnTime(ItemStack stack) { + int burnTime = GameRegistry.getFuelValue(stack); + if (burnTime <= 0) { + burnTime = TileEntityFurnace.getItemBurnTime(stack); + } + + return burnTime; + } + + public void consumeFuel(IGregTechTileEntity tile, ItemStack fuel, int burnTime) { + this.mProcessingEnergy += burnTime / 10; + this.mTemperature += burnTime / 500; // will add bonus temperature points if the burn time is pretty high + + tile.decrStackSize(2, 1); + if (tile.getRandomNumber(3) == 0) { + if (fuel.getDisplayName().toLowerCase().contains("charcoal") + || fuel.getDisplayName().toLowerCase().contains("coke")) { + tile.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } else { + tile.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { + if (aSide != this.getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return super.allowCoverOnSide(aSide, aCover); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java new file mode 100644 index 0000000000..dfbd254897 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_HV.java @@ -0,0 +1,56 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; + +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT_MetaTileEntity_Boiler_HV + extends GT_MetaTileEntity_Boiler_Base { + + public GT_MetaTileEntity_Boiler_HV(int aID, String aNameRegional, int aBoilerTier) { + super(aID, aNameRegional, aBoilerTier); + } + + public GT_MetaTileEntity_Boiler_HV(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_HV(this.mName, 3, this.mDescription, this.mTextures); + } + + + @Override + protected GT_RenderedTexture getCasingTexture(){ + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_HV_SIDE); + } + + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT)}; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Talonite)}; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE)}; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } + + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java new file mode 100644 index 0000000000..e2b9046c68 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_LV.java @@ -0,0 +1,52 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; + +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT_MetaTileEntity_Boiler_LV +extends GT_MetaTileEntity_Boiler_Base { + + public GT_MetaTileEntity_Boiler_LV(int aID, String aNameRegional, int aBoilerTier) { + super(aID, aNameRegional, aBoilerTier); + } + + public GT_MetaTileEntity_Boiler_LV(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_LV(this.mName, 1, this.mDescription, this.mTextures); + } + + + @Override + protected GT_RenderedTexture getCasingTexture(){ + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_LV_SIDE); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT)}; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Potin)}; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE)}; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java new file mode 100644 index 0000000000..7ef781da17 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_MV.java @@ -0,0 +1,52 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; + +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT_MetaTileEntity_Boiler_MV +extends GT_MetaTileEntity_Boiler_Base { + + public GT_MetaTileEntity_Boiler_MV(int aID, String aNameRegional, int aBoilerTier) { + super(aID, aNameRegional, aBoilerTier); + } + + public GT_MetaTileEntity_Boiler_MV(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_MV(this.mName, 2, this.mDescription, this.mTextures); + } + + @Override + protected GT_RenderedTexture getCasingTexture(){ + return new GT_RenderedTexture(Textures.BlockIcons.MACHINE_MV_SIDE); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT)}; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Tumbaga)}; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE)}; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return getTop(aColor); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java new file mode 100644 index 0000000000..f9cf904cc2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java @@ -0,0 +1,194 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_AdvancedBoiler; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_AdvancedBoiler; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.common.gui.GT_Container_Boiler; +import gregtech.common.gui.GT_GUIContainer_Boiler; +import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +public class GT_MetaTileEntity_Boiler_Solar +extends GT_MetaTileEntity_Boiler { + public GT_MetaTileEntity_Boiler_Solar(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, "Steam Power by the Sun"); + } + + public GT_MetaTileEntity_Boiler_Solar(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + "Produces "+(this.getPollution()*20)+" pollution/sec", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[4][17][]; + for (byte i = -1; i < 16; i = (byte) (i + 1)) { + final ITexture[] tmp0 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; + rTextures[0][(i + 1)] = tmp0; + final ITexture[] tmp1 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_SOLAR)}; + rTextures[1][(i + 1)] = tmp1; + final ITexture[] tmp2 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; + rTextures[2][(i + 1)] = tmp2; + final ITexture[] tmp3 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE)}; + rTextures[3][(i + 1)] = tmp3; + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[aSide >= 2 ? ((byte) (aSide != aFacing ? 2 : 3)) : aSide][aColorIndex + 1]; + } + + @Override + public int maxProgresstime() { + return 500; + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_AdvancedBoiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png"); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Solar(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + private int mRunTime = 0; + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mRunTime", this.mRunTime); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mRunTime = aNBT.getInteger("mRunTime"); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { + if (this.mTemperature <= 20) { + this.mTemperature = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 45) { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + if (this.mSteam != null) { + final byte i = aBaseMetaTileEntity.getFrontFacing(); + final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) { + final FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) { + final int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); + } + } + } + } + if ((aTick % 25L) == 0L) { + if (this.mTemperature > 100) { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { + this.mHadNoWater = true; + } else { + if (this.mHadNoWater) { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + this.mRunTime += 1; + int tOutput = 150; + if(this.mRunTime > 10000){ + tOutput = Math.max(50, 150 - ((this.mRunTime-10000)/100)); + } + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(tOutput); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += tOutput; + } else { + this.mSteam = GT_ModHandler.getSteam(tOutput); + } + } + } else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && + (this.mSteam.amount > 16000)) { + this.sendSound((byte) 1); + this.mSteam.amount = 12000; + } + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && ((aTick % 256L) == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { + final boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && (aBaseMetaTileEntity.getBiome().rainfall > 0.0F); + this.mProcessingEnergy += (bRain && (aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4)) || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; + } + if ((this.mTemperature < 500) && (this.mProcessingEnergy > 0) && ((aTick % 12L) == 0L)) { + this.mProcessingEnergy -= 1; + this.mTemperature += 1; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } + + @Override + protected int getPollution() { + return 0; + } + + @Override + protected int getProductionPerSecond() { + return 0; + } + + @Override + protected int getMaxTemperature() { + return 0; + } + + @Override + protected int getEnergyConsumption() { + return 0; + } + + @Override + protected int getCooldownInterval() { + return 0; + } + + @Override + protected void updateFuel(IGregTechTileEntity iGregTechTileEntity, long l) { + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_RfConvertor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_RfConvertor.java new file mode 100644 index 0000000000..c6f368f0c0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_RfConvertor.java @@ -0,0 +1,348 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import static gregtech.api.enums.GT_Values.V; + +import cofh.api.energy.IEnergyConnection; +import cofh.api.energy.IEnergyHandler; +import cofh.api.energy.IEnergyProvider; +import cofh.api.energy.IEnergyReceiver; +import cofh.api.energy.IEnergyStorage; +import crazypants.enderio.machine.capbank.TileCapBank; +import crazypants.enderio.machine.capbank.network.ICapBankNetwork; +import crazypants.enderio.power.IPowerContainer; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +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_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaEnergyBuffer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * + * This is the main construct for my Basic Machines such as the Automatic Extractor + * Extend this class to make a simple Machine + */ +public class GT_MetaTileEntity_RfConvertor extends GregtechMetaEnergyBuffer implements IEnergyReceiver { + + + public GT_MetaTileEntity_RfConvertor(final String aName, final int aTier, + final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aDescription, aTextures, aSlotCount); + } + + public GT_MetaTileEntity_RfConvertor(final int aID, final String aName, + final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); + } + + @Override + public String[] getDescription() { + return new String[] { + "Use Screwdriver to change voltage", + "Hold Shift while using Screwdriver to change amperage", + EnumChatFormatting.DARK_AQUA+"Variable Output Voltage", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[12][17][]; + GT_RenderedTexture aTex = new GT_RenderedTexture(TexturesGtBlock.Casing_Material_ZirconiumCarbide); + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; + rTextures[1][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; + rTextures[2][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; + rTextures[3][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; + rTextures[4][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; + rTextures[5][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; + rTextures[6][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; + rTextures[7][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; + rTextures[8][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; + rTextures[9][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; + rTextures[10][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; + rTextures[11][i + 1] = new ITexture[]{aTex, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aActive ? 0 : 6)][aColorIndex + 1]; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_RfConvertor(this.mName, this.mTier, this.mDescription, + this.mTextures, this.mInventory.length); + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return Integer.MAX_VALUE; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return V[this.mTier]; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return !isOutputFacing(aSide); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (!aBaseMetaTileEntity.isActive()) { + aBaseMetaTileEntity.setActive(true); + } + if (this.getEUVar() < this.maxEUStore()) { + for (byte i = 0; i < 6 && aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity(); i++) { + if (isInputFacing(i)) { + receiveEnergy(ForgeDirection.getOrientation(i), Integer.MAX_VALUE, false); + } + } + } + return; + } + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + String[] infoData = super.getInfoData(); + return new String[] { + infoData[0], + "Converts RF -> GTEU | Tier: "+this.mTier, + infoData[1], + infoData[2] + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mTier", this.mTier); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mTier = aNBT.getByte("mTier"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + byte aTest = (byte) (aCurrentOutputAmperage + 1); + if (aTest > 16 || aTest <= 0 ) { + aTest = 1; + } + aCurrentOutputAmperage = aTest; + PlayerUtils.messagePlayer(aPlayer, "Now handling "+maxAmperesOut()+" Amps."); + } + else { + if (this.mTier < (CORE.GTNH ? GT_Values.V.length : 9)) { + this.mTier++; + } + else { + this.mTier = 0; + } + PlayerUtils.messagePlayer(aPlayer, "Now running at "+GT_Values.VOLTAGE_NAMES[this.mTier]+"."); + } + + } + + @Override + public boolean canConnectEnergy(ForgeDirection from) { + if (isOutputFacing((byte) from.ordinal())) { + return false; + } + return true; + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + + // Cannot accept power on the output face. + if (!canConnectEnergy(from) || isOutputFacing((byte) from.ordinal())) { + return 0; + } + + TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide((byte) from.ordinal()); + if (tTileEntity == null) { + return 0; + } + + Logger.WARNING("Someone is trying to inject RF from "+from+". Type:"+tTileEntity.getClass().getName()); + + // Calculate maximum RF we need to consume + int aInputRF = MathUtils.safeInt(this.maxEUOutput() * GregTech_API.mEUtoRF / 100); + + // Make sure we only consume the correct amount of RF that is pushed into this Tile. + if (aInputRF > maxReceive) { + aInputRF = maxReceive; + } + + int aInjectedRF = 0; + boolean aVal = false; + + long aStoredEU = this.getEUVar(); + long aMaxEU = this.maxEUStore(); + Logger.WARNING("Stored: "+aStoredEU+", Capacity: "+aMaxEU+""); + if (aStoredEU < aMaxEU) { + Logger.WARNING("StoredEU < MaxEU"); + long aRemainingSpace = aMaxEU - aStoredEU; + if (aRemainingSpace > 0) { + long tEU = 0; + byte aSide = (byte) from.ordinal(); + Logger.WARNING("Free: "+aRemainingSpace+"EU"); + if (tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(aSide)), 1, true) == 1) { + tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(aSide)), (int) maxEUOutput() * 100 / GregTech_API.mRFtoEU, false); + Logger.WARNING("Drained from IEnergyProvider Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); + tEU = tEU * GregTech_API.mRFtoEU / 100; + } + else if (tTileEntity instanceof IEnergyStorage && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) { + tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy((int) maxEUOutput() * 100 / GregTech_API.mRFtoEU, false); + Logger.WARNING("Drained from IEnergyStorage Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); + tEU = tEU * GregTech_API.mRFtoEU / 100; + } + else if (GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) { + int storedRF = ((IPowerContainer) tTileEntity).getEnergyStored(); + int extractRF = (int) maxEUOutput() * 100 / GregTech_API.mRFtoEU; + tEU = 0; + if (tTileEntity instanceof TileCapBank) { + ICapBankNetwork network = ((TileCapBank) tTileEntity).getNetwork(); + if (network != null && network.getEnergyStoredL() > 0) { + tEU = Math.min((Math.min(Math.min(network.getEnergyStoredL(), storedRF - extractRF), network.getMaxOutput())) * GregTech_API.mRFtoEU / 100, maxEUOutput()); + Logger.WARNING("Drained from EIO CapBank Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); + network.addEnergy((int) -(tEU * 100 / GregTech_API.mRFtoEU)); + } + } else { + if (storedRF > extractRF) { + ((IPowerContainer) tTileEntity).setEnergyStored(storedRF - extractRF); + tEU = maxEUOutput(); + Logger.WARNING("Drained from EIO Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); + } else { + ((IPowerContainer) tTileEntity).setEnergyStored(0); + tEU = storedRF * GregTech_API.mRFtoEU / 100; + Logger.WARNING("Drained from EIO Tile: "+(tEU * 100 / GregTech_API.mRFtoEU)+""); + } + } + } + Logger.WARNING("EU to inject: "+tEU+"EU"); + if (!simulate) { + aVal = this.getBaseMetaTileEntity().increaseStoredEnergyUnits(tEU, true); + } + if (tEU > 0) { + Logger.WARNING("Tried injecting "+tEU+" eu into self. Success? "+aVal); + } + } + } + return aInjectedRF; + } + + @Override + public int getEnergyStored(ForgeDirection from) { + long aStoredEU = this.getEUVar(); + long aMaxEU = this.maxEUStore(); + if (aStoredEU == 0) { + return 0; + } + if (aStoredEU < aMaxEU) { + long aRemainingSpace = aMaxEU - aStoredEU; + if (aRemainingSpace > 0) { + if (aRemainingSpace > (this.maxEUOutput() / (GregTech_API.mEUtoRF / 100))) { + int aCalculatedFreeSpace = 0; + int aRfPer10Eu = GregTech_API.mEUtoRF / 10; + // Calculate how many lots of '10 + aCalculatedFreeSpace = (int) Math.floor(aRemainingSpace / 10); + // Return value equal to how many lots of '10eu' packets we can fit in. + return Integer.MAX_VALUE - MathUtils.balance(aCalculatedFreeSpace * aRfPer10Eu, 0, Integer.MAX_VALUE); + } + } + } + return Integer.MAX_VALUE; + } + + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return Integer.MAX_VALUE; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java new file mode 100644 index 0000000000..d1628bdb59 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_SemiFluidGenerator.java @@ -0,0 +1,171 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_SemiFluidGenerator extends GT_MetaTileEntity_BasicGenerator { + + public int mEfficiency; + + /*public GT_MetaTileEntity_SemiFluidGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + onConfigLoad(); + }*/ + + public GT_MetaTileEntity_SemiFluidGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, + "Requires semi-fluid Fuel", + new ITexture[0]); + onConfigLoad(); + } + + public GT_MetaTileEntity_SemiFluidGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + public int getPollution() { + return (int) (CORE.ConfigSwitches.basePollutionPerSecondSemiFluidGenerator * CORE.ConfigSwitches.pollutionReleasedByTierSemiFluidGenerator[this.mTier]); + } + + @Override + public int getCapacity() { + return 4000 * this.mTier; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, + "SemiFluidGenerator.efficiency.tier." + this.mTier, 100 - (this.mTier * 5)); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_SemiFluidGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + //Logger.WARNING("Fuel Count: "+Gregtech_Recipe_Map.sSemiFluidLiquidFuels.mRecipeList.size()); + return GTPP_Recipe_Map.sSemiFluidLiquidFuels; + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + "Produces "+(this.getPollution())+" pollution/sec", + "Fuel Efficiency: "+this.getEfficiency() + "%", + CORE.GT_Tooltip}; + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return (aSide == getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { + if (aSide != this.getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return super.allowCoverOnSide(aSide, aCover); + } + + @Override + public int getFuelValue(ItemStack aStack) { + if ((GT_Utility.isStackInvalid(aStack)) || (getRecipes() == null)) { + Logger.WARNING("Bad Fuel?"); + return 0; + } + int rValue = Math.max(GT_ModHandler.getFuelCanValue(aStack) * 6 / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + Logger.WARNING("Good Fuel: "+rValue); + return rValue; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE) }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) }; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java new file mode 100644 index 0000000000..2a0133245e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java @@ -0,0 +1,153 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import cpw.mods.fml.common.registry.GameRegistry; + +import net.minecraft.item.ItemStack; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GregtechMetaTileEntityDoubleFuelGeneratorBase +extends GregtechRocketFuelGeneratorBase { + + public int mEfficiency; + + public GregtechMetaTileEntityDoubleFuelGeneratorBase(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires two liquid Fuels. Fuel A is Fastburn, Fuel B is slowburn.", new ITexture[0]); + this.onConfigLoad(); + } + + public GregtechMetaTileEntityDoubleFuelGeneratorBase(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.onConfigLoad(); + } + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, + "Generates power at " + this.getEfficiency() + "% Efficiency per tick", + "Output Voltage: "+this.getOutputTier()+" EU/t", + CORE.GT_Tooltip + }; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityDoubleFuelGeneratorBase(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } + + @Override + public int getCapacity() { + return 32000; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "RocketEngine.efficiency.tier." + this.mTier, (100 - (this.mTier * 8))); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getFuelValue(final ItemStack aStack) { + int rValue = Math.max((GT_ModHandler.getFuelCanValue(aStack) * 6) / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + private GT_RenderedTexture getCasingTexture(){ + if (this.mTier <= 4){ + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + else if (this.mTier == 5){ + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + else { + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + //return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent)}; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal)}; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast)}; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active)}; + } + + @Override + public int getPollution() { + return 250; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java new file mode 100644 index 0000000000..a392ae5a58 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java @@ -0,0 +1,151 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import cpw.mods.fml.common.registry.GameRegistry; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GregtechMetaTileEntityGeothermalGenerator +extends GT_MetaTileEntity_BasicGenerator +{ + + public int mEfficiency; + + public GregtechMetaTileEntityGeothermalGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires Pahoehoe Lava or Normal Lava as Fuel", new ITexture[0]); + this.onConfigLoad(); + } + + public GregtechMetaTileEntityGeothermalGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.onConfigLoad(); + } + + @Override + public String[] getDescription() { + String aPollution = "Causes "+this.getPollution()+ " Pollution per second"; + return new String[]{ + this.mDescription, + "Generates power at " + this.getEfficiency() + "% Efficiency per tick", + aPollution, + CORE.GT_Tooltip}; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public int getCapacity() { + //return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); + return 5000*this.mTier; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "ThermalGenerator.efficiency.tier." + this.mTier, (100 - (this.mTier * 7))); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getFuelValue(final ItemStack aStack) { + int rValue = Math.max((GT_ModHandler.getFuelCanValue(aStack) * 6) / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityGeothermalGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical)}; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM)}; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER)}; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT)}; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical_Active)}; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE)}; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE)}; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE)}; + } + + @Override + public GT_Recipe_Map getRecipes() + { + return GT_Recipe_Map.sHotFuels; + } + + public int getPollution() { + return (int) (CORE.ConfigSwitches.basePollutionPerSecondGeothermalGenerator * CORE.ConfigSwitches.pollutionReleasedByTierGeothermalGenerator[mTier]); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java new file mode 100644 index 0000000000..c05c7ae3ff --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -0,0 +1,142 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +public class GregtechMetaTileEntityRocketFuelGenerator +extends GregtechRocketFuelGeneratorBase { + + public int mEfficiency; + + public GregtechMetaTileEntityRocketFuelGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires GT++ Rocket Fuels", new ITexture[0]); + this.onConfigLoad(); + } + + public GregtechMetaTileEntityRocketFuelGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.onConfigLoad(); + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + //Logger.INFO("Valid Fuels: "+Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.mRecipeList.size()); + return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; + } + + @Override + public int getCapacity() { + return 32000; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "RocketEngine.efficiency.tier." + this.mTier, 80 - (10 * (this.mTier - 4))); + } + + @Override + public int getEfficiency() { + int eff = 80 - (10 * (this.mTier - 4)); + return eff; + + } + + @Override + public int getFuelValue(final ItemStack aStack) { + int rValue = Math.max((GT_ModHandler.getFuelCanValue(aStack) * 6) / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + private GT_RenderedTexture getCasingTexture(){ + if (this.mTier <= 4){ + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + else if (this.mTier == 5){ + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + else{ + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + //return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], this.getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent)}; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal)}; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], this.getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast)}; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active)}; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java new file mode 100644 index 0000000000..68dbc4fb61 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java @@ -0,0 +1,187 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import static gregtech.api.enums.GT_Values.V; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SolarGenerator; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_SolarGenerator; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechMetaSolarGenerator; + +public class GregtechMetaTileEntitySolarGenerator extends GregtechMetaSolarGenerator { + + public GregtechMetaTileEntitySolarGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, "Feasts on the power of the Sun!", new ITexture[0]); + this.onConfigLoad(); + } + + public GregtechMetaTileEntitySolarGenerator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.onConfigLoad(); + } + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, + "Generates power at " + this.getEfficiency() + "% Efficiency per tick", + "Output Voltage: "+this.getOutputTier()+" EU/t", + CORE.GT_Tooltip + }; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png"); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntitySolarGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "SunAbsorber.efficiency.tier." + this.mTier, 100 - (this.mTier * 10)); + + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() + && (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + aBaseMetaTileEntity.getEUCapacity()))) { + + if (this.mSolarCharge <= 20) { + //Utils.LOG_WARNING("1."); + this.mSolarCharge = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 45) { + //Utils.LOG_WARNING("2."); + this.mSolarCharge -= 1; + this.mLossTimer = 0; + } + + if ((aTick % 10L) == 0L) { + + Logger.WARNING("getUniversalEnergyStored: "+aBaseMetaTileEntity.getUniversalEnergyStored() + " maxEUOutput * 20 + getMinimumStoredEU: " + ((this.maxEUOutput() * 20) + this.getMinimumStoredEU())); + + if ((this.mSolarCharge > 100) && (aBaseMetaTileEntity.isAllowedToWork()) && + (!aBaseMetaTileEntity.getWorld().isThundering()) && + (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUStore() - this.getMinimumStoredEU()))) { + this.getBaseMetaTileEntity().increaseStoredEnergyUnits(sEnergyPerTick * this.getEfficiency(), true); + } + } + + if ((this.mSolarCharge < 500) && (this.mProcessingEnergy != 0) && ((aTick % 32L) == 0L)) { + Logger.WARNING("Adding Solar Charge. Currently "+this.mSolarCharge); + this.mProcessingEnergy -= 1; + this.mSolarCharge += 1; + } + + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && ((aTick % 64L) == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { + Logger.WARNING("Adding Processing Energy. Currently "+this.mProcessingEnergy); + final boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && (aBaseMetaTileEntity.getBiome().rainfall > 0.0F); + this.mProcessingEnergy += (bRain && (aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4)) || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; + } + + if (aBaseMetaTileEntity.isServerSide()){ + //Utils.LOG_WARNING("6."); + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && (aBaseMetaTileEntity.getUniversalEnergyStored() >= (this.maxEUOutput() + this.getMinimumStoredEU()))); + } + } + } + + @Override + public void inValidate() { + + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public long maxEUStore() { + return Math.max(this.getEUVar(), (V[this.mTier] * 16000) + this.getMinimumStoredEU()); + } + + + ITexture SolarArray[] = {new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_8V), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_MV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_HV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_EV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_ZPM), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_UV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; + } + + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; + } + + @Override + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + } + + @Override + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; + } + + @Override + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; + } + + @Override + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; + } + + @Override + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java new file mode 100644 index 0000000000..ab000b98d4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java @@ -0,0 +1,390 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_RTG extends GT_MetaTileEntity_BasicGenerator { + public int mEfficiency; + private int mDays; + private long mTicksToBurnFor; + private int mVoltage = 0; + private GT_Recipe mCurrentRecipe; + private int mDaysRemaining = 0; + private int mDayTick = 0; + private byte mNewTier = 0; + + public int removeDayOfTime(){ + if (this.mDaysRemaining > 0){ + return this.mDaysRemaining--; + } + return this.mDaysRemaining; + } + + //Generates fuel value based on MC days + public static int convertDaysToTicks(float days){ + int value = 0; + value = MathUtils.roundToClosestInt(20*86400*days); + return value; + } + + public static long getTotalEUGenerated(int ticks, int voltage){ + return ticks*voltage; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("mTicksToBurnFor", this.mTicksToBurnFor); + aNBT.setInteger("mVoltage", this.mVoltage); + aNBT.setInteger("mDaysRemaining", this.mDaysRemaining); + aNBT.setInteger("mDayTick", this.mDayTick); + aNBT.setByte("mNewTier", this.mNewTier); + + + if (this.mCurrentRecipe != null){ + final NBTTagList list = new NBTTagList(); + final ItemStack stack = this.mCurrentRecipe.mInputs[0]; + if(stack != null){ + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("mSlot", 0); + list.appendTag(data); + } + aNBT.setTag("mRecipeItem", list); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + //this.mMachineBlock = aNBT.getByte("mMachineBlock"); + this.mTicksToBurnFor = aNBT.getLong("mTicksToBurnFor"); + this.mVoltage = aNBT.getInteger("mVoltage"); + this.mDaysRemaining = aNBT.getInteger("mDaysRemaining"); + this.mDayTick = aNBT.getInteger("mDayTick"); + this.mNewTier = aNBT.getByte("mNewTier"); + + try { + ReflectionUtils.setByte(this, "mTier", this.mNewTier); + } + catch (Exception e) { + if (this.getBaseMetaTileEntity() != null){ + IGregTechTileEntity thisTile = this.getBaseMetaTileEntity(); + if (thisTile.isAllowedToWork() || thisTile.isActive()){ + thisTile.setActive(false); + } + } + } + + + final NBTTagList list = aNBT.getTagList("mRecipeItem", 10); + final NBTTagCompound data = list.getCompoundTagAt(0); + ItemStack lastUsedFuel = ItemStack.loadItemStackFromNBT(data); + if (lastUsedFuel != null){ + this.mCurrentRecipe = getRecipes().findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, new ItemStack[] { lastUsedFuel }); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()){ + if (this.mDayTick < 24000){ + this.mDayTick++; + } + else if (this.mDayTick >= 24000){ + this.mDayTick = 0; + this.mDaysRemaining = this.removeDayOfTime(); + } + } + + + if ((aBaseMetaTileEntity.isServerSide()) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 10L == 0L)) { + long tProducedEU = 0L; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { + this.mInventory[getStackDisplaySlot()] = null; + } else { + if (this.mInventory[getStackDisplaySlot()] == null) + this.mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + this.mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); + } + } else { + int tFuelValue = getFuelValue(this.mFluid); + int tConsumed = consumedFluidPerOperation(this.mFluid); + if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed)) { + long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, + (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + if ((tFluidAmountToUse > 0L) + && (aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true))) { + tProducedEU = tFluidAmountToUse * tFuelValue; + FluidStack tmp260_257 = this.mFluid; + tmp260_257.amount = (int) (tmp260_257.amount - (tFluidAmountToUse * tConsumed)); + } + } + } + if ((this.mInventory[getInputSlot()] != null) + && (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() * 20L + getMinimumStoredEU()) + && (GT_Utility.getFluidForFilledItem(this.mInventory[getInputSlot()], true) == null)) { + int tFuelValue = getFuelValue(this.mInventory[getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = getEmptyContainer(this.mInventory[getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + tProducedEU = tFuelValue; + } + } + } + if ((tProducedEU > 0L) && (getPollution() > 0)) { + PollutionUtils.addPollution(aBaseMetaTileEntity, (int) (tProducedEU * getPollution() / 500 * this.mTier + 1L)); + } + } + + if (aBaseMetaTileEntity.isServerSide()) + aBaseMetaTileEntity.setActive((aBaseMetaTileEntity.isAllowedToWork()) + && (aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU())); + } + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, + "Fuel is measured in minecraft days (Check with Scanner)", + "RTG changes output voltage depending on fuel", + "Generates power at " + this.getEfficiency() + "% Efficiency per tick", + "Output Voltage: "+this.getOutputTier()+" EU/t", + CORE.GT_Tooltip + }; + } + + public GregtechMetaTileEntity_RTG(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires RTG Pellets", new ITexture[0]); + } + + private byte getTier(){ + int voltage = this.mVoltage; + if (voltage >= 512){ + return 4; + } + else if (voltage >= 128){ + return 3; + } + else if (voltage >= 32){ + return 2; + } + else if (voltage >= 8){ + return 1; + } + return 0; + } + + public GregtechMetaTileEntity_RTG(String aName, int aTier, String aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return ((aSide > 1) && (aSide != getBaseMetaTileEntity().getFrontFacing()) + && (aSide != getBaseMetaTileEntity().getBackFacing())); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_RTG(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + return GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public int getEfficiency() { + return this.mEfficiency = 100; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB) }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP), + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[]{ + gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()]}; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB_ACTIVE) }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE) }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE) }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{ + gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(0)], + new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[getTier()]}; + } + + + public int getPollution() { + return 0; + } + + @Override + public int getFuelValue(ItemStack aStack) { + if ((GT_Utility.isStackInvalid(aStack)) || (getRecipes() == null)) + return 0; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, + new ItemStack[] { aStack }); + if (tFuel != null){ + this.mCurrentRecipe = tFuel; + int voltage = tFuel.mEUt; + this.mVoltage = voltage; + int sfsf = this.mTier; + //this.mDaysRemaining = tFuel.mSpecialValue*365; + + //Do some voodoo. + byte mTier2; + //mTier2 = ReflectionUtils.getField(this.getClass(), "mTier"); + try { + if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_AM241.get(1))){ + mTier2 = 1; + } + else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PO210.get(1))){ + mTier2 = 3; + } + else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PU238.get(1))){ + mTier2 = 2; + } + else if (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_SR90.get(1))){ + mTier2 = 1; + } + else { + //Utils.LOG_INFO("test:"+tFuel.mInputs[0].getDisplayName() + " | " + (ItemStack.areItemStacksEqual(tFuel.mInputs[0], GregtechItemList.Pellet_RTG_PU238.get(1)))); + mTier2 = 0; + } + ReflectionUtils.setByte(this, "mTier", mTier2); + this.mNewTier = mTier2; + //ReflectionUtils.setFinalStatic(mTier2, GT_Values.V[0]); + } catch (Exception e) { + Logger.WARNING("Failed setting mTier."); + e.printStackTrace(); + } + + this.mTicksToBurnFor = getTotalEUGenerated(convertDaysToTicks(tFuel.mSpecialValue), voltage); + if (mTicksToBurnFor >= Integer.MAX_VALUE){ + mTicksToBurnFor = Integer.MAX_VALUE; + Logger.WARNING("Fuel went over Int limit, setting to MAX_VALUE."); + } + this.mDaysRemaining = MathUtils.roundToClosestInt(mTicksToBurnFor/20/60/3); + Logger.WARNING("step | "+(int) (mTicksToBurnFor * getEfficiency() / 100L)); + return (int) (mTicksToBurnFor * getEfficiency() / 100L); + //return (int) (tFuel.mSpecialValue * 365L * getEfficiency() / 100L); + //return tFuel.mEUt; + } + Logger.WARNING("Not sure"); + return 0; + } + + @Override + public long maxEUOutput() { + return ((getBaseMetaTileEntity().isAllowedToWork()) ? this.mVoltage : 0L); + } + + @Override + public long getOutputTier() { + if (this.mCurrentRecipe != null){ + return this.mVoltage = this.mCurrentRecipe.mEUt; + } + return 0; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { "RTG - Running at tier "+this.mTier, + "Active: "+this.getBaseMetaTileEntity().isActive(), "Current Output: " + this.mVoltage + " EU/t", + "Days of Fuel remaining: "+(mTicksToBurnFor/20/60/20), + "Hours of Fuel remaining: "+(mTicksToBurnFor/20/60/60), + "Ticks of "+this.mVoltage+"v remaining: "+(mTicksToBurnFor), + "Current Recipe input: "+ this.mCurrentRecipe != null ? this.mCurrentRecipe.mInputs[0].getDisplayName() + " x1" : "NUll" + }; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_CombustionGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_CombustionGenerator.java new file mode 100644 index 0000000000..58919f0954 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_CombustionGenerator.java @@ -0,0 +1,50 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators.ULV; + +import static gregtech.api.enums.GT_Values.V; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.common.tileentities.generators.GT_MetaTileEntity_DieselGenerator; +import gtPlusPlus.core.lib.CORE; + +public class GT_MetaTileEntity_ULV_CombustionGenerator extends GT_MetaTileEntity_DieselGenerator { + public GT_MetaTileEntity_ULV_CombustionGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_ULV_CombustionGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + "Produces "+(this.getPollution()*20)+" pollution/sec", + "Fuel Efficiency: "+this.getEfficiency() + "%", + CORE.GT_Tooltip}; + } + + @Override + public long maxEUStore() { + return Math.max(getEUVar(), V[1] * 80L + getMinimumStoredEU()); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ULV_CombustionGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public int getCapacity() { + return 16000; + } + + @Override + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "DieselGenerator.efficiency.tier." + this.mTier, 95); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_GasTurbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_GasTurbine.java new file mode 100644 index 0000000000..17bb4463c4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_GasTurbine.java @@ -0,0 +1,59 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators.ULV; + +import static gregtech.api.enums.GT_Values.V; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.common.tileentities.generators.GT_MetaTileEntity_GasTurbine; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT_MetaTileEntity_ULV_GasTurbine extends GT_MetaTileEntity_GasTurbine { + public GT_MetaTileEntity_ULV_GasTurbine(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_ULV_GasTurbine(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + "Produces "+(this.getPollution()*20)+" pollution/sec", + "Fuel Efficiency: "+this.getEfficiency() + "%", + CORE.GT_Tooltip}; + } + + @Override + public long maxEUStore() { + return Math.max(getEUVar(), V[1] * 80L + getMinimumStoredEU()); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ULV_GasTurbine(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public int getCapacity() { + return 16000; + } + + @Override + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "GasTurbine.efficiency.tier." + this.mTier, 95); + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], + new GT_RenderedTexture((IIconContainer) TexturesGtBlock.Overlay_Machine_Turbine_Active)}; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_SteamTurbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_SteamTurbine.java new file mode 100644 index 0000000000..ef3310c6fc --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/ULV/GT_MetaTileEntity_ULV_SteamTurbine.java @@ -0,0 +1,58 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators.ULV; + +import static gregtech.api.enums.GT_Values.V; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.common.tileentities.generators.GT_MetaTileEntity_SteamTurbine; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT_MetaTileEntity_ULV_SteamTurbine extends GT_MetaTileEntity_SteamTurbine { + public GT_MetaTileEntity_ULV_SteamTurbine(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_ULV_SteamTurbine(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + "Produces "+(this.getPollution()*20)+" pollution/sec", + "Fuel Efficiency: "+this.getEfficiency() + "%", + CORE.GT_Tooltip}; + } + + @Override + public long maxEUStore() { + return Math.max(getEUVar(), V[1] * 80L + getMinimumStoredEU()); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ULV_SteamTurbine(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public int getCapacity() { + return 16000; + } + + @Override + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "SteamTurbine.efficiency.tier." + this.mTier, 6 + 1); + } + + @Override + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], + new GT_RenderedTexture((IIconContainer) TexturesGtBlock.Overlay_Machine_Turbine_Active)}; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java new file mode 100644 index 0000000000..a62a5d16c8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java @@ -0,0 +1,229 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators.creative; + +import static gregtech.api.enums.GT_Values.V; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import gregtech.api.enums.GT_Values; +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 gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaEnergyBuffer; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * + * This is the main construct for my Basic Machines such as the Automatic Extractor + * Extend this class to make a simple Machine + */ +public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { + + + public GregtechMetaCreativeEnergyBuffer(final String aName, final int aTier, + final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aDescription, aTextures, aSlotCount); + // TODO Auto-generated constructor stub + } + + public GregtechMetaCreativeEnergyBuffer(final int aID, final String aName, + final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, + "Use Screwdriver to change voltage", + "Hold Shift while using Screwdriver to change amperage", + EnumChatFormatting.GREEN+"CREATIVE MACHINE", + CORE.GT_Tooltip}; + } + + /* + * MACHINE_STEEL_SIDE + */ + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + CustomIcon h = TexturesGtBlock.Casing_Material_RedSteel; + CustomIcon g = TexturesGtBlock.Casing_Material_Grisium; + CustomIcon k; + boolean j = MathUtils.isNumberEven(this.mTier); + final ITexture[][][] rTextures = new ITexture[2][17][]; + k = j ? g : h; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture(k) }; + rTextures[1][i + 1] = new ITexture[] { + new GT_RenderedTexture(k), this.mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] + : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, + final boolean aRedstone) { + return this.mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaCreativeEnergyBuffer(this.mName, this.mTier, this.mDescription, + this.mTextures, this.mInventory.length); + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public long maxEUInput() { + return V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return V[this.mTier]; + } + + @Override + public long maxAmperesIn() { + return 16; + } + + @Override + public long maxAmperesOut() { + return 16; + } + + @Override public int getProgresstime() {return Integer.MAX_VALUE;} + @Override public int maxProgresstime() {return Integer.MAX_VALUE;} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + this.getBaseMetaTileEntity().increaseStoredEnergyUnits(Integer.MAX_VALUE, true); + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(Integer.MAX_VALUE, true); + } + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + String[] infoData = super.getInfoData(); + return new String[] { + infoData[0], + "THIS IS A CREATIVE ITEM - FOR TESTING | Tier: "+this.mTier, + infoData[1], + infoData[2] + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mTier", this.mTier); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mTier = aNBT.getByte("mTier"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (KeyboardUtils.isShiftKeyDown()) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + else { + if (this.mTier < (CORE.GTNH ? GT_Values.V.length-1 : 9)) { + this.mTier++; + } + else { + this.mTier = 0; + } + this.markDirty(); + try { + Field field = ReflectionUtils.getField(this.getClass(), "mTextures"); + field.setAccessible(true); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); + ITexture[][][] V = getTextureSet(null); + if (V != null) { + Logger.REFLECTION("Got Valid Textures."); + if (this.getBaseMetaTileEntity().isClientSide()) { + Logger.REFLECTION("Clientside Call."); + Logger.REFLECTION("Refreshing Textures on buffer."); + field.set(this, V); + Logger.REFLECTION("Refreshed Textures on buffer."); + } + else { + Logger.REFLECTION("Serverside Call."); + } + } + else { + Logger.REFLECTION("Bad mTextures setter."); + } + } + catch (Throwable t) { + //Bad refresh. + t.printStackTrace(); + Logger.REFLECTION("Bad mTextures setter."); + } + PlayerUtils.messagePlayer(aPlayer, "Now running at "+GT_Values.VOLTAGE_NAMES[this.mTier]+"."); + } + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_WorldAccelerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_WorldAccelerator.java new file mode 100644 index 0000000000..129446c40d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_WorldAccelerator.java @@ -0,0 +1,328 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import static gregtech.api.enums.GT_Values.V; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons.CustomIcon; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraftforge.common.util.ForgeDirection; + +public class GT_MetaTileEntity_WorldAccelerator extends GT_MetaTileEntity_TieredMachineBlock { + + public static String[] BlacklistedTileEntiyClassNames; + + private byte mMode = 0; // 0: RandomTicks around 1: TileEntities with range + // 1 + private static CustomIcon _mGTIco_Norm_Idle; + private static CustomIcon _mGTIco_Norm_Active; + private static CustomIcon _mGTIco_TE_Idle; + private static CustomIcon _mGTIco_TE_Active; + private static int[] mAccelerateStatic = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, 512, 512, 512, 512, 512 }; + + @Override + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + _mGTIco_Norm_Idle = new CustomIcon("iconsets/OVERLAY_ACCELERATOR"); + _mGTIco_Norm_Active = new CustomIcon("iconsets/OVERLAY_ACCELERATOR_ACTIVE"); + _mGTIco_TE_Idle = new CustomIcon("iconsets/OVERLAY_ACCELERATOR_TE"); + _mGTIco_TE_Active = new CustomIcon("iconsets/OVERLAY_ACCELERATOR_TE_ACTIVE"); + } + + @SideOnly(Side.CLIENT) + @Override + public void onValueUpdate(byte aValue) { + mMode = aValue; + } + + @Override + public byte getUpdateData() { + return mMode; + } + + public GT_MetaTileEntity_WorldAccelerator(int pID, String pName, String pNameRegional, int pTier) { + super(pID, pName, pNameRegional, pTier, 0, ""); + } + + @Override + public String[] getDescription() { + return new String[] { + String.format("Accelerating things (Radius: %d EU/t: %d Speed Bonus: x%d)", mTier, + getEnergyDemand(mTier, false), mAccelerateStatic[mTier]), + "Use a screwdriver to change mode", "To accelerate TileEntities, this machine has to be adjacent to it", + "This machine accepts up to 8 Amps", "Accelerating TileEntities doubles Energy-Demand"}; + + } + + public GT_MetaTileEntity_WorldAccelerator(String pName, int pTier, int pInvSlotCount, String pDescription, + ITexture[][][] pTextures) { + super(pName, pTier, pInvSlotCount, pDescription, pTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity pTileEntity) { + return new GT_MetaTileEntity_WorldAccelerator(mName, mTier, mInventory.length, mDescription, mTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] pTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity pBaseMetaTileEntity, byte pSide, byte pFacing, byte pColorIndex, + boolean pActive, boolean pRedstone) { + if (mMode == 0) + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][pColorIndex + 1], + (pSide < 2) ? null + : pActive ? new GT_RenderedTexture(_mGTIco_Norm_Active) + : new GT_RenderedTexture(_mGTIco_Norm_Idle) }; + else + return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[mTier][pColorIndex + 1], (pSide < 2) ? null + : pActive ? new GT_RenderedTexture(_mGTIco_TE_Active) : new GT_RenderedTexture(_mGTIco_TE_Idle) }; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity pBaseMetaTileEntity, int pIndex, byte pSide, ItemStack pStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity pBaseMetaTileEntity, int pIndex, byte pSide, ItemStack pStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound pNBT) { + pNBT.setByte("mAccelMode", mMode); + } + + public static long getEnergyDemand(int pTier, boolean pIsAcceleratingTEs) { + return V[pTier] * (pIsAcceleratingTEs ? 6 : 3); + } + + @Override + public void loadNBTData(NBTTagCompound pNBT) { + mMode = pNBT.getByte("mAccelMode"); + } + + @Override + public boolean isAccessAllowed(EntityPlayer pPlayer) { + return true; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return true; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public long maxEUStore() { + return 512 + V[mTier] * 50; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxAmperesIn() { + return 8; + } + + private static String[] mModeStr = { "Blocks", "TileEntities" }; + + @Override + public void onScrewdriverRightClick(byte pSide, EntityPlayer pPlayer, float pX, float pY, float pZ) { + mMode = (byte) (mMode == 0x00 ? 0x01 : 0x00); + markDirty(); + PlayerUtils.messagePlayer(pPlayer, String.format("Switched mode to: %s", mModeStr[mMode])); + } + + @Override + public void onPostTick(IGregTechTileEntity pBaseMetaTileEntity, long pTick) { + try { + if (!pBaseMetaTileEntity.isServerSide()) + return; + + long tEnergyDemand = getEnergyDemand(mTier, (mMode == 1)); + + // Do we have enough energy to run? Or are we not allowed to run? + if (pBaseMetaTileEntity.getStoredEU() < tEnergyDemand || !pBaseMetaTileEntity.isAllowedToWork()) { + // Check if machine was active before + if (pBaseMetaTileEntity.isActive()) + pBaseMetaTileEntity.setActive(false); // Then disable it now + } else { + // Continue to drain power + if (pBaseMetaTileEntity.decreaseStoredEnergyUnits(tEnergyDemand, false)) { + World tWorld = pBaseMetaTileEntity.getWorld(); + // Limit the random ticks to once per second + if (mMode == 0) { + if (pTick % 20 == 0) + doAccelerateNormalBlocks(pBaseMetaTileEntity, tWorld); + } else + doAccelerateTileEntities(pBaseMetaTileEntity, tWorld); + + } else { + // Energy drain failed. Disable machine + if (pBaseMetaTileEntity.isActive()) + pBaseMetaTileEntity.setActive(false); + } + } + } catch (Exception e) { + Logger.ERROR("GT_MetaTileEntity_WorldAccelerator.onPostTick.crash"); + Logger.ERROR(e.getMessage()); + } + } + + private void doAccelerateTileEntities(IGregTechTileEntity pBaseMetaTileEntity, World pWorld) { + try { + if (!pBaseMetaTileEntity.isActive()) + getBaseMetaTileEntity().setActive(true); + + for (ForgeDirection tDir : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tTile = pBaseMetaTileEntity.getTileEntityAtSide((byte) tDir.ordinal()); + if (isTEBlackListed(tTile)) + continue; + + long tMaxTime = System.nanoTime() + 1000000; + for (int j = 0; j < mAccelerateStatic[mTier]; j++) { + tTile.updateEntity(); + if (System.nanoTime() > tMaxTime) + break; + } + } + } catch (Exception e) { + Logger.ERROR("GT_MetaTileEntity_WorldAccelerator.doAccelerateTileEntities.crash"); + Logger.ERROR(e.getMessage()); + } + } + + private static List<String> _mBlacklistedTileEntities = new ArrayList<String>(); + + // Inspired by ChromatiCraft's TileAccelerator + private boolean isTEBlackListed(TileEntity pTile) { + if (pTile == null) + return true; // Obvious + if (!pTile.canUpdate()) + return true; // Skip if TE can't update at all + if (pTile.isInvalid()) + return true; // Obvious + + String tSimpleClassName = pTile.getClass().getSimpleName().toLowerCase(); + String tCanonicalName = pTile.getClass().getCanonicalName().toLowerCase(); + if (tSimpleClassName.contains("conduit") || tSimpleClassName.contains("wire") + || tSimpleClassName.contains("cable")) + return true; + if (tCanonicalName.contains("appeng") || tCanonicalName.contains("gregtech")) + // Don't accelerate ANY Gregtech machines! + return true; + for (String tS : BlacklistedTileEntiyClassNames) { + if (tCanonicalName.equalsIgnoreCase(tS)) + return true; + } + + return false; + } + + /** + * Accelerate normal blocks. Eats some power and adds randomTicks to every + * block within its working area (Tier-Number = radius) This does only + * affect blocks that implement the "RandomTick" method; Which is mostly + * used for grass growth and plants. + * + * @param pBaseMetaTileEntity + */ + private void doAccelerateNormalBlocks(IGregTechTileEntity pBaseMetaTileEntity, World pWorld) { + if (!pBaseMetaTileEntity.isActive()) + getBaseMetaTileEntity().setActive(true); + + Random rnd = new Random(); + int tX = pBaseMetaTileEntity.getXCoord(); + int tY = pBaseMetaTileEntity.getYCoord(); + int tZ = pBaseMetaTileEntity.getZCoord(); + + int tX1 = tX - mTier; + int tX2 = tX + mTier; + int tY1 = Math.max(tY - mTier, 0); // Limit to bedrock + int tY2 = Math.min(tY + mTier, 255); // Limit to build height + int tZ1 = tZ - mTier; + int tZ2 = tZ + mTier; + + for (int xi = tX1; xi <= tX2; xi++) + for (int yi = tY1; yi <= tY2; yi++) + for (int zi = tZ1; zi <= tZ2; zi++) + tryTickBlock(pWorld, xi, yi, zi, rnd); + + } + + /** + * Send a tick to the target block + * + * @param pWorld + * @param pX + * @param pY + * @param pZ + * @param pRnd + */ + private void tryTickBlock(World pWorld, int pX, int pY, int pZ, Random pRnd) { + try { + for (int j = 0; j < mTier; j++) { + Block tBlock = pWorld.getBlock(pX, pY, pZ); + if (tBlock.getTickRandomly()) + tBlock.updateTick(pWorld, pX, pY, pZ, pRnd); + } + } catch (Exception e) { + Logger.ERROR("GT_MetaTileEntity_WorldAccelerator.tryTickBlock.crash"); + Logger.ERROR(e.getMessage()); + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java new file mode 100644 index 0000000000..33ffd1f118 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -0,0 +1,867 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import static gregtech.api.enums.GT_Values.V; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.general.ItemAirFilter; +import gtPlusPlus.core.item.general.ItemBasicScrubberTurbine; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.gui.basic.CONTAINER_PollutionCleaner; +import gtPlusPlus.xmod.gregtech.api.gui.basic.GUI_PollutionCleaner; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_BasicMachine { + + public int mPollutionReduction = 0; + protected int mBaseEff = 2500; + protected int mOptimalAirFlow = 0; + protected boolean mHasPollution = false; + protected int SLOT_ROTOR = 5; + protected int SLOT_FILTER = 6; + protected static boolean mPollutionEnabled = true; + + protected boolean mSaveRotor = false; + + public GregtechMetaAtmosphericReconditioner(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 2, "Making sure you don't live in Gwalior - Uses 2A", 3, 0, "Recycler.png", "", + new ITexture[]{ + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB) + }); + mPollutionEnabled = PollutionUtils.isPollutionEnabled(); + } + + public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 2, aDescription, aTextures, 2, 0, aGUIName, aNEIName); + mPollutionEnabled = PollutionUtils.isPollutionEnabled(); + } + + /*public GregtechMetaAtmosphericReconditioner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 2, aDescription, aTextures, 2, 0, aGUIName, aNEIName); + }*/ + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaAtmosphericReconditioner(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public String[] getDescription() { + + boolean highTier = this.mTier >= 7; + + String[] A = new String[]{ + this.mDescription, + highTier ? "Will attempt to remove 1/4 pollution from 8 surrounding chunks" : "", + highTier ? "If these chunks are not loaded, they will be ignored" : "", + "Requires a turbine rotor and an Air Filter [T1/T2] to run.", + "The turbine rotor must be manually inserted/replaced", + "Can be configured with a soldering iron to change modes", + "Low Efficiency: Removes half pollution, Turbine takes 50% dmg", + "High Efficiency: Removes full pollution, Turbine takes 100% dmg", + "Turbine Rotor will not break in LE mode", + "Insert an equal tier Conveyor Module to enable automation" + }; + if (!mPollutionEnabled) { + String[] B = new String[] { + "===============================================", + "Pollution is disabled, scrubbers will now have a bonus use", + "They are now able to remove ALL lingering pollution as GT ignores it", + "and it will linger forever!", + "===============================================", + }; + A = ArrayUtils.addAll(A, B); + } + return A; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); + aNBT.setBoolean("mSaveRotor", mSaveRotor); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mOptimalAirFlow = aNBT.getInteger("mOptimalAirFlow"); + this.mSaveRotor = aNBT.getBoolean("mSaveRotor"); + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 2; + } + + @Override + public long maxEUStore() { + return V[mTier] * 256; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + + //Get Current Pollution Amount. + int mCurrentPollution = getCurrentChunkPollution(); + boolean isIdle = true; + + //Get Inventory Item + ItemStack stackRotor = this.mInventory[SLOT_ROTOR]; + ItemStack stackFilter = this.mInventory[SLOT_FILTER]; + + //Power Drain + long drainEU = maxEUInput() * maxAmperesIn(); + if (aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU){ + if(aBaseMetaTileEntity.decreaseStoredEnergyUnits(drainEU, false)){ + isIdle = false; + } + else { + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + } + else if (!aBaseMetaTileEntity.isActive() && aBaseMetaTileEntity.getStoredEU() >= drainEU/4){ + if(aBaseMetaTileEntity.decreaseStoredEnergyUnits((drainEU/4), false)){ + isIdle = false; + } + else { + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + } + else { + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + + //Only try once/sec. + if (!isIdle && aTick % 20L == 0L){ + + + + for (int i=0;i<this.mInventory.length;i++) { + ItemStack aSlotContent = this.mInventory[i]; + if (aSlotContent != null) { + Logger.INFO("Found "+aSlotContent.getDisplayName()+" in slot "+i); + } + } + + for (int i=0;i<this.mInventory.length;i++) { + if (hasRotor(this.mInventory[i])) { + Logger.INFO("Found Rotor in slot "+i); + break; + } + } + for (int i=0;i<this.mInventory.length;i++) { + if (hasAirFilter(this.mInventory[i])) { + Logger.INFO("Found Filter in slot "+i); + break; + } + } + + //Check if machine can work. + if ((aBaseMetaTileEntity.isAllowedToWork())){ + Logger.INFO("Can work."); + + //Enable machine animation/graphic + if (hasRotor(stackRotor) && hasAirFilter(stackFilter) && this.mHasPollution){ + if (!this.getBaseMetaTileEntity().isActive()) { + Logger.INFO("Set Active."); + aBaseMetaTileEntity.setActive(true); + } + } + else if (!this.mHasPollution || mCurrentPollution <= 0 || stackRotor == null || stackFilter == null || !hasRotor(stackRotor) || !hasAirFilter(stackFilter)){ + if (!this.getBaseMetaTileEntity().isActive()) { + Logger.INFO("Set Inactive."); + aBaseMetaTileEntity.setActive(false); + this.sendSound((byte) -122); + } + } + + //If Active. + if (aBaseMetaTileEntity.isActive()){ + Logger.INFO("Doing something."); + + //Do nothing if there is no pollution. + if(this.mHasPollution && mCurrentPollution > 0){ + Logger.INFO("Has Pollution? "+mHasPollution+", Current Pollution: "+mCurrentPollution); + + //Only check every 30s. + if (!isIdle && aTick % (20L * 30) == 0L){ + mPollutionEnabled = PollutionUtils.isPollutionEnabled(); + //Clear out pollution if it's disabled, because I am a nice gal. + if (!PollutionUtils.isPollutionEnabled()) { + PollutionUtils.nullifyPollution(this.getBaseMetaTileEntity()); + } + } + + + + + //Use a Turbine + if(hasRotor(stackRotor) && hasAirFilter(stackFilter)){ + Logger.INFO("Found Turbine."); + + mBaseEff = getBaseEfficiency(stackRotor); + mOptimalAirFlow = getOptimalAirFlow(stackRotor); + + //Make sure we have a valid Turbine and Eff/Airflow + if (this.mBaseEff > 0 && this.mOptimalAirFlow > 0){ + //Utils.LOG_WARNING("Pollution Cleaner [5]"); + + //Log Debug information. + Logger.INFO("mBaseEff[1]:"+mBaseEff); + Logger.INFO("mOptimalAirFlow[1]:"+mOptimalAirFlow); + + //Calculate The Voltage we are running + long tVoltage = drainEU; + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + //Check Sides for Air, + //More air means more pollution processing. + int mAirSides = getFreeSpaces(); + + int reduction = 0; + + //If no sides are free, how will you process the atmosphere? + if (mAirSides > 0){ + reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); //Was originally *100 + Logger.INFO("mPollutionReduction[1]:"+reduction); + + //I stole this code + reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); + Logger.INFO("reduction[2]:"+reduction); + reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); + Logger.INFO("reduction[3]:"+reduction); + + mPollutionReduction = reduction; + + //Set a temp to remove variable to aleviate duplicate code. + int toRemove = 0; + + Logger.INFO("mCurrentPollution[4]:"+mCurrentPollution); + Logger.INFO("mCurrentPollution[5]:"+reduction); + if (reduction <= mCurrentPollution){ + //Clean some Air. + toRemove = reduction; + } + else { + //Makes sure we don't get negative pollution. + toRemove = mCurrentPollution; + } + + toRemove = toRemove/2; + Logger.INFO("mCurrentPollution[6]:"+toRemove); + + //We are good to clean + if (toRemove > 0){ + if (damageTurbineRotor() && damageAirFilter()){ + Logger.INFO("Removing "+toRemove+" pollution"); + removePollution(mSaveRotor ? (toRemove/2) : toRemove); + Logger.INFO("mNewPollution[4]:"+getCurrentChunkPollution()); + } + else { + Logger.INFO("Could not damage turbine rotor or Air Filter."); + aBaseMetaTileEntity.setActive(false); + } + } //End of pollution removal block. + } //End of valid air sides block. + } //End of valid toolstats block. + } //End of correct inventory item block. + else { + //Utils.LOG_WARNING("Wrong Tool metaitem Found."); + } + } + } + else if (!aBaseMetaTileEntity.isActive()) { + return; + } + } //End of can work block. + else { //Disable Machine. + //aBaseMetaTileEntity.setActive(false); + } + } //End of 1/sec action block. + else { + + if (hasRotor(stackRotor) && hasAirFilter(stackFilter) && this.mHasPollution && !isIdle && aBaseMetaTileEntity.isAllowedToWork()){ + aBaseMetaTileEntity.setActive(true); + } + else if (isIdle || !this.mHasPollution || mCurrentPollution <= 0 || stackRotor == null || stackFilter == null || !hasRotor(stackRotor) || !hasAirFilter(stackFilter)){ + aBaseMetaTileEntity.setActive(false); + } + + } + if (this.getBaseMetaTileEntity().isActive()) { + if (MathUtils.randInt(0, 5) <= 2) { + this.sendSound((byte) -120); + } + } + + } //End of is serverside block. + } + + + public int getCurrentChunkPollution(){ + int mCurrentChunkPollution = 0; + if (this.mTier < 7) { + mCurrentChunkPollution = PollutionUtils.getPollution(getBaseMetaTileEntity()); + } + else { + AutoMap<Chunk> aSurrounding = new AutoMap<Chunk>(); + World aWorld = this.getBaseMetaTileEntity().getWorld(); + int xPos = this.getBaseMetaTileEntity().getXCoord(); + int zPos = this.getBaseMetaTileEntity().getZCoord(); + Chunk a1 = aWorld.getChunkFromBlockCoords(xPos-32, zPos-32); + Chunk a2 = aWorld.getChunkFromBlockCoords(xPos-32, zPos); + Chunk a3 = aWorld.getChunkFromBlockCoords(xPos-32, zPos+32); + Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos-32); + Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); + Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos+32); + Chunk c1 = aWorld.getChunkFromBlockCoords(xPos+32, zPos-32); + Chunk c2 = aWorld.getChunkFromBlockCoords(xPos+32, zPos); + Chunk c3 = aWorld.getChunkFromBlockCoords(xPos+32, zPos+32); + aSurrounding.put(a1); + aSurrounding.put(a2); + aSurrounding.put(a3); + aSurrounding.put(b1); + aSurrounding.put(b2); + aSurrounding.put(b3); + aSurrounding.put(c1); + aSurrounding.put(c2); + aSurrounding.put(c3); + for (Chunk r : aSurrounding) { + mCurrentChunkPollution += getPollutionInChunk(r); + } + } + if (mCurrentChunkPollution > 0){ + mHasPollution = true; + } + else { + mHasPollution = false; + } + return mCurrentChunkPollution; + } + + public int getPollutionInChunk(Chunk aChunk){ + int mCurrentChunkPollution = PollutionUtils.getPollution(aChunk); + if (mCurrentChunkPollution > 0){ + mHasPollution = true; + } + else { + mHasPollution = false; + } + return mCurrentChunkPollution; + } + + public boolean hasRotor(ItemStack rotorStack){ + if(rotorStack != null){ + if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { + //Logger.INFO("Found Basic Turbine Rotor."); + return true; + } + else if (rotorStack.getItem() instanceof GT_MetaGenerated_Tool && rotorStack.getItemDamage() >= 170 && rotorStack.getItemDamage() <= 179){ + //Logger.INFO("Found Turbine Rotor."); + return true; + } + else { + //Logger.INFO("Found: "+rotorStack.getDisplayName()+":"+rotorStack.getItemDamage()); + } + } + //Logger.INFO("Found No Turbine Rotor."); + return false; + } + + public boolean damageTurbineRotor(){ + try{ + + boolean creativeRotor = false; + ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; + if (rotorStack == null) { + return false; + } + else if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { + long currentUse = ItemBasicScrubberTurbine.getFilterDamage(rotorStack); + //Remove broken Filter + if (rotorStack.getItemDamage() == 0 && currentUse >= 2000-10){ + Logger.INFO("Depleting ItemBasicScrubberTurbine T1"); + this.mInventory[this.SLOT_FILTER] = null; + return false; + } + else if (rotorStack.getItemDamage() == 1 && currentUse >= 4000-10){ + Logger.INFO("Depleting ItemBasicScrubberTurbine T2"); + this.mInventory[this.SLOT_FILTER] = null; + return false; + } + else if (rotorStack.getItemDamage() == 2 && currentUse >= 6000-10){ + Logger.INFO("Depleting ItemBasicScrubberTurbine T3"); + this.mInventory[this.SLOT_FILTER] = null; + return false; + } + else { + //Do Damage + Logger.INFO("Damaging ItemBasicScrubberTurbine"); + ItemBasicScrubberTurbine.setFilterDamage(rotorStack, currentUse+10); + Logger.INFO("Rotor Damage: "+currentUse); + return true; + } + } + else if(rotorStack.getItem() instanceof GT_MetaGenerated_Tool_01) { + Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(rotorStack); + Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(rotorStack); + if (t1 == Materials._NULL && t2 == Materials._NULL){ + Logger.INFO("Found creative rotor."); + creativeRotor = true; + } + } + else { + Logger.INFO("Bad item in rotor slot."); + return false; + } + + if(mInventory[SLOT_ROTOR].getItem() instanceof GT_MetaGenerated_Tool_01 && + ((GT_MetaGenerated_Tool) mInventory[SLOT_ROTOR].getItem()).getToolStats(mInventory[SLOT_ROTOR]).getSpeedMultiplier()>0 && + GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[SLOT_ROTOR]).mToolSpeed>0 ) { + + long damageValue = (long) Math.floor(Math.abs(MathUtils.randFloat(1, 2) - MathUtils.randFloat(1, 3)) * (1 + 3 - 1) + 1); + double fDam = Math.floor(Math.abs(MathUtils.randFloat(1f, 2f) - MathUtils.randFloat(1f, 2f)) * (1f + 2f - 1f) + 1f); + damageValue -= fDam; + + //Logger.INFO("Trying to do "+damageValue+" damage to the rotor. ["+fDam+"]"); + /*Materials M1 = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[this.SLOT_ROTOR]); + Materials M2 = GT_MetaGenerated_Tool.getSecondaryMaterial(this.mInventory[this.SLOT_ROTOR]); + + Logger.INFO("Trying to do "+damageValue+" damage to the rotor. [2]");*/ + + //Damage Rotor + //int rotorDurability = this.mInventory[this.SLOT_ROTOR].getItemDamage(); + long rotorDamage = creativeRotor ? 0 : GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + long rotorDurabilityMax = creativeRotor ? Integer.MAX_VALUE : GT_MetaGenerated_Tool.getToolMaxDamage(this.mInventory[this.SLOT_ROTOR]); + long rotorDurability = (rotorDurabilityMax - rotorDamage); + Logger.INFO("Rotor Damage: "+rotorDamage + " | Max Durability: "+rotorDurabilityMax+" | "+" Remaining Durability: "+rotorDurability); + if (rotorDurability >= damageValue){ + + + if (!mSaveRotor){ + Logger.INFO("Damaging Rotor."); + + if (!creativeRotor) + GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue, 0, null); + + long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + if (tempDur < rotorDurabilityMax){ + return true; + } + else { + rotorDurability = 0; + } + } + else { + Logger.INFO("Damaging Rotor."); + if (rotorDurability > 1000){ + if (!creativeRotor) + GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue/2, 0, null); + long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + if (tempDur < rotorDurabilityMax){ + return true; + } + else { + rotorDurability = 0; + } + } + } + + + } + + if (rotorDurability <= 0 && !mSaveRotor && !creativeRotor) { + Logger.INFO("Destroying Rotor."); + this.mInventory[this.SLOT_ROTOR] = null; + return false; + } + else if (rotorDurability <= 0 && mSaveRotor) { + Logger.INFO("Saving Rotor."); + return false; + } + + + }else { + Logger.INFO("Bad Rotor."); + return false; + } + } + catch (Throwable t){ + t.printStackTrace(); + } + return false; + } + + public int getFreeSpaces(){ + int mAir = 0; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if(aBaseMetaTileEntity.getAirOffset(1, 0, 0)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(-1, 0, 0)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(0, 0, 1)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(0, 0, -1)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(0, 1, 0)){ + mAir++; + } + if(aBaseMetaTileEntity.getAirOffset(0, -1, 0)){ + mAir++; + } + return mAir; + } + + public boolean removePollution(int toRemove){ + + if (this == null || this.getBaseMetaTileEntity() == null || this.getBaseMetaTileEntity().getWorld() == null) { + return false; + } + + if (this.mTier < 7) { + int startPollution = getCurrentChunkPollution(); + Logger.INFO("Current Chunk Pollution: "+startPollution); + PollutionUtils.removePollution(this.getBaseMetaTileEntity(), toRemove); + int after = getCurrentChunkPollution(); + Logger.INFO("Current Chunk Pollution: "+after); + return (after<startPollution); + } + else { + int chunksWithRemoval = 0; + int totalRemoved = 0; + AutoMap<Chunk> aSurrounding = new AutoMap<Chunk>(); + Chunk aThisChunk = this.getBaseMetaTileEntity().getWorld().getChunkFromBlockCoords(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getZCoord()); + int mainChunkX = aThisChunk.xPosition; + int mainChunkZ = aThisChunk.zPosition; + + World aWorld = this.getBaseMetaTileEntity().getWorld(); + int xPos = this.getBaseMetaTileEntity().getXCoord(); + int zPos = this.getBaseMetaTileEntity().getZCoord(); + + Chunk a1 = aWorld.getChunkFromBlockCoords(xPos-32, zPos-32); + Chunk a2 = aWorld.getChunkFromBlockCoords(xPos-32, zPos); + Chunk a3 = aWorld.getChunkFromBlockCoords(xPos-32, zPos+32); + Chunk b1 = aWorld.getChunkFromBlockCoords(xPos, zPos-32); + Chunk b2 = aWorld.getChunkFromBlockCoords(xPos, zPos); + Chunk b3 = aWorld.getChunkFromBlockCoords(xPos, zPos+32); + Chunk c1 = aWorld.getChunkFromBlockCoords(xPos+32, zPos-32); + Chunk c2 = aWorld.getChunkFromBlockCoords(xPos+32, zPos); + Chunk c3 = aWorld.getChunkFromBlockCoords(xPos+32, zPos+32); + + aSurrounding.put(a1); + aSurrounding.put(a2); + aSurrounding.put(a3); + aSurrounding.put(b1); + aSurrounding.put(b2); + aSurrounding.put(b3); + aSurrounding.put(c1); + aSurrounding.put(c2); + aSurrounding.put(c3); + + for (Chunk r : aSurrounding) { + if (!r.isChunkLoaded) { + continue; + } + + int startPollution = getPollutionInChunk(r); + if (startPollution == 0) { + continue; + } + + Logger.INFO("Trying to remove pollution from chunk "+r.xPosition+", "+r.zPosition+" | "+startPollution); + int after = 0; + boolean isMainChunk = r.isAtLocation(mainChunkX, mainChunkZ); + + int removal = Math.max(0, !isMainChunk ? (toRemove/4) : toRemove); + if (removePollution(r, removal)) { + chunksWithRemoval++; + after = getPollutionInChunk(r); + } + else { + after = 0; + } + if (startPollution - after > 0) { + totalRemoved += (startPollution - after); + } + Logger.INFO("Removed "+(startPollution - after)+" pollution from chunk "+r.xPosition+", "+r.zPosition+" | "+after); + } + return totalRemoved > 0 && chunksWithRemoval > 0; + } + } + + public boolean removePollution(Chunk aChunk, int toRemove){ + int before = getCurrentChunkPollution(); + PollutionUtils.removePollution(aChunk, toRemove); + int after = getCurrentChunkPollution(); + return (after<before); + } + + + public boolean hasAirFilter(ItemStack filter){ + if (filter == null) { + return false; + } + if (filter.getItem() instanceof ItemAirFilter){ + return true; + } + return false; + } + + public boolean damageAirFilter(){ + ItemStack filter = this.mInventory[this.SLOT_FILTER]; + if (filter == null) { + return false; + } + + boolean creativeRotor = false; + ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; + if (rotorStack != null) { + if(rotorStack.getItem() instanceof GT_MetaGenerated_Tool_01) { + Materials t1 = GT_MetaGenerated_Tool.getPrimaryMaterial(rotorStack); + Materials t2 = GT_MetaGenerated_Tool.getSecondaryMaterial(rotorStack); + if (t1 == Materials._NULL && t2 == Materials._NULL){ + creativeRotor = true; + } + } + } + + if (creativeRotor) { + return true; + } + + + if (filter.getItem() instanceof ItemAirFilter){ + + long currentUse = ItemAirFilter.getFilterDamage(filter); + + //Remove broken Filter + if (filter.getItemDamage() == 0 && currentUse >= 50-1){ + this.mInventory[this.SLOT_FILTER] = null; + return false; + } + else if (filter.getItemDamage() == 1 && currentUse >= 2500-1){ + this.mInventory[this.SLOT_FILTER] = null; + return false; + } + else { + //Do Damage + ItemAirFilter.setFilterDamage(filter, currentUse+1); + Logger.INFO("Filter Damage: "+currentUse); + return true; + } + } + return false; + } + + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_PollutionCleaner(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_PollutionCleaner(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex == SLOT_FILTER) { + if (aStack.getItem() instanceof ItemAirFilter) { + Logger.INFO("Inserting Air Filter into "+aIndex); + return true; + } + } + if (aIndex == SLOT_ROTOR) { + if (this.mInventory[7] != null) { + Logger.INFO("Found conveyor, can automate turbines. Inserting into "+aIndex); + if (aStack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } + if (aStack.getItem() instanceof GT_MetaGenerated_Tool && aStack.getItemDamage() >= 170 && aStack.getItemDamage() <= 179){ + return true; + } + } + } + //return super.canInsertItem(aIndex, aStack, aSide); + return false; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, + float aZ) { + this.mSaveRotor = Utils.invertBoolean(mSaveRotor); + if (mSaveRotor){ + PlayerUtils.messagePlayer(aPlayer, "Running in low efficiency mode, rotors will not break."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Running in high efficiency mode, rotors will break."); + } + return true; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + if (aIndex == -120) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(103)), MathUtils.randInt(5, 50), 0.05F, aX, aY, aZ); + } else if (aIndex == -121 || aIndex == -122) { + //GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(108)), 0, 0.5F, aX, aY, aZ); + } /*else if (aIndex == -122) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(6)), 100, 1.0F, aX, aY, aZ); + }*/ else { + super.doSound((byte) 0, aX, aY, aZ); + } + } + + @Override + public boolean canHaveInsufficientEnergy() { + // TODO Auto-generated method stub + return super.canHaveInsufficientEnergy(); + } + + @Override + public String[] getInfoData() { + AutoMap<String> aTooltipSuper = new AutoMap<String>(); + for (String s : super.getInfoData()) { + aTooltipSuper.put(s); + } + int mAirSides = getFreeSpaces(); + int reduction = 0; + + try { + long tVoltage = maxEUInput(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); + reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); + reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); + + aTooltipSuper.put("Maximum pollution removed per second: "+reduction); + } + catch (Throwable t) { + aTooltipSuper.put("Maximum pollution removed per second: "+mPollutionReduction); + } + aTooltipSuper.put("Air Sides: "+mAirSides); + + String[] mBuiltOutput = new String[aTooltipSuper.size()]; + int aIndex = 0; + for (String i : aTooltipSuper) { + mBuiltOutput[aIndex++] = i; + } + + + + return mBuiltOutput; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + if (aSide <= 1) { + return false; + } + return super.allowCoverOnSide(aSide, aCoverID); + } + + @Override + public ITexture[] getTopFacingInactive(byte aColor) { + return super.getTopFacingInactive(aColor); + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + aNBT.setInteger("mOptimalAirFlow", this.mOptimalAirFlow); + aNBT.setBoolean("mSaveRotor", mSaveRotor); + super.setItemNBT(aNBT); + } + + private static ItemStack[] sGregTurbines; + + public static ItemStack getTieredTurbine(int aTier) { + if (sGregTurbines == null) { + sGregTurbines = new ItemStack[3]; + sGregTurbines[0] = GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(GT_MetaGenerated_Tool_01.TURBINE_SMALL, 1, Materials.Iron, Materials.Iron, null); + sGregTurbines[1] = GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(GT_MetaGenerated_Tool_01.TURBINE_SMALL, 1, Materials.Bronze, Materials.Bronze, null); + sGregTurbines[2] = GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(GT_MetaGenerated_Tool_01.TURBINE_SMALL, 1, Materials.Steel, Materials.Steel, null); + } + else { + return sGregTurbines[aTier]; + } + + return null; + } + + public int getBaseEfficiency(ItemStack aStackRotor) { + if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { + return getBaseEfficiency(getTieredTurbine(aStackRotor.getItemDamage())); + } + return (int) ((50.0F + (10.0F * ((GT_MetaGenerated_Tool) aStackRotor.getItem()).getToolCombatDamage(aStackRotor))) * 100); + } + + public int getOptimalAirFlow(ItemStack aStackRotor) { + if (aStackRotor.getItem() instanceof ItemBasicScrubberTurbine) { + return getOptimalAirFlow(getTieredTurbine(aStackRotor.getItemDamage())); + } + return (int) Math.max(Float.MIN_NORMAL, ((GT_MetaGenerated_Tool) aStackRotor.getItem()).getToolStats(aStackRotor).getSpeedMultiplier() + * GT_MetaGenerated_Tool.getPrimaryMaterial(aStackRotor).mToolSpeed * 50); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaCondensor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaCondensor.java new file mode 100644 index 0000000000..0f7edd062d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaCondensor.java @@ -0,0 +1,174 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import net.minecraft.entity.player.InventoryPlayer; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SteamCondenser; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_SteamCondenser; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechMetaBoilerBase; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +public class GregtechMetaCondensor extends GregtechMetaBoilerBase{ + + public GregtechMetaCondensor(final int aID, final String aName, final String aNameRegional) + { + super(aID, aName, aNameRegional, "A Steam condenser - [IC2->Steam]", new ITexture[0]); + } + + public GregtechMetaCondensor(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) + { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, "IC2 Steam + Water = Normal Steam.", "Requires no power to run, although it's not very fast.", CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) + { + final ITexture[][][] rTextures = new ITexture[5][17][]; + for (byte i = -1; i < 16; i++){ + rTextures[0][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa))}; + rTextures[1][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; + rTextures[2][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; + rTextures[3][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER) }; + rTextures[4][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE) }; + } + return rTextures; + } + + @Override + public int maxProgresstime() + { + return 1000; + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) + { + return new CONTAINER_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) + { + return new GUI_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png"); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) + { + return new GregtechMetaCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) + { + this.RI = MathUtils.randLong(5L, 30L); + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) + { + if (this.mTemperature <= 5) + { + this.mTemperature = 5; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 10) + { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { + if (i != aBaseMetaTileEntity.getFrontFacing()) + { + final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) + { + final FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) + { + final int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); + } + } + } + } + } + if ((aTick % 10L) == 0L) { + if (this.mTemperature > 5) + { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) + { + this.mHadNoWater = true; + } + else + { + if (this.mHadNoWater) + { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(30L); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += 30; + } else { + this.mSteam = GT_ModHandler.getSteam(30L); + } + } + } + else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && + (this.mSteam.amount > getSteamCapacity())) + { + this.sendSound((byte)1); + this.mSteam.amount = getSteamCapacity() * 3 / 4; + } + /*if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && + (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(IC2.getItemFromBlock(p_150898_0_))))) + { + this.mProcessingEnergy += 1000; + aBaseMetaTileEntity.decrStackSize(2, 1); + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); + }*/ + if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && ((aTick % this.RI) == 0L)) + { + this.mProcessingEnergy -= 40; + this.mTemperature += 2; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } + + @Override + public final int fill(final FluidStack aFluid, final boolean doFill) + { + if ((Utils.isIC2Steam(aFluid)) && (this.mProcessingEnergy < 50)) + { + final int tFilledAmount = Math.min(50, aFluid.amount); + if (doFill) { + this.mProcessingEnergy += tFilledAmount; + } + return tFilledAmount; + } + return super.fill(aFluid, doFill); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java new file mode 100644 index 0000000000..88658c399d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java @@ -0,0 +1,323 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +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_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class GregtechMetaGarbageCollector extends GregtechMetaTileEntity { + + long mLastCleanup = 0; + long mLocalTickVar = 0; + int mFrequency = 5; + + public GregtechMetaGarbageCollector(final String aName, final String aNameRegional, final String aDescription) { + super(991, aName, aNameRegional, 5, 0, aDescription); + } + + public GregtechMetaGarbageCollector(final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 0, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, + "Can request the JVM to perform garbage collection", + "Configurable to run once every 5 minute interval (5-180)", + "This Machine has no recipe", + "Admin Tool, Limit one per world if possible", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3)}; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (mFrequency < 180){ + mFrequency += 5; + } + else { + mFrequency = 5; + } + PlayerUtils.messagePlayer(aPlayer, "Running every "+mFrequency+" minutes."); + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaGarbageCollector(this.mName, this.mDescription, this.mTextures); + } + + @Override public boolean isSimpleMachine() {return true;} + @Override public boolean isElectric() {return false;} + @Override public boolean isValidSlot(final int aIndex) {return false;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return false;} + @Override public boolean isEnetOutput() {return false;} + @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return 0;} + @Override public long maxEUStore() {return 0;} + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return 0;} + @Override public int dechargerSlotCount() {return 0;} + @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} + @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + private void showPollution(final World worldIn, final EntityPlayer playerIn){ + PlayerUtils.messagePlayer(playerIn, "Running every "+mFrequency+" minutes. Owner: "+this.getBaseMetaTileEntity().getOwnerName()); + long aDiff = mLocalTickVar - this.mLastCleanup; + PlayerUtils.messagePlayer(playerIn, "Last run: "+Utils.getSecondsFromMillis(aDiff)+" seconds ago."); + + + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName() + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + mLocalTickVar = System.currentTimeMillis(); + long aDiff = mLocalTickVar - this.mLastCleanup; + if (Utils.getSecondsFromMillis(aDiff) >= (this.mFrequency * 60)) { + CORE.gc(); + this.mLastCleanup = mLocalTickVar; + } + } + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java new file mode 100644 index 0000000000..65217f9e53 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionCreator.java @@ -0,0 +1,382 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +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_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class GregtechMetaPollutionCreator extends GregtechMetaTileEntity { + + int mCurrentPollution; + int mAveragePollution; + int mAveragePollutionArray[] = new int[10]; + private int mArrayPos = 0; + private int mTickTimer = 0; + private int mSecondTimer = 0; + + public GregtechMetaPollutionCreator(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaPollutionCreator(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "A useful debug machine to create pollution.", CORE.GT_Tooltip}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (pollutionMultiplier > 99){ + pollutionMultiplier = 1; + } + else { + pollutionMultiplier++; + } + PlayerUtils.messagePlayer(aPlayer, "Pollution Mutliplier is now "+pollutionMultiplier+"."); + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPollutionCreator(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(final int aIndex) {return true;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isEnetOutput() {return false;} + @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return 0;} + @Override public long maxEUStore() {return 0;} + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return 0;} + @Override public int dechargerSlotCount() {return 0;} + @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} + @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + public int pollutionMultiplier = 1; + + private void showPollution(final World worldIn, final EntityPlayer playerIn){ + if(!PollutionUtils.isPollutionEnabled()){ + PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); + } + else { + addPollution(); + PlayerUtils.messagePlayer(playerIn, "This chunk now contains "+getCurrentChunkPollution()+" pollution."); + //PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" pollution."); + } + } + + private boolean addPollution(){ + PollutionUtils.addPollution(getBaseMetaTileEntity(), 100000*pollutionMultiplier); + return true; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + public int getCurrentChunkPollution(){ + return getCurrentChunkPollution(this.getBaseMetaTileEntity()); + } + + public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity){ + return PollutionUtils.getPollution(aBaseMetaTileEntity); + } + + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName(), + "Current Pollution: "+this.mCurrentPollution, + "Average/10 minutes:"+getAveragePollutionOverLastTen()}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + //int mCurrentPollution; + //int mAveragePollution; + //int mAveragePollutionArray[] = new int[10]; + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); + aNBT.setInteger("mAveragePollution", this.mAveragePollution); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); + this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.mCurrentPollution == 0) { + this.mCurrentPollution = getCurrentChunkPollution(); + } + if (this.mArrayPos < 0 || this.mArrayPos > 9) { + this.mArrayPos = 0; + } + this.mTickTimer = 0; + } + } + + + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + //TickTimer - 20 times a second + this.mTickTimer++; + if (mTickTimer % 20 == 0){ + this.mCurrentPollution = getCurrentChunkPollution(); + } + } + } + + public int getAveragePollutionOverLastTen(){ + int counter = 0; + int total = 0; + + for (int i=0;i<this.mAveragePollutionArray.length;i++){ + if (this.mAveragePollutionArray[i] != 0){ + total += this.mAveragePollutionArray[i]; + counter++; + } + } + int returnValue = 0; + if (total > 0 && counter > 0){ + returnValue = (total/counter); + this.mAveragePollution = returnValue; + } + else { + returnValue = getCurrentChunkPollution(); + } + //Logger.INFO("| DEBUG: "+returnValue +" | ArrayPos:"+this.mArrayPos+" | Counter:"+counter+" | Total:"+total+" |"); + return returnValue; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java new file mode 100644 index 0000000000..69a4f96708 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java @@ -0,0 +1,435 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +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_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { + + int mCurrentPollution; + int mAveragePollution; + int mAveragePollutionArray[] = new int[10]; + private int mArrayPos = 0; + private int mTickTimer = 0; + private int mSecondTimer = 0; + private long mRedstoneLevel = 0; + + public GregtechMetaPollutionDetector(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaPollutionDetector(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Right click to check pollution levels.", + "Configure with screwdriver to set redstone output amount.", + "Does not use power.", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return aSide == aFacing + ? new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) } + : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), + new GT_RenderedTexture(Textures.BlockIcons.VOID) }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + /*@Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + }*/ + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaPollutionDetector(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(final int aIndex) {return true;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isEnetOutput() {return false;} + @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return 0;} + @Override public long maxEUStore() {return 0;} + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return 0;} + @Override public int dechargerSlotCount() {return 0;} + @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} + @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + private void showPollution(final World worldIn, final EntityPlayer playerIn){ + if(!PollutionUtils.isPollutionEnabled()){ + PlayerUtils.messagePlayer(playerIn, "This block is useless, Pollution is disabled."); + } + else { + PlayerUtils.messagePlayer(playerIn, "This chunk contains "+getCurrentChunkPollution()+" pollution."); + PlayerUtils.messagePlayer(playerIn, "Emit Redstone at pollution level: "+this.mRedstoneLevel); + } + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + public int getCurrentChunkPollution(){ + return getCurrentChunkPollution(this.getBaseMetaTileEntity()); + } + + public int getCurrentChunkPollution(IGregTechTileEntity aBaseMetaTileEntity){ + return PollutionUtils.getPollution(aBaseMetaTileEntity); + } + + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName(), + "Current Pollution: "+this.mCurrentPollution, + "Average/10 Sec: "+this.mAveragePollution, + "Emit Redstone at pollution level: "+this.mRedstoneLevel}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + //int mCurrentPollution; + //int mAveragePollution; + //int mAveragePollutionArray[] = new int[10]; + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); + aNBT.setInteger("mAveragePollution", this.mAveragePollution); + aNBT.setLong("mRedstoneLevel", this.mRedstoneLevel); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); + this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + this.mRedstoneLevel = aNBT.getLong("mRedstoneLevel"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + //Only Calc server-side + if (!this.getBaseMetaTileEntity().isServerSide()) { + return; + } + //Emit Redstone + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel){ + for (int i=0;i<6;i++){ + this.getBaseMetaTileEntity().setStrongOutputRedstoneSignal((byte) i, (byte) 16); + } + this.markDirty(); + } + else { + for (int i=0;i<6;i++){ + this.getBaseMetaTileEntity().setStrongOutputRedstoneSignal((byte) i, (byte) 0); + } + this.markDirty(); + } + + //Do Math for stats + if (this.mTickTimer % 20 == 0) { + mCurrentPollution = this.getCurrentChunkPollution(); + if (mArrayPos > mAveragePollutionArray.length-1) { + mArrayPos = 0; + } + mAveragePollutionArray[mArrayPos] = mCurrentPollution; + mAveragePollution = getAveragePollutionOverLastTen(); + mArrayPos++; + } + this.mTickTimer++; + + } + + public int getAveragePollutionOverLastTen(){ + return MathUtils.getIntAverage(mAveragePollutionArray); + + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + + if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { + final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + (2 * (byte) (int) (tCoords[1] * 2.0F)))) { + case 0: + this.mRedstoneLevel -= 5000; + break; + case 1: + this.mRedstoneLevel += 5000; + break; + case 2: + this.mRedstoneLevel -= 50000; + break; + case 3: + this.mRedstoneLevel += 50000; + } + this.markDirty(); + GT_Utility.sendChatToPlayer(aPlayer, "Emit Redstone at Pollution Level: " + this.mRedstoneLevel); + } + + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + public boolean allowGeneralRedstoneOutput() { + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel){ + this.markDirty(); + return true; + } + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, + EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public void onMachineBlockUpdate() { + super.onMachineBlockUpdate(); + } + + @Override + public boolean hasSidedRedstoneOutputBehavior() { + if (this.getCurrentChunkPollution() >= this.mRedstoneLevel){ + this.markDirty(); + return true; + } + return false; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java new file mode 100644 index 0000000000..140f1d9cd5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java @@ -0,0 +1,394 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import static gregtech.api.enums.GT_Values.V; + +import java.util.HashSet; +import java.util.Set; + +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_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.interfaces.IChunkLoader; +import gtPlusPlus.core.chunkloading.GTPP_ChunkManager; +import gtPlusPlus.core.chunkloading.StaticChunkFunctions; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_BasicMachine implements IChunkLoader { + + public GregtechMetaTileEntityChunkLoader(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 2, "Loads " + getMaxChunksToLoadForTier(aTier) + " chunks when powered", 0, 0, "Recycler.png", "", new ITexture[]{}); + } + + public GregtechMetaTileEntityChunkLoader(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 2, aDescription, aTextures, 0, 0, aGUIName, aNEIName); + } + + public static int getMaxChunksToLoadForTier(int aTier) { + if (aTier < 4) { + return 3 * 3; + } + if (aTier < 6) { + return 7 * 7; + } + if (aTier < 8) { + return 15 * 15; + } + else { + return 0; + } + } + + @Override + public String[] getDescription() { + return new String[] { + "Loads " + getMaxChunksToLoadForTier(this.mTier) + " chunks when powered", + "Consumes 2A", + "Behaves Identically to a Railcraft World Anchor", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier])}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_MaragingSteel), new GT_RenderedTexture(TexturesGtBlock.TIERED_MACHINE_HULLS[mTier+1])}; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityChunkLoader(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + private void showPollution(final World worldIn, final EntityPlayer playerIn){ + //PlayerUtils.messagePlayer(playerIn, "Running every "+mFrequency+" minutes. Owner: "+this.getBaseMetaTileEntity().getOwnerName()); + //PlayerUtils.messagePlayer(playerIn, "Last run: "+Utils.getSecondsFromMillis(aDiff)+" seconds ago."); + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + + @Override + public String[] getInfoData() { + return super.getInfoData(); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + // Have we set the Chunk this Tile resides in yet? + if (mCurrentChunk == null) { + int xTile = getBaseMetaTileEntity().getXCoord(); + int zTile = getBaseMetaTileEntity().getZCoord(); + createInitialWorkingChunk(aBaseMetaTileEntity, xTile, zTile); + } + + // Try unload all chunks if fail to meet global chunkloading conditions. + if (StaticChunkFunctions.onPostTick(aBaseMetaTileEntity, aTick)) { + // Can this tile actively chunkload? + if (getChunkLoadingActive()) { + // Consume some power + this.setEUVar(this.getEUVar() - (maxEUInput() * maxAmperesIn())); + + // Do we need to re-request tickets? + if (getDoesWorkChunkNeedReload()) { + // Request ticket for current chunk. + GTPP_ChunkManager.requestChunkLoad((TileEntity)getBaseMetaTileEntity(), mCurrentChunk); + // Request a ticket for each chunk we have mapped out in a spiral pattern. + if (!mLoadedChunks.isEmpty()) { + for (ChunkCoordIntPair Y : mLoadedChunks) { + GTPP_ChunkManager.requestChunkLoad((TileEntity)getBaseMetaTileEntity(), Y); + } + } + setDoesWorkChunkNeedReload(false); + } + + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + StaticChunkFunctions.saveNBTDataForTileEntity(this.getBaseMetaTileEntity(), aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + StaticChunkFunctions.loadNBTDataForTileEntity(this.getBaseMetaTileEntity(), aNBT); + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 2; + } + + @Override + public long maxEUStore() { + return V[mTier] * 256; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + + /* + * Chunkloading Vars + */ + + private long mTicksRemainingForChunkloading = -1; + private ChunkCoordIntPair mCurrentChunk; + private Set<ChunkCoordIntPair> mLoadedChunks = new HashSet<ChunkCoordIntPair>(); + private boolean mRefreshChunkTickets = false; + + @Override + public long getTicksRemaining() { + return -1; + } + + @Override + public void setTicksRemaining(long aTicks) { + mTicksRemainingForChunkloading = aTicks; + } + + @Override + public ChunkCoordIntPair getResidingChunk() { + return mCurrentChunk; + } + + @Override + public void setResidingChunk(ChunkCoordIntPair aCurrentChunk) { + mCurrentChunk = aCurrentChunk; + } + + @Override + public boolean getChunkLoadingActive() { + return this.getEUVar() >= maxEUInput() * maxAmperesIn(); + } + + @Override + public void setChunkLoadingActive(boolean aActive) { + + } + + @Override + public boolean getDoesWorkChunkNeedReload() { + return mRefreshChunkTickets; + } + + @Override + public void setDoesWorkChunkNeedReload(boolean aActive) { + mRefreshChunkTickets = aActive; + } + + @Override + public boolean addChunkToLoadedList(ChunkCoordIntPair aActiveChunk) { + return mLoadedChunks.add(aActiveChunk); + } + + @Override + public boolean removeChunkFromLoadedList(ChunkCoordIntPair aActiveChunk) { + return mLoadedChunks.remove(aActiveChunk); + } + + @Override + public Set<ChunkCoordIntPair> getManagedChunks() { + return mLoadedChunks; + } + + @Override + public void onRemoval() { + StaticChunkFunctions.onRemoval(getBaseMetaTileEntity()); + super.onRemoval(); + } + + public static Set<ChunkCoordIntPair> spiralChunks(final IGregTechTileEntity aBaseMetaTileEntity, int X, int Z) { + World w = aBaseMetaTileEntity.getWorld(); + HashSet<ChunkCoordIntPair> aSet = new HashSet<ChunkCoordIntPair>(); + if (w == null) { + return aSet; + } + Chunk thisChunk = w.getChunkFromBlockCoords(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getZCoord()); + ChunkCoordIntPair aChunkCo = new ChunkCoordIntPair(thisChunk.xPosition, thisChunk.zPosition); + int x,z,dx,dz; + x = z = dx =0; + dz = -1; + int t = Math.max(X,Z); + int maxI = t*t; + for(int i =0; i < maxI; i++){ + if ((-X/2 <= x) && (x <= X/2) && (-Z/2 <= z) && (z <= Z/2)){ + Chunk C = w.getChunkFromChunkCoords(aChunkCo.chunkXPos + x, aChunkCo.chunkZPos + z); + if (C != null) { + aSet.add(new ChunkCoordIntPair(C.xPosition, C.zPosition)); + } + } + if( (x == z) || ((x < 0) && (x == -z)) || ((x > 0) && (x == 1-z))){ + t = dx; + dx = -dz; + dz = t; + } + x += dx; + z += dz; + } + return aSet; + } + + @Override + public int getChunkloaderTier() { + return mTier; + } + + public void createInitialWorkingChunk(IGregTechTileEntity aBaseMetaTileEntity, int aTileX, int aTileZ) { + final int centerX = aTileX >> 4; + final int centerZ = aTileZ >> 4; + addChunkToLoadedList(new ChunkCoordIntPair(centerX, centerZ)); + GTPP_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity.getMetaTileEntity(), getResidingChunk()); + // If this surrounding chunk map for this tile is empty, we spiral out and map chunks to keep loaded. + if (getManagedChunks().isEmpty()) { + int aChunks = GregtechMetaTileEntityChunkLoader.getMaxChunksToLoadForTier(getChunkloaderTier()); + mLoadedChunks.addAll(spiralChunks(aBaseMetaTileEntity, getChunkloaderTier(), getChunkloaderTier())); + } + if (!mLoadedChunks.isEmpty()) { + for (ChunkCoordIntPair Y : mLoadedChunks) { + GTPP_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity.getMetaTileEntity(), Y); + } + } + setDoesWorkChunkNeedReload(false); + } + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java new file mode 100644 index 0000000000..8456f40797 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityThaumcraftResearcher.java @@ -0,0 +1,204 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +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_Utility; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GregtechMetaTileEntityThaumcraftResearcher extends GregtechMetaTileEntity { + + public GregtechMetaTileEntityThaumcraftResearcher(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaTileEntityThaumcraftResearcher(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Generates Thaumcraft research notes, because it's magic."}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Metal_Grate_A)}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Metal_Grate_B)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{getSides(aColor)[0]}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return getFront(aColor); + } + + + public ITexture[] getBackActive(final byte aColor) { + return getBack(aColor); + } + + + public ITexture[] getBottomActive(final byte aColor) { + return getBottom(aColor); + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{getSides(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return getSides(aColor); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityThaumcraftResearcher(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(final int aIndex) {return true;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isEnetOutput() {return false;} + @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getBackFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return 0;} + @Override public long maxEUStore() {return 512000;} + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return 0;} + @Override public int dechargerSlotCount() {return 0;} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public int getCapacity() { + return 128000; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + { + return true; + } + return true; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aSide==this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName(), + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int getSizeInventory() { + return 2; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + //aNBT.setInteger("mCurrentPollution", this.mCurrentPollution); + //aNBT.setInteger("mAveragePollution", this.mAveragePollution); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + //this.mCurrentPollution = aNBT.getInteger("mCurrentPollution"); + //this.mAveragePollution = aNBT.getInteger("mAveragePollution"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_BasicWasher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_BasicWasher.java new file mode 100644 index 0000000000..99b3faa7d4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_BasicWasher.java @@ -0,0 +1,71 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.lib.CORE; +import gregtech.api.util.GTPP_Recipe; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_BasicWasher extends GT_MetaTileEntity_BasicMachine { + + public GregtechMetaTileEntity_BasicWasher(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, + "It's like an automatic Cauldron for washing dusts.", 1, 1, "PotionBrewer.png", "", + new ITexture[]{ + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_ROCK_BREAKER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_ROCK_BREAKER), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_ROCK_BREAKER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_ROCK_BREAKER) + } + ); + } + + public GregtechMetaTileEntity_BasicWasher(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + /*public GregtechMetaTileEntity_BasicWasher(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + }*/ + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, "Grants no byproducts, but it is fast.", CORE.GT_Tooltip}; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_BasicWasher(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (aFluid.getFluid().getName().equals("water")) || (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 8000 * Math.max(1, this.mTier); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java new file mode 100644 index 0000000000..c872e5c912 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java @@ -0,0 +1,666 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import static gregtech.api.enums.GT_Values.E; + +import java.util.HashSet; +import java.util.List; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.slots.SlotChemicalPlantInput; +import gtPlusPlus.xmod.gregtech.api.gui.fluidreactor.Container_FluidReactor; +import gtPlusPlus.xmod.gregtech.api.gui.fluidreactor.GUI_FluidReactor; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class GregtechMetaTileEntity_ChemicalReactor extends GT_MetaTileEntity_BasicMachine { + + public boolean mFluidTransfer_1 = false; + public boolean mFluidTransfer_2 = false; + + public FluidStack[] mInputFluids = new FluidStack[4]; + public FluidStack[] mOutputFluids = new FluidStack[2]; + + public GregtechMetaTileEntity_ChemicalReactor(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, + "For mixing fluids", 4, 4, "ChemicalReactor.png", "", + new ITexture[]{ + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Side_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Side), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Front_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Front), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top_Active), + new GT_RenderedTexture(TexturesGtBlock.Overlay_FluidReactor_Top) + } + ); + } + + public GregtechMetaTileEntity_ChemicalReactor(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + /*public GregtechMetaTileEntity_BasicWasher(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + }*/ + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, "Because why not?", CORE.GT_Tooltip}; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + try { + GregtechMetaTileEntity_ChemicalReactor y = new GregtechMetaTileEntity_ChemicalReactor(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + return y; + } + catch(Throwable t) { + t.printStackTrace(); + } + return null; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + try { + Container_FluidReactor y = new Container_FluidReactor(aPlayerInventory, aBaseMetaTileEntity); + return y; + } + catch(Throwable t) { + t.printStackTrace(); + } + return null; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_FluidReactor(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + this.mGUIName, + GT_Utility.isStringValid(this.mNEIName) + ? this.mNEIName + : (this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "")); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000 * Math.max(1, this.mTier) / 4; + } + + @Override + public int getInputSlot() { + return 3; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return aSide > 1; + } + + @Override + public boolean isLiquidOutput(byte aSide) { + return aSide < 2; + } + + @Override + public int getOutputSlot() { + return super.getOutputSlot(); + } + + @Override + public int getStackDisplaySlot() { + return super.getStackDisplaySlot(); + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return super.canTankBeFilled(); + } + + @Override + public boolean canTankBeEmptied() { + return super.canTankBeEmptied(); + } + + @Override + public FluidStack getDisplayedFluid() { + return super.getDisplayedFluid(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mFluidTransfer_1", mFluidTransfer_1); + aNBT.setBoolean("mFluidTransfer_2", mFluidTransfer_2); + for (int i=0;i<4;i++) { + if (this.mInputFluids[i] != null) { + aNBT.setTag("mInputFluid"+i, this.mInputFluids[i].writeToNBT(new NBTTagCompound())); + } + } + for (int i=0;i<2;i++) { + if (this.mOutputFluids[i] != null) { + aNBT.setTag("mOutputFluid"+i, this.mOutputFluids[i].writeToNBT(new NBTTagCompound())); + } + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluidTransfer_1 = aNBT.getBoolean("mFluidTransfer_1"); + mFluidTransfer_2 = aNBT.getBoolean("mFluidTransfer_2"); + for (int i=0;i<4;i++) { + if (this.mInputFluids[i] == null) { + this.mInputFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mInputFluid"+i)); + } + } + for (int i=0;i<2;i++) { + if (this.mOutputFluids[i] == null) { + this.mOutputFluids[i] = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid"+i)); + } + } + } + + /* + * Custom Fluid Handling - TODO + */ + + public FluidStack getFillableStack() { + return this.mFluid; + } + + public FluidStack setFillableStack(FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + public FluidStack getDrainableStack() { + return this.mFluid; + } + + public FluidStack setDrainableStack(FluidStack aFluid) { + this.mFluid = aFluid; + return this.mFluid; + } + + + + + + + + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // Re-implement basic machine logic from the ground up.= + + if (aBaseMetaTileEntity.isServerSide()) { + this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L; + this.mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3L; + this.doDisplayThings(); + boolean tSucceeded = false; + int i; + if (this.mMaxProgresstime > 0 && (this.mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { + aBaseMetaTileEntity.setActive(true); + if (this.mProgresstime >= 0 && !this.drainEnergyForProcess((long) this.mEUt)) { + if (!this.mStuttering) { + this.stutterProcess(); + if (this.canHaveInsufficientEnergy()) { + this.mProgresstime = -100; + } + + this.mStuttering = true; + } + } else { + if (++this.mProgresstime >= this.mMaxProgresstime) { + for (i = 0; i < this.mOutputItems.length; ++i) { + for (i = 0; i < this.mOutputItems.length && !aBaseMetaTileEntity.addStackToSlot( + this.getOutputSlot() + (i + i) % this.mOutputItems.length, + this.mOutputItems[i]); ++i) { + ; + } + } + + if (this.mOutputFluid != null) { + if (this.getDrainableStack() == null) { + this.setDrainableStack(this.mOutputFluid.copy()); + } else if (this.mOutputFluid.isFluidEqual(this.getDrainableStack())) { + FluidStack var10000 = this.getDrainableStack(); + var10000.amount += this.mOutputFluid.amount; + } + } + + for (i = 0; i < this.mOutputItems.length; ++i) { + this.mOutputItems[i] = null; + } + + this.mOutputFluid = null; + this.mEUt = 0; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + this.mStuttering = false; + tSucceeded = true; + this.endProcess(); + } + + if (this.mProgresstime > 5) { + this.mStuttering = false; + } + } + } else { + aBaseMetaTileEntity.setActive(false); + } + + boolean tRemovedOutputFluid = false; + if (this.doesAutoOutputFluids() && this.getDrainableStack() != null + && aBaseMetaTileEntity.getFrontFacing() != this.mMainFacing && (tSucceeded || aTick % 20L == 0L)) { + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); + if (tTank != null) { + FluidStack tDrained = this.drain(1000, false); + if (tDrained != null) { + int tFilledAmount = tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + if (tFilledAmount > 0) { + tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), + this.drain(tFilledAmount, true), true); + } + } + } + + if (this.getDrainableStack() == null) { + tRemovedOutputFluid = true; + } + } + + int j; + if (this.doesAutoOutput() && !this.isOutputEmpty() + && aBaseMetaTileEntity.getFrontFacing() != this.mMainFacing + && (tSucceeded || this.mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600L == 0L)) { + TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); + j = 0; + + for (byte tCosts = 1; j < this.mOutputItems.length && tCosts > 0 + && aBaseMetaTileEntity.isUniversalEnergyStored(128L); ++j) { + tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, + aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), (List) null, + false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (tCosts > 0) { + aBaseMetaTileEntity.decreaseStoredEnergyUnits((long) tCosts, true); + } + } + } + + if (this.mOutputBlocked != 0) { + if (this.isOutputEmpty()) { + this.mOutputBlocked = 0; + } else { + ++this.mOutputBlocked; + } + } + + if (this.allowToCheckRecipe()) { + if (this.mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() + && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600L == 0L || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) + && this.hasEnoughEnergyToCheckRecipe()) { + if (this.checkRecipe() == 2) { + if (this.mInventory[3] != null && this.mInventory[3].stackSize <= 0) { + this.mInventory[3] = null; + } + + i = this.getInputSlot(); + + for (j = i + this.mInputSlotCount; i < j; ++i) { + if (this.mInventory[i] != null && this.mInventory[i].stackSize <= 0) { + this.mInventory[i] = null; + } + } + + for (i = 0; i < this.mOutputItems.length; ++i) { + this.mOutputItems[i] = GT_Utility.copy(new Object[]{this.mOutputItems[i]}); + if (this.mOutputItems[i] != null && this.mOutputItems[i].stackSize > 64) { + this.mOutputItems[i].stackSize = 64; + } + + this.mOutputItems[i] = GT_OreDictUnificator.get(true, this.mOutputItems[i]); + } + + if (this.mFluid != null && this.mFluid.amount <= 0) { + this.mFluid = null; + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + if (GT_Utility.isDebugItem(this.mInventory[this.dechargerSlotStartIndex()])) { + this.mEUt = this.mMaxProgresstime = 1; + } + + this.startProcess(); + } else { + this.mMaxProgresstime = 0; + + for (i = 0; i < this.mOutputItems.length; ++i) { + this.mOutputItems[i] = null; + } + + this.mOutputFluid = null; + } + } + } else if (!this.mStuttering) { + this.stutterProcess(); + this.mStuttering = true; + } + } + + + + } + + @Override + protected void doDisplayThings() { + // TODO Auto-generated method stub + super.doDisplayThings(); + } + + @Override + protected ItemStack getSpecialSlot() { + // TODO Auto-generated method stub + return super.getSpecialSlot(); + } + + @Override + protected ItemStack getOutputAt(int aIndex) { + // TODO Auto-generated method stub + return super.getOutputAt(aIndex); + } + + @Override + protected ItemStack[] getAllOutputs() { + // TODO Auto-generated method stub + return super.getAllOutputs(); + } + + @Override + protected ItemStack getInputAt(int aIndex) { + // TODO Auto-generated method stub + return super.getInputAt(aIndex); + } + + @Override + protected ItemStack[] getAllInputs() { + // TODO Auto-generated method stub + return super.getAllInputs(); + } + + @Override + protected boolean displaysInputFluid() { + return true; + } + + @Override + protected boolean displaysOutputFluid() { + return true; + } + + @Override + public boolean doesAutoOutput() { + return super.doesAutoOutput(); + } + + @Override + public boolean doesAutoOutputFluids() { + return this.mFluidTransfer_1 && this.mFluidTransfer_2; + } + + @Override + public void startProcess() { + super.startProcess(); + } + + @Override + public void endProcess() { + super.endProcess(); + } + + @Override + public String[] getInfoData() { + return super.getInfoData(); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPullStack(aBaseMetaTileEntity, aIndex, aSide, aStack); + } + + @Override + public int checkRecipe() { + return super.checkRecipe(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + + /* if (aBaseMetaTileEntity != null) { + if (!aBaseMetaTileEntity.getWorld().isRemote) { + itemslots : for (int i=3;i<7;i++) { + ItemStack aStack = aBaseMetaTileEntity.getStackInSlot(i); + if (aStack != null) { + if (FluidContainerRegistry.isContainer(aStack)) { + if (this.isItemValidForSlot(i, aStack)) { + // Add Fluid + FluidStack aContainerFluid = FluidContainerRegistry.getFluidForFilledItem(aStack); + if (aContainerFluid != null) { + fluidslots : for (FluidStack u : mInputFluids) { + if (u != null && u.isFluidEqual(aContainerFluid)) { + if (u.amount <= (this.getCapacity() - aContainerFluid.amount)) { + + // Matching, not full, let's fill, then continue + u.amount += aContainerFluid.amount; + + // Update stack size + if (aStack.stackSize > 1) { + aStack.stackSize--; + } + else { + aStack = null; + } + + // Add Output container + // TODO + + continue itemslots; + } + else { + // Too full + break fluidslots; + } + } + else { + if (u == null ) { + + // Empty, let's fill, then continue + u = aContainerFluid.copy(); + + // Update stack size + if (aStack.stackSize > 1) { + aStack.stackSize--; + } + else { + aStack = null; + } + + // Add Output container + // TODO + + continue itemslots; + + } + else { + // Not empty, doesn't match, check next slot. + continue fluidslots; + } + } + } + + + + } + // Eat Input + + // Add Container to Output + } + } + } + } + } + }*/ + + } + + @Override + public FluidStack getFluid() { + return super.getFluid(); + } + + @Override + public int getFluidAmount() { + return super.getFluidAmount(); + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return super.drain(maxDrain, doDrain); + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + super.setItemNBT(aNBT); + } + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + if (aIndex >= 3 && aIndex <= 6) { + return SlotChemicalPlantInput.isItemValidForChemicalPlantSlot(aStack); + } + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int aSide) { + return super.getAccessibleSlotsFromSide(aSide); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex >= 3 && aIndex <= 6) { + return super.canInsertItem(aIndex, aStack, aSide); + } + return false; + } + + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { + if (aIndex >= 7 && aIndex <= 11) { + return super.canExtractItem(aIndex, aStack, aSide); + } + return false; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + // TODO Auto-generated method stub + return super.canFill(aSide, aFluid); + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + // TODO Auto-generated method stub + return super.canDrain(aSide, aFluid); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + // TODO Auto-generated method stub + return super.getTankInfo(aSide); + } + + @Override + public int fill_default( + ForgeDirection aSide, FluidStack aFluid, boolean doFill + ) { + // TODO Auto-generated method stub + return super.fill_default(aSide, aFluid, doFill); + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + // TODO Auto-generated method stub + return super.fill(aSide, aFluid, doFill); + } + + @Override + public FluidStack drain( + ForgeDirection aSide, FluidStack aFluid, boolean doDrain + ) { + // TODO Auto-generated method stub + return super.drain(aSide, aFluid, doDrain); + } + + @Override + public FluidStack drain( + ForgeDirection aSide, int maxDrain, boolean doDrain + ) { + // TODO Auto-generated method stub + return super.drain(aSide, maxDrain, doDrain); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java new file mode 100644 index 0000000000..2197ce193d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java @@ -0,0 +1,702 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeMachine; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_CompactFusionReactor extends GT_MetaTileEntity_DeluxeMachine { + + private boolean mCanProcessRecipe = false; + private boolean mCharging = false; + private long mChargeConsumed = 0; + + private GT_Recipe mLastRecipe; + private long mEUStore; + private boolean mRunningOnLoad = false; + private boolean mMachine = false; + private int mEfficiency, mEfficiencyIncrease, mEfficiencyMax = 0; + private int mStartUpCheck = 100, mUpdate = 0; + private FluidStack[] mOutputFluids = null; + + public GregtechMetaTileEntity_CompactFusionReactor(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, "It's like a midget Ra.", 1, 1, "PotionBrewer.png", ""); + } + + public GregtechMetaTileEntity_CompactFusionReactor(String aName, int aTier, String aDescription, + ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, "Not Very Fast, but not very big either.", + "Each side pair in/out puts to different slots.", "Top & Bottom Sides are Outputs.", + "Front & Back are Input Plasma 1.", "Sides are Input Plasma 2." }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_CompactFusionReactor(this.mName, this.mTier, this.mDescription, + this.mTextures, this.mGUIName, this.mNEIName); + } + + public int tier() { + return this.mTier; + } + + public int tierOverclock() { + return this.mTier == 6 ? 0 : this.mTier == 7 ? 1 : 2; + } + + private GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + + 1]; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (aFluid.getFluid().getName().contains("plasma")) || (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public void abortProcess() { + super.abortProcess(); + } + + long mFusionPoint = 20000000L; + + @Override + public int checkRecipe() { + Logger.MACHINE_INFO("Recipe Tick 1."); + if (!this.mCanProcessRecipe) { + Logger.MACHINE_INFO("Recipe Tick 1.1 - Cannot Process Recipe."); + if (this.mChargeConsumed < mFusionPoint) { + Logger.MACHINE_INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); + this.mCharging = true; + this.mCanProcessRecipe = false; + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits((mFusionPoint / 100), false)) { + Logger.MACHINE_INFO("Recipe Tick 1.3 - Charging Internal storage. " + (mFusionPoint / 100) + "/" + + mFusionPoint); + mChargeConsumed += (mFusionPoint / 100); + } + } + else { + mChargeConsumed = 0; + this.mCharging = false; + this.mCanProcessRecipe = true; + + } + } + else { + Logger.MACHINE_INFO("Recipe Tick 1.1 - Try to Process Recipe."); + if (checkRecipeMulti()) { + Logger.MACHINE_INFO("Recipe Tick 1.2 - Process Recipe was Successful."); + return 2; + } + } + Logger.MACHINE_INFO("Recipe Tick 2. - Process Recipe failed."); + return 0; + } + + public ArrayList<FluidStack> getStoredFluids() { + ArrayList<FluidStack> mList = new ArrayList<FluidStack>(); + mList.add(this.mFluid); + mList.add(this.mFluid2); + return mList; + } + + public boolean checkRecipeMulti() { + ArrayList<FluidStack> tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; i++) { + for (int j = i + 1; j < tFluidList_sS; j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } + else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } + } + } + } + if (tFluidList.size() > 1) { + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); + GT_Recipe tRecipe = getRecipeList().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, + GT_Values.V[8], tFluids, new ItemStack[] {}); + if (tRecipe == null) { + return false; + } + if ((tRecipe == null && !mRunningOnLoad) || (tRecipe != null && maxEUStore() < tRecipe.mSpecialValue)) { + this.mLastRecipe = null; + Logger.MACHINE_INFO("Just plain bad."); + return false; + } + if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[] {})) { + this.mLastRecipe = tRecipe; + this.mEUt = (this.mLastRecipe.mEUt * overclock(this.mLastRecipe.mSpecialValue)); + this.mMaxProgresstime = this.mLastRecipe.mDuration / overclock(this.mLastRecipe.mSpecialValue); + + this.mEfficiencyIncrease = 10000; + + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + mRunningOnLoad = false; + return true; + } + } + return false; + } + + public int overclock(int mStartEnergy) { + if (tierOverclock() == 1) { + return 1; + } + if (tierOverclock() == 2) { + return mStartEnergy < 160000000 ? 2 : 1; + } + return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean doesAutoOutputFluids() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public long maxAmperesIn() { + return 16L; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public void doExplosion(long aExplosionPower) { + super.doExplosion(aExplosionPower * 2); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + onRunningTickMulti(); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + if (MathUtils.randInt(0, 4) == 4) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), + aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), + (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.4F) - (tRandom.nextFloat() * 0.3F), + aBaseMetaTileEntity.getYCoord() + 0.2f + (tRandom.nextFloat() * 0.1F), + (aBaseMetaTileEntity.getZCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.6F) - (tRandom.nextFloat() * 0.9F), + aBaseMetaTileEntity.getYCoord() + 0.4f + (tRandom.nextFloat() * 0.3F), + (aBaseMetaTileEntity.getZCoord() + 1.8F) - (tRandom.nextFloat() * 2.6F), 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mCanProcessRecipe", this.mCanProcessRecipe); + aNBT.setBoolean("mCharging", this.mCharging); + aNBT.setLong("mChargeConsumed", this.mChargeConsumed); + aNBT.setInteger("mEfficiency", this.mEfficiency); + aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); + aNBT.setInteger("mEfficiencyMax", this.mEfficiencyMax); + aNBT.setInteger("mStartUpCheck", this.mStartUpCheck); + aNBT.setInteger("mUpdate", mUpdate); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setBoolean("mRunningOnLoad", this.mRunningOnLoad); + aNBT.setBoolean("mMachine", this.mMachine); + aNBT.setLong("mEUStore", this.mEUStore); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (mMaxProgresstime > 0) + mRunningOnLoad = true; + this.mCanProcessRecipe = aNBT.getBoolean("mCanProcessRecipe"); + this.mCharging = aNBT.getBoolean("mCharging"); + this.mChargeConsumed = aNBT.getLong("mChargeConsumed"); + this.mEfficiency = aNBT.getInteger("mEfficiency"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyMax = aNBT.getInteger("mEfficiencyMax"); + this.mStartUpCheck = aNBT.getInteger("mStartUpCheck"); + this.mUpdate = aNBT.getInteger("mUpdate"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mRunningOnLoad = aNBT.getBoolean("mRunningOnLoad"); + this.mMachine = aNBT.getBoolean("mMachine"); + this.mEUStore = aNBT.getLong("mEUStore"); + super.loadNBTData(aNBT); + } + + @Override + public String[] getInfoData() { + String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; + float plasmaOut = 0; + String fusionName = ""; + int powerRequired = 0; + if (this.mLastRecipe != null) { + fusionName = this.mLastRecipe.mFluidOutputs[0].getLocalizedName() + " Fusion."; + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; + } + } + + return new String[] { "Fusion Reactor MK " + tier, "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + this.getEUVar() + " / " + maxEUStore(), "Plasma Output: " + plasmaOut + "L/t", + "Current Recipe: " + fusionName }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active) }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue) }; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + // Logger.MACHINE_INFO("1"); + if (mEfficiency < 0) + mEfficiency = 0; + if (mRunningOnLoad) { + Logger.MACHINE_INFO("2"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipeMulti(); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + Logger.MACHINE_INFO("3"); + mMachine = true; + } + if (mStartUpCheck < 0) { + //Logger.MACHINE_INFO("4"); + if (mMachine) { + //Logger.MACHINE_INFO("5"); + + if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore()) { + if (aBaseMetaTileEntity.increaseStoredEnergyUnits(2048 * tierOverclock(), true)) { + //Logger.MACHINE_INFO("5.5 A"); + } + else { + //Logger.MACHINE_INFO("5.5 B"); + } + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + Logger.MACHINE_INFO("6"); + stopMachine(); + this.mLastRecipe = null; + } + if (mMaxProgresstime > 0) { + Logger.MACHINE_INFO("7"); + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) + if (tStack != null) + addOutput(tStack); + mEfficiency = Math.max(0, (mEfficiency + mEfficiencyIncrease)); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) { + + } + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) + checkRecipeMulti(); + } + } + else { + //Logger.MACHINE_INFO("8"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity.hasInventoryBeenModified()) { + Logger.MACHINE_INFO("9"); + // turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + Logger.MACHINE_INFO("10"); + if (checkRecipeMulti()) { + Logger.MACHINE_INFO("11"); + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + Logger.MACHINE_INFO("12"); + mMaxProgresstime = 0; + // turnCasingActive(false); + } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); + } + } + if (mMaxProgresstime <= 0) + mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } + else { + // turnCasingActive(false); + Logger.MACHINE_INFO("Bad"); + this.mLastRecipe = null; + stopMachine(); + } + } + Logger.MACHINE_INFO("Good | "+mMaxProgresstime); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean onRunningTickMulti() { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (mEUt < 0) { + if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + this.mLastRecipe = null; + stopMachine(); + Logger.MACHINE_INFO("a1"); + return false; + } + } + if (this.mEUStore <= 0) { + this.mLastRecipe = null; + stopMachine(); + Logger.MACHINE_INFO("a2"); + return false; + } + } + return true; + } + + public boolean drainEnergyInput(long aEU) { + return false; + } + + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) + return false; + FluidStack copiedFluidStack = aLiquid.copy(); + this.mOutputFluid = copiedFluidStack; + return false; + } + + public void stopMachine() { + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + @Override + public boolean isLiquidInput(byte aSide) { + switch (aSide) { + case 0: + return true; + case 1: + return true; + case 2: + return true; + case 3: + return false; + case 4: + return false; + case 5: + return false; + default: + return false; + } + } + + @Override + public boolean isLiquidOutput(byte aSide) { + switch (aSide) { + case 0: + return false; + case 1: + return false; + case 2: + return false; + case 3: + return true; + case 4: + return true; + case 5: + return true; + default: + return true; + } + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return super.drain(maxDrain, doDrain); + } + + @Override + public int getTankPressure() { + return 500; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return false; + } + else { + return super.canFill(aSide, aFluid); + } + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.canDrain(aSide, aFluid); + } + else { + return false; + } + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return 0; + } + else { + return super.fill_default(aSide, aFluid, doFill); + } + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.fill(aSide, aFluid, doFill); + } + else { + return 0; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, aFluid, doDrain); + } + else { + return null; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, maxDrain, doDrain); + } + else { + return null; + } + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, + float aY, float aZ) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + // TODO Auto-generated method stub + return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + // TODO Auto-generated method stub + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + return false; + } + + @Override + public void onExplosion() { + // TODO Auto-generated method stub + super.onExplosion(); + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(212)), 10, 1.0F, aX, aY, + aZ); + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java new file mode 100644 index 0000000000..6cae58ced2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java @@ -0,0 +1,704 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeMachine; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_PocketFusion extends GT_MetaTileEntity_DeluxeMachine { + + private boolean mCanProcessRecipe = false; + private boolean mCharging = false; + private long mChargeConsumed = 0; + + private GT_Recipe mLastRecipe; + private long mEUStore; + private boolean mRunningOnLoad = false; + private boolean mMachine = false; + private int mEfficiency, mEfficiencyIncrease, mEfficiencyMax = 0; + private int mStartUpCheck = 100, mUpdate = 0; + private FluidStack[] mOutputFluids = null; + + public GregtechMetaTileEntity_PocketFusion(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, "It's like a midget Ra.", 1, 1, "PotionBrewer.png", ""); + } + + public GregtechMetaTileEntity_PocketFusion(String aName, int aTier, String aDescription, + ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, "Not Very Fast, but not very big either.", + "Each side pair in/out puts to different slots.", "Top & Bottom Sides are Outputs.", + "Front & Back are Input Plasma 1.", "Sides are Input Plasma 2.", CORE.GT_Tooltip }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_PocketFusion(this.mName, this.mTier, this.mDescription, + this.mTextures, this.mGUIName, this.mNEIName); + } + + public int tier() { + return this.mTier; + } + + public int tierOverclock() { + return this.mTier == 6 ? 0 : this.mTier == 7 ? 1 : 2; + } + + private GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + + 1]; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (aFluid.getFluid().getName().contains("plasma")) || (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public void abortProcess() { + super.abortProcess(); + } + + long mFusionPoint = 20000000L; + + @Override + public int checkRecipe() { + Logger.MACHINE_INFO("Recipe Tick 1."); + if (!this.mCanProcessRecipe) { + Logger.MACHINE_INFO("Recipe Tick 1.1 - Cannot Process Recipe."); + if (this.mChargeConsumed < mFusionPoint) { + Logger.MACHINE_INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); + this.mCharging = true; + this.mCanProcessRecipe = false; + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits((mFusionPoint / 100), false)) { + Logger.MACHINE_INFO("Recipe Tick 1.3 - Charging Internal storage. " + (mFusionPoint / 100) + "/" + + mFusionPoint); + mChargeConsumed += (mFusionPoint / 100); + } + } + else { + mChargeConsumed = 0; + this.mCharging = false; + this.mCanProcessRecipe = true; + + } + } + else { + Logger.MACHINE_INFO("Recipe Tick 1.1 - Try to Process Recipe."); + if (checkRecipeMulti()) { + Logger.MACHINE_INFO("Recipe Tick 1.2 - Process Recipe was Successful."); + return 2; + } + } + Logger.MACHINE_INFO("Recipe Tick 2. - Process Recipe failed."); + return 0; + } + + public ArrayList<FluidStack> getStoredFluids() { + ArrayList<FluidStack> mList = new ArrayList<FluidStack>(); + mList.add(this.mFluid); + mList.add(this.mFluid2); + return mList; + } + + public boolean checkRecipeMulti() { + ArrayList<FluidStack> tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; i++) { + for (int j = i + 1; j < tFluidList_sS; j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } + else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } + } + } + } + if (tFluidList.size() > 1) { + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); + GT_Recipe tRecipe = getRecipeList().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, + GT_Values.V[8], tFluids, new ItemStack[] {}); + + if (tRecipe == null) { + return false; + } + + if ((tRecipe == null && !mRunningOnLoad) || (tRecipe != null && maxEUStore() < tRecipe.mSpecialValue)) { + this.mLastRecipe = null; + Logger.MACHINE_INFO("Just plain bad."); + return false; + } + if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[] {})) { + this.mLastRecipe = tRecipe; + this.mEUt = (this.mLastRecipe.mEUt * overclock(this.mLastRecipe.mSpecialValue)); + this.mMaxProgresstime = this.mLastRecipe.mDuration / overclock(this.mLastRecipe.mSpecialValue); + + this.mEfficiencyIncrease = 10000; + + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + mRunningOnLoad = false; + return true; + } + } + return false; + } + + public int overclock(int mStartEnergy) { + if (tierOverclock() == 1) { + return 1; + } + if (tierOverclock() == 2) { + return mStartEnergy < 160000000 ? 2 : 1; + } + return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean doesAutoOutputFluids() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public long maxAmperesIn() { + return 16L; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public void doExplosion(long aExplosionPower) { + super.doExplosion(aExplosionPower * 2); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + onRunningTickMulti(); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + if (MathUtils.randInt(0, 4) == 4) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), + aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), + (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.4F) - (tRandom.nextFloat() * 0.3F), + aBaseMetaTileEntity.getYCoord() + 0.2f + (tRandom.nextFloat() * 0.1F), + (aBaseMetaTileEntity.getZCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.6F) - (tRandom.nextFloat() * 0.9F), + aBaseMetaTileEntity.getYCoord() + 0.4f + (tRandom.nextFloat() * 0.3F), + (aBaseMetaTileEntity.getZCoord() + 1.8F) - (tRandom.nextFloat() * 2.6F), 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mCanProcessRecipe", this.mCanProcessRecipe); + aNBT.setBoolean("mCharging", this.mCharging); + aNBT.setLong("mChargeConsumed", this.mChargeConsumed); + aNBT.setInteger("mEfficiency", this.mEfficiency); + aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); + aNBT.setInteger("mEfficiencyMax", this.mEfficiencyMax); + aNBT.setInteger("mStartUpCheck", this.mStartUpCheck); + aNBT.setInteger("mUpdate", mUpdate); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setBoolean("mRunningOnLoad", this.mRunningOnLoad); + aNBT.setBoolean("mMachine", this.mMachine); + aNBT.setLong("mEUStore", this.mEUStore); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (mMaxProgresstime > 0) + mRunningOnLoad = true; + this.mCanProcessRecipe = aNBT.getBoolean("mCanProcessRecipe"); + this.mCharging = aNBT.getBoolean("mCharging"); + this.mChargeConsumed = aNBT.getLong("mChargeConsumed"); + this.mEfficiency = aNBT.getInteger("mEfficiency"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyMax = aNBT.getInteger("mEfficiencyMax"); + this.mStartUpCheck = aNBT.getInteger("mStartUpCheck"); + this.mUpdate = aNBT.getInteger("mUpdate"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mRunningOnLoad = aNBT.getBoolean("mRunningOnLoad"); + this.mMachine = aNBT.getBoolean("mMachine"); + this.mEUStore = aNBT.getLong("mEUStore"); + super.loadNBTData(aNBT); + } + + @Override + public String[] getInfoData() { + String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; + float plasmaOut = 0; + String fusionName = ""; + int powerRequired = 0; + if (this.mLastRecipe != null) { + fusionName = this.mLastRecipe.mFluidOutputs[0].getLocalizedName() + " Fusion."; + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; + } + } + + return new String[] { "Fusion Reactor MK " + tier, "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + this.getEUVar() + " / " + maxEUStore(), "Plasma Output: " + plasmaOut + "L/t", + "Current Recipe: " + fusionName }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active) }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue) }; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + // Logger.MACHINE_INFO("1"); + if (mEfficiency < 0) + mEfficiency = 0; + if (mRunningOnLoad) { + Logger.MACHINE_INFO("2"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipeMulti(); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + Logger.MACHINE_INFO("3"); + mMachine = true; + } + if (mStartUpCheck < 0) { + //Logger.MACHINE_INFO("4"); + if (mMachine) { + //Logger.MACHINE_INFO("5"); + + if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore()) { + if (aBaseMetaTileEntity.increaseStoredEnergyUnits(2048 * tierOverclock(), true)) { + //Logger.MACHINE_INFO("5.5 A"); + } + else { + //Logger.MACHINE_INFO("5.5 B"); + } + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + Logger.MACHINE_INFO("6"); + stopMachine(); + this.mLastRecipe = null; + } + if (mMaxProgresstime > 0) { + Logger.MACHINE_INFO("7"); + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) + if (tStack != null) + addOutput(tStack); + mEfficiency = Math.max(0, (mEfficiency + mEfficiencyIncrease)); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) { + + } + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) + checkRecipeMulti(); + } + } + else { + //Logger.MACHINE_INFO("8"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity.hasInventoryBeenModified()) { + Logger.MACHINE_INFO("9"); + // turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + Logger.MACHINE_INFO("10"); + if (checkRecipeMulti()) { + Logger.MACHINE_INFO("11"); + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + Logger.MACHINE_INFO("12"); + mMaxProgresstime = 0; + // turnCasingActive(false); + } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); + } + } + if (mMaxProgresstime <= 0) + mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } + else { + // turnCasingActive(false); + Logger.MACHINE_INFO("Bad"); + this.mLastRecipe = null; + stopMachine(); + } + } + Logger.MACHINE_INFO("Good | "+mMaxProgresstime); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean onRunningTickMulti() { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (mEUt < 0) { + if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + this.mLastRecipe = null; + stopMachine(); + Logger.MACHINE_INFO("a1"); + return false; + } + } + if (this.mEUStore <= 0) { + this.mLastRecipe = null; + stopMachine(); + Logger.MACHINE_INFO("a2"); + return false; + } + } + return true; + } + + public boolean drainEnergyInput(long aEU) { + return false; + } + + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) + return false; + FluidStack copiedFluidStack = aLiquid.copy(); + this.mOutputFluid = copiedFluidStack; + return false; + } + + public void stopMachine() { + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + @Override + public boolean isLiquidInput(byte aSide) { + switch (aSide) { + case 0: + return true; + case 1: + return true; + case 2: + return true; + case 3: + return false; + case 4: + return false; + case 5: + return false; + default: + return false; + } + } + + @Override + public boolean isLiquidOutput(byte aSide) { + switch (aSide) { + case 0: + return false; + case 1: + return false; + case 2: + return false; + case 3: + return true; + case 4: + return true; + case 5: + return true; + default: + return true; + } + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return super.drain(maxDrain, doDrain); + } + + @Override + public int getTankPressure() { + return 500; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return false; + } + else { + return super.canFill(aSide, aFluid); + } + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.canDrain(aSide, aFluid); + } + else { + return false; + } + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return 0; + } + else { + return super.fill_default(aSide, aFluid, doFill); + } + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.fill(aSide, aFluid, doFill); + } + else { + return 0; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, aFluid, doDrain); + } + else { + return null; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, maxDrain, doDrain); + } + else { + return null; + } + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, + float aY, float aZ) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + // TODO Auto-generated method stub + return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + // TODO Auto-generated method stub + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + return false; + } + + @Override + public void onExplosion() { + // TODO Auto-generated method stub + super.onExplosion(); + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(212)), 10, 1.0F, aX, aY, + aZ); + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorColdTrap.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorColdTrap.java new file mode 100644 index 0000000000..85e2df42c9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorColdTrap.java @@ -0,0 +1,67 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_ReactorColdTrap extends GT_MetaTileEntity_BasicMachine { + + public GregtechMetaTileEntity_ReactorColdTrap(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, + "Just like the Arctic", 2, 9, "Dehydrator.png", "", + new ITexture[]{ + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_SIDE_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_SIDE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_FRONT_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_FRONT), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_COLDTRAP_TOP) + } + ); + } + + public GregtechMetaTileEntity_ReactorColdTrap(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, "Does not require ice cubes", CORE.GT_Tooltip}; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_ReactorColdTrap(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sColdTrapRecipes; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return super.isFluidInputAllowed(aFluid); + } + + @Override + public int getCapacity() { + return 16000 * Math.max(1, this.mTier); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorProcessingUnit.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorProcessingUnit.java new file mode 100644 index 0000000000..60e2ec8c0a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ReactorProcessingUnit.java @@ -0,0 +1,67 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_ReactorProcessingUnit extends GT_MetaTileEntity_BasicMachine { + + public GregtechMetaTileEntity_ReactorProcessingUnit(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, + "Processes Nuclear things", 2, 9, "Dehydrator.png", "", + new ITexture[]{ + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_SIDE_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_SIDE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_FRONT_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_FRONT), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP_ACTIVE), + new GT_RenderedTexture(TexturesGtBlock.OVERLAY_REACTOR_PROCESSINGUNIT_TOP) + } + ); + } + + public GregtechMetaTileEntity_ReactorProcessingUnit(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, CORE.GT_Tooltip}; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_ReactorProcessingUnit(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return GTPP_Recipe.GTPP_Recipe_Map.sReactorProcessingUnitRecipes; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (getRecipeList().containsInput(aStack)); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return super.isFluidInputAllowed(aFluid); + } + + @Override + public int getCapacity() { + return 8000 * Math.max(1, this.mTier); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java new file mode 100644 index 0000000000..ffaa77a0be --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -0,0 +1,560 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.enums.GT_Values; +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_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; + +public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { + + private boolean mHasBeenMapped = false; + private int mCurrentDimension = 0; + public int mMode = 0; + + public GregtechMetaWirelessCharger(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaWirelessCharger(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, + "3 Modes, Long-Range, Local and Mixed.", + "Long-Range: Can supply 2A of power to a single player up to "+(GT_Values.V[this.mTier]*4)+"m away.", + "Local: Can supply several Amps to each player within "+this.mTier*20+"m.", + "Mixed: Provides both 2A of long range and 1A per player locally.", + "Mixed mode is more conservative of power and as a result only", + "Gets half the distances each singular mode gets.", + CORE.GT_Tooltip + }; + } + + public int getTier(){ + return this.mTier; + } + + public int getMode(){ + return this.mMode; + } + + public int getDimensionID(){ + return this.mCurrentDimension; + } + + public Map<UUID, EntityPlayer> getLocalMap(){ + return this.mLocalChargingMap; + } + + public Map<EntityPlayer, UUID> getLongRangeMap(){ + return this.mWirelessChargingMap; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + + if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()){ + for (Object mTempPlayer : this.getBaseMetaTileEntity().getWorld().playerEntities){ + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + + if (this.mMode >= 2){ + this.mMode = 0; + } + else { + this.mMode++; + } + if (this.mMode == 0){ + PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Charge Mode."); + } + else if (this.mMode == 1){ + PlayerUtils.messagePlayer(aPlayer, "Now in Local Charge Mode."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Now in Mixed Charge Mode."); + } + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaWirelessCharger(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(final int aIndex) {return true;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isEnetOutput() {return false;} + @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return 0;} + @Override public long maxEUStore() {return GT_Values.V[this.mTier]*128;} + + @Override + public int getCapacity() { + return (int) (GT_Values.V[this.mTier]*32); + } + + @Override + public long maxEUInput() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + if (this.mMode == 0){ + return 2; + } + else if (this.mMode == 1){ + return this.mLocalChargingMap.size()*8; + } + else { + return ((this.mLocalChargingMap.size()*4)+this.mWirelessChargingMap.size()); + } + } + + @Override + public long maxAmperesOut() { + return 0; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return 0;} + @Override public int dechargerSlotCount() {return 0;} + @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} + @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + { + return true; + } + return true; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName()}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mMode", this.mMode); + aNBT.setInteger("mCurrentDimension", this.mCurrentDimension); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mMode = aNBT.getInteger("mMode"); + this.mCurrentDimension = aNBT.getInteger("mCurrentDimension"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + + private Map<EntityPlayer, UUID> mWirelessChargingMap = new HashMap<EntityPlayer, UUID>(); + private Map<UUID, EntityPlayer> mLocalChargingMap = new HashMap<UUID, EntityPlayer>(); + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + + if (this.mCurrentDimension != aBaseMetaTileEntity.getWorld().provider.dimensionId){ + this.mCurrentDimension = aBaseMetaTileEntity.getWorld().provider.dimensionId; + } + + if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ + mHasBeenMapped = true; + } + + if (aTick % 20 == 0 && mHasBeenMapped){ + if (!aBaseMetaTileEntity.getWorld().playerEntities.isEmpty()){ + for (Object mTempPlayer : aBaseMetaTileEntity.getWorld().playerEntities){ + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + + if (this.mMode == 1 || this.mMode == 2){ + int tempRange = (this.mMode == 1 ? this.mTier*20 : this.mTier*10); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ + if (!mLocalChargingMap.containsKey(mTemp.getPersistentID())){ + mLocalChargingMap.put(mTemp.getPersistentID(), mTemp); + ChargingHelper.addValidPlayer(mTemp, this); + //PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m - Local]."); + } + } + else { + if (mLocalChargingMap.containsKey(mTemp.getPersistentID())){ + if (mLocalChargingMap.remove(mTemp.getPersistentID()) != null){ + //PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m - Local]."); + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + } + if (this.mMode == 0 || this.mMode == 2){ + int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) <= tempRange){ + if (!mWirelessChargingMap.containsKey(mTemp)){ + if (mTemp.getDisplayName().equalsIgnoreCase(this.getBaseMetaTileEntity().getOwnerName())) { + mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()); + ChargingHelper.addValidPlayer(mTemp, this); + PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m - Long-Range]."); + } + } + } + else { + if (mWirelessChargingMap.containsKey(mTemp)){ + if (mWirelessChargingMap.remove(mTemp) != null){ + PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m - Long Range]."); + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + if (mWirelessChargingMap.containsKey(mTemp) && !mTemp.getDisplayName().equalsIgnoreCase(this.getBaseMetaTileEntity().getOwnerName())){ + if (mWirelessChargingMap.remove(mTemp) != null){ + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + /*if (this.mMode == 0 || this.mMode == 2){ + int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ + if (!mWirelessChargingMap.containsKey(mTemp)){ + mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()); + PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); + ChargingHelper.addValidPlayer(mTemp, this); + } + } + else { + if (mWirelessChargingMap.containsKey(mTemp)){ + if (mWirelessChargingMap.remove(mTemp) != null){ + PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + } */ + + } + } + } + } + + + } + } + + public BlockPos getTileEntityPosition(){ + return new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld()); + } + + public BlockPos getPositionOfEntity(Entity mEntity){ + if (mEntity == null){ + return null; + } + return EntityUtils.findBlockPosUnderEntity(mEntity); + } + + public double getDistanceBetweenTwoPositions(BlockPos objectA, BlockPos objectB){ + if (objectA == null || objectB == null){ + return 0f; + } + int[] objectArray1 = new int[]{objectA.xPos, objectA.yPos, objectA.zPos}; + int[] objectArray2 = new int[]{objectB.xPos, objectB.yPos, objectB.zPos}; + + final double distance = Math.sqrt( + (objectArray2[0]-objectArray1[0])*(objectArray2[0]-objectArray1[0]) + +(objectArray2[1]-objectArray1[1])*(objectArray2[1]-objectArray1[1]) + +(objectArray2[2]-objectArray1[2])*(objectArray2[2]-objectArray1[2])); + return distance; + } + + @Override + public void onRemoval() { + + ChargingHelper.removeEntry(getTileEntityPosition(), this); + + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()){ + for (Object mTempPlayer : this.getBaseMetaTileEntity().getWorld().playerEntities){ + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + ChargingHelper.removeValidPlayer(mTemp, this); + } + } + } + + + super.onRemoval(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, + EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + + int tempRange; + + if (this.mMode == 0 || this.mMode == 2){ + tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); + } + else { + tempRange = this.mMode == 1 ? this.mTier*20 : this.mTier*10; + } + + if (this.mMode == 2){ + PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: "+this.mTier*10+"m | Long: "+tempRange+"m"); + } + else if (this.mMode == 1){ + PlayerUtils.messagePlayer(aPlayer, "Local Mode: "+this.mTier*20+"m"); + + } + else { + PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m"); + + } + + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public void onServerStart() { + mWirelessChargingMap.clear(); + mLocalChargingMap.clear(); + super.onServerStart(); + } + + @Override + public void onExplosion() { + ChargingHelper.removeEntry(getTileEntityPosition(), this); + super.onExplosion(); + } + + @Override + public void doExplosion(long aExplosionPower) { + ChargingHelper.removeEntry(getTileEntityPosition(), this); + super.doExplosion(aExplosionPower); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ + mHasBeenMapped = true; + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java new file mode 100644 index 0000000000..b8f24d6c5e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java @@ -0,0 +1,323 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc; + +import java.util.ArrayList; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.*; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemStackData; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { + + private long mVoltage; + private byte mTier; + private int mCasing; + private IStructureDefinition<GMTE_AmazonPackager> STRUCTURE_DEFINITION = null; + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GMTE_AmazonPackager(mName); + } + + public GMTE_AmazonPackager(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GMTE_AmazonPackager(String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Packager"; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "Generic3By3"; + } + + @Override + public IStructureDefinition<GMTE_AmazonPackager> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GMTE_AmazonPackager>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GMTE_AmazonPackager::addAmazonPackagerList, TAE.getIndexFromPage(2, 9), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings3Misc, 9 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + + + public final boolean addAmazonPackagerList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Amazon Warehouse") + .addInfo("This Multiblock is used for EXTREME packaging requirements") + .addInfo("Dust Schematics are inserted into the input busses") + .addInfo("If inserted into the controller, it is shared across all busses") + .addInfo("1x, 2x, 3x & Other Schematics are to be placed into the controller GUI slot") + .addInfo("Uncomparably fast compared to a single packager of the same tier") + .addInfo("Only uses 75% of the eu/t normally required") + .addInfo("Processes five items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Supply Depot Casings", 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher("GT++"); + return tt; + } + + private final void initFields() { + mVoltage = getMaxInputVoltage(); + mTier = (byte) Math.max(1, GT_Utility.getTier(mVoltage)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 1)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 1))}; + } + + + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes; + } + + public void sortInputBusses() { + for (GT_MetaTileEntity_Hatch_InputBus h : this.mInputBusses) { + h.updateSlots(); + } + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + + //Just the best place to check this~ + initFields(); + + ArrayList<ItemStack> tItems = getStoredInputs(); + if (this.getGUIItemStack() != null) { + tItems.add(this.getGUIItemStack()); + } + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + boolean state = checkRecipeGeneric(tItemInputs, tFluidInputs, 5 * GT_Utility.getTier(this.getMaxInputVoltage()), 75, 500, 10000); + + + if (state) { + return true; + } + else { + tItems = getStoredInputs(); + AutoMap<ItemStackData> mCompleted = new AutoMap<ItemStackData>(); + AutoMap<ItemStackData> mSchematics = new AutoMap<ItemStackData>(); + for (ItemStack tInputItem : tItems) { + if (tInputItem != null) { + if (ItemList.Schematic_1by1.isStackEqual((Object) tInputItem) || ItemList.Schematic_2by2.isStackEqual((Object) tInputItem) || ItemList.Schematic_3by3.isStackEqual((Object) tInputItem)) { + mSchematics.put(new ItemStackData(tInputItem)); + } + } + } + if (mSchematics.size() > 0) { + for (ItemStackData g : mSchematics) { + for (ItemStack tInputItem : tItems) { + if (tInputItem != null) { + mCompleted.put(new ItemStackData(tInputItem)); + checkRecipe(tInputItem, g.getStack()); + } + } + } + } + + return mCompleted != null && mCompleted.size() > 0; + } + } + + public boolean checkRecipe(ItemStack inputStack, ItemStack schematicStack) { + if (GT_Utility.isStackValid((Object) inputStack) && GT_Utility.isStackValid((Object) schematicStack) + && GT_Utility.getContainerItem(inputStack, true) == null) { + ItemStack tOutputStack; + if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack)&& inputStack.stackSize >= 1) { + tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[]{inputStack}); + if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { + final ItemStack input = inputStack; + --input.stackSize; + this.mEUt = 32 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + //this.mMaxProgresstime = 16 / (1 << this.mTier - 1); + this.mMaxProgresstime = 2; + this.addOutput(tOutputStack); + updateSlots(); + return true; + } + return false; + } else if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) + && inputStack.stackSize >= 4) { + tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[]{inputStack, + inputStack, null, inputStack, inputStack}); + if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { + final ItemStack input2 = inputStack; + input2.stackSize -= 4; + this.mEUt = 32 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + //this.mMaxProgresstime = 32 / (1 << this.mTier - 1); + this.mMaxProgresstime = 4; + this.addOutput(tOutputStack); + updateSlots(); + return true; + } + return false; + } else if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) + && inputStack.stackSize >= 9) { + tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[]{inputStack, + inputStack, inputStack, inputStack, inputStack, + inputStack, inputStack, inputStack, inputStack}); + if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { + final ItemStack input3 = inputStack; + input3.stackSize -= 9; + this.mEUt = 32 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + //this.mMaxProgresstime = 64 / (1 << this.mTier - 1); + this.mMaxProgresstime = 6; + this.addOutput(tOutputStack); + updateSlots(); + return true; + } + return false; + } + } + return false; + } + + public boolean allowPutStack(final ItemStack aStack, ItemStack schematicStack) { + //If Schematic Static is not 1x1, 2x2, 3x3 + if (!ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) && !ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) && !ItemList.Schematic_3by3.isStackEqual((Object) schematicStack)) { + return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack); + } + //Something + if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe((IHasWorldObjectAndCoords) this.getBaseMetaTileEntity(), true, GT_Values.V[this.mTier], + (FluidStack[]) null, new ItemStack[]{GT_Utility.copyAmount(64L, new Object[]{aStack}), schematicStack}) != null) { + return true; + } + //1x1 + if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) + && GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack}) != null) { + return true; + } + //2x2 + if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) + && GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack, aStack, null, aStack, aStack}) != null) { + return true; + } + //3x3 + if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) && GT_ModHandler.getRecipeOutput( + new ItemStack[]{aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack}) != null) { + return true; + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + @Override + public int getMaxEfficiency(ItemStack p0) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack arg0){ + return CORE.ConfigSwitches.pollutionPerSecondMultiPackager; + } + + @Override + public int getMaxParallelRecipes() { + return 9; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java new file mode 100644 index 0000000000..7ddf16b36f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java @@ -0,0 +1,479 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc; + +import static gregtech.api.enums.GT_Values.*; + +import java.util.*; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +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_Energy; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.entity.EntityTeslaTowerLightning; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMTE_TeslaTower extends GregtechMeta_MultiBlockBase { + + private Block casingBlock; + private int casingMeta; + private int frameMeta; + private int casingTextureIndex; + + private ForgeDirection back; + + private int xLoc, yLoc, zLoc; + + protected int mRange; + */ +/** + * Machine Mode, + * {@value false} Attacks all entities, + * {@value true} Only attacks players. + *//* + + protected volatile boolean mMode = false; + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMTE_TeslaTower(mName); + } + + public GregtechMTE_TeslaTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + initFields(); + } + + public GregtechMTE_TeslaTower(String aName) { + super(aName); + initFields(); + } + + @Override + public String getMachineType() { + return "Weaponized Lighting Rod"; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String[] getTooltip() { + String casings = getCasingBlockItem().get(0).getDisplayName(); + return new String[]{ + "Controller Block for the Tesla Defence Tower Mk3200", + "Enemies within "+this.mRange+"m are blasted with a high energy plasma.", + "This uses 5,000,000EU per blast.", + "Can screwdriver to toggle mode between Players and all Entities.", + "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", + "3x1x3 Base of " + casings, + "1x3x1 " + casings + " pillar (Center of base)", + "1x3x1 " + MaterialUtils.getMaterialName(getFrameMaterial()) + " Frame Boxes (Each pillar side and on top)", + "1x Maintenance Hatch (One of base casings)", + "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)"}; + } + + private final void initFields() { + casingBlock = ModBlocks.blockCasings2Misc; + casingMeta = getCasingBlockItem().get(0).getItemDamage(); + int frameId = 4096 + getFrameMaterial().mMetaItemSubID; + frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W; + casingTextureIndex = getCasingTextureIndex(); + mRange = 50; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()), new GT_RenderedTexture(aActive ? gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex())}; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mMode", this.mMode); + aNBT.setInteger("mRange", this.mRange); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mMode = aNBT.getBoolean("mMode"); + this.mRange = aNBT.getInteger("mRange"); + super.loadNBTData(aNBT); + } + + private boolean isEnergyEnough() { + if (this.getEUVar() >= 5000000){ + return true; + } + return false; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + */ +/*if (!isEnergyEnough()) { + this.mProgresstime = 0; + this.mMaxProgresstime = 20; + this.getBaseMetaTileEntity().setActive(false); + stopMachine(); + } + else {*//* +*/ +/* + this.mProgresstime = 1; + this.mMaxProgresstime = 100; + this.getBaseMetaTileEntity().setActive(true);*//* + + //} + return false; + } + + @Override + public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + updateCoordinates(); + //check base layer + for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { + for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { + if (xOff == 0 && zOff == 0) continue; + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); + if (!checkCasingBlock(xOff, 0, zOff) + && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex) + && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex)){ + Logger.INFO("bad block"); + return false; + } + } + } + if(!checkHatches()){ + Logger.INFO("bad Hatches"); + return false; + } + if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()){ + Logger.INFO("bad Voltage"); + return false; + } + //check tower + for (int yOff = 1; yOff < 4; yOff++) { + if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) + || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ) + || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ) + || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1) + || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1) + || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)){ + Logger.INFO("bad frame?"); + return false; + } + } + Logger.INFO("good"); + return true; + } + + private void updateCoordinates() { + casingTextureIndex = getCasingTextureIndex(); + mRange = 50; + xLoc = getBaseMetaTileEntity().getXCoord(); + yLoc = getBaseMetaTileEntity().getYCoord(); + zLoc = getBaseMetaTileEntity().getZCoord(); + back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()); + } + + protected boolean checkCasingBlock(int xOff, int yOff, int zOff) { + Logger.INFO("Looking For Casing."); + return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); + } + //meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation) + protected boolean checkFrameBlock(int xOff, int yOff, int zOff) { + Logger.INFO("Looking For Frame."); + return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); + } + + protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) { + return checkBlockAndMeta(xLoc + xOff, yLoc + yOff, zLoc + zOff, block, meta); + } + + private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) { + Logger.INFO("Found: "+getBaseMetaTileEntity().getBlock(x, y, z).getLocalizedName()+" | Meta: "+getBaseMetaTileEntity().getMetaID(x, y, z)); + Logger.INFO("Expected: "+block.getLocalizedName()+" | Meta: "+meta); + return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta) + && getBaseMetaTileEntity().getBlock(x, y, z) == block; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + protected int getMinTier() { + return 7; + } + + protected boolean checkHatches() { + return !mMaintenanceHatches.isEmpty() && !mEnergyHatches.isEmpty(); + } + + private Map<Pair<Long, Long>, Entity> mInRange = new HashMap<Pair<Long, Long>, Entity>(); + + @SuppressWarnings("unchecked") + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + try { + if (this.getBaseMetaTileEntity().isServerSide()){ + if (this.mEnergyHatches.size() > 0) { + for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches){ + if (isValidMetaTileEntity(tHatch)) { + long mHT = tHatch.getBaseMetaTileEntity().getInputVoltage(); + if (tHatch.getEUVar() >= mHT) { + for (int o=0;o<(tHatch.getEUVar()/mHT);o++){ + //1A + if (this.getEUVar()<(this.maxEUStore()-mHT)){ + tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); + this.setEUVar(this.getEUVar()+mHT); + } + //2A + if (this.getEUVar()<(this.maxEUStore()-mHT)){ + tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); + this.setEUVar(this.getEUVar()+mHT); + } + } + } + } + } + } + + if (aTick % 10 == 0){ + if (this.getEUVar() >= 5000000){ + //Logger.INFO("Can Zap."); + this.getBaseMetaTileEntity().enableWorking(); + this.getBaseMetaTileEntity().setActive(true); + if (this.mProgresstime <= 0){ + this.mProgresstime++; + } + else if (this.mProgresstime >= 100){ + this.mProgresstime = 0; + } + this.mMaxProgresstime = 10000; + } + //Logger.INFO("Allowed to be Working? "+this.getBaseMetaTileEntity().isAllowedToWork()); + //Logger.INFO("Working? "+this.getBaseMetaTileEntity().isActive()); + //Logger.INFO("Has Working just been enabled? "+this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()); + } + + + if (aTick % 20 == 0){ + List<Object> o = aBaseMetaTileEntity.getWorld().loadedEntityList; + //Clean up old entities first + if (this.mInRange.size() > 0){ + for (Entity j : this.mInRange.values()){ + if (((Entity) j).getDistance(this.xLoc, this.yLoc, this.zLoc) > this.mRange){ + mInRange.remove(new Pair<Long, Long>(((Entity) j).getUniqueID().getMostSignificantBits(), ((Entity) j).getUniqueID().getLeastSignificantBits()), (Entity) j); + } + } + } + //Add new entities + if (o.size() > 0){ + for (Object r : o){ + if (r instanceof Entity){ + if (!((Entity) r).getUniqueID().equals(getOwner())){ + if (((Entity) r).isEntityAlive() || r instanceof EntityLiving){ + if (((Entity) r).getDistance(this.xLoc, this.yLoc, this.zLoc) <= this.mRange){ + if (r instanceof EntityItem){ + //Do nothing + } + else { + if (!this.mMode){ + mInRange.put(new Pair<Long, Long>(((Entity) r).getUniqueID().getMostSignificantBits(), ((Entity) r).getUniqueID().getLeastSignificantBits()), (Entity) r); + } + else { + if (r instanceof EntityPlayer){ + mInRange.put(new Pair<Long, Long>(((Entity) r).getUniqueID().getMostSignificantBits(), ((Entity) r).getUniqueID().getLeastSignificantBits()), (Entity) r); + } + } + } + } + } + } + } + } + } + } + } + } + catch (Throwable r){ + + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + try { + if (this.getBaseMetaTileEntity().isServerSide()){ + //Handle Progress Time + if (this.getEUVar() >= 0 && !this.getBaseMetaTileEntity().isAllowedToWork()){ + this.mProgresstime = 20; + this.mMaxProgresstime = 40; + } + else if (this.getEUVar() >= 0 && this.getBaseMetaTileEntity().isAllowedToWork()){ + this.mProgresstime = 20; + this.mMaxProgresstime = 40; + } + + if (aTick % 10 == 0){ + if (this.mInRange.size() > 0){ + if (this.getEUVar() >= 5000000){ + + for (Entity f : mInRange.values()){ + if (f instanceof EntityLiving){ + int j1 = (int) f.posX; + int l1 = (int) f.posY; + int k1 = (int) f.posZ; + World world = aBaseMetaTileEntity.getWorld(); + + if (f.isEntityAlive() && !f.getUniqueID().equals(getOwner())){ + //if (world.canLightningStrikeAt(j1, l1+1, k1)){ + //if (isEnergyEnough() && world.addWeatherEffect(new EntityTeslaTowerLightning(world, (double)j1, (double)l1, (double)k1))){ + if (isEnergyEnough() && world.addWeatherEffect(new EntityTeslaTowerLightning(world, (double)j1, (double)l1, (double)k1, f, getOwner()))){ + if (f == null || f.isDead || !f.isEntityAlive()){ + this.mInRange.remove(new Pair<Long, Long>(f.getUniqueID().getMostSignificantBits(), f.getUniqueID().getLeastSignificantBits())); + } + this.setEUVar(this.getEUVar()-5000000); + } + //} + } + + } + } + } + } + } + } + } + catch (Throwable r){ + + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + + protected GregtechItemList getCasingBlockItem() { + return GregtechItemList.Casing_TeslaTower; + } + + protected Materials getFrameMaterial() { + */ +/*casingBlock = getCasingBlockItem().getBlock(); + casingMeta = getCasingBlockItem().get(0).getItemDamage(); + int frameId = 4096 + getFrameMaterial().mMetaItemSubID; + frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W; + *//* +return Materials.get("TungstenCarbide"); + } + + protected int getCasingTextureIndex() { + return TAE.GTPP_INDEX(30); + } + + public UUID getOwner(){ + return PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public long maxAmperesIn() { + return 32; + } + + @Override + public long maxEUInput() { + return 131072; + } + + @Override + public long maxEUStore() { + return Integer.MAX_VALUE; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mMode = Utils.invertBoolean(mMode); + this.mInRange.clear(); + if (mMode){ + PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Now only targetting players."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Targetting all types of entities."); + } + } + + @Override + public int getMaxParallelRecipes() { + return 0; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java new file mode 100644 index 0000000000..df01d01679 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java @@ -0,0 +1,403 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gtPlusPlus.core.lib.CORE; +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +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 gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_IndustrialAlloySmelter extends GregtechMeta_MultiBlockBase { + + public static int CASING_TEXTURE_ID; + private HeatingCoilLevel mHeatingCapacity; + private int mLevel = 0; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialAlloySmelter> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialAlloySmelter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); + } + + public GregtechMetaTileEntity_IndustrialAlloySmelter(String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 1); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialAlloySmelter(this.mName); + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID), new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiFurnace.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sAlloySmelterRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialAlloySmelter; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Alloy Smelter"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Alloy Smelter") + .addInfo("Gains one parallel per voltage tier") + .addInfo("Gains one multiplier per coil tier") + .addInfo("parallel = tier * coil tier") + .addInfo("Gains 5% speed bonus per coil tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 5, 3, true) + .addController("Bottom center") + .addCasingInfo("Inconel Reinforced Casings", 10) + .addCasingInfo("Integral Encasement V", 8) + .addCasingInfo("Heating Coils", 16) + .addInputBus("Any Inconel Reinforced Casing", 1) + .addOutputBus("Any Inconel Reinforced Casing", 1) + .addEnergyHatch("Any Inconel Reinforced Casing", 1) + .addMaintenanceHatch("Any Inconel Reinforced Casing", 1) + .addMufflerHatch("Any Inconel Reinforced Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialAlloySmelter> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialAlloySmelter>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"VVV", "V-V", "VVV"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialAlloySmelter::addIndustrialAlloySmelterList, CASING_TEXTURE_ID, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings3Misc, 1 + ) + ) + ) + ) + .addElement( + 'H', + ofCoil( + GregtechMetaTileEntity_IndustrialAlloySmelter::setCoilLevel, GregtechMetaTileEntity_IndustrialAlloySmelter::getCoilLevel + ) + ) + .addElement( + 'V', + ofBlock( + ModBlocks.blockCasingsTieredGTPP, 4 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addIndustrialAlloySmelterList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 4, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mLevel = 0; + setCoilLevel(HeatingCoilLevel.None); + return checkPiece(mName, 1, 4, 0) && mCasing >= 10 && getCoilLevel() != HeatingCoilLevel.None && (mLevel = getCoilLevel().getTier() + 1) > 0 && checkHatch(); + } + + @Override + public int getMaxParallelRecipes() { + return (this.mLevel * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + + @Override + public boolean checkRecipe(ItemStack aStack) { + FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList<ItemStack> tInputs = new ArrayList<>(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { + tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + if (tInputs.size() > 1) { + ItemStack[] tItems = tInputs.toArray(new ItemStack[0]); + if (checkRecipeGeneric(tItems, tFluids, getMaxParallelRecipes(), 100, 5 * this.mLevel, 10000)) { + return true; + } + } + } + return false; + } + + @Override + public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, + int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { + // 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(); + Logger.WARNING("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = this.getRecipeMap().findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + Logger.WARNING("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + Logger.WARNING("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + int tHeatCapacityDivTiers = (int) mHeatingCapacity.getHeat() / 900; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + // 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)) { + Logger.WARNING("Broke at " + parallelRecipes + "."); + break; + } + Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + Logger.WARNING("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 = mLevel * 5; + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor); + int rInt = 2; + + this.mEUt = (int) Math.max(Math.ceil(tTotalEUt), 1); + + 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 /= (tHeatCapacityDivTiers >= rInt ? 4 : 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(); + + Logger.WARNING("GOOD RETURN - 1"); + return true; + + } + + public HeatingCoilLevel getCoilLevel() { + return mHeatingCapacity; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + mHeatingCapacity = aCoilLevel; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java new file mode 100644 index 0000000000..eae867d11d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java @@ -0,0 +1,330 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +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.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +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.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; +import net.minecraft.util.EnumChatFormatting; + +public class GregtechMetaTileEntity_IndustrialArcFurnace extends GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_IndustrialArcFurnace> { + + //862 + private static final int mCasingTextureID = TAE.getIndexFromPage(3, 3); + public static String mCasingName = "Tempered Arc Furnace Casing"; + private boolean mPlasmaMode = false; + private int mSize = 0; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialArcFurnace> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialArcFurnace(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 3); + } + + public GregtechMetaTileEntity_IndustrialArcFurnace(final String aName) { + super(aName); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 3); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialArcFurnace(this.mName); + } + + @Override + public String getMachineType() { + return "(Plasma/Electric) Arc Furnace"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 3); + } + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for Industrial Arc Furnace") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Processes 8 items per voltage tier * W/L") + .addInfo("Max Size required to process Plasma recipes") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addController("Top center") + .addStructureInfo("Size: nx3xn [WxHxL] (Hollow)") + .addStructureInfo("n can be 3, 5 or 7") + .addCasingInfo(mCasingName, 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialArcFurnace> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialArcFurnace>builder() + .addShape(mName + "3", new String[][]{ + {"CCC", "C~C", "CCC"}, + {"CCC", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + }) + .addShape(mName + "5", new String[][]{ + {"CCCCC", "CCCCC", "CC~CC", "CCCCC", "CCCCC"}, + {"CCCCC", "C---C", "C---C", "C---C", "CCCCC"}, + {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, + }) + .addShape(mName + "7", new String[][]{ + {"CCCCCCC", "CCCCCCC", "CCCCCCC", "CCC~CCC", "CCCCCCC", "CCCCCCC", "CCCCCCC"}, + {"CCCCCCC", "C-----C", "C-----C", "C-----C", "C-----C", "C-----C", "CCCCCCC"}, + {"CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC"}, + }) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialArcFurnace::addIndustrialArcFurnaceList, mCasingTextureID, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings4Misc, 3 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public void clearHatches() { + mOutputHatches.clear(); + mInputHatches.clear(); + mOutputBusses.clear(); + mInputBusses.clear(); + mEnergyHatches.clear(); + mMaintenanceHatches.clear(); + mMufflerHatches.clear(); + } + + public final boolean addIndustrialArcFurnaceList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + int size; + switch (stackSize.stackSize) { + case 1: size = 3; break; + case 2: size = 5; break; + default: size = 7; break; + } + buildPiece(mName + size, stackSize, hintsOnly, (size - 1) / 2, (size - 1) / 2, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mSize = 0; + if (checkPiece(mName + "3", 1, 1, 0)) { + mSize = 3; + return mCasing >= 10 && checkHatch(); + } + mCasing = 0; + clearHatches(); + if (checkPiece(mName + "5", 2, 2, 0)) { + mSize = 5; + return mCasing >= 10 && checkHatch(); + } + mCasing = 0; + clearHatches(); + if (checkPiece(mName + "7", 3, 3, 0)) { + mSize = 7; + return mCasing >= 10 && checkHatch(); + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(mCasingTextureID), + new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(mCasingTextureID)}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialExtruder"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mPlasmaMode ? GT_Recipe.GT_Recipe_Map.sPlasmaArcFurnaceRecipes : GT_Recipe.GT_Recipe_Map.sArcFurnaceRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return this.checkRecipeGeneric(getMaxParallelRecipes(), 100, 250); + } + + @Override + public int getMaxParallelRecipes() { + return (this.mSize * 8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialArcFurnace; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + + public byte getCasingMeta() { + return 3; + } + + public Block getCasingBlock2() { + return ModBlocks.blockCasings3Misc; + } + + + public byte getCasingMeta2() { + return 15; + } + + public byte getCasingTextureIndex() { + return (byte) mCasingTextureID; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mSize > 5) { + this.mPlasmaMode = Utils.invertBoolean(mPlasmaMode); + if (mPlasmaMode) { + PlayerUtils.messagePlayer(aPlayer, "["+EnumChatFormatting.RED+"MODE"+EnumChatFormatting.RESET+"] "+EnumChatFormatting.LIGHT_PURPLE+"Plasma"+EnumChatFormatting.RESET); + } + else { + PlayerUtils.messagePlayer(aPlayer, "["+EnumChatFormatting.RED+"MODE"+EnumChatFormatting.RESET+"] "+EnumChatFormatting.YELLOW+"Electric"+EnumChatFormatting.RESET); + } + } + else { + PlayerUtils.messagePlayer(aPlayer, "["+EnumChatFormatting.RED+"MODE"+EnumChatFormatting.RESET+"] "+EnumChatFormatting.GRAY+"Cannot change mode, structure not large enough."+EnumChatFormatting.RESET); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mPlasmaMode", mPlasmaMode); + aNBT.setInteger("mSize", mSize); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mPlasmaMode = aNBT.getBoolean("mPlasmaMode"); + mSize = aNBT.getInteger("mSize"); + } + + @Override + public void onMachineBlockUpdate() { + mUpdate = 100; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java new file mode 100644 index 0000000000..8802a7148b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java @@ -0,0 +1,263 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialCentrifuge +extends GregtechMeta_MultiBlockBase { + + private boolean mIsAnimated; + private static ITexture frontFace; + private static ITexture frontFaceActive; + private static CustomIcon GT9_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static CustomIcon GT9_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialCentrifuge> STRUCTURE_DEFINITION = null; + //public static double recipesComplete = 0; + + public GregtechMetaTileEntity_IndustrialCentrifuge(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + frontFaceActive = new GT_RenderedTexture(GT9_5_Active); + frontFace = new GT_RenderedTexture(GT9_5); + mIsAnimated = true; + } + + public GregtechMetaTileEntity_IndustrialCentrifuge(final String aName) { + super(aName); + mIsAnimated = true; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); + } + + @Override + public String getMachineType() { + return "Centrifuge"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Centrifuge") + .addInfo("125% faster than using single block machines of the same voltage") + .addInfo("Disable animations with a screwdriver") + .addInfo("Only uses 90% of the eu/t normally required") + .addInfo("Processes six items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Centrifuge Casings", 10) + .addInputBus("Any Casing except front", 1) + .addOutputBus("Any Casing except front", 1) + .addInputHatch("Any Casing except front", 1) + .addOutputHatch("Any Casing except front", 1) + .addEnergyHatch("Any Casing except front", 1) + .addMaintenanceHatch("Any Casing except front", 1) + .addMufflerHatch("Any Casing except front", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialCentrifuge> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialCentrifuge>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialCentrifuge::addIndustrialCentrifugeList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 0 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + public final boolean addIndustrialCentrifugeList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(0)), aFacing == aSide ? aActive ? getFrontFacingTurbineTexture(aActive) : getFrontFacingTurbineTexture(aActive) : Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(0))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialCentrifuge"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(6* GT_Utility.getTier(this.getMaxInputVoltage()), 90, 125); + } + + @Override + public int getMaxParallelRecipes() { + return (6 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 90; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + public byte getCasingMeta() { + return 0; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(0); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCentrifuge; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + this.mIsAnimated = !mIsAnimated; + Logger.INFO("Is Centrifuge animated "+this.mIsAnimated); + if (this.mIsAnimated) { + PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture. "); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture. "); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mIsAnimated", mIsAnimated); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("mIsAnimated")) { + mIsAnimated = aNBT.getBoolean("mIsAnimated"); + } + else { + mIsAnimated = true; + } + } + + public boolean usingAnimations() { + //Logger.INFO("Is animated? "+this.mIsAnimated); + return this.mIsAnimated; + } + + private ITexture getFrontFacingTurbineTexture(boolean isActive) { + if (usingAnimations()) { + if (isActive) { + return frontFaceActive; + } + } + return frontFace; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java new file mode 100644 index 0000000000..63dd3d62dc --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -0,0 +1,230 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialCokeOven +extends GregtechMeta_MultiBlockBase { + private int mLevel = 0; + private int mCasing; + private int mCasing1; + private int mCasing2; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialCokeOven> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialCokeOven(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialCokeOven(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); + } + + @Override + public String getMachineType() { + return "Coke Oven"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Processes Logs and Coal into Charcoal and Coal Coke.") + .addInfo("Controller Block for the Industrial Coke Oven") + .addInfo("Gain 4% speed bonus per voltage tier increased") + .addInfo("Process 12x materials with Heat Resistant Casings") + .addInfo("Or 24x materials with Heat Proof Casings") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front middle at bottom") + .addCasingInfo("Structural Coke Oven Casings", 8) + .addCasingInfo("Heat Resistant/Proof Coke Oven Casings", 8) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialCokeOven> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialCokeOven>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialCokeOven::addIndustrialCokeOvenList, TAE.GTPP_INDEX(1), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 1 + ) + ) + ) + ) + .addElement( + 'H', + ofChain( + onElementPass( + x -> ++x.mCasing1, + ofBlock( + ModBlocks.blockCasingsMisc, 2 + ) + ), + onElementPass( + x -> ++x.mCasing2, + ofBlock( + ModBlocks.blockCasingsMisc, 3 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 2, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mCasing1 = 0; + mCasing2 = 0; + mLevel = 0; + if (checkPiece(mName, 1, 2, 0)) { + if (mCasing1 == 8) mLevel = 1; + if (mCasing2 == 8) mLevel = 2; + return mLevel > 0 && mCasing >= 8 && checkHatch(); + } + return false; + } + + public final boolean addIndustrialCokeOvenList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(1)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(1))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "CokeOven"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes; + + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + @Override + public int getMaxParallelRecipes() { + return this.mLevel * 12; + } + + @Override + public int getEuDiscountForParallelism() { + return (100-(GT_Utility.getTier(this.getMaxInputVoltage())*4)); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCokeOven; + } + + @Override + public int getAmountOfOutputs() { + return 24; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java new file mode 100644 index 0000000000..bf5f8aaeaf --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -0,0 +1,234 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialCuttingMachine +extends GregtechMeta_MultiBlockBase { + + private boolean mCuttingMode = true; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialCuttingMachine> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialCuttingMachine(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialCuttingMachine(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCuttingMachine(this.mName); + } + + @Override + public String getMachineType() { + return "Cutting Machine / Slicing Machine"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Cutting Factory") + .addInfo("200% faster than using single block machines of the same voltage") + .addInfo("Only uses 75% of the eu/t normally required") + .addInfo("Processes four items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front Center") + .addCasingInfo("Cutting Factory Frames", 26) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialCuttingMachine> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialCuttingMachine>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + {"C~C", "C-C", "C-C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialCuttingMachine::addIndustrialCuttingMachineList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 13 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 26 && checkHatch(); + } + + public final boolean addIndustrialCuttingMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(29)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(29))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialCuttingMachine"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mCuttingMode ? GT_Recipe.GT_Recipe_Map.sCutterRecipes : GT_Recipe.GT_Recipe_Map.sSlicerRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((4* GT_Utility.getTier(this.getMaxInputVoltage())), 75, 200); + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 75; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCuttingMachine; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + + public byte getCasingMeta() { + return 13; + } + + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(29); + } + + @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); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("mCuttingMode")) { + mCuttingMode = aNBT.getBoolean("mCuttingMode"); + } + else { + mCuttingMode = true; + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java new file mode 100644 index 0000000000..44552ea2f7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java @@ -0,0 +1,415 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gtPlusPlus.core.lib.CORE; +import org.apache.commons.lang3.ArrayUtils; + +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.GTPP_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +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.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_IndustrialDehydrator extends GregtechMeta_MultiBlockBase { + + private static int CASING_TEXTURE_ID; + private static String mCasingName = "Vacuum Casing"; + private HeatingCoilLevel mHeatingCapacity; + private boolean mDehydratorMode = false; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialDehydrator> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialDehydrator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 10); + } + + public GregtechMetaTileEntity_IndustrialDehydrator(String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(3, 10); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 10); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialDehydrator(mName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 10); + } + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Vacuum Furnace") + .addInfo("Can toggle the operation temperature with a Screwdriver") + .addInfo("All Dehydrator recipes are Low Temp recipes") + .addInfo("Speed: 120% | Eu Usage: 50% | Parallel: 4") + .addInfo("Each 900K over the min. Heat Capacity grants 5% speedup (multiplicatively)") + .addInfo("Each 1800K over the min. Heat Capacity allows for one upgraded overclock") + .addInfo("Upgraded overclocks reduce recipe time to 25% and increase EU/t to 400%") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, true) + .addController("Bottom Center") + .addCasingInfo(mCasingName, 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialDehydrator> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialDehydrator>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialDehydrator::addIndustrialDehydratorList, CASING_TEXTURE_ID, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings4Misc, 10 + ) + ) + ) + ) + .addElement( + 'H', + ofCoil( + GregtechMetaTileEntity_IndustrialDehydrator::setCoilLevel, GregtechMetaTileEntity_IndustrialDehydrator::getCoilLevel + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 4, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + setCoilLevel(HeatingCoilLevel.None); + return checkPiece(mName, 1, 4, 0) && mCasing >= 10 && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); + } + + public final boolean addIndustrialDehydratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID), + new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active + : TexturesGtBlock.Overlay_Machine_Controller_Advanced) }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID) }; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mDehydratorMode ? GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes : GTPP_Recipe.GTPP_Recipe_Map.sVacuumFurnaceRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialDehydrator; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getMachineType() { + return "Vacuum Furnace / Dehydrator"; + } + + @Override + public int getMaxParallelRecipes() { + return 4; + } + + @Override + public int getEuDiscountForParallelism() { + return 50; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ElectricBlastFurnace"; + } + + public boolean checkRecipe(ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 120); + } + + @Override + public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, + int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { + // 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(); + Logger.WARNING("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = this.getRecipeMap().findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + Logger.WARNING("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null || this.mHeatingCapacity.getHeat() < tRecipe.mSpecialValue) { + Logger.WARNING("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + int tHeatCapacityDivTiers = (int) (mHeatingCapacity.getHeat() - tRecipe.mSpecialValue) / 900; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + // 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)) { + Logger.WARNING("Broke at " + parallelRecipes + "."); + break; + } + Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + Logger.WARNING("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); + int rInt = 2; + + 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 /= (tHeatCapacityDivTiers >= rInt ? 4 : 2); + } + } + + if (tHeatCapacityDivTiers > 0) { + this.mEUt = (int) (this.mEUt * (Math.pow(0.95, tHeatCapacityDivTiers))); + } + 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(); + + Logger.WARNING("GOOD RETURN - 1"); + return true; + + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mDehydratorMode = Utils.invertBoolean(mDehydratorMode); + String aMode = mDehydratorMode ? "Dehydrator" : "Vacuum Furnace"; + PlayerUtils.messagePlayer(aPlayer, "Mode: "+aMode); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mDehydratorMode", mDehydratorMode); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mDehydratorMode = aNBT.getBoolean("mDehydratorMode"); + } + + public HeatingCoilLevel getCoilLevel() { + return mHeatingCapacity; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + mHeatingCapacity = aCoilLevel; + } +} + + diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java new file mode 100644 index 0000000000..f6613980ca --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java @@ -0,0 +1,193 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialElectrolyzer +extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialElectrolyzer> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialElectrolyzer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialElectrolyzer(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); + } + + @Override + public String getMachineType() { + return "Electrolyzer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Electrolyzer") + .addInfo("180% faster than using single block machines of the same voltage") + .addInfo("Only uses 90% of the eu/t normally required") + .addInfo("Processes two items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Electrolyzer Casings", 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialElectrolyzer> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialElectrolyzer>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialElectrolyzer::addIndustrialElectrolyzerList, TAE.GTPP_INDEX(5), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 5 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + public final boolean addIndustrialElectrolyzerList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(5)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(5))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialElectrolyzer"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(2* GT_Utility.getTier(this.getMaxInputVoltage()), 90, 180); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialElectrolyzer; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 2* GT_Utility.getTier(this.getMaxInputVoltage()); + } + + @Override + public int getEuDiscountForParallelism() { + return 90; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java new file mode 100644 index 0000000000..a5c7f62578 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java @@ -0,0 +1,260 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import java.util.ArrayList; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialExtruder +extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialExtruder> STRUCTURE_DEFINITION = null; + + + public GregtechMetaTileEntity_IndustrialExtruder(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialExtruder(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialExtruder(this.mName); + } + + @Override + public String getMachineType() { + return "Extruder"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Material Extruder") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Processes four items per voltage tier") + .addInfo("Extrusion Shape for recipe goes in the Input Bus") + .addInfo("Each Input Bus can have a different shape!") + .addInfo("You can use several input buses per multiblock") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front Center") + .addCasingInfo("Inconel Reinforced Casings", 28) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Back Center", 2) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialExtruder> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialExtruder>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + {"C~C", "C-C", "C-C", "C-C", "CMC"}, + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialExtruder::addIndustrialExtruderList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + getCasingBlock(), getCasingMeta() + ) + ) + ) + ) + .addElement( + 'M', + ofHatchAdder( + GregtechMetaTileEntity_IndustrialExtruder::addIndustrialExtruderMufflerList, getCasingTextureIndex(), 2 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 28 && checkHatch(); + } + + public final boolean addIndustrialExtruderList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addIndustrialExtruderMufflerList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(203)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(33)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(33))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialExtruder"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sExtruderRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); + tBus.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + ItemStack[] inputs = new ItemStack[tBusItems.size()]; + int slot = 0; + for (ItemStack g : tBusItems) { + inputs[slot++] = g; + } + if (inputs.length > 0) { + int para = (4* GT_Utility.getTier(this.getMaxInputVoltage())); + log("Recipe. ["+inputs.length+"]["+para+"]"); + if (checkRecipeGeneric(inputs, new FluidStack[]{}, para, 100, 250, 10000)) { + log("Recipe 2."); + return true; + } + } + + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialExtruder; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings3Misc; + } + + public byte getCasingMeta() { + return 1; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(33); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java new file mode 100644 index 0000000000..b6e072b653 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java @@ -0,0 +1,259 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import java.util.Random; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialMacerator +extends GregtechMeta_MultiBlockBase { + private int mCasing; + private int mPerLayer; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialMacerator> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialMacerator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialMacerator(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMacerator(this.mName); + } + + @Override + public String getMachineType() { + return "Macerator/Pulverizer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Maceration Stack") + .addInfo("60% faster than using single block machines of the same voltage") + .addInfo("Processes 8*tier materials at a time") + .addInfo("ULV = Tier 0, LV = Tier 1, etc.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 6, 3, true) + .addController("Bottom Center") + .addCasingInfo("Maceration Stack Casings", 26) + .addInputBus("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .addOutputBus("One per layer except bottom layer", 2) + .addMufflerHatch("Any Casing", 2) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialMacerator> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialMacerator>builder() + .addShape(mName + "top", transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + })) + .addShape(mName + "mid", transpose(new String[][]{ + {"CCC", "C-C", "CCC"}, + })) + .addShape(mName + "bottom", transpose(new String[][]{ + {"B~B", "BBB", "BBB"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialMacerator::addIndustrialMaceratorMidList, TAE.GTPP_INDEX(7), 2 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 7 + ) + ) + ) + ) + .addElement( + 'B', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialMacerator::addIndustrialMaceratorBottomList, TAE.GTPP_INDEX(7), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 7 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName + "bottom", stackSize, hintsOnly, 1, 0, 0); + buildPiece(mName + "mid", stackSize, hintsOnly, 1, 1, 0); + buildPiece(mName + "mid", stackSize, hintsOnly, 1, 2, 0); + buildPiece(mName + "mid", stackSize, hintsOnly, 1, 3, 0); + buildPiece(mName + "mid", stackSize, hintsOnly, 1, 4, 0); + buildPiece(mName + "top", stackSize, hintsOnly, 1, 5, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mPerLayer = 0; + if (checkPiece(mName + "bottom", 1, 0 ,0)) { + while (mPerLayer < 4) { + if (!checkPiece(mName + "mid", 1, mPerLayer + 1, 0) || + mPerLayer + 1 != mOutputBusses.size()) return false; + mPerLayer ++; + } + return checkPiece(mName + "top", 1, 5, 0) && mOutputBusses.size() == 5 && mCasing >= 26 && checkHatch(); + } + return false; + } + + public final boolean addIndustrialMaceratorBottomList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addIndustrialMaceratorMidList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(201)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(7)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_MatterFab_Active : TexturesGtBlock.Overlay_MatterFab)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(7))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MacerationStack"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + } + + @Override + public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld().spawnParticle("smoke", (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), 0.0D, 0.0D, 0.0D); + } + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 60, 7500); + } + + @Override + protected boolean doesMachineBoostOutput() { + return true; + } + + @Override + public int getMaxParallelRecipes() { + final long tVoltage = getMaxInputVoltage(); + final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + return Math.max(1, 8 * tTier); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMacerator; + } + + @Override + public int getAmountOfOutputs() { + return 16; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java new file mode 100644 index 0000000000..5e405d426d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java @@ -0,0 +1,257 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import java.util.ArrayList; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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 net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialMixer +extends GregtechMeta_MultiBlockBase { + + public static int CASING_TEXTURE_ID; + public static String mCasingName = "Advanced Blast Furnace Casing"; + public static String mCasingName2 = "Advanced Blast Furnace Casing"; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialMixer> STRUCTURE_DEFINITION = null; + + + public GregtechMetaTileEntity_IndustrialMixer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 2); + mCasingName2 = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockCasings4, 11); + } + + public GregtechMetaTileEntity_IndustrialMixer(final String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 2); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 2); + mCasingName2 = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockCasings4, 11); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMixer(this.mName); + } + + @Override + public String getMachineType() { + return "Mixer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 2); + } + if (mCasingName2.toLowerCase().contains(".name")) { + mCasingName2 = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockCasings4, 11); + } + + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Mixer") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Processes eight recipes per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, false) + .addController("Second Layer Center") + .addCasingInfo(mCasingName, 16) + .addCasingInfo(mCasingName2, 2) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialMixer> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialMixer>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"CCC", "CMC", "CCC"}, + {"C~C", "CMC", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialMixer::addIndustrialMixerList, CASING_TEXTURE_ID, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings3Misc, 2 + ) + ) + ) + ) + .addElement( + 'M', + ofBlock( + GregTech_API.sBlockCasings4, 11 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 2, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 2, 0) && mCasing >= 16 && checkHatch(); + } + + public final boolean addIndustrialMixerList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(203)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialMixer"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map.sMultiblockMixerRecipes_GT; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); + tBus.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + ItemStack[] inputs = new ItemStack[tBusItems.size()]; + int slot = 0; + for (ItemStack g : tBusItems) { + inputs[slot++] = g; + } + if (inputs.length > 0) { + log("Recipe. ["+inputs.length+"]["+getMaxParallelRecipes()+"]"); + FluidStack[] fluid = this.getStoredFluids().toArray(new FluidStack[] {}); + if (checkRecipeGeneric(inputs,fluid , getMaxParallelRecipes(), getEuDiscountForParallelism(), 250, 10000)) { + log("Recipe 2."); + return true; + } + } + + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMixer; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java new file mode 100644 index 0000000000..a0909a4fff --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java @@ -0,0 +1,541 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.util.*; +import gtPlusPlus.core.lib.CORE; +import org.apache.commons.lang3.ArrayUtils; + +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 gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +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.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_IndustrialMultiMachine +extends GregtechMeta_MultiBlockBase { + + protected int mInternalMode = 0; + protected GT_Recipe[] mLastRecipeExtended = new GT_Recipe[9]; + private static final int MODE_COMPRESSOR = 0; + private static final int MODE_LATHE = 1; + private static final int MODE_MAGNETIC = 2; + private static final int MODE_FERMENTER = 3; + private static final int MODE_FLUIDEXTRACT = 4; + private static final int MODE_EXTRACTOR = 5; + private static final int MODE_LASER = 6; + private static final int MODE_AUTOCLAVE = 7; + private static final int MODE_FLUIDSOLIDIFY = 8; + private static final int[][] MODE_MAP = new int[][] {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}}; + public static final String[] aToolTipNames = new String[9]; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialMultiMachine> STRUCTURE_DEFINITION = null; + + static { + for (int id = 0; id < 9; id++) { + String aNEI = GT_LanguageManager.getTranslation(getRecipeMap(id).mUnlocalizedName); + aToolTipNames[id] = aNEI != null ? aNEI : "BAD NEI NAME (Report to Github)"; + } + } + + + public GregtechMetaTileEntity_IndustrialMultiMachine(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialMultiMachine(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMultiMachine(this.mName); + } + + @Override + public String getMachineType() { + return "Nine in One"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + + String[] aBuiltStrings = new String[3]; + aBuiltStrings[0] = aToolTipNames[0] + ", " + aToolTipNames[1] + ", " + aToolTipNames[2]; + aBuiltStrings[1] = aToolTipNames[3] + ", " + aToolTipNames[4] + ", " + aToolTipNames[5]; + aBuiltStrings[2] = aToolTipNames[6] + ", " + aToolTipNames[7]; + + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Multi-Machine") + .addInfo("250% faster than using single block machines of the same voltage") + .addInfo("Only uses 80% of the eu/t normally required") + .addInfo("Processes two items per voltage tier") + .addInfo("Machine Type: [A] - " + EnumChatFormatting.YELLOW + aBuiltStrings[0] + EnumChatFormatting.RESET) + .addInfo("Machine Type: [B] - " + EnumChatFormatting.YELLOW + aBuiltStrings[1] + EnumChatFormatting.RESET) + .addInfo("Machine Type: [C] - " + EnumChatFormatting.YELLOW + aBuiltStrings[2] + EnumChatFormatting.RESET) + .addInfo("Read Multi-Machine Manual for extra information") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Multi-Use Casings", 6) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialMultiMachine> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialMultiMachine>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialMultiMachine::addIndustrialMultiMachineList, getTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings3Misc, 2 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 6 && checkHatch(); + } + + public final boolean addIndustrialMultiMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getTextureIndex()), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getTextureIndex())}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "Generic3By3"; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + ArrayList<FluidStack> tFluids = getStoredFluids(); + //Logger.MACHINE_INFO("1"); + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); + tBus.mRecipeMap = getRecipeMap(); + //Logger.MACHINE_INFO("2"); + if (isValidMetaTileEntity(tBus)) { + //Logger.MACHINE_INFO("3"); + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + + boolean aFoundCircuitInBus = false; + for (ItemStack aBusItem : tBusItems) { + if (ItemUtils.isControlCircuit(aBusItem)) { + aFoundCircuitInBus = true; + } + } + if (!aFoundCircuitInBus) { + continue; + } + + Object[] tempArray = tFluids.toArray(new FluidStack[] {}); + FluidStack[] properArray; + properArray = ((tempArray != null && tempArray.length > 0) ? (FluidStack[]) tempArray : new FluidStack[] {}); + + //Logger.MACHINE_INFO("4"); + if (checkRecipeGeneric(tBusItems.toArray(new ItemStack[]{}), properArray, + (2*GT_Utility.getTier(this.getMaxInputVoltage())), 80, 250, 10000)) return true; + } + return false; + + //return checkRecipeGeneric(2*GT_Utility.getTier(this.getMaxInputVoltage()), 90, 180); + } + + @Override + public int getMaxParallelRecipes() { + return (2 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 80; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + if (mInternalMode == 0) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal; + } + else if (mInternalMode == 1) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid; + } + else { //config 2 + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc; + } + } + + public int getTextureIndex() { + return TAE.getIndexFromPage(2, 2); + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private ItemStack getCircuit(ItemStack[] t) { + for (ItemStack j : t) { + if (j.getItem() == CI.getNumberedCircuit(0).getItem()) { + if (j.getItemDamage() >= 20 && j.getItemDamage() <= 22) { + return j; + } + } + } + return null; + } + + private final int getCircuitID(ItemStack circuit) { + int H = circuit.getItemDamage(); + int T = (H == 20 ? 0 : (H == 21 ? 1 : (H == 22 ? 2 : -1))); + return MODE_MAP[this.mInternalMode][T]; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + private final GT_Recipe.GT_Recipe_Map getRecipeMap(ItemStack circuit) { + return getRecipeMap(getCircuitID(circuit)); + } + + private static final GT_Recipe.GT_Recipe_Map getRecipeMap(int aMode) { + if (aMode == MODE_COMPRESSOR) { + return GT_Recipe.GT_Recipe_Map.sCompressorRecipes; + } + else if (aMode == MODE_LATHE) { + return GT_Recipe.GT_Recipe_Map.sLatheRecipes; + } + else if (aMode == MODE_MAGNETIC) { + return GT_Recipe.GT_Recipe_Map.sPolarizerRecipes; + } + else if (aMode == MODE_FERMENTER) { + return GT_Recipe.GT_Recipe_Map.sFermentingRecipes; + } + else if (aMode == MODE_FLUIDEXTRACT) { + return GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes; + } + else if (aMode == MODE_EXTRACTOR) { + return GT_Recipe.GT_Recipe_Map.sExtractorRecipes; + } + else if (aMode == MODE_LASER) { + return GT_Recipe.GT_Recipe_Map.sLaserEngraverRecipes; + } + else if (aMode == MODE_AUTOCLAVE) { + return GT_Recipe.GT_Recipe_Map.sAutoclaveRecipes; + } + else if (aMode == MODE_FLUIDSOLIDIFY) { + return GT_Recipe.GT_Recipe_Map.sFluidSolidficationRecipes; + } + else { + return null; + } + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll) { + + // Based on the Processing Array. A bit overkill, but very flexible. + + // Get Circuit info for this recipe. + ItemStack tCircuit = getCircuit(aItemInputs); + int tCircuitID = getCircuitID(tCircuit); + + Logger.MACHINE_INFO("Mode: "+tCircuitID); + + // 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)); + + GT_Recipe.GT_Recipe_Map tRecipeMap = this.getRecipeMap(tCircuit); + if (tRecipeMap == null) + return false; + GT_Recipe tRecipe = tRecipeMap.findRecipe( + getBaseMetaTileEntity(), this.mLastRecipeExtended[tCircuitID], false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + // Remember last recipe - an optimization for findRecipe() + //this.mLastRecipe = tRecipe; //Let's not do this, it's bad. + //Instead, how about I use a array for types? + this.mLastRecipeExtended[tCircuitID] = tRecipe; + + if (tRecipe == null) { + Logger.MACHINE_INFO("BAD RETURN - 1|"+tCircuitID); + + if (aItemInputs.length > 0) { + Logger.MACHINE_INFO("Input Items: "+ItemUtils.getArrayStackNames(aItemInputs)); + } + if (aFluidInputs.length > 0) { + Logger.MACHINE_INFO("Input Fluids: "+ItemUtils.getFluidArrayStackNames(aFluidInputs)); + } + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + Logger.MACHINE_INFO("BAD RETURN - 2|"+tCircuitID); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + Logger.WARNING("parallelRecipes: "+parallelRecipes); + Logger.WARNING("aMaxParallelRecipes: "+aMaxParallelRecipes); + Logger.WARNING("tTotalEUt: "+tTotalEUt); + Logger.WARNING("tVoltage: "+tVoltage); + Logger.WARNING("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + Logger.WARNING("Broke at "+parallelRecipes+"."); + break; + } + Logger.WARNING("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + Logger.MACHINE_INFO("BAD RETURN - 3|"+tCircuitID); + 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(); + + Logger.MACHINE_INFO("GOOD RETURN - 1|"+tCircuitID); + return true; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (mInternalMode < 2) { + mInternalMode++; + } + else { + mInternalMode = 0; + } + String mModeString = (mInternalMode == 0 ? "Metal" : mInternalMode == 1 ? "Fluid" : mInternalMode == 2 ? "Misc." : "null"); + PlayerUtils.messagePlayer(aPlayer, "Multi-Machine is now in "+mModeString+" mode."); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mInternalMode", mInternalMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mInternalMode = aNBT.getInteger("mInternalMode"); + super.loadNBTData(aNBT); + } + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java new file mode 100644 index 0000000000..007d1a0d0f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java @@ -0,0 +1,242 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import java.util.ArrayList; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.GregTech_API; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialPlatePress extends GregtechMeta_MultiBlockBase { + + private boolean mFormingMode = false; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialPlatePress> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialPlatePress(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialPlatePress(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); + } + + @Override + public String getMachineType() { + return "Bending Machine, Forming Press"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for Advanced Bending & Forming") + .addInfo("500% faster than using single block machines of the same voltage") + .addInfo("Processes four items per voltage tier") + .addInfo("Circuit for recipe goes in the Input Bus") + .addInfo("Each Input Bus can have a different Circuit/Shape!") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Material Press Machine Casings", 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialPlatePress> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialPlatePress>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialPlatePress::addIndustrialPlatePressList, 50, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 4 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + public final boolean addIndustrialPlatePressList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(203)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(50), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(50)}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MaterialPress"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mFormingMode ? GT_Recipe.GT_Recipe_Map.sPressRecipes : GT_Recipe.GT_Recipe_Map.sBenderRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); + tBus.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + + if (checkRecipeGeneric(tBusItems.toArray(new ItemStack[]{}), new FluidStack[]{}, + (4* GT_Utility.getTier(this.getMaxInputVoltage())), 100, 500, 10000)) return true; + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + if (this.mFormingMode) return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeForming; + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialPlatePress_ModeBending; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mFormingMode", mFormingMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mFormingMode = aNBT.getBoolean("mFormingMode"); + super.loadNBTData(aNBT); + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mFormingMode = Utils.invertBoolean(mFormingMode); + if (mFormingMode){ + PlayerUtils.messagePlayer(aPlayer, "Now running in Forming Press Mode."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Now running in Bending Mode."); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java new file mode 100644 index 0000000000..c5450fec5b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java @@ -0,0 +1,225 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import java.util.Random; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialSifter +extends GregtechMeta_MultiBlockBase { + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialSifter> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialSifter(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialSifter(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialSifter(this.mName); + } + + @Override + public String getMachineType() { + return "Sifter"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Sifter") + .addInfo("400% faster than single-block machines of the same voltage") + .addInfo("Only uses 75% of the eu/t normally required") + .addInfo("Processes four items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 3, 5, false) + .addController("Bottom Center") + .addCasingInfo("Sieve Grate", 18) + .addCasingInfo("Sieve Casings", 35) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialSifter> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialSifter>builder() + .addShape(mName, transpose(new String[][]{ + {"CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC"}, + {"CCCCC", "CMMMC", "CMMMC", "CMMMC", "CCCCC"}, + {"CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialSifter::addIndustrialSifterList, TAE.GTPP_INDEX(21), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 5 + ) + ) + ) + ) + .addElement( + 'M', + ofBlock( + ModBlocks.blockCasings2Misc, 6 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 2, 2, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 2, 2, 0) && mCasing >= 35 && mOutputBusses.size() >= 4 && checkHatch(); + } + + public final boolean addIndustrialSifterList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(21)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(21))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialSifter"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sSifterRecipes; + } + + @Override + public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + if (tRandom.nextFloat() > 0.4) return; + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + + aBaseMetaTileEntity.getWorld().spawnParticle("smoke", + (aBaseMetaTileEntity.getXCoord() + xDir + 2.1F) - (tRandom.nextFloat() * 3.2F), + aBaseMetaTileEntity.getYCoord() + 2.5f + (tRandom.nextFloat() * 1.2F), + (aBaseMetaTileEntity.getZCoord() + zDir + 2.1F) - (tRandom.nextFloat() * 3.2F), + 0.0, 0.0, 0.0); + + } + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((4* GT_Utility.getTier(this.getMaxInputVoltage())), 75, 400, 10000); + } + + @Override + protected boolean doesMachineBoostOutput() { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 75; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialSifter; + } + + @Override + public int getAmountOfOutputs() { + return 16; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSinter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSinter.java new file mode 100644 index 0000000000..5a62c6c335 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSinter.java @@ -0,0 +1,268 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.entity.player.InventoryPlayer; +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.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +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.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GregtechMetaTileEntity_IndustrialSinter +extends GT_MetaTileEntity_MultiBlockBase { + + + RenderBlocks asdasd = RenderBlocks.getInstance(); + + public GregtechMetaTileEntity_IndustrialSinter(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialSinter(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialSinter(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Sinter Furnace", + "Size: 3x5x3 [WxLxH] (Hollow)", "Controller (front centered)", + "2x Input Bus (side centered)", + "2x Output Bus (side centered)", + "1x Energy Hatch (top or bottom centered)", + "1x Maintenance Hatch (back centered)", + "Sinter Furnace Casings for the rest (32 at least!)", + "Causes " + 20 * this.getPollutionPerTick(null) + " Pollution per second", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(7)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(7))}; + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "WireFactory.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + final ArrayList<ItemStack> tInputList = this.getStoredInputs(); + for (final ItemStack tInput : tInputList) { + final long tVoltage = this.getMaxInputVoltage(); + final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { + this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1))); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1))); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + 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); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + this.updateSlots(); + return true; + } + } + } + return false; + } + + @Override + public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + final int controllerX = aBaseMetaTileEntity.getXCoord(); + final int controllerY = aBaseMetaTileEntity.getYCoord(); + final int controllerZ = aBaseMetaTileEntity.getZCoord(); + + final byte tSide = this.getBaseMetaTileEntity().getBackFacing(); + if ((this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 1)) && (this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 2) && (this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 3)))) { + int tAirCount = 0; + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + for (byte k = -1; k < 2; k = (byte) (k + 1)) { + if (this.getBaseMetaTileEntity().getAirOffset(i, j, k)) { + Logger.INFO("Found Air at: "+(controllerX+i)+" "+(controllerY+k)+" "+(controllerZ+k)); + //if (aBaseMetaTileEntity.getWorld().isRemote){ + //asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, (controllerX+i), (controllerY+k), (controllerZ+k)); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.YELLOW_GREEN); + //} + tAirCount++; + } + } + } + } + if (tAirCount != 10) { + Logger.INFO("False. Air != 10. Air == "+tAirCount); + //return false; + } + for (byte i = 2; i < 6; i = (byte) (i + 1)) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY), (controllerZ), Color.LIME_GREEN); + IGregTechTileEntity tTileEntity; + if ((null != (tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == this.getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialSinter))) { + //Utils.LOG_INFO("False 1"); + return false; + } + } + final int tX = this.getBaseMetaTileEntity().getXCoord(); + final int tY = this.getBaseMetaTileEntity().getYCoord(); + final int tZ = this.getBaseMetaTileEntity().getZCoord(); + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + if ((i != 0) || (j != 0)) { + for (byte k = 0; k < 5; k = (byte) (k + 1)) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.ORANGE); + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.TOMATO); + if ((this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock()) && (this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta())) { + } + else if (!this.addToMachineList(this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) && (!this.addEnergyInputToMachineList(this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { + Logger.INFO("False 2"); + return false; + } + } + else if ((this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock()) && (this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta())) { + } + else { + Logger.INFO("False 3"); + return false; + } + } + } + } + } + if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() != 0)) { + Logger.INFO("Use Busses, Not Hatches for Input/Output."); + return false; + } + if ((this.mInputBusses.size() != 2) || (this.mOutputBusses.size() != 2)) { + Logger.INFO("Incorrect amount of Input & Output busses."); + return false; + } + this.mMaintenanceHatches.clear(); + final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { + this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this.getCasingTextureIndex(); + } else { + Logger.INFO("Maintenance hatch must be in the middle block on the back."); + return false; + } + } + if ((this.mMaintenanceHatches.size() != 1) || (this.mEnergyHatches.size() != 1)) { + Logger.INFO("Incorrect amount of Maintenance or Energy hatches."); + return false; + } + } else { + Logger.INFO("False 5"); + return false; + } + Logger.INFO("True"); + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + + public byte getCasingMeta() { + return 6; + } + + + public byte getCasingTextureIndex() { + return 1; //TODO + } + + private boolean addToMachineList(final IGregTechTileEntity tTileEntity) { + return ((this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex()))); + } + + private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { + return ((this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()))); + } +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java new file mode 100644 index 0000000000..01b887694a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java @@ -0,0 +1,224 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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.item.ItemStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialThermalCentrifuge +extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialThermalCentrifuge> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialThermalCentrifuge(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialThermalCentrifuge(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialThermalCentrifuge(this.mName); + } + + @Override + public String getMachineType() { + return "Thermal Centrifuge"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Thermal Centrifuge") + .addInfo("150% faster than using single block machines of the same voltage") + .addInfo("Only uses 80% of the eu/t normally required") + .addInfo("Processes eight items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 2, 3, false) + .addController("Front Center") + .addCasingInfo("Thermal Processing Casings/Noise Hazard Sign Blocks", 8) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .addMufflerHatch("Bottom Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialThermalCentrifuge> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialThermalCentrifuge>builder() + .addShape(mName, transpose(new String[][]{ + {"X~X", "XXX", "XXX"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialThermalCentrifuge::addIndustrialThermalCentrifugeList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 0 + ) + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + GregTech_API.sBlockCasings3, 9 + ) + ) + ) + ) + .addElement( + 'X', + ofChain( + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 0 + ) + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + GregTech_API.sBlockCasings3, 9 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 0, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 0, 0) && mCasing >= 8 && checkHatch(); + } + + public final boolean addIndustrialThermalCentrifugeList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex())}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialThermalCentrifuge"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sThermalCentrifugeRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((8* GT_Utility.getTier(this.getMaxInputVoltage())), 80, 150); + } + + @Override + public int getMaxParallelRecipes() { + return (8 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 80; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialThermalCentrifuge; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + public byte getCasingMeta() { + return 0; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(16); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java new file mode 100644 index 0000000000..1f63995651 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java @@ -0,0 +1,261 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.GregTech_API; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta_MultiBlockBase { + + public static int CASING_TEXTURE_ID; + public static String mCryoFuelName = "Gelid Cryotheum"; + public static String mCasingName = "Advanced Cryogenic Casing"; + public static String mHatchName = "Cryotheum Hatch"; + public static FluidStack mFuelStack; + private boolean mHaveHatch; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialVacuumFreezer> STRUCTURE_DEFINITION = null; + + + public GregtechMetaTileEntity_IndustrialVacuumFreezer(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); + mCryoFuelName = mFuelStack.getLocalizedName(); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 10); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); + } + + public GregtechMetaTileEntity_IndustrialVacuumFreezer(final String aName) { + super(aName); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); + mCryoFuelName = mFuelStack.getLocalizedName(); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 10); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (IMetaTileEntity) new GregtechMetaTileEntity_IndustrialVacuumFreezer(this.mName); + } + + @Override + public String getMachineType() { + return "Vacuum Freezer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 10); + } + if (mCryoFuelName.toLowerCase().contains(".")) { + mCryoFuelName = FluidUtils.getFluidStack("cryotheum", 1).getLocalizedName(); + } + if (mHatchName.toLowerCase().contains(".name")) { + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); + } + + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Advanced Vacuum Freezer") + .addInfo("Speed: 200% | Eu Usage: 100% | Parallel: 4") + .addInfo("Consumes 1L of " + mCryoFuelName + "/t during operation") + .addInfo("Constructed exactly the same as a normal Vacuum Freezer") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo(mCasingName, 10) + .addStructureHint(mHatchName, 1) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialVacuumFreezer> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialVacuumFreezer>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialVacuumFreezer::addIndustrialVacuumFreezerList, CASING_TEXTURE_ID, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings3Misc, 10 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mHaveHatch = false; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && mHaveHatch && checkHatch(); + } + + public final boolean addIndustrialVacuumFreezerList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 967) { + mHaveHatch = true; + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID), + new GT_RenderedTexture((IIconContainer) (aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced))}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "VacuumFreezer"; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT; + } + + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + public boolean checkRecipe(final ItemStack aStack) { + return this.checkRecipeGeneric(4, 100, 100); + } + + @Override + public int getMaxParallelRecipes() { + return 4; + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialVacuumFreezer; + } + + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private volatile int mGraceTimer = 2; + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + /*if (this.getBaseMetaTileEntity().isActive()) { + if (!this.depleteInput(mFuelStack.copy())) { + this.getBaseMetaTileEntity().setActive(false); + } + } */ + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (this.mStartUpCheck < 0) { + if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (aTick % 10 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (!this.depleteInput(FluidUtils.getFluidStack("cryotheum", 10))) { + if (mGraceTimer-- == 0) { + this.causeMaintenanceIssue(); + this.stopMachine(); + mGraceTimer = 2; + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java new file mode 100644 index 0000000000..168d4ff6d6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java @@ -0,0 +1,335 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +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.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +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 ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +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; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialWashPlant +extends GregtechMeta_MultiBlockBase { + + private boolean mChemicalMode = false; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialWashPlant> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialWashPlant(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialWashPlant(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialWashPlant(this.mName); + } + + @Override + public String getMachineType() { + return "Ore Washer, Chemical Bath"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Ore Washing Plant") + .addInfo("Can be configured with a screwdriver to also process Chemical Bathing") + .addInfo("400% faster than using single block machines of the same voltage") + .addInfo("Processes four item per voltage tier") + .addInfo("Always requires an Input Hatch full of water to refill structure") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 3, 7, true) + .addController("Front Center") + .addCasingInfo("Wash Plant Casings", 40) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialWashPlant> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialWashPlant>builder() + .addShape(mName, transpose(new String[][]{ + {"CCCCC", "C C", "C C", "C C", "C C", "C C", "CCCCC"}, + {"CC~CC", "C C", "C C", "C C", "C C", "C C", "CCCCC"}, + {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialWashPlant::addIndustrialWashPlantList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + getCasingBlock(), getCasingMeta() + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 2, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 2, 1, 0) && mCasing >= 40 && checkHatch(); + } + + public final boolean addIndustrialWashPlantList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a washer, water will flow out. + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex())}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialWashPlant"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mChemicalMode ? GT_Recipe.GT_Recipe_Map.sChemicalBathRecipes : GT_Recipe.GT_Recipe_Map.sOreWasherRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + if (checkForWater()) { + return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 100, 400); + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (4* GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + if (this.mChemicalMode) return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath; + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWashPlant_ModeWasher; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + + public byte getCasingMeta() { + return 4; + } + + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(11); + } + + public boolean checkForWater() { + + //Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + if (mDirectionX == 0){ + mCurrentDirectionX = 2; + mCurrentDirectionZ = 3; + mOffsetX_Lower = -2; + mOffsetX_Upper = 2; + mOffsetZ_Lower = -3; + mOffsetZ_Upper = 3; + } + else { + mCurrentDirectionX = 3; + mCurrentDirectionZ = 2; + mOffsetX_Lower = -3; + mOffsetX_Upper = 3; + mOffsetZ_Lower = -2; + mOffsetZ_Upper = 2; + } + + //if (aBaseMetaTileEntity.fac) + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; ++h) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == Blocks.water) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + //Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = null; + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water) { + fluidUsed = Blocks.water; + } + if (tBlock == Blocks.water) { + fluidUsed = BlocksItems.getFluidBlock(InternalName.fluidDistilledWater); + } + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord() + xDir + i, aBaseMetaTileEntity.getYCoord() + h, aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); + + + } + } + } + } + } + if (tBlock == Blocks.water) { + ++tAmount; + //Utils.LOG_WARNING("Found Water"); + } else if (tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + ++tAmount; + ++tAmount; + //Utils.LOG_WARNING("Found Distilled Water"); + } + } + } + } + if ((tAmount >= 45)){ + Logger.WARNING("Filled structure."); + } + else { + Logger.WARNING("Did not fill structure."); + } + return (tAmount >= 45); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mChemicalMode", mChemicalMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mChemicalMode = aNBT.getBoolean("mChemicalMode"); + super.loadNBTData(aNBT); + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mChemicalMode = Utils.invertBoolean(mChemicalMode); + if (mChemicalMode){ + PlayerUtils.messagePlayer(aPlayer, "Wash Plant is now running in Chemical Bath Mode."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Wash Plant is now running in Ore Washer Mode."); + } + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java new file mode 100644 index 0000000000..ccce25d925 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java @@ -0,0 +1,206 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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.item.ItemStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_IndustrialWireMill +extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialWireMill> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialWireMill(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialWireMill(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); + } + + @Override + public String getMachineType() { + return "Wiremill"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Wire Factory") + .addInfo("200% faster than using single block machines of the same voltage") + .addInfo("Only uses 75% of the eu/t normally required") + .addInfo("Processes four items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front Center") + .addCasingInfo("Wire Factory Casings", 32) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialWireMill> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialWireMill>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + {"C~C", "C-C", "C-C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialWireMill::addIndustrialWireMillList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + getCasingBlock(), getCasingMeta() + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 32 && checkHatch(); + } + + public final boolean addIndustrialWireMillList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(204)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(6)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(6))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "IndustrialWireFactory"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((4* GT_Utility.getTier(this.getMaxInputVoltage())), 75, 200); + } + + @Override + public int getMaxParallelRecipes() { + return (4* GT_Utility.getTier(this.getMaxInputVoltage())); + } + + @Override + public int getEuDiscountForParallelism() { + return 75; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialWireMill; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + public byte getCasingMeta() { + return 6; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(6); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java new file mode 100644 index 0000000000..5d6904bd46 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java @@ -0,0 +1,403 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_IronBlastFurnace; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_IronBlastFurnace; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMetaTileEntity_IronBlastFurnace +extends MetaTileEntity { + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top)}; + private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; + private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; + public int mMaxProgresstime = 0; + public int mUpdate = 30; + public int mProgresstime = 0; + public boolean mMachine = false; + public ItemStack mOutputItem1; + public ItemStack mOutputItem2; + + public GregtechMetaTileEntity_IronBlastFurnace(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 4); + } + + public GregtechMetaTileEntity_IronBlastFurnace(final String aName) { + super(aName, 4); + } + + @Override + public String[] getDescription() { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return new String[]{"Iron is a much better furnace material!", + "Can be Automated", + "Multiblock: 3x3x5 hollow with opening on top", + "Same shape as Bronze/Bricked blast furnace, except one ring of 8 taller.", + "40 Iron Plated Bricks required", + }; + } + else { + return new String[]{"Sloooowly, Skip the Bronze age, Get some Steel!", + "Multiblock: 3x3x5 hollow with opening on top", + "40 Iron Plated Bricks required", + "----", + "Even though Iron melts hotter than bronze,", + "this machine is to help players skip looking", + "for tin and copper, which are not as common", + "as Iron is. This machine takes 5x longer than the bronze", + "blast furnace as a result.", + "----", + }; + } + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return aActive ? FACING_ACTIVE : FACING_FRONT; + } + return FACING_SIDE; + } + + @Override + public boolean isSteampowered() { + return false; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isPneumatic() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(final byte aSide) { + return false; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return false; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public int getProgresstime() { + return this.mProgresstime; + } + + @Override + public int maxProgresstime() { + return this.mMaxProgresstime; + } + + @Override + public int increaseProgress(final int aProgress) { + this.mProgresstime += aProgress; + return this.mMaxProgresstime - this.mProgresstime; + } + + @Override + public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { + return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mProgresstime", this.mProgresstime); + aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); + if (this.mOutputItem1 != null) { + final NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem1.writeToNBT(tNBT); + aNBT.setTag("mOutputItem1", tNBT); + } + if (this.mOutputItem2 != null) { + final NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem2.writeToNBT(tNBT); + aNBT.setTag("mOutputItem2", tNBT); + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mUpdate = 30; + this.mProgresstime = aNBT.getInteger("mProgresstime"); + this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); + this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + private boolean checkMachine() { + final int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; + final int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 4; j++) { //This is height + for (int k = -1; k < 2; k++) { + if (((xDir + i) != 0) || (j != 0) || ((zDir + k) != 0)) { + if ((i != 0) || (j == -1) || (k != 0)) { + if ((this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) != ModBlocks.blockCasingsMisc) || (this.getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) { + return false; + } + } else if ((!GT_Utility.arrayContains(this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[]{Blocks.lava, Blocks.flowing_lava, null})) && (!this.getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) { + return false; + } + } + } + } + } + return true; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 30; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { + if ((aBaseMetaTileEntity.isClientSide()) && + (aBaseMetaTileEntity.isActive())) { + aBaseMetaTileEntity.getWorld().spawnParticle("cloud", aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), 0.0D, 0.3D, 0.0D); + } + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate-- == 0) { + this.mMachine = this.checkMachine(); + } + if (this.mMachine) { + if (this.mMaxProgresstime > 0) { + if (++this.mProgresstime >= this.mMaxProgresstime) { + this.addOutputProducts(); + this.mOutputItem1 = null; + this.mOutputItem2 = null; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + try { + GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel"); + } catch (final Exception e) { + } + } + } else if (aBaseMetaTileEntity.isAllowedToWork()) { + this.checkRecipe(); + } + } + aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); + if (aBaseMetaTileEntity.isActive()) { + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); + this.mUpdate = 1; + } + } else { + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); + this.mUpdate = 1; + } + } + } + } + + private void addOutputProducts() { + if (this.mOutputItem1 != null) { + if (this.mInventory[2] == null) { + this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1}); + } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { + this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize); + } + } + if (this.mOutputItem2 != null) { + if (this.mInventory[3] == null) { + this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2}); + } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { + this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), this.mOutputItem2.stackSize + this.mInventory[3].stackSize); + } + } + } + + private boolean spaceForOutput(final ItemStack aStack1, final ItemStack aStack2) { + if (((this.mInventory[2] == null) || (aStack1 == null) || (((this.mInventory[2].stackSize + aStack1.stackSize) <= this.mInventory[2].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) && ( + (this.mInventory[3] == null) || (aStack2 == null) || (((this.mInventory[3].stackSize + aStack2.stackSize) <= this.mInventory[3].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) { + return true; + } + return false; + } + + private int getProperTime(int time) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return (int) (time/3); + } + else { + return time; + } + } + + private boolean checkRecipe() { + + if (!this.mMachine) { + return false; + } + if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 4*3); + this.mMaxProgresstime = getProperTime(36000); + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 2) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 2*3); + this.mMaxProgresstime = getProperTime(4800); + return true; + } + if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 9); + this.getBaseMetaTileEntity().decrStackSize(1, 4*3); + this.mMaxProgresstime = getProperTime(64800); + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 2*3); + this.mMaxProgresstime = getProperTime(3600); + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 1) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 1*3); + this.mMaxProgresstime = getProperTime(2400); + return true; + } + if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 2) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 9); + this.getBaseMetaTileEntity().decrStackSize(1, 2*3); + this.mMaxProgresstime = getProperTime(32400); + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 64); + this.mMaxProgresstime = getProperTime(64800); + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 18) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 18*3); + this.mMaxProgresstime = getProperTime(43200); + return true; + } + if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (this.spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + this.getBaseMetaTileEntity().decrStackSize(0, 1); + this.getBaseMetaTileEntity().decrStackSize(1, 4*3); + this.mMaxProgresstime = getProperTime(64800); + return true; + } + } + } + this.mOutputItem1 = null; + this.mOutputItem2 = null; + return false; + } + + @Override + public boolean isGivingInformation() { + return false; + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return aIndex > 1; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + if (aIndex < 2) { + } + return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); + } + + @Override + public byte getTileEntityBaseType() { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java new file mode 100644 index 0000000000..59e6e78757 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java @@ -0,0 +1,666 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gtPlusPlus.core.lib.CORE; +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +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.GTPP_Recipe; +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.lib.CORE; +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; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +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 { + + protected boolean boostEu = false; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IsaMill> STRUCTURE_DEFINITION = null; + + 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) { + super(aID, aName, aNameRegional); + frontFaceActive = new GT_RenderedTexture(new CustomIcon("iconsets/Grinder/GRINDER_ACTIVE5")); + frontFace = new GT_RenderedTexture(new CustomIcon("iconsets/Grinder/GRINDER5")); + } + + public GregtechMetaTileEntity_IsaMill(String aName) { + super(aName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Large Grinding Machine") + .addInfo("Grind ores.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 7, false) + .addController("Front Center") + .addCasingInfo("IsaMill Exterior Casing", 40) + .addOtherStructurePart("IsaMill Gearbox", "Inner Blocks") + .addOtherStructurePart("IsaMill Piping", "8x, ring around controller") + .addStructureInfo("IsaMill Pipings must not be obstructed in front (only air blocks)") + .addOtherStructurePart("Milling Ball Hatch", "Any Casing") + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IsaMill> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IsaMill>builder() + .addShape(mName, transpose(new String[][]{ + {"DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC"}, + {"D~D", "CGC", "CGC", "CGC", "CGC", "CGC", "CCC"}, + {"DDD", "CCC", "CCC", "CCC", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IsaMill::addToMachineList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + getCasingBlock(), getCasingMeta() + ) + ) + ) + ) + .addElement( + 'D', + ofBlock( + getIntakeBlock(), getIntakeMeta() + ) + ) + .addElement( + 'G', + ofBlock( + getGearboxBlock(), getGearboxMeta() + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mMillingBallBuses.clear(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 48 - 8 && checkHatch(); + } + + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return new ITexture[]{ + Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(2)), + aFacing == aSide ? aActive ? frontFaceActive : frontFace : Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(2))}; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + 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"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sOreMillRecipes; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long 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>(); + + public void checkForEntities(IGregTechTileEntity aBaseMetaTileEntity, long aTime) { + + if (aTime % 100 == 0) { + mFrontBlockPosCache.clear(); + } + if (mFrontBlockPosCache.isEmpty()) { + byte tSide = aBaseMetaTileEntity.getBackFacing(); + int aTileX = aBaseMetaTileEntity.getXCoord(); + int aTileY = aBaseMetaTileEntity.getYCoord(); + int aTileZ = aBaseMetaTileEntity.getZCoord(); + boolean xFacing = (tSide == 4 || tSide == 5); + boolean zFacing = (tSide == 2 || tSide == 3); + + // Check Casings + int aDepthOffset = (tSide == 2 || tSide == 4) ? 1 : -1; + for (int aHorizontalOffset = -1; aHorizontalOffset < 2; aHorizontalOffset++) { + for (int aVerticalOffset = -1; aVerticalOffset < 2; aVerticalOffset++) { + int aX = !xFacing ? (aTileX + aHorizontalOffset) : (aTileX + aDepthOffset); + int aY = aTileY + aVerticalOffset; + int aZ = !zFacing ? (aTileZ + aHorizontalOffset) : (aTileZ + aDepthOffset); + mFrontBlockPosCache.add(new BlockPos(aX, aY, aZ, aBaseMetaTileEntity.getWorld())); + } + } + } + + AutoMap<EntityLivingBase> aEntities = getEntities(mFrontBlockPosCache, aBaseMetaTileEntity.getWorld()); + if (!aEntities.isEmpty()) { + for (EntityLivingBase aFoundEntity : aEntities) { + if (aFoundEntity instanceof EntityPlayer) { + EntityPlayer aPlayer = (EntityPlayer) aFoundEntity; + if (PlayerUtils.isCreative(aPlayer) || !PlayerUtils.canTakeDamage(aPlayer)) { + continue; + } + else { + if (aFoundEntity.getHealth() > 0) { + EntityUtils.doDamage(aFoundEntity, mIsaMillDamageSource, (int) (aFoundEntity.getMaxHealth() / 5)); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { + generateParticles(aFoundEntity); + } + } + } + } + if (aFoundEntity.getHealth() > 0) { + EntityUtils.doDamage(aFoundEntity, mIsaMillDamageSource, Math.max(1, (int) (aFoundEntity.getMaxHealth() / 3))); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { + generateParticles(aFoundEntity); + } + } + } + } + } + + private static final AutoMap<EntityLivingBase> getEntities(AutoMap<BlockPos> aPositionsToCheck, World aWorld){ + AutoMap<EntityLivingBase> aEntities = new AutoMap<EntityLivingBase>(); + HashSet<Chunk> aChunksToCheck = new HashSet<Chunk>(); + if (!aPositionsToCheck.isEmpty()) { + Chunk aLocalChunk; + for (BlockPos aPos : aPositionsToCheck) { + aLocalChunk = aWorld.getChunkFromBlockCoords(aPos.xPos, aPos.zPos); + aChunksToCheck.add(aLocalChunk); + } + } + if (!aChunksToCheck.isEmpty()) { + AutoMap<EntityLivingBase> aEntitiesFound = new AutoMap<EntityLivingBase>(); + for (Chunk aChunk : aChunksToCheck) { + if (aChunk.isChunkLoaded) { + List[] aEntityLists = aChunk.entityLists; + for (List aEntitySubList : aEntityLists) { + for (Object aEntity : aEntitySubList) { + if (aEntity instanceof EntityLivingBase) { + EntityLivingBase aPlayer = (EntityLivingBase) aEntity; + aEntitiesFound.add(aPlayer); + } + } + } + } + } + if (!aEntitiesFound.isEmpty()) { + for (EntityLivingBase aEntity : aEntitiesFound) { + BlockPos aPlayerPos = EntityUtils.findBlockPosOfEntity(aEntity); + for (BlockPos aBlockSpaceToCheck : aPositionsToCheck) { + if (aBlockSpaceToCheck.equals(aPlayerPos)) { + aEntities.add(aEntity); + } + } + } + } + } + return aEntities; + } + + private static void generateParticles(EntityLivingBase aEntity) { + BlockPos aPlayerPosBottom = EntityUtils.findBlockPosOfEntity(aEntity); + BlockPos aPlayerPosTop = aPlayerPosBottom.getUp(); + AutoMap<BlockPos> aEntityPositions = new AutoMap<BlockPos>(); + aEntityPositions.add(aPlayerPosBottom); + aEntityPositions.add(aPlayerPosTop); + for (int i = 0; i < 64; i++) { + BlockPos aEffectPos = aEntityPositions.get(aEntity.height > 1f ? MathUtils.randInt(0, 1) : 0); + float aOffsetX = MathUtils.randFloat(-0.35f, 0.35f); + float aOffsetY = MathUtils.randFloat(-0.25f, 0.35f); + float aOffsetZ = MathUtils.randFloat(-0.35f, 0.35f); + aEntity.worldObj.spawnParticle("reddust", aEffectPos.xPos + aOffsetX, aEffectPos.yPos + 0.3f + aOffsetY, aEffectPos.zPos + aOffsetZ, 0.0D, 0.0D, 0.0D); + } + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + return checkRecipeGeneric(); + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings5Misc; + } + + public byte getCasingMeta() { + return 0; + } + + public Block getIntakeBlock() { + return ModBlocks.blockCasings5Misc; + } + + public byte getIntakeMeta() { + return 1; + } + + public Block getGearboxBlock() { + return ModBlocks.blockCasings5Misc; + } + + public byte getGearboxMeta() { + return 2; + } + + public byte getCasingTextureIndex() { + return 66; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IsaMill(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIsaMill; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public String[] getExtraInfoData() { + return new String[]{ + "IsaMill Grinding Machine", + "Current Efficiency: " + (mEfficiency / 100) + "%", + getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance" + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Grinding Machine"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + 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, boolean isOC) { + + // 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/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java new file mode 100644 index 0000000000..81f8ba9edb --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java @@ -0,0 +1,414 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +import java.util.ArrayList; +import java.util.List; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +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_Output; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GasSpargingRecipe; +import gregtech.api.util.GasSpargingRecipeMap; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +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.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_SpargeTower extends GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_SpargeTower> { + + protected static final String STRUCTURE_PIECE_BASE = "base"; + protected static final String STRUCTURE_PIECE_LAYER = "layer"; + protected static final String STRUCTURE_PIECE_LAYER_HINT = "layerHint"; + protected static final String STRUCTURE_PIECE_TOP_HINT = "topHint"; + private static final IStructureDefinition<GregtechMetaTileEntity_SpargeTower> STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_SpargeTower>builder() + .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][]{ + {"b~b", "bbb", "bbb"}, + })) + .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][]{ + {"lll", "lcl", "lll"} + })) + .addShape(STRUCTURE_PIECE_LAYER_HINT, transpose(new String[][]{ + {"lll", "l-l", "lll"} + })) + .addShape(STRUCTURE_PIECE_TOP_HINT, transpose(new String[][]{ + {"lll", "lll", "lll"} + })) + .addElement('b', ofChain( + ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addEnergyInputToMachineList, getCasingIndex(), 1), + ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addInputToMachineList, getCasingIndex(), 1), + ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addMaintenanceToMachineList, getCasingIndex(), 1), + onElementPass(GregtechMetaTileEntity_SpargeTower::onCasingFound, ofBlock(ModBlocks.blockCasings5Misc, 4)) + )) + .addElement('l', ofChain( + ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addEnergyInputToMachineList, getCasingIndex(), 2), + ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addLayerOutputHatch, getCasingIndex(), 2), + ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addMaintenanceToMachineList, getCasingIndex(), 2), + onElementPass(GregtechMetaTileEntity_SpargeTower::onCasingFound, ofBlock(ModBlocks.blockCasings5Misc, 4)) + )) + .addElement('c', ofChain( + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addOutputToMachineList, getCasingIndex(), 3)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GregtechMetaTileEntity_SpargeTower::addMaintenanceToMachineList, getCasingIndex(), 3)), + onElementPass(t -> t.onTopLayerFound(true), ofBlock(ModBlocks.blockCasings5Misc, 4)), + isAir() + )) + .build(); + + protected final List<List<GT_MetaTileEntity_Hatch_Output>> mOutputHatchesByLayer = new ArrayList<>(); + protected int mHeight; + protected int mCasing; + protected boolean mTopLayerFound; + + public GregtechMetaTileEntity_SpargeTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_SpargeTower(String aName) { + super(aName); + } + + public static int getCasingIndex() { + return 68; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_SpargeTower(this.mName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Gas Sparge Tower") + .addInfo("Controller block for the Sparging Tower") + .addInfo("Fluids are only put out at the correct height") + .addInfo("The correct height equals the slot number in the NEI recipe") + .addSeparator() + .beginStructureBlock(3, 8, 3, true) + .addController("Front bottom") + .addOtherStructurePart("Sparge Tower Exterior Casing", "45 (minimum)") + .addEnergyHatch("Any casing", 1, 2) + .addMaintenanceHatch("Any casing", 1, 2, 3) + .addInputHatch("2x Input Hatches (Any bottom layer casing)", 1) + .addOutputHatch("6x Output Hatches (At least one per layer except bottom layer)", 2, 3) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + if (aActive) + return new ITexture[]{ + BlockIcons.getCasingTextureForId(getCasingIndex()), + TextureFactory.builder().addIcon(TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active).extFacing().build()}; + return new ITexture[]{ + BlockIcons.getCasingTextureForId(getCasingIndex()), + TextureFactory.builder().addIcon(TexturesGtBlock.Overlay_Machine_Controller_Advanced).extFacing().build()}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingIndex())}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DistillationTower.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.isEmpty()) { + generateRecipes(); + } + return GTPP_Recipe_Map.sSpargeTowerRecipes; + } + + private static boolean generateRecipes() { + for (GasSpargingRecipe aRecipe : GasSpargingRecipeMap.mRecipes) { + GTPP_Recipe newRecipe = new GTPP_Recipe( + false, + new ItemStack[] {}, + new ItemStack[] {}, + null, + null, + aRecipe.mFluidInputs.clone(), + new FluidStack[] {}, + aRecipe.mDuration, + aRecipe.mEUt, + 0); + GTPP_Recipe_Map.sSpargeTowerRecipes.add(newRecipe); + } + if (GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.isEmpty()) { + return false; + } + return true; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<FluidStack> tFluidList = getStoredFluids(); + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(0, GT_Utility.getTier(tVoltage)); + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); + if (tFluids.length > 0) { + Logger.INFO("Found "+tFluids.length+" input fluids. Searching "+GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.size()+" recipes."); + GT_Recipe tRecipe = getRecipeMap().findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids); + if (tRecipe != null) { + Logger.INFO("Found recipe!"); + if (tRecipe.isRecipeInputEqual(true, tFluids)) { + Logger.INFO("Found recipe that matches!"); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + this.mLastRecipe = tRecipe; + + calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); + int aDevProgress = this.mMaxProgresstime / 10; + this.mMaxProgresstime = Math.max(1, aDevProgress); + this.mOutputItems = new ItemStack[]{}; + ArrayList<FluidStack> aFluidOutputs = getByproductsOfSparge(tRecipe.mFluidInputs[0], tRecipe.mFluidInputs[1]); + this.mOutputFluids = (FluidStack[]) aFluidOutputs.toArray(new FluidStack[0]); + updateSlots(); + Logger.INFO("Done!"); + return true; + } + } + else { + Logger.INFO("Did not find recipe!"); + } + } + this.mEUt = 0; + this.mEfficiency = 0; + Logger.INFO("Did not find recipe! (2)"); + return false; + } + + private static ArrayList<FluidStack> getByproductsOfSparge(final FluidStack aSpargeGas, final FluidStack aSpentFuel){ + GasSpargingRecipe aSpargeRecipe = GasSpargingRecipeMap.findRecipe(aSpargeGas, aSpentFuel); + ArrayList<FluidStack> aOutputGases = new ArrayList<FluidStack>(); + if (aSpargeRecipe == null) { + Logger.INFO("Did not find sparge recipe!"); + return aOutputGases; + } + int aSpargeGasAmount = aSpargeRecipe.mInputGas.amount; + + aOutputGases.add(aSpargeRecipe.mOutputSpargedFuel.copy()); + ArrayList<FluidStack> aTempMap = new ArrayList<FluidStack>(); + for (int i=2;i<aSpargeRecipe.mFluidOutputs.length;i++) { + int aGasAmount = MathUtils.randInt(0, (aSpargeRecipe.mMaxOutputQuantity[i-2]/100)); + FluidStack aOutput = aSpargeRecipe.mFluidOutputs[i].copy(); + aSpargeGasAmount -= aGasAmount; + FluidStack aSpargeOutput = null; + if (aGasAmount > 0) { + aSpargeOutput = new FluidStack(aOutput.getFluid(), aGasAmount); + } + aTempMap.add(aSpargeOutput); + } + Logger.INFO("Sparge gas left: "+aSpargeGasAmount); + if (aSpargeGasAmount > 0) { + aOutputGases.add(new FluidStack(aSpargeRecipe.mInputGas.getFluid(), aSpargeGasAmount)); + } + //Logger.INFO("Sparge Outputs: "+ItemUtils.getArrayStackNames(aTempMap)); + aOutputGases.addAll(aTempMap); + Logger.INFO("Sparge output size: "+aOutputGases.size()); + //Logger.INFO("Output of sparging: "+ItemUtils.getArrayStackNames(aOutputGases)); + return aOutputGases; + } + + protected void onCasingFound() { + mCasing++; + } + + protected void onTopLayerFound(boolean aIsCasing) { + mTopLayerFound = true; + if (aIsCasing) { + onCasingFound(); + } + } + + protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null || aTileEntity.isDead() || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) { + Logger.INFO("Bad Output Hatch"); + return false; + } + while (mOutputHatchesByLayer.size() < mHeight) { + mOutputHatchesByLayer.add(new ArrayList<>()); + } + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); + tHatch.updateTexture(aBaseCasingIndex); + boolean addedHatch = mOutputHatchesByLayer.get(mHeight - 1).add(tHatch); + Logger.INFO("Added Hatch: "+addedHatch); + return addedHatch; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a freaking tower, it won't work + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_SpargeTower> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // reset + mOutputHatchesByLayer.forEach(List::clear); + mHeight = 1; + mTopLayerFound = false; + mCasing = 0; + + // check base + if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) { + Logger.INFO("Bad Base. Height: "+mHeight); + return false; + } + + // check each layer + while (mHeight < 8 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) { + if (mOutputHatchesByLayer.get(mHeight - 1).isEmpty()) { + // layer without output hatch + Logger.INFO("Height: "+mHeight + " - Missing output on "+(mHeight - 1)); + return false; + } + // not top + mHeight++; + } + + // validate final invariants... + Logger.INFO("Height: "+mHeight); + Logger.INFO("Casings: "+mCasing); + Logger.INFO("Required: "+(7 * mHeight - 5)); + Logger.INFO("Found Top: "+mTopLayerFound); + return mCasing >= 45 && mTopLayerFound && mMaintenanceHatches.size() == 1; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length && i < mOutputHatchesByLayer.size(); i++) { + FluidStack tStack = mOutputFluids2[i] != null ? mOutputFluids2[i].copy() : null; + if (tStack == null) { + continue; + } + if (!dumpFluid(mOutputHatchesByLayer.get(i), tStack, true)) { + dumpFluid(mOutputHatchesByLayer.get(i), tStack, false); + } + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); + int tTotalHeight = 8; // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); + } + buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 1, tTotalHeight - 1, 0); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getMachineType() { + return "Gas Sparger"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean onPlungerRightClick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + int aLayerIndex = 0; + PlayerUtils.messagePlayer(aPlayer, "Trying to clear "+mOutputHatchesByLayer.size()+" layers of output hatches."); + for (List<GT_MetaTileEntity_Hatch_Output> layer : this.mOutputHatchesByLayer) { + int aHatchIndex = 0; + for (GT_MetaTileEntity_Hatch_Output hatch : layer) { + if (hatch.mFluid != null) { + PlayerUtils.messagePlayer(aPlayer, "Clearing "+hatch.mFluid.amount+"L of "+hatch.mFluid.getLocalizedName()+" from hatch "+aHatchIndex+" on layer "+aLayerIndex+"."); + hatch.mFluid = null; + } + aHatchIndex++; + } + aLayerIndex++; + } + return aLayerIndex > 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_AssemblyLine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_AssemblyLine.java new file mode 100644 index 0000000000..8c9e886e94 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_AssemblyLine.java @@ -0,0 +1,629 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +import java.util.ArrayList; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +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_DataAccess; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.minecraft.LangUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Naquadah; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_Adv_AssemblyLine + extends GregtechMeta_MultiBlockBase { + + public ArrayList<GT_MetaTileEntity_Hatch_DataAccess> mDataAccessHatches = new ArrayList<GT_MetaTileEntity_Hatch_DataAccess>(); + + public static String[] mCasingName = new String[5]; + private final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 13); + private final int META_BaseCasing = 0; //4 + private final int META_ContainmentCasing = 15; //3 + private final int META_Shielding = 13; //1 + private final int META_PipeCasing = 1; //4 + private final int META_IntegralCasing = 6; //0 + private final int META_ContainmentChamberCasing = 2; //4 + + + public GregtechMetaTileEntity_Adv_AssemblyLine(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); + mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); + mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); + mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); + mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); + } + + public GregtechMetaTileEntity_Adv_AssemblyLine(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_AssemblyLine(this.mName); + } + + public String[] getTooltip() { + if (mCasingName[0].toLowerCase().contains(".name")) { + mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); + } + if (mCasingName[1].toLowerCase().contains(".name")) { + mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); + } + if (mCasingName[2].toLowerCase().contains(".name")) { + mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); + } + if (mCasingName[3].toLowerCase().contains(".name")) { + mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); + } + if (mCasingName[4].toLowerCase().contains(".name")) { + mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); + } + return new String[]{ + "Advanced Integrated Assembly Line" + }; + } + + private Block getCasing(int casingID) { + if (casingID == 1) { + return ModBlocks.blockCasingsMisc; + } + else if (casingID == 2) { + return ModBlocks.blockCasings2Misc; + } + else if (casingID == 3) { + return ModBlocks.blockCasings3Misc; + } + else if (casingID == 4) { + return ModBlocks.blockCasings4Misc; + } + else { + return ModBlocks.blockCasingsTieredGTPP; + } + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(16), new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(16)}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "AssemblyLine.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + if(GT_Values.D1)System.out.println("Start ALine recipe check"); + ArrayList<ItemStack> tDataStickList = getDataItems(2); + if (tDataStickList.size() == 0) return false; + if(GT_Values.D1)System.out.println("Stick accepted, " + tDataStickList.size() + " Data Sticks found"); + + ItemStack tStack[] = new ItemStack[15]; + FluidStack[] tFluids = new FluidStack[4]; + boolean findRecipe = false; + nextDS:for (ItemStack tDataStick : tDataStickList){ + NBTTagCompound tTag = tDataStick.getTagCompound(); + if (tTag == null) continue; + for (int i = 0; i < 15; i++) { + int count = tTag.getInteger("a"+i); + if (!tTag.hasKey("" + i) && count <= 0) continue; + if (mInputBusses.get(i) == null) { + continue nextDS; + } + + ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); + boolean flag = true; + if (count > 0) { + for (int j = 0; j < count; j++) { + tStack[i] = GT_Utility.loadItem(tTag, "a" + i + ":" + j); + if (tStack[i] == null) continue; + if(GT_Values.D1)System.out.println("Item "+i+" : "+tStack[i].getUnlocalizedName()); + if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { + flag = false; + break; + } + } + } + if (flag) { + tStack[i] = GT_Utility.loadItem(tTag, "" + i); + if (tStack[i] == null) { + flag = false; + continue; + } + if(GT_Values.D1)System.out.println("Item "+i+" : "+tStack[i].getUnlocalizedName()); + if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { + flag = false; + } + } + if(GT_Values.D1) System.out.println(i + (flag ? " not accepted" : " accepted")); + if (flag) continue nextDS; + } + + if(GT_Values.D1)System.out.println("All Items done, start fluid check"); + for (int i = 0; i < 4; i++) { + if (!tTag.hasKey("f" + i)) continue; + tFluids[i] = GT_Utility.loadFluid(tTag, "f" + i); + if (tFluids[i] == null) continue; + if(GT_Values.D1)System.out.println("Fluid "+i+" "+tFluids[i].getUnlocalizedName()); + if (mInputHatches.get(i) == null) { + continue nextDS; + } + FluidStack fluidInHatch = mInputHatches.get(i).mFluid; + if (fluidInHatch == null || !GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) { + if(GT_Values.D1)System.out.println(i+" not accepted"); + continue nextDS; + } + if(GT_Values.D1)System.out.println(i+" accepted"); + } + + if(GT_Values.D1)System.out.println("Input accepted, check other values"); + if (!tTag.hasKey("output")) continue; + mOutputItems = new ItemStack[]{GT_Utility.loadItem(tTag, "output")}; + if (mOutputItems[0] == null || !GT_Utility.isStackValid(mOutputItems[0])) + continue; + + if (!tTag.hasKey("time")) continue; + mMaxProgresstime = tTag.getInteger("time"); + if (mMaxProgresstime <= 0) continue; + + if (!tTag.hasKey("eu")) continue; + mEUt = tTag.getInteger("eu"); + + if(GT_Values.D1)System.out.println("Find avaiable recipe"); + findRecipe = true; + break; + } + if (!findRecipe) return false; + + if(GT_Values.D1)System.out.println("All checked start consuming inputs"); + for (int i = 0; i < 15; i++) { + if (tStack[i] == null) continue; + ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); + stackInSlot.stackSize -= tStack[i].stackSize; + } + + for (int i = 0; i < 4; i++) { + if (tFluids[i] == null) continue; + mInputHatches.get(i).mFluid.amount -= tFluids[i].amount; + if (mInputHatches.get(i).mFluid.amount <= 0) { + mInputHatches.get(i).mFluid = null; + } + } + if(GT_Values.D1)System.out.println("Check overclock"); + + byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (mEUt <= 16) { + this.mEUt = (mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (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); + updateSlots(); + if(GT_Values.D1)System.out.println("Recipe sucessfull"); + return true; + } + + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ); + } + } + + public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 4; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 4; + + // Counts for all Casing Types + int aBaseCasingCount = 0; + int aContainmentCasingCount = 0; + int aShieldingCount = 0; + int aPipeCount = 0; + int aIntegralCasingCount = 0; + int aContainmentChamberCount = 0; + + // Bottom Layer + aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, -7, xDir, zDir); + log("Bottom Layer is Valid. Moving to Layer 1."); + + // Layer 1 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -6, xDir, zDir); + aIntegralCasingCount += checkIntegralRing(aBaseMetaTileEntity, getCasing(0), this.META_IntegralCasing, -6, xDir, zDir); + aContainmentChamberCount += checkContainmentRing(aBaseMetaTileEntity, getCasing(4), this.META_ContainmentChamberCasing, -6, xDir, zDir); + log("Layer 1 is Valid. Moving to Layer 2."); + + // Layer 2 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -5, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -5, xDir, zDir); + log("Layer 2 is Valid. Moving to Layer 3."); + + // Layer 3 + aContainmentCasingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(3), this.META_ContainmentCasing, -4, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -4, xDir, zDir); + log("Layer 3 is Valid. Moving to Layer 4."); + + // Layer 4 + aContainmentCasingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(3), this.META_ContainmentCasing, -3, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -3, xDir, zDir); + log("Layer 4 is Valid. Moving to Layer 5."); + + // Layer 5 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -2, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -2, xDir, zDir); + log("Layer 5 is Valid. Moving to Layer 6."); + + // Layer 6 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -1, xDir, zDir); + aIntegralCasingCount += checkIntegralRing(aBaseMetaTileEntity, getCasing(0), this.META_IntegralCasing, -1, xDir, zDir); + aContainmentChamberCount += checkContainmentRing(aBaseMetaTileEntity, getCasing(4), this.META_ContainmentChamberCasing, -1, xDir, zDir); + log("Layer 6 is Valid. Moving to Top Layer."); + + // Top Layer + aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, 0, xDir, zDir); + + log("Found "+aBaseCasingCount+" "+mCasingName[0]+"s"); + log("Found "+aShieldingCount+" "+mCasingName[4]+"s"); + log("Found "+aPipeCount+" "+mCasingName[1]+"s"); + log("Found "+aContainmentCasingCount+" "+mCasingName[3]+"s"); + log("Found "+aIntegralCasingCount+" "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s"); + log("Found "+aContainmentChamberCount+" "+mCasingName[2]+"s"); + + // Try mesage player + String aOwnerName = this.getBaseMetaTileEntity().getOwnerName(); + EntityPlayer aOwner = null; + if (aOwnerName != null && aOwnerName.length() > 0) { + aOwner = PlayerUtils.getPlayer(aOwnerName); + } + + if (aShieldingCount != 128) { + log("Not enough "+mCasingName[4]+"s, require 128."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[4]+"s, require 128."); + } + return false; + } + if (aPipeCount != 20) { + log("Not enough "+mCasingName[1]+"s, require 20."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[1]+"s, require 20."); + } + return false; + } + if (aContainmentCasingCount != 64) { + log("Not enough "+mCasingName[3]+"s, require 64."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[3]+"s, require 64."); + } + return false; + } + if (aContainmentChamberCount != 42) { + log("Not enough "+mCasingName[2]+"s, require 42."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[2]+"s, require 42."); + } + return false; + } + if (aBaseCasingCount < 140) { + log("Not enough "+mCasingName[0]+"s, require 140 at a minimum."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[0]+"s, require 140 at a minimum."); + } + return false; + } + if (aIntegralCasingCount != 48) { + log("Not enough "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s, require 48."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s, require 48."); + } + return false; + } + log("LNR Formed."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Large Naquadah Reactor has formed successfully."); + } + return true; + } + + public boolean addNaquadahHatchToMachineInput(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); + } + return false; + } + + public int checkEntireLayer(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -4; x < 5; x++) { + for (int z = -4; z < 5; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { + continue; + } + // Skip controller + if (aY == 0 && x == 0 && z == 0) { + continue; + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, true, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + public int checkOuterRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -4; x < 5; x++) { + for (int z = -4; z < 5; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { + continue; + } + + // If we are on the 5x5 ring, proceed + if ((x > -4 && x < 4 ) && (z > -4 && z < 4)) { + if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + } + else { + continue; + } + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + public int checkIntegralRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -3; x < 4; x++) { + for (int z = -3; z < 4; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { + continue; + } + + // If we are on the 5x5 ring, proceed + if ((x > -3 && x < 3 ) && (z > -3 && z < 3)) { + if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + } + else { + continue; + } + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + public int checkPipes(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -1; x < 2; x++) { + for (int z = -1; z < 2; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 1 && z == 1) || (x == -1 && z == -1) || (x == 1 && z == -1) || (x == -1 && z == 1) || (x == 0 && z == 0)) { + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Pipe has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + }; + } + } + } + return aCasingCount; + } + + public int checkContainmentRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -2; x < 3; x++) { + for (int z = -2; z < 3; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { + continue; + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + */ +/** + * @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb + *//* + + private boolean isCorrectDataItem(ItemStack aStack, int state){ + if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, true, true)) return true; + if ((state & 2) != 0 && ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) return true; + if ((state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) return true; + return false; + } + + */ +/** + * @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb + *//* + + public ArrayList<ItemStack> getDataItems(int state) { + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + if (GT_Utility.isStackValid(mInventory[1]) && isCorrectDataItem(mInventory[1], state)) { + rList.add(mInventory[1]); + } + for (GT_MetaTileEntity_Hatch_DataAccess tHatch : mDataAccessHatches) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null + && isCorrectDataItem(tHatch.getBaseMetaTileEntity().getStackInSlot(i), state)) + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } + + public boolean addDataAccessToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); + } + return false; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Assembly Line"; + } + + @Override + public int getMaxParallelRecipes() { + return 0; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java new file mode 100644 index 0000000000..6d8ca49d7d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java @@ -0,0 +1,481 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +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.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; + +public class GregtechMetaTileEntity_Adv_DistillationTower extends GregtechMeta_MultiBlockBase { + + private short mControllerY = 0; + private byte mMode = 0; + private boolean mUpgraded = false; + private IStructureDefinition<GregtechMetaTileEntity_Adv_DistillationTower> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_Adv_DistillationTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_Adv_DistillationTower(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_DistillationTower(this.mName); + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_Adv_DistillationTower> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_Adv_DistillationTower>builder() + .addShape(mName + "bottom", transpose(new String[][]{ + {"I~I", "III", "III"} + })) + .addShape(mName + "mid", transpose(new String[][]{ + {"CCC", "C-C", "CCC"} + })) + .addShape(mName + "top", transpose(new String[][]{ + {"MMM", "MMM", "MMM"} + })) + .addElement( + 'I', + ofHatchAdderOptional( + GregtechMetaTileEntity_Adv_DistillationTower::addAdvDistillationTowerBottomList, getCasingTextureID(), + 1, GregTech_API.sBlockCasings4, 1 + ) + ) + .addElement( + 'C', + ofHatchAdderOptional( + GregtechMetaTileEntity_Adv_DistillationTower::addAdvDistillationTowerMidList, getCasingTextureID(), + 2, GregTech_API.sBlockCasings4, 1 + ) + ) + .addElement( + 'M', + ofHatchAdderOptional( + GregtechMetaTileEntity_Adv_DistillationTower::addAdvDistillationTowerTopList, getCasingTextureID(), + 3, GregTech_API.sBlockCasings4, 1 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addAdvDistillationTowerBottomList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addAdvDistillationTowerMidList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addAdvDistillationTowerTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Advanced Distillation Tower") + .addInfo("T1 and T2 constructed identical to standard DT") + .addInfo("Right click the controller with screwdriver to change mode.") + .addInfo("Max parallel dictated by tower tier and mode") + .addInfo("DTower Mode: T1=4, T2=12") + .addInfo("Distilery Mode: Tower Tier * (4*InputTier)") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addCasingInfo("Clean Stainless Steel Machine Casing", 7) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addOutputHatch("One per layer except bottom", 2) + .addMufflerHatch("Top Center Casing", 3) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + int layer = Math.min(stackSize.stackSize + 2, 12); + buildPiece(mName + "bottom", stackSize, hintsOnly, 1, 0, 0); + for (int i = 1; i < layer - 1; i++) { + buildPiece(mName + "mid", stackSize, hintsOnly, 1, i, 0); + } + buildPiece(mName + "top", stackSize, hintsOnly, 1, layer - 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + if (!checkPiece(mName + "bottom", 1, 0, 0)) + return false; + int layer = 1; + while (checkPiece(mName + "mid", 1, layer, 0)) { + if (layer != mOutputHatches.size()) return false; + layer ++; + } + if (layer > 12 || !checkPiece(mName + "top", 1, layer, 0)) + return false; + return layer == mOutputHatches.size() && checkHatch(); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName()+(mUpgraded ? " T2" : ""), "MultiblockDisplay.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return mMode == 0 ? GT_Recipe.GT_Recipe_Map.sDistillationRecipes : GT_Recipe.GT_Recipe_Map.sDistilleryRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // don't rotate a freaking tower, it won't work + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + if (this.mMode == 1) return CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDistillery; + return CORE.ConfigSwitches.pollutionPerSecondMultiAdvDistillationTower_ModeDT; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mMode", mMode); + aNBT.setInteger("mCasingTier", this.mCasingTier); + aNBT.setBoolean("mUpgraded", mUpgraded); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mMode = aNBT.getByte("mMode"); + mCasingTier = aNBT.getInteger("mCasingTier"); + mUpgraded = aNBT.getBoolean("mUpgraded"); + super.loadNBTData(aNBT); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(203)); + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mMode++; + if (mMode > 1){ + mMode = 0; + PlayerUtils.messagePlayer(aPlayer, "Now running in Distillation Tower Mode."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Now running in Distillery Mode."); + } + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack tLiquid = aLiquid.copy(); + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? tHatch.outputsSteam() : tHatch.outputsLiquids()) { + if (tHatch.getBaseMetaTileEntity().getYCoord() == this.mControllerY + 1) { + int tAmount = tHatch.fill(tLiquid, false); + if (tAmount >= tLiquid.amount) { + return tHatch.fill(tLiquid, true) >= tLiquid.amount; + } else if (tAmount > 0) { + tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); + } + } + } + } + return false; + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length; i++) { + if (mOutputHatches.size() > i && mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity(mOutputHatches.get(i))) { + if (mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord() == this.mControllerY + 1 + i) { + mOutputHatches.get(i).fill(mOutputFluids2[i], true); + } + } + } + + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "DistillationTower"; + } + + @Override + public String getMachineType() { + return "Distillery, Distillation Tower"; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + // Run standard recipe handling for distillery recipes + if (mMode == 1) { + return this.checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 100); + } + else { + for (GT_MetaTileEntity_Hatch_Input hatch : mInputHatches) { + FluidStack tFluid = hatch.getFluid(); + if (tFluid != null) { + int para = (4* GT_Utility.getTier(this.getMaxInputVoltage())); + if (checkRecipeGeneric(null, new FluidStack[]{tFluid}, para,100, 250, 10000)) { + return true; + } + } + } + return false; + } + } + + @Override + public int getMaxParallelRecipes() { + if (this.mMode == 0) { + return getTierOfTower() == 1 ? 4 : getTierOfTower() == 2 ? 12 : 0; + } + else if (this.mMode == 1) { + return getTierOfTower() * (4 * GT_Utility.getTier(this.getMaxInputVoltage())); + } + return 0; + } + + @Override + public int getEuDiscountForParallelism() { + return 15; + } + + private int getTierOfTower() { + return mUpgraded ? 2 : 1; + } + + private int mCasingTier = 0; + + private int getMachineCasingTier() { + return mCasingTier; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + + ITexture aOriginalTexture; + + // Check things exist client side (The worst code ever) + if (aBaseMetaTileEntity.getWorld() != null) { + + } + // Check the Tier Client Side + int aTier = mCasingTier; + + if (aTier == 0) { + aOriginalTexture = Textures.BlockIcons.getCasingTextureForId(49); + } + else if (aTier == 1) { + aOriginalTexture = Textures.BlockIcons.getCasingTextureForId(43); + } + else { + aOriginalTexture = Textures.BlockIcons.getCasingTextureForId(49); + } + + if (aSide == aFacing) { + return new ITexture[]{aOriginalTexture, new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER)}; + } + return new ITexture[]{aOriginalTexture}; + } + + private int getCasingTextureID() { + // Check the Tier Client Side + int aTier = mCasingTier; + + if (aTier == 1) { + return 49; + } + else if (aTier == 2) { + return 43; + } + else { + return 49; + } + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity) { + int aMaxTier = getMachineCasingTier(); + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) { + GT_MetaTileEntity_TieredMachineBlock aMachineBlock = (GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity; + int aTileTier = aMachineBlock.mTier; + if (aTileTier > aMaxTier) { + Logger.INFO("Hatch tier too high."); + return false; + } + else { + return addToMachineList(aTileEntity, getCasingTextureID()); + } + } + else { + Logger.INFO("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. + return false; + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aTick % 20 == 0 && !mUpgraded) { + ItemStack aGuiStack = this.getGUIItemStack(); + if (aGuiStack != null) { + if (GT_Utility.areStacksEqual(aGuiStack, GregtechItemList.Distillus_Upgrade_Chip.get(1))) { + this.mUpgraded = true; + ItemUtils.depleteStack(aGuiStack); + } + } + } + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mCasingTier = getCasingTierOnClientSide(); + } + } + + + + @SideOnly(Side.CLIENT) + private final int getCasingTierOnClientSide() { + if (this == null || this.getBaseMetaTileEntity().getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (aBaseMetaTileEntity == null || aBaseMetaTileEntity.getWorld() == null || aBaseMetaTileEntity.getWorld().getChunkFromBlockCoords(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getZCoord()) == null) { + return 0; + } + for (int i=1;i<10;i++) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, i, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, i, 0); + if (aInitStructureCheck == null) { + continue; + } + if (aInitStructureCheck == GregTech_API.sBlockCasings4 && aInitStructureCheckMeta == 1) { + return 0; + } + else if (aInitStructureCheck == ModBlocks.blockCasingsTieredGTPP) { + return 1; + } + } + } + catch (Throwable t) { + //t.printStackTrace(); + } + return 0; + + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + aNBT.setBoolean("mUpgraded", mUpgraded); + super.setItemNBT(aNBT); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java new file mode 100644 index 0000000000..ce54aef282 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -0,0 +1,484 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentTranslation; +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 gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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 net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase { + + public static int CASING_TEXTURE_ID; + public static String mHotFuelName = "Blazing Pyrotheum"; + public static String mCasingName = "Advanced Blast Furnace Casing"; + public static String mHatchName = "Pyrotheum Hatch"; + private IStructureDefinition<GregtechMetaTileEntity_Adv_EBF> STRUCTURE_DEFINITION = null; + private int mCasing; + private boolean mHaveHatch; + + private HeatingCoilLevel mHeatingCapacity; + private boolean isBussesSeparate = false; + + public GregtechMetaTileEntity_Adv_EBF(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); + mHotFuelName = FluidUtils.getFluidStack("pyrotheum", 1).getLocalizedName(); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 11); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 968); + } + + public GregtechMetaTileEntity_Adv_EBF(String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 11); + mHotFuelName = FluidUtils.getFluidStack("pyrotheum", 1).getLocalizedName(); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 11); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 968); + } + + @Override + public String getMachineType() { + return "Blast Furnace"; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_EBF(this.mName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 11); + } + if (mHotFuelName.toLowerCase().contains(".")) { + mHotFuelName = FluidUtils.getFluidStack("pyrotheum", 1).getLocalizedName(); + } + if (mHatchName.toLowerCase().contains(".name")) { + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 968); + } + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Advanced Blast Furnace") + .addInfo("Speed: 120% | Eu Usage: 90% | Parallel: 8") + .addInfo("Consumes 10L of " + mHotFuelName + " per second during operation") + .addInfo("Constructed exactly the same as a normal EBF") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addController("Bottom center") + .addCasingInfo(mCasingName, 9) + .addInputHatch("Any Casing", 1) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addStructureHint(mHatchName, 1) + .addEnergyHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_Adv_EBF> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_Adv_EBF>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_Adv_EBF::addAdvEBFList, CASING_TEXTURE_ID, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings3Misc, 11 + ) + ) + ) + ) + .addElement( + 'H', + ofCoil( + GregtechMetaTileEntity_Adv_EBF::setCoilLevel, GregtechMetaTileEntity_Adv_EBF::getCoilLevel + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 3, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mHaveHatch = false; + setCoilLevel(HeatingCoilLevel.None); + return checkPiece(mName, 1, 3, 0) && mCasing >= 9 && mHaveHatch && getCoilLevel() != HeatingCoilLevel.None && checkHatch(); + } + + public final boolean addAdvEBFList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 968) { + mHaveHatch = true; + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID), + new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced) }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID) }; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ElectricBlastFurnace"; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBlastRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + if (isBussesSeparate) { + FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList<ItemStack> tInputs = new ArrayList<>(); + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { + tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + if (tInputs.size() > 0) { + if (checkRecipeGeneric(tInputs.toArray(new ItemStack[0]), tFluids, 8, 90, 120, 10000)) { + return true; + } + } + } + return false; + } else { + return checkRecipeGeneric(8, 90, 120); + } + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiAdvEBF; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, + int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { + // 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(); + Logger.WARNING("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = this.getRecipeMap().findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + Logger.WARNING("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null || this.mHeatingCapacity.getHeat() < tRecipe.mSpecialValue) { + Logger.WARNING("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + Logger.WARNING("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + int tHeatCapacityDivTiers = (int) (mHeatingCapacity.getHeat() - tRecipe.mSpecialValue) / 900; + if (tHeatCapacityDivTiers > 0) + tRecipeEUt = (int) (tRecipeEUt * (Math.pow(0.95, tHeatCapacityDivTiers))); + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + // 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)) { + Logger.WARNING("Broke at " + parallelRecipes + "."); + break; + } + Logger.WARNING("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + Logger.WARNING("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); + int tHalfHeatCapacityDivTiers = tHeatCapacityDivTiers / 2; + + 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; + if (tHalfHeatCapacityDivTiers > 0) { + this.mMaxProgresstime = mMaxProgresstime / 4; + tHalfHeatCapacityDivTiers--; + } else { + this.mMaxProgresstime = mMaxProgresstime / 2; + } + if (this.mMaxProgresstime <= 1) { + break; + } + } + } + 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(); + + Logger.WARNING("GOOD RETURN - 1"); + return true; + + } + + private volatile int mGraceTimer = 2; + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + //Try dry Pyrotheum after all other logic + if (this.mStartUpCheck < 0) { + if (this.mMaxProgresstime > 0 && this.mProgresstime != 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (aTick % 10 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + if (!this.depleteInput(FluidUtils.getFluidStack("pyrotheum", 5))) { + if (mGraceTimer-- == 0) { + this.causeMaintenanceIssue(); + this.stopMachine(); + mGraceTimer = 2; + } + } + } + } + } + + } + + @Override + public int getMaxParallelRecipes() { + return 8; + } + + @Override + public int getEuDiscountForParallelism() { + return 90; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + isBussesSeparate = !isBussesSeparate; + aPlayer.addChatMessage(new ChatComponentTranslation(isBussesSeparate ? "interaction.separateBusses.enabled" : "interaction.separateBusses.disabled")); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("isBussesSeparate", isBussesSeparate); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + isBussesSeparate = aNBT.getBoolean("isBussesSeparate"); + super.loadNBTData(aNBT); + } + + public HeatingCoilLevel getCoilLevel() { + return mHeatingCapacity; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + mHeatingCapacity = aCoilLevel; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java new file mode 100644 index 0000000000..56206f8178 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java @@ -0,0 +1,153 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +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.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_FusionComputer; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.block.Block; + +import java.lang.reflect.Method; + +public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_FusionComputer { + + public static final Method mUpdateHatchTexture; + + static { + mUpdateHatchTexture = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); + } + + public GregtechMetaTileEntity_Adv_Fusion_MK4(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 6); + } + + public GregtechMetaTileEntity_Adv_Fusion_MK4(String aName) { + super(aName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Fusion Reactor") + .addInfo("HARNESSING THE POWER OF A NEUTRON STAR") + .addSeparator() + .beginStructureBlock(15, 3, 15, false) + .addController("See diagram when placed") + .addCasingInfo("Fusion Machine Casings MK III", 79) + .addStructureInfo("Cover the coils with casing") + .addOtherStructurePart("Advanced Fusion Coils", "Center part of the ring") + .addEnergyHatch("1-16, Specified casings", 2) + .addInputHatch("2-16, Specified casings", 1) + .addOutputHatch("1-16, Specified casings", 3) + .addStructureInfo("ALL Hatches must be UHV or better") + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public int tier() { + return 9; + } + + @Override + public long maxEUStore() { + return (640010000L * 4) * (Math.min(16, this.mEnergyHatches.size())) / 8L; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_Fusion_MK4(mName); + } + + @Override + public Block getCasing() { + return getFusionCoil(); + } + + @Override + public int getCasingMeta() { + return 12; + } + + @Override + public Block getFusionCoil() { + return ModBlocks.blockCasings3Misc; + } + + @Override + public int getFusionCoilMeta() { + return 13; + } + + @Override + public int tierOverclock() { + return 8; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + ITexture[] sTexture; + if (aSide == aFacing) { + sTexture = new ITexture[]{ + new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, + Dyes.getModulation(-1, Dyes._NULL.mRGBa)), + new GT_RenderedTexture(this.getIconOverlay())}; + } else if (!aActive) { + sTexture = new ITexture[]{ + new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, + Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; + } else { + sTexture = new ITexture[]{ + new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_FUSION_CASING_ULTRA, + Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; + } + return sTexture; + } + + @Override + public ITexture getTextureOverlay() { + return new GT_RenderedTexture(this.mMaxProgresstime > 0 ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1); + } + + public IIconContainer getIconOverlay() { + return this.mMaxProgresstime > 0 ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1; + } + + public boolean turnCasingActive(final boolean status) { + try { + if (this.mEnergyHatches != null) { + for (final GT_MetaTileEntity_Hatch_Energy hatch : this.mEnergyHatches) { + mUpdateHatchTexture.invoke(hatch, (status ? TAE.getIndexFromPage(2, 14) : 53)); + } + } + if (this.mOutputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Output hatch2 : this.mOutputHatches) { + mUpdateHatchTexture.invoke(hatch2, (status ? TAE.getIndexFromPage(2, 14) : 53)); + } + } + if (this.mInputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Input hatch3 : this.mInputHatches) { + mUpdateHatchTexture.invoke(hatch3, (status ? TAE.getIndexFromPage(2, 14) : 53)); + } + } + } + catch (Throwable t) { + return false; + } + return true; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java new file mode 100644 index 0000000000..aff614184a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java @@ -0,0 +1,207 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.GregTech_API.sBlockCasings4; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_Adv_Implosion +extends GregtechMeta_MultiBlockBase { + + private String mCasingName; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_Adv_Implosion> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_Adv_Implosion(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + mCasingName = ItemList.Casing_RobustTungstenSteel.get(1).getDisplayName(); + } + + public GregtechMetaTileEntity_Adv_Implosion(String aName) { + super(aName); + mCasingName = ItemList.Casing_RobustTungstenSteel.get(1).getDisplayName(); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Adv_Implosion(this.mName); + } + + @Override + public String getMachineType() { + return "Implosion Compressor"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + if (mCasingName.contains("gt.blockcasings")) { + mCasingName = ItemList.Casing_RobustTungstenSteel.get(1).getDisplayName(); + } + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Factory Grade Advanced Implosion Compressor") + .addInfo("Speed: 100% | Eu Usage: 100% | Parallel: ((Tier/2)+1)") + .addInfo("Constructed exactly the same as a normal Implosion Compressor") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo(mCasingName, 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_Adv_Implosion> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_Adv_Implosion>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_Adv_Implosion::addAdvImplosionList, 48, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + sBlockCasings4, 0 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addAdvImplosionList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(48), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(48)}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ImplosionCompressor"; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sImplosionRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric((GT_Utility.getTier(this.getMaxInputVoltage())/2+1), 100, 100); + } + + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public String getSound() { + return (String) GregTech_API.sSoundList.get(Integer.valueOf(5)); + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiAdvImplosion; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return (GT_Utility.getTier(this.getMaxInputVoltage())/2+1); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java new file mode 100644 index 0000000000..3191f56889 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/GregtechMetaTileEntity_SteamMacerator.java @@ -0,0 +1,165 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.GregTech_API.sBlockCasings1; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusInput; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusOutput; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_SteamMultiBase; +import net.minecraft.item.ItemStack; + +public class GregtechMetaTileEntity_SteamMacerator extends GregtechMeta_SteamMultiBase { + + private String mCasingName = "Bronze Plated Bricks"; + private IStructureDefinition<GregtechMetaTileEntity_SteamMacerator> STRUCTURE_DEFINITION = null; + private int mCasing; + + public GregtechMetaTileEntity_SteamMacerator(String aName) { + super(aName); + } + + public GregtechMetaTileEntity_SteamMacerator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity arg0) { + return new GregtechMetaTileEntity_SteamMacerator(this.mName); + } + + @Override + protected GT_RenderedTexture getFrontOverlay() { + return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR); + } + + @Override + protected GT_RenderedTexture getFrontOverlayActive() { + return new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_MACERATOR_ACTIVE); + } + + @Override + public String getMachineType() { + return "Macerator"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + if (mCasingName.contains("gt.blockcasings")) { + mCasingName = ItemList.Casing_BronzePlatedBricks.get(1).getDisplayName(); + } + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Steam Macerator") + .addInfo("Macerates " + getMaxParallelRecipes() + " ores at a time") + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo(mCasingName, 14) + .addStructureHint("Input Bus (Steam)", 1) + .addStructureHint("Output Bus (Steam)", 1) + .addStructureHint("Steam Hatch", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_SteamMacerator> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_SteamMacerator>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_SteamMacerator::addSteamMaceratorList, 10, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + sBlockCasings1, 10 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addSteamMaceratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_CustomFluidBase && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileID() == 31040){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusInput){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Steam_BusOutput){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + fixAllMaintenanceIssue(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 14; + } + + @Override + public int getMaxParallelRecipes() { + return 8; + } + + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + } + + @Override + public ItemStack[] getOutputItems(GT_Recipe aRecipe) { + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[1]; + for (int h = 0; h < 1; h++) { + if (aRecipe.getOutput(h) != null) { + tOutputItems[h] = aRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + return tOutputItems; + } + + @Override + public int getOutputCount(ItemStack[] aOutputs) { + return 1; + } + + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java new file mode 100644 index 0000000000..eae51e5c1d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java @@ -0,0 +1,656 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.lang.reflect.Field; +import java.util.ArrayList; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.helpers.CraftingHelper; +import gtPlusPlus.xmod.gregtech.common.helpers.autocrafter.AC_Helper_Utils; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { + + private MODE mMachineMode = MODE.ASSEMBLY; + private byte mTier = 1; + protected GT_Recipe mLastRecipeToBuffer; + private int mCasing; + private IStructureDefinition<GT4Entity_AutoCrafter> STRUCTURE_DEFINITION = null; + + /** The crafting matrix inventory (3x3). */ + public CraftingHelper mInventoryCrafter; + + public static enum MODE { + CRAFTING("CIRCUIT", "ASSEMBLY"), ASSEMBLY("CRAFTING", "DISASSEMBLY"), DISASSEMBLY("ASSEMBLY", "CIRCUIT"), CIRCUIT("DISASSEMBLY", "CRAFTING"); + + private final String lastMode; + private final String nextMode; + + MODE(String previous, String next) { + this.lastMode = previous; + this.nextMode = next; + } + + public MODE nextMode() { + return MODE.valueOf(this.nextMode); + } + + public MODE lastMode() { + return MODE.valueOf(this.lastMode); + } + + } + + public void onRightclick(EntityPlayer aPlayer) { + } + + public GT4Entity_AutoCrafter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT4Entity_AutoCrafter(String mName) { + super(mName); + } + + @Override + public String getMachineType() { + String sType = "Assembler, Disassembler, "+((CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) ? "Circuit Assembler" : ""); + return sType; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_AutoCrafter(this.mName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + return super.onRunningTick(aStack); + //return true; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiAutoCrafter; + } + + public int getAmountOfOutputs() { + return 1; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Highly Advanced Autocrafter") + .addInfo("Right Click with a Screwdriver to change mode") + .addInfo("200% faster than using single block machines of the same voltage") + .addInfo("Processes two items per voltage tier") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Autocrafter Frame", 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(0, 10)), + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE + : Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER) }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(0, 10)) }; + } + + @Override + public IStructureDefinition<GT4Entity_AutoCrafter> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GT4Entity_AutoCrafter>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GT4Entity_AutoCrafter::addAutoCrafterList, TAE.getIndexFromPage(0, 10), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 12 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + if (checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch()) { + setTier(); + return true; + } else return false; + } + + public final boolean addAutoCrafterList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + private static GT_Recipe_Map fCircuitMap; + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (this.mMachineMode == MODE.ASSEMBLY) { + return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; + } + else if (this.mMachineMode == MODE.CIRCUIT && !CORE.GTNH) { + if (fCircuitMap != null) { + return fCircuitMap; + } + GT_Recipe_Map r; + try { + Field f = ReflectionUtils.getField(GT_Recipe.GT_Recipe_Map.class, "sCircuitAssemblerRecipes"); + if (f != null) { + r = (GT_Recipe_Map) f.get(null); + if (r != null) { + fCircuitMap = r; + return r; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + else if (this.mMachineMode == MODE.DISASSEMBLY || this.mMachineMode == MODE.CRAFTING) { + return null; + } + return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; + } + + private boolean isModernGT = true; + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (isModernGT && !CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + isModernGT = false; + } + //5.09 support + if (isModernGT && !CORE.GTNH) { + mMachineMode = mMachineMode.nextMode(); + if (mMachineMode == MODE.CRAFTING) { + PlayerUtils.messagePlayer(aPlayer, "Running the Auto-Crafter in mode: "+EnumChatFormatting.AQUA+"AutoCrafting"); + } else if (mMachineMode == MODE.ASSEMBLY) { + PlayerUtils.messagePlayer(aPlayer, "Running the Auto-Crafter in mode: "+EnumChatFormatting.GREEN+"Assembly"); + } else if (mMachineMode == MODE.DISASSEMBLY) { + PlayerUtils.messagePlayer(aPlayer, "Running the Auto-Crafter in mode: "+EnumChatFormatting.RED+"Disassembly"); + } else { + PlayerUtils.messagePlayer(aPlayer, "Running the Auto-Crafter in mode: "+EnumChatFormatting.YELLOW+"Circuit Assembly"); + } + } + //5.08 support + else { + if (mMachineMode.nextMode() == MODE.CIRCUIT) { + mMachineMode = MODE.ASSEMBLY; + } + else if (mMachineMode.nextMode() == MODE.CRAFTING) { + mMachineMode = MODE.ASSEMBLY; + } + else { + mMachineMode = mMachineMode.nextMode(); + } + + if (mMachineMode == MODE.CRAFTING) { + PlayerUtils.messagePlayer(aPlayer, "You are now running the Auto-Crafter in mode: "+EnumChatFormatting.AQUA+"AutoCrafting"); + } else if (mMachineMode == MODE.ASSEMBLY) { + PlayerUtils.messagePlayer(aPlayer, "You are now running the Auto-Crafter in mode: "+EnumChatFormatting.GREEN+"Assembly"); + } else { + PlayerUtils.messagePlayer(aPlayer, "You are now running the Auto-Crafter in mode: "+EnumChatFormatting.RED+"Disassembly"); + } + } + } + +// @Override +// public boolean checkRecipe(final ItemStack aStack) { +// +// final long tVoltage = this.getMaxInputVoltage(); +// final byte tTier = this.mTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); +// +// if (mMachineMode == MODE.DISASSEMBLY) { +// return doDisassembly(); +// } else if (mMachineMode == MODE.CRAFTING) { +// return doCrafting(aStack); +// } else { +// return super.checkRecipeGeneric(getMaxParallelRecipes(), 100, 200); +// } +// } + + private void setTier() { + long tVoltage = getMaxInputVoltage(); + this.mTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + if (mMachineMode == MODE.DISASSEMBLY) { + return doDisassembly(); + } else if (mMachineMode == MODE.CRAFTING) { + return doCrafting(aStack); + } else { + ArrayList<FluidStack> tFluids = getStoredFluids(); + //Logger.MACHINE_INFO("1"); + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); + //Logger.MACHINE_INFO("2"); + if (isValidMetaTileEntity(tBus)) { + //Logger.MACHINE_INFO("3"); + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) + tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + + Object[] tempArray = tFluids.toArray(new FluidStack[] {}); + FluidStack[] properArray; + properArray = ((tempArray != null && tempArray.length > 0) ? (FluidStack[]) tempArray : new FluidStack[] {}); + + //Logger.MACHINE_INFO("4"); + if (checkRecipeGeneric(tBusItems.toArray(new ItemStack[]{}), properArray, + getMaxParallelRecipes(), 100, 200, 10000)) return true; + } + return false; + } + } + + @Override + public int getMaxParallelRecipes() { + return 2 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + public boolean doDisassembly() { + + final ArrayList<ItemStack> tInputList = this.getStoredInputs(); + for (int tInputList_sS = tInputList.size(), i = 0; i < tInputList_sS - 1; ++i) { + for (int j = i + 1; j < tInputList_sS; ++j) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize < tInputList.get(j).stackSize) { + tInputList.remove(i--); + tInputList_sS = tInputList.size(); + break; + } + tInputList.remove(j--); + tInputList_sS = tInputList.size(); + } + } + } + final ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); + + ItemStack inputItem = tInputs[0]; + if (tInputs[0].stackSize <= 0) { + tInputs[0] = null; + this.updateSlots(); + } + int outputSlots = this.mOutputBusses.get(0).getSizeInventory(); + + if (this.mOutputBusses.size() > 1) { + outputSlots = 0; + for (GT_MetaTileEntity_Hatch_OutputBus r : this.mOutputBusses) { + outputSlots += r.getSizeInventory(); + } + } + + this.mOutputItems = new ItemStack[outputSlots]; + if (inputItem != null && inputItem.stackSize > 0) { + NBTTagCompound tNBT = inputItem.getTagCompound(); + if (tNBT != null) { + tNBT = tNBT.getCompoundTag("GT.CraftingComponents"); + if (tNBT != null) { + this.mEUt = 16 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + this.mMaxProgresstime = (100 - (8 * this.mTier)); + for (int i = 0; i < this.mOutputItems.length; ++i) { + if (this.getBaseMetaTileEntity().getRandomNumber(100) < 60 + 12 * this.mTier) { + this.mOutputItems[i] = GT_Utility.loadItem(tNBT, "Ingredient." + i); + if (this.mOutputItems[i] != null) { + this.mMaxProgresstime *= (int) 1.5; + } + } + } + + if (this.mTier > 5) { + this.mMaxProgresstime >>= this.mTier - 5; + } + if (this.mEUt > 0) + this.mEUt = (-this.mEUt); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + inputItem.stackSize--; + if (inputItem.stackSize <= 0) { + tInputs[0] = null; + } + this.updateSlots(); + return true; + + } + } + } + return false; + } + + private boolean doesCrafterHave9SlotInput() { + GT_MetaTileEntity_Hatch_InputBus craftingInput = null; + if (!this.mInputBusses.isEmpty()) { + for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses) { + if (x.mInventory.length == 9) { + craftingInput = x; + } + } + } + // Return if no input hatch set. + if (craftingInput == null) { + Logger.WARNING("Cannot do Auto-Crafting without a 9-slot Input Bus [MV]."); + return false; + + } else { + return true; + } + } + + private boolean doCrafting(ItemStack aStack) { + this.mMaxProgresstime = 0; + return false; // do nothing + /* + try { + // Set Crafting input hatch + if (!doesCrafterHave9SlotInput()) { + return false; + } + + // Read stored data from encrypted data stick. + ItemStack storedData_Output[] = NBTUtils.readItemsFromNBT(aStack, "Output"); + ItemStack storedData_Input[] = NBTUtils.readItemsFromNBT(aStack); + if (storedData_Output != null && storedData_Input != null) { + ItemStack loadedData[] = new ItemStack[9]; + if (storedData_Input.length >= 1) { + int number = 0; + for (ItemStack a : storedData_Input) { + if (a.getItem() == ModItems.ZZZ_Empty) { + // Utils.LOG_WARNING("Allocating free memory into crafting manager slot + // "+number+"."); + loadedData[number] = null; + } else { + // Utils.LOG_WARNING("Downloading "+a.getDisplayName()+" into crafting manager + // slot "+number+"."); + loadedData[number] = a; + } + number++; + } + } + + // Remove inputs here + ArrayList<ItemStack> mInputArray = new ArrayList<ItemStack>(); + ItemStack allInputs[]; + + for (GT_MetaTileEntity_Hatch_InputBus x : this.mInputBusses) { + if (x.mInventory.length > 0) { + for (ItemStack r : x.mInventory) { + if (r != null) { + mInputArray.add(r); + } + } + } + } + + if (mInputArray.isEmpty()) { + return false; + } else { + List<ItemStack> list = mInputArray; + allInputs = list.toArray(new ItemStack[list.size()]); + + if (allInputs != null && allInputs.length > 0) { + + this.mEUt = 8 * (1 << this.mTier - 1) * (1 << this.mTier - 1); + this.mMaxProgresstime = MathUtils.roundToClosestInt((50 - (5 + * MathUtils.randDouble(((this.mTier - 2) <= 0 ? 1 : (this.mTier - 2)), this.mTier)))); + + Logger.WARNING("MPT: " + mMaxProgresstime + " | " + mEUt); + this.getBaseMetaTileEntity().setActive(true); + + // Setup some vars + int counter = 0; + + ItemStack toUse[] = new ItemStack[9]; + + outerloop: for (ItemStack inputItem : loadedData) { + if (inputItem == null) { + toUse[counter] = null; + continue outerloop; + } + for (ItemStack r : allInputs) { + if (r != null) { + // Utils.LOG_WARNING("Input Bus Inventory Iteration - Found:" + // +r.getDisplayName()+" | "+allInputs.length); + if (GT_Utility.areStacksEqual(r, inputItem)) { + if (this.getBaseMetaTileEntity().isServerSide()) { + toUse[counter] = inputItem; + counter++; + continue outerloop; + } + + } + } + } + counter++; + } + + int mCorrectInputs = 0; + for (ItemStack isValid : toUse) { + if (isValid == null || this.depleteInput(isValid)) { + mCorrectInputs++; + } else { + Logger.WARNING("Input in Slot " + mCorrectInputs + " was not valid."); + } + } + + if (this.mTier > 5) { + this.mMaxProgresstime >>= this.mTier - 5; + } + if (this.mEUt > 0) + this.mEUt = (-this.mEUt); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + if (mCorrectInputs == 9) { + ItemStack mOutputItem = storedData_Output[0]; + NBTUtils.writeItemsToGtCraftingComponents(mOutputItem, loadedData, true); + this.addOutput(mOutputItem); + this.updateSlots(); + return true; + } else { + return false; + } + + } + } + } + } + // End Debug + catch (Throwable t) { + t.printStackTrace(); + this.mMaxProgresstime = 0; + } + + this.mMaxProgresstime = 0; + return false; + */ + } + + @Override + public String[] getExtraInfoData() { + final String tRunning = (this.mMaxProgresstime > 0 ? "Auto-Crafter running" : "Auto-Crafter stopped"); + final String tMaintainance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintainance issues" + : "Needs Maintainance"); + String tSpecialText = "" + (60 + 12 * this.mTier) + "% chance to recover disassembled parts."; + String tMode; + if (mMachineMode == MODE.DISASSEMBLY) { + tMode = "§cDisassembly"; + tSpecialText = "" + (60 + 12 * this.mTier) + "% chance to recover disassembled parts."; + } else if (mMachineMode == MODE.ASSEMBLY || mMachineMode == MODE.CIRCUIT) { + tMode = mMachineMode == MODE.ASSEMBLY ? "§aAssembly" : "§eCircuit Assembly"; + if (mLastRecipeToBuffer != null && mLastRecipeToBuffer.mOutputs[0].getDisplayName() != null) { + tSpecialText = "Currently processing: " + mLastRecipeToBuffer.mOutputs[0].getDisplayName(); + } else { + tSpecialText = "Currently processing: Nothing"; + } + } else { + tMode = "§dAuto-Crafting"; + tSpecialText = "Does Auto-Crafter have 9-slot input bus? " + doesCrafterHave9SlotInput(); + } + + return new String[] { "Large Scale Auto-Asesembler v1.01c", tRunning, tMaintainance, "Mode: " + tMode, + tSpecialText }; + } + + private String getMode() { + return this.mMachineMode.name(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + String mMode = getMode(); + aNBT.setString("mMode", mMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + String modeString = aNBT.getString("mMode"); + MODE newMode = MODE.valueOf(modeString); + this.mMachineMode = newMode; + super.loadNBTData(aNBT); + } + + @Override + public void explodeMultiblock() { + AC_Helper_Utils.removeCrafter(this); + super.explodeMultiblock(); + } + + @Override + public void onExplosion() { + AC_Helper_Utils.removeCrafter(this); + super.onExplosion(); + } + + @Override + public void onRemoval() { + AC_Helper_Utils.removeCrafter(this); + super.onRemoval(); + } + + @Override + public void doExplosion(long aExplosionPower) { + AC_Helper_Utils.removeCrafter(this); + super.doExplosion(aExplosionPower); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "Generic3By3"; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java new file mode 100644 index 0000000000..65474d38ed --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java @@ -0,0 +1,354 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +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.MetaTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.*; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.general.ItemLavaFilter; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GT4Entity_ThermalBoiler +extends GregtechMeta_MultiBlockBase +{ + private int mCasing; + private IStructureDefinition<GT4Entity_ThermalBoiler> STRUCTURE_DEFINITION = null; + private int mSuperEfficencyIncrease = 0; + + public void onRightclick(EntityPlayer aPlayer) + { + getBaseMetaTileEntity().openGUI(aPlayer, 158); + } + + public GT4Entity_ThermalBoiler(int aID, String aName, String aNameRegional) + { + super(aID, aName, aNameRegional); + } + + public GT4Entity_ThermalBoiler(String mName) { + super(mName); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GT4Entity_ThermalBoiler(this.mName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) + { + return true; + } + + @Override + public String getMachineType() { + return "Boiler"; + } + + @Override + public int getDamageToComponent(ItemStack aStack){ + //log("Trying to damage component."); + return ItemList.Component_LavaFilter.get(1L).getClass().isInstance(aStack) ? 1 : 0; + } + + private static Item mLavaFilter; + + @Override + public boolean checkRecipe(ItemStack aStack) { + this.mSuperEfficencyIncrease=0; + + if (mLavaFilter == null) { + mLavaFilter = ItemList.Component_LavaFilter.getItem(); + } + + //Try reload new Lava Filter + if (aStack == null) { + ItemStack uStack = this.findItemInInventory(mLavaFilter); + if (uStack != null) { + this.setGUIItemStack(uStack); + aStack = this.getGUIItemStack(); + } + } + + + for (GT_Recipe tRecipe : GTPP_Recipe.GTPP_Recipe_Map.sThermalFuels.mRecipeList) { + FluidStack tFluid = tRecipe.mFluidInputs[0]; + if (tFluid != null) { + if (depleteInput(tFluid)) { + this.mMaxProgresstime = Math.max(1, runtimeBoost(tRecipe.mSpecialValue * 2)); + this.mEUt = getEUt(); + this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); + + int loot_MAXCHANCE = 100000; + if (mLavaFilter.getClass().isInstance(aStack.getItem())) { + + if ((tRecipe.getOutput(0) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(0))) { + this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(0) }) }; + } + if ((tRecipe.getOutput(1) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(1))) { + this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(1) }) }; + } + if ((tRecipe.getOutput(2) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(2))) { + this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(2) }) }; + } + if ((tRecipe.getOutput(3) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(3))) { + this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(3) }) }; + } + if ((tRecipe.getOutput(4) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(4))) { + this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(4) }) }; + } + if ((tRecipe.getOutput(5) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(5))) { + this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(5) }) }; + } + + } + //Give Obsidian without Lava Filter + if (tFluid.isFluidEqual(GT_ModHandler.getLava(86))){ + if ((tRecipe.getOutput(6) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(6))) { + this.mOutputItems = new ItemStack[] { GT_Utility.copy(new Object[] { tRecipe.getOutput(6) }) }; + } + } + + + return true; + } + } + } + this.mMaxProgresstime = 0; + this.mEUt = 0; + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mEUt > 0) { + if(this.mSuperEfficencyIncrease>0){ + this.mEfficiency = Math.min(10000, this.mEfficiency + this.mSuperEfficencyIncrease); + } + int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); + if (tGeneratedEU > 0) { + long amount = (tGeneratedEU + 160) / 160; + if (depleteInput(Materials.Water.getFluid(amount)) || depleteInput(GT_ModHandler.getDistilledWater(amount))) { + addOutput(GT_ModHandler.getSteam(tGeneratedEU)); + } else { + explodeMultiblock(); + } + } + return true; + } + return true; + } + + public int getEUt() { + return 400; + } + + public int getEfficiencyIncrease() { + return 12; + } + + int runtimeBoost(int mTime) { + return mTime * 150 / 100; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) + { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) + { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) + { + return CORE.ConfigSwitches.pollutionPerSecondMultiThermalBoiler; + } + + public int getAmountOfOutputs() + { + return 7; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Thermal Boiler Controller") + .addInfo("Converts Water & Heat into Steam") + .addInfo("Consult user manual for more information") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Thermal Containment Casings", 10) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(1)), + new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(1))}; + } + + @Override + public IStructureDefinition<GT4Entity_ThermalBoiler> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GT4Entity_ThermalBoiler>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GT4Entity_ThermalBoiler::addThermalBoilerList, TAE.getIndexFromPage(0, 1), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 11 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 && checkHatch(); + } + + public final boolean addThermalBoilerList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public void damageFilter(){ + ItemStack filter = this.mInventory[1]; + if (filter != null){ + if (filter.getItem() instanceof ItemLavaFilter){ + + long currentUse = ItemLavaFilter.getFilterDamage(filter); + + //Remove broken Filter + if (currentUse >= 100-1){ + this.mInventory[1] = null; + } + else { + //Do Damage + ItemLavaFilter.setFilterDamage(filter, currentUse+1); + } + } + } + + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()){ + // Reload Lava Filter + if (this.getGUIItemStack() == null) { + if (this.mInputBusses.size() > 0) { + for (GT_MetaTileEntity_Hatch_InputBus aBus : this.mInputBusses) { + for (ItemStack aStack : aBus.mInventory) { + if (aStack != null && aStack.getItem() instanceof ItemLavaFilter) { + this.setGUIItemStack(aStack); + } + } + } + } + } + + if (this.mEUt > 0){ + if (aTick % 600L == 0L){ + damageFilter(); + } + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "Generic3By3"; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java new file mode 100644 index 0000000000..326cc01de7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java @@ -0,0 +1,744 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +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_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Triplet; +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.GT_MetaTileEntity_Hatch_ElementalDataOrbHolder; +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.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase { + + private int mSolidCasingTier = 0; + private int mMachineCasingTier = 0; + private int mPipeCasingTier = 0; + private int mCoilTier = 0; + private int checkCoil; + private int[] checkCasing = new int[8]; + private int checkMachine; + private int checkPipe; + private int maxTierOfHatch; + private int mCasing; + private IStructureDefinition<GregtechMTE_ElementalDuplicator> STRUCTURE_DEFINITION = null; + + private ArrayList<GT_MetaTileEntity_Hatch_ElementalDataOrbHolder> mReplicatorDataOrbHatches = new ArrayList<GT_MetaTileEntity_Hatch_ElementalDataOrbHolder>(); + + private static final HashMap<Integer, Triplet<Block, Integer, Integer>> mTieredBlockRegistry = new HashMap<Integer, Triplet<Block, Integer, Integer>>(); + + public GregtechMTE_ElementalDuplicator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_ElementalDuplicator(final String aName) { + super(aName); + } + + public static boolean registerMachineCasingForTier(int aTier, Block aBlock, int aMeta, int aCasingTextureID) { + int aSize = mTieredBlockRegistry.size(); + int aSize2 = aSize; + Triplet<Block, Integer, Integer> aCasingData = new Triplet<Block, Integer, Integer>(aBlock, aMeta, aCasingTextureID); + if (mTieredBlockRegistry.containsKey(aTier)) { + CORE.crash("Tried to register a Machine casing for tier "+aTier+" to the Chemical Plant, however this tier already contains one."); + } + mTieredBlockRegistry.put(aTier, aCasingData); + aSize = mTieredBlockRegistry.size(); + return aSize > aSize2; + } + + private static int getCasingTextureIdForTier(int aTier) { + if (!mTieredBlockRegistry.containsKey(aTier)) { + return 10; + } + int aCasingID = mTieredBlockRegistry.get(aTier).getValue_3(); + //Logger.INFO("Found casing texture ID "+aCasingID+" for tier "+aTier); + return aCasingID; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_ElementalDuplicator(this.mName); + } + + @Override + public String getMachineType() { + return "Replicator"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Industrial Replication Machine") + .addInfo("Now replication is less painful") + .addInfo("Please read to user manual for more information on construction & usage") + .addSeparator() + .addController("Bottom Center") + .addStructureHint("Catalyst Housing", 1) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addOutputHatch("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + public void setMachineMeta(int meta) { + checkMachine = meta; + } + + public int getMachineMeta() { + return checkMachine; + } + + public void setPipeMeta(int meta) { + checkPipe = meta; + } + + public int getPipeMeta() { + return checkPipe; + } + + public void setCoilMeta(int meta) { + checkCoil = meta; + } + + public int getCoilMeta() { + return checkCoil; + } + + public int coilTier(int meta) { + switch (meta) { + case 0: return 1; + case 1: return 2; + case 2: return 3; + case 3: return 4; + case 4: return 5; + case 5: return 7; + case 6: return 8; + case 7: return 10; + case 8: return 11; + case 9: return 6; + case 10: return 9; + } + return 0; + } + + @Override + public IStructureDefinition<GregtechMTE_ElementalDuplicator> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMTE_ElementalDuplicator>builder() + .addShape(mName, transpose(new String[][]{ + {"XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX"}, + {"X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X"}, + {"X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X"}, + {"X X", " ", " HHH ", " HHH ", " HHH ", " ", "X X"}, + {"X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X"}, + {"X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X"}, + {"CCC~CCC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CCCCCCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMTE_ElementalDuplicator::addChemicalPlantList, getCasingTextureID(), 1 + ), + onElementPass( + x -> {++x.checkCasing[0]; ++x.mCasing;}, + ofSolidCasing(0) + ), + onElementPass( + x -> {++x.checkCasing[1]; ++x.mCasing;}, + ofSolidCasing(1) + ), + onElementPass( + x -> {++x.checkCasing[2]; ++x.mCasing;}, + ofSolidCasing(2) + ), + onElementPass( + x -> {++x.checkCasing[3]; ++x.mCasing;}, + ofSolidCasing(3) + ), + onElementPass( + x -> {++x.checkCasing[4]; ++x.mCasing;}, + ofSolidCasing(4) + ), + onElementPass( + x -> {++x.checkCasing[5]; ++x.mCasing;}, + ofSolidCasing(5) + ), + onElementPass( + x -> {++x.checkCasing[6]; ++x.mCasing;}, + ofSolidCasing(6) + ), + onElementPass( + x -> {++x.checkCasing[7]; ++x.mCasing;}, + ofSolidCasing(7) + ) + ) + ) + .addElement( + 'X', + ofChain( + onElementPass( + x -> {++x.checkCasing[0]; ++x.mCasing;}, + ofSolidCasing(0) + ), + onElementPass( + x -> {++x.checkCasing[1]; ++x.mCasing;}, + ofSolidCasing(1) + ), + onElementPass( + x -> {++x.checkCasing[2]; ++x.mCasing;}, + ofSolidCasing(2) + ), + onElementPass( + x -> {++x.checkCasing[3]; ++x.mCasing;}, + ofSolidCasing(3) + ), + onElementPass( + x -> {++x.checkCasing[4]; ++x.mCasing;}, + ofSolidCasing(4) + ), + onElementPass( + x -> {++x.checkCasing[5]; ++x.mCasing;}, + ofSolidCasing(5) + ), + onElementPass( + x -> {++x.checkCasing[6]; ++x.mCasing;}, + ofSolidCasing(6) + ), + onElementPass( + x -> {++x.checkCasing[7]; ++x.mCasing;}, + ofSolidCasing(7) + ) + ) + ) + .addElement( + 'M', + addTieredBlock( + GregTech_API.sBlockCasings1, GregtechMTE_ElementalDuplicator::setMachineMeta, GregtechMTE_ElementalDuplicator::getMachineMeta, 10 + ) + ) + .addElement( + 'H', + addTieredBlock( + GregTech_API.sBlockCasings5, GregtechMTE_ElementalDuplicator::setCoilMeta, GregtechMTE_ElementalDuplicator::getCoilMeta, 11 + ) + ) + .addElement( + 'P', + addTieredBlock( + GregTech_API.sBlockCasings2, GregtechMTE_ElementalDuplicator::setPipeMeta, GregtechMTE_ElementalDuplicator::getPipeMeta, 12, 16 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public static <T> IStructureElement<T> ofSolidCasing(int aIndex) { + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + Block target = mTieredBlockRegistry.get(aIndex).getValue_1(); + int targetMeta = mTieredBlockRegistry.get(aIndex).getValue_2(); + return target.equals(block) && meta == targetMeta; + } + + int getIndex(int size) { + if (size > 8) size = 8; + return size - 1; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2()); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return world.setBlock(x, y, z, mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2(), 3); + } + }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 3, 6, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + for (int i = 0; i < 8; i++) { + checkCasing[i] = 0; + } + checkCoil = 0; + checkPipe = 0; + checkMachine = 0; + mSolidCasingTier = 0; + mMachineCasingTier = 0; + mPipeCasingTier = 0; + mCoilTier = 0; + mReplicatorDataOrbHatches.clear(); + if (checkPiece(mName, 3, 6, 0) && mCasing >= 80) { + for (int i = 0; i < 8; i++) { + if (checkCasing[i] == mCasing) { + mSolidCasingTier = i; + } + else if (checkCasing[i] > 0) + return false; + } + mMachineCasingTier = checkMachine - 1; + mPipeCasingTier = checkPipe - 12; + mCoilTier = coilTier(checkCoil - 1); + updateHatchTexture(); + return mMachineCasingTier >= maxTierOfHatch; + } + return false; + } + + public void updateHatchTexture() { + for (GT_MetaTileEntity_Hatch h : mReplicatorDataOrbHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mInputBusses) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mMaintenanceHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mEnergyHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mOutputBusses) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mInputHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); + } + + public final boolean addChemicalPlantList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ElementalDataOrbHolder){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + + ITexture aOriginalTexture; + + // Check things exist client side (The worst code ever) + if (aBaseMetaTileEntity.getWorld() != null) { + + } + int aCasingID = getCasingTextureID(); + aOriginalTexture = Textures.BlockIcons.getCasingTextureForId(aCasingID); + + if (aSide == aFacing) { + return new ITexture[]{aOriginalTexture, new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{aOriginalTexture}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList.size() == 0) { + generateRecipes(); + } + return GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT; + } + + public static void generateRecipes() { + for (GT_Recipe i : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList) { + GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.add(i); + } + } + + @Override + public int getMaxParallelRecipes() { + return 2 * getPipeCasingTier(); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + private int getSolidCasingTier() { + return this.mSolidCasingTier; + } + + private int getMachineCasingTier() { + return mMachineCasingTier; + } + + private int getPipeCasingTier() { + return mPipeCasingTier; + } + + private int getCasingTextureID() { + // Check the Tier Client Side + int aTier = mSolidCasingTier; + int aCasingID = getCasingTextureIdForTier(aTier); + return aCasingID; + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity) { + int aMaxTier = getMachineCasingTier(); + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) { + GT_MetaTileEntity_TieredMachineBlock aMachineBlock = (GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity; + int aTileTier = aMachineBlock.mTier; + if (aTileTier > aMaxTier) { + log("Hatch tier too high."); + return false; + } + else { + return addToMachineList(aTileEntity, getCasingTextureID()); + } + } + else { + log("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. + return false; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mSolidCasingTier", this.mSolidCasingTier); + aNBT.setInteger("mMachineCasingTier", this.mMachineCasingTier); + aNBT.setInteger("mPipeCasingTier", this.mPipeCasingTier); + aNBT.setInteger("mCoilTier", this.mCoilTier); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mSolidCasingTier = aNBT.getInteger("mSolidCasingTier"); + mMachineCasingTier = aNBT.getInteger("mMachineCasingTier"); + mPipeCasingTier = aNBT.getInteger("mPipeCasingTier"); + mCoilTier = aNBT.getInteger("mCoilTier"); + } + + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) { + log("Found GT_MetaTileEntity_Hatch_ElementalDataOrbHolder"); + ((GT_MetaTileEntity_Hatch_ElementalDataOrbHolder) aTileEntity).mRecipeMap = getRecipeMap(); + return addToMachineListInternal(mReplicatorDataOrbHatches, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 100; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + // Same speed bonus as pyro oven + public int getSpeedBonus() { + return 50 * (this.mCoilTier - 2); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mReplicatorDataOrbHatches.clear(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), getSpeedBonus()); + } + + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isOC) { + return false; + } + + private static final HashMap<Long, AutoMap<GT_Recipe>> mTieredRecipeMap = new HashMap<Long, AutoMap<GT_Recipe>>(); + private static final AutoMap<GT_Recipe> aTier0Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier1Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier2Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier3Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier4Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier5Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier6Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier7Recipes = new AutoMap<GT_Recipe>(); + private static boolean mInitRecipeCache = false; + + private static void initRecipeCaches() { + if (!mInitRecipeCache) { + mTieredRecipeMap.put((long) 0, aTier0Recipes); + mTieredRecipeMap.put((long) 1, aTier1Recipes); + mTieredRecipeMap.put((long) 2, aTier2Recipes); + mTieredRecipeMap.put((long) 3, aTier3Recipes); + mTieredRecipeMap.put((long) 4, aTier4Recipes); + mTieredRecipeMap.put((long) 5, aTier5Recipes); + mTieredRecipeMap.put((long) 6, aTier6Recipes); + mTieredRecipeMap.put((long) 7, aTier7Recipes); + for (GT_Recipe aRecipe : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList) { + if (aRecipe != null) { + switch (aRecipe.mSpecialValue) { + case 0: + aTier0Recipes.add(aRecipe); + continue; + case 1: + aTier1Recipes.add(aRecipe); + continue; + case 2: + aTier2Recipes.add(aRecipe); + continue; + case 3: + aTier3Recipes.add(aRecipe); + continue; + case 4: + aTier4Recipes.add(aRecipe); + continue; + case 5: + aTier5Recipes.add(aRecipe); + continue; + case 6: + aTier6Recipes.add(aRecipe); + continue; + case 7: + aTier7Recipes.add(aRecipe); + continue; + } + } + } + mInitRecipeCache = true; + } + } + + private static boolean areInputsEqual(GT_Recipe aComparator, ItemStack[] aInputs, FluidStack[] aFluids) { + int aInputCount = aComparator.mInputs.length; + if (aInputCount > 0) { + //Logger.INFO("Looking for recipe with "+aInputCount+" Items"); + int aMatchingInputs = 0; + recipe : for (ItemStack a : aComparator.mInputs) { + for (ItemStack b : aInputs) { + if (a.getItem() == b.getItem()) { + if (a.getItemDamage() == b.getItemDamage()) { + //Logger.INFO("Found matching Item Input - "+b.getUnlocalizedName()); + aMatchingInputs++; + continue recipe; + } + } + } + } + if (aMatchingInputs != aInputCount) { + return false; + } + } + int aFluidInputCount = aComparator.mFluidInputs.length; + if (aFluidInputCount > 0) { + //Logger.INFO("Looking for recipe with "+aFluidInputCount+" Fluids"); + int aMatchingFluidInputs = 0; + recipe : for (FluidStack b : aComparator.mFluidInputs) { + //Logger.INFO("Checking for fluid "+b.getLocalizedName()); + for (FluidStack a : aFluids) { + if (GT_Utility.areFluidsEqual(a, b)) { + //Logger.INFO("Found matching Fluid Input - "+b.getLocalizedName()); + aMatchingFluidInputs++; + continue recipe; + } + else { + //Logger.INFO("Found fluid which did not match - "+a.getLocalizedName()); + } + } + } + if (aMatchingFluidInputs != aFluidInputCount) { + return false; + } + } + Logger.INFO("Recipes Match!"); + return true; + } + + public GT_Recipe findRecipe(final GT_Recipe aRecipe, final long aVoltage, final long aSpecialValue, ItemStack[] aInputs, final FluidStack[] aFluids) { + if (!mInitRecipeCache) { + initRecipeCaches(); + } + if (this.getRecipeMap().mRecipeList.isEmpty()) { + log("No Recipes in Map to search through."); + return null; + } + else { + log("Checking tier "+aSpecialValue+" recipes and below. Using Input Voltage of "+aVoltage+"V."); + log("We have "+aInputs.length+" Items and "+aFluids.length+" Fluids."); + // Try check the cached recipe first + if (aRecipe != null) { + if (areInputsEqual(aRecipe, aInputs, aFluids)) { + if (aRecipe.mEUt <= aVoltage) { + Logger.INFO("Using cached recipe."); + return aRecipe; + } + } + } + + // Get all recipes for the tier + AutoMap<AutoMap<GT_Recipe>> aMasterMap = new AutoMap<AutoMap<GT_Recipe>>(); + for (long i=0;i<=aSpecialValue;i++) { + aMasterMap.add(mTieredRecipeMap.get(i)); + } + GT_Recipe aFoundRecipe = null; + + // Iterate the tiers recipes until we find the one with all inputs matching + master : for (AutoMap<GT_Recipe> aTieredMap : aMasterMap) { + for (GT_Recipe aRecipeToCheck : aTieredMap) { + if (areInputsEqual(aRecipeToCheck, aInputs, aFluids)) { + log("Found recipe with matching inputs!"); + if (aRecipeToCheck.mSpecialValue <= aSpecialValue) { + if (aRecipeToCheck.mEUt <= aVoltage) { + aFoundRecipe = aRecipeToCheck; + break master; + } + } + } + } + } + + // If we found a recipe, return it + if (aFoundRecipe != null) { + log("Found valid recipe."); + return aFoundRecipe; + } + } + log("Did not find valid recipe."); + return null; + } + + /* + * Catalyst Handling + */ + + @Override + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_ElementalDataOrbHolder tHatch : mReplicatorDataOrbHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getInventory()); + } + } + return tItems; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FastNeutronReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FastNeutronReactor.java new file mode 100644 index 0000000000..3941d59edb --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FastNeutronReactor.java @@ -0,0 +1,231 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_FastNeutronReactor +extends GregtechMeta_MultiBlockBase +{ + + private int mSuperEfficencyIncrease = 0; + + + public GregtechMTE_FastNeutronReactor(int aID, String aName, String aNameRegional) + { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_FastNeutronReactor(String mName) { + super(mName); + } + + @Override + public String getMachineType() { + return "Reactor"; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GregtechMTE_FastNeutronReactor(this.mName); + } + @Override + public boolean isFacingValid(byte aFacing) + { + return aFacing > 1; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) + { + return true; + } + + @Override + public int getDamageToComponent(ItemStack aStack){ + return 0; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + this.mSuperEfficencyIncrease=0; + if (processing_Stage_1()) { + if (processing_Stage_2()) { + if (processing_Stage_3()) { + if (processing_Stage_4()) { + + } + else { + //Stage 4 + } + } + else { + //Stage 3 + } + } + else { + //Stage 2 + } + } + else { + //Stage 1 + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + public boolean processing_Stage_1() { //Deplete Water, Add More Progress Time + for (GT_MetaTileEntity_Hatch_Input tRecipe : this.mInputHatches) { + if (tRecipe.getFluid() != null){ + FluidStack tFluid = FluidUtils.getFluidStack(tRecipe.getFluid(), 200); + if (tFluid != null) { + if (tFluid == GT_ModHandler.getDistilledWater(1)) { + if (depleteInput(tFluid)) { + this.mMaxProgresstime = Math.max(1, runtimeBoost(8 * 2)); + this.mEUt = getEUt(); + this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); + return true; + } + } + + } + } + } + this.mMaxProgresstime = 0; + this.mEUt = 0; + return false; + } + public boolean processing_Stage_2() { + return false; + } + public boolean processing_Stage_3() { + return false; + } + public boolean processing_Stage_4() { + return false; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mEUt > 0) { + if(this.mSuperEfficencyIncrease>0){ + this.mEfficiency = Math.min(10000, this.mEfficiency + this.mSuperEfficencyIncrease); + } + int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); + if (tGeneratedEU > 0) { + long amount = (tGeneratedEU + 160) / 160; + if (!depleteInput(GT_ModHandler.getDistilledWater(amount))) { + explodeMultiblock(); + } else { + addOutput(GT_ModHandler.getSteam(tGeneratedEU)); + } + } + return true; + } + return true; + } + + public int getEUt() { + return 0; //Default 400 + } + + public int getEfficiencyIncrease() { + return 0; //Default 12 + } + + int runtimeBoost(int mTime) { + return mTime * 150 / 100; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) + { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) + { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) + { + return 0; + } + + public int getAmountOfOutputs() + { + return 1; + } + + @Override + public String[] getTooltip() + { + return new String[]{ + "Fukushima-Daiichi Reactor No. 6", + "------------------------------------------", + "Boiling Water Reactor", + "Harness the power of Nuclear Fission", + "------------------------------------------", + "Consult user manual for more information", + }; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(1)), + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(1))}; + } + + @Override + public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack arg1) { + return true; + } + + public boolean damageFilter(){ + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java new file mode 100644 index 0000000000..8a936525f0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java @@ -0,0 +1,449 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gtPlusPlus.core.lib.CORE; +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.GTPP_Recipe; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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 net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition<GregtechMTE_FrothFlotationCell> STRUCTURE_DEFINITION = null; + + 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 + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Process that milled ore!") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front Center") + .addCasingInfo("Inconel Reinforced Casing", 68) + .addCasingInfo("Flotation Casings", 52) + .addInputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addOutputHatch("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @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.getCasingTextureForId(aID), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(aID)}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sFlotationCellRecipes; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public IStructureDefinition<GregtechMTE_FrothFlotationCell> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMTE_FrothFlotationCell>builder() + .addShape(mName, new String[][]{ + {" ", " ", " X ", " X~X ", " X ", " ", " "}, + {" ", " F ", " FFF ", " FF FF ", " FFF ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" ", " F ", " F F ", " F F ", " F F ", " F ", " "}, + {" CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC "}, + {" CCC ", " CCCCC ", "CCCCCCC", "CCCCCCC", "CCCCCCC", " CCCCC ", " CCC "}, + }) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMTE_FrothFlotationCell::addFrothFlotationCellList, TAE.getIndexFromPage(2, 1), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings3Misc, 1 + ) + ) + ) + ) + .addElement( + 'F', + ofBlock( + ModBlocks.blockSpecialMultiCasings, 9 + ) + ) + .addElement( + 'X', + ofBlock( + ModBlocks.blockCasings3Misc, 1 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 3, 3, 0) && mCasing >= 68 - 4 && checkHatch(); + } + + public final boolean addFrothFlotationCellList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiFrothFlotationCell; + } + + @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/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java new file mode 100644 index 0000000000..1ead7edad5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_LargeNaqReactor.java @@ -0,0 +1,501 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.ArrayList; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +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.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.minecraft.LangUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Naquadah; +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.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMTE_LargeNaqReactor extends GregtechMeta_MultiBlockBase { + + public ArrayList<GT_MetaTileEntity_Hatch_Naquadah> mNaqHatches = new ArrayList<GT_MetaTileEntity_Hatch_Naquadah>(); + public static String[] mCasingName = new String[5]; + public static String mHatchName = "Naquadah Fuel Hatch"; + + private final int CASING_TEXTURE_ID = TAE.getIndexFromPage(0, 13); + private final int META_BaseCasing = 0; //4 + private final int META_ContainmentCasing = 15; //3 + private final int META_Shielding = 13; //1 + private final int META_PipeCasing = 1; //4 + private final int META_IntegralCasing = 6; //0 + private final int META_ContainmentChamberCasing = 2; //4 + + public GregtechMTE_LargeNaqReactor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); + mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); + mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); + mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); + mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); + mHatchName = LangUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 969); + } + + public GregtechMTE_LargeNaqReactor(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMTE_LargeNaqReactor(this.mName); + } + + public String[] getTooltip() { + if (mCasingName[0].toLowerCase().contains(".name")) { + mCasingName[0] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 0); + } + if (mCasingName[1].toLowerCase().contains(".name")) { + mCasingName[1] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 1); + } + if (mCasingName[2].toLowerCase().contains(".name")) { + mCasingName[2] = LangUtils.getLocalizedNameOfBlock(getCasing(4), 2); + } + if (mCasingName[3].toLowerCase().contains(".name")) { + mCasingName[3] = LangUtils.getLocalizedNameOfBlock(getCasing(3), 15); + } + if (mCasingName[4].toLowerCase().contains(".name")) { + mCasingName[4] = LangUtils.getLocalizedNameOfBlock(getCasing(1), 13); + } + if (mHatchName.toLowerCase().contains(".name")) { + mHatchName = LangUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 969); + } + return new String[]{ + "Naquadah reacts violently with potassium, ", + "resulting in massive explosions with radioactive potential.", + "Size: 3x4x12, WxHxL", + "Bottom Layer: "+mCasingName[0]+"s, (30x min)", + "Middle Layer: "+mCasingName[2]+"s (10x), with", + " "+mCasingName[3]+"s on either side", + " "+mCasingName[3]+"s also on each end (x26)", + "Middle Layer2: "+mCasingName[1]+" (12x total), with", + " "+mCasingName[4]+"s on either side (x24)", + "Top: Single row of "+mCasingName[0]+" along the middle (x12) ", + "", + "1x " + mHatchName + " (Any bottom layer casing)", + "1x " + "Maintenance Hatch" + " (Any bottom layer side casing)", + "1x " + "Energy Hatch" + " (Any top layer casing)", + + }; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + return aSide == aFacing + ? new ITexture[]{BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(3, 0)), + new GT_RenderedTexture(aActive + ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active + : TexturesGtBlock.Overlay_Machine_Controller_Default)} + : new ITexture[]{BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(3, 0))}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + "AssemblyLine.png"); + } + + public GT_Recipe_Map getRecipeMap() { + return null; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing == 1; + } + + public boolean checkRecipe(ItemStack aStack) { + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(212)), 10, 1.0F, aX, aY, + aZ); + } + } + + @Override + public String getSound() { + return (String) GregTech_API.sSoundList.get(Integer.valueOf(212)); + } + + private Block getCasing(int casingID) { + if (casingID == 1) { + return ModBlocks.blockCasingsMisc; + } + else if (casingID == 2) { + return ModBlocks.blockCasings2Misc; + } + else if (casingID == 3) { + return ModBlocks.blockCasings3Misc; + } + else if (casingID == 4) { + return ModBlocks.blockCasings4Misc; + } + else { + return ModBlocks.blockCasingsTieredGTPP; + } + } + + + + //Casing3, Meta 10 - "Grate Machine Casing"); + //Casing2, Meta 0 - "Solid Steel Machine Casing" + //Casing2, Meta 5 - "Assembling Line Casing" + //Casing2, Meta 9 - "Assembler Machine Casing" + //Magic Glass - blockAlloyGlass + + public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 4; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 4; + + // Counts for all Casing Types + int aBaseCasingCount = 0; + int aContainmentCasingCount = 0; + int aShieldingCount = 0; + int aPipeCount = 0; + int aIntegralCasingCount = 0; + int aContainmentChamberCount = 0; + + // Bottom Layer + aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, -7, xDir, zDir); + log("Bottom Layer is Valid. Moving to Layer 1."); + + // Layer 1 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -6, xDir, zDir); + aIntegralCasingCount += checkIntegralRing(aBaseMetaTileEntity, getCasing(0), this.META_IntegralCasing, -6, xDir, zDir); + aContainmentChamberCount += checkContainmentRing(aBaseMetaTileEntity, getCasing(4), this.META_ContainmentChamberCasing, -6, xDir, zDir); + log("Layer 1 is Valid. Moving to Layer 2."); + + // Layer 2 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -5, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -5, xDir, zDir); + log("Layer 2 is Valid. Moving to Layer 3."); + + // Layer 3 + aContainmentCasingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(3), this.META_ContainmentCasing, -4, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -4, xDir, zDir); + log("Layer 3 is Valid. Moving to Layer 4."); + + // Layer 4 + aContainmentCasingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(3), this.META_ContainmentCasing, -3, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -3, xDir, zDir); + log("Layer 4 is Valid. Moving to Layer 5."); + + // Layer 5 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -2, xDir, zDir); + aPipeCount += checkPipes(aBaseMetaTileEntity, getCasing(4), this.META_PipeCasing, -2, xDir, zDir); + log("Layer 5 is Valid. Moving to Layer 6."); + + // Layer 6 + aShieldingCount += checkOuterRing(aBaseMetaTileEntity, getCasing(1), this.META_Shielding, -1, xDir, zDir); + aIntegralCasingCount += checkIntegralRing(aBaseMetaTileEntity, getCasing(0), this.META_IntegralCasing, -1, xDir, zDir); + aContainmentChamberCount += checkContainmentRing(aBaseMetaTileEntity, getCasing(4), this.META_ContainmentChamberCasing, -1, xDir, zDir); + log("Layer 6 is Valid. Moving to Top Layer."); + + // Top Layer + aBaseCasingCount += checkEntireLayer(aBaseMetaTileEntity, getCasing(4), META_BaseCasing, 0, xDir, zDir); + + log("Found "+aBaseCasingCount+" "+mCasingName[0]+"s"); + log("Found "+aShieldingCount+" "+mCasingName[4]+"s"); + log("Found "+aPipeCount+" "+mCasingName[1]+"s"); + log("Found "+aContainmentCasingCount+" "+mCasingName[3]+"s"); + log("Found "+aIntegralCasingCount+" "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s"); + log("Found "+aContainmentChamberCount+" "+mCasingName[2]+"s"); + + // Try mesage player + String aOwnerName = this.getBaseMetaTileEntity().getOwnerName(); + EntityPlayer aOwner = null; + if (aOwnerName != null && aOwnerName.length() > 0) { + aOwner = PlayerUtils.getPlayer(aOwnerName); + } + + if (aShieldingCount != 128) { + log("Not enough "+mCasingName[4]+"s, require 128."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[4]+"s, require 128."); + } + return false; + } + if (aPipeCount != 20) { + log("Not enough "+mCasingName[1]+"s, require 20."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[1]+"s, require 20."); + } + return false; + } + if (aContainmentCasingCount != 64) { + log("Not enough "+mCasingName[3]+"s, require 64."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[3]+"s, require 64."); + } + return false; + } + if (aContainmentChamberCount != 42) { + log("Not enough "+mCasingName[2]+"s, require 42."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[2]+"s, require 42."); + } + return false; + } + if (aBaseCasingCount < 140) { + log("Not enough "+mCasingName[0]+"s, require 140 at a minimum."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+mCasingName[0]+"s, require 140 at a minimum."); + } + return false; + } + if (aIntegralCasingCount != 48) { + log("Not enough "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s, require 48."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Not enough "+LangUtils.getLocalizedNameOfBlock(getCasing(0), 6)+"s, require 48."); + } + return false; + } + log("LNR Formed."); + if (aOwner != null) { + PlayerUtils.messagePlayer(aOwner, "Large Naquadah Reactor has formed successfully."); + } + return true; + } + + public boolean addNaquadahHatchToMachineInput(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Naquadah) { + this.updateTexture(aMetaTileEntity, aBaseCasingIndex); + return this.mNaqHatches.add((GT_MetaTileEntity_Hatch_Naquadah) aMetaTileEntity); + } else { + return false; + } + } + } + + public int checkEntireLayer(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -4; x < 5; x++) { + for (int z = -4; z < 5; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { + continue; + } + // Skip controller + if (aY == 0 && x == 0 && z == 0) { + continue; + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, true, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + public int checkOuterRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -4; x < 5; x++) { + for (int z = -4; z < 5; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 4 && z == 4) || (x == -4 && z == -4) || (x == 4 && z == -4) || (x == -4 && z == 4)) { + continue; + } + + // If we are on the 5x5 ring, proceed + if ((x > -4 && x < 4 ) && (z > -4 && z < 4)) { + if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + } + else { + continue; + } + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + public int checkIntegralRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -3; x < 4; x++) { + for (int z = -3; z < 4; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 3 && z == 3) || (x == -3 && z == -3) || (x == 3 && z == -3) || (x == -3 && z == 3)) { + continue; + } + + // If we are on the 5x5 ring, proceed + if ((x > -3 && x < 3 ) && (z > -3 && z < 3)) { + if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + } + else { + continue; + } + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + public int checkPipes(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -1; x < 2; x++) { + for (int z = -1; z < 2; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 1 && z == 1) || (x == -1 && z == -1) || (x == 1 && z == -1) || (x == -1 && z == 1) || (x == 0 && z == 0)) { + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Pipe has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + }; + } + } + } + return aCasingCount; + } + + public int checkContainmentRing(IGregTechTileEntity aBaseMetaTileEntity, Block aBlock, int aMeta, int aY, int xDir, int zDir) { + int aCasingCount = 0; + for (int x = -2; x < 3; x++) { + for (int z = -2; z < 3; z++) { + int aOffsetX = this.getBaseMetaTileEntity().getXCoord() + x; + int aOffsetY = this.getBaseMetaTileEntity().getYCoord() + aY; + int aOffsetZ = this.getBaseMetaTileEntity().getZCoord() + z; + //Skip the corners + if ((x == 2 && z == 2) || (x == -2 && z == -2) || (x == 2 && z == -2) || (x == -2 && z == 2)) { + continue; + } + + Block aCurrentBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, aY, zDir + z); + int aCurrentMeta = (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + x, aY, zDir + z); + if (aCurrentBlock == aBlock && aCurrentMeta == aMeta) { + aCasingCount++; + } + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, aY, zDir + z); + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, aCurrentBlock, aCurrentMeta, aBlock, aMeta)) { + log("Layer has error. Height: "+aY); + //this.getBaseMetaTileEntity().getWorld().setBlock(aOffsetX, aOffsetY, aOffsetZ, aBlock, aMeta, 3); + return 0; + } + } + } + return aCasingCount; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 133; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Reactor"; + } +}*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java new file mode 100644 index 0000000000..9c2e3289c3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java @@ -0,0 +1,386 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.ArrayList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ControlCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Plasma; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { + + public long currentVoltage = GT_Values.V[7]; + public byte currentTier = 8; + + public void upvolt() { + byte f = currentTier; + if ((f+1) > 10) { + f = 8; + } + else { + f++; + } + this.currentTier = f; + updateVoltage(); + } + + public void downvolt() { + byte f = currentTier; + if ((f-1) < 8) { + f = 10; + } + else { + f--; + } + this.currentTier = f; + updateVoltage(); + } + + private long updateVoltage() { + this.currentVoltage = GT_Values.V[this.currentTier-1]; + return currentVoltage; + } + + public GregtechMTE_MiniFusionPlant(String aName) { + super(aName); + } + + public GregtechMTE_MiniFusionPlant(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMTE_MiniFusionPlant(this.mName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == this.getBaseMetaTileEntity().getBackFacing()) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(10)), + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[(int) this.getInputTier()]}; + } + if (aSide == 1) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(10)), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[(int) this.getOutputTier()]}; + } + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(10)), + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(10))}; + } + + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Fusion Reactor"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Small scale fusion", + "16x slower than using Multiblock of the same voltage", + //"Input voltage can be changed within the GUI", + "Place Input/Output Hatches on sides and bottom", + "Power can only be inserted into the back", + //e"Power can only be extracted from the top", + TAG_HIDE_HATCHES + }; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int xDir2 = ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()).offsetX; + int zDir2 = ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()).offsetZ; + int tAmount = 0; + + ForgeDirection aDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); + + //Require air in front, I think + if (!aBaseMetaTileEntity.getAirOffset(xDir2, 0, zDir2)) { + Logger.INFO("Did not find air in front"); + return false; + } else { + for (int i = -1; i < 2; ++i) { + for (int j = -1; j < 2; ++j) { + for (int h = -1; h < 2; ++h) { + if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, + h, zDir + j); + if (this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(10))) { + tAmount++; + } + } + } + } + } + } + Logger.INFO("Tanks found: "+tAmount); + return tAmount == 3; + } + + @Override + public boolean checkRecipe(ItemStack arg0) { + + + ArrayList tFluidList = this.getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + + for (int tFluids = 0; tFluids < tFluidList_sS - 1; ++tFluids) { + for (int tRecipe = tFluids + 1; tRecipe < tFluidList_sS; ++tRecipe) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(tFluids), + (FluidStack) tFluidList.get(tRecipe))) { + if (((FluidStack) tFluidList.get(tFluids)).amount < ((FluidStack) tFluidList.get(tRecipe)).amount) { + tFluidList.remove(tFluids--); + tFluidList_sS = tFluidList.size(); + break; + } + + tFluidList.remove(tRecipe--); + tFluidList_sS = tFluidList.size(); + } + } + } + int aStep = 0; + //Logger.INFO("Step "+aStep++); + if (tFluidList.size() > 1) { + //Logger.INFO("Step "+aStep++); + FluidStack[] arg5 = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); + GT_Recipe arg6 = getRecipeMap().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, + false, this.getMaxInputVoltage(), arg5, new ItemStack[0]); + if (arg6 == null && !this.mRunningOnLoad || (arg6 != null && this.maxEUStore() < (long) arg6.mSpecialValue)) { + //Logger.INFO("Bad Step "+aStep++); + //this.turnCasingActive(false); + this.mLastRecipe = null; + return false; + } + //Logger.INFO("Step "+aStep++); + + if (this.mRunningOnLoad || (arg6 != null && arg6.isRecipeInputEqual(true, arg5, new ItemStack[0]))) { + //Logger.INFO("Step "+aStep++); + this.mLastRecipe = arg6; + this.mEUt = this.mLastRecipe.mEUt * 1; + this.mMaxProgresstime = this.mLastRecipe.mDuration / 1; + this.mEfficiencyIncrease = 10000; + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + //this.turnCasingActive(true); + this.mRunningOnLoad = false; + return true; + } + //Logger.INFO("Step "+aStep++); + } + //Logger.INFO("Step "+aStep++); + + return false; + + + + + //return this.checkRecipeGeneric(this.getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + @Override + public int getMaxEfficiency(ItemStack arg0) { + return 10000; + } + + @Override + public boolean drainEnergyInput(long aEU) { + // Not applicable to this machine + return true; + } + + @Override + public boolean addEnergyOutput(long aEU) { + // Not applicable to this machine + return true; + } + + @Override + public long maxEUStore() { + return this.getMaxInputVoltage() * 256 * 512; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public String[] getExtraInfoData() { + String mode = EnumChatFormatting.BLUE + "" + currentVoltage + EnumChatFormatting.RESET; + String aOutput = EnumChatFormatting.BLUE + "" + mEUt + EnumChatFormatting.RESET; + String storedEnergyText; + if (this.getEUVar() > maxEUStore()) { + storedEnergyText = EnumChatFormatting.RED + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } else { + storedEnergyText = EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } + + return new String[]{ + "Stored EU: " + storedEnergyText, + "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, + "Voltage: " + mode, + "Output Voltage: " + aOutput + }; + } + + @Override + public void explodeMultiblock() { + super.explodeMultiblock(); + } + + @Override + public void doExplosion(long aExplosionPower) { + super.doExplosion(aExplosionPower); + } + + @Override + public long getMaxInputVoltage() { + return updateVoltage(); + } + + @Override + public long getInputTier() { + return (long) GT_Utility.getTier(maxEUInput()); + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(byte aSide) { + return (aSide == this.getBaseMetaTileEntity().getBackFacing()); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == 1; + } + + @Override + public long maxAmperesIn() { + return 32; + } + + @Override + public long maxAmperesOut() { + return 1; + } + + @Override + public long maxEUInput() { + return updateVoltage(); + } + + @Override + public long maxEUOutput() { + return mEUt > 0 ? mEUt : 0; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + this.mWrench = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mHardHammer = true; + this.mSolderingTool = true; + this.mCrowbar = true; + } + + @Override + public boolean causeMaintenanceIssue() { + return true; + } + + @Override + public int getControlCoreTier() { + return this.currentTier; + } + + @Override + public int getPollutionPerTick(ItemStack arg0) { + return 0; + } + + @Override + public GT_MetaTileEntity_Hatch_ControlCore getControlCoreBus() { + GT_MetaTileEntity_Hatch_ControlCore x = new GT_MetaTileEntity_Hatch_ControlCore("", 0, "", null); + return (GT_MetaTileEntity_Hatch_ControlCore) x; + } + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java new file mode 100644 index 0000000000..1f6ae41be2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java @@ -0,0 +1,523 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +import java.util.Collection; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +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.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.nuclear.NUCLIDE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase<GregtechMTE_NuclearReactor> { + + protected int mFuelRemaining = 0; + + private int mCasing; + private IStructureDefinition<GregtechMTE_NuclearReactor> STRUCTURE_DEFINITION = null; + + + public GregtechMTE_NuclearReactor(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_NuclearReactor(final String aName) { + super(aName); + } + + @Override + public long maxEUStore() { + return (640000000L * (Math.min(16, this.mEnergyHatches.size()))) / 16L; + } + + @Override + public String getMachineType() { + return "Reactor"; + } + + @Override + public GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Liquid Fluoride Thorium Reactor.") + .addInfo("Produces Heat & Energy from Radioactive Beta Decay.") + .addInfo("Outputs U233 every 10 seconds, on average") + .addInfo("Input Fluorine and Helium for bonus byproducts") + .addInfo("Input Li2BeF4 and a molten salt as fuel.") + .addInfo("LiFBeF2ThF4UF4, LiFBeF2ZrF4UF4 or LiFBeF2ZrF4U235") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(7, 4, 7, true) + .addController("Bottom Center") + .addCasingInfo("Hastelloy-N Reactor Casing", 27) + .addCasingInfo("Zeron-100 Reactor Shielding", 26) + .addInputHatch("Top or bottom layer edges", 1) + .addOutputHatch("Top or bottom layer edges", 1) + .addDynamoHatch("Top or bottom layer edges", 1) + .addMaintenanceHatch("Top or bottom layer edges", 1) + .addMufflerHatch("Top 3x3", 2) + .addStructureInfo("All dynamos must be IV or LuV tier.") + .addStructureInfo("All other hatches must be IV+ tier.") + .addStructureInfo("3x Output Hatches, 2x Input Hatches, 4x Dynamo Hatches") + .addStructureInfo("2x Maintenance Hatches, 4x Mufflers") + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public String[] getExtraInfoData() { + final String tRunning = (this.mMaxProgresstime>0 ? "Reactor running":"Reactor stopped"); + final String tMaintainance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance"); + + return new String[]{ + "Liquid Fluoride Thorium Reactor", + tRunning, + tMaintainance, + "Current Output: "+this.mEUt+" EU/t", + "Fuel Remaining: "+this.mFuelRemaining+" Litres", + "Current Efficiency: "+(this.mEfficiency/5)+"%", + "Current Efficiency (Raw): "+(this.mEfficiency), + "It requires you to have 100% Efficiency."}; + } + + @Override + public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aStack) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + boolean aWarmedUp = this.mEfficiency == this.getMaxEfficiency(null); + if (!aBaseMetaTileEntity.isActive() || !aWarmedUp){ + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12)), + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12))}; + } + else if(aBaseMetaTileEntity.isActive() && aWarmedUp){ + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13)), + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13))}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12))}; + + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MatterFabricator"; + } + + public final boolean addNuclearReactorEdgeList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo && (((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity).mTier >= 5 && ((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity).mTier <= 6)){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input && ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output && ((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addNuclearReactorTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler && ((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public IStructureDefinition<GregtechMTE_NuclearReactor> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMTE_NuclearReactor>builder() + .addShape(mName, transpose(new String[][]{ + {"CCCCCCC", "COOOOOC", "COXXXOC", "COXXXOC", "COXXXOC", "COOOOOC", "CCCCCCC"}, + {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, + {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, + {"CCC~CCC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "CCCCCCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMTE_NuclearReactor::addNuclearReactorEdgeList, TAE.GTPP_INDEX(12), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 12 + ) + ) + ) + ) + .addElement( + 'X', + ofChain( + ofHatchAdder( + GregtechMTE_NuclearReactor::addNuclearReactorTopList, TAE.GTPP_INDEX(12), 2 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 12 + ) + ) + ) + ) + .addElement( + 'O', + ofBlock( + ModBlocks.blockCasingsMisc, 12 + ) + ) + .addElement( + 'G', + ofBlock( + ModBlocks.blockCasingsMisc, 13 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 3, 3, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + if (checkPiece(mName, 3, 3, 0) && mCasing >= 27) { + if (mOutputHatches.size() >= 3 && mInputHatches.size() >= 2 && mDynamoHatches.size() == 4 && + mMufflerHatches.size() == 4 && mMaintenanceHatches.size() == 2) { + this.mWrench = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mHardHammer = true; + this.mSolderingTool = true; + this.mCrowbar = true; + this.turnCasingActive(false); + return true; + } + } + return false; + } + + // Alk's Life Lessons from Greg. + /* + [23:41:15] <GregoriusTechneticies> xdir and zdir are x2 and not x3 + [23:41:26] <GregoriusTechneticies> thats you issue + [23:44:33] <Alkalus> mmm? + [23:44:49] <Alkalus> Should they be x3? + [23:44:50] <GregoriusTechneticies> you just do a x2, what is for a 5x5 multiblock + [23:45:01] <GregoriusTechneticies> x3 is for a 7x7 one + [23:45:06] <Alkalus> I have no idea what that value does, tbh.. + [23:45:15] <GregoriusTechneticies> its the offset + [23:45:23] <Alkalus> Debugging checkMachine has been a pain and I usually trash designs that don't work straight up.. + [23:45:28] <GregoriusTechneticies> it determines the horizontal middle of the multiblock + [23:45:47] <GregoriusTechneticies> which is in your case THREE blocks away from the controller + [23:45:51] <Alkalus> Ahh + [23:45:57] <GregoriusTechneticies> and not 2 + [23:46:06] <Alkalus> Noted, thanks :D + */ + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return true; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_NuclearReactor(this.mName); + } + + public boolean turnCasingActive(final boolean status) { + //TODO + if (this.mDynamoHatches != null) { + for (final GT_MetaTileEntity_Hatch_Dynamo hatch : this.mDynamoHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + if (this.mMufflerHatches != null) { + for (final GT_MetaTileEntity_Hatch_Muffler hatch : this.mMufflerHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + if (this.mOutputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + if (this.mInputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + if (this.mMaintenanceHatches != null) { + for (final GT_MetaTileEntity_Hatch_Maintenance hatch : this.mMaintenanceHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); + } + } + return true; + } + + public FluidStack[] getStoredFluidsAsArray() { + return getStoredFluids().toArray(new FluidStack[0]); + } + + public int getStoredFuel(GT_Recipe aRecipe) { + int aFuelStored = 0; + FluidStack aFuelFluid = null; + for (FluidStack aFluidInput : aRecipe.mFluidInputs) { + if (!aFluidInput.getFluid().equals(NUCLIDE.Li2BeF4.getFluid())) { + aFuelFluid = aFluidInput; + break; + } + } + if (aFuelFluid != null) { + for (GT_MetaTileEntity_Hatch_Input aInputHatch : this.mInputHatches) { + if (aInputHatch.getFluid() != null && aInputHatch.getFluidAmount() > 0) { + if (aInputHatch.getFluid().isFluidEqual(aFuelFluid)) { + aFuelStored += aInputHatch.getFluidAmount(); + } + } + } + } + return aFuelStored; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + // Warm up for 4~ minutes + Logger.WARNING("Checking LFTR recipes."); + if (mEfficiency < this.getMaxEfficiency(null)) { + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 2; + Logger.WARNING("Warming Up! "+this.mEfficiency+"/"+this.getMaxEfficiency(null)); + return true; + } + Logger.WARNING("Warmed up, checking LFTR recipes."); + + final FluidStack[] tFluids = getStoredFluidsAsArray(); + final Collection<GT_Recipe> tRecipeList = getRecipeMap().mRecipeList; + if(tFluids.length > 0 && tRecipeList != null && tRecipeList.size() > 0) { //Does input hatch have a LFTR fuel? + Logger.WARNING("Found more than one input fluid and a list of valid recipes."); + // Find a valid recipe + GT_Recipe aFuelProcessing = this.findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, 0, tFluids, new ItemStack[] {}); + if (aFuelProcessing == null) { + Logger.WARNING("Did not find valid recipe for given inputs."); + return false; + } + else { + Logger.WARNING("Found recipe? "+(aFuelProcessing != null ? "true" : "false")); + for (FluidStack aFluidInput : aFuelProcessing.mFluidInputs) { + Logger.WARNING("Using "+aFluidInput.getLocalizedName()); + } + } + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + this.mLastRecipe = aFuelProcessing; + // Deplete Inputs + if (aFuelProcessing.mFluidInputs.length > 0) { + for (FluidStack aInputToConsume : aFuelProcessing.mFluidInputs) { + Logger.WARNING("Depleting "+aInputToConsume.getLocalizedName()+" - "+aInputToConsume.amount+"L"); + this.depleteInput(aInputToConsume); + } + } + // -- Try not to fail after this point - inputs have already been consumed! -- + this.mMaxProgresstime = (int)(aFuelProcessing.mDuration); + this.mEUt = aFuelProcessing.mSpecialValue * 4; + Logger.WARNING("Outputting "+this.mEUt+"eu/t"); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + Logger.WARNING("Recipe time: "+this.mMaxProgresstime); + mFuelRemaining = getStoredFuel(aFuelProcessing); //Record available fuel + + this.mOutputFluids = aFuelProcessing.mFluidOutputs.clone(); + updateSlots(); + Logger.WARNING("Recipe Good!"); + return true; + } + this.mEUt = 0; + this.mEfficiency = 0; + Logger.WARNING("Recipe Bad!"); + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public void explodeMultiblock() { + this.mInventory[1] = null; + long explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + for (final MetaTileEntity tTileEntity : this.mInputBusses) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mOutputBusses) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mInputHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mOutputHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mDynamoHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mMufflerHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mEnergyHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + for (final MetaTileEntity tTileEntity : this.mMaintenanceHatches) { + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + tTileEntity.getBaseMetaTileEntity().doExplosion(explodevalue); + } + explodevalue = MathUtils.randLong(Integer.MAX_VALUE, 8589934588L); + this.getBaseMetaTileEntity().doExplosion(explodevalue); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.getWorld().isRemote) { + if (aBaseMetaTileEntity.isActive()){ + // Set casings active if we're warmed up. + if (this.mEfficiency == this.getMaxEfficiency(null)){ + this.turnCasingActive(true); + } + else { + this.turnCasingActive(false); + } + } + else { + this.turnCasingActive(false); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + // See if we're warmed up. + if (this.mEfficiency == this.getMaxEfficiency(null)){ + // Try output some Uranium-233 + if (MathUtils.randInt(1, 300) == 1){ + this.addOutput(ELEMENT.getInstance().URANIUM233.getFluidStack(MathUtils.randInt(1, 10))); + } + + } + return super.onRunningTick(aStack); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mFuelRemaining", this.mFuelRemaining); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mFuelRemaining = aNBT.getInteger("mFuelRemaining"); + super.loadNBTData(aNBT); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java new file mode 100644 index 0000000000..cccee84c99 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java @@ -0,0 +1,521 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntityGeneratorArray extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntityGeneratorArray> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntityGeneratorArray(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityGeneratorArray(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityGeneratorArray(this.mName); + } + + @Override + public String getMachineType() { + return "Processing Array"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Generator Array") + .addInfo("Runs supplied generators as if placed in the world") + .addInfo("Place up to 16 Single Block GT Generators into the Controller") + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Robust Tungstensteel Machine Casings", 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addDynamoHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(48), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(48)}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ProcessingArray"; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + this.mMode = getModeFromInventorySlot(this.getGUIItemStack()); + if (this.mMode == MODE_NONE) { + return null; + } + else if (this.mMode == MODE_STEAM) { + return GTPP_Recipe.GTPP_Recipe_Map.sSteamTurbineFuels; + } + else if (this.mMode == MODE_DIESEL) { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } + else if (this.mMode == MODE_GAS) { + return GT_Recipe.GT_Recipe_Map.sTurbineFuels; + } + else if (this.mMode == MODE_SEMIFLUID) { + return GTPP_Recipe.GTPP_Recipe_Map.sSemiFluidLiquidFuels; + } + else if (this.mMode == MODE_GEOTHERMAL) { + return GTPP_Recipe.GTPP_Recipe_Map.sThermalFuels; + } + else if (this.mMode == MODE_ROCKETFUEL) { + return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; + } + else if (this.mMode == MODE_MAGIC_A) { + return GT_Recipe.GT_Recipe_Map.sMagicFuels; + } + else if (this.mMode == MODE_PLASMA) { + return GT_Recipe.GT_Recipe_Map.sPlasmaFuels; + } + else if (this.mMode == MODE_NAQUADAH) { + return GT_Recipe.GT_Recipe_Map.sFluidNaquadahReactorFuels; + } + return null; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + if (aStack != null && aStack.getUnlocalizedName().startsWith("gt.blockmachines.")) { + return true; + } + return false; + } + + public String mMachine = ""; + protected int fuelConsumption = 0; + protected int fuelValue = 0; + protected int fuelRemaining = 0; + protected boolean boostEu = false; + + int mMode = 0; + + private final static int MODE_STEAM = 0; + private final static int MODE_DIESEL = 1; + private final static int MODE_GAS = 2; + private final static int MODE_SEMIFLUID = 3; + private final static int MODE_GEOTHERMAL = 4; + private final static int MODE_ROCKETFUEL = 5; + private final static int MODE_MAGIC_A = 6; + private final static int MODE_MAGIC_B_DISABLED = 7; + private final static int MODE_PLASMA = 8; + private final static int MODE_NAQUADAH = 9; + private final static int MODE_NONE = 100; + + private final static int[] ID_STEAM = new int[] {962, 1120, 1121, 1122}; + private final static int[] ID_GAS = new int[] {961, 1115, 1116, 1117}; + private final static int[] ID_DIESEL = new int[] {960, 1110, 1111, 1112}; + private final static int[] ID_SEMIFLUID = new int[] {837, 838, 839}; + private final static int[] ID_GEOTHERMAL = new int[] {830, 831, 832}; + private final static int[] ID_ROCKETFUEL = new int[] {793, 794, 795}; + private final static int[] ID_MAGIC_A = new int[] {1123, 1124, 1125}; + private final static int[] ID_MAGIC_B_DISABLED = new int[] {1127, 1128, 1129, 1130}; + private final static int[] ID_PLASMA = new int[] {1196, 1197, 1198}; + private final static int[] ID_NAQUADAH = new int[] {1190, 1191, 1192}; + + private static final int getModeFromInventorySlot(ItemStack aStack) { + + if (aStack == null) { + return MODE_NONE; + } + + String aItemStackName = aStack == null ? "" : aStack.getUnlocalizedName(); + //Logger.INFO("Item Name: "+aItemStackName+" ("+aStack.getItemDamage()+")"); + if (aItemStackName.toLowerCase().contains("gt.blockmachines")) { + for (int g : ID_STEAM) { + if (aStack.getItemDamage() == g) { + return MODE_STEAM; + } + } + for (int g : ID_GAS) { + if (aStack.getItemDamage() == g) { + return MODE_GAS; + } + } + for (int g : ID_DIESEL) { + if (aStack.getItemDamage() == g) { + return MODE_DIESEL; + } + } + for (int g : ID_SEMIFLUID) { + if (aStack.getItemDamage() == g) { + return MODE_SEMIFLUID; + } + } + for (int g : ID_GEOTHERMAL) { + if (aStack.getItemDamage() == g) { + return MODE_GEOTHERMAL; + } + } + for (int g : ID_ROCKETFUEL) { + if (aStack.getItemDamage() == g) { + return MODE_ROCKETFUEL; + } + } + for (int g : ID_MAGIC_A) { + if (aStack.getItemDamage() == g) { + return MODE_MAGIC_A; + } + } + for (int g : ID_PLASMA) { + if (aStack.getItemDamage() == g) { + return MODE_PLASMA; + } + } + for (int g : ID_NAQUADAH) { + if (aStack.getItemDamage() == g) { + return MODE_NAQUADAH; + } + } + } + return MODE_NONE; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + + this.resetRecipeMapForAllInputHatches(); + this.mMode = getModeFromInventorySlot(aStack); + if (mMode == MODE_NONE) { + Logger.INFO("Did not find valid generator."); + return false; + } + else { + Logger.INFO("Changed Mode to "+mMode); + } + int aMulti = this.getGUIItemStack() != null ? this.getGUIItemStack().stackSize : 0; + if (aMulti > 16 || aMulti == 0) { + return false; + } + + + + ArrayList<FluidStack> tFluids = this.getStoredFluids(); + + Collection<GT_Recipe> tRecipeList = this.getRecipeMap().mRecipeList; + Logger.INFO("Got Recipe Map"); + if (tFluids.size() > 0 && tRecipeList != null) { + Logger.INFO("Found Fuels for Map."); + Iterator<FluidStack> arg3 = tFluids.iterator(); + int aCount = 0; + while (arg3.hasNext()) { + FluidStack hatchFluid1 = (FluidStack) arg3.next(); + Logger.INFO("Iterating Fluid Found "+(aCount++)+" | "+hatchFluid1.getLocalizedName()); + Iterator<GT_Recipe> arg5 = tRecipeList.iterator(); + + int Hatch = 0; + int totalFuelValue = 0; + while (arg5.hasNext()) { + Logger.INFO("Iterating Recipe "+(Hatch++)); + GT_Recipe aFuel = (GT_Recipe) arg5.next(); + FluidStack tLiquid; + boolean addedFuelOnce = false; + for (int a = 0; a < aMulti; a++) { + if ((tLiquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null + && hatchFluid1.isFluidEqual(tLiquid)) { + this.fuelConsumption = tLiquid.amount = this.boostEu + ? 4096 / aFuel.mSpecialValue + : 2048 / aFuel.mSpecialValue; + if (this.depleteInput(tLiquid)) { + Logger.INFO("Depleted Fuel"); + this.boostEu = this.depleteInput(Materials.Oxygen.getGas(2L)); + +/*if (!tFluids.contains(Materials.Lubricant.getFluid(1L))) { + Logger.INFO("No Lube."); + return false; + }*/ + + if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { + this.depleteInput(Materials.Lubricant.getFluid(this.boostEu ? 2L : 1L)); + } + Logger.INFO("ADDING POWER"); + this.fuelRemaining = hatchFluid1.amount; + totalFuelValue++; + } + } + } + //Do things after consuming Fuel + if (totalFuelValue == aMulti) { + this.fuelValue = aFuel.mSpecialValue*aMulti; + this.mEUt = this.mEfficiency < 2000 ? 0 : aFuel.mSpecialValue*aMulti; + this.mProgresstime = aMulti; + this.mMaxProgresstime = aMulti; + this.mEfficiencyIncrease = 15*aMulti; + return true; + } + } + } + } + + this.mEUt = 0; + this.mEfficiency = 0; + return false; + } + + public static ItemStack[] clean(final ItemStack[] v) { + List<ItemStack> list = new ArrayList<ItemStack>(Arrays.asList(v)); + list.removeAll(Collections.singleton(null)); + return list.toArray(new ItemStack[list.size()]); + } + + @Override + public IStructureDefinition<GregtechMetaTileEntityGeneratorArray> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntityGeneratorArray>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntityGeneratorArray::addGeneratorArrayList, 48, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + GregTech_API.sBlockCasings4, 0 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10; + } + + public final boolean addGeneratorArrayList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + /** + * Code from single blocks + */ + + public void tryProcessFuelItems(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a) { + if (a != null + && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + this.getMinimumStoredEU() + && GT_Utility.getFluidForFilledItem(a, true) == null) { + int tFuelValue; + tFuelValue = this.getFuelValue(a); + if (tFuelValue > 0) { + ItemStack tEmptyContainer1 = this.getEmptyContainer(a); + if (this.addOutput(tEmptyContainer1)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); + this.depleteInput(a); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); + } + } + } + } + + public void tryProcessFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick, FluidStack mFluid) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { + int tFuelValue; + if (mFluid != null) { + tFuelValue = this.getFuelValue(mFluid); + int tEmptyContainer = this.consumedFluidPerOperation(mFluid); + if (tFuelValue > 0 && tEmptyContainer > 0 && mFluid.amount > tEmptyContainer) { + long tFluidAmountToUse = Math.min((long) (mFluid.amount / tEmptyContainer), + (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); + if (tFluidAmountToUse > 0L && aBaseMetaTileEntity + .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); + mFluid.amount = (int) ((long) mFluid.amount + - tFluidAmountToUse * (long) tEmptyContainer); + } + } + } + + //Check items + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity + .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); + } + + } + + public boolean isFluidInputAllowed(FluidStack aFluid) { + return this.getFuelValue(aFluid) > 0; + } + + + public int consumedFluidPerOperation(FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid != null && this.getRecipeMap() != null) { + Collection<GT_Recipe> tRecipeList = this.getRecipeMap().mRecipeList; + if (tRecipeList != null) { + Iterator<GT_Recipe> arg3 = tRecipeList.iterator(); + + while (arg3.hasNext()) { + GT_Recipe tFuel = (GT_Recipe) arg3.next(); + FluidStack tLiquid; + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null + && aLiquid.isFluidEqual(tLiquid)) { + return (int) ((long) tFuel.mSpecialValue * (long) this.mEfficiency + * (long) this.consumedFluidPerOperation(tLiquid) / 100L); + } + } + } + + return 0; + } else { + return 0; + } + } + + public int getFuelValue(ItemStack aStack) { + if (!GT_Utility.isStackInvalid(aStack) && this.getRecipeMap() != null) { + GT_Recipe tFuel = this.getRecipeMap().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, + (FluidStack[]) null, new ItemStack[]{aStack}); + return tFuel != null ? (int) ((long) tFuel.mSpecialValue * 1000L * (long) this.mEfficiency / 100L) : 0; + } else { + return 0; + } + } + + public ItemStack getEmptyContainer(ItemStack aStack) { + if (!GT_Utility.isStackInvalid(aStack) && this.getRecipeMap() != null) { + GT_Recipe tFuel = this.getRecipeMap().findRecipe(this.getBaseMetaTileEntity(), false, Long.MAX_VALUE, + (FluidStack[]) null, new ItemStack[]{aStack}); + return tFuel != null + ? GT_Utility.copy(new Object[]{tFuel.getOutput(0)}) + : GT_Utility.getContainerItem(aStack, true); + } else { + return null; + } + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java new file mode 100644 index 0000000000..83b8eae458 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -0,0 +1,332 @@ + +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import codechicken.nei.ItemStackMap; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.*; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.*; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper; +import gtPlusPlus.xmod.gregtech.common.helpers.treefarm.TreeGenerator; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase { + + public static int CASING_TEXTURE_ID; + public static String mCasingName = "Advanced Cryogenic Casing"; + public static TreeGenerator mTreeData; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntityTreeFarm> STRUCTURE_DEFINITION = null; + + static { + new Thread("GTPP-TreeDataWorker") { + @Override + public void run() { + mTreeData = new TreeGenerator(); + } + }.start(); + } + + private static ItemStack aLeaves; + + public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); + } + + public GregtechMetaTileEntityTreeFarm(final String aName) { + super(aName); + CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityTreeFarm(this.mName); + } + + @Override + public String getMachineType() { + return "Tree Farm"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); + } + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Converts EU to Oak Logs") + .addInfo("Eu Usage: 100% | Parallel: 1") + .addInfo("Requires a Saw or Chainsaw in GUI slot") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Sterile Farm Casing", 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID), + TextureFactory.of(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "VacuumFreezer"; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + public boolean isCorrectMachinePart(final ItemStack aStack) { + // is correct part && either not powered tool or have enough power + return TreeFarmHelper.getPartType(aStack) != null && !GT_ModHandler.isElectricItem(aStack) || GT_ModHandler.canUseElectricItem(aStack, 1); + } + + public boolean checkRecipe(final ItemStack aStack) { + if (mTreeData == null) + // not finished somehow + return false; + if (aStack == null && !replaceTool()) + // no tool + return false; + if (!isCorrectMachinePart(aStack)) + // not a tool + return false; + if (mTreeData != null) { + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + this.mMaxProgresstime = 100; + this.mEUt = (int) tVoltage; + + 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); + } + + + int aChance = MathUtils.randInt(0, 10); + + try { + if (aChance < 8) { + ItemStackMap<Integer> allOutputs = new ItemStackMap<>(); + if (aLeaves == null) + aLeaves = ItemUtils.getSimpleStack(Blocks.leaves); + //1% Chance per Tick + for (int u = 0; u < (Math.max(4, (MathUtils.randInt((3 * tTier), 100) * tTier * tTier) / 14)); u++) { + AutoMap<ItemStack> aOutputs = mTreeData.generateOutput(0); + if (aOutputs.size() > 0) { + for (ItemStack aOutputItemStack : aOutputs) { + if (!GT_Utility.areStacksEqual(aLeaves, aOutputItemStack)) { + Integer oldStackSize = allOutputs.get(aOutputItemStack); + int oldStackSizeUnboxed = oldStackSize == null ? 0 : oldStackSize; + allOutputs.put(aOutputItemStack, oldStackSizeUnboxed + aOutputItemStack.stackSize); + } + } + } + } + + mOutputItems = allOutputs.entries().stream() + .map(e -> { + e.key.stackSize = e.value; + return e.key; + }).toArray(ItemStack[]::new); + } + } catch (Throwable t) { + t.printStackTrace(GT_Log.err); + } + return true; + } else { + return false; + } + } + + @Override + public boolean checkHatch() { + return super.checkHatch() && mEnergyHatches.size() == 1; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 - 8 && checkHatch(); + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntityTreeFarm> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntityTreeFarm>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntityTreeFarm::addTreeFarmList, CASING_TEXTURE_ID, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 15 + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addTreeFarmList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiTreeFarm; + } + + public int getDamageToComponent(final ItemStack aStack) { + return MathUtils.balance((int) (75 - ((GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).getMass()))), 5, 120); + } + + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public boolean replaceTool() { + ItemStack invItem = this.mInventory[1]; + if (invItem == null) { + for (GT_MetaTileEntity_Hatch_InputBus mInputBus : this.mInputBusses) { + for (int i = 0; i < mInputBus.mInventory.length; i++) { + ItemStack uStack = mInputBus.mInventory[i]; + if (uStack != null && TreeFarmHelper.getPartType(uStack) != null) { + this.setGUIItemStack(uStack); + return true; + } + } + } + } + return false; + } + + public boolean tryDamageTool(ItemStack invItem) { + if (invItem != null && invItem.getItem() instanceof GT_MetaGenerated_Tool) { + long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); + long aDmgMax = GT_MetaGenerated_Tool.getToolMaxDamage(invItem); + if (aDmg < aDmgMax && GT_MetaGenerated_Tool.getPrimaryMaterial(invItem) != Materials._NULL) { + return GT_ModHandler.damageOrDechargeItem(invItem, 1, 0, null); + } + } + return false; + } + + @Override + public boolean doRandomMaintenanceDamage() { + ItemStack tSaw = mInventory[1]; + if (!isCorrectMachinePart(tSaw) || getRepairStatus() == 0) { + stopMachine(); + return false; + } + if (CORE.RANDOM.nextInt(200) == 0) { + if (!tryDamageTool(tSaw)) { + if (tSaw.getItem().isDamageable()) + addOutput(tSaw); + this.mInventory[1] = null; + if (!replaceTool()) + this.getBaseMetaTileEntity().disableWorking(); + tryDamageTool(tSaw); + } + } + return super.doRandomMaintenanceDamage(); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + replaceTool(); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java new file mode 100644 index 0000000000..323efa2193 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -0,0 +1,338 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +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 net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_AlloyBlastSmelter +extends GregtechMeta_MultiBlockBase { + + private int mMode = 0; + private boolean isUsingControllerCircuit = false; + private static Item circuit; + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_AlloyBlastSmelter> STRUCTURE_DEFINITION = null; + + + public GregtechMetaTileEntity_AlloyBlastSmelter(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_AlloyBlastSmelter(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_AlloyBlastSmelter(this.mName); + } + + @Override + public String getMachineType() { + return "Fluid Alloy Cooker"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Alloy Blast Smelter") + .addInfo("20% Faster than the Electric Blast Furnace") + .addInfo("Allows Complex GT++ alloys to be created") + .addInfo("Circuit for recipe goes in the Input Bus or GUI slot") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 4, 3, true) + .addController("Bottom Center") + .addCasingInfo("Blast Smelter Casings", 10) + .addCasingInfo("Blast Smelter Heat Containment Coils", 16) + .addInputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_AlloyBlastSmelter> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_AlloyBlastSmelter>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"HHH", "H-H", "HHH"}, + {"HHH", "H-H", "HHH"}, + {"C~C", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_AlloyBlastSmelter::addAlloyBlastSmelterList, TAE.GTPP_INDEX(15), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 15 + ) + ) + ) + ) + .addElement( + 'H', + ofBlock( + ModBlocks.blockCasingsMisc, 14 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 3, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 3, 0) && mCasing >= 10 && mEnergyHatches.size() == 1 && checkHatch(); + } + + public final boolean addAlloyBlastSmelterList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(208)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(15)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(15))}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public boolean requiresVanillaGtGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return "ElectricBlastFurnace"; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + if (this.getBaseMetaTileEntity().isServerSide()) { + //Get Controller Circuit + if (circuit == null) { + circuit = CI.getNumberedCircuit(0).getItem(); + } + if (aStack != null && aStack.getItem() == circuit) { + this.mMode = aStack.getItemDamage(); + return this.isUsingControllerCircuit = true; + } + else { + if (aStack == null) { + this.isUsingControllerCircuit = false; + return true; //Allowed empty + } + Logger.WARNING("Not circuit in GUI inputs."); + return this.isUsingControllerCircuit = false; + } + } + Logger.WARNING("No Circuit, clientside."); + return this.isUsingControllerCircuit = false; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + + if (this.getBaseMetaTileEntity().isServerSide()) { + //Get Controller Circuit + this.isUsingControllerCircuit = isCorrectMachinePart(aStack); + + final ArrayList<ItemStack> tInputList = this.getStoredInputs(); + for (int i = 0; i < (tInputList.size() - 1); i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + + //Validity check + if ((isUsingControllerCircuit && tInputList.size() < 1) || (!isUsingControllerCircuit && tInputList.size() < 2)) { + Logger.WARNING("Not enough inputs."); + return false; + } + else if (isUsingControllerCircuit && tInputList.size() >= 1) { + tInputList.add(CI.getNumberedCircuit(this.mMode)); + } + + + final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, tInputList.size()); + + final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); + for (int i = 0; i < (tFluidList.size() - 1); i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 1) { + final long tVoltage = this.getMaxInputVoltage(); + final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + final GT_Recipe tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + Logger.WARNING("Found some Valid Inputs."); + this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1))); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1))); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + 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); + this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + List<ItemStack> tOutPutItems = new ArrayList<ItemStack>(); + for (ItemStack tOut : tRecipe.mOutputs) { + if (ItemUtils.checkForInvalidItems(tOut)) { + tOutPutItems.add(tOut); + } + } + if (tOutPutItems.size() > 0) + this.mOutputItems = tOutPutItems.toArray(new ItemStack[tOutPutItems.size()]); + this.updateSlots(); + return true; + } + } + } + Logger.WARNING("Failed to find some Valid Inputs or Clientside."); + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiABS; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java new file mode 100644 index 0000000000..ecd4882516 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java @@ -0,0 +1,481 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.ArrayList; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.IonParticles; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +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.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_Cyclotron> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_Cyclotron(int aID, String aName, String aNameRegional, int tier) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_Cyclotron(String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Particle Accelerator"; + } + + public int tier(){ + return 5; + } + + @Override + public long maxEUStore() { + return 1800000000L; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + //return new CONTAINER_Cyclotron(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return super.getClientGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + //return new GUI_Cyclotron(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), Recipe_GT.Gregtech_Recipe_Map.sCyclotronRecipes.mNEIName); + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Cyclotron(this.mName); + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_Cyclotron> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_Cyclotron>builder() + .addShape(mName, transpose(new String[][]{ + { + " ", + " hhh ", + " hh hh ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " hh hh ", + " hhh ", + " ", + }, + { + " hhh ", + " hhccchh ", + " hcchhhcch ", + " hchh hhch ", + " hch hch ", + " hch hch ", + "hch hch", + "hch hch", + "hch hch", + " hch hch ", + " hch hch ", + " hchh hhch ", + " hcch~hcch ", + " hhccchh ", + " hhh ", + }, + { + " ", + " hhh ", + " hh hh ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " h h ", + " hh hh ", + " hhh ", + " ", + } + })) + .addElement( + 'h', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_Cyclotron::addCyclotronList, 44, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + getCasing(), getCasingMeta() + ) + ) + ) + ) + .addElement( + 'c', + ofBlock( + getCyclotronCoil(), getCyclotronCoilMeta() + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 7, 1, 12); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 7, 1, 12) && mCasing >= 40 && checkHatch(); + } + + public final boolean addCyclotronList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus && ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier >= 5){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy && ((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity).mTier >= 5){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus && ((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler && ((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input && ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public Block getCasing() { + return ModBlocks.blockCasings2Misc; + } + + public int getCasingMeta() { + return 10; + } + + public Block getCyclotronCoil() { + return ModBlocks.blockCasings2Misc; + } + + public int getCyclotronCoilMeta() { + return 9; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Super Magnetic Speed Shooter") + .addSeparator() + .addInfo("Particles are accelerated over 186 revolutions to 80% light speed") + .addInfo("Can produce a continuous beam current of 2.2 mA at 590 MeV") + .addInfo("Which will be extracted from the Isochronous Cyclotron") + .addSeparator() + .addInfo("Consists of the same layout as a Fusion Reactor") + .addInfo("Any external casing can be a hatch/bus, unlike Fusion") + .addInfo("Cyclotron Machine Casings around Cyclotron Coil Blocks") + .addInfo("All Hatches must be IV or better") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .addCasingInfo("Cyclotron Machine Casings", 40) + .addCasingInfo("Cyclotron Coil", 32) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + ITexture[] sTexture; + if (aSide == aFacing) { + sTexture = new ITexture[]{Textures.BlockIcons.getCasingTextureForId(44), new GT_RenderedTexture(getIconOverlay())}; + } else { + if (!aActive) { + sTexture = new ITexture[]{Textures.BlockIcons.getCasingTextureForId(44)}; + } else { + sTexture = new ITexture[]{Textures.BlockIcons.getCasingTextureForId(44)}; + } + } + return sTexture; + } + + public IIconContainer getIconOverlay() { + if (this.getBaseMetaTileEntity().isActive()){ + return TexturesGtBlock.Overlay_MatterFab_Active_Animated; + } + return TexturesGtBlock.Overlay_MatterFab_Animated; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + + /*if (CORE.DEVENV) { + return this.checkRecipeGeneric(); + }*/ + this.fixAllMaintenanceIssue(); + + //log("Recipe Check."); + ArrayList<ItemStack> tItemList = getStoredInputs(); + ItemStack[] tItemInputs = tItemList.toArray(new ItemStack[tItemList.size()]); + ArrayList<FluidStack> tInputList = getStoredFluids(); + FluidStack[] tFluidInputs = tInputList.toArray(new FluidStack[tInputList.size()]); + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.findRecipe(getBaseMetaTileEntity(), false, + gregtech.api.enums.GT_Values.V[tTier], tFluidInputs, tItemInputs); + if (tRecipe != null){ + if (tRecipe.isRecipeInputEqual(true, tFluidInputs, tItemInputs)) { + + this.mEfficiency = (10000 - ((getIdealStatus() - getRepairStatus()) * 1000)); + this.mEfficiencyIncrease = 10000; + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + + 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); + + final ItemStack[] outputs = new ItemStack[tRecipe.mOutputs.length]; + for (int i = 0; i < tRecipe.mOutputs.length; i++){ + if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)){ + Logger.WARNING("Adding a bonus output"); + outputs[i] = tRecipe.getOutput(i); + } + else { + Logger.WARNING("Adding null output"); + outputs[i] = null; + } + } + + for (ItemStack s : outputs) { + if (s != null) { + if (s.getItem() instanceof IonParticles) { + long aCharge = IonParticles.getChargeState(s); + if (aCharge == 0) { + IonParticles.setChargeState(s, MathUtils.getRandomFromArray(new int[] { + -5, -5, + -4, -4, -4, + -3, -3, -3, -3, -3, + -2, -2, -2, -2, -2, -2, -2, + -1, -1, -1, -1, -1, -1, -1, -1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, + 5, 5, 5, + 6, 6})); + } + } + } + } + + this.mOutputItems = outputs; + this.mOutputFluids = new FluidStack[] {tRecipe.getFluidOutput(0)}; + return true; + } + } + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mOutputBusses.size() > 0) { + for (GT_MetaTileEntity_Hatch_OutputBus g : this.mOutputBusses) { + if (g != null) { + for (ItemStack s : g.mInventory) { + if (s != null) { + if (s.getItem() instanceof IonParticles) { + long aCharge = IonParticles.getChargeState(s); + if (aCharge == 0) { + IonParticles.setChargeState(s, MathUtils.getRandomFromArray(new int[] { + -5, -5, + -4, -4, -4, + -3, -3, -3, -3, -3, + -2, -2, -2, -2, -2, -2, -2, + -1, -1, -1, -1, -1, -1, -1, -1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, + 5, 5, 5, + 6, 6})); + } + } + } + } + } + } + } + this.fixAllMaintenanceIssue(); + return super.onRunningTick(aStack); + } + + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiCyclotron; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public String[] getExtraInfoData() { + String tier = tier() == 5 ? "I" : "II"; + float plasmaOut = 0; + int powerRequired = 0; + if (this.mLastRecipe != null) { + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float)this.mLastRecipe.getFluidOutput(0).amount / (float)this.mLastRecipe.mDuration; + } + } + + return new String[]{ + "COMET - Compact Cyclotron MK "+tier, + "EU Required: "+powerRequired+"EU/t", + "Stored EU: "+this.getEUVar()+" / "+maxEUStore()}; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @SuppressWarnings("deprecation") + public boolean turnCasingActive(final boolean status) { + if (this.mEnergyHatches != null) { + for (final GT_MetaTileEntity_Hatch_Muffler hatch : this.mMufflerHatches) { + hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; + } + } + if (this.mOutputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { + hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; + } + } + if (this.mInputHatches != null) { + for (final GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { + hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; + } + } + if (this.mMaintenanceHatches != null) { + for (final GT_MetaTileEntity_Hatch_Maintenance hatch : this.mMaintenanceHatches) { + hatch.mMachineBlock = status ? (byte) 44 : (byte) 44; + } + } + return true; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java new file mode 100644 index 0000000000..80eb09640d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -0,0 +1,623 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.*; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomFishable; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_IndustrialFishingPond extends GregtechMeta_MultiBlockBase { + + private boolean isUsingControllerCircuit = false; + private static final Item circuit = CI.getNumberedCircuit(0).getItem(); + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_IndustrialFishingPond> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_IndustrialFishingPond(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialFishingPond(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialFishingPond(this.mName); + } + + @Override + public String getMachineType() { + return "Fish Trap"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Fishing Pond") + .addInfo("Can process (Tier + 1) * 2 recipes") + .addInfo("Put a numbered circuit into the input bus.") + .addInfo("Circuit 14 for Fish") + .addInfo("Circuit 15 for Junk") + .addInfo("Circuit 16 for Treasure") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(9, 3, 9, true) + .addController("Front Center") + .addCasingInfo("Aquatic Casings", 64) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // fuck + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_IndustrialFishingPond> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialFishingPond>builder() + .addShape(mName, transpose(new String[][]{ + {"XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", "X X", "XXXXXXXXX"}, + {"XXXX~XXXX", "X X", "X X", "X X", "X X", "X X", "X X", "X X", "XXXXXXXXX"}, + {"XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX", "XXXXXXXXX"}, + })) + .addElement( + 'X', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_IndustrialFishingPond::addIndustrialFishingPondList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + getCasingBlock(), getCasingMeta() + ) + ) + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addIndustrialFishingPondList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 4, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 4, 1, 0) && mCasing >= 64 && checkHatch(); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()), + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE + : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER) }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex()) }; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + if (aStack != null) { + log("Found " + aStack.getDisplayName()); + if (aStack.getItem() == circuit) { + this.isUsingControllerCircuit = true; + this.mMode = aStack.getItemDamage(); + log("Found Circuit!"); + } else { + this.isUsingControllerCircuit = false; + } + } else { + this.isUsingControllerCircuit = false; + } + if (!hasGenerateRecipes) { + log("Generating Recipes."); + generateRecipes(); + } + if (hasGenerateRecipes) { + if (!checkForWater()) { + return false; + } + + log("Trying to run recipe."); + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + + if (!isUsingControllerCircuit && tItems.size() == 0) { + return false; + } + + return checkRecipeGeneric(tItemInputs, tFluidInputs, getMaxParallelRecipes(), 100, 80, 100); + } + return true; + } + + @Override + public int getMaxParallelRecipes() { + return (2 * (GT_Utility.getTier(this.getMaxInputVoltage())+1)); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialFishingPond; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings3Misc; + } + + public byte getCasingMeta() { + return 0; + } + + public int getCasingTextureIndex() { + return TAE.GTPP_INDEX(32); + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + // byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity.getWorld().setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); + + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + // log("Found Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 60; + + if (isValidWater) { + log("Filled structure."); + return true; + } + else { + + long aAvgVoltage = 0; + for (GT_MetaTileEntity_Hatch_Energy g : this.mEnergyHatches) { + if (g != null) { + aAvgVoltage += (g.maxEUInput() * g.maxAmperesIn()); + } + } + this.mEUt = (int) Math.max(30, aAvgVoltage); + this.mMaxProgresstime = (int) Math.max(((aAvgVoltage/8)*20/10), 100); + this.mProgresstime = 1; + log("Did not fill structure. Consuming "+aAvgVoltage+"eu/t to try fill."); + return false; + } + } + + private static AutoMap<AutoMap<WeightedRandomFishable>> categories = new AutoMap<AutoMap<WeightedRandomFishable>>(); + private static AutoMap<WeightedRandomFishable> categoryFish = new AutoMap<WeightedRandomFishable>(); + private static AutoMap<WeightedRandomFishable> categoryJunk = new AutoMap<WeightedRandomFishable>(); + private static AutoMap<WeightedRandomFishable> categoryLoot = new AutoMap<WeightedRandomFishable>(); + private static boolean hasGenerateRecipes = false; + private int mMode = 14; + private int mMax = 8; + + private boolean generateRecipes() { + if (!hasGenerateRecipes) { + categories.put(categoryFish); + categories.put(categoryJunk); + categories.put(categoryLoot); + for (WeightedRandomFishable h : FishPondFakeRecipe.fish) { + categoryFish.put(h); + } + for (WeightedRandomFishable h : FishPondFakeRecipe.junk) { + categoryJunk.put(h); + } + for (WeightedRandomFishable h : FishPondFakeRecipe.treasure) { + categoryLoot.put(h); + } + hasGenerateRecipes = true; + return true; + } else { + return true; + } + } + + private int getCircuit(ItemStack[] t) { + if (!this.isUsingControllerCircuit) { + for (ItemStack j : t) { + if (j.getItem() == CI.getNumberedCircuit(0).getItem()) { + // Fish + if (j.getItemDamage() == 14) { + mMax = 8 + (this.getMaxParallelRecipes() - 2); + this.mMode = 14; + break; + } + // Junk + else if (j.getItemDamage() == 15) { + this.mMode = 15; + mMax = 4; + break; + } + // Loot + else if (j.getItemDamage() == 16) { + this.mMode = 16; + mMax = 4; + break; + } else { + this.mMode = 0; + mMax = 0; + break; + } + } else { + this.mMode = 0; + mMax = 0; + break; + } + } + } + return this.mMode; + } + + // reflection map + private static Map<WeightedRandomFishable, ItemStack> reflectiveFishMap = new HashMap<WeightedRandomFishable, ItemStack>(); + + private ItemStack reflectiveFish(WeightedRandomFishable y) { + if (reflectiveFishMap.containsKey(y)) { + return reflectiveFishMap.get(y); + } + ItemStack t; + try { + t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b").get(y); + ItemStack k = ItemUtils.getSimpleStack(t, 1); + reflectiveFishMap.put(y, k); + return t; + } catch (IllegalArgumentException | IllegalAccessException e) { + } + return null; + } + + private ItemStack[] generateLoot(int mode) { + ItemStack[] mFishOutput = new ItemStack[this.mMax]; + if (this.mMode == 14) { + for (int k = 0; k < this.mMax; k++) { + if (mFishOutput[k] == null) + for (WeightedRandomFishable g : categoryFish.values()) { + if (MathUtils.randInt(0, (65 - getMaxParallelRecipes())) <= 2) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } else if (this.mMode == 15) { + for (int k = 0; k < this.mMax; k++) { + if (mFishOutput[k] == null) + for (WeightedRandomFishable g : categoryJunk.values()) { + if (MathUtils.randInt(0, 100) <= 1) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } else if (this.mMode == 16) { + for (int k = 0; k < this.mMax; k++) { + if (mFishOutput[k] == null) + for (WeightedRandomFishable g : categoryLoot.values()) { + if (MathUtils.randInt(0, 1000) <= 2) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } else { + mFishOutput = null; + } + return mFishOutput; + } + + @Override + public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, + int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { + + + + //Control Core to control the Multiblocks behaviour. + int aControlCoreTier = getControlCoreTier(); + + //If no core, return false; + if (aControlCoreTier == 0 && CORE.ConfigSwitches.requireControlCores) { + log("Invalid/No Control Core"); + return false; + } + + + // 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)); + log("Running checkRecipeGeneric(0)"); + + //Check to see if Voltage Tier > Control Core Tier + if (tTier > aControlCoreTier && CORE.ConfigSwitches.requireControlCores) { + return false; + } + + // Based on the Processing Array. A bit overkill, but very flexible. + getCircuit(aItemInputs); + + /* + * GT_Recipe tRecipe = this.getRecipeMap().findRecipe( getBaseMetaTileEntity(), + * mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, + * aItemInputs); + */ + + ItemStack[] mFishOutput = generateLoot(this.mMode); + mFishOutput = removeNulls(mFishOutput); + GT_Recipe g = new GTPP_Recipe(true, new ItemStack[] {}, mFishOutput, null, new int[] {}, aFluidInputs, mOutputFluids, 200, 16, 0); + aMaxParallelRecipes = this.canBufferOutputs(g, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("No Space"); + return false; + } + + log("Mode: " + this.mMode + " | Is loot valid? " + (mFishOutput != null)); + + int jslot = 0; + for (ItemStack x : mFishOutput) { + if (x != null) { + log( + "Slot " + jslot + " in mFishOutput contains " + x.stackSize + "x " + x.getDisplayName() + "."); + } else { + log("Slot " + jslot + " in mFishOutput was null."); + } + jslot++; + } + + // EU discount + float tRecipeEUt = (8 * 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 < (tVoltage - tRecipeEUt); parallelRecipes++) { + 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)(20 * tTimeFactor * 4); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + + //Only Overclock as high as the control circuit. + byte tTierOld = tTier; + tTier = CORE.ConfigSwitches.requireControlCores ? (byte) aControlCoreTier : tTierOld; + + // 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); + + + log("Recipe Step. [3]"); + // Collect output item types + ItemStack[] tOutputItems = mFishOutput; + + int rslot = 0; + tOutputItems = removeNulls(mFishOutput); + + for (ItemStack x : tOutputItems) { + if (x != null) { + log( + "rSlot " + rslot + " in mFishOutput contains " + x.stackSize + "x " + x.getDisplayName() + "."); + } else { + log("rSlot " + rslot + " in mFishOutput was null."); + } + rslot++; + } + + // Commit outputs + this.mOutputItems = tOutputItems; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + return true; + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java new file mode 100644 index 0000000000..d9162cea89 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java @@ -0,0 +1,629 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.ArrayList; +import java.util.Collection; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.RocketFuels; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_AirIntake; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler_Adv; +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.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_LargeRocketEngine> +{ + protected int fuelConsumption; + protected int fuelValue; + protected int fuelRemaining; + protected int freeFuelTicks = 0; + protected int euProduction = 0; + protected boolean boostEu; + + public static String mLubricantName = "Carbon Dioxide"; + public static String mCoolantName = "Liquid Hydrogen"; + + public static String mCasingName = "Turbodyne Casing"; + public static String mIntakeHatchName = "Tungstensteel Turbine Casing"; + public static String mGearboxName = "Inconel Reinforced Casing"; + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_LargeRocketEngine> STRUCTURE_DEFINITION = null; + + private final static int CASING_ID = TAE.getIndexFromPage(3, 11); + + public GregtechMetaTileEntity_LargeRocketEngine(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + this.fuelConsumption = 0; + this.fuelValue = 0; + this.fuelRemaining = 0; + this.boostEu = false; + } + + public GregtechMetaTileEntity_LargeRocketEngine(final String aName) { + super(aName); + this.fuelConsumption = 0; + this.fuelValue = 0; + this.fuelRemaining = 0; + this.boostEu = false; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 11); + } + if (mIntakeHatchName.toLowerCase().contains(".name")) { + mIntakeHatchName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 11); + } + if (mGearboxName.toLowerCase().contains(".name")) { + mGearboxName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 1); + } + if (mLubricantName.toLowerCase().contains(".")) { + mLubricantName = FluidUtils.getFluidStack("carbondioxide", 1).getLocalizedName(); + } + if (mCoolantName.toLowerCase().contains(".")) { + mCoolantName = FluidUtils.getFluidStack("liquidhydrogen", 1).getLocalizedName(); + } + + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Large Rocket Engine") + .addInfo("Supply Rocket Fuels and 1000L(3000L boosted) of " + mLubricantName + " per hour to run") + .addInfo("Supply 4L of " + mCoolantName + " per second per 2100 eu/t to boost output (optional)") + .addInfo("Consumes 2000L/s of air per 16384 eu/t produced") + .addInfo("Produces as much energy as you put fuel in") + .addInfo("Produces 1500 pollution/S per 16384 eu/t produced") + .addInfo("When producing more then 32K eu/t fuel wil be consume less efficiently (3x - 1.5x eff@57Keu/t input energy)") + .addInfo("formula: x = input of energy (10K^(1/3)/ x^(1/3)) * (40K^(1/3)/ x^(1/3))") + .addInfo("Boosting will produce 3x the amount of power but will consume 3x fuel") + .addSeparator() + .beginStructureBlock(3, 3, 10, false) + .addController("Front Center") + .addCasingInfo(mCasingName, 64) + .addCasingInfo(mGearboxName, 8) + .addStructureHint("Air Intake Hatch", 1) + .addInputBus("Side center line", 1) + .addInputHatch("Side center line", 1) + .addMaintenanceHatch("Side center line", 1) + .addDynamoHatch("Top center line", 2) + .addMufflerHatch("Back Center", 3) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_LargeRocketEngine> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_LargeRocketEngine>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CTC", "CCC"}, + {"C~C", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "CMC"}, + {"CCC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CCC"}, + })) + .addElement( + 'C', + ofBlock( + getCasingBlock(), getCasingMeta() + ) + ) + .addElement( + 'I', + ofBlock( + getGearboxBlock(), getGearboxMeta() + ) + ) + .addElement( + 'T', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineTopList, getCasingTextureIndex(), 2 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + getCasingBlock(), getCasingMeta() + ) + ) + ) + ) + .addElement( + 'S', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineSideList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + getCasingBlock(), getCasingMeta() + ) + ) + ) + ) + .addElement( + 'M', + ofHatchAdder( + GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineBackList, getCasingTextureIndex(), 3 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + this.mTecTechDynamoHatches.clear(); + this.mAllDynamoHatches.clear(); + this.mAirIntakes.clear(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 64 - 48 && mAirIntakes.size() >= 8 && checkHatch(); + } + + public final boolean addLargeRocketEngineTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } if (LoadedMods.TecTech) { + if (isThisHatchMultiDynamo(aMetaTileEntity)) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + } + return false; + } + + public final boolean addLargeRocketEngineSideList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_AirIntake) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addLargeRocketEngineBackList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_ID), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced) }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_ID) }; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return this.getMaxEfficiency(aStack) > 0; + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return super.getClientGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + } + + public int getAir() { + if (this.mAirIntakes.isEmpty() || this.mAirIntakes.size() <= 0) { + return 0; + } + else { + int totalAir = 0; + FluidStack airstack = FluidUtils.getFluidStack("air", 1); + for (GT_MetaTileEntity_Hatch_AirIntake u : this.mAirIntakes) { + if (u != null && u.mFluid != null) { + // had this trow errors cousing the machine to stop probebly fixed + FluidStack f = u.mFluid; + if (f.isFluidEqual(airstack)) { + totalAir += f.amount; + } + } + } + return totalAir; + } + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + final ArrayList<FluidStack> tFluids = this.getStoredFluids(); + FluidStack air = FluidUtils.getFluidStack("air", 1); + + int aircount = getAir() ; + if (aircount < euProduction/100) { + //log("Not Enough Air to Run "+aircount); + return false; + } + else { + boolean hasIntakeAir = this.depleteInput(FluidUtils.getFluidStack(air, euProduction/100)); + if (!hasIntakeAir) { + //log("Could not consume Air to run "+aircount); + freeFuelTicks = 0; + return false; + } + } + // reste fuel ticks incase it does not reset when it stops + if (freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0) + freeFuelTicks = 0; + + //log("Running "+aircount); + log("looking at hatch"); + final Collection<GT_Recipe> tRecipeList = GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels.mRecipeList; + + + if (tFluids.size() > 0 && tRecipeList != null) { + + if (tFluids.contains(MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) || tFluids.contains(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1)))) { + if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { + if (!consumeCO2()) { + freeFuelTicks = 0; + return false; + } + } + } else + { + freeFuelTicks = 0; + return false; + } + + if (freeFuelTicks == 0) + this.boostEu = consumeLOH(); + + for (final FluidStack hatchFluid1 : tFluids) { + if (hatchFluid1.isFluidEqual(air)) { + continue; + } + + if (freeFuelTicks == 0) { + for (final GT_Recipe aFuel : tRecipeList) { + final FluidStack tLiquid; + tLiquid = aFuel.mFluidInputs[0]; + if (hatchFluid1.isFluidEqual(tLiquid)) { + if (!consumeFuel(aFuel,hatchFluid1.amount)) { + continue; + } + this.fuelValue = aFuel.mSpecialValue; + this.fuelRemaining = hatchFluid1.amount; + this.mEUt = (int) ((this.mEfficiency < 2000) ? 0 : GT_Values.V[5]<<1); + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = euProduction/2000; + return true; + //log(""); + } + } + + } else + { + this.mEfficiencyIncrease = euProduction/2000; + freeFuelTicks--; + this.mEUt = (int) ((this.mEfficiency < 1000) ? 0 : GT_Values.V[5]<<1); + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + return true; + } + + } + } + this.mEUt = 0; + this.mEfficiency = 0; + freeFuelTicks = 0; + return false; + } + + /** + * Consumes Fuel if required. Free Fuel Ticks are handled here. + * @param aFuel + * @return + */ + public boolean consumeFuel(GT_Recipe aFuel,int amount) { + amount *= this.boostEu ? 0.3 : 0.9; + freeFuelTicks = 0; + int value = aFuel.mSpecialValue * 3; + int energy = value * amount; + if (amount < 5) + return false; + FluidStack tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], (this.boostEu ? amount * 3 : amount)); + if (!this.depleteInput(tLiquid)) { + return false; + } + else { + this.fuelConsumption = this.boostEu ? amount * 3 : amount; + this.freeFuelTicks = 20; + setEUProduction(energy); + return true; + } + } + + public void setEUProduction(int energy){ + energy /= 20; + double energyEfficiency; + double tDevideEnergy = Math.cbrt(energy); + if (energy > 10000) { + //cbrt(10 000) / + energyEfficiency = ((double) 21.5443469/tDevideEnergy); + if (energy >= 40000) + //cbrt(40 000) / + energyEfficiency *= ((double)34.19951893/tDevideEnergy); + energyEfficiency *= energy; + } + else { + energyEfficiency = energy; + } + euProduction = (int) ((double) energyEfficiency * 1.84); + if (this.boostEu) + euProduction *= 3; + } + + public boolean consumeCO2() { + if (this.depleteInput(MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) || this.depleteInput(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1)))) { + return true; + } + else { + return false; + } + } + + public boolean consumeLOH() { + int LOHamount = (3 * euProduction)/1000; + return this.depleteInput(FluidUtils.getFluidStack(RocketFuels.Liquid_Hydrogen, LOHamount)); //(40 * ((long) euProduction / 10000)) + } + + @Override + public boolean addEnergyOutput(long aEU) { + if (aEU <= 0) { + return true; + } + if (mAllDynamoHatches.size() > 0) { + return addEnergyOutputMultipleDynamos(aEU, true); + } + return false; + } + + + public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { + int injected = 0; + long totalOutput = 0; + long aFirstVoltageFound = -1; + boolean aFoundMixedDynamos = false; + for (GT_MetaTileEntity_Hatch aDynamo : mAllDynamoHatches) { + if( aDynamo == null ) { + return false; + } + if (isValidMetaTileEntity(aDynamo)) { + long aVoltage = aDynamo.maxEUOutput(); + long aTotal = aDynamo.maxAmperesOut() * aVoltage; + // Check against voltage to check when hatch mixing + if (aFirstVoltageFound == -1) { + aFirstVoltageFound = aVoltage; + } + else { + /** + * Calcualtes overclocked ness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + * @param mAmperage - should be 1 ? + */ + //Long time calculation + if (aFirstVoltageFound != aVoltage) { + aFoundMixedDynamos = true; + } + } + totalOutput += aTotal; + } + } + + if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) { + explodeMultiblock(); + return false; + } + + long leftToInject; + //Long EUt calculation + long aVoltage; + //Isnt too low EUt check? + int aAmpsToInject; + int aRemainder; + + //xEUt *= 4;//this is effect of everclocking + for (GT_MetaTileEntity_Hatch aDynamo : mAllDynamoHatches) { + if (isValidMetaTileEntity(aDynamo)) { + leftToInject = aEU - injected; + aVoltage = aDynamo.maxEUOutput(); + aAmpsToInject = (int) (leftToInject / aVoltage); + aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); + long powerGain; + for (int i = 0; i < Math.min(aDynamo.maxAmperesOut(), aAmpsToInject + 1); i++) { + if (i == Math.min(aDynamo.maxAmperesOut(), aAmpsToInject)){ + powerGain = aRemainder; + }else{ + powerGain = aVoltage; + } + aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(powerGain, false); + injected += powerGain; + } + } + } + return injected > 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mRuntime%20 == 0) { + if (mMufflerHatches.size() == 1 && mMufflerHatches.get(0) instanceof GT_MetaTileEntity_Hatch_Muffler_Adv) { + GT_MetaTileEntity_Hatch_Muffler_Adv tMuffler = (GT_MetaTileEntity_Hatch_Muffler_Adv) mMufflerHatches.get(0); + if (!tMuffler.hasValidFilter()) { + ArrayList<ItemStack> tInputs = getStoredInputs(); + for (ItemStack tItem : tInputs) { + if (tMuffler.isAirFilter(tItem)) { + tMuffler.mInventory[0] = tItem.copy(); + depleteInput(tItem); + updateSlots(); + break; + } + } + } + } + } + super.onRunningTick(aStack); + return true; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + public byte getCasingMeta() { + return 11; + } + + public Block getGearboxBlock() { + return ModBlocks.blockCasings3Misc; + } + + public byte getGearboxMeta() { + return 1; + } + + public byte getCasingTextureIndex() { + return (byte) CASING_ID; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_LargeRocketEngine(this.mName); + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("freeFuelTicks", freeFuelTicks); + aNBT.setInteger("euProduction", euProduction); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + freeFuelTicks = aNBT.getInteger("freeFuelTicks"); + euProduction = aNBT.getInteger("euProduction"); + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 1; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return euProduction; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 75 * ( euProduction / 10000); + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return true; + } + + @Override + public String[] getExtraInfoData() { + return new String[] { + "Rocket Engine", + "Current Air: "+getAir(), + "Current Pollution: " + getPollutionPerTick(null), + "Time until next fuel consumption: "+freeFuelTicks, + "Current Output: " + this.mEUt * this.mEfficiency / 10000 + " EU/t", + "Fuel Consumption: " + (this.fuelConsumption) + "L/s", + "Fuel Value: " + this.fuelValue*3 + " EU/L", + "Fuel Remaining: " + this.fuelRemaining + " Litres", + "Current Efficiency: " + this.mEfficiency / 100 + "%", + (this.getIdealStatus() == this.getRepairStatus()) ? "No Maintainance issues" : "Needs Maintainance" }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Rocket Engine"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java new file mode 100644 index 0000000000..9be787e922 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java @@ -0,0 +1,341 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.ArrayList; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_LargeSemifluidGenerator extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_LargeSemifluidGenerator> STRUCTURE_DEFINITION = null; + + protected int fuelConsumption = 0; + protected int fuelValue = 0; + protected int fuelRemaining = 0; + protected boolean boostEu = false; + + public GregtechMetaTileEntity_LargeSemifluidGenerator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_LargeSemifluidGenerator(String aName) { + super(aName); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Large Semifluid Generator") + .addInfo("Engine Intake Casings must not be obstructed in front (only air blocks)") + .addInfo("Supply Semifluid Fuels and 2000L of Lubricant per hour to run.") + .addInfo("Supply 80L of Oxygen per second to boost output (optional).") + .addInfo("Default: Produces 2048EU/t at 100% efficiency") + .addInfo("Boosted: Produces 6144EU/t at 150% efficiency") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 4, false) + .addController("Front Center") + .addCasingInfo("Stable Titanium Machine Casing", 16) + .addCasingInfo("Steel Gear Box Machine Casing", 2) + .addCasingInfo("Engine Intake Machine Casing", 8) + .addInputHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .addDynamoHatch("Back Center", 2) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(50), new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DIESEL_ENGINE)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(50)}; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeDieselEngine.png"); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<FluidStack> tFluids = getStoredFluids(); + + // Check for lubricant and oxygen first, so we can compute costs ahead of time. + // This will allow us to check costs without needing to actually try to deplete fluids + // (wasting earlier fluids in the check if later fluids turn out to be insufficient). + FluidStack lubricant = Materials.Lubricant.getFluid(0L); + FluidStack oxygen = Materials.Oxygen.getGas(0L); + for (FluidStack hatchFluid : tFluids) { + if (hatchFluid.isFluidEqual(lubricant)) { + lubricant.amount = Math.max(lubricant.amount, hatchFluid.amount); + } else if (hatchFluid.isFluidEqual(oxygen)) { + oxygen.amount = Math.max(oxygen.amount, hatchFluid.amount); + } + } + boostEu = oxygen.amount >= 4L; + long lubricantCost = boostEu ? 2L : 1L; + if (lubricant.amount < lubricantCost) { + return false; + } + + for (FluidStack hatchFluid : tFluids) { //Loops through hatches + GT_Recipe aFuel = GTPP_Recipe_Map.sSemiFluidLiquidFuels.findFuel(hatchFluid); + if (aFuel == null) { + // Not a valid semi-fluid fuel. + continue; + } + + int newEUt = boostEu ? 4096 : 2048; + fuelConsumption = newEUt / aFuel.mSpecialValue; //Calc fuel consumption + FluidStack tLiquid = new FluidStack(hatchFluid.getFluid(), fuelConsumption); + if(depleteInput(tLiquid)) { //Deplete that amount + // We checked beforehand, so both of these depletions should succeed. + // But check the return values anyway just to be safe. + if (boostEu) { + if (!depleteInput(Materials.Oxygen.getGas(4L))) { + return false; + } + } + //Deplete Lubricant. 2000L should = 1 hour of runtime (if baseEU = 2048) + if(mRuntime % 72 == 0 || mRuntime == 0) { + if(!depleteInput(Materials.Lubricant.getFluid(lubricantCost))) { + return false; + } + } + + fuelValue = aFuel.mSpecialValue; + fuelRemaining = hatchFluid.amount; //Record available fuel + this.mEUt = mEfficiency < 2000 ? 0 : newEUt; //Output 0 if startup is less than 20% + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 15; + return true; + } + } + + this.mEUt = 0; + this.mEfficiency = 0; + return false; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_LargeSemifluidGenerator> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_LargeSemifluidGenerator>builder() + .addShape(mName, transpose(new String[][]{ + {"III", "CCC", "CCC", "CCC"}, + {"I~I", "CGC", "CGC", "CMC"}, + {"III", "CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_LargeSemifluidGenerator::addLargeSemifluidGeneratorList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + getCasingBlock(), getCasingMeta() + ) + ) + ) + ) + .addElement( + 'G', + ofBlock( + getGearboxBlock(), getGearboxMeta() + ) + ) + .addElement( + 'I', + ofBlock( + getIntakeBlock(), getIntakeMeta() + ) + ) + .addElement( + 'M', + ofHatchAdder( + GregtechMetaTileEntity_LargeSemifluidGenerator::addLargeSemifluidGeneratorBackList, getCasingTextureIndex(), 2 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mDynamoHatches.clear(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 16 && checkHatch(); + } + + public final boolean addLargeSemifluidGeneratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public final boolean addLargeSemifluidGeneratorBackList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo || this.isThisHatchMultiDynamo(aTileEntity)){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getCasingMeta() { + return 2; + } + + public Block getIntakeBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getIntakeMeta() { + return 13; + } + + public Block getGearboxBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getGearboxMeta() { + return 3; + } + + public byte getCasingTextureIndex() { + return 50; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_LargeSemifluidGenerator(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + public int getMaxEfficiency(ItemStack aStack) { + return boostEu ? 15000 : 10000; + } + + @Override + public int getPollutionPerSecond(ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiLargeSemiFluidGenerator; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return true; + } + + @Override + public String[] getExtraInfoData() { + return new String[]{ + "Large Semifluid Generator", + "Current Output: " + mEUt * mEfficiency / 10000 + " EU/t", + "Fuel Consumption: " + fuelConsumption + "L/t", + "Fuel Value: " + fuelValue + " EU/L", + "Fuel Remaining: " + fuelRemaining + " Litres", + "Current Efficiency: " + (mEfficiency / 100) + "%", + getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Semifluid Generator"; + } + + @Override + public int getMaxParallelRecipes() { + return 0; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java new file mode 100644 index 0000000000..f016288547 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java @@ -0,0 +1,425 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.ArrayList; +import java.util.Collection; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.*; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MatterFab; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlockBase { + + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3200; + + private int mMatterProduced = 0; + private int mScrapProduced = 0; + private int mAmplifierProduced = 0; + private int mScrapUsed = 0; + private int mAmplifierUsed = 0; + + public static String mCasingName1 = "Matter Fabricator Casing"; + public static String mCasingName2 = "Containment Casing"; + public static String mCasingName3 = "Matter Generation Coil"; + + private int mMode = 0; + + private final static int MODE_SCRAP = 1; + private final static int MODE_UU = 0; + + public static boolean sRequiresUUA = false; + private static FluidStack[] mUU = new FluidStack[2]; + private static ItemStack mScrap[] = new ItemStack[2]; + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_MassFabricator> STRUCTURE_DEFINITION = null; + + public int getAmplifierUsed(){ + return this.mAmplifierUsed; + } + + public int getMatterProduced(){ + return this.mMatterProduced; + } + + public GregtechMetaTileEntity_MassFabricator(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + mCasingName1 = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasingsMisc, 9); + mCasingName2 = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 15); + mCasingName3 = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasingsMisc, 8); + } + + public GregtechMetaTileEntity_MassFabricator(final String aName) { + super(aName); + mCasingName1 = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasingsMisc, 9); + mCasingName2 = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 15); + mCasingName3 = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasingsMisc, 8); + } + + @Override + public String getMachineType() { + return "Mass Fabricator / Recycler"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + + if (mCasingName1.toLowerCase().contains(".name")) { + mCasingName1 = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasingsMisc, 9); + } + if (mCasingName2.toLowerCase().contains(".name")) { + mCasingName2 = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 15); + } + if (mCasingName3.toLowerCase().contains(".name")) { + mCasingName3 = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasingsMisc, 8); + } + + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Matter Fabricator") + .addInfo("Produces UU-A, UU-M & Scrap") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(5, 4, 5, true) + .addController("Front Center") + .addCasingInfo(mCasingName3, 9) + .addCasingInfo(mCasingName2, 24) + .addCasingInfo(mCasingName1, 40) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addOutputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) + .addMufflerHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(9)), + new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_MatterFab_Active_Animated : TexturesGtBlock.Overlay_MatterFab_Animated)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(9))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MatterFabricator"; + } + + public static ItemStack getScrapPile() { + if (mScrap[0] == null) { + mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); + } + return mScrap[0]; + } + public static ItemStack getScrapBox() { + if (mScrap[1] == null) { + mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); + } + return mScrap[1]; + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); + } + + @Override + public void onConfigLoad(final GT_Config aConfig) { + super.onConfigLoad(aConfig); + sDurationMultiplier = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUM_Duration_Multiplier", sDurationMultiplier); + sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_per_UUM", sUUAperUUM); + sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Speed_Bonus", sUUASpeedBonus); + sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Requirement", sRequiresUUA); + //Materials.UUAmplifier.mChemicalFormula = ("Mass Fabricator Eff/Speed Bonus: x" + sUUASpeedBonus); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric(tItemInputs, tFluidInputs, 4, 80, 00, 100); + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_MassFabricator> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_MassFabricator>builder() + .addShape(mName, transpose(new String[][]{ + {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"}, + {"CGGGC", "G---G", "G---G", "G---G", "CGGGC"}, + {"CGGGC", "G---G", "G---G", "G---G", "CGGGC"}, + {"CC~CC", "CHHHC", "CHHHC", "CHHHC", "CCCCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_MassFabricator::addMassFabricatorList, TAE.GTPP_INDEX(9), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 9 + ) + ) + ) + ) + .addElement( + 'H', + ofBlock( + ModBlocks.blockCasingsMisc, 8 + ) + ) + .addElement( + 'G', + ofBlock( + ModBlocks.blockCasings3Misc, 15 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 2, 3, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 2, 3, 0) && mCasing >= 40 && checkHatch(); + } + + public final boolean addMassFabricatorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiMassFabricator; + } + + @Override + public int getAmountOfOutputs() { + return 10; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MassFabricator(this.mName); + } + + public boolean doesHatchContainUUA() { + if (mUU[0] == null) { + mUU[0] = Materials.UUAmplifier.getFluid(100); + } + if (mUU[1] == null) { + mUU[1] = Materials.UUMatter.getFluid(100); + } + + if (mUU[0] != null && mUU[1] != null) { + for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { + if (g.getFluid() != null) { + if (g.mFluid.isFluidEqual(mUU[0])) { + return true; + } + } + } + } + + return false; + } + + + /** + * Special Recipe Handling + */ + + + @Override + public GT_Recipe_Map getRecipeMap() { + return this.mMode == MODE_SCRAP ? GT_Recipe_Map.sRecyclerRecipes : GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes; + //return Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes; + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll) { + + if (this.mMode == MODE_SCRAP) { + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + GT_Recipe c = new GTPP_Recipe(false, new ItemStack[] { GT_Utility.copyAmount(1, aItemInputs[0]) }, + GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(64, aItemInputs[0]), 0) == null ? null + : new ItemStack[] { ItemList.IC2_Scrap.get(1) }, + null, new int[] { 2000 }, null, null, 100, + (int) gregtech.api.enums.GT_Values.V[2], 0); + + // EU discount + float tRecipeEUt = (c.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!c.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + this.mEUt = (int) gregtech.api.enums.GT_Values.V[tTier]; + this.mMaxProgresstime = 10; + return true; + } + + return super.checkRecipeGeneric(c, getMaxParallelRecipes(), getEuDiscountForParallelism(), aSpeedBonusPercent, aOutputChanceRoll, true); + } + + //Return normal Recipe handling + return super.checkRecipeGeneric(aItemInputs, aFluidInputs, getMaxParallelRecipes(), getEuDiscountForParallelism(), aSpeedBonusPercent, aOutputChanceRoll, true); + } + + @Override + public int getMaxParallelRecipes() { + return this.mMode == MODE_SCRAP ? 32 : 2 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); + } + + @Override + public int getEuDiscountForParallelism() { + return 80; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + int aMode = this.mMode + 1; + if (aMode > 1) { + this.mMode = MODE_UU; + PlayerUtils.messagePlayer(aPlayer, "Mode ["+this.mMode+"]: Matter/AmpliFabricator"); + } + else if (aMode == 1) { + this.mMode = MODE_SCRAP; + PlayerUtils.messagePlayer(aPlayer, "Mode ["+this.mMode+"]: Recycler"); + } + else { + this.mMode = MODE_SCRAP; + PlayerUtils.messagePlayer(aPlayer, "Mode ["+this.mMode+"]: Recycler"); + } + GT_Recipe_Map r = this.getRecipeMap(); + final Collection<GT_Recipe> x = r.mRecipeList; + Logger.INFO("Dumping " + r.mUnlocalizedName + " Recipes for Debug. size: "+x.size()); + for (final GT_Recipe newBo : x) { + Logger.INFO("========================"); + Logger.INFO("Dumping Input: " + ItemUtils.getArrayStackNames(newBo.mInputs)); + Logger.INFO("Dumping Inputs " + ItemUtils.getFluidArrayStackNames(newBo.mFluidInputs)); + Logger.INFO("Dumping Duration: " + newBo.mDuration); + Logger.INFO("Dumping EU/t: " + newBo.mEUt); + Logger.INFO("Dumping Output: " + ItemUtils.getArrayStackNames(newBo.mOutputs)); + Logger.INFO("Dumping Output: " + ItemUtils.getFluidArrayStackNames(newBo.mFluidOutputs)); + Logger.INFO("========================"); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mScrapProduced", mScrapProduced); + aNBT.setInteger("mAmplifierProduced", mAmplifierProduced); + aNBT.setInteger("mMatterProduced", mMatterProduced); + aNBT.setInteger("mScrapUsed", mScrapUsed); + aNBT.setInteger("mAmplifierUsed", mAmplifierUsed); + aNBT.setInteger("mMode", mMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mScrapProduced = aNBT.getInteger("mScrapProduced"); + mAmplifierProduced = aNBT.getInteger("mAmplifierProduced"); + mMatterProduced = aNBT.getInteger("mMatterProduced"); + mScrapUsed = aNBT.getInteger("mScrapUsed"); + mAmplifierUsed = aNBT.getInteger("mAmplifierUsed"); + mMode = aNBT.getInteger("mMode"); + super.loadNBTData(aNBT); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java new file mode 100644 index 0000000000..f86ecf3196 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java @@ -0,0 +1,238 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +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.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.item.ItemStack; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase { + + private int mCasing; + private IStructureDefinition<GregtechMetaTileEntity_Refinery> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_Refinery(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_Refinery(final String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Fuel Refinery"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Fission Fuel Processing Unit") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 9, 3, false) + .addController("Bottom Center") + .addCasingInfo("Hastelloy-X Structural Casing", 7) + .addCasingInfo("Incoloy-DS Fluid Containment Block", 5) + .addCasingInfo("Zeron-100 Reactor Shielding", 4) + .addCasingInfo("Hastelloy-N Sealant Blocks", 17) + .addInputHatch("Base platform", 1) + .addOutputHatch("Base platform", 1) + .addOutputBus("Base platform", 1) + .addMufflerHatch("Base platform", 1) + .addMaintenanceHatch("Base platform", 1) + .addEnergyHatch("Base platform", 1) + .addStructureInfo("Muffler's Tier must be LuV+") + .addStructureInfo("4x Input Hatches, 2x Output Hatches, 1x Output Bus") + .addStructureInfo("1x Muffler, 1x Maintenance Hatch, 1x Energy Hatch") + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(18)), new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(18))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return "MatterFabricator"; + } + + @Override + public GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + //this.resetRecipeMapForAllInputHatches(); + for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { + g.mRecipeMap = null; + } + boolean ab = super.checkRecipeGeneric(); + //Logger.INFO("Did Recipe? "+ab); + return ab; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + public final boolean addRefineryList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler && ((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity).mTier >= 6) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public IStructureDefinition<GregtechMetaTileEntity_Refinery> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_Refinery>builder() + .addShape(mName, transpose(new String[][]{ + {" ", " N ", " "}, + {" N ", "NIN", " N "}, + {" N ", "NIN", " N "}, + {" N ", "NIN", " N "}, + {" Z ", "ZIZ", " Z "}, + {" N ", "NIN", " N "}, + {"XXX", "XXX", "XXX"}, + {"X~X", "XXX", "XXX"}, + })) + .addElement( + 'X', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_Refinery::addRefineryList, TAE.GTPP_INDEX(18), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 2 + ) + ) + ) + ) + .addElement( + 'I', + ofBlock( + ModBlocks.blockCasings2Misc, 3 + ) + ) + .addElement( + 'N', + ofBlock( + ModBlocks.blockCasings2Misc, 1 + ) + ) + .addElement( + 'Z', + ofBlock( + ModBlocks.blockCasingsMisc, 13 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 7, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + if (checkPiece(mName, 1, 7, 0) && mCasing >= 7) { + if (this.mInputHatches.size() == 4 && this.mOutputHatches.size() == 2 && + this.mOutputBusses.size() == 1 && this.mMufflerHatches.size() == 1 && + this.mMaintenanceHatches.size() == 1 && this.mEnergyHatches.size() == 1) { + this.resetRecipeMapForAllInputHatches(this.getRecipeMap()); + return true; + } + } + return false; + } + + @Override + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiRefinery; + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 5; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_Refinery(this.mName); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java new file mode 100644 index 0000000000..d42b33a403 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java @@ -0,0 +1,702 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +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 gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.block.ModBlocks; +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.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.tileentities.misc.TileEntitySolarHeater; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class GregtechMetaTileEntity_SolarTower +extends GregtechMeta_MultiBlockBase { + + //862 + private static final int mCasingTextureID = TAE.getIndexFromPage(3, 4); + public static String mCasingName = ""; + private int mHeight = 0; + private int mHeatLevel = 0; + + public GregtechMetaTileEntity_SolarTower(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 4); + } + + public GregtechMetaTileEntity_SolarTower(final String aName) { + super(aName); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 4); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_SolarTower(this.mName); + } + + @Override + public String getMachineType() { + return "Solar Tower"; + } + + @Override + public String[] getTooltip() { + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 4); + } + return new String[]{ + "Contributing Green Energy towards the future", + mCasingName+"s for the base of the tower", + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(212)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == 0 || aSide == 1) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(3, 6)), + new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(3, 6))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing <= 1; + } + + private Set<String> mCachedReflectors = new HashSet<String>(); + + public Set<String> getConnectedSolarReflectors(){ + Set<String> mValidTilePositions = new HashSet<String>(); + IGregTechTileEntity tTileEntity; + Map<String, BlockPos> mFastMap = new HashMap<String, BlockPos>(); + for (int x = -64; x <= 64; x++) { + for (int z = -64; z <= 64; z++) { + int aX, aY, aZ; + aX = this.getBaseMetaTileEntity().getXCoord(); + aY = this.mHeight; + aZ = this.getBaseMetaTileEntity().getZCoord(); + BlockPos b = new BlockPos(aX+x, aY, aZ+z, this.getBaseMetaTileEntity().getWorld()); + + tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntity(aX + x, this.mHeight, aZ + z); + if (tTileEntity == null) { + continue; + } + else { + Logger.INFO("Found Tile Entity at "+b.getLocationString()); + if (tTileEntity.getMetaTileEntity() instanceof TileEntitySolarHeater) { + TileEntitySolarHeater mTile = (TileEntitySolarHeater) tTileEntity.getMetaTileEntity(); + if (mTile != null) { + b = new BlockPos(tTileEntity.getXCoord(), tTileEntity.getYCoord(), tTileEntity.getZCoord(), tTileEntity.getWorld()); + if (!mTile.mHasTower || mTile.mSolarTower == null) { + Logger.INFO("Found Solar Reflector, Injecting Data."); + mTile.setSolarTower(b); + } + mFastMap.put(b.getUniqueIdentifier(), b); + } + } + else { + continue; + } + } + + if (addToMachineList(tTileEntity, mCasingTextureID)) { + continue; + } + } + } + + for (BlockPos p : mFastMap.values()) { + if (mValidTilePositions.add(p.getUniqueIdentifier())); + } + mCachedReflectors = mValidTilePositions; + return mCachedReflectors; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + //this.mEfficiencyIncrease = 100; + //this.mMaxProgresstime = 100; + //this.mEUt = -4; + return true; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + this.mHeight = 0; + for (int i = 0; i <= 19; i++) { + if (!checkLayer(i)) { + Logger.INFO("Invalid Structure on Y level "+i); + return false; + } + } + if (mMaintenanceHatches.size() != 1) { + Logger.INFO("Bad Hatches"); + return false; + } + + this.mHeight = this.getBaseMetaTileEntity().getYCoord() - 19; + Logger.INFO("Built Structure"); + if (!aBaseMetaTileEntity.getWorld().isRemote) + getConnectedSolarReflectors(); + 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; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + + public byte getCasingMeta() { + return 4; + } + + + public byte getCasingMeta2() { + return 5; + } + + + public byte getCasingMeta3() { + return 6; + } + + public boolean isValidCasingBlock(Block aBlock, int aMeta) { + if (aBlock == getCasingBlock() && aMeta == getCasingMeta()) { + return true; + } + if (aBlock == getCasingBlock() && aMeta == getCasingMeta2()) { + return true; + } + if (aBlock == getCasingBlock() && aMeta == getCasingMeta3()) { + return true; + } + Logger.INFO("Found "+(aBlock != null ? aBlock.getLocalizedName() : "Air") + "With Meta "+aMeta); + return false; + } + + public byte getCasingTextureIndex() { + return (byte) mCasingTextureID; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mHeight > 3) {} + + + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mHeight", mHeight); + aNBT.setInteger("mHeatLevel", mHeatLevel); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mHeight = aNBT.getInteger("mHeight"); + mHeatLevel = aNBT.getInteger("mHeatLevel"); + } + + public boolean checkLayer(int aY) { + if (aY >= 0 && aY <= 6) { + return checkTopLayers(-aY); + } + if (aY >= 7 && aY <= 16) { + return checkTowerLayer(-aY); + } + else if (aY >= 17 && aY <= 19) { + return checkBaseLayer(-aY); + } + Logger.INFO("Bad Y level to check"); + return false; + } + + public boolean checkTopLayers(int aY) { + Block aBlock; + int aMeta; + + if (aY == 0) { + return true; + } else if (aY == -1) { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + aBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z); + aMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z); + if (aBlock == getCasingBlock() && aMeta == getCasingMeta3()) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } + } + } else if (aY == -2 || aY == -6) { + for (int x = -2; x <= 2; x++) { + for (int z = -2; z <= 2; z++) { + aBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z); + aMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z); + //Edge Casing + if (x == -2 || x == 2 || z == -2 || z == 2) { + //Edge Corners + if ((x == 2 || x == -2) && (z == 2 | z == -2)) { + if (!getBaseMetaTileEntity().getAirOffset(x, aY, z)) { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block on Outside Corner "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + else { + continue; + } + } + else { + //Edge Sides + if (aBlock == getCasingBlock() && aMeta == getCasingMeta3()) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } + } + + //Internal + else { + if (aBlock == getCasingBlock() && aMeta == getCasingMeta2()) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block Internally on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } + } + } + } + //Top Layers 7x7 + else if (aY == -3 || aY == -5) { + for (int x = -3; x <= 3; x++) { + for (int z = -3; z <= 3; z++) { + aBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z); + aMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z); + //Edge Casing + if (x == -3 || x == 3 || z == -3 || z == 3) { + + //3, 3 + //2, 3 + //3, 2 + + //Air Spacing + if (x == 3 && (z == -3 || z == -2 || z == 2 || z == 3)) { + if (!getBaseMetaTileEntity().getAirOffset(x, aY, z)) { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block on Outside Corner "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + else { + continue; + } + } + else if (x == -3 && (z == -3 || z == -2 || z == 2 || z == 3)) { + if (!getBaseMetaTileEntity().getAirOffset(x, aY, z)) { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block on Outside Corner "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + else { + continue; + } + } + else if (z == 3 && (x == -3 || x == -2 || x == 2 || x == 3)) { + if (!getBaseMetaTileEntity().getAirOffset(x, aY, z)) { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block on Outside Corner "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + else { + continue; + } + } + else if (z == -3 && (x == -3 || x == -2 || x == 2 || x == 3)) { + if (!getBaseMetaTileEntity().getAirOffset(x, aY, z)) { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block on Outside Corner "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + else { + continue; + } + } + else { + //Edge Sides + if (aBlock == getCasingBlock() && aMeta == getCasingMeta3()) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } + } + else if ((x == -2 || x == 2) & (z == -2 || z == 2)) { + if (aBlock == getCasingBlock() && aMeta == getCasingMeta3()) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } + //Internal + else { + if (aBlock == getCasingBlock() && aMeta == getCasingMeta2()) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block Internally on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } + } + } + } + //Midle Top Layer 9x9 + else if (aY == -4) { + //Check Inner 5x5 + for (int x = -2; x <= 2; x++) { + for (int z = -2; z <= 2; z++) { + if (getBaseMetaTileEntity().getBlockOffset(x, aY, z) != getCasingBlock() && this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z) != getCasingMeta2()) { + Logger.INFO("Error at offset: X:" + x + ", Y:" + aY + ", Z:" + z); + return false; + } + else { + continue; + } + } + } + //Check Pos Sides + for (int z = -1; z <= -1; z++) { + if (getBaseMetaTileEntity().getBlockOffset(3, aY, z) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(3, aY, z) == getCasingMeta2()) { + continue; + } else if (getBaseMetaTileEntity().getBlockOffset(-3, aY, z) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(-3, aY, z) == getCasingMeta2()) { + continue; + } else { + Logger.INFO("1 Error at offset: X:3/-3" + ", Y:" + aY + ", Z:" + z); + return false; + } + + } + for (int x = -1; x <= -1; x++) { + if (getBaseMetaTileEntity().getBlockOffset(x, aY, 3) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, 3) == getCasingMeta2()) { + continue; + } else if (getBaseMetaTileEntity().getBlockOffset(x, aY, -3) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, -3) == getCasingMeta2()) { + continue; + } else { + Logger.INFO("1 Error at offset: X:" + x + ", Y:" + aY + ", Z:3/-3"); + return false; + } + } + + //Corner Casings + for (int z = -2; z <= -2; z++) { + if (z == -2 || z == 2) { + if (getBaseMetaTileEntity().getBlockOffset(3, aY, z) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(3, aY, z) == getCasingMeta3()) { + continue; + } else if (getBaseMetaTileEntity().getBlockOffset(-3, aY, z) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(-3, aY, z) == getCasingMeta3()) { + continue; + } else { + Logger.INFO("2 Error at offset: X:3/-3" + ", Y:" + aY + ", Z:" + z); + return false; + } + } + } + for (int x = -2; x <= -2; x++) { + if (x == -2 || x == 2) { + if (getBaseMetaTileEntity().getBlockOffset(x, aY, 3) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, 3) == getCasingMeta3()) { + continue; + } else if (getBaseMetaTileEntity().getBlockOffset(x, aY, -3) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, -3) == getCasingMeta3()) { + continue; + } else { + Logger.INFO("2 Error at offset: X:" + x + ", Y:" + aY + ", Z:3/-3"); + return false; + } + } + } + //Check Sides Casings + for (int z = -1; z <= -1; z++) { + if (getBaseMetaTileEntity().getBlockOffset(4, aY, z) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(4, aY, z) == getCasingMeta3()) { + continue; + } else if (getBaseMetaTileEntity().getBlockOffset(-4, aY, z) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(-4, aY, z) == getCasingMeta3()) { + continue; + } else { + Logger.INFO("1 Error at offset: X:3/-3" + ", Y:" + aY + ", Z:" + z); + return false; + } + + } + for (int x = -1; x <= -1; x++) { + if (getBaseMetaTileEntity().getBlockOffset(x, aY, 4) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, 4) == getCasingMeta3()) { + continue; + } else if (getBaseMetaTileEntity().getBlockOffset(x, aY, -4) == getCasingBlock() + && this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, -4) == getCasingMeta3()) { + continue; + } else { + Logger.INFO("1 Error at offset: X:" + x + ", Y:" + aY + ", Z:3/-3"); + return false; + } + } + } + return true; + } + + public boolean checkTowerLayer(int aY) { + Block aBlock; + int aMeta; + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + aBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z); + aMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z); + if (x == -1 || x == 1 || z == -1 || z == 1) { + if (aBlock == getCasingBlock() && aMeta == getCasingMeta()) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block Externally on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } else { + if (aBlock == getCasingBlock() && aMeta == getCasingMeta2()) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block Internally on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } + } + } + return true; + } + + public boolean checkBaseLayer(int aY) { + Block aBlock; + int aMeta; + + int requiredMeta = getCasingMeta2(); + if (aY == -19) { + requiredMeta = getCasingMeta(); + } + + for (int x = -3; x <= 3; x++) { + for (int z = -3; z <= 3; z++) { + aBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z); + aMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z); + + if ((x == 3 && z == 3) || (x == 2 && z == 2) || (x == 3 && z == 2) || (x == 2 && z == 3)) { + if (!getBaseMetaTileEntity().getAirOffset(x, aY, z)) { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + return false; + } + } + else if ((x == -3 && z == -3) || (x == -2 && z == -2) || (x == -3 && z == -2) || (x == -2 && z == -3)) { + if (!getBaseMetaTileEntity().getAirOffset(x, aY, z)) { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + return false; + } + } + else if ((x == -3 && z == 3) || (x == -2 && z == 2) || (x == -3 && z == 2) || (x == -2 && z == 3)) { + if (!getBaseMetaTileEntity().getAirOffset(x, aY, z)) { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + return false; + } + } + else if ((x == 3 && z == -3) || (x == 2 && z == -2) || (x == 3 && z == -2) || (x == 2 && z == -3)) { + if (!getBaseMetaTileEntity().getAirOffset(x, aY, z)) { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + return false; + } + } + else { + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z); + if (addToMachineList(tTileEntity, mCasingTextureID)) { + continue; + } + if (x == 0 && z == 0) { + if (aBlock == getCasingBlock() && aMeta == requiredMeta) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block Internally on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } + else { + if (aBlock == getCasingBlock() && aMeta == getCasingMeta()) { + continue; + } else { + Logger.INFO("Error at offset: X:"+x+", Y:"+aY+", Z:"+z); + Logger.INFO("Found Bad Block Internally on Layer "+aY+": "+(aBlock != null ? aBlock.getLocalizedName() : "Air")+" | Meta: "+aMeta); + return false; + } + } + } + } + } + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + //Add Heat every second + if (aTick % 20 == 0) { + + //Add Heat First, if sources available + int aCacheSize = this.mCachedReflectors.size(); + if (aCacheSize > 0) { + int aCount = aCacheSize; + for (int i = 0; i < aCount; i++) { + this.mHeatLevel++; + } + } + + //Remove Heat, based on time of day + World w = this.getBaseMetaTileEntity().getWorld(); + if (w != null) { + int aRemovalFactor = 0; + if (w.isDaytime()) { + aRemovalFactor = 1; + } + else { + aRemovalFactor = 3; + } + for (int i = 0; i<MathUtils.randInt((aCacheSize/10), (aCacheSize*10)); i++){ + this.mHeatLevel -= aRemovalFactor; + } + } + } + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (this.mCachedReflectors.isEmpty()) { + if (aTick % (30*20) == 0) { + this.getConnectedSolarReflectors(); + } + } + } + + @Override + public void onRemoval() { + this.mCachedReflectors.clear(); + super.onRemoval(); + } + + @Override + public String[] getExtraInfoData() { + return new String[] { + "Internal Heat Level: "+this.mHeatLevel, + "Connected Solar Reflectors: "+this.mCachedReflectors.size() + }; + } + + + + + + + + + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java new file mode 100644 index 0000000000..4759457d8d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java @@ -0,0 +1,486 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gtPlusPlus.core.lib.CORE; +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 gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.lib.CORE; +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.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.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { + + private int mLevel = -1; + private int mCasing; + private IStructureDefinition<GregtechMTE_AlgaePondBase> STRUCTURE_DEFINITION = null; + private int checkMeta; + + public GregtechMTE_AlgaePondBase(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_AlgaePondBase(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_AlgaePondBase(this.mName); + } + + @Override + public String getMachineType() { + return "Algae Pond"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Grows Algae!") + .addInfo("Controller Block for the Algae Farm") + .addInfo("Provide compost to boost production by one tier") + .addInfo("Does not require power or maintenance") + .addInfo("All Machine Casings must be the same tier, this dictates machine speed.") + .addInfo("Fill Input Hatch with water.") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(9, 3, 9, true) + .addController("Front Center") + .addCasingInfo("Machine Casings", 64) + .addCasingInfo("Sterile Farm Casings", 34) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + public void setMeta(int meta) { + checkMeta = meta; + } + + public int getMeta() { + return checkMeta; + } + + @Override + public IStructureDefinition<GregtechMTE_AlgaePondBase> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMTE_AlgaePondBase>builder() + .addShape(mName, transpose(new String[][]{ + {"XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", "X X", "XXXXXXXXX"}, + {"XXXXXXXXX", "X X", "X X", "X X", "X X", "X X", "X X", "X X", "XXXXXXXXX"}, + {"CCCC~CCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC", "CCCCCCCCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMTE_AlgaePondBase::addAlgaePondBaseList, TAE.getIndexFromPage(1, 15), 1 + ), + onElementPass( + x -> ++x.mCasing, + addTieredBlock( + GregTech_API.sBlockCasings1, GregtechMTE_AlgaePondBase::setMeta, GregtechMTE_AlgaePondBase::getMeta, 10 + ) + ) + ) + ) + .addElement( + 'X', + ofBlock( + ModBlocks.blockCasings2Misc, 15 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 4, 2, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mLevel = 0; + checkMeta = 0; + if (checkPiece(mName, 4, 2, 0) && mCasing >= 64 && checkMeta > 0) { + mLevel = checkMeta - 1; + return true; + } + return false; + } + + public final boolean addAlgaePondBaseList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + }else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + // fuck + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && !f.isVerticallyFliped(); + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @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(1, 15); + if (mLevel > -1) { + aID = mLevel; + } + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(aID), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(aID)}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public int getMaxParallelRecipes() { + return 2; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + // byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity.getWorld().setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); + + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + // Logger.INFO("Found Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 60; + + if (isValidWater) { + Logger.INFO("Filled structure."); + return true; + } + else { + return false; + } + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerSecond(final ItemStack aStack) { + return CORE.ConfigSwitches.pollutionPerSecondMultiAlgaePond; + } + + @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); + this.fixAllMaintenanceIssue(); + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mLevel = getCasingTier(); + } + + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + + if (this.mLevel < 0) { + Logger.INFO("Bad Tier."); + return false; + } + + if (!checkForWater()) { + Logger.INFO("Not enough Water."); + return false; + } + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + Logger.INFO("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); + + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + return false; + } + if (tRecipe.mInputs.length > 0) { + for (ItemStack aInputToConsume : tRecipe.mInputs) { + this.depleteInput(aInputToConsume); + } + } + + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + this.mMaxProgresstime = (int)(tRecipe.mDuration); + this.mEUt = 0; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + Logger.INFO("Recipe time: "+this.mMaxProgresstime); + 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 *= aMaxParallelRecipes; + } + } + + // 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 < aMaxParallelRecipes; 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(); + + Logger.INFO("GOOD RETURN - 1"); + return true; + + } + + private boolean isUsingCompost(ItemStack[] aItemInputs) { + ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1); + for (ItemStack i : aItemInputs) { + if (GT_Utility.areStacksEqual(aCompost, i)) { + if (i.stackSize >= 8) { + return true; + } + } + } + return false; + } + + + private int getCasingTier() { + if (this.getBaseMetaTileEntity().getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir); + if (aInitStructureCheck == GregTech_API.sBlockCasings1) { + return aInitStructureCheckMeta; + } + return 0; + } + catch (Throwable t) { + t.printStackTrace(); + return 0; + } + } + + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java new file mode 100644 index 0000000000..018120d614 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java @@ -0,0 +1,46 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.bedrock; + +import gregtech.api.enums.TAE; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.Material; + +public class GregtechMetaTileEntity_BedrockMiningPlatform1 extends GregtechMetaTileEntity_BedrockMiningPlatformBase { + public GregtechMetaTileEntity_BedrockMiningPlatform1(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_BedrockMiningPlatform1(final String aName) { + super(aName); + } + + public String[] getTooltip() { + return this.getDescriptionInternal("I"); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (IMetaTileEntity) new GregtechMetaTileEntity_BedrockMiningPlatform1(this.mName); + } + + protected Material getFrameMaterial() { + return ALLOY.INCONEL_690; + } + + protected int getCasingTextureIndex() { + return TAE.getIndexFromPage(0, 14); + } + + protected int getRadiusInChunks() { + return 9; + } + + protected int getMinTier() { + return 5; + } + + protected int getBaseProgressTime() { + return (int) (420*(this.mProductionModifier/100)); + } +}*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java new file mode 100644 index 0000000000..6b97cb7ee2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java @@ -0,0 +1,46 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.bedrock; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; + +public class GregtechMetaTileEntity_BedrockMiningPlatform2 extends GregtechMetaTileEntity_BedrockMiningPlatformBase { + public GregtechMetaTileEntity_BedrockMiningPlatform2(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_BedrockMiningPlatform2(final String aName) { + super(aName); + } + + public String[] getTooltip() { + return this.getDescriptionInternal("II"); + } + + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (IMetaTileEntity) new GregtechMetaTileEntity_BedrockMiningPlatform2(this.mName); + } + + protected Material getFrameMaterial() { + return ELEMENT.getInstance().AMERICIUM241; + } + + protected int getCasingTextureIndex() { + return 62; + } + + protected int getRadiusInChunks() { + return 9; + } + + protected int getMinTier() { + return 5; + } + + protected int getBaseProgressTime() { + return 480; + } +}*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java new file mode 100644 index 0000000000..05a05d53e0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java @@ -0,0 +1,683 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.bedrock; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Worldgen_GT_Ore_Layer; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.ORES; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MiningUtils; +import gtPlusPlus.core.util.minecraft.OreDictUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.oredict.OreDictionary; + +public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends GregtechMeta_MultiBlockBase { + + protected double mProductionModifier = 0; + + + private static final ItemStack miningPipe; + private static final ItemStack miningPipeTip; + + private Block casingBlock; + private int casingMeta; + // private int frameMeta; + private int casingTextureIndex; + + private ForgeDirection back; + + private int xDrill; + private int yDrill; + private int zDrill; + + private int[] xCenter = new int[5]; + private int[] zCenter = new int[5]; + + public GregtechMetaTileEntity_BedrockMiningPlatformBase(final int aID, final String aName, + final String aNameRegional) { + super(aID, aName, aNameRegional); + this.initFields(); + } + + public GregtechMetaTileEntity_BedrockMiningPlatformBase(final String aName) { + super(aName); + this.initFields(); + } + + private void initFields() { + this.casingBlock = this.getCasingBlockItem().getBlock(); + this.casingMeta = this.getCasingBlockItem().get(0L, new Object[0]).getItemDamage(); + this.casingTextureIndex = this.getCasingTextureIndex(); + } + + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(this.casingTextureIndex), + new GT_RenderedTexture( + (IIconContainer) (aActive ? Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE + : Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT)) }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(this.casingTextureIndex) }; + } + + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + "OreDrillingPlant.png"); + } + + + public int getAmountOfOutputs() { + return 1; + } + + public void saveNBTData(final NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setDouble("mProductionModifier", mProductionModifier); + } + + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mProductionModifier = aNBT.getDouble("mProductionModifier"); + } + + public boolean checkRecipe(final ItemStack aStack) { + //this.setElectricityStats(); + + + if (true) { + return false; + } + + boolean[] didWork = new boolean[5]; + + if (!this.tryConsumeDrillingFluid()) { + Logger.INFO("No drilling Fluid."); + return false; + } + + if (MathUtils.isNumberEven((int) this.mProductionModifier)) { + if (!this.tryConsumePyrotheum()) { + Logger.INFO("No tryConsumePyrotheum Fluid."); + return false; + } + else { + mProductionModifier++; + } + } + else { + if (!this.tryConsumeCryotheum()) { + Logger.INFO("No tryConsumeCryotheum Fluid."); + return false; + } + else { + mProductionModifier++; + } + } + + for (int i = 0; i < 5; i++) { + process(); + didWork[i] = true; + } + + // Fail recipe handling if one pipe didn't handle properly, to try again + // next run. + for (boolean y : didWork) { + if (!y) { + Logger.INFO("[Bedrock Miner] Fail [x]"); + return false; + } + } + + this.mEUt = -8000; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 10000; + + return true; + } + + private boolean isEnergyEnough() { + long requiredEnergy = 512L + this.getMaxInputVoltage() * 4L; + for (final GT_MetaTileEntity_Hatch_Energy energyHatch : this.mEnergyHatches) { + requiredEnergy -= energyHatch.getEUVar(); + if (requiredEnergy <= 0L) { + return true; + } + } + return false; + } + + private void setElectricityStats() { + //this.mEfficiency = this.getCurrentEfficiency((ItemStack) null); + this.mEfficiencyIncrease = 10000; + final int overclock = 8 << GT_Utility.getTier(this.getMaxInputVoltage()); + //this.mEUt = -12 * overclock * overclock; + Logger.INFO("Trying to set EU to "+(12 * overclock * overclock)); + int mCombinedAvgTime = 0; + for (int g = 0; g < 5; g++) { + mCombinedAvgTime += this.getBaseProgressTime() / overclock; + } + Logger.INFO("Trying to set Max Time to "+(mCombinedAvgTime)); + //this.mMaxProgresstime = (mCombinedAvgTime / 5); + } + + private boolean tryConsumeDrillingFluid() { + boolean consumed = false; + boolean g = (this.getBaseMetaTileEntity().getWorld().getTotalWorldTime() % 2 == 0); + consumed = (g ? tryConsumePyrotheum() : tryConsumeCryotheum()); + if (consumed) { + //increaseProduction(g ? 2 : 1); + } + else { + //lowerProduction(g ? 5 : 3); + } + return consumed; + } + + private boolean tryConsumePyrotheum() { + return this.depleteInput(FluidUtils.getFluidStack("pyrotheum", 4)); + } + + private boolean tryConsumeCryotheum() { + return this.depleteInput(FluidUtils.getFluidStack("cryotheum", 4)); + } + + private void putMiningPipesFromInputsInController() { + final int maxPipes = 64; + if (this.isHasMiningPipes(maxPipes)) { + return; + } + ItemStack pipes = this.getStackInSlot(1); + for (final ItemStack storedItem : this.getStoredInputs()) { + if (!storedItem.isItemEqual(GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe)) { + continue; + } + if (pipes == null) { + this.setInventorySlotContents(1, + GT_Utility.copy(new Object[] { GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe })); + pipes = this.getStackInSlot(1); + } + if (pipes.stackSize == maxPipes) { + break; + } + final int needPipes = maxPipes - pipes.stackSize; + final int transferPipes = (storedItem.stackSize < needPipes) ? storedItem.stackSize : needPipes; + final ItemStack itemStack = pipes; + itemStack.stackSize += transferPipes; + final ItemStack itemStack2 = storedItem; + itemStack2.stackSize -= transferPipes; + } + this.updateSlots(); + } + + + + private boolean isHasMiningPipes(final int minCount) { + final ItemStack pipe = this.getStackInSlot(1); + return pipe != null && pipe.stackSize > minCount - 1 + && pipe.isItemEqual(GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe); + } + + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + this.updateCoordinates(); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int tAmount = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } else { + + Block aCasing = Block.getBlockFromItem(getCasingBlockItem().getItem()); + + for (int i = -1; i < 2; ++i) { + for (int j = -1; j < 2; ++j) { + for (int h = -1; h < 2; ++h) { + if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, + h, zDir + j); + Block aBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + + if (!this.addToMachineList(tTileEntity, 48)) { + if (aBlock != aCasing) { + Logger.INFO("Found Bad Casing"); + return false; + } + if (aMeta != 3) { + Logger.INFO("Found Bad Meta"); + return false; + } + } + ++tAmount; + + + + /*if (!isValidBlockForStructure(tTileEntity, 48, true, aBlock, aMeta, sBlockCasings4, 0)) { + Logger.INFO("Bad centrifuge casing"); + return false; + }*/ + + } + } + } + } + return tAmount >= 10; + } + + } + + private void updateCoordinates() { + this.xDrill = this.getBaseMetaTileEntity().getXCoord(); + this.yDrill = this.getBaseMetaTileEntity().getYCoord()-1; + this.zDrill = this.getBaseMetaTileEntity().getZCoord(); + this.back = ForgeDirection.getOrientation((int) this.getBaseMetaTileEntity().getBackFacing()); + + // Middle + this.xCenter[0] = this.xDrill + this.back.offsetX; + this.zCenter[0] = this.zDrill + this.back.offsetZ; + + this.xCenter[1] = xCenter[0] + 1; + this.zCenter[1] = zCenter[0]; + + this.xCenter[2] = xCenter[0] - 1; + this.zCenter[2] = zCenter[0]; + + this.xCenter[3] = xCenter[0]; + this.zCenter[3] = zCenter[0] + 1; + + this.xCenter[4] = xCenter[0]; + this.zCenter[4] = zCenter[0] - 1; + + } + + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; + } + + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(final ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + protected GregtechItemList getCasingBlockItem() { + return GregtechItemList.Casing_BedrockMiner; + } + + protected abstract Material getFrameMaterial(); + + protected abstract int getCasingTextureIndex(); + + protected abstract int getRadiusInChunks(); + + protected abstract int getMinTier(); + + protected abstract int getBaseProgressTime(); + + protected String[] getDescriptionInternal(final String tierSuffix) { + final String casings = this.getCasingBlockItem().get(0L, new Object[0]).getDisplayName(); + return new String[] { + "Controller Block for the Experimental Deep Earth Drilling Platform - MK " + + ((tierSuffix != null) ? tierSuffix : ""), + "Size(WxHxD): 3x7x3, Controller (Front middle bottom)", "3x1x3 Base of " + casings, + "1x3x1 " + casings + " pillar (Center of base)", + "1x3x1 " + this.getFrameMaterial().getLocalizedName() + " Frame Boxes (Each pillar side and on top)", + "2x Input Hatch (Any bottom layer casing)", + "1x Input Bus for mining pipes (Any bottom layer casing; not necessary)", + "1x Output Bus (Any bottom layer casing)", "1x Maintenance Hatch (Any bottom layer casing)", + "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", + "Radius is " + (this.getRadiusInChunks() << 4) + " blocks", + "Every tick, this machine altenates betweem consumption of Pyrotheum & Cryotheum", + "Pyrotheum is used to bore through the Mantle of the world", + "Cryotheum is used to keep the internal components cool",}; + } + + static { + miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0L); + miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0L); + } + + + + + + + + + + + + + + + + + + + + + + + + + + private AutoMap<ItemStack> mOutputs; + + public void process() { + ItemStack aOutput = generateOutputWithchance(); + if (aOutput != null) { + this.addOutput(aOutput); + Logger.INFO("Mined some "+aOutput.getDisplayName()); + } + this.updateSlots(); + } + + public ItemStack generateOutputWithchance() { + int aChance = MathUtils.randInt(0, 7500); + if (aChance < 100) { + return generateOutput(); + } + else { + return null; + } + } + + public ItemStack generateOutput() { + AutoMap<ItemStack> aData = generateOreForOutput(); + int aMax = aData.size()-1; + return aData.get(MathUtils.randInt(0, aMax)); + } + + /** + * Here we generate valid ores and also a basic loot set + */ + + public AutoMap<ItemStack> generateOreForOutput() { + + if (mOutputs != null) { + return mOutputs; + } + + AutoMap<GT_Worldgen_GT_Ore_Layer> aOverWorldOres = MiningUtils.getOresForDim(0); + AutoMap<GT_Worldgen_GT_Ore_Layer> aNetherOres = MiningUtils.getOresForDim(-1); + AutoMap<GT_Worldgen_GT_Ore_Layer> aEndOres = MiningUtils.getOresForDim(1); + + AutoMap<ItemStack> aTempMap = new AutoMap<ItemStack>(); + Block tOreBlock = GregTech_API.sBlockOres1; + Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [Initial]"); + + for (GT_Worldgen_GT_Ore_Layer layer : aOverWorldOres) { + if (layer.mEnabled) { + ItemStack aTempOreStack1 = ItemUtils.simpleMetaStack(tOreBlock, layer.mPrimaryMeta, 1); + ItemStack aTempOreStack2 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSecondaryMeta, 1); + ItemStack aTempOreStack3 = ItemUtils.simpleMetaStack(tOreBlock, layer.mBetweenMeta, 1); + ItemStack aTempOreStack4 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSporadicMeta, 1); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + } + } + Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [Overworld]"); + for (GT_Worldgen_GT_Ore_Layer layer : aNetherOres) { + if (layer.mEnabled) { + ItemStack aTempOreStack1 = ItemUtils.simpleMetaStack(tOreBlock, layer.mPrimaryMeta, 1); + ItemStack aTempOreStack2 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSecondaryMeta, 1); + ItemStack aTempOreStack3 = ItemUtils.simpleMetaStack(tOreBlock, layer.mBetweenMeta, 1); + ItemStack aTempOreStack4 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSporadicMeta, 1); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + } + } + Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [Nether]"); + for (GT_Worldgen_GT_Ore_Layer layer : aEndOres) { + if (layer.mEnabled) { + ItemStack aTempOreStack1 = ItemUtils.simpleMetaStack(tOreBlock, layer.mPrimaryMeta, 1); + ItemStack aTempOreStack2 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSecondaryMeta, 1); + ItemStack aTempOreStack3 = ItemUtils.simpleMetaStack(tOreBlock, layer.mBetweenMeta, 1); + ItemStack aTempOreStack4 = ItemUtils.simpleMetaStack(tOreBlock, layer.mSporadicMeta, 1); + aTempMap.put(aTempOreStack1); + aTempMap.put(aTempOreStack2); + aTempMap.put(aTempOreStack3); + aTempMap.put(aTempOreStack4); + } + } + Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [End]"); + + addOreTypeToMap(ELEMENT.getInstance().IRON, 200, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().COPPER, 175, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().TIN, 150, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().GOLD, 150, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().SILVER, 110, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().NICKEL, 40, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().ZINC, 40, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().LEAD, 40, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().ALUMINIUM, 30, aTempMap); + addOreTypeToMap(ELEMENT.getInstance().THORIUM, 20, aTempMap); + Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [Extra Common Ores]"); + + AutoMap<Pair<String, Integer>> mMixedOreData = new AutoMap<Pair<String, Integer>>(); + mMixedOreData.put(new Pair<String, Integer>("oreRuby", 30)); + mMixedOreData.put(new Pair<String, Integer>("oreSapphire", 25)); + mMixedOreData.put(new Pair<String, Integer>("oreEmerald", 25)); + mMixedOreData.put(new Pair<String, Integer>("oreLapis", 40)); + mMixedOreData.put(new Pair<String, Integer>("oreRedstone", 40)); + + if (LoadedMods.Thaumcraft || (OreDictUtils.containsValidEntries("oreAmber") && OreDictUtils.containsValidEntries("oreCinnabar"))) { + mMixedOreData.put(new Pair<String, Integer>("oreAmber", 20)); + mMixedOreData.put(new Pair<String, Integer>("oreCinnabar", 20)); + } + if (LoadedMods.Railcraft || OreDictUtils.containsValidEntries("oreSaltpeter")) { + mMixedOreData.put(new Pair<String, Integer>("oreSaltpeter", 10)); + } + if (LoadedMods.IndustrialCraft2 || OreDictUtils.containsValidEntries("oreUranium")) { + mMixedOreData.put(new Pair<String, Integer>("oreUranium", 10)); + } + if (OreDictUtils.containsValidEntries("oreSulfur")) { + mMixedOreData.put(new Pair<String, Integer>("oreSulfur", 15)); + } + if (OreDictUtils.containsValidEntries("oreSilicon")) { + mMixedOreData.put(new Pair<String, Integer>("oreSilicon", 15)); + } + if (OreDictUtils.containsValidEntries("oreApatite")) { + mMixedOreData.put(new Pair<String, Integer>("oreApatite", 25)); + } + + mMixedOreData.put(new Pair<String, Integer>("oreFirestone", 2)); + mMixedOreData.put(new Pair<String, Integer>("oreBismuth", 20)); + mMixedOreData.put(new Pair<String, Integer>("oreLithium", 20)); + mMixedOreData.put(new Pair<String, Integer>("oreManganese", 20)); + mMixedOreData.put(new Pair<String, Integer>("oreBeryllium", 20)); + mMixedOreData.put(new Pair<String, Integer>("oreCoal", 75)); + mMixedOreData.put(new Pair<String, Integer>("oreLignite", 75)); + mMixedOreData.put(new Pair<String, Integer>("oreSalt", 15)); + mMixedOreData.put(new Pair<String, Integer>("oreCalcite", 15)); + mMixedOreData.put(new Pair<String, Integer>("oreBauxite", 20)); + mMixedOreData.put(new Pair<String, Integer>("oreAlmandine", 15)); + mMixedOreData.put(new Pair<String, Integer>("oreGraphite", 25)); + mMixedOreData.put(new Pair<String, Integer>("oreGlauconite", 15)); + mMixedOreData.put(new Pair<String, Integer>("orePyrolusite", 15)); + mMixedOreData.put(new Pair<String, Integer>("oreGrossular", 15)); + mMixedOreData.put(new Pair<String, Integer>("oreTantalite", 15)); + + for (Pair<String, Integer> g : mMixedOreData) { + for (int i=0; i<g.getValue();i++) { + aTempMap.put(ItemUtils.getItemStackOfAmountFromOreDict(g.getKey(), 1)); + } + } + Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [Extra Mixed Ores]"); + + + addOreTypeToMap(ELEMENT.STANDALONE.RUNITE, 2, aTempMap); + addOreTypeToMap(ELEMENT.STANDALONE.GRANITE, 8, aTempMap); + Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [OSRS Ores]"); + + + AutoMap<Material> aMyOreMaterials = new AutoMap<Material>(); + aMyOreMaterials.add(ORES.CROCROITE); + aMyOreMaterials.add(ORES.GEIKIELITE); + aMyOreMaterials.add(ORES.NICHROMITE); + aMyOreMaterials.add(ORES.TITANITE); + aMyOreMaterials.add(ORES.ZIMBABWEITE); + aMyOreMaterials.add(ORES.ZIRCONILITE); + aMyOreMaterials.add(ORES.GADOLINITE_CE); + aMyOreMaterials.add(ORES.GADOLINITE_Y); + aMyOreMaterials.add(ORES.LEPERSONNITE); + aMyOreMaterials.add(ORES.SAMARSKITE_Y); + aMyOreMaterials.add(ORES.SAMARSKITE_YB); + aMyOreMaterials.add(ORES.XENOTIME); + aMyOreMaterials.add(ORES.YTTRIAITE); + aMyOreMaterials.add(ORES.YTTRIALITE); + aMyOreMaterials.add(ORES.YTTROCERITE); + aMyOreMaterials.add(ORES.ZIRCON); + aMyOreMaterials.add(ORES.POLYCRASE); + aMyOreMaterials.add(ORES.ZIRCOPHYLLITE); + aMyOreMaterials.add(ORES.ZIRKELITE); + aMyOreMaterials.add(ORES.LANTHANITE_LA); + aMyOreMaterials.add(ORES.LANTHANITE_CE); + aMyOreMaterials.add(ORES.LANTHANITE_ND); + aMyOreMaterials.add(ORES.AGARDITE_Y); + aMyOreMaterials.add(ORES.AGARDITE_CD); + aMyOreMaterials.add(ORES.AGARDITE_LA); + aMyOreMaterials.add(ORES.AGARDITE_ND); + aMyOreMaterials.add(ORES.HIBONITE); + aMyOreMaterials.add(ORES.CERITE); + aMyOreMaterials.add(ORES.FLUORCAPHITE); + aMyOreMaterials.add(ORES.FLORENCITE); + aMyOreMaterials.add(ORES.CRYOLITE); + aMyOreMaterials.add(ORES.LAUTARITE); + aMyOreMaterials.add(ORES.LAFOSSAITE); + aMyOreMaterials.add(ORES.DEMICHELEITE_BR); + aMyOreMaterials.add(ORES.COMANCHEITE); + aMyOreMaterials.add(ORES.PERROUDITE); + aMyOreMaterials.add(ORES.HONEAITE); + aMyOreMaterials.add(ORES.ALBURNITE); + aMyOreMaterials.add(ORES.MIESSIITE); + aMyOreMaterials.add(ORES.KASHINITE); + aMyOreMaterials.add(ORES.IRARSITE); + aMyOreMaterials.add(ORES.RADIOBARITE); + aMyOreMaterials.add(ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT); + + for (Material aOreType : aMyOreMaterials) { + if (aOreType == ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT || aOreType == ORES.RADIOBARITE) { + addOreTypeToMap(aOreType, 4, aTempMap); + } + else { + addOreTypeToMap(aOreType, 7, aTempMap); + } + } + + //Cleanup Map + Logger.INFO("Ore Map contains "+aTempMap.size()+" values. [GT++]"); + AutoMap<ItemStack> aCleanUp = new AutoMap<ItemStack>(); + for (ItemStack verify : aTempMap) { + if (!ItemUtils.checkForInvalidItems(verify)) { + aCleanUp.put(verify); + } + } + Logger.INFO("Cleanup Map contains "+aCleanUp.size()+" values."); + for (ItemStack remove : aCleanUp) { + aTempMap.remove(remove); + } + + //Generate Massive Map + AutoMap<ItemStack> aFinalMap = new AutoMap<ItemStack>(); + for (ItemStack aTempItem : aTempMap) { + int aTempMulti = MathUtils.randInt(20, 50); + for (int i=0;i<aTempMulti;i++) { + aFinalMap.put(aTempItem.copy()); + } + } + Logger.INFO("Final Ore Map contains "+aFinalMap.size()+" values."); + mOutputs = aFinalMap; + return mOutputs; + } + + + private static void addOreTypeToMap(Material aMaterial, int aAmount, AutoMap<ItemStack> aMap) { + for (int i=0; i<aAmount;i++) { + aMap.add(aMaterial.getOre(1)); + } + } + + + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Miner"; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + + + + + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java new file mode 100644 index 0000000000..42912c4fa8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -0,0 +1,1046 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +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_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Triplet; +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.blocks.textures.TexturesGtBlock; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { + + private int mSolidCasingTier = 0; + private int mMachineCasingTier = 0; + private int mPipeCasingTier = 0; + private int mCoilTier = 0; + private int checkCoil; + private int[] checkCasing = new int[8]; + private int checkMachine; + private int checkPipe; + private int maxTierOfHatch; + private int mCasing; + private IStructureDefinition<GregtechMTE_ChemicalPlant> STRUCTURE_DEFINITION = null; + + private ArrayList<GT_MetaTileEntity_Hatch_Catalysts> mCatalystBuses = new ArrayList<GT_MetaTileEntity_Hatch_Catalysts>(); + + private static final HashMap<Integer, Triplet<Block, Integer, Integer>> mTieredBlockRegistry = new HashMap<Integer, Triplet<Block, Integer, Integer>>(); + + public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_ChemicalPlant(final String aName) { + super(aName); + } + + public static boolean registerMachineCasingForTier(int aTier, Block aBlock, int aMeta, int aCasingTextureID) { + int aSize = mTieredBlockRegistry.size(); + int aSize2 = aSize; + Triplet<Block, Integer, Integer> aCasingData = new Triplet<Block, Integer, Integer>(aBlock, aMeta, aCasingTextureID); + if (mTieredBlockRegistry.containsKey(aTier)) { + CORE.crash("Tried to register a Machine casing for tier "+aTier+" to the Chemical Plant, however this tier already contains one."); + } + mTieredBlockRegistry.put(aTier, aCasingData); + aSize = mTieredBlockRegistry.size(); + return aSize > aSize2; + } + + private static int getCasingTextureIdForTier(int aTier) { + if (!mTieredBlockRegistry.containsKey(aTier)) { + return 10; + } + int aCasingID = mTieredBlockRegistry.get(aTier).getValue_3(); + //Logger.INFO("Found casing texture ID "+aCasingID+" for tier "+aTier); + return aCasingID; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_ChemicalPlant(this.mName); + } + + @Override + public String getMachineType() { + return "Chemical Plant"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Controller Block for the Chemical Plant") + .addInfo("Heavy Industry, now right at your doorstep!") + .addInfo("Please read the user manual for more information on construction and usage") + .addSeparator() + .addController("Bottom Center") + .addStructureHint("Catalyst Housing", 1) + .addInputBus("Bottom Casing", 1) + .addOutputBus("Bottom Casing", 1) + .addInputHatch("Bottom Casing", 1) + .addOutputHatch("Bottom Casing", 1) + .addEnergyHatch("Bottom Casing", 1) + .addMaintenanceHatch("Bottom Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + public void setMachineMeta(int meta) { + checkMachine = meta; + } + + public int getMachineMeta() { + return checkMachine; + } + + public void setPipeMeta(int meta) { + checkPipe = meta; + } + + public int getPipeMeta() { + return checkPipe; + } + + public void setCoilMeta(int meta) { + checkCoil = meta; + } + + public int getCoilMeta() { + return checkCoil; + } + + public int coilTier(int meta) { + switch (meta) { + case 0: return 1; + case 1: return 2; + case 2: return 3; + case 3: return 4; + case 4: return 5; + case 5: return 7; + case 6: return 8; + case 7: return 10; + case 8: return 11; + case 9: return 6; + case 10: return 9; + } + return 0; + } + + @Override + public IStructureDefinition<GregtechMTE_ChemicalPlant> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMTE_ChemicalPlant>builder() + .addShape(mName, transpose(new String[][]{ + {"XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX", "XXXXXXX"}, + {"X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X"}, + {"X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X"}, + {"X X", " ", " HHH ", " HHH ", " HHH ", " ", "X X"}, + {"X X", " ", " PPP ", " PPP ", " PPP ", " ", "X X"}, + {"X X", " MMMMM ", " MHHHM ", " MHHHM ", " MHHHM ", " MMMMM ", "X X"}, + {"CCC~CCC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CMMMMMC", "CCCCCCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMTE_ChemicalPlant::addChemicalPlantList, getCasingTextureID(), 1 + ), + onElementPass( + x -> {++x.checkCasing[0]; ++x.mCasing;}, + ofSolidCasing(0) + ), + onElementPass( + x -> {++x.checkCasing[1]; ++x.mCasing;}, + ofSolidCasing(1) + ), + onElementPass( + x -> {++x.checkCasing[2]; ++x.mCasing;}, + ofSolidCasing(2) + ), + onElementPass( + x -> {++x.checkCasing[3]; ++x.mCasing;}, + ofSolidCasing(3) + ), + onElementPass( + x -> {++x.checkCasing[4]; ++x.mCasing;}, + ofSolidCasing(4) + ), + onElementPass( + x -> {++x.checkCasing[5]; ++x.mCasing;}, + ofSolidCasing(5) + ), + onElementPass( + x -> {++x.checkCasing[6]; ++x.mCasing;}, + ofSolidCasing(6) + ), + onElementPass( + x -> {++x.checkCasing[7]; ++x.mCasing;}, + ofSolidCasing(7) + ) + ) + ) + .addElement( + 'X', + ofChain( + onElementPass( + x -> {++x.checkCasing[0]; ++x.mCasing;}, + ofSolidCasing(0) + ), + onElementPass( + x -> {++x.checkCasing[1]; ++x.mCasing;}, + ofSolidCasing(1) + ), + onElementPass( + x -> {++x.checkCasing[2]; ++x.mCasing;}, + ofSolidCasing(2) + ), + onElementPass( + x -> {++x.checkCasing[3]; ++x.mCasing;}, + ofSolidCasing(3) + ), + onElementPass( + x -> {++x.checkCasing[4]; ++x.mCasing;}, + ofSolidCasing(4) + ), + onElementPass( + x -> {++x.checkCasing[5]; ++x.mCasing;}, + ofSolidCasing(5) + ), + onElementPass( + x -> {++x.checkCasing[6]; ++x.mCasing;}, + ofSolidCasing(6) + ), + onElementPass( + x -> {++x.checkCasing[7]; ++x.mCasing;}, + ofSolidCasing(7) + ) + ) + ) + .addElement( + 'M', + addTieredBlock( + GregTech_API.sBlockCasings1, GregtechMTE_ChemicalPlant::setMachineMeta, GregtechMTE_ChemicalPlant::getMachineMeta, 10 + ) + ) + .addElement( + 'H', + addTieredBlock( + GregTech_API.sBlockCasings5, GregtechMTE_ChemicalPlant::setCoilMeta, GregtechMTE_ChemicalPlant::getCoilMeta, 11 + ) + ) + .addElement( + 'P', + addTieredBlock( + GregTech_API.sBlockCasings2, GregtechMTE_ChemicalPlant::setPipeMeta, GregtechMTE_ChemicalPlant::getPipeMeta, 12, 16 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public static <T> IStructureElement<T> ofSolidCasing(int aIndex) { + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + Block target = mTieredBlockRegistry.get(aIndex).getValue_1(); + int targetMeta = mTieredBlockRegistry.get(aIndex).getValue_2(); + return target.equals(block) && meta == targetMeta; + } + + int getIndex(int size) { + if (size > 8) size = 8; + return size - 1; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2()); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return world.setBlock(x, y, z, mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_1(), mTieredBlockRegistry.get(getIndex(trigger.stackSize)).getValue_2(), 3); + } + }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 3, 6, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + for (int i = 0; i < 8; i++) { + checkCasing[i] = 0; + } + checkCoil = 0; + checkPipe = 0; + checkMachine = 0; + mSolidCasingTier = 0; + mMachineCasingTier = 0; + mPipeCasingTier = 0; + mCoilTier = 0; + mCatalystBuses.clear(); + if (checkPiece(mName, 3, 6, 0) && mCasing >= 80) { + for (int i = 0; i < 8; i++) { + if (checkCasing[i] == mCasing) { + mSolidCasingTier = i; + } + else if (checkCasing[i] > 0) + return false; + } + mMachineCasingTier = checkMachine - 1; + mPipeCasingTier = checkPipe - 12; + mCoilTier = coilTier(checkCoil - 1); + updateHatchTexture(); + return mMachineCasingTier >= maxTierOfHatch; + } + return false; + } + + public void updateHatchTexture() { + for (GT_MetaTileEntity_Hatch h : mCatalystBuses) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mInputBusses) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mMaintenanceHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mEnergyHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mOutputBusses) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mInputHatches) h.updateTexture(getCasingTextureID()); + for (GT_MetaTileEntity_Hatch h : mOutputHatches) h.updateTexture(getCasingTextureID()); + } + + public final boolean addChemicalPlantList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + maxTierOfHatch = Math.max(maxTierOfHatch, ((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity).mTier); + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + return false; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + + ITexture aOriginalTexture; + + // Check things exist client side (The worst code ever) + if (aBaseMetaTileEntity.getWorld() != null) { + + } + int aCasingID = getCasingTextureID(); + aOriginalTexture = Textures.BlockIcons.getCasingTextureForId(aCasingID); + + if (aSide == aFacing) { + return new ITexture[]{aOriginalTexture, new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + } + return new ITexture[]{aOriginalTexture}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList.size() == 0) { + generateRecipes(); + } + return GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT; + } + + public static void generateRecipes() { + for (GT_Recipe i : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList) { + GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.add(i); + } + } + + @Override + public int getMaxParallelRecipes() { + return 2 * getPipeCasingTier(); + } + + @Override + public int getEuDiscountForParallelism() { + return 100; + } + + private int getSolidCasingTier() { + return this.mSolidCasingTier; + } + + private int getMachineCasingTier() { + return mMachineCasingTier; + } + + private int getPipeCasingTier() { + return mPipeCasingTier; + } + + private int getCasingTextureID() { + // Check the Tier Client Side + int aTier = mSolidCasingTier; + return getCasingTextureIdForTier(aTier); + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity) { + int aMaxTier = getMachineCasingTier(); + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) { + GT_MetaTileEntity_TieredMachineBlock aMachineBlock = (GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity; + int aTileTier = aMachineBlock.mTier; + if (aTileTier > aMaxTier) { + log("Hatch tier too high."); + return false; + } + else { + return addToMachineList(aTileEntity, getCasingTextureID()); + } + } + else { + log("Bad Tile Entity being added to hatch map."); // Shouldn't ever happen, but.. ya know.. + return false; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mSolidCasingTier", this.mSolidCasingTier); + aNBT.setInteger("mMachineCasingTier", this.mMachineCasingTier); + aNBT.setInteger("mPipeCasingTier", this.mPipeCasingTier); + aNBT.setInteger("mCoilTier", this.mCoilTier); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mSolidCasingTier = aNBT.getInteger("mSolidCasingTier"); + mMachineCasingTier = aNBT.getInteger("mMachineCasingTier"); + mPipeCasingTier = aNBT.getInteger("mPipeCasingTier"); + mCoilTier = aNBT.getInteger("mCoilTier"); + } + + @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); + } + + @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; + } + + // Same speed bonus as pyro oven + public int getSpeedBonus() { + return 50 * (this.mCoilTier - 2); + } + + public int getMaxCatalystDurability() { + return 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mCatalystBuses.clear(); + } + } + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + if (this != null && this.getBaseMetaTileEntity() != null && this.getBaseMetaTileEntity().getWorld() != null) { + this.mSolidCasingTier = getCasingTierOnClientSide(); + markDirty(); + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), getSpeedBonus()); + } + + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isOC) { + + // 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); + GT_Recipe tRecipe = findRecipe(mLastRecipe, gregtech.api.enums.GT_Values.V[tTier], getSolidCasingTier(), aItemInputs, aFluidInputs); + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + // checks if it has a catalyst + ItemStack tCatalystRecipe = findCatalyst(aItemInputs); + boolean aDoesRecipeNeedCatalyst = false; + for (ItemStack aInputItem : tRecipe.mInputs) { + if (ItemUtils.isCatalyst(aInputItem)) { + aDoesRecipeNeedCatalyst = true; + break; + } + } + if (aDoesRecipeNeedCatalyst) { + if (tCatalystRecipe == null) { + log("does not have catalyst"); + return false; + } + if (mCatalystBuses.size() != 1) { + log("does not have correct number of catalyst hatches. (Required 1, found "+mCatalystBuses.size()+")"); + return false; + } + } + + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe.mSpecialValue > this.mSolidCasingTier) { + log("solid tier is too low"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // checks if it has enough catalyst durability + ArrayList<ItemStack>tCatalysts = null; + int tMaxParallelCatalyst = aMaxParallelRecipes; + if (tCatalystRecipe != null) { + tCatalysts = new ArrayList<ItemStack>(); + tMaxParallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes, tCatalysts); + log("Can process "+tMaxParallelCatalyst+" recipes. If less than "+aMaxParallelRecipes+", catalyst does not have enough durability."); + } + + if (tMaxParallelCatalyst == 0) { + log("found not enough catalysts"); + 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: "+tMaxParallelCatalyst); + 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 < tMaxParallelCatalyst && 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 catalyst once all is said and done. + if (tCatalystRecipe != null) { + log("damaging catalyst"); + damageCatalyst(tCatalystRecipe, parallelRecipes); + } + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + for (GT_MetaTileEntity_Hatch_Catalysts h : mCatalystBuses) { + h.updateSlots(); + h.tryFillUsageSlots(); + } + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + private static final HashMap<Long, AutoMap<GT_Recipe>> mTieredRecipeMap = new HashMap<Long, AutoMap<GT_Recipe>>(); + private static final AutoMap<GT_Recipe> aTier0Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier1Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier2Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier3Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier4Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier5Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier6Recipes = new AutoMap<GT_Recipe>(); + private static final AutoMap<GT_Recipe> aTier7Recipes = new AutoMap<GT_Recipe>(); + private static boolean mInitRecipeCache = false; + + private static void initRecipeCaches() { + if (!mInitRecipeCache) { + mTieredRecipeMap.put((long) 0, aTier0Recipes); + mTieredRecipeMap.put((long) 1, aTier1Recipes); + mTieredRecipeMap.put((long) 2, aTier2Recipes); + mTieredRecipeMap.put((long) 3, aTier3Recipes); + mTieredRecipeMap.put((long) 4, aTier4Recipes); + mTieredRecipeMap.put((long) 5, aTier5Recipes); + mTieredRecipeMap.put((long) 6, aTier6Recipes); + mTieredRecipeMap.put((long) 7, aTier7Recipes); + for (GT_Recipe aRecipe : GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlant_GT.mRecipeList) { + if (aRecipe != null) { + switch (aRecipe.mSpecialValue) { + case 0: + aTier0Recipes.add(aRecipe); + continue; + case 1: + aTier1Recipes.add(aRecipe); + continue; + case 2: + aTier2Recipes.add(aRecipe); + continue; + case 3: + aTier3Recipes.add(aRecipe); + continue; + case 4: + aTier4Recipes.add(aRecipe); + continue; + case 5: + aTier5Recipes.add(aRecipe); + continue; + case 6: + aTier6Recipes.add(aRecipe); + continue; + case 7: + aTier7Recipes.add(aRecipe); + continue; + } + } + } + mInitRecipeCache = true; + } + } + + private static boolean areInputsEqual(GT_Recipe aComparator, ItemStack[] aInputs, FluidStack[] aFluids) { + int aInputCount = aComparator.mInputs.length; + if (aInputCount > 0) { + //Logger.INFO("Looking for recipe with "+aInputCount+" Items"); + int aMatchingInputs = 0; + recipe : for (ItemStack a : aComparator.mInputs) { + for (ItemStack b : aInputs) { + if (a.getItem() == b.getItem()) { + if (a.getItemDamage() == b.getItemDamage()) { + //Logger.INFO("Found matching Item Input - "+b.getUnlocalizedName()); + aMatchingInputs++; + continue recipe; + } + } + } + } + if (aMatchingInputs != aInputCount) { + return false; + } + } + int aFluidInputCount = aComparator.mFluidInputs.length; + if (aFluidInputCount > 0) { + //Logger.INFO("Looking for recipe with "+aFluidInputCount+" Fluids"); + int aMatchingFluidInputs = 0; + recipe : for (FluidStack b : aComparator.mFluidInputs) { + //Logger.INFO("Checking for fluid "+b.getLocalizedName()); + for (FluidStack a : aFluids) { + if (GT_Utility.areFluidsEqual(a, b)) { + //Logger.INFO("Found matching Fluid Input - "+b.getLocalizedName()); + aMatchingFluidInputs++; + continue recipe; + } + else { + //Logger.INFO("Found fluid which did not match - "+a.getLocalizedName()); + } + } + } + if (aMatchingFluidInputs != aFluidInputCount) { + return false; + } + } + Logger.INFO("Recipes Match!"); + return true; + } + + public GT_Recipe findRecipe(final GT_Recipe aRecipe, final long aVoltage, final long aSpecialValue, ItemStack[] aInputs, final FluidStack[] aFluids) { + if (!mInitRecipeCache) { + initRecipeCaches(); + } + if (this.getRecipeMap().mRecipeList.isEmpty()) { + log("No Recipes in Map to search through."); + return null; + } + else { + log("Checking tier "+aSpecialValue+" recipes and below. Using Input Voltage of "+aVoltage+"V."); + log("We have "+aInputs.length+" Items and "+aFluids.length+" Fluids."); + // Try check the cached recipe first + if (aRecipe != null) { + if (areInputsEqual(aRecipe, aInputs, aFluids)) { + if (aRecipe.mEUt <= aVoltage) { + Logger.INFO("Using cached recipe."); + return aRecipe; + } + } + } + + // Get all recipes for the tier + AutoMap<AutoMap<GT_Recipe>> aMasterMap = new AutoMap<AutoMap<GT_Recipe>>(); + for (long i=0;i<=aSpecialValue;i++) { + aMasterMap.add(mTieredRecipeMap.get(i)); + } + GT_Recipe aFoundRecipe = null; + + // Iterate the tiers recipes until we find the one with all inputs matching + master : for (AutoMap<GT_Recipe> aTieredMap : aMasterMap) { + for (GT_Recipe aRecipeToCheck : aTieredMap) { + if (areInputsEqual(aRecipeToCheck, aInputs, aFluids)) { + log("Found recipe with matching inputs!"); + if (aRecipeToCheck.mSpecialValue <= aSpecialValue) { + if (aRecipeToCheck.mEUt <= aVoltage) { + aFoundRecipe = aRecipeToCheck; + break master; + } + } + } + } + } + + // If we found a recipe, return it + if (aFoundRecipe != null) { + log("Found valid recipe."); + return aFoundRecipe; + } + } + log("Did not find valid recipe."); + return null; + } + + private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParrallel, ArrayList<ItemStack> aOutPut) { + int allowedParallel = 0; + for (final ItemStack aInput : aItemInputs) { + if (aRecipeCatalyst.isItemEqual(aInput)) { + int aDurabilityRemaining = getMaxCatalystDurability() - getDamage(aInput); + return Math.min(aMaxParrallel, aDurabilityRemaining); + } + } + return allowedParallel; + } + + private ItemStack findCatalyst(ItemStack[] aItemInputs) { + if (aItemInputs != null) { + for (final ItemStack aInput : aItemInputs) { + if (aInput != null) { + if (ItemUtils.isCatalyst(aInput)) { + return aInput; + } + } + } + } + return null; + } + + + 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.stackSize -= 1; + } + else { + log("damaging catalyst"); + setDamage(aStack, damage); + } + } + else { + log("not consuming catalyst"); + } + } + } + + private int getDamage(ItemStack aStack) { + return ItemGenericChemBase.getCatalystDamage(aStack); + } + + private void setDamage(ItemStack aStack,int aAmount) { + ItemGenericChemBase.setCatalystDamage(aStack, aAmount); + } + + @SideOnly(Side.CLIENT) + private final int getCasingTierOnClientSide() { + + if (this == null || this.getBaseMetaTileEntity().getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 3; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 3; + if (xDir == 0) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(zDir, 1, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(zDir, 1, 0); + } + else { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 1, xDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 1, xDir); + } + for (int aTier : mTieredBlockRegistry.keySet()) { + Triplet<Block, Integer, Integer> aData = mTieredBlockRegistry.get(aTier); + if (aData.getValue_1() == aInitStructureCheck && aData.getValue_2() == aInitStructureCheckMeta) { + return aTier; + } + } + return 0; + } + catch (Throwable t) { + t.printStackTrace(); + return 0; + } + } + + /* + * 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/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java new file mode 100644 index 0000000000..f52f02b5de --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java @@ -0,0 +1,179 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; + +import java.util.ArrayList; + +import gregtech.GT_Mod; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTurbineBase { + + public boolean achievement = false; + private boolean looseFit=false; + + public GT_MTE_LargeTurbine_SHSteam(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MTE_LargeTurbine_SHSteam(String aName) { + super(aName); + } + + public String[] getTooltip() { + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 9); + } + return new String[]{ + "Controller Block for the XL High Pressure Steam Turbine", + "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", + "1x Superheated Steam Input Hatch (Side centered)", + "1x Maintenance Hatch (Side centered)", + "1x Dynamo Hatch (Back centered)", + "1x Output Hatch for Steam (Side centered)", + mCasingName+"s for the rest (24 at least!)", + "Needs a Turbine Item (Inside controller GUI)", + "Output depending on Rotor and fitting", + "Use screwdriver to adjust fitting of turbine"}; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MTE_LargeTurbine_SHSteam(mName); + } + + @Override + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + @Override + public byte getCasingMeta() { + return 9; + } + + @Override + public byte getCasingTextureIndex() { + return 59; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + if(looseFit) { + aOptFlow*=4; + if(aBaseEff>10000){ + aOptFlow*=Math.pow(1.1f,((aBaseEff-7500)/10000F)*20f); + aBaseEff=7500; + }else if(aBaseEff>7500){ + aOptFlow*=Math.pow(1.1f,((aBaseEff-7500)/10000F)*20f); + aBaseEff*=0.75f; + }else{ + aBaseEff*=0.75f; + } + } + int tEU = 0; + int totalFlow = 0; // Byproducts are based on actual flow + int flow = 0; + int remainingFlow = MathUtils.safeInt((long)(aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + this.realOptFlow = aOptFlow; + + storedFluid=0; + for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { + String fluidName = aFluids.get(i).getFluid().getUnlocalizedName(aFluids.get(i)); + if (fluidName.equals("ic2.fluidSuperheatedSteam")) { + flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + if (!achievement) { + try { + GT_Mod.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "efficientsteam"); + } catch (Exception e) { + } + achievement = true; + } + }else if(fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") || fluidName.equals("fluid.mfr.steam.still.name")){ + depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); + } + } + if(totalFlow<=0)return 0; + tEU = totalFlow; + addOutput(GT_ModHandler.getSteam(totalFlow)); + if (totalFlow != aOptFlow) { + float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow); + //if(totalFlow>aOptFlow){efficiency = 1.0f;} + tEU *= efficiency; + tEU = Math.max(1, MathUtils.safeInt((long)tEU * (long)aBaseEff / 10000L)); + } else { + tEU = MathUtils.safeInt((long)tEU * (long)aBaseEff / 10000L); + } + + return tEU; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + looseFit^=true; + GT_Utility.sendChatToPlayer(aPlayer, looseFit ? "Fitting: Loose - More Flow" : "Fitting: Tight - More Efficiency"); + } + super.onModeChangeByScrewdriver(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return (looseFit && CORE.RANDOM.nextInt(4)==0)?0:1; + } + + @Override + public String[] getExtraInfoData() { + super.looseFit = looseFit; + return super.getInfoData(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("turbineFitting",looseFit); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + looseFit=aNBT.getBoolean("turbineFitting"); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Large Super-heated Steam Turbine"; + } + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java new file mode 100644 index 0000000000..2e6f6149e7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java @@ -0,0 +1,189 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; + +import static gtPlusPlus.core.lib.CORE.RANDOM; + +import java.util.ArrayList; + +import gregtech.GT_Mod; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurbineBase { + + private float water; + private boolean achievement = false; + private boolean looseFit=false; + + public GT_MTE_LargeTurbine_Steam(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + + public GT_MTE_LargeTurbine_Steam(String aName) { + super(aName); + } + + public String[] getTooltip() { + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, 8); + } + return new String[]{ + "Controller Block for the XL Steam Turbine", + "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", + "1x Steam Input Hatch (Side centered)", + "1x Maintenance Hatch (Side centered)", + "1x Dynamo Hatch (Back centered)", + "1x Output Hatch for Distilled Water (Side centered)", + mCasingName+"s for the rest (24 at least!)", + "Needs a Turbine Item (Inside controller GUI)", + "Output depending on Rotor and fitting", + "Use screwdriver to adjust fitting of turbine"}; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MTE_LargeTurbine_Steam(mName); + } + + @Override + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + @Override + public byte getCasingMeta() { + return 8; + } + + @Override + public byte getCasingTextureIndex() { + return 16; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + private int useWater(float input) { + water = water + input; + int usage = (int) water; + water = water - usage; + return usage; + } + + @Override + int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + if(looseFit) { + aOptFlow*=4; + if(aBaseEff>10000){ + aOptFlow*=Math.pow(1.1f,((aBaseEff-7500)/10000F)*20f); + aBaseEff=7500; + }else if(aBaseEff>7500){ + aOptFlow*=Math.pow(1.1f,((aBaseEff-7500)/10000F)*20f); + aBaseEff*=0.75f; + }else{ + aBaseEff*=0.75f; + } + } + int tEU = 0; + int totalFlow = 0; // Byproducts are based on actual flow + int flow = 0; + int remainingFlow = MathUtils.safeInt((long)(aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + this.realOptFlow = aOptFlow; + + storedFluid=0; + for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and track totals. + String fluidName = aFluids.get(i).getFluid().getUnlocalizedName(aFluids.get(i)); + if (fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") || fluidName.equals("fluid.mfr.steam.still.name")) { + flow = Math.min(aFluids.get(i).amount, remainingFlow); // try to use up w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid += aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + if (!achievement) { + GT_Mod.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "muchsteam"); + achievement = true; + } + }else if(fluidName.equals("ic2.fluidSuperheatedSteam")){ + depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); + } + } + if(totalFlow<=0)return 0; + tEU = totalFlow; + int waterToOutput = useWater(totalFlow / 160.0f); + addOutput(GT_ModHandler.getDistilledWater(waterToOutput)); + if (totalFlow != aOptFlow) { + float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow); + //if(totalFlow>aOptFlow){efficiency = 1.0f;} + tEU *= efficiency; + tEU = Math.max(1, MathUtils.safeInt((long)tEU * (long)aBaseEff / 20000L)); + } else { + tEU = MathUtils.safeInt((long)tEU * (long)aBaseEff / 20000L); + } + + return tEU; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + looseFit^=true; + GT_Utility.sendChatToPlayer(aPlayer, looseFit ? "Fitting: Loose - More Flow" : "Fitting: Tight - More Efficiency"); + } + super.onModeChangeByScrewdriver(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return (looseFit && RANDOM.nextInt(4)==0)?0:1; + } + + + @Override + public String[] getExtraInfoData() { + super.looseFit = looseFit; + return super.getInfoData(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("turbineFitting",looseFit); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + looseFit=aNBT.getBoolean("turbineFitting"); + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Large Steam Turbine"; + } + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java new file mode 100644 index 0000000000..9da724c6eb --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java @@ -0,0 +1,663 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines; + +import java.util.ArrayList; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Turbine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.turbine.LargeTurbineTextureHandler; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GregtechMetaTileEntity_LargerTurbineBase extends GregtechMeta_MultiBlockBase { + + protected int baseEff = 0; + protected int optFlow = 0; + protected double realOptFlow = 0; + protected int storedFluid = 0; + protected int counter = 0; + protected boolean looseFit=false; + + private final int mCasingTextureID; + public static String mCasingName; + + public ArrayList<GT_MetaTileEntity_Hatch_Turbine> mTurbineRotorHatches = new ArrayList<GT_MetaTileEntity_Hatch_Turbine>(); + + public GregtechMetaTileEntity_LargerTurbineBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, getCasingMeta()); + mCasingTextureID = getTAE(); + GT9_5_Active = getCasingMeta() == 8 ? LargeTurbineTextureHandler.frontFaceActive_4 : LargeTurbineTextureHandler.frontFaceHPActive_4; + GT9_5 = getCasingMeta() == 8 ? LargeTurbineTextureHandler.frontFace_4 : LargeTurbineTextureHandler.frontFaceHP_4; + frontFaceActive = new GT_RenderedTexture(GT9_5_Active); + frontFace = new GT_RenderedTexture(GT9_5); + + } + public GregtechMetaTileEntity_LargerTurbineBase(String aName) { + super(aName); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, getCasingMeta()); + mCasingTextureID = getTAE(); + GT9_5_Active = getCasingMeta() == 8 ? LargeTurbineTextureHandler.frontFaceActive_4 : LargeTurbineTextureHandler.frontFaceHPActive_4; + GT9_5 = getCasingMeta() == 8 ? LargeTurbineTextureHandler.frontFace_4 : LargeTurbineTextureHandler.frontFaceHP_4; + frontFaceActive = new GT_RenderedTexture(GT9_5_Active); + frontFace = new GT_RenderedTexture(GT9_5); + } + + public final int getTAE() { + return TAE.getIndexFromPage(3, getCasingMeta()); + } + + public final String getCasingNaming() { + return ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings4Misc, getCasingMeta()); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeTurbine.png"); + } + + @Override + public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + return checkMachine2(aBaseMetaTileEntity, aStack); + } + + public boolean checkMachine2(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + //9 high + //7x7 + + this.mDynamoHatches.clear(); + this.mTurbineRotorHatches.clear(); + this.mMaintenanceHatches.clear(); + this.mMufflerHatches.clear(); + this.mInputHatches.clear(); + this.mOutputHatches.clear(); + + for (int i=0;i>-9;i--) { + if (!getLayer(i)) { + Logger.INFO("Bad Layer: "+(+i)); + return false; + } + } + + Logger.INFO("Hatches | Found "+mTurbineRotorHatches.size()+" Rotor Assemblies, "+12+" are required."); + Logger.INFO("Hatches | Found "+mMaintenanceHatches.size()+" Maint. hatches, "+1+" are required."); + Logger.INFO("Hatches | Found "+mDynamoHatches.size()+" Dynamos, "+1+" or more are required."); + Logger.INFO("Hatches | Found "+mMufflerHatches.size()+" Mufflers, "+4+" are required."); + Logger.INFO("Hatches | Found "+mInputHatches.size()+" Input Hatches, "+1+" or more are required."); + Logger.INFO("Hatches | Found "+mOutputHatches.size()+" Output Hatches, "+1+" ore more are required."); + + if (mTurbineRotorHatches.size() != 12 || + mMaintenanceHatches.size() != 1 || + mDynamoHatches.size() < 1 || + mMufflerHatches.size() != 4 || + mInputHatches.size() < 1 || + mOutputHatches.size() < 1 + ) { + return false; + } + Logger.INFO("Built Structure"); + return true; + } + + + public boolean getLayer(int aY) { + if (aY == 0 || aY == -2 || aY == -3 || aY == -5 || aY == -6 || aY == -8) { + return checkNormalLayer(aY); + } + else { + return checkTurbineLayer(aY); + } + } + + public boolean checkNormalLayer(int aY) { + Block tBlock; + int tMeta; + for (int x = -3; x <= 3; x++) { + for (int z = -3; z <= 3; z++) { + tBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z); + tMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z); + IGregTechTileEntity tTileEntity; + + if (aY == 0 && x == 0 && z == 0) { + continue; + } + else if ((x == 0 && z == -3) || (x == 0 && z == 3) || (x == 3 && z == 0) || (x == -3 && z == 0) || + ((aY == 0) && (x == 0 && z == -2) || (x == 0 && z == 2) || (x == 2 && z == 0) || (x == -2 && z == 0))) { + tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z); + if (this.addToMachineList(tTileEntity, this.mCasingTextureID)) { + Logger.INFO("Added Hatch at offset "+x+", "+aY+", "+z+" | Type: "+tTileEntity.getInventoryName()); + continue; + } + } + else if (isValidCasingBlock(tBlock, tMeta)) { + continue; + } else { + if (tBlock != null) { + log("Offset: "+x+", "+aY+", "+z); + log("Found "+tBlock.getLocalizedName()+" with Meta "+tMeta); + log("Expected "+getCasingBlock().getLocalizedName()+" with Meta "+getCasingMeta()); + } + return false; + } + } + } + return true; + } + + + public boolean checkTurbineLayer(int aY) { + if (!checkTurbineLayerX(aY)) { + return checkTurbineLayerZ(aY); + } + else { + return true; + } + } + + public boolean checkTurbineLayerX(int aY) { + Logger.INFO("checking X"); + Block tBlock; + int tMeta; + for (int x = -3; x <= 3; x++) { + for (int z = -3; z <= 3; z++) { + tBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z); + tMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z); + + if ((x == 0 && z == -3) || (x == 0 && z == 3) || (x == 3 && z == 0) || (x == -3 && z == 0) || + ((aY == 0) && (x == 0 && z == -2) || (x == 0 && z == 2) || (x == 2 && z == 0) || (x == -2 && z == 0))) { + IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z); + if (this.addToMachineList(tTileEntity, this.mCasingTextureID)) { + Logger.INFO("Added Hatch at offset "+x+", "+aY+", "+z+" | Type: "+tTileEntity.getInventoryName()); + continue; + } + } + + + if (x == -2 || x == 2) { + + //Find Hatches on the ends + if (z == -3 || z == 3) { + IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z); + if (this.addTurbineHatch(tTileEntity, this.mCasingTextureID)) { + log("Found x axis Turbine Assembly at Offset: "+x+", "+aY+", "+z); + continue; + } + else { + log("Missing x axis Turbine Assembly at Offset: "+x+", "+aY+", "+z); + } + } + + if (isValidTurbineBlock(tBlock, tMeta)) { + continue; + } + else { + return false; + } + } + else { + if (isValidCasingBlock(tBlock, tMeta)) { + continue; + } + else { + return false; + } + } + } + } + return true; + } + + public boolean checkTurbineLayerZ(int aY) { + Logger.INFO("checking Z"); + Block tBlock; + int tMeta; + for (int x = -3; x <= 3; x++) { + for (int z = -3; z <= 3; z++) { + tBlock = this.getBaseMetaTileEntity().getBlockOffset(x, aY, z); + tMeta = this.getBaseMetaTileEntity().getMetaIDOffset(x, aY, z); + + if ((x == 0 && z == -3) || (x == 0 && z == 3) || (x == 3 && z == 0) || (x == -3 && z == 0) || + ((aY == 0) && (x == 0 && z == -2) || (x == 0 && z == 2) || (x == 2 && z == 0) || (x == -2 && z == 0))) { + IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z); + if (this.addToMachineList(tTileEntity, this.mCasingTextureID)) { + Logger.INFO("Added Hatch at offset "+x+", "+aY+", "+z+" | Type: "+tTileEntity.getInventoryName()); + continue; + } + } + + if (z == -2 || z == 2) { + + //Find Hatches on the ends + if (x == -3 || x == 3) { + IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(x, aY, z); + if (this.addTurbineHatch(tTileEntity, this.mCasingTextureID)) { + log("Found z axis Turbine Assembly at Offset: "+x+", "+aY+", "+z); + continue; + } + else { + log("Missing z axis Turbine Assembly at Offset: "+x+", "+aY+", "+z); + } + } + + if (isValidTurbineBlock(tBlock, tMeta)) { + continue; + } + else { + return false; + } + } + else { + if (isValidCasingBlock(tBlock, tMeta)) { + continue; + } + else { + return false; + } + } + } + } + return true; + } + + public boolean isValidCasingBlock(Block aBlock, int aMeta) { + if (GregTech_API.sBlockMachines == aBlock) { + return true; + } + if (Block.isEqualTo(aBlock, getCasingBlock()) && (int) aMeta == (int) getCasingMeta()) { + return true; + } + log("Found "+(aBlock != null ? aBlock.getLocalizedName() : "Air") + " With Meta "+aMeta+", Expected "+getCasingBlock().getLocalizedName()+" With Meta "+getCasingMeta()); + return false; + } + + public boolean isValidTurbineBlock(Block aBlock, int aMeta) { + if (aBlock == getCasingBlock() && aMeta == getCasingMetaTurbine()) { + return true; + } + log("Found "+(aBlock != null ? aBlock.getLocalizedName() : "Air") + " With Meta "+aMeta+", Expected "+getCasingBlock().getLocalizedName()+" With Meta "+getCasingMetaTurbine()); + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings4Misc; + } + + public abstract byte getCasingMeta(); + + public byte getCasingMetaTurbine() { + return 7; + } + + public abstract byte getCasingTextureIndex(); + + @Override + public boolean checkRecipe(ItemStack aStack) { + if((counter&7)==0 && (aStack==null || !(aStack.getItem() instanceof GT_MetaGenerated_Tool) || aStack.getItemDamage() < 170 || aStack.getItemDamage() >179)) { + stopMachine(); + return false; + } + ArrayList<FluidStack> tFluids = getStoredFluids(); + if (tFluids.size() > 0) { + if (baseEff == 0 || optFlow == 0 || counter >= 512 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() + || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { + counter = 0; + baseEff = MathUtils.safeInt((long)((5F + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack)) * 1000F)); + optFlow = MathUtils.safeInt((long)Math.max(Float.MIN_NORMAL, + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() + * GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolSpeed + * 50)); + if(optFlow<=0 || baseEff<=0){ + stopMachine();//in case the turbine got removed + return false; + } + } else { + counter++; + } + } + else { + Logger.INFO("Did not find any valid input fluids."); + } + + int newPower = fluidIntoPower(tFluids, optFlow, baseEff); // How much the turbine should be producing with this flow + int difference = newPower - this.mEUt; // difference between current output and new output + + // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick) + // This is how much the turbine can actually change during this tick + int maxChangeAllowed = Math.max(10, MathUtils.safeInt((long)Math.abs(difference)/100)); + + if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change + int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. + this.mEUt += change; // Apply the change + } else { + this.mEUt = newPower; + } + + if (this.mEUt <= 0) { + //stopMachine(); + this.mEUt=0; + this.mEfficiency=0; + return false; + } else { + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 10; + if(this.mDynamoHatches.size()>0){ + for(GT_MetaTileEntity_Hatch dynamo:mDynamoHatches) + if(isValidMetaTileEntity(dynamo) && dynamo.maxEUOutput() < mEUt) + explodeMultiblock(); + } + return true; + } + } + + abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff); + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + public int getMaxEfficiency(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) { + return 0; + } + if (aStack.getItem() instanceof GT_MetaGenerated_Tool_01) { + return 10000; + } + return 0; + } + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return true; + } + + @Override + public String[] getExtraInfoData() { + int mPollutionReduction=0; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + mPollutionReduction=Math.max(StaticFields59.calculatePollutionReducation(tHatch, 100),mPollutionReduction); + } + } + + String tRunning = mMaxProgresstime>0 ? + + EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.running.true")+EnumChatFormatting.RESET : + EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.running.false")+EnumChatFormatting.RESET; + String tMaintainance = getIdealStatus() == getRepairStatus() ? + EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.maintenance.false")+EnumChatFormatting.RESET : + EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.maintenance.true")+EnumChatFormatting.RESET ; + int tDura = 0; + + if (mInventory[1] != null && mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { + tDura = MathUtils.safeInt((long)(100.0f / GT_MetaGenerated_Tool.getToolMaxDamage(mInventory[1]) * (GT_MetaGenerated_Tool.getToolDamage(mInventory[1]))+1)); + } + + long storedEnergy=0; + long maxEnergy=0; + for(GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); + } + } + String[] ret = new String[]{ + // 8 Lines available for information panels + tRunning + ": " + EnumChatFormatting.RED+mEUt+EnumChatFormatting.RESET+" EU/t", */ +/* 1 *//* + + tMaintainance, */ +/* 2 *//* + + StatCollector.translateToLocal("GT5U.turbine.efficiency")+": "+EnumChatFormatting.YELLOW+(mEfficiency/100F)+EnumChatFormatting.RESET+"%", */ +/* 2 *//* + + StatCollector.translateToLocal("GT5U.multiblock.energy")+": " + EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ */ +/* 3 *//* + + EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", + StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+MathUtils.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/t" + */ +/* 4 *//* + + EnumChatFormatting.YELLOW+" ("+(looseFit?StatCollector.translateToLocal("GT5U.turbine.loose"):StatCollector.translateToLocal("GT5U.turbine.tight"))+")", */ +/* 5 *//* + + StatCollector.translateToLocal("GT5U.turbine.fuel")+": "+EnumChatFormatting.GOLD+storedFluid+EnumChatFormatting.RESET+"L", */ +/* 6 *//* + + StatCollector.translateToLocal("GT5U.turbine.dmg")+": "+EnumChatFormatting.RED+Integer.toString(tDura)+EnumChatFormatting.RESET+"%", */ +/* 7 *//* + + StatCollector.translateToLocal("GT5U.multiblock.pollution")+": "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" */ +/* 8 *//* + + }; + if (!this.getClass().getName().contains("Steam")) + ret[4]=StatCollector.translateToLocal("GT5U.turbine.flow")+": "+EnumChatFormatting.YELLOW+MathUtils.safeInt((long)realOptFlow)+EnumChatFormatting.RESET+" L/t"; + return ret; + + + } + + @Override + public boolean isGivingInformation() { + return true; + } + + + public boolean polluteEnvironment(int aPollutionLevel) { + mPollution += aPollutionLevel; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (mPollution >= 1000) { + if (tHatch.polluteEnvironment()) { + mPollution -= 1000; + } + } else { + break; + } + } + } + return mPollution < 1000; + } + @Override + public long maxAmperesOut() { + return 16; + } + + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!KeyboardUtils.isShiftKeyDown()) { + //super.onModeChangeByScrewdriver(aSide, aPlayer, aX, aY, aZ); + } + else { + this.mIsAnimated = Utils.invertBoolean(mIsAnimated); + if (this.mIsAnimated) { + PlayerUtils.messagePlayer(aPlayer, "Using Animated Turbine Texture."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Using Static Turbine Texture."); + } + if (mTurbineRotorHatches.size() > 0) { + for (GT_MetaTileEntity_Hatch_Turbine h : mTurbineRotorHatches) { + if (h != null) { + h.mUsingAnimation = mIsAnimated; + } + } + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mIsAnimated", mIsAnimated); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mIsAnimated = aNBT.getBoolean("mIsAnimated"); + } + + private boolean mIsAnimated = true; + public ITexture frontFace; + public ITexture frontFaceActive; + private CustomIcon GT9_5_Active; + private CustomIcon GT9_5; + + public boolean usingAnimations() { + return mIsAnimated; + } + + @Override + public final ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? getFrontFacingTurbineTexture(aActive) : Textures.BlockIcons.getCasingTextureForId(getTAE())}; + } + + protected ITexture getFrontFacingTurbineTexture(boolean isActive) { + if (usingAnimations()) { + if (isActive) { + return frontFaceActive; + } + } + return frontFace; + } + + public boolean addTurbineHatch(final IGregTechTileEntity aTileEntity, + final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Turbine) { + log("Found GT_MetaTileEntity_Hatch_Turbine"); + updateTexture(aTileEntity, aBaseCasingIndex); + GT_MetaTileEntity_Hatch_Turbine aTurbineHatch = (GT_MetaTileEntity_Hatch_Turbine) aMetaTileEntity; + IGregTechTileEntity g = this.getBaseMetaTileEntity(); + if (aTurbineHatch.setController(new BlockPos(g.getXCoord(), g.getYCoord(), g.getZCoord(), g.getWorld()))) { + Logger.INFO("Injected Controller into Turbine Assembly."); + return this.mTurbineRotorHatches.add(aTurbineHatch); + } + else { + Logger.INFO("Failed to inject controller into Turbine Assembly Hatch."); + } + } + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if (mUpdate == 0 || this.mStartUpCheck == 0) { + this.mTurbineRotorHatches.clear(); + } + } + if (aTick % 20 == 0 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()) { + enableAllTurbineHatches(); + } + + } + @Override + public void startProcess() { + super.startProcess(); + enableAllTurbineHatches(); + } + @Override + public void onMachineBlockUpdate() { + super.onMachineBlockUpdate(); + } + @Override + public boolean onRunningTick(ItemStack aStack) { + return super.onRunningTick(aStack); + } + @Override + public void stopMachine() { + super.stopMachine(); + disableAllTurbineHatches(); + } + @Override + public void onRemoval() { + super.onRemoval(); + for (GT_MetaTileEntity_Hatch_Turbine h : this.mTurbineRotorHatches) { + h.clearController(); + } + disableAllTurbineHatches(); + this.mTurbineRotorHatches.clear(); + } + + public boolean enableAllTurbineHatches() { + return updateTurbineHatches(this.isMachineRunning()) > 0; + } + public boolean disableAllTurbineHatches() { + return updateTurbineHatches(false) > 0; + } + + private Long mLastHatchUpdate; + public int updateTurbineHatches(boolean aState) { + int aUpdated = 0; + if (mLastHatchUpdate == null) { + mLastHatchUpdate = System.currentTimeMillis()/1000; + } + if (this.mTurbineRotorHatches.isEmpty() || ((System.currentTimeMillis()/1000)-mLastHatchUpdate) <= 2) { + return 0; + } + for (GT_MetaTileEntity_Hatch_Turbine h : this.mTurbineRotorHatches) { + h.setActive(aState); + aUpdated++; + } + + mLastHatchUpdate = System.currentTimeMillis()/1000; + return aUpdated; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_MultiTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_MultiTank.java new file mode 100644 index 0000000000..6ed14eb2a9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_MultiTank.java @@ -0,0 +1,621 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage; + +import java.util.ArrayList; +import java.util.Arrays; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +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.api.objects.data.Pair; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +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.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_MultiTank +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_MultiTank(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private short multiblockCasingCount = 0; + private int mInternalSaveClock = 0; + private final short storageMultiplier = 1; + private int maximumFluidStorage = 128000; + private FluidStack internalStorageTank = null; + private final NBTTagCompound internalCraftingComponentsTag = new NBTTagCompound(); + + @Override + public String getMachineType() { + return "Fluid Tank"; + } + + @Override + public String[] getExtraInfoData() { + final ArrayList<GT_MetaTileEntity_Hatch_Energy> mTier = this.mEnergyHatches; + if (!mTier.isEmpty()){ + final int temp = mTier.get(0).mTier; + if (this.internalStorageTank == null) { + return new String[]{ + GT_Values.VOLTAGE_NAMES[temp]+" Large Fluid Tank", + "Stored Fluid: No Fluid", + "Internal | Current: "+Integer.toString(0) + "L", + "Internal | Maximum: "+Integer.toString(this.maximumFluidStorage) + "L"}; + } + return new String[]{ + GT_Values.VOLTAGE_NAMES[temp]+" Large Fluid Tank", + "Stored Fluid: "+this.internalStorageTank.getLocalizedName(), + "Internal | Current: "+Integer.toString(this.internalStorageTank.amount) + "L", + "Internal | Maximum: "+Integer.toString(this.maximumFluidStorage) + "L"}; + } + return new String[]{ + "Voltage Tier not set -" +" Large Fluid Tank", + "Stored Fluid: No Fluid", + "Internal | Current: "+Integer.toString(0) + "L", + "Internal | Maximum: "+Integer.toString(this.maximumFluidStorage) + "L"}; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + */ +/*final NBTTagCompound gtCraftingComponentsTag = aNBT.getCompoundTag("GT.CraftingComponents"); + if (gtCraftingComponentsTag != null){ + + Utils.LOG_WARNING("Got Crafting Tag"); + + if (this.internalStorageTank != null){ + Utils.LOG_WARNING("mFluid was not null, Saving TileEntity NBT data."); + + gtCraftingComponentsTag.setString("xFluid", this.internalStorageTank.getFluid().getName()); + gtCraftingComponentsTag.setInteger("xAmount", this.internalStorageTank.amount); + gtCraftingComponentsTag.setLong("xAmountMax", this.maximumFluidStorage); + + aNBT.setTag("GT.CraftingComponents", gtCraftingComponentsTag); + } + else { + Utils.LOG_WARNING("mFluid was null, Saving TileEntity NBT data."); + gtCraftingComponentsTag.removeTag("xFluid"); + gtCraftingComponentsTag.removeTag("xAmount"); + gtCraftingComponentsTag.removeTag("xAmountMax"); + gtCraftingComponentsTag.setLong("xAmountMax", this.maximumFluidStorage); + + + aNBT.setTag("GT.CraftingComponents", gtCraftingComponentsTag); + } + }*//* + + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + */ +/*final NBTTagCompound gtCraftingComponentsTag = aNBT.getCompoundTag("GT.CraftingComponents"); + String xFluid = null; + int xAmount = 0; + if (gtCraftingComponentsTag.hasNoTags()){ + if (this.internalStorageTank != null){ + Utils.LOG_WARNING("mFluid was not null, Creating TileEntity NBT data."); + gtCraftingComponentsTag.setInteger("xAmount", this.internalStorageTank.amount); + gtCraftingComponentsTag.setString("xFluid", this.internalStorageTank.getFluid().getName()); + aNBT.setTag("GT.CraftingComponents", gtCraftingComponentsTag); + } + } + else { + + //internalCraftingComponentsTag = gtCraftingComponentsTag.getCompoundTag("backupTag"); + + if (gtCraftingComponentsTag.hasKey("xFluid")){ + Utils.LOG_WARNING("xFluid was not null, Loading TileEntity NBT data."); + xFluid = gtCraftingComponentsTag.getString("xFluid"); + } + if (gtCraftingComponentsTag.hasKey("xAmount")){ + Utils.LOG_WARNING("xAmount was not null, Loading TileEntity NBT data."); + xAmount = gtCraftingComponentsTag.getInteger("xAmount"); + } + if ((xFluid != null) && (xAmount != 0)){ + Utils.LOG_WARNING("Setting Internal Tank, loading "+xAmount+"L of "+xFluid); + this.setInternalTank(xFluid, xAmount); + } + }*//* + + } + + private boolean setInternalTank(final String fluidName, final int amount){ + final FluidStack temp = FluidUtils.getFluidStack(fluidName, amount); + if (temp != null){ + if (this.internalStorageTank == null){ + this.internalStorageTank = temp; + Logger.WARNING(temp.getFluid().getName()+" Amount: "+temp.amount+"L"); + } + else{ + Logger.WARNING("Retained Fluid."); + Logger.WARNING(this.internalStorageTank.getFluid().getName()+" Amxount: "+this.internalStorageTank.amount+"L"); + } + this.markDirty(); + return true; + } + return false; + } + + @Override + public void onLeftclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + this.tryForceNBTUpdate(); + super.onLeftclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public boolean onWrenchRightClick(final byte aSide, final byte aWrenchingSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { + this.tryForceNBTUpdate(); + return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + } + + @Override + public void onRemoval() { + this.tryForceNBTUpdate(); + super.onRemoval(); + } + + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if ((this.internalStorageTank != null) && this.internalStorageTank.amount >= this.maximumFluidStorage){ + if (this.internalStorageTank.amount > this.maximumFluidStorage){ + this.internalStorageTank.amount = this.maximumFluidStorage; + } + this.stopMachine(); + } + + if (this.mInternalSaveClock != 20){ + this.mInternalSaveClock++; + } + else { + this.mInternalSaveClock = 0; + this.tryForceNBTUpdate(); + } + + } + + public GregtechMetaTileEntity_MultiTank(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MultiTank(this.mName); + } + + @Override + public String[] getTooltip() { + return new String[]{ + "Controller Block for the Multitank", + "Size: 3xHx3 (Block behind controller must be air)", + "Structure must be at least 4 blocks tall, maximum 20.", + "Each casing within the structure adds 128000L storage.", + "Multitank Exterior Casings (16 at least!)", + "Controller (front centered)", + "1x Input hatch", + "1x Output hatch", + "1x Energy Hatch", + }; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(11)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Screen_Logo : TexturesGtBlock.Overlay_Machine_Screen_Logo)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(11))}; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + + final ArrayList<ItemStack> tInputList = this.getStoredInputs(); + for (int i = 0; i < (tInputList.size() - 1); i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); + for (int i = 0; i < (tFluidList.size() - 1); i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[1]), 0, 1); + + if (tFluids.length >= 2){ + Logger.WARNING("Bad"); + return false; + } + + final ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>> rList = new ArrayList<>(); + int slotInputCount = 0; + for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + boolean containsFluid = false; + if (isValidMetaTileEntity(tHatch)) { + slotInputCount++; + for (int i=0; i<tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { + if (tHatch.canTankBeEmptied()){containsFluid=true;} + } + rList.add(new Pair<>(tHatch, containsFluid)); + } + } + if ((tFluids.length <= 0) || (slotInputCount > 1)){ + Logger.WARNING("Bad"); + return false; + } + + Logger.WARNING("Okay - 2"); + if (this.internalStorageTank == null){ + Logger.WARNING("Okay - 3"); + if ((rList.get(0).getKey().mFluid != null) && (rList.get(0).getKey().mFluid.amount > 0)){ + Logger.WARNING("Okay - 4"); + Logger.WARNING("Okay - 1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount */ +/*+" internalStorageTank:"+internalStorageTank.amount*//* +); + final FluidStack tempFluidStack = rList.get(0).getKey().mFluid; + final Fluid tempFluid = tempFluidStack.getFluid(); + this.internalStorageTank = FluidUtils.getFluidStack(tempFluid.getName(), tempFluidStack.amount); + rList.get(0).getKey().mFluid.amount = 0; + Logger.WARNING("Okay - 1.1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount +" internalStorageTank:"+this.internalStorageTank.amount); + return true; + } + Logger.WARNING("No Fluid in hatch."); + return false; + } + else if (this.internalStorageTank.isFluidEqual(rList.get(0).getKey().mFluid)){ + Logger.WARNING("Storing "+rList.get(0).getKey().mFluid.amount+"L"); + Logger.WARNING("Contains "+this.internalStorageTank.amount+"L"); + + + int tempAdd = 0; + tempAdd = rList.get(0).getKey().getFluidAmount(); + rList.get(0).getKey().mFluid = null; + Logger.WARNING("adding "+tempAdd); + this.internalStorageTank.amount = this.internalStorageTank.amount + tempAdd; + Logger.WARNING("Tank now Contains "+this.internalStorageTank.amount+"L of "+this.internalStorageTank.getFluid().getName()+"."); + + + //Utils.LOG_WARNING("Tank"); + return true; + } + else { + final FluidStack superTempFluidStack = rList.get(0).getKey().mFluid; + Logger.WARNING("is input fluid equal to stored fluid? "+(this.internalStorageTank.isFluidEqual(superTempFluidStack))); + if (superTempFluidStack != null) { + Logger.WARNING("Input hatch[0] Contains "+superTempFluidStack.amount+"L of "+superTempFluidStack.getFluid().getName()+"."); + } + Logger.WARNING("Large Multi-Tank Contains "+this.internalStorageTank.amount+"L of "+this.internalStorageTank.getFluid().getName()+"."); + + if (this.internalStorageTank.amount <= 0){ + Logger.WARNING("Internal Tank is empty, sitting idle."); + return false; + } + + if ((this.mOutputHatches.get(0).mFluid == null) || this.mOutputHatches.isEmpty() || (this.mOutputHatches.get(0).mFluid.isFluidEqual(this.internalStorageTank) && (this.mOutputHatches.get(0).mFluid.amount < this.mOutputHatches.get(0).getCapacity()))){ + Logger.WARNING("Okay - 3"); + final int tempCurrentStored = this.internalStorageTank.amount; + int tempResult = 0; + final int tempHatchSize = this.mOutputHatches.get(0).getCapacity(); + final int tempHatchCurrentHolding = this.mOutputHatches.get(0).getFluidAmount(); + final int tempHatchRemainingSpace = tempHatchSize - tempHatchCurrentHolding; + final FluidStack tempOutputFluid = this.internalStorageTank; + if (tempHatchRemainingSpace <= 0){ + return false; + } + Logger.WARNING("Okay - 3.1.x"+" hatchCapacity: "+tempHatchSize +" tempCurrentStored: "+tempCurrentStored+" output hatch holds: "+tempHatchCurrentHolding+" tank has "+tempHatchRemainingSpace+"L of space left."); + + if (tempHatchSize >= tempHatchRemainingSpace){ + Logger.WARNING("Okay - 3.1.1"+" hatchCapacity: "+tempHatchSize +" tempCurrentStored: "+tempCurrentStored+" output hatch holds: "+tempHatchCurrentHolding+" tank has "+tempHatchRemainingSpace+"L of space left."); + + int adder; + if ((tempCurrentStored > 0) && (tempCurrentStored <= tempHatchSize)){ + adder = tempCurrentStored; + if (adder >= tempHatchRemainingSpace){ + adder = tempHatchRemainingSpace; + } + } + else { + adder = 0; + if (tempCurrentStored >= tempHatchRemainingSpace){ + adder = tempHatchRemainingSpace; + } + } + + tempResult = adder; + tempOutputFluid.amount = tempResult; + Logger.WARNING("Okay - 3.1.2"+" result: "+tempResult +" tempCurrentStored: "+tempCurrentStored + " filling output hatch with: "+tempOutputFluid.amount+"L of "+tempOutputFluid.getFluid().getName()); + this.mOutputHatches.get(0).fill(tempOutputFluid, true); + //mOutputHatches.get(0).mFluid.amount = tempResult; + this.internalStorageTank.amount = (tempCurrentStored-adder); + Logger.WARNING("Okay - 3.1.3"+" internalTankStorage: "+this.internalStorageTank.amount +"L | output hatch contains: "+this.mOutputHatches.get(0).mFluid.amount+"L of "+this.mOutputHatches.get(0).mFluid.getFluid().getName()); + */ +/*if (internalStorageTank.amount <= 0) + internalStorageTank = null;*//* + + } + Logger.WARNING("Tank ok."); + return true; + } + } + //this.getBaseMetaTileEntity().(tFluids[0].amount, true); + Logger.WARNING("Tank"); + return false; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + Logger.WARNING("Must be hollow."); + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 19; h++) { + if ((h != 0) || ((((xDir + i) != 0) || ((zDir + j) != 0)) && ((i != 0) || (j != 0)))) { + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!this.addMaintenanceToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!this.addInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!this.addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!this.addEnergyInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11)))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + if (h < 3){ + Logger.WARNING("Casing Expected."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 11) { + if (h < 3){ + Logger.WARNING("Wrong Meta."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (h < 3){ + tAmount++; + } + else if (h >= 3){ + if ((aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == Blocks.air) || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ + Logger.WARNING("Found air"); + } + else { + Logger.WARNING("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); + tAmount++; + } + } + } + } + } + } + } + this.multiblockCasingCount = (short) tAmount; + this.maximumFluidStorage = getMaximumTankStorage(tAmount); + Logger.INFO("Your Multitank can be 20 blocks tall."); + Logger.INFO("Casings Count: "+this.multiblockCasingCount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+this.maximumFluidStorage+"L"); + this.tryForceNBTUpdate(); + return tAmount >= 16; + } + + */ +/*public int countCasings() { + Utils.LOG_INFO("Counting Machine Casings"); + try{ + if (this.getBaseMetaTileEntity().getWorld() == null){ + Utils.LOG_INFO("Tile Entity's world was null for casing count."); + return 0; + } + if (this.getBaseMetaTileEntity() == null){ + Utils.LOG_INFO("Tile Entity was null for casing count."); + return 0; + } + } catch(NullPointerException r){ + Utils.LOG_INFO("Null Pointer Exception caught."); + return 0; + } + int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; + if (!this.getBaseMetaTileEntity().getAirOffset(xDir, 0, zDir)) { + Utils.LOG_INFO("Failed due to air being misplaced."); + Utils.LOG_WARNING("Must be hollow."); + return 0; + } + int tAmount = 0; + Utils.LOG_INFO("Casing Count set to 0."); + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 19; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!addInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(11))) && (!addEnergyInputToMachineList(tTileEntity, TAE.GTPP_INDEX(11)))) { + if (this.getBaseMetaTileEntity().getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + if (h < 3){ + Utils.LOG_WARNING("Casing Expected."); + return 0; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (this.getBaseMetaTileEntity().getMetaIDOffset(xDir + i, h, zDir + j) != 11) { + if (h < 3){ + Utils.LOG_WARNING("Wrong Meta."); + return 0; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (h < 3){ + tAmount++; + } + else if (h >= 3){ + if (this.getBaseMetaTileEntity().getBlockOffset(xDir + i, h, zDir + j) == Blocks.air || this.getBaseMetaTileEntity().getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ + Utils.LOG_WARNING("Found air"); + } + else { + Utils.LOG_WARNING("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); + tAmount++; + } + } + } + } + } + } + } + Utils.LOG_INFO("Finished counting."); + multiblockCasingCount = (short) tAmount; + //Utils.LOG_INFO("Your Multitank can be 20 blocks tall."); + Utils.LOG_INFO("Casings Count: "+tAmount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+getMaximumTankStorage(tAmount)+"L"); + return tAmount; + }*//* + + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 5; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + private static short getStorageMultiplier(final int casingCount){ + final int tsm = 1*casingCount; + if (tsm <= 0){ + return 1; + } + return (short) tsm; + } + + private static int getMaximumTankStorage(final int casingCount){ + final int multiplier = getStorageMultiplier(casingCount); + final int tempTankStorageMax = 128000*multiplier; + if (tempTankStorageMax <= 0){return 128000;} + return tempTankStorageMax; + } + + private boolean tryForceNBTUpdate(){ +*/ +/* + //Block is invalid. + if ((this == null) || (this.getBaseMetaTileEntity() == null)){ + Utils.LOG_WARNING("Block was not valid for saving data."); + return false; + } + + //Don't need this to run clientside. + if (!this.getBaseMetaTileEntity().isServerSide()) { + return false; + } + + //Internal Tag was not valid. + try{ + if (this.internalCraftingComponentsTag == null){ + Utils.LOG_WARNING("Internal NBT data tag was null."); + return false; + } + } catch (final NullPointerException x){ + Utils.LOG_WARNING("Caught null NBT."); + } + + //Internal tag was valid. + this.saveNBTData(this.internalCraftingComponentsTag); + + + //Mark block for update + int x,y,z = 0; + x = this.getBaseMetaTileEntity().getXCoord(); + y = this.getBaseMetaTileEntity().getYCoord(); + z = this.getBaseMetaTileEntity().getZCoord(); + this.getBaseMetaTileEntity().getWorld().markBlockForUpdate(x, y, z); + + //Mark block dirty, let chunk know it's data has changed and it must be saved to disk. (Albeit slowly) + this.getBaseMetaTileEntity().markDirty();*//* + + return true; + } +}*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java new file mode 100644 index 0000000000..78adb094ed --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -0,0 +1,740 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; + +import java.util.function.Predicate; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +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.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.preloader.asm.AsmConfig; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_PowerSubStation; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_PowerSubStation; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_PowerSubStationController> { + + private static enum TopState { + MayBeTop, + Top, + NotTop + } + + protected long mAverageEuUsage = 0; + protected long mTotalEnergyAdded = 0; + protected long mTotalEnergyConsumed = 0; + protected long mTotalEnergyLost = 0; + protected boolean mIsOutputtingPower = false; + protected long mBatteryCapacity = 0; + + private final int ENERGY_TAX = 2; + + private int mCasing; + private int[] cellCount = new int[6]; + private TopState topState = TopState.MayBeTop; + private static IStructureDefinition<GregtechMetaTileEntity_PowerSubStationController> STRUCTURE_DEFINITION = null; + + public GregtechMetaTileEntity_PowerSubStationController(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_PowerSubStationController(final String aName) { + super(aName); + } + + @Override + public String getMachineType() { + return "Energy Buffer"; + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("[BUG] GUI does not work until structure is assembled correctly. (Do Not Report issue)") + .addInfo("Consumes " + this.ENERGY_TAX + "% of the average voltage of all energy type hatches") + .addInfo("Does not require maintenance") + .addInfo("Can be built with variable height between " + (CELL_HEIGHT_MIN + 2) + "-" + (CELL_HEIGHT_MAX + 2) + "") + .addInfo("Hatches can be placed nearly anywhere") + .addInfo("HV Energy/Dynamo Hatches are the lowest tier you can use") + .addInfo("Supports voltages >= UHV using MAX tier components.") + .addSeparator() + .addController("Bottom Center") + .addCasingInfo("Sub-Station External Casings", 10) + .addDynamoHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); + return tt; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(24)), + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER)}; + } + if (aSide == this.getBaseMetaTileEntity().getBackFacing()) { + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(24)), + mIsOutputtingPower ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[(int) this.getOutputTier()] : Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[(int) this.getInputTier()]}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(23))}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (mBatteryCapacity <= 0) return false; + if (!aBaseMetaTileEntity.isClientSide()) { + aBaseMetaTileEntity.openGUI(aPlayer); + } + return true; + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_PowerSubStation(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "Ergon Energy - Sub Station"); + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_PowerSubStation(aPlayerInventory, aBaseMetaTileEntity); + } + + private void checkMachineProblem(String msg, int xOff, int yOff, int zOff) { + final IGregTechTileEntity te = this.getBaseMetaTileEntity(); + final Block tBlock = te.getBlockOffset(xOff, yOff, zOff); + final byte tMeta = te.getMetaIDOffset(xOff, yOff, zOff); + String name = tBlock.getLocalizedName(); + String problem = msg + ": (" + xOff + ", " + yOff + ", " + zOff + ") " + name + ":" + tMeta; + checkMachineProblem(problem); + } + private void checkMachineProblem(String msg) { + if (!AsmConfig.disableAllLogging) { + Logger.INFO("Power Sub-Station problem: " + msg); + } + } + + public static int getCellTier(Block aBlock, int aMeta) { + if (aBlock == ModBlocks.blockCasings2Misc && aMeta == 7) { + return 4; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 4) { + return 5; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 5) { + return 6; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 6) { + return 7; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 7) { + return 8; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 8) { + return 9; + } else { + return -1; + } + } + + public static int getMetaFromTier(int tier) { + if (tier == 4) return 7; + if (tier >= 5 && tier <= 9) return tier - 1; + return 0; + } + + public static Block getBlockFromTier(int tier) { + switch (tier) { + case 4: return ModBlocks.blockCasings2Misc; + case 5: case 6: case 7: case 8: case 9: return ModBlocks.blockCasings3Misc; + default: return null; + } + } + + public static int getMaxHatchTier(int aCellTier) { + switch(aCellTier) { + case 9: + return CORE.GTNH ? 15 : 9; + default: + if (aCellTier < 4) { + return 0; + } + else { + return aCellTier; + } + } + } + + public static final int CELL_HEIGHT_MAX = 16; + public static final int CELL_HEIGHT_MIN = 2; + + @Override + public IStructureDefinition<GregtechMetaTileEntity_PowerSubStationController> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_PowerSubStationController>builder() + .addShape(mName + "bottom", transpose(new String[][]{ + {"CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"} + })) + .addShape(mName + "layer", transpose(new String[][]{ + {"CCCCC", "CIIIC", "CIIIC", "CIIIC", "CCCCC"} + })) + .addShape(mName + "mid", transpose(new String[][]{ + {"CCCCC", "CHHHC", "CHHHC", "CHHHC", "CCCCC"} + })) + .addShape(mName + "top", transpose(new String[][]{ + {"CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"} + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntity_PowerSubStationController::addPowerSubStationList, TAE.GTPP_INDEX(24), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 8 + ) + ) + ) + ) + .addElement( + 'I', + ofChain( + onlyIf( + x -> x.topState != TopState.NotTop, + onElementPass( + x -> x.topState = TopState.Top, + ofHatchAdderOptional(GregtechMetaTileEntity_PowerSubStationController::addPowerSubStationList, TAE.GTPP_INDEX(24), 1, ModBlocks.blockCasings2Misc, 8) + ) + ), + onlyIf( + x -> x.topState != TopState.Top, + onElementPass( + x -> x.topState = TopState.NotTop, + ofChain( + onElementPass( + x -> ++x.cellCount[0], + ofCell(4) + ), + onElementPass( + x -> ++x.cellCount[1], + ofCell(5) + ), + onElementPass( + x -> ++x.cellCount[2], + ofCell(6) + ), + onElementPass( + x -> ++x.cellCount[3], + ofCell(7) + ), + onElementPass( + x -> ++x.cellCount[4], + ofCell(8) + ), + onElementPass( + x -> ++x.cellCount[5], + ofCell(9) + ) + ) + ) + ) + ) + ) + .addElement('H', ofCell(4)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public static <T> IStructureElement<T> onlyIf(Predicate<? super T> predicate, IStructureElement<? super T> downstream) { + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + return predicate.test(t) && downstream.check(t, world, x, y, z); + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return predicate.test(t) && downstream.spawnHint(t, world, x, y, z, trigger); + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return predicate.test(t) && downstream.placeBlock(t, world, x, y, z, trigger); + } + }; + } + + public static <T> IStructureElement<T> ofCell(int aIndex) { + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + int tier = getCellTier(block, meta); + return aIndex == tier; + } + + public int getIndex(int size) { + if (size > 6) size = 6; + return size + 3; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, getBlockFromTier(getIndex(trigger.stackSize)), getMetaFromTier(getIndex(trigger.stackSize))); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return world.setBlock(x, y, z, getBlockFromTier(getIndex(trigger.stackSize)), getMetaFromTier(getIndex(trigger.stackSize)), 3); + } + }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + int layer = Math.min(stackSize.stackSize + 3, 18); + log("Layer: "+layer); + log("Building 0"); + buildPiece(mName + "bottom" , stackSize, hintsOnly, 2, 0, 0); + log("Built 0"); + for (int i = 1; i < layer - 1; i++) { + log("Building "+i); + buildPiece(mName + "mid", stackSize, hintsOnly, 2, i, 0); + log("Built "+i); + } + log("Building "+(layer - 1)); + buildPiece(mName + "top", stackSize, hintsOnly, 2, layer - 1, 0); + log("Built "+(layer - 1)); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + mEnergyHatches.clear(); + mDynamoHatches.clear(); + mTecTechEnergyHatches.clear(); + mTecTechDynamoHatches.clear(); + mAllEnergyHatches.clear(); + mAllDynamoHatches.clear(); + for (int i = 0; i < 6; i++) { + cellCount[i] = 0; + } + log("Checking 0"); + if (!checkPiece(mName + "bottom", 2, 0, 0)) { + log("Failed on Layer 0"); + return false; + } + log("Pass 0"); + int layer = 1; + topState = TopState.MayBeTop; + while (true) { + if (!checkPiece(mName + "layer", 2, layer, 0)) + return false; + layer ++; + if (topState == TopState.Top) + break; // top found, break out + topState = TopState.MayBeTop; + if (layer > 18) + return false; // too many layers + } + int level = 0; + for (int i = 0; i < 6; i++) { + if (cellCount[i] != 0) { + if (level == 0) { + level = i + 4; + } + else { + return false; + } + } + } + int tier = getMaxHatchTier(level); + long volSum = 0; + for (GT_MetaTileEntity_Hatch hatch : mAllDynamoHatches) { + if (hatch.mTier > tier || hatch.mTier < 3) { + return false; + } + volSum += (8L << (hatch.mTier * 2)); + } + for (GT_MetaTileEntity_Hatch hatch : mAllEnergyHatches) { + if (hatch.mTier > tier || hatch.mTier < 3) { + return false; + } + volSum += (8L << (hatch.mTier * 2)); + } + mBatteryCapacity = getCapacityFromCellTier(level) * cellCount[level - 4]; + if (mAllEnergyHatches.size() + mAllDynamoHatches.size() > 0) { + mAverageEuUsage = volSum / (mAllEnergyHatches.size() + mAllDynamoHatches.size()); + } + else mAverageEuUsage = 0; + fixAllMaintenanceIssue(); + return true; + } + + public final boolean addPowerSubStationList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + else if (LoadedMods.TecTech) { + if (isThisHatchMultiDynamo(aMetaTileEntity)) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (isThisHatchMultiEnergy(aMetaTileEntity)) { + return addToMachineList(aTileEntity, aBaseCasingIndex); + } + } + } + return false; + } + + // Define storage capacity of smallest cell tier (EV) and compute higher tiers from it + private static final long CELL_TIER_EV_CAPACITY = 100 * 1000 * 1000; // one lapotronic orb + private static final long CELL_TIER_MULTIPLIER = 4; // each tier's capacity is this many times the previous tier + + public static long getCapacityFromCellTier(int aOverallCellTier) { + // Use integer math instead of `Math.pow` to avoid range/precision errors + if (aOverallCellTier < 4) return 0; + aOverallCellTier -= 4; + long capacity = CELL_TIER_EV_CAPACITY; + while (aOverallCellTier > 0) { + capacity *= CELL_TIER_MULTIPLIER; + aOverallCellTier--; + } + return capacity; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_PowerSubStationController(this.mName); + } + + //mTotalEnergyAdded + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setLong("mAverageEuUsage", this.mAverageEuUsage); + + //Usage Stats + aNBT.setLong("mTotalEnergyAdded", this.mTotalEnergyAdded); + aNBT.setLong("mTotalEnergyLost", this.mTotalEnergyLost); + aNBT.setLong("mTotalEnergyConsumed", this.mTotalEnergyConsumed); + aNBT.setLong("mTotalRunTime", this.mTotalRunTime); + aNBT.setBoolean("mIsOutputtingPower", this.mIsOutputtingPower); + aNBT.setLong("mBatteryCapacity", this.mBatteryCapacity); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + + // Best not to get a long if the Tag Map is holding an int + if (aNBT.hasKey("mAverageEuUsage")) { + this.mAverageEuUsage = aNBT.getLong("mAverageEuUsage"); + } + + //Usage Stats + this.mTotalEnergyAdded = aNBT.getLong("mTotalEnergyAdded"); + this.mTotalEnergyLost = aNBT.getLong("mTotalEnergyLost"); + this.mTotalEnergyConsumed = aNBT.getLong("mTotalEnergyConsumed"); + this.mTotalRunTime = aNBT.getLong("mTotalRunTime"); + + this.mIsOutputtingPower = aNBT.getBoolean("mIsOutputtingPower"); + + this.mBatteryCapacity = aNBT.getLong("mBatteryCapacity"); + + super.loadNBTData(aNBT); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEUt = 0; + this.mEfficiencyIncrease = 10000; + this.fixAllMaintenanceIssue(); + return true; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + private void drawEnergyFromHatch(MetaTileEntity aHatch) { + if (!isValidMetaTileEntity(aHatch)) return; + + long stored = aHatch.getEUVar(); + long voltage = aHatch.maxEUInput() * aHatch.maxAmperesIn(); + + if (voltage > stored) { + return; + } + + if (this.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false)) { + aHatch.setEUVar((stored - voltage)); + this.mTotalEnergyAdded += voltage; + } + } + + private void addEnergyToHatch(MetaTileEntity aHatch) { + if (!isValidMetaTileEntity(aHatch)) return; + + long voltage = aHatch.maxEUOutput() * aHatch.maxAmperesOut(); + + if (aHatch.getEUVar() > aHatch.maxEUStore() - voltage) return; + + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(voltage, false)) { + aHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false); + this.mTotalEnergyConsumed+=voltage; + } + + } + + private long computeEnergyTax() { + float mTax = mAverageEuUsage * (ENERGY_TAX / 100f); + + // Increase tax up to 2x if machine is not fully repaired + mTax = mTax * (1f + (10000f - mEfficiency) / 10000f); + + return MathUtils.roundToClosestLong(mTax); + } + + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + this.fixAllMaintenanceIssue(); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + // First, decay overcharge (0.1% of stored energy plus 1000 EU per tick) + if (this.getEUVar() > this.mBatteryCapacity) { + long energy = (long) (this.getEUVar() * 0.999f) - 1000; + this.setEUVar(energy); + } + + // Pay Tax + long mDecrease = computeEnergyTax(); + this.mTotalEnergyLost += Math.min(mDecrease, this.getEUVar()); + this.setEUVar(Math.max(0, this.getEUVar() - mDecrease)); + + // Input Power + for (Object THatch : this.mDischargeHatches) { + GT_MetaTileEntity_Hatch_OutputBattery tHatch = (GT_MetaTileEntity_Hatch_OutputBattery) THatch; + drawEnergyFromHatch(tHatch); + } + for (GT_MetaTileEntity_Hatch tHatch : this.mAllEnergyHatches) { + drawEnergyFromHatch(tHatch); + } + + // Output Power + for (Object THatch : this.mChargeHatches) { + GT_MetaTileEntity_Hatch_InputBattery tHatch = (GT_MetaTileEntity_Hatch_InputBattery) THatch; + addEnergyToHatch(tHatch); + } + for (GT_MetaTileEntity_Hatch tHatch : this.mAllDynamoHatches) { + addEnergyToHatch(tHatch); + } + + return true; + + } + + @Override + public boolean drainEnergyInput(long aEU) { + // Not applicable to this machine + return true; + } + + @Override + public boolean addEnergyOutput(long aEU) { + // Not applicable to this machine + return true; + } + + @Override + public long maxEUStore() { + return mBatteryCapacity; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public String[] getExtraInfoData() { + String mode; + if (mIsOutputtingPower) { + mode = EnumChatFormatting.GOLD + "Output" + EnumChatFormatting.RESET; + } else { + mode = EnumChatFormatting.BLUE + "Input" + EnumChatFormatting.RESET; + } + + String storedEnergyText; + if (this.getEUVar() > this.mBatteryCapacity) { + storedEnergyText = EnumChatFormatting.RED + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } else { + storedEnergyText = EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } + + int errorCode = this.getBaseMetaTileEntity().getErrorDisplayID(); + boolean mMaint = (errorCode != 0); + + return new String[]{ + "Ergon Energy - District Sub-Station", + "Stored EU: " + storedEnergyText, + "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, + "Running Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.computeEnergyTax()) + EnumChatFormatting.RESET + " EU/t", + "Controller Mode: " + mode, + "Requires Maintenance: " + (!mMaint ? EnumChatFormatting.GREEN : EnumChatFormatting.RED)+ mMaint + EnumChatFormatting.RESET +" | Code: ["+(!mMaint ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + errorCode + EnumChatFormatting.RESET +"]", + "----------------------", + "Stats for Nerds", + "Total Input: " + EnumChatFormatting.BLUE + GT_Utility.formatNumbers(this.mTotalEnergyAdded) + EnumChatFormatting.RESET + " EU", + "Total Output: " + EnumChatFormatting.GOLD + GT_Utility.formatNumbers(this.mTotalEnergyConsumed) + EnumChatFormatting.RESET + " EU", + "Total Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.mTotalEnergyLost) + EnumChatFormatting.RESET + " EU", + }; + } + + @Override + public void explodeMultiblock() { + // TODO Auto-generated method stub + super.explodeMultiblock(); + } + + @Override + public void doExplosion(long aExplosionPower) { + // TODO Auto-generated method stub + super.doExplosion(aExplosionPower); + } + + @Override + public long getMaxInputVoltage() { + return 32768; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetInput() { + return !mIsOutputtingPower; + } + + @Override + public boolean isEnetOutput() { + return mIsOutputtingPower; + } + + @Override + public boolean isInputFacing(byte aSide) { + return (aSide == this.getBaseMetaTileEntity().getBackFacing() && !mIsOutputtingPower); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return (aSide == this.getBaseMetaTileEntity().getBackFacing() && mIsOutputtingPower); + } + + @Override + public long maxAmperesIn() { + return 32; + } + + @Override + public long maxAmperesOut() { + return 32; + } + + @Override + public long maxEUInput() { + return 32768; + } + + @Override + public long maxEUOutput() { + return 32768; + } + + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mIsOutputtingPower = Utils.invertBoolean(mIsOutputtingPower); + if (mIsOutputtingPower) { + PlayerUtils.messagePlayer(aPlayer, "Sub-Station is now outputting power from the controller."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Sub-Station is now inputting power into the controller."); + } + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java new file mode 100644 index 0000000000..5d8e9d468d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java @@ -0,0 +1,348 @@ +/* +package gtPlusPlus.xmod.gregtech.common.tileentities.misc; + +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_TieredMachineBlock; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_SolarTower; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class TileEntitySolarHeater extends GT_MetaTileEntity_TieredMachineBlock { + + public String mSolarTower; + public boolean mHasTower = false; + + private Integer mTX, mTY, mTZ; + private Byte mRequiredFacing; + + public TileEntitySolarHeater(final int aID, final String aName, final String aNameRegional, final int aTier, + final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public TileEntitySolarHeater(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + this.mDescription, + "Point me at a Solar Tower", + CORE.GT_Tooltip }; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + + 1]; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV) }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new TileEntitySolarHeater(this.mName, this.mTier, this.mDescription, this.mTextures, 0); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName(), + "Testificate" + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing >= 2; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mHasTower", mHasTower); + if (mHasTower && mTX != null && mTY != null && mTZ != null) { + aNBT.setInteger("mTX", mTX); + aNBT.setInteger("mTY", mTY); + aNBT.setInteger("mTZ", mTZ); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mHasTower = aNBT.getBoolean("mHasTower"); + if (this.mHasTower) { + if (aNBT.hasKey("mTX")) + this.mTX = aNBT.getInteger("mTX"); + if (aNBT.hasKey("mTY")) + this.mTY = aNBT.getInteger("mTY"); + if (aNBT.hasKey("mTZ")) + this.mTZ = aNBT.getInteger("mTZ"); + } + } + + @Override + public long getInputTier() { + return 0; + } + + @Override + public long getOutputTier() { + return 0; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + return false; + } + + @Override + public void onExplosion() { + + } + + public GregtechMetaTileEntity_SolarTower getSolarTower() { + if (this.mHasTower && this.mSolarTower != null && this.mSolarTower.length() > 0) { + BlockPos p = BlockPos.generateBlockPos(mSolarTower); + if (p != null) { + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntity(p.xPos, p.yPos, p.zPos); + if (tTileEntity != null && tTileEntity instanceof GregtechMetaTileEntity_SolarTower) { + return (GregtechMetaTileEntity_SolarTower) tTileEntity; + } + } + } + return null; + } + + + public boolean setSolarTower(BlockPos aTowerPos) { + if (!this.mHasTower && setSolarTowerInternal(aTowerPos.getUniqueIdentifier())) { + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntity(aTowerPos.xPos, aTowerPos.yPos, aTowerPos.zPos); + if (tTileEntity != null && tTileEntity instanceof GregtechMetaTileEntity_SolarTower) { + this.mTX = tTileEntity.getXCoord(); + this.mTY = (int) tTileEntity.getYCoord(); + this.mTZ = tTileEntity.getZCoord(); + this.mHasTower = true; + return true; + } + } + return false; + } + + private boolean clearSolarTower() { + if (mHasTower || mTX != null || mTY != null || mTZ != null || mRequiredFacing != null || this.mSolarTower != null) { + this.mTX = null; + this.mTY = null; + this.mTZ = null; + this.mRequiredFacing = null; + this.mSolarTower = null; + this.mHasTower = false; + return true; + } + return false; + } + + private final boolean setSolarTowerInternal(String aTowerPos) { + this.mSolarTower = aTowerPos; + return this.mSolarTower != null && this.mSolarTower.length() > 0; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + } + + @Override + public void onRemoval() { + super.onRemoval(); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide > 1; + } + + @Override + public boolean isInputFacing(byte aSide) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public void onFacingChange() { + super.onFacingChange(); + } + + @Override + public void doExplosion(long aExplosionPower) { + + } +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java new file mode 100644 index 0000000000..a3c11d486b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java @@ -0,0 +1,574 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.data.ArrayUtils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SuperChest; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_SuperChest; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT_MetaTileEntity_ConnectableCrate extends GT_MetaTileEntity_TieredMachineBlock { + + /*sides.put(getUp()); + sides.put(getDown()); + sides.put(getXPos()); + sides.put(getXNeg()); + sides.put(getZPos()); + sides.put(getZNeg());*/ + + public int mItemCount = 0; + public ItemStack mItemStack = null; + private final static double mStorageFactor = 2; + + //Meta Tile ID + public final static int mCrateID = 955; + + //Sides + public final static int SIDE_Up = 0; + public final static int SIDE_Down = 1; + public final static int SIDE_XPos = 2; + public final static int SIDE_XNeg = 3; + public final static int SIDE_ZPos = 4; + public final static int SIDE_ZNeg = 5; + public final static int[] SIDES = new int[] {SIDE_Up, SIDE_Down, SIDE_XPos, SIDE_XNeg, SIDE_ZPos, SIDE_ZNeg}; + + //Neighbour Cache + private GT_MetaTileEntity_ConnectableCrate[] mNeighbourCache = new GT_MetaTileEntity_ConnectableCrate[6]; + //Cached Crate Location + private BlockPos mCurrentPos = null; + //Master Crate Position + protected BlockPos mMasterCrateLocation = null; + //Is Master? + protected boolean mIsMaster = false; + //Is Connected? + protected boolean mIsConnected[] = new boolean[] {false, false, false, false, false, false}; + //How many are connected? + protected int mConnectedCount = 0; + //Map of connected locations + protected AutoMap<String> mConnectedCache = new AutoMap<String>(); + + + public GT_MetaTileEntity_ConnectableCrate(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, + "This Crate stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", new ITexture[0]); + } + + public GT_MetaTileEntity_ConnectableCrate(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + CORE.GT_Tooltip}; + } + + public boolean isSimpleMachine() { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return true; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ConnectableCrate(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public int getOppositeSide(int side) { + if (side == SIDE_Up) { + return SIDE_Down; + } + else if (side == SIDE_Down) { + return SIDE_Up; + } + else if (side == SIDE_XNeg) { + return SIDE_XPos; + } + else if (side == SIDE_XPos) { + return SIDE_XNeg; + } + else if (side == SIDE_ZNeg) { + return SIDE_ZPos; + } + else { + return SIDE_ZNeg; + } + } + + public boolean calculateOwnershipIfConnected() { + if (mCurrentPos == null) { + mCurrentPos = new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld()); + } + AutoMap<BlockPos> n = mCurrentPos.getSurroundingBlocks(); + int p = 0; + for (BlockPos i : n) { + if (i != null) { + if (doesSideContainCrate(p)) { + GT_MetaTileEntity_ConnectableCrate yu = getCrateAtBlockPos(i); + if (yu != null) { + mNeighbourCache[p] = yu; + } + } + } + p++; + } + + int e4 = 0; + if (mNeighbourCache.length > 0) { + for (GT_MetaTileEntity_ConnectableCrate e : mNeighbourCache) { + this.mConnectedCount = this.mConnectedCache.size(); + if (e != null) { + //First, we check if this Crate is a Master, if not, continue checking what it is. + if (this.mIsMaster) { + //So this other Crate is also a master? Which is more Powerful + if (e.mIsMaster) { + //This crate holds more connected, it becomes master now. + if (this.mConnectedCount > e.mConnectedCount) { + e.mIsMaster = false; + e.mMasterCrateLocation = this.mCurrentPos; + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + this.mConnectedCache = ArrayUtils.mergeTwoMaps(this.mConnectedCache, e.mConnectedCache); + continue; + } + //Other crate held more connected, it is now master. + else { + this.mIsMaster = false; + this.mMasterCrateLocation = e.mCurrentPos; + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + e.mConnectedCache = ArrayUtils.mergeTwoMaps(e.mConnectedCache, this.mConnectedCache); + //Best wipe our cache of connected blocks then, since they no longer hold value. + mConnectedCache.clear(); + continue; + } + } + //Other Crate was not a Master, but we are, time to inherit it into our connection hivemind. + else { + //It would appear this controller has another master, time to query it. + if (e.mMasterCrateLocation != null && !e.mMasterCrateLocation.getUniqueIdentifier().equalsIgnoreCase(this.mMasterCrateLocation.getUniqueIdentifier())) { + GT_MetaTileEntity_ConnectableCrate gM = getCrateAtBlockPos(e.mMasterCrateLocation); + if (gM != null) { + //Lets compare controller strengths + int gM_Owned = gM.mConnectedCount; + //We are stronger, let's inherit it. + if (this.mConnectedCount > gM_Owned) { + e.mIsMaster = false; + e.mMasterCrateLocation = this.mCurrentPos; + gM.mIsMaster = false; + gM.mMasterCrateLocation = this.mCurrentPos; + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + this.mConnectedCache = ArrayUtils.mergeTwoMaps(this.mConnectedCache, gM.mConnectedCache); + continue; + } + //We lost, time to submit to a new master crate + else { + this.mIsMaster = false; + this.mMasterCrateLocation = e.mMasterCrateLocation; + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + gM.mConnectedCache = ArrayUtils.mergeTwoMaps(gM.mConnectedCache, this.mConnectedCache); + //Best wipe our cache of connected blocks then, since they no longer hold value. + mConnectedCache.clear(); + continue; + } + } + else { + //Could not get the Tile Entity for the Other Master Crate.. Guess I can just ignore this case for now~ TODO + continue; + } + } + //Either the other crate has no known Master or it is already this crate. + else { + //The other crate has no master, time to inherit. + if (e.mMasterCrateLocation == null || (!e.mIsConnected[getOppositeSide(e4)])) { + e.mMasterCrateLocation = this.mCurrentPos; + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + mConnectedCache.put(e.mCurrentPos.getUniqueIdentifier()); + continue; + } + else { + //Do nothing, we own this Crate already :) + continue; + } + + + } + } + } + + //We are not a Storage Master Crate, into a brave new world we go + else { + //Best wipe our cache of connected blocks then, since they no longer hold value. + mConnectedCache.clear(); + + //Dang, the other crate is a master, time to get incorporated. + if (e.mIsMaster) { + this.mIsMaster = false; + this.mMasterCrateLocation = e.mCurrentPos; + this.mIsConnected[e4] = true; + if (!e.mIsConnected[e4]) { + e.mIsConnected[e4] = true; + } + if (e.mMasterCrateLocation == null) { + e.mMasterCrateLocation = e.mCurrentPos; + } + e.mConnectedCache.put(this.mCurrentPos.getUniqueIdentifier()); + continue; + } + //So the Crate we Checked is not a Master, so let's see if it knows where one is + else { + //So, this Crate we have found knows about a master + if (e.mMasterCrateLocation != null) { + GT_MetaTileEntity_ConnectableCrate gM = getCrateAtBlockPos(e.mMasterCrateLocation); + //Found the master crate + if (gM != null) { + this.mIsMaster = false; + this.mMasterCrateLocation = e.mMasterCrateLocation; + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + gM.mConnectedCache.put(this.mCurrentPos.getUniqueIdentifier()); + continue; + } + else { + //Could not get the Tile Entity for the Other Master Crate.. Guess I can just ignore this case for now~ TODO + continue; + } + } + //This crate has no master, not going to check if it's connected. + else { + this.mIsMaster = true; + this.mMasterCrateLocation = this.mCurrentPos; + e.mIsMaster = false; + e.mMasterCrateLocation = this.mCurrentPos; + if (!e.mIsConnected[getOppositeSide(e4)]) { + e.mIsConnected[getOppositeSide(e4)] = true; + } + if (!this.mIsConnected[e4]) { + this.mIsConnected[e4] = true; + } + mConnectedCache.put(e.mCurrentPos.getUniqueIdentifier()); + continue; + } + } + } + } + e4++; + } + return true; + } + else { + return false; + } + + + + + } + + public boolean doesSideContainCrate(int side) { + return checkSideForDataType(0, side); + } + + public boolean isCrateAtSideController(int side) { + return checkSideForDataType(1, side); + } + + private boolean checkSideForDataType(int aType, int aSide) { + BlockPos mPosToCheck = + aSide == SIDE_Up ? mCurrentPos.getUp() : + aSide == SIDE_Down ? mCurrentPos.getDown() : + aSide == SIDE_XPos ? mCurrentPos.getXPos() : + aSide == SIDE_XNeg ? mCurrentPos.getXNeg() : + aSide == SIDE_ZPos ? mCurrentPos.getZPos() : + mCurrentPos.getZNeg(); + GT_MetaTileEntity_ConnectableCrate g = getCrateAtBlockPos(mPosToCheck); + if (g != null) { + if (aType == 0) { + return true; + } + else { + if (g.mIsMaster) { + return true; + } + } + } + return false; + } + + public GT_MetaTileEntity_ConnectableCrate getCrateAtBlockPos(BlockPos pos) { + if (pos != null) { + Block b = pos.getBlockAtPos(); + int m = pos.getMetaAtPos(); + TileEntity t = pos.world.getTileEntity(pos.xPos, pos.yPos, pos.zPos); + if (b != null && t != null) { + if (b == GregTech_API.sBlockMachines && m == mCrateID) { + if (t instanceof IGregTechTileEntity) { + IGregTechTileEntity g = (IGregTechTileEntity) t; + final IMetaTileEntity aMetaTileEntity = g.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return null; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_ConnectableCrate) { + return ((GT_MetaTileEntity_ConnectableCrate) aMetaTileEntity); + + } + } + } + } + } + return null; + } + + + + + + + + + + + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + + + + + + + + + + + + + + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) { + if (this.getItemCount() <= 0) { + this.mItemStack = null; + this.mItemCount = 0; + } + + if (this.mItemStack == null && this.mInventory[0] != null) { + this.mItemStack = this.mInventory[0].copy(); + } + + if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() + && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { + this.mItemCount += this.mInventory[0].stackSize; + if (this.mItemCount > this.getMaxItemCount()) { + this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); + this.mItemCount = this.getMaxItemCount(); + } else { + this.mInventory[0] = null; + } + } + + if (this.mInventory[1] == null && this.mItemStack != null) { + this.mInventory[1] = this.mItemStack.copy(); + this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + this.mItemCount -= this.mInventory[1].stackSize; + } else if (this.mItemCount > 0 && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) + && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { + int tmp = Math.min(this.mItemCount, + this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); + this.mInventory[1].stackSize += tmp; + this.mItemCount -= tmp; + } + + if (this.mItemStack != null) { + this.mInventory[2] = this.mItemStack.copy(); + this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + } else { + this.mInventory[2] = null; + } + } + + } + + private int getItemCount() { + return this.mItemCount; + } + + public void setItemCount(int aCount) { + this.mItemCount = aCount; + } + + public int getProgresstime() { + return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) + + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); + } + + public int maxProgresstime() { + return this.getMaxItemCount(); + } + + public int getMaxItemCount() { + return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D); + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 1; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 0 && (this.mInventory[0] == null || GT_Utility.areStacksEqual(this.mInventory[0], aStack)); + } + + public String[] getInfoData() { + return this.mItemStack == null + ? new String[]{"Super Storage Chest", "Stored Items:", "No Items", Integer.toString(0), + Integer.toString(this.getMaxItemCount())} + : new String[]{"Super Storage Chest", "Stored Items:", this.mItemStack.getDisplayName(), + Integer.toString(this.mItemCount), Integer.toString(this.getMaxItemCount())}; + } + + public boolean isGivingInformation() { + return true; + } + + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", this.mItemCount); + if (this.mItemStack != null) { + aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); + } + aNBT.setString("mMasterCrateLocation", mMasterCrateLocation.getUniqueIdentifier()); + aNBT.setBoolean("mIsMaster", mIsMaster); + for (int y=0;y<this.mIsConnected.length;y++) { + aNBT.setBoolean("mIsConnected"+y, mIsConnected[y]); + } + aNBT.setInteger("mConnectedCount", mConnectedCount); + } + + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mItemCount")) { + this.mItemCount = aNBT.getInteger("mItemCount"); + } + if (aNBT.hasKey("mItemStack")) { + this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); + } + if (aNBT.hasKey("mMasterCrateLocation")) { + this.mMasterCrateLocation = BlockPos.generateBlockPos(aNBT.getString("mMasterCrateLocation")); + } + if (aNBT.hasKey("mIsMaster")) { + this.mIsMaster = aNBT.getBoolean("mIsMaster"); + } + + for (int y=0;y<this.mIsConnected.length;y++) { + if (aNBT.hasKey("mIsConnected"+y)) { + this.mIsConnected[y] = aNBT.getBoolean("mIsConnected"+y); + } + } + + if (aNBT.hasKey("mConnectedCount")) { + this.mConnectedCount = aNBT.getInteger("mConnectedCount"); + } + + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + return aBaseMetaTileEntity.getFrontFacing() == 0 && aSide == 4 + ? new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_AMAZON), + new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST)} + : (aSide == aBaseMetaTileEntity.getFrontFacing() + ? new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_AMAZON), + new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST)} + : new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_AMAZON)}); + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public void onExplosion() { + // TODO Auto-generated method stub + super.onExplosion(); + } + + @Override + public void onRemoval() { + // TODO Auto-generated method stub + super.onRemoval(); + } + + @Override + public void onMachineBlockUpdate() { + // TODO Auto-generated method stub + super.onMachineBlockUpdate(); + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java new file mode 100644 index 0000000000..951b4223dc --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredChest.java @@ -0,0 +1,199 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SuperChest; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_SuperChest; + +public class GT_MetaTileEntity_TieredChest extends GT_MetaTileEntity_TieredMachineBlock { + public int mItemCount = 0; + public ItemStack mItemStack = null; + private final static double mStorageFactor = (270000.0D/16); + + public GT_MetaTileEntity_TieredChest(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, + "This Chest stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", new ITexture[0]); + } + + public GT_MetaTileEntity_TieredChest(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + /*public GT_MetaTileEntity_TieredChest(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + }*/ + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + CORE.GT_Tooltip}; + } + + public boolean isSimpleMachine() { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return true; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TieredChest(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) { + if (this.getItemCount() <= 0) { + this.mItemStack = null; + this.mItemCount = 0; + } + + if (this.mItemStack == null && this.mInventory[0] != null) { + this.mItemStack = this.mInventory[0].copy(); + } + + if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() + && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { + this.mItemCount += this.mInventory[0].stackSize; + if (this.mItemCount > this.getMaxItemCount()) { + this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); + this.mItemCount = this.getMaxItemCount(); + } else { + this.mInventory[0] = null; + } + } + + if (this.mInventory[1] == null && this.mItemStack != null) { + this.mInventory[1] = this.mItemStack.copy(); + this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + this.mItemCount -= this.mInventory[1].stackSize; + } else if (this.mItemCount > 0 && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) + && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { + int tmp = Math.min(this.mItemCount, + this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); + this.mInventory[1].stackSize += tmp; + this.mItemCount -= tmp; + } + + if (this.mItemStack != null) { + this.mInventory[2] = this.mItemStack.copy(); + this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + } else { + this.mInventory[2] = null; + } + } + + } + + private int getItemCount() { + return this.mItemCount; + } + + public void setItemCount(int aCount) { + this.mItemCount = aCount; + } + + public int getProgresstime() { + return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) + + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); + } + + public int maxProgresstime() { + return this.getMaxItemCount(); + } + + public int getMaxItemCount() { + return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D); + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 1; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 0 && (this.mInventory[0] == null || GT_Utility.areStacksEqual(this.mInventory[0], aStack)); + } + + public String[] getInfoData() { + return this.mItemStack == null + ? new String[]{"Super Storage Chest", "Stored Items:", "No Items", Integer.toString(0), + Integer.toString(this.getMaxItemCount())} + : new String[]{"Super Storage Chest", "Stored Items:", this.mItemStack.getDisplayName(), + Integer.toString(this.mItemCount), Integer.toString(this.getMaxItemCount())}; + } + + public boolean isGivingInformation() { + return true; + } + + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", this.mItemCount); + if (this.mItemStack != null) { + aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); + } + + } + + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mItemCount")) { + this.mItemCount = aNBT.getInteger("mItemCount"); + } + + if (aNBT.hasKey("mItemStack")) { + this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); + } + + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { + return aBaseMetaTileEntity.getFrontFacing() == 0 && aSide == 4 + ? new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST)} + : (aSide == aBaseMetaTileEntity.getFrontFacing() + ? new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], + new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST)} + : new ITexture[]{BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]}); + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java new file mode 100644 index 0000000000..ef7fe829d4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java @@ -0,0 +1,160 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_RenderedTexture; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.preloader.asm.AsmConfig; + +public class GT_MetaTileEntity_TieredTank extends GT_MetaTileEntity_BasicTank { + + public GT_MetaTileEntity_TieredTank(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid"); + } + + public GT_MetaTileEntity_TieredTank(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid", aTextures); + } + + @Override + public String[] getDescription() { + String[] aTip; + + String aTankPortableness = "portable"; + + if (this.mFluid == null) { + aTip = new String[] {this.mDescription, "A "+aTankPortableness+" tank.", CORE.GT_Tooltip}; + } + else { + aTip = new String[] {this.mDescription, "A "+aTankPortableness+" tank.", "Fluid: "+mFluid.getLocalizedName()+" "+mFluid.amount+"L", CORE.GT_Tooltip}; + } + return aTip; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return aSide == 1 ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER)}; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public final byte getUpdateData() { + return 0x00; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public String[] getInfoData() { + + if (this.mFluid == null) { + return new String[]{ + GT_Values.VOLTAGE_NAMES[this.mTier]+" Fluid Tank", + "Stored Fluid:", + "No Fluid", + Integer.toString(0) + "L", + Integer.toString(this.getCapacity()) + "L"}; + } + return new String[]{ + GT_Values.VOLTAGE_NAMES[this.mTier]+" Fluid Tank", + "Stored Fluid:", + this.mFluid.getLocalizedName(), + Integer.toString(this.mFluid.amount) + "L", + Integer.toString(this.getCapacity()) + "L"}; + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TieredTank(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public int getCapacity() { + return (int) (Math.pow(2, this.mTier) * 32000); + } + + @Override + public int getTankPressure() { + return 100; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + //setVars(); + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { + if (mFluid != null){ + Logger.WARNING("Setting item fluid nbt"); + aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + if (aNBT.hasKey("mFluid")) { + Logger.WARNING("Set mFluid to NBT."); + } + } + } + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java new file mode 100644 index 0000000000..320e2175b0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java @@ -0,0 +1,421 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import static gregtech.api.enums.GT_Values.V; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_1by1; +import gregtech.api.gui.GT_GUIContainer_1by1; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { + + protected byte aCurrentOutputAmperage = 4; + + public GregtechMetaEnergyBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaEnergyBuffer(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, + "Defaults 4A In/Out", + "Change output Amperage with a screwdriver", + "Now Portable!", + CORE.GT_Tooltip}; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { + if (aSide != this.getBaseMetaTileEntity().getFrontFacing()) { + return true; + } + return super.allowCoverOnSide(aSide, aCover); + } + + /* + * MACHINE_STEEL_SIDE + */ + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + /*@Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[2][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_HEATPROOFCASING) }; + rTextures[1][i + 1] = new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_HEATPROOFCASING), + mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] + : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; + } + return rTextures; + }*/ + + /* + * @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { + * ITexture[][][] rTextures = new ITexture[5][17][]; for (byte i = -1; i < + * 16; i = (byte) (i + 1)) { ITexture[] tmp0 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)) }; rTextures[0][(i + 1)] = tmp0; ITexture[] tmp1 = { + * new GT_RenderedTexture( Textures.BlockIcons.MACHINE_STEEL_TOP) }; + * rTextures[1][(i + 1)] = tmp1; ITexture[] tmp2 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)), new + * GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; rTextures[2][(i + + * 1)] = tmp2; ITexture[] tmp4 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)), new + * GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; rTextures[3][(i + + * 1)] = tmp4; ITexture[] tmp5 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)), new GT_RenderedTexture( + * Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; rTextures[4][(i + 1)] = tmp5; + * } return rTextures; } + */ + + /*@Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1]; + }*/ + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaEnergyBuffer(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(final int aIndex) {return true;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isEnetOutput() {return true;} + @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return V[this.mTier]*2;} + @Override public long maxEUStore() {return V[this.mTier]*250000;} + + @Override + public long maxEUInput() { + return V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return V[this.mTier]; + } + + @Override + public long maxAmperesIn() { + return aCurrentOutputAmperage; + } + + @Override + public long maxAmperesOut() { + return aCurrentOutputAmperage; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return 0;} + @Override public int dechargerSlotCount() {return 0;} + @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} + @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); + if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { + long aEU = this.getBaseMetaTileEntity().getStoredEU(); + if (aEU > 0){ + aNBT.setLong("aStoredEU", aEU); + if (aNBT.hasKey("aStoredEU")) { + Logger.WARNING("Set aStoredEU to NBT."); + } + } + } + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + aCurrentOutputAmperage = aNBT.getByte("aCurrentOutputAmperage"); + if (aNBT.hasKey("aStoredEU")) { + this.setEUVar(aNBT.getLong("aStoredEU")); + } + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + Logger.WARNING("Right Click on MTE by Player"); + if (aBaseMetaTileEntity.isClientSide()) + { + return true; + //aBaseMetaTileEntity.openGUI(aPlayer); + } + + Logger.WARNING("MTE is Client-side"); + this.showEnergy(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + private void showEnergy(final World worldIn, final EntityPlayer playerIn){ + final long tempStorage = this.getBaseMetaTileEntity().getStoredEU(); + final double c = ((double) tempStorage / this.maxEUStore()) * 100; + final double roundOff = Math.round(c * 100.00) / 100.00; + PlayerUtils.messagePlayer(playerIn, "Energy: " + GT_Utility.formatNumbers(tempStorage) + " EU at "+V[this.mTier]+"v ("+roundOff+"%)"); + PlayerUtils.messagePlayer(playerIn, "Amperage: " + GT_Utility.formatNumbers(maxAmperesOut())+"A"); + + } + //Utils.LOG_WARNING("Begin Show Energy"); + /* + * + //Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" C: "+c); + Utils.LOG_INFO("getProgressTime: "+getProgresstime()); + Utils.LOG_INFO("maxProgressTime: "+maxProgresstime()); + Utils.LOG_INFO("getMinimumStoredEU: "+getMinimumStoredEU()); + Utils.LOG_INFO("maxEUStore: "+maxEUStore());*/ + /*final long d = (tempStorage * 100L) / maxEUStore(); + Utils.LOG_INFO("getProgresstime: "+tempStorage+" maxProgresstime: "+maxEUStore()+" D: "+d); + final double roundOff2 = Math.round(d * 100.00) / 100.00; + Utils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff2+"%)"); + Utils.LOG_WARNING("Making new instance of Guihandler"); + GuiHandler block = new GuiHandler(); + Utils.LOG_WARNING("Guihandler.toString(): "+block.toString()); + block.getClientGuiElement(1, playerIn, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);*/ + + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + String cur = GT_Utility.formatNumbers(this.getBaseMetaTileEntity().getStoredEU()); + String max = GT_Utility.formatNumbers(this.getBaseMetaTileEntity().getEUCapacity()); + + // Right-align current storage with maximum storage + String fmt = String.format("%%%ds", max.length()); + cur = String.format(fmt, cur); + + return new String[] { + cur+" EU stored", + max+" EU capacity"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { + } + + @Override + public String getInventoryName() { + return super.getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { + aNBT.setByte("aCurrentOutputAmperage", aCurrentOutputAmperage); + long aEU = this.getBaseMetaTileEntity().getStoredEU(); + if (aEU > 0){ + aNBT.setLong("aStoredEU", aEU); + if (aNBT.hasKey("aStoredEU")) { + Logger.WARNING("Set aStoredEU to NBT."); + } + } + } + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + byte aTest = (byte) (aCurrentOutputAmperage + 1); + if (aTest > 16 || aTest <= 0 ) { + aTest = 1; + } + aCurrentOutputAmperage = aTest; + PlayerUtils.messagePlayer(aPlayer, "Now handling "+aCurrentOutputAmperage+" Amps."); + } + + + + + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java new file mode 100644 index 0000000000..63042d4702 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java @@ -0,0 +1,62 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import net.minecraft.entity.player.InventoryPlayer; + +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 gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SafeBlock; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_SafeBlock; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase; + +public class GregtechMetaSafeBlock +extends GregtechMetaSafeBlockBase { + + public GregtechMetaSafeBlock(final int aID, final String aName, final String aNameRegional, final int aTier) { + super(aID, aName, aNameRegional, aTier, 28, "Protecting your items from sticky fingers."); + } + + public GregtechMetaSafeBlock(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + } + + public GregtechMetaSafeBlock(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + CORE.GT_Tooltip}; + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaSafeBlock(this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures); + } + + @Override + public ITexture getOverlayIcon() { + return new GT_RenderedTexture(Textures.BlockIcons.VOID); + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex < (this.mInventory.length - 1); + } + + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SafeBlock(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SafeBlock(aPlayerInventory, aBaseMetaTileEntity); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java new file mode 100644 index 0000000000..fb37f33055 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/creative/GT_MetaTileEntity_InfiniteItemHolder.java @@ -0,0 +1,105 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage.creative; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; + +public class GT_MetaTileEntity_InfiniteItemHolder extends GT_MetaTileEntity_TieredChest { + + public GT_MetaTileEntity_InfiniteItemHolder(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_InfiniteItemHolder(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[]{ + this.mDescription, + CORE.GT_Tooltip}; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.getWorld().isRemote) { + return false; + } + + if (!KeyboardUtils.isShiftKeyDown()) { + if (this.mItemStack == null) { + if (aPlayer.getHeldItem() != null) { + this.mItemStack = aPlayer.getHeldItem().copy(); + this.mItemCount = Short.MAX_VALUE; + aPlayer.setCurrentItemOrArmor(0, null); + PlayerUtils.messagePlayer(aPlayer, "Now holding "+this.mItemStack.getDisplayName()+" x"+Short.MAX_VALUE+"."); + return true; + } + } + else { + if (aPlayer.getHeldItem() == null) { + aPlayer.entityDropItem(mItemStack, 1); + this.mItemStack = null; + this.mItemCount = 0; + PlayerUtils.messagePlayer(aPlayer, "Emptying."); + return true; + } + } + } + + PlayerUtils.messagePlayer(aPlayer, "Currently holding: "+(this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing")+" x"+this.mItemCount); + return true; + //return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (mItemStack != null) { + setItemCount(0); + } + super.onPostTick(aBaseMetaTileEntity, aTimer); + } + + @Override + public void setItemCount(int aCount) { + super.setItemCount(Short.MAX_VALUE); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_InfiniteItemHolder(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + + + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java new file mode 100644 index 0000000000..43d5cffe82 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java @@ -0,0 +1,359 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.enums.*; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicHull_NonElectric; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class GT4Entity_Shelf extends GT_MetaTileEntity_BasicHull_NonElectric { + public byte mType = 0; + public String mOldDesc = ""; + public boolean mLocked = false; + protected byte mIndex = (byte) MathUtils.randInt(1, 3); + public static GT_RenderedTexture texBottom = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_bottom")); + public static GT_RenderedTexture texTop = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_top")); + public static GT_RenderedTexture texSide = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_side")); + public static GT_RenderedTexture texSideCabinet = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_side_cabinet")); + + public GT4Entity_Shelf(final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, 0, aDescription); + mOldDesc = aDescription; + } + + public GT4Entity_Shelf(final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 0, aDescription, aTextures); + mOldDesc = aDescription; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + public int getInvSize() { + return 1; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + if (this.getBaseMetaTileEntity().getOwnerName().equalsIgnoreCase(aPlayer.getDisplayName())) { + return true; + } + PlayerUtils.messagePlayer(aPlayer, "This container belongs to "+this.getBaseMetaTileEntity().getOwnerName()+"."); + return false; + } + + @Override + public boolean ownerControl() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(byte aSide) { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aTile, EntityPlayer aPlayer) { + if (aTile.isClientSide()) { + return true; + } + ItemStack tStack = aPlayer.inventory.getStackInSlot(aPlayer.inventory.currentItem); + if (tStack == null) { + if (KeyboardUtils.isCtrlKeyDown()) { + if (this.mInventory[0] != null) { + PlayerUtils.messagePlayer(aPlayer, "Contains "+this.mInventory[0].getDisplayName()+" x"+this.mInventory[0].stackSize+"."); + } + return false; + } + else { + if ((this.mInventory[0] != null) && (this.mInventory[0].stackSize > 0)) { + if (!this.mLocked) { + PlayerUtils.messagePlayer(aPlayer, "Removed "+this.mInventory[0].getDisplayName()+" x"+this.mInventory[0].stackSize+"."); + aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, this.mInventory[0]); + getBaseMetaTileEntity().setInventorySlotContents(0, null); + this.mType = 0; + return true; + } + else { + PlayerUtils.messagePlayer(aPlayer, "This container is locked. It belongs to "+aTile.getOwnerName()+"."); + return false; + } + } + return false; + } + } + else if (tStack != null && this.mInventory[0] == null) { + + if (KeyboardUtils.isCtrlKeyDown() || GT_MetaGenerated_Tool_01.class.isInstance(tStack.getItem())) { + return false; + } + PlayerUtils.messagePlayer(aPlayer, "Stored "+tStack.getDisplayName()+" x"+tStack.stackSize+"."); + aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, null); + getBaseMetaTileEntity().setInventorySlotContents(0, tStack); + this.mType = (byte) MathUtils.randInt(1, 3); + return true; + } + else { + if (this.mInventory[0] == null) { + this.mType = 0; + } + return super.onRightclick(aTile, aPlayer); + } + } + + @Override + public void onLeftclick(IGregTechTileEntity aTile,EntityPlayer aPlayer) { + if ((this.mInventory[0] != null) && (this.mInventory[0].stackSize > 0)) { + ItemStack tOutput = GT_Utility.copy(new Object[] { this.mInventory[0] }); + if (!aPlayer.isSneaking()) { + tOutput.stackSize = 1; + } + getBaseMetaTileEntity().decrStackSize(0, tOutput.stackSize); + EntityItem tEntity = new EntityItem(getBaseMetaTileEntity().getWorld(), + getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, + getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, + getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, tOutput); + tEntity.motionX = 0.0D; + tEntity.motionY = 0.0D; + tEntity.motionZ = 0.0D; + getBaseMetaTileEntity().getWorld().spawnEntityInWorld(tEntity); + if (this.mInventory[0] == null) { + this.mType = 0; + } + } + super.onLeftclick(aTile, aPlayer); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf(this.mName, this.mDescription, this.mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) {//mLocked + aNBT.setInteger("mType", this.mType); + aNBT.setBoolean("mLocked", this.mLocked); + aNBT.setByte("mIndex", this.mIndex); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mIndex")) { + this.mType = ((byte) aNBT.getInteger("mType")); + } + if (aNBT.hasKey("mIndex")) { + this.mLocked = (aNBT.getBoolean("mLocked")); + } + if (aNBT.hasKey("mIndex")) { + this.mIndex = aNBT.getByte("mIndex"); + } + } + + @Override + public void onValueUpdate(byte aValue) { + this.mType = aValue; + } + + @Override + public byte getUpdateData() { + return this.mType; + } + + @Override + public String[] getDescription() { + return new String[] { + mOldDesc, + "Decorative Item Storage", + "Right click to store/remove something", + "Ctrl + Rmb to check contents", + "Ctrl + Rmb with a screwdriver to lock", + }; + } + + @Override + public byte getTileEntityBaseType() { + return 0; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + //return aSide != getBaseMetaTileEntity().getFrontFacing(); + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity p0, int p1, byte p2, ItemStack p3) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity p0, int p1, byte p2, ItemStack p3) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[7][17][]; + for (byte i = -1; i < 16; i = (byte) (i + 1)) { + ITexture[] tmp0 = {this.getBottom((byte) 0)[0]}; + rTextures[0][(i + 1)] = tmp0; + ITexture[] tmp1 = { this.getTop((byte) 0)[0]}; + rTextures[1][(i + 1)] = tmp1; + ITexture[] tmp2 = { this.getSides((byte) 0)[0]}; + rTextures[2][(i + 1)] = tmp2; + ITexture[] tmp4 = {this.getSides((byte) 0)[0]}; + rTextures[3][(i + 1)] = tmp4; + ITexture[] tmp5 = {this.getSides((byte) 0)[0], getFront((byte) 0)[0]}; + rTextures[4][(i + 1)] = tmp5; + ITexture[] tmp6 = {this.getSides((byte) 0)[0], getFront((byte) 1)[0]}; + rTextures[5][(i + 1)] = tmp6; + ITexture[] tmp7 = {this.getSides((byte) 0)[0], getFront((byte) 2)[0]}; + rTextures[6][(i + 1)] = tmp7; + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, + final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, + final boolean aRedstone) { + + ITexture[] tmp = this.mTextures[(aSide >= 2) ? ((aSide != aFacing) ? 2 : ((byte) this.mType == 0 ? 4 : this.mType == 1 || this.mType == 2 ? 5 : this.mType == 3 ? 6 : 0)) : aSide][aColorIndex + 1]; + if (aSide != aFacing && tmp.length == 2) { + tmp = new ITexture[]{tmp[0]}; + } + return tmp; + } + + private static GT_RenderedTexture x1 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_FRONT); + private static GT_RenderedTexture x2 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_PAPER_FRONT); + private static GT_RenderedTexture x3 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_CANS_FRONT); + + public ITexture[] getFrontNormal() { + return new ITexture[]{x1}; + } + public ITexture[] getFrontActive() { + return new ITexture[]{x2}; + } + public ITexture[] getFrontAlternative() { + return new ITexture[]{x3}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return this.getFrontNormal(); + } + + public ITexture[] getBackActive(final byte aColor) { + return this.getBack(aColor); + } + + public ITexture[] getBottomActive(final byte aColor) { + return this.getBottom(aColor); + } + + public ITexture[] getTopActive(final byte aColor) { + return this.getTop(aColor); + } + + public ITexture[] getSidesActive(final byte aColor) { + return this.getSides(aColor); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + public ITexture[] getFront(byte aColour) { + if (aColour == 1) { + return getFrontActive(); + } + else if (aColour == 2) { + return getFrontAlternative(); + } + return getFrontNormal(); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (KeyboardUtils.isCtrlKeyDown()) { + if (!aPlayer.getDisplayName().equalsIgnoreCase(this.getBaseMetaTileEntity().getOwnerName())) { + PlayerUtils.messagePlayer(aPlayer, "Container is not yours to lock."); + } + else { + this.mLocked = Utils.invertBoolean(this.mLocked); + if (this.mLocked) { + PlayerUtils.messagePlayer(aPlayer, "Container is now locked."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Container is now unlocked."); + } + } + } + else { + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java new file mode 100644 index 0000000000..7dcb76a22e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java @@ -0,0 +1,39 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; + +import net.minecraft.entity.player.EntityPlayer; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT4Entity_Shelf_Compartment extends GT4Entity_Shelf { + + + public GT4Entity_Shelf_Compartment(final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, aDescription); + } + + public GT4Entity_Shelf_Compartment(String mName, String mDescriptionArray, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_Compartment(this.mName, this.mDescription, this.mTextures); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + this.mType = ((byte) ((this.mType + 1) % 16)); + PlayerUtils.messagePlayer(aPlayer, "Set type to "+this.mType+"."); + } + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{TexturesGtBlock.OVERLAYS_COMPARTMENT_FRONT[this.mType < 16 ? this.mType : 0]}; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java new file mode 100644 index 0000000000..2c7186a3ce --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java @@ -0,0 +1,45 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; + +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT4Entity_Shelf_Desk extends GT4Entity_Shelf { + + public GT4Entity_Shelf_Desk(final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, aDescription); + } + + public GT4Entity_Shelf_Desk(String mName, String mDescriptionArray, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_Desk(this.mName, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{TexturesGtBlock.OVERLAYS_CABINET_FRONT[this.mType < 16 ? this.mType : 0]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks)}; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java new file mode 100644 index 0000000000..93bb7d5bb9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java @@ -0,0 +1,55 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; + +import net.minecraft.entity.player.EntityPlayer; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; + +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +public class GT4Entity_Shelf_FileCabinet extends GT4Entity_Shelf { + + public GT4Entity_Shelf_FileCabinet(final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, aDescription); + } + + public GT4Entity_Shelf_FileCabinet(String mName, String mDescriptionArray, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) { + this.mType = ((byte) ((this.mType + 1) % 16)); + PlayerUtils.messagePlayer(aPlayer, "Set type to "+this.mType+"."); + } + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_FileCabinet(this.mName, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{TexturesGtBlock.OVERLAYS_CABINET_FRONT[this.mType < 16 ? this.mType : 0]}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{texSide}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{texBottom}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{texTop}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{texSide}; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java new file mode 100644 index 0000000000..606496501f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java @@ -0,0 +1,41 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; + +public class GT4Entity_Shelf_Iron extends GT4Entity_Shelf { + + public GT4Entity_Shelf_Iron(final int aID, final String aName, final String aNameRegional, final String aDescription) { + super(aID, aName, aNameRegional, aDescription); + } + + public GT4Entity_Shelf_Iron(String mName, String mDescriptionArray, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_Iron(this.mName, this.mDescription, this.mTextures); + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{texSideCabinet}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{texSide}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{texBottom}; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{texTop}; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{texSide}; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java new file mode 100644 index 0000000000..cc17f49d83 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java @@ -0,0 +1,266 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SuperChest; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_SuperChest; + +public class GT4Entity_Shelf_Large extends GT4Entity_Shelf { + + private final int mSize; + public int mItemCount; + public ItemStack mItemStack; + + + public GT4Entity_Shelf_Large(final int aID, final String aName, final String aNameRegional, final String aDescription, final int aSize) { + super(aID, aName, aNameRegional, aDescription); + this.mSize = aSize; + this.mItemCount = 0; + this.mItemStack = null; + } + + public GT4Entity_Shelf_Large(String mName, String mDescriptionArray, final int aSize, ITexture[][][] mTextures) { + super(mName, mDescriptionArray, mTextures); + this.mSize = aSize; + this.mItemCount = 0; + this.mItemStack = null; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT4Entity_Shelf_Large(this.mName, this.mDescription, mSize, this.mTextures); + } + + /*@Override + public int getInvSize() { + return (mSize > 0 && mSize < 255 ? mSize : 255); + }*/ + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean isDigitalChest() { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return true; + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + if (KeyboardUtils.isCtrlKeyDown()) { + String itemName = (this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing."); + String itemAmount = (this.mItemCount > 0 ? ""+this.mItemCount : "bad"); + String itemMessage = "This container currently holds "+(itemAmount.equalsIgnoreCase("bad") ? "nothing." : itemName+" x"+itemAmount+"."); + PlayerUtils.messagePlayer(aPlayer, itemMessage); + } + else { + aBaseMetaTileEntity.openGUI(aPlayer); + } + return true; + } + + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SuperChest(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SuperChest(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", this.mItemCount); + if (this.mItemStack != null) { + aNBT.setTag("mItemStack", (NBTBase) this.mItemStack.writeToNBT(new NBTTagCompound())); + } + super.saveNBTData(aNBT); + + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mItemCount")) { + this.mItemCount = aNBT.getInteger("mItemCount"); + } + if (aNBT.hasKey("mItemStack")) { + this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); + } + super.loadNBTData(aNBT); + } + + @Override + public void onOpenGUI() { + super.onOpenGUI(); + } + + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { + if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) { + try { + if (this.mInventory[0] != null) { + this.mType = (byte) this.mIndex; + } + else { + this.mType = 0; + } + + if (this.getItemCount() <= 0) { + this.mItemStack = null; + this.mItemCount = 0; + } + if (this.mItemStack == null && this.mInventory[0] != null) { + this.mItemStack = this.mInventory[0].copy(); + } + if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() + && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { + this.mItemCount += this.mInventory[0].stackSize; + if (this.mItemCount > this.getMaxItemCount()) { + this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); + this.mItemCount = this.getMaxItemCount(); + } else { + this.mInventory[0] = null; + } + } + if (this.mInventory[1] == null && this.mItemStack != null) { + this.mInventory[1] = this.mItemStack.copy(); + this.mInventory[1].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + this.mItemCount -= this.mInventory[1].stackSize; + } else if (this.mItemCount > 0 && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) + && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { + final int tmp = Math.min(this.mItemCount, + this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); + final ItemStack itemStack = this.mInventory[1]; + itemStack.stackSize += tmp; + this.mItemCount -= tmp; + } + if (this.mItemStack != null) { + this.mInventory[2] = this.mItemStack.copy(); + this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); + } else { + this.mInventory[2] = null; + } + } + catch (Throwable t) { + if (t instanceof ArrayIndexOutOfBoundsException) { + + } + } + } + } + + private int getItemCount() { + return this.mItemCount; + } + + public void setItemCount(final int aCount) { + this.mItemCount = aCount; + } + + public int getProgresstime() { + try { + return this.mItemCount + ((this.mInventory[0] == null) ? 0 : this.mInventory[0].stackSize) + + ((this.mInventory[1] == null) ? 0 : this.mInventory[1].stackSize); + } + catch (Throwable t) { + return 0; + } + } + + public int maxProgresstime() { + return this.getMaxItemCount(); + } + + public int getMaxItemCount() { + return this.mSize; + } + + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return aIndex == 1; + } + + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + return aIndex == 0 && ((this.mInventory[0] == null && this.mItemStack == null) || GT_Utility.areStacksEqual(this.mInventory[0], aStack) || (this.mItemStack != null && GT_Utility.areStacksEqual(this.mItemStack, aStack))); + } + + public String[] getInfoData() { + if (this.mItemStack == null) { + return new String[]{ + this.getLocalName(), "No Items Stored", "Free Space: "+Integer.toString(this.getMaxItemCount())}; + } + return new String[]{ + this.getLocalName(), + "Storing: "+this.mItemStack.getDisplayName()+" x"+Integer.toString(this.mItemCount), + "Space Remaining: "+Integer.toString(this.getMaxItemCount()-this.getItemCount())+"/"+Integer.toString(this.getMaxItemCount())}; + } + + @Override + public String[] getDescription() { + String[] mSuper = super.getDescription(); + String[] desc = new String[mSuper.length+1]; + for (int i=0;i>mSuper.length;i++) { + desc[i] = mSuper[i]; + } + desc[desc.length-1] = "Control + Rmb block to check contents"; + return desc; + } + + @Override + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { + Logger.INFO("1:"+aIndex); + if (aIndex == 2) { + if (ItemStack.areItemStacksEqual(aStack, mItemStack)) { + return true; + } + else { + if (mItemStack == null) { + return true; + } + return false; + } + } + return super.isItemValidForSlot(aIndex, aStack); + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + Logger.INFO("2:"+aIndex); + if (aIndex == 0) { + if (ItemStack.areItemStacksEqual(aStack, mItemStack)) { + return true; + } + else { + if (mItemStack == null) { + return true; + } + return false; + } + } + return super.canInsertItem(aIndex, aStack, aSide); + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java new file mode 100644 index 0000000000..27f118e363 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_AngleGrinder.java @@ -0,0 +1,199 @@ +package gtPlusPlus.xmod.gregtech.common.tools; + +import java.util.Arrays; +import java.util.List; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures.ItemIcons; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.common.items.behaviors.Behaviour_None; +import gregtech.common.tools.GT_Tool; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; +import gtPlusPlus.xmod.gregtech.common.items.behaviours.Behaviour_Choocher; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.event.world.BlockEvent; + +public class TOOL_Gregtech_AngleGrinder +extends GT_Tool { + + public static final List<String> mEffectiveList = Arrays.asList(new String[]{EntityIronGolem.class.getName(), "EntityTowerGuardian"}); + + + @Override + public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + String tName = aEntity.getClass().getName(); + tName = tName.substring(tName.lastIndexOf(".") + 1); + return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; + } + + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 8.0F; + } + + @Override + public float getSpeedMultiplier() { + return 2F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.8F; + } + + @Override + public String getCraftingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(1)); + } + + @Override + public String getEntityHitSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(2)); + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public boolean canBlock() { + return false; + } + + public boolean isWrench(){ + return false; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isWeapon() { + return true; + } + + @Override + public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { + final String tTool = aBlock.getHarvestTool(aMetaData); + return (tTool != null) && (tTool.equals("sword") || tTool.equals("file")); + } + + + @Override + public int convertBlockDrops(final List<ItemStack> aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { + int rConversions = 0; + /*GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{new ItemStack(aBlock, 1, aMetaData)}); + if ((tRecipe == null) || (aBlock.hasTileEntity(aMetaData))) { + for (final ItemStack tDrop : aDrops) { + tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{GT_Utility.copyAmount(1L, new Object[]{tDrop})}); + if (tRecipe != null) { + final ItemStack tHammeringOutput = tRecipe.getOutput(0); + if (tHammeringOutput != null) { + rConversions += tDrop.stackSize; + tDrop.stackSize *= tHammeringOutput.stackSize; + tHammeringOutput.stackSize = tDrop.stackSize; + GT_Utility.setStack(tDrop, tHammeringOutput); + } + } + } + } else { + aDrops.clear(); + aDrops.add(tRecipe.getOutput(0)); + rConversions++; + }*/ + return rConversions; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead + ? TexturesGtTools.ANGLE_GRINDER + : ItemIcons.POWER_UNIT_HV); + } + + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return aIsToolHead + ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa + : Materials.TungstenSteel.mRGBa; + } + + + + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been Ground out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); + } + + @Override + public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { + aItem.addItemBehavior(aID, new Behaviour_None()); + } + + @Override + public boolean isGrafter() { + return false; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Base.java new file mode 100644 index 0000000000..97f9a43187 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Base.java @@ -0,0 +1,180 @@ +package gtPlusPlus.xmod.gregtech.common.tools; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EntityDamageSource; +import net.minecraft.util.IChatComponent; + +import gregtech.api.GregTech_API; +import gregtech.api.damagesources.GT_DamageSources; + +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_ToolStats; +import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; +import net.minecraftforge.event.world.BlockEvent; + +public abstract class TOOL_Gregtech_Base +implements Interface_ToolStats { + public static final Enchantment[] FORTUNE_ENCHANTMENT = {Enchantment.fortune}; + public static final Enchantment[] LOOTING_ENCHANTMENT = {Enchantment.looting}; + public static final Enchantment[] ZERO_ENCHANTMENTS = new Enchantment[0]; + public static final int[] ZERO_ENCHANTMENT_LEVELS = new int[0]; + + @Override + public int getToolDamagePerBlockBreak() { + return 100; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 800; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 200; + } + + @Override + public float getSpeedMultiplier() { + return 1.0F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.0F; + } + + @Override + public int getHurtResistanceTime(final int aOriginalHurtResistance, final Entity aEntity) { + return aOriginalHurtResistance; + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public String getCraftingSound() { + return null; + } + + @Override + public String getEntityHitSound() { + return null; + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public boolean canBlock() { + return false; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isWrench() { + return false; + } + + @Override + public boolean isWeapon() { + return false; + } + + @Override + public boolean isRangedWeapon() { + return false; + } + + @Override + public boolean isMiningTool() { + return true; + } + + public boolean isChainsaw(){ + return false; + } + + + @Override + public boolean isGrafter(){ + return false; + } + + + @Override + public DamageSource getDamageSource(final EntityLivingBase aPlayer, final Entity aEntity) { + return GT_DamageSources.getCombatDamage((aPlayer instanceof EntityPlayer) ? "player" : "mob", aPlayer, (aEntity instanceof EntityLivingBase) ? this.getDeathMessage(aPlayer, (EntityLivingBase) aEntity) : null); + } + + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new EntityDamageSource((aPlayer instanceof EntityPlayer) ? "player" : "mob", aPlayer).func_151519_b(aEntity); + } + + @Override + public int convertBlockDrops(final List<ItemStack> aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { + return 0; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + @Override + public Enchantment[] getEnchantments(final ItemStack aStack) { + return ZERO_ENCHANTMENTS; + } + + @Override + public int[] getEnchantmentLevels(final ItemStack aStack) { + return ZERO_ENCHANTMENT_LEVELS; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + aPlayer.triggerAchievement(AchievementList.openInventory); + aPlayer.triggerAchievement(AchievementList.mineWood); + aPlayer.triggerAchievement(AchievementList.buildWorkBench); + } + + @Override + public void onStatsAddedToTool(final Gregtech_MetaTool aItem, final int aID) { + } + + @Override + public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + return aOriginalDamage; + } + + @Override + public float getMagicDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + return aOriginalDamage; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Choocher.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Choocher.java new file mode 100644 index 0000000000..1fd1e8241a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_Choocher.java @@ -0,0 +1,196 @@ +package gtPlusPlus.xmod.gregtech.common.tools; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.tools.GT_Tool; + +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; +import gtPlusPlus.xmod.gregtech.common.items.behaviours.Behaviour_Choocher; +import net.minecraftforge.event.world.BlockEvent; + +public class TOOL_Gregtech_Choocher +extends GT_Tool { + + public static final List<String> mEffectiveList = Arrays.asList(new String[]{EntityIronGolem.class.getName(), "EntityTowerGuardian"}); + + + @Override + public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + String tName = aEntity.getClass().getName(); + tName = tName.substring(tName.lastIndexOf(".") + 1); + return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; + } + + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 4.0F; + } + + @Override + public float getSpeedMultiplier() { + return 0.85F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.2F; + } + + @Override + public String getCraftingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(1)); + } + + @Override + public String getEntityHitSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(2)); + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public boolean canBlock() { + return true; + } + + public boolean isWrench(){ + return true; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isWeapon() { + return true; + } + + @Override + public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { + final String tTool = aBlock.getHarvestTool(aMetaData); + return ((tTool != null) && ((tTool.equals("sword")) || (tTool.equals("wrench")) || (tTool.equals("hammer")) || (tTool.equals("pickaxe")))) || (aBlock.getMaterial() == Material.rock) || (aBlock.getMaterial() == Material.glass) || (aBlock.getMaterial() == Material.piston) || (aBlock == Blocks.hopper) || (aBlock == Blocks.dispenser) || (aBlock == Blocks.dropper) || (aBlock.getMaterial() == Material.ice) || (aBlock.getMaterial() == Material.packedIce) || (GT_Recipe.GT_Recipe_Map.sHammerRecipes.containsInput(new ItemStack(aBlock, 1, aMetaData))) || (aBlock.getMaterial() == Material.sand) || (aBlock.getMaterial() == Material.grass) || (aBlock.getMaterial() == Material.ground) || (aBlock.getMaterial() == Material.snow) || (aBlock.getMaterial() == Material.clay) || (aBlock.getMaterial() == Material.leaves) || (aBlock.getMaterial() == Material.vine) || (aBlock.getMaterial() == Material.wood) || (aBlock.getMaterial() == Material.cactus) || (aBlock.getMaterial() == Material.circuits) || (aBlock.getMaterial() == Material.gourd) || (aBlock.getMaterial() == Material.web) || (aBlock.getMaterial() == Material.cloth) || (aBlock.getMaterial() == Material.carpet) || (aBlock.getMaterial() == Material.plants) || (aBlock.getMaterial() == Material.cake) || (aBlock.getMaterial() == Material.tnt) || (aBlock.getMaterial() == Material.sponge); + } + + @Override + public int convertBlockDrops(final List<ItemStack> aDrops, final ItemStack aStack, final EntityPlayer aPlayer, final Block aBlock, final int aX, final int aY, final int aZ, final byte aMetaData, final int aFortune, final boolean aSilkTouch, final BlockEvent.HarvestDropsEvent aEvent) { + int rConversions = 0; + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{new ItemStack(aBlock, 1, aMetaData)}); + if ((tRecipe == null) || (aBlock.hasTileEntity(aMetaData))) { + for (final ItemStack tDrop : aDrops) { + tRecipe = GT_Recipe.GT_Recipe_Map.sHammerRecipes.findRecipe(null, true, 2147483647L, null, new ItemStack[]{GT_Utility.copyAmount(1L, new Object[]{tDrop})}); + if (tRecipe != null) { + final ItemStack tHammeringOutput = tRecipe.getOutput(0); + if (tHammeringOutput != null) { + rConversions += tDrop.stackSize; + tDrop.stackSize *= tHammeringOutput.stackSize; + tHammeringOutput.stackSize = tDrop.stackSize; + GT_Utility.setStack(tDrop, tHammeringOutput); + } + } + } + } else { + aDrops.clear(); + aDrops.add(tRecipe.getOutput(0)); + rConversions++; + } + return rConversions; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + @Override + public IIconContainer getIcon(final boolean aIsToolHead, final ItemStack aStack) { + //Utils.LOG_INFO("Texture: "+TexturesGtTools.SKOOKUM_CHOOCHER.getTextureFile()); + return TexturesGtTools.SKOOKUM_CHOOCHER; + } + + @Override + public short[] getRGBa(final boolean aIsToolHead, final ItemStack aStack) { + return GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been Choochered by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); + } + + @Override + public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { + aItem.addItemBehavior(aID, new Behaviour_Choocher()); + } + + @Override + public boolean isGrafter() { + return false; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricButcherKnife.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricButcherKnife.java new file mode 100644 index 0000000000..7aa7529817 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricButcherKnife.java @@ -0,0 +1,192 @@ +package gtPlusPlus.xmod.gregtech.common.tools; + +import java.util.Arrays; +import java.util.List; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures.ItemIcons; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.common.items.behaviors.Behaviour_None; +import gregtech.common.tools.GT_Tool; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.event.world.BlockEvent; + +public class TOOL_Gregtech_ElectricButcherKnife +extends GT_Tool { + + public static final List<String> mEffectiveList = Arrays.asList(new String[]{EntityIronGolem.class.getName(), "EntityTowerGuardian"}); + + + @Override + public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + String tName = aEntity.getClass().getName(); + tName = tName.substring(tName.lastIndexOf(".") + 1); + return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; + } + + @Override + public int getToolDamagePerBlockBreak() { + return 100; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 100; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 200; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 8.0F; + } + + @Override + public float getSpeedMultiplier() { + return 2F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.8F; + } + + @Override + public String getCraftingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(1)); + } + + @Override + public String getEntityHitSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(2)); + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public boolean canBlock() { + return false; + } + + public boolean isWrench(){ + return false; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { + final String tTool = aBlock.getHarvestTool(aMetaData); + return (tTool != null) && (tTool.equals("sword") || tTool.equals("knife")); + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead + ? TexturesGtTools.ELECTRIC_BUTCHER_KNIFE + : ItemIcons.POWER_UNIT_HV); + } + + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return aIsToolHead + ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa + : Materials.RedSteel.mRGBa; + } + + + + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been Sliced out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); + } + + @Override + public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { + aItem.addItemBehavior(aID, new Behaviour_None()); + } + + @Override + public boolean isGrafter() { + return false; + } + + @Override + public int getHurtResistanceTime(int aOriginalHurtResistance, Entity aEntity) { + return aOriginalHurtResistance * 2; + } + + @Override + public boolean isWeapon() { + return true; + } + + @Override + public boolean isMiningTool() { + return false; + } + + @Override + public Enchantment[] getEnchantments(ItemStack aStack) { + return LOOTING_ENCHANTMENT; + } + + @Override + public int[] getEnchantmentLevels(ItemStack aStack) { + return new int[]{(4 + GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mToolQuality) / 2}; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricLighter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricLighter.java new file mode 100644 index 0000000000..395a7c42cb --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricLighter.java @@ -0,0 +1,166 @@ +package gtPlusPlus.xmod.gregtech.common.tools; + +import java.util.Arrays; +import java.util.List; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures.ItemIcons; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.common.tools.GT_Tool; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; +import gtPlusPlus.xmod.gregtech.common.items.behaviours.Behaviour_Electric_Lighter; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; + +public class TOOL_Gregtech_ElectricLighter +extends GT_Tool { + + public static final List<String> mEffectiveList = Arrays.asList(new String[]{EntityIronGolem.class.getName(), "EntityTowerGuardian"}); + + + @Override + public float getNormalDamageAgainstEntity(final float aOriginalDamage, final Entity aEntity, final ItemStack aStack, final EntityPlayer aPlayer) { + String tName = aEntity.getClass().getName(); + tName = tName.substring(tName.lastIndexOf(".") + 1); + return (mEffectiveList.contains(tName)) || (tName.contains("Golem")) ? aOriginalDamage * 2.0F : aOriginalDamage; + } + + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 8.0F; + } + + @Override + public float getSpeedMultiplier() { + return 2F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.8F; + } + + @Override + public String getCraftingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(1)); + } + + @Override + public String getEntityHitSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(2)); + } + + @Override + public String getBreakingSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(0)); + } + + @Override + public String getMiningSound() { + return null; + } + + @Override + public boolean canBlock() { + return false; + } + + public boolean isWrench(){ + return false; + } + + @Override + public boolean isCrowbar() { + return false; + } + + @Override + public boolean isWeapon() { + return true; + } + + @Override + public boolean isMinableBlock(final Block aBlock, final byte aMetaData) { + return false; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead + ? TexturesGtTools.ELECTRIC_LIGHTER + : ItemIcons.POWER_UNIT_HV); + } + + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return !aIsToolHead + ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa + : Materials.Silver.mRGBa; + } + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been burnt out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); + } + + @Override + public void onStatsAddedToTool(final GT_MetaGenerated_Tool aItem, final int aID) { + aItem.addItemBehavior(aID, new Behaviour_Electric_Lighter()); + } + + @Override + public boolean isGrafter() { + return false; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java new file mode 100644 index 0000000000..2277ce339f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tools/TOOL_Gregtech_ElectricSnips.java @@ -0,0 +1,97 @@ +package gtPlusPlus.xmod.gregtech.common.tools; + +import gregtech.GT_Mod; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures.ItemIcons; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.common.tools.GT_Tool_WireCutter; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; + +public class TOOL_Gregtech_ElectricSnips +extends GT_Tool_WireCutter { + + + @Override + public int getToolDamagePerBlockBreak() { + return 50; + } + + @Override + public int getToolDamagePerDropConversion() { + return 100; + } + + @Override + public int getToolDamagePerContainerCraft() { + return 400; + } + + @Override + public int getToolDamagePerEntityAttack() { + return 100; + } + + @Override + public int getBaseQuality() { + return 0; + } + + @Override + public float getBaseDamage() { + return 4.0F; + } + + @Override + public float getSpeedMultiplier() { + return 1F; + } + + @Override + public float getMaxDurabilityMultiplier() { + return 1.4F; + } + + @Override + public ItemStack getBrokenItem(final ItemStack aStack) { + return null; + } + + public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) { + return (IIconContainer) (aIsToolHead + ? TexturesGtTools.ELECTRIC_SNIPS + : ItemIcons.POWER_UNIT_MV); + } + + public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) { + return aIsToolHead + ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa + : Materials.TungstenSteel.mRGBa; + } + + + + @Override + public void onToolCrafted(final ItemStack aStack, final EntityPlayer aPlayer) { + super.onToolCrafted(aStack, aPlayer); + aPlayer.triggerAchievement(AchievementList.buildSword); + try { + GT_Mod.achievements.issueAchievement(aPlayer, "tools"); + GT_Mod.achievements.issueAchievement(aPlayer, "unitool"); + } catch (final Exception e) { + } + } + + @Override + public IChatComponent getDeathMessage(final EntityLivingBase aPlayer, final EntityLivingBase aEntity) { + return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been Snipped out of existence by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java new file mode 100644 index 0000000000..4c8707e5e8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java @@ -0,0 +1,290 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.lang.reflect.*; +import java.util.HashMap; +import java.util.Map; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class GT_Material_Loader { + + private volatile static GT_Material_Loader instance = new GT_Material_Loader(); + private volatile Object mProxyObject; + private static AutoMap<Materials> mMaterials = new AutoMap<Materials>(); + private static volatile boolean mHasRun = false; + + public synchronized GT_Material_Loader getInstance(){ + return GT_Material_Loader.instance; + } + + public synchronized boolean getRunAbility(){ + return (mHasRun ? false : true); + } + public synchronized void setRunAbility(boolean b){ + mHasRun = Utils.invertBoolean(b); + } + + public GT_Material_Loader() { + if (getRunAbility()){ + //Set Singleton Instance + instance = this; + + //Try Reflectively add ourselves to the GT loader. + Class mInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && mInterface != null){ + + //Make this class Dynamically implement IMaterialHandler + if (mProxyObject == null){ + mProxyObject = Proxy.newProxyInstance( + mInterface.getClassLoader(), new Class[] { mInterface }, + new MaterialHandler(getInstance())); + } + + if (ReflectionUtils.invoke(Materials.class, "add", new Class[]{ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler")}, new Object[]{mProxyObject})){ + Logger.REFLECTION("Successfully invoked add, on the proxied object implementing IMaterialHandler."); + + + Logger.REFLECTION("Examining Proxy to ensure it implements the correct Interface."); + Class[] i = mProxyObject.getClass().getInterfaces(); + for (int r=0;r<i.length;r++){ + Logger.REFLECTION("Contains "+i[r].getCanonicalName()+"."); + if (i[r] == mInterface){ + Logger.REFLECTION("Found gregtech.api.interfaces.IMaterialHandler. This Proxy is valid."); + } + } + } + else { + Logger.REFLECTION("Failed to invoke add, on the proxied object implementing IMaterialHandler."); + } + } + //Materials.add(this); + + //Stupid shit running twice, I don't think so. + setRunAbility(false); + } + } + + public void onMaterialsInit() { + Logger.DEBUG_MATERIALS("onMaterialsInit()"); + } + + public void onComponentInit() { + Logger.DEBUG_MATERIALS("onComponentInit()"); + if (!mMaterials.isEmpty()){ + Logger.DEBUG_MATERIALS("Found "+mMaterials.size()+" materials to re-enable."); + for (Materials M : mMaterials.values()){ + String name = MaterialUtils.getMaterialName(M); + Logger.DEBUG_MATERIALS("Trying to enable "+name+"."); + boolean success = tryEnableAllComponentsForMaterial(M); + if (success){ + Logger.DEBUG_MATERIALS("Success! Enabled "+name+"."); + } + else { + Logger.DEBUG_MATERIALS("Failure... Did not enable "+name+"."); + } + } + } + } + + public void onComponentIteration(Materials aMaterial) { + Logger.DEBUG_MATERIALS("onComponentIteration()"); + } + + public synchronized boolean enableMaterial(Materials m){ + if (mMaterials.setValue(m)){ + Logger.DEBUG_MATERIALS("Added "+MaterialUtils.getMaterialName(m)+" to internal Map."); + return true; + } + Logger.DEBUG_MATERIALS("Failed to add "+MaterialUtils.getMaterialName(m)+" to internal Map."); + return false; + } + + + + + + + /* + * Static internal handler methods + */ + + private static synchronized boolean tryEnableMaterial(Materials mMaterial){ + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + return false; + } + + boolean value = ReflectionUtils.setField(mMaterial, "mHasParentMod", true); + if (value){ + Logger.DEBUG_MATERIALS("Set mHasParentMod true for "+mMaterial.mDefaultLocalName); + } + else { + Logger.DEBUG_MATERIALS("Failed to set mHasParentMod true for "+mMaterial.mDefaultLocalName); + } + return value; + } + + private static synchronized boolean tryEnableMaterialPart(OrePrefixes prefix, Materials mMaterial){ + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + return false; + } + try { + Method enableComponent = ReflectionUtils.getClass("gregtech.api.enums.OrePrefixes").getDeclaredMethod("enableComponent", Materials.class); + enableComponent.invoke(prefix, mMaterial); + Logger.DEBUG_MATERIALS("Enabled "+prefix.name()+" for "+mMaterial.mDefaultLocalName+"."); + return true; + } + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException error) { + Logger.DEBUG_MATERIALS("Failed to enabled "+prefix.name()+" for "+mMaterial.mDefaultLocalName+". Caught "+error.getCause().toString()+"."); + error.printStackTrace(); + } + Logger.DEBUG_MATERIALS("Did not enable "+prefix.name()+" for "+mMaterial.mDefaultLocalName+". Report this error to Alkalus on Github."); + return false; + } + + private static synchronized boolean tryEnableAllComponentsForMaterial(Materials material){ + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + return false; + } + try { + tryEnableMaterial(material); + int mValid = 0; + for(OrePrefixes ore:OrePrefixes.values()){ + if (tryEnableMaterialPart(ore, material)){ + mValid++; + } + } + if (mValid > 0){ + Logger.DEBUG_MATERIALS("Success - Re-enabled all components for "+MaterialUtils.getMaterialName(material)); + } + else { + Logger.DEBUG_MATERIALS("Failure - Did not enable any components for "+MaterialUtils.getMaterialName(material)); + } + return mValid > 0; + } + catch (SecurityException | IllegalArgumentException e) { + Logger.DEBUG_MATERIALS("Total Failure - Unable to re-enable "+MaterialUtils.getMaterialName(material)+". Most likely an IllegalArgumentException, but small chance it's a SecurityException."); + return false; + } + } + + + + + + + + + + /** + * Special Dynamic Interface Class + */ + + public class MaterialHandler implements InvocationHandler { + + private final Map<String, Method> methods = new HashMap<String, Method>(); + private Object target; + + public MaterialHandler(Object target) { + Logger.REFLECTION("Created a Proxy Interface which implements IMaterialHandler."); + this.target = target; + for(Method method: target.getClass().getDeclaredMethods()) { + Logger.REFLECTION("Adding "+method.getName()+" to internal method map."); + this.methods.put(method.getName(), method); + } + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable { + long start = System.nanoTime(); + Object result = methods.get(method.getName()).invoke(target, args); + long elapsed = System.nanoTime() - start; + Logger.INFO("[Debug] Executed "+method.getName()+" in "+elapsed+" ns"); + return result; + } + } + + + /* + public static class ProxyListener implements java.lang.reflect.InvocationHandler { + + public static Object IMaterialHandlerProxy; + + ProxyListener(){ + + Logger.REFLECTION("Failed setting IMaterialHandler Proxy instance."); + } + + //Loading the class at runtime + public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { + Class<?> someInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); + Object instance = Proxy.newProxyInstance(someInterface.getClassLoader(), new Class<?>[]{someInterface}, new InvocationHandler() { + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + //Handle the invocations + if(method.getName().equals("onMaterialsInit")){ + Logger.REFLECTION("Invoked onMaterialsInit() via IMaterialHandler proxy"); + return 1; + } + else if(method.getName().equals("onComponentInit")){ + Logger.REFLECTION("Invoked onComponentInit() via IMaterialHandler proxy"); + return 2; + } + else if(method.getName().equals("onComponentIteration")){ + Logger.REFLECTION("Invoked onComponentIteration() via IMaterialHandler proxy"); + return 3; + } + else { + return -1; + } + } + }); + System.out.println(instance.getClass().getDeclaredMethod("someMethod", (Class<?>[])null).invoke(instance, new Object[]{})); + } + + private static class MaterialHandler implements InvocationHandler { + private final Object original; + + public MaterialHandler(Object original) { + this.original = original; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) + throws IllegalAccessException, IllegalArgumentException, + InvocationTargetException { + System.out.println("BEFORE"); + method.invoke(original, args); + System.out.println("AFTER"); + return null; + } + } + + public static void init(){ + + Class<?> someInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); + GT_Material_Loader original = GT_Material_Loader.instance; + MaterialHandler handler = new MaterialHandler(original); + + Object f = Proxy.newProxyInstance(someInterface.getClassLoader(), + new Class[] { someInterface }, + handler); + + f.originalMethod("Hallo"); + } + + + + } + + */ +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java new file mode 100644 index 0000000000..e918d8015e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.xmod.gregtech.common.blocks.*; + +public class Gregtech_Blocks { + + public static void run(){ + + //Casing Blocks + ModBlocks.blockCasingsMisc = new GregtechMetaCasingBlocks(); + ModBlocks.blockCasings2Misc = new GregtechMetaCasingBlocks2(); + ModBlocks.blockCasings3Misc = new GregtechMetaCasingBlocks3(); + ModBlocks.blockCasings4Misc = new GregtechMetaCasingBlocks4(); + ModBlocks.blockCasings5Misc = new GregtechMetaCasingBlocks5(); + + ModBlocks.blockCasingsTieredGTPP = new GregtechMetaTieredCasingBlocks1(); + ModBlocks.blockSpecialMultiCasings = new GregtechMetaSpecialMultiCasings(); + ModBlocks.blockCustomMachineCasings = new GregtechMetaSpecialMachineCasings(); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java new file mode 100644 index 0000000000..51316f024a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java @@ -0,0 +1,135 @@ + +package gtPlusPlus.xmod.gregtech.loaders; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_ModHandler.RecipeBits; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import net.minecraft.item.ItemStack; + +public class ProcessingAngleGrinder implements Interface_OreRecipeRegistrator, Runnable { + public ProcessingAngleGrinder() { + GregtechOrePrefixes.toolAngleGrinder.add(this); + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, + final String aModName, final ItemStack aStack) { + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint)) { + if (aMaterial != Materials.Rubber) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) + && (!aMaterial.contains(SubTag.NO_SMASHING))) { + + } + } + } + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final String aOreDictName, + final String aModName, final ItemStack aStack) { + // TODO Auto-generated method stub + + } + + public void materialsLoops() { + final Materials[] i = Materials.values(); + final int size = i.length; + Logger.MATERIALS("Materials to attempt tool gen. with: " + size); + int used = 0; + Materials aMaterial = null; + for (int r = 0; r < size; r++) { + aMaterial = i[r]; + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint) && (aMaterial != Materials.Rubber) + && (aMaterial != Materials._NULL)) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) + && (!aMaterial.contains(SubTag.NO_SMASHING)) && (!aMaterial.contains(SubTag.TRANSPARENT)) + && (!aMaterial.contains(SubTag.FLAMMABLE)) && (!aMaterial.contains(SubTag.MAGICAL)) + && (!aMaterial.contains(SubTag.NO_SMELTING))) { + Logger.MATERIALS("Generating Angle Grinder from "+MaterialUtils.getMaterialName(aMaterial)); + // Input 1 + + + final ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plate, aMaterial, 1L); + final ItemStack longrod = GT_OreDictUnificator.get(OrePrefixes.stickLong, aMaterial, 1L); + + if ((null != plate && longrod != null)) { + addRecipe(aMaterial, 1600000L, 3, ItemList.Battery_RE_HV_Lithium.get(1)); + addRecipe(aMaterial, 1200000L, 3, ItemList.Battery_RE_HV_Cadmium.get(1)); + addRecipe(aMaterial, 800000L, 3, ItemList.Battery_RE_HV_Sodium.get(1)); + used++; + } else { + Logger.MATERIALS("Unable to generate Angle Grinder from "+MaterialUtils.getMaterialName(aMaterial)+", Plate or Long Rod may be invalid. Invalid | Plate? "+(plate == null) +" | Rod? "+(longrod == null)+" |"); + } + // GT_ModHandler.addCraftingRecipe(, + // GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | + // GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"P H", "PIP", " I ", + // Character.valueOf('I'), OrePrefixes.ingot.get(aMaterial), + // Character.valueOf('P'), OrePrefixes.plate.get(aMaterial), + // Character.valueOf('H'), OrePrefixes.toolHeadHammer.get(aMaterial)}); + } else { + Logger.MATERIALS("Unable to generate Angle Grinder from "+MaterialUtils.getMaterialName(aMaterial)); + } + } else { + Logger.MATERIALS("Unable to generate Angle Grinder from "+MaterialUtils.getMaterialName(aMaterial)); + } + + } + + Logger.INFO("Materials used for tool gen: " + used); + } + + @Override + public void run() { + Logger.INFO("Generating Angle Grinders for all valid GT Materials."); + this.materialsLoops(); + } + + public boolean addRecipe(Materials aMaterial, long aBatteryStorage, int aVoltageTier, ItemStack aBattery) { + + ItemStack aOutputStack = MetaGeneratedGregtechTools.INSTANCE.getToolWithStats( + MetaGeneratedGregtechTools.ANGLE_GRINDER, + 1, + aMaterial, + Materials.Titanium, + new long[]{aBatteryStorage, GT_Values.V[aVoltageTier], 3L, -1L}); + + + + long aDura = MetaGeneratedGregtechTools.getToolMaxDamage(aOutputStack); + if (aDura <= 32000) { + Logger.MATERIALS("Unable to generate Angle Grinder from "+MaterialUtils.getMaterialName(aMaterial)+", Durability: "+aDura); + return false; + } + + return GT_ModHandler.addCraftingRecipe( + aOutputStack, + RecipeBits.DISMANTLEABLE | RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | RecipeBits.BUFFERED, + new Object[]{ + "SXL", + "GMG", + "PBP", + 'X', ItemList.Component_Grinder_Tungsten.get(1), + 'M', CI.getElectricMotor(aVoltageTier, 1), + 'S', OrePrefixes.screw.get(Materials.Titanium), + 'L', OrePrefixes.stickLong.get(aMaterial), + 'P', OrePrefixes.plate.get(aMaterial), + 'G', ELEMENT.STANDALONE.BLACK_METAL.getGear(1), + 'B', aBattery + }); + + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricButcherKnife.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricButcherKnife.java new file mode 100644 index 0000000000..9fe9ad7816 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricButcherKnife.java @@ -0,0 +1,134 @@ + +package gtPlusPlus.xmod.gregtech.loaders; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_ModHandler.RecipeBits; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import net.minecraft.item.ItemStack; + +public class ProcessingElectricButcherKnife implements Interface_OreRecipeRegistrator, Runnable { + public ProcessingElectricButcherKnife() { + GregtechOrePrefixes.toolElectricButcherKnife.add(this); + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, + final String aModName, final ItemStack aStack) { + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint)) { + if (aMaterial != Materials.Rubber) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) + && (!aMaterial.contains(SubTag.NO_SMASHING))) { + + } + } + } + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final String aOreDictName, + final String aModName, final ItemStack aStack) { + // TODO Auto-generated method stub + + } + + public void materialsLoops() { + final Materials[] i = Materials.values(); + final int size = i.length; + Logger.MATERIALS("Materials to attempt tool gen. with: " + size); + int used = 0; + Materials aMaterial = null; + for (int r = 0; r < size; r++) { + aMaterial = i[r]; + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint) && (aMaterial != Materials.Rubber) + && (aMaterial != Materials._NULL)) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) + && (!aMaterial.contains(SubTag.NO_SMASHING)) && (!aMaterial.contains(SubTag.TRANSPARENT)) + && (!aMaterial.contains(SubTag.FLAMMABLE)) && (!aMaterial.contains(SubTag.MAGICAL)) + && (!aMaterial.contains(SubTag.NO_SMELTING))) { + Logger.MATERIALS("Generating Electric Butcher Knife from "+MaterialUtils.getMaterialName(aMaterial)); + // Input 1 + + + final ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plate, aMaterial, 1L); + final ItemStack screw = GT_OreDictUnificator.get(OrePrefixes.screw, aMaterial, 1L); + + if ((null != plate) && screw != null) { + addRecipe(aMaterial, 1600000L, 3, ItemList.Battery_RE_HV_Lithium.get(1)); + addRecipe(aMaterial, 1200000L, 3, ItemList.Battery_RE_HV_Cadmium.get(1)); + addRecipe(aMaterial, 800000L, 3, ItemList.Battery_RE_HV_Sodium.get(1)); + used++; + } else { + Logger.MATERIALS("Unable to generate Electric Butcher Knife from "+MaterialUtils.getMaterialName(aMaterial)+", Plate or Long Rod may be invalid. Invalid | Plate? "+(plate == null) +" | Rod? "+" |"); + } + // GT_ModHandler.addCraftingRecipe(, + // GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | + // GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"P H", "PIP", " I ", + // Character.valueOf('I'), OrePrefixes.ingot.get(aMaterial), + // Character.valueOf('P'), OrePrefixes.plate.get(aMaterial), + // Character.valueOf('H'), OrePrefixes.toolHeadHammer.get(aMaterial)}); + } else { + Logger.MATERIALS("Unable to generate Electric Butcher Knife from "+MaterialUtils.getMaterialName(aMaterial)); + } + } else { + Logger.MATERIALS("Unable to generate Electric Butcher Knife from "+MaterialUtils.getMaterialName(aMaterial)); + } + + } + + Logger.INFO("Materials used for tool gen: " + used); + } + + @Override + public void run() { + Logger.INFO("Generating Electric Butcher Knives for all valid GT Materials."); + this.materialsLoops(); + } + + public boolean addRecipe(Materials aMaterial, long aBatteryStorage, int aVoltageTier, ItemStack aBattery) { + + ItemStack aOutputStack = MetaGeneratedGregtechTools.INSTANCE.getToolWithStats( + MetaGeneratedGregtechTools.ELECTRIC_BUTCHER_KNIFE, + 1, + aMaterial, + Materials.Titanium, + new long[]{aBatteryStorage, GT_Values.V[aVoltageTier], 3L, -1L}); + + ItemStack aInputCutter = GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.BUTCHERYKNIFE, + 1, + aMaterial, + aMaterial, + null); + + long aDura = MetaGeneratedGregtechTools.getToolMaxDamage(aOutputStack); + if (aDura <= 32000) { + Logger.MATERIALS("Unable to generate Electric Butcher Knife from "+MaterialUtils.getMaterialName(aMaterial)+", Durability: "+aDura); + return false; + } + + + + return RecipeUtils.addShapedRecipe( + OrePrefixes.wireFine.get(Materials.Electrum), aInputCutter, OrePrefixes.wireFine.get(Materials.Electrum), + OrePrefixes.plate.get(aMaterial), CI.getElectricMotor(aVoltageTier, 1), OrePrefixes.plate.get(aMaterial), + OrePrefixes.screw.get(aMaterial), aBattery, OrePrefixes.screw.get(aMaterial), + aOutputStack); + + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricLighter.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricLighter.java new file mode 100644 index 0000000000..5f6c5a0427 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricLighter.java @@ -0,0 +1,131 @@ + +package gtPlusPlus.xmod.gregtech.loaders; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_ModHandler.RecipeBits; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import net.minecraft.item.ItemStack; + +public class ProcessingElectricLighter implements Interface_OreRecipeRegistrator, Runnable { + public ProcessingElectricLighter() { + GregtechOrePrefixes.toolElectricLighter.add(this); + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, + final String aModName, final ItemStack aStack) { + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint)) { + if (aMaterial != Materials.Rubber) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) + && (!aMaterial.contains(SubTag.NO_SMASHING))) { + + } + } + } + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final String aOreDictName, + final String aModName, final ItemStack aStack) { + // TODO Auto-generated method stub + + } + + public void materialsLoops() { + final Materials[] i = Materials.values(); + final int size = i.length; + Logger.MATERIALS("Materials to attempt tool gen. with: " + size); + int used = 0; + Materials aMaterial = null; + for (int r = 0; r < size; r++) { + aMaterial = i[r]; + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint) && (aMaterial != Materials.Rubber) + && (aMaterial != Materials._NULL)) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) + && (!aMaterial.contains(SubTag.NO_SMASHING)) && (!aMaterial.contains(SubTag.TRANSPARENT)) + && (!aMaterial.contains(SubTag.FLAMMABLE)) && (!aMaterial.contains(SubTag.MAGICAL)) + && (!aMaterial.contains(SubTag.NO_SMELTING))) { + Logger.MATERIALS("Generating Electric Lighter from "+MaterialUtils.getMaterialName(aMaterial)); + // Input 1 + + + final ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plate, aMaterial, 1L); + + if ((null != plate)) { + addRecipe(aMaterial, 1600000L, 3, ItemList.Battery_RE_HV_Lithium.get(1)); + addRecipe(aMaterial, 1200000L, 3, ItemList.Battery_RE_HV_Cadmium.get(1)); + addRecipe(aMaterial, 800000L, 3, ItemList.Battery_RE_HV_Sodium.get(1)); + used++; + } else { + Logger.MATERIALS("Unable to generate Electric Lighter from "+MaterialUtils.getMaterialName(aMaterial)+", Plate or Long Rod may be invalid. Invalid | Plate? "+(plate == null) +" | Rod? "+" |"); + } + // GT_ModHandler.addCraftingRecipe(, + // GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | + // GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"P H", "PIP", " I ", + // Character.valueOf('I'), OrePrefixes.ingot.get(aMaterial), + // Character.valueOf('P'), OrePrefixes.plate.get(aMaterial), + // Character.valueOf('H'), OrePrefixes.toolHeadHammer.get(aMaterial)}); + } else { + Logger.MATERIALS("Unable to generate Electric Lighter from "+MaterialUtils.getMaterialName(aMaterial)); + } + } else { + Logger.MATERIALS("Unable to generate Electric Lighter from "+MaterialUtils.getMaterialName(aMaterial)); + } + + } + + Logger.INFO("Materials used for tool gen: " + used); + } + + @Override + public void run() { + Logger.INFO("Generating Electric Lighters for all valid GT Materials."); + this.materialsLoops(); + } + + public boolean addRecipe(Materials aMaterial, long aBatteryStorage, int aVoltageTier, ItemStack aBattery) { + + ItemStack aOutputStack = MetaGeneratedGregtechTools.INSTANCE.getToolWithStats( + MetaGeneratedGregtechTools.ELECTRIC_LIGHTER, + 1, + aMaterial, + Materials.Titanium, + new long[]{aBatteryStorage, GT_Values.V[aVoltageTier], 3L, -1L}); + + ItemStack aInputCutter = GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.SOLDERING_IRON_LV, + 1, + aMaterial, + aMaterial, + null); + + long aDura = MetaGeneratedGregtechTools.getToolMaxDamage(aOutputStack); + if (aDura <= 32000) { + Logger.MATERIALS("Unable to generate Electric Lighter from "+MaterialUtils.getMaterialName(aMaterial)+", Durability: "+aDura); + return false; + } + + return RecipeUtils.addShapedRecipe( + OrePrefixes.wireGt04.get(Materials.Gold), aInputCutter, OrePrefixes.wireGt04.get(Materials.Gold), + ELEMENT.STANDALONE.RUNITE.getPlate(1), CI.getSensor(aVoltageTier, 1), ELEMENT.STANDALONE.RUNITE.getPlate(1), + OrePrefixes.plate.get(aMaterial), aBattery, OrePrefixes.plate.get(aMaterial), + aOutputStack); + + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricSnips.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricSnips.java new file mode 100644 index 0000000000..dfcb7de4f8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricSnips.java @@ -0,0 +1,130 @@ + +package gtPlusPlus.xmod.gregtech.loaders; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_ModHandler.RecipeBits; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import net.minecraft.item.ItemStack; + +public class ProcessingElectricSnips implements Interface_OreRecipeRegistrator, Runnable { + public ProcessingElectricSnips() { + GregtechOrePrefixes.toolElectricSnips.add(this); + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, + final String aModName, final ItemStack aStack) { + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint)) { + if (aMaterial != Materials.Rubber) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) + && (!aMaterial.contains(SubTag.NO_SMASHING))) { + + } + } + } + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final String aOreDictName, + final String aModName, final ItemStack aStack) { + // TODO Auto-generated method stub + + } + + public void materialsLoops() { + final Materials[] i = Materials.values(); + final int size = i.length; + Logger.MATERIALS("Materials to attempt tool gen. with: " + size); + int used = 0; + Materials aMaterial = null; + for (int r = 0; r < size; r++) { + aMaterial = i[r]; + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint) && (aMaterial != Materials.Rubber) + && (aMaterial != Materials._NULL)) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) + && (!aMaterial.contains(SubTag.NO_SMASHING)) && (!aMaterial.contains(SubTag.TRANSPARENT)) + && (!aMaterial.contains(SubTag.FLAMMABLE)) && (!aMaterial.contains(SubTag.MAGICAL)) + && (!aMaterial.contains(SubTag.NO_SMELTING))) { + Logger.MATERIALS("Generating Electric Snips from "+MaterialUtils.getMaterialName(aMaterial)); + // Input 1 + + + final ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plate, aMaterial, 1L); + + if ((null != plate)) { + addRecipe(aMaterial, 1600000L, 3, ItemList.Battery_RE_HV_Lithium.get(1)); + addRecipe(aMaterial, 1200000L, 3, ItemList.Battery_RE_HV_Cadmium.get(1)); + addRecipe(aMaterial, 800000L, 3, ItemList.Battery_RE_HV_Sodium.get(1)); + used++; + } else { + Logger.MATERIALS("Unable to generate Electric Snips from "+MaterialUtils.getMaterialName(aMaterial)+", Plate or Long Rod may be invalid. Invalid | Plate? "+(plate == null) +" | Rod? "+" |"); + } + // GT_ModHandler.addCraftingRecipe(, + // GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | + // GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"P H", "PIP", " I ", + // Character.valueOf('I'), OrePrefixes.ingot.get(aMaterial), + // Character.valueOf('P'), OrePrefixes.plate.get(aMaterial), + // Character.valueOf('H'), OrePrefixes.toolHeadHammer.get(aMaterial)}); + } else { + Logger.MATERIALS("Unable to generate Electric Snips from "+MaterialUtils.getMaterialName(aMaterial)); + } + } else { + Logger.MATERIALS("Unable to generate Electric Snips from "+MaterialUtils.getMaterialName(aMaterial)); + } + + } + + Logger.INFO("Materials used for tool gen: " + used); + } + + @Override + public void run() { + Logger.INFO("Generating Electric Snips for all valid GT Materials."); + this.materialsLoops(); + } + + public boolean addRecipe(Materials aMaterial, long aBatteryStorage, int aVoltageTier, ItemStack aBattery) { + + ItemStack aOutputStack = MetaGeneratedGregtechTools.INSTANCE.getToolWithStats( + MetaGeneratedGregtechTools.ELECTRIC_SNIPS, + 1, + aMaterial, + Materials.Titanium, + new long[]{aBatteryStorage, GT_Values.V[aVoltageTier], 3L, -1L}); + + ItemStack aInputCutter = GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats( + GT_MetaGenerated_Tool_01.WIRECUTTER, + 1, + aMaterial, + aMaterial, + null); + + long aDura = MetaGeneratedGregtechTools.getToolMaxDamage(aOutputStack); + if (aDura <= 32000) { + Logger.MATERIALS("Unable to generate Electric Snips from "+MaterialUtils.getMaterialName(aMaterial)+", Durability: "+aDura); + return false; + } + return RecipeUtils.addShapedRecipe( + OrePrefixes.wireFine.get(Materials.Electrum), aInputCutter, OrePrefixes.wireFine.get(Materials.Electrum), + ELEMENT.STANDALONE.WHITE_METAL.getGear(1), CI.getElectricMotor(aVoltageTier, 1), ELEMENT.STANDALONE.WHITE_METAL.getGear(1), + OrePrefixes.plate.get(aMaterial), aBattery, OrePrefixes.plate.get(aMaterial), + aOutputStack); + + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingToolHeadChoocher.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingToolHeadChoocher.java new file mode 100644 index 0000000000..e4858f8cd1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/ProcessingToolHeadChoocher.java @@ -0,0 +1,92 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.*; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; + +public class ProcessingToolHeadChoocher implements Interface_OreRecipeRegistrator, Runnable { + public ProcessingToolHeadChoocher() { + GregtechOrePrefixes.toolSkookumChoocher.add(this); + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint)) { + if (aMaterial != Materials.Rubber) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) && (!aMaterial.contains(SubTag.NO_SMASHING))) { + GT_ModHandler.addCraftingRecipe(MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(16, 1, aMaterial, aMaterial, null), GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"IhI", "III", " I ", Character.valueOf('I'), OrePrefixes.ingot.get(aMaterial)}); + } + } + } + } + + @Override + public void registerOre(final GregtechOrePrefixes aPrefix, + final GT_Materials aMaterial, final String aOreDictName, final String aModName, + final ItemStack aStack) { + // TODO Auto-generated method stub + + } + + public void materialsLoops(){ + final Materials[] i = Materials.values(); + final int size = i.length; + Logger.WARNING("Materials to attempt tool gen. with: "+size); + int used = 0; + Materials aMaterial = null; + for (int r=0;r<size;r++){ + aMaterial = i[r]; + if ((aMaterial != Materials.Stone) && (aMaterial != Materials.Flint) && (aMaterial != Materials.Rubber) && (aMaterial != Materials._NULL)) { + if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) && (!aMaterial.contains(SubTag.NO_SMASHING))&& (!aMaterial.contains(SubTag.TRANSPARENT))&& (!aMaterial.contains(SubTag.FLAMMABLE))&& (!aMaterial.contains(SubTag.MAGICAL))&& (!aMaterial.contains(SubTag.NO_SMELTING))) { + Logger.WARNING("Found "+aMaterial.name()+" as a valid Skookum Choocher Material."); + //Input 1 + final ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plate, aMaterial, 1L); + final ItemStack ingot = GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial, 1L); + final ItemStack screw = GT_OreDictUnificator.get(OrePrefixes.screw, aMaterial, 1L); + final ItemStack longrod = GT_OreDictUnificator.get(OrePrefixes.stickLong, aMaterial, 1L); + final ItemStack hammerhead = GT_OreDictUnificator.get(OrePrefixes.toolHeadHammer, aMaterial, 1L); + + if ((null != plate) && (null != ingot) && (null != hammerhead) && (null != longrod) && (null != screw)){ + RecipeUtils.addShapedRecipe( + hammerhead, ToolDictNames.craftingToolScrewdriver.name(), plate, + ingot, plate, plate, + longrod, screw, null, + MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(MetaGeneratedGregtechTools.SKOOKUM_CHOOCHER, 1, aMaterial, null, null)); + used++; + } + else { + Logger.WARNING(""+aMaterial.name()+" could not be used for all input compoenents. [3x"+aMaterial.name()+" plates, 2x"+aMaterial.name()+" ingots, 1x"+aMaterial.name()+" Hard Hammer Head."); + } + //GT_ModHandler.addCraftingRecipe(, GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"P H", "PIP", " I ", Character.valueOf('I'), OrePrefixes.ingot.get(aMaterial), Character.valueOf('P'), OrePrefixes.plate.get(aMaterial), Character.valueOf('H'), OrePrefixes.toolHeadHammer.get(aMaterial)}); + } + else { + Logger.WARNING(""+aMaterial.name()+" was not a valid Skookum Choocher Material."); + } + } + else { + Logger.WARNING(""+aMaterial.name()+" was not a valid Skookum Choocher Material."); + } + + + } + + Logger.INFO("Materials used for tool gen: "+used); + } + + @Override + public void run() { + Logger.INFO("Generating Skookum Choochers of all GT Materials."); + this.materialsLoops(); + } + + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/Processing_Textures_Items.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/Processing_Textures_Items.java new file mode 100644 index 0000000000..ae559db232 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/Processing_Textures_Items.java @@ -0,0 +1,11 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechTextures.ItemIcons.CustomIcon; + +public class Processing_Textures_Items { + + public static final CustomIcon itemSkookumChoocher = new CustomIcon("iconsets/SKOOKUMCHOOCHER"); + public static final CustomIcon itemElectricPump = new CustomIcon("iconsets/PUMP"); + +} + diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_AlloySmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_AlloySmelter.java new file mode 100644 index 0000000000..7754d039cf --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_AlloySmelter.java @@ -0,0 +1,66 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; + +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class RecipeGen_AlloySmelter extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_AlloySmelter(final Material M){ + this.toGenerate = M; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + private void generateRecipes(final Material material){ + final int tVoltageMultiplier = material.vVoltageMultiplier; + + + + //Nuggets + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getNugget(1))) + GT_Values.RA.addAlloySmelterRecipe( + material.getIngot(1), + ItemList.Shape_Mold_Nugget.get(0), + material.getNugget(9), + (int) Math.max(material.getMass() * 2L, 1L), + tVoltageMultiplier); + + //Gears + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getGear(1))) + GT_Values.RA.addAlloySmelterRecipe( + material.getIngot(8), + ItemList.Shape_Mold_Gear.get(0), + material.getGear(1), + (int) Math.max(material.getMass() * 2L, 1L), + tVoltageMultiplier); + + //Ingot + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getNugget(1))) + GT_Values.RA.addAlloySmelterRecipe( + material.getNugget(9), + ItemList.Shape_Mold_Ingot.get(0), + material.getIngot(1), + (int) Math.max(material.getMass() * 2L, 1L), + tVoltageMultiplier); + + } + +} + diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Assembler.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Assembler.java new file mode 100644 index 0000000000..d7244919d8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Assembler.java @@ -0,0 +1,81 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GT_Values; + +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class RecipeGen_Assembler extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_Assembler(final Material M){ + this.toGenerate = M; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + private void generateRecipes(final Material material){ + + //Frame Box + if (ItemUtils.checkForInvalidItems(new ItemStack[] {material.getRod(1), material.getFrameBox(1)})) + GT_Values.RA.addAssemblerRecipe( + material.getRod(4), + ItemUtils.getGregtechCircuit(4), + material.getFrameBox(1), + 60, + material.vVoltageMultiplier); + + //Rotor + if (ItemUtils.checkForInvalidItems(new ItemStack[] {material.getPlate(1), material.getRing(1), material.getRotor(1)})) + addAssemblerRecipe( + material.getPlate(4), + material.getRing(1), + material.getRotor(1), + 240, + material.vVoltageMultiplier); + + } + + private static void addAssemblerRecipe(final ItemStack input1, final ItemStack input2, final ItemStack output1, final int seconds, final int euCost){ + GT_Values.RA.addAssemblerRecipe( + input1, + input2, + FluidUtils.getFluidStack("molten.solderingalloy", 16), + output1, + seconds, + euCost); + GT_Values.RA.addAssemblerRecipe( + input1, + input2, + FluidUtils.getFluidStack("molten.tin", 32), + output1, + seconds, + euCost); + GT_Values.RA.addAssemblerRecipe( + input1, + input2, + FluidUtils.getFluidStack("molten.lead", 48), + output1, + seconds, + euCost); + } + + +} + diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Base.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Base.java new file mode 100644 index 0000000000..7e9153679f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Base.java @@ -0,0 +1,16 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.core.material.Material; + +public abstract class RecipeGen_Base implements RunnableWithInfo<Material>{ + + protected Material toGenerate; + protected boolean disableOptional; + + @Override + public Material getInfoData() { + return toGenerate; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java new file mode 100644 index 0000000000..9e58d486d3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java @@ -0,0 +1,280 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.material.nuclear.NUCLIDE; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeGen_BlastSmelter extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_BlastSmelter(final Material M){ + this.toGenerate = M; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateARecipe(this.toGenerate); + } + + private void generateARecipe(final Material M){ + + //Add a Blast Smelting Recipe, Let's go! + ItemStack tStack; + if (null != (tStack = M.getDust(1))) { + + final Material[] badMaterials = { + FLUORIDES.THORIUM_HEXAFLUORIDE, + FLUORIDES.THORIUM_TETRAFLUORIDE, + ALLOY.BLOODSTEEL, + NUCLIDE.LiFBeF2ThF4UF4, + NUCLIDE.LiFBeF2ZrF4UF4, + NUCLIDE.LiFBeF2ZrF4U235 + }; + for (final Material R : badMaterials){ + if (M == R){ + return; + } + } + + //Prepare some Variables + ItemStack[] components; + ArrayList<MaterialStack> tMaterial = new ArrayList<>(); + int inputStackCount=0; + int fluidAmount=0; + final boolean doTest = true; + tMaterial = M.getComposites(); + + //This Bad boy here is what dictates unique recipes. Fuck life, right? + ItemStack circuitGT = ItemUtils.getGregtechCircuit(0); + + + //Set a duration - OLD + /*int duration = 0; + if (M.getMeltingPointK() > 150){ + duration = (int) Math.max(M.getMass() / 50L, 1L) * M.getMeltingPointK(); + } + else { + duration = (int) Math.max(M.getMass() / 50L, 1L) * 150; + }*/ + + long aVoltage = MaterialUtils.getVoltageForTier(M.vTier); + + + //Set a duration - NEW + int duration = 120*M.vTier*10; + + if (M.vTier <= 4){ + duration = 20*M.vTier*10; + } + + int mMaterialListSize=0; + + int mTotalPartsCounter = M.smallestStackSizeWhenProcessing; + + if (M.getComposites() != null){ + for (final gtPlusPlus.core.material.MaterialStack ternkfsdf : M.getComposites()){ + if (ternkfsdf != null) { + mMaterialListSize++; + //mTotalPartsCounter += ternkfsdf.getSmallestStackSizes()[0]; + } + } + } + else { + mMaterialListSize = 1; + } + + if (duration <= 0){ + final int second = 20; + duration = 14*second*mMaterialListSize*8; + } + + Logger.WARNING("[BAS] Size: "+mMaterialListSize); + + + //Make a simple one Material Materialstack[] and log it for validity. + circuitGT = ItemUtils.getGregtechCircuit(1); + final ItemStack[] tItemStackTest = new ItemStack[]{circuitGT, tStack}; + inputStackCount = 1; + fluidAmount = 144*inputStackCount; + Logger.WARNING("[BAS] Adding an Alloy Blast Smelter Recipe for "+M.getLocalizedName()+". Gives "+fluidAmount+"L of molten metal."); + for (int das=0;das<tItemStackTest.length;das++){ + if (tItemStackTest[das] != null) { + Logger.WARNING("[BAS] tMaterial["+das+"]: "+tItemStackTest[das].getDisplayName()+" Meta: "+tItemStackTest[das].getItemDamage()+", Amount: "+tItemStackTest[das].stackSize); + } + } + + final boolean hasMoreInputThanACircuit = (tItemStackTest.length > 1); + + //Generate Recipes for all singular materials that can be made molten. + if (hasMoreInputThanACircuit){ + if (M.requiresBlastFurnace()) { + if (CORE.RA.addBlastSmelterRecipe(tItemStackTest, M.getFluidStack(fluidAmount), 100, (duration/(mTotalPartsCounter > 0 ? mTotalPartsCounter : 1)), (int) aVoltage)){ + Logger.WARNING("[BAS] Success."); + Logger.WARNING("[BAS] Success, Also added a Fluid solidifier recipe."); + if (GT_Values.RA.addFluidExtractionRecipe(M.getIngot(1), null, M.getFluidStack(144), 100, duration, 120)){ + Logger.WARNING("[BAS] Success, Also added a Fluid Extractor recipe."); + } + if (GT_Values.RA.addFluidExtractionRecipe(M.getNugget(1), null, M.getFluidStack(16), 100, duration/9, 120)){ + Logger.WARNING("[BAS] Success, Also added a Fluid Extractor recipe."); + } + /*if (GT_Values.RA.addFluidExtractionRecipe(M.getSmallDust(1), null, M.getFluid(36), 100, duration/4, 120)){ + Logger.WARNING("[BAS] Success, Also added a Fluid Extractor recipe."); + } + if (GT_Values.RA.addFluidExtractionRecipe(M.getTinyDust(1), null, M.getFluid(16), 100, duration/9, 120)){ + Logger.WARNING("[BAS] Success, Also added a Fluid Extractor recipe."); + }*/ + } + } + else { + Logger.WARNING("[BAS] Failed."); + } + } + else { + if (CORE.RA.addBlastSmelterRecipe(tItemStackTest, M.getFluidStack(fluidAmount), 100, duration/(mTotalPartsCounter > 0 ? mTotalPartsCounter : 1)/2, (int) aVoltage)){ + Logger.WARNING("[BAS] Success."); + if (GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Ingot.get(0), M.getFluidStack(144), M.getIngot(1), duration/2, 60)){ + Logger.WARNING("[BAS] Success, Also added a Fluid solidifier recipe."); + if (GT_Values.RA.addFluidExtractionRecipe(M.getIngot(1), null, M.getFluidStack(144), 100, duration/2, 60)){ + Logger.WARNING("[BAS] Success, Also added a Fluid Extractor recipe."); + } + if (GT_Values.RA.addFluidExtractionRecipe(M.getNugget(1), null, M.getFluidStack(16), 100, duration/2/9, 60)){ + Logger.WARNING("[BAS] Success, Also added a Fluid Extractor recipe."); + } + /*if (GT_Values.RA.addFluidExtractionRecipe(M.getSmallDust(1), null, M.getFluid(36), 100, duration/2/4, 60)){ + Logger.WARNING("[BAS] Success, Also added a Fluid Extractor recipe."); + } + if (GT_Values.RA.addFluidExtractionRecipe(M.getTinyDust(1), null, M.getFluid(16), 100, duration/2/9, 60)){ + Logger.WARNING("[BAS] Success, Also added a Fluid Extractor recipe."); + }*/ + } + } + else { + Logger.WARNING("[BAS] Failed."); + } + } + + if (tMaterial != null){ + //Reset the Variables for compounds if last recipe was a success. + inputStackCount=0; + + //If this Material has some kind of compound list, proceed + if (mMaterialListSize > 1){ + final gtPlusPlus.core.material.MaterialStack[] tempStack = new gtPlusPlus.core.material.MaterialStack[mMaterialListSize]; + circuitGT = ItemUtils.getGregtechCircuit(mMaterialListSize); + //Just double checking + if (tempStack.length > 1){ + + //Builds me a MaterialStack[] from the MaterialList of M. + int ooo=0; + for (final gtPlusPlus.core.material.MaterialStack xMaterial : M.getComposites()){ + if (xMaterial != null){ + if (xMaterial.getStackMaterial() != null){ + Logger.WARNING("[BAS] FOUND: "+xMaterial.getStackMaterial().getLocalizedName()); + Logger.WARNING("[BAS] ADDING: "+xMaterial.getStackMaterial().getLocalizedName()); + } + tempStack[ooo] = xMaterial; + } + ooo++; + } + + //Builds me an ItemStack[] of the materials. - Without a circuit - this gets a good count for the 144L fluid multiplier + components = new ItemStack[9]; + inputStackCount=0; + FluidStack componentsFluid = null; + for (int irc=0;irc<M.getComposites().size();irc++){ + if (M.getComposites().get(irc) != null){ + final int r = (int) M.vSmallestRatio[irc]; + inputStackCount = inputStackCount+r; + if ((M.getComposites().get(irc).getStackMaterial().getState() != MaterialState.SOLID) || !ItemUtils.checkForInvalidItems(M.getComposites().get(irc).getDustStack(r))){ + final int xr = r; + if ((xr > 0) && (xr <= 100)){ + final int mathmatics = (r*1000); + componentsFluid = FluidUtils.getFluidStack(M.getComposites().get(irc).getStackMaterial().getFluidStack(mathmatics), mathmatics); + } + } + else { + components[irc] = M.getComposites().get(irc).getDustStack(r); + } + } + } + + + //Adds a circuit + if ((mMaterialListSize < 9) && (mMaterialListSize != 0)){ + final ItemStack[] components_NoCircuit = components; + //Builds me an ItemStack[] of the materials. - With a circuit + components = new ItemStack[components_NoCircuit.length+1]; + for (int fr=0;fr<components.length;fr++){ + if (fr==0){ + components[0] = circuitGT; + } + else { + components[fr] = components_NoCircuit[fr-1]; + } + } + Logger.WARNING("[BAS] Should have added a circuit. mMaterialListSize: "+mMaterialListSize+" | circuit: "+components[0].getDisplayName()); + } + else { + Logger.WARNING("[BAS] Did not add a circuit. mMaterialListSize: "+mMaterialListSize); + } + + //Set Fluid output + fluidAmount = 144*inputStackCount; + + Logger.WARNING("[BAS] Adding an Alloy Blast Smelter Recipe for "+M.getLocalizedName()+" using it's compound dusts. This material has "+ inputStackCount+" parts. Gives "+fluidAmount+"L of molten metal."); + Logger.WARNING("[BAS] tMaterial.length: "+components.length+"."); + for (int das=0;das<components.length;das++){ + if (components[das] != null) { + Logger.WARNING("[BAS] tMaterial["+das+"]: "+components[das].getDisplayName()+" Meta: "+components[das].getItemDamage()+", Amount: "+components[das].stackSize); + } + } + + //Adds Recipe + if (M.requiresBlastFurnace()) { + if (CORE.RA.addBlastSmelterRecipe(components, componentsFluid, M.getFluidStack(fluidAmount), 100, duration, (int) aVoltage)){ + Logger.WARNING("[BAS] Success."); + } + else { + Logger.WARNING("[BAS] Failed."); + } + } + else { + if (CORE.RA.addBlastSmelterRecipe(components, componentsFluid, M.getFluidStack(fluidAmount), 100, duration, (int) aVoltage/2)){ + Logger.WARNING("[BAS] Success."); + } + else { + Logger.WARNING("[BAS] Failed."); + } + } + } + } + } + else { + Logger.WARNING("[BAS] doTest: "+doTest+" | tMaterial != null: "+(tMaterial != null)); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_Ex.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_Ex.java new file mode 100644 index 0000000000..e76b769ef6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_Ex.java @@ -0,0 +1,153 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.interfaces.IOreRecipeRegistrator; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeGen_BlastSmelterGT_Ex implements IOreRecipeRegistrator { + + private final OrePrefixes[] mSmeltingPrefixes = { + OrePrefixes.crushed, + OrePrefixes.ingot, + OrePrefixes.crushedPurified, + OrePrefixes.crushedCentrifuged, + OrePrefixes.dust, + OrePrefixes.dustPure, + OrePrefixes.dustImpure, + OrePrefixes.dustRefined, + OrePrefixes.dustSmall, + OrePrefixes.dustTiny + }; + + public RecipeGen_BlastSmelterGT_Ex() { + for (OrePrefixes tPrefix : this.mSmeltingPrefixes) tPrefix.add(this); + } + + @Override + public void registerOre(OrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack) { + + boolean keepHighTempRecipes = !CORE.GTNH; + + switch (aPrefix) { + case dust: + ItemStack tDustStack; + if (keepHighTempRecipes || aMaterial.mBlastFurnaceTemp <= 3600){ + if ((null != (tDustStack = GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial.mSmeltInto, 1L))) && (!aMaterial.contains(SubTag.NO_SMELTING))) { + if (aMaterial.mBlastFurnaceRequired) { + addBlastRecipe(GT_Utility.copyAmount(1L, new Object[]{aStack}), null, null, null, aMaterial.mBlastFurnaceTemp > 1750 ? GT_OreDictUnificator.get(OrePrefixes.ingotHot, aMaterial.mSmeltInto, tDustStack, 1L) : GT_Utility.copyAmount(1L, new Object[]{tDustStack}), null, (int) Math.max(aMaterial.getMass() / 40L, 1L) * aMaterial.mBlastFurnaceTemp, 120, aMaterial); + if (aMaterial.mBlastFurnaceTemp <= 1000) { + GT_ModHandler.addRCBlastFurnaceRecipe(GT_Utility.copyAmount(1L, new Object[]{aStack}), GT_Utility.copyAmount(1L, new Object[]{tDustStack}), aMaterial.mBlastFurnaceTemp); + } + } + } + } + case ingot: + if (keepHighTempRecipes || aMaterial.mBlastFurnaceTemp <= 3600){ + if ((null != (tDustStack = GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial.mSmeltInto, 1L))) && (!aMaterial.contains(SubTag.NO_SMELTING))) { + if (aMaterial.mBlastFurnaceRequired) { + addBlastRecipe(GT_Utility.copyAmount(1L, new Object[]{aStack}), null, null, null, aMaterial.mBlastFurnaceTemp > 1750 ? GT_OreDictUnificator.get(OrePrefixes.ingotHot, aMaterial.mSmeltInto, tDustStack, 1L) : GT_Utility.copyAmount(1L, new Object[]{tDustStack}), null, (int) Math.max(aMaterial.getMass() / 40L, 1L) * aMaterial.mBlastFurnaceTemp, 120, aMaterial); + } + } + } + break; + case dustSmall: + if (keepHighTempRecipes || aMaterial.mBlastFurnaceTemp <= 3600){ + if (aMaterial.mBlastFurnaceRequired) { + addBlastRecipe(GT_Utility.copyAmount(4L, new Object[]{aStack}), null, null, null, aMaterial.mBlastFurnaceTemp > 1750 ? GT_OreDictUnificator.get(OrePrefixes.ingotHot, aMaterial.mSmeltInto, GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial.mSmeltInto, 1L), 1L) : GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial.mSmeltInto, 1L), null, (int) Math.max(aMaterial.getMass() / 40L, 1L) * aMaterial.mBlastFurnaceTemp, 120, aMaterial); + } + } + break; + case dustTiny: + if (keepHighTempRecipes || aMaterial.mBlastFurnaceTemp <= 3600){ + if (!aMaterial.contains(gregtech.api.enums.SubTag.NO_SMELTING)) { + if (aMaterial.mBlastFurnaceRequired) { + addBlastRecipe(GT_Utility.copyAmount(9L, new Object[]{aStack}), null, null, null, aMaterial.mBlastFurnaceTemp > 1750 ? GT_OreDictUnificator.get(OrePrefixes.ingotHot, aMaterial.mSmeltInto, GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial.mSmeltInto, 1L), 1L) : GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial.mSmeltInto, 1L), null, (int) Math.max(aMaterial.getMass() / 40L, 1L) * aMaterial.mBlastFurnaceTemp, 120, aMaterial); + + } + } + } + break; + default: + if (keepHighTempRecipes || aMaterial.mBlastFurnaceTemp <= 3600){ + if (!aMaterial.contains(SubTag.NO_SMELTING)) { + if ((aMaterial.mBlastFurnaceRequired) || (aMaterial.mDirectSmelting.mBlastFurnaceRequired)) { + addBlastRecipe(GT_Utility.copyAmount(1L, new Object[]{aStack}), null, null, null, aMaterial.mBlastFurnaceTemp > 1750 ? GT_OreDictUnificator.get(OrePrefixes.ingotHot, aMaterial, GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial, 1L), 1L) : GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial, 1L), null, (int) Math.max(aMaterial.getMass() / 4L, 1L) * aMaterial.mBlastFurnaceTemp, 120, aMaterial); + if (aMaterial.mBlastFurnaceTemp <= 1000) + GT_ModHandler.addRCBlastFurnaceRecipe(GT_Utility.copyAmount(1L, new Object[]{aStack}), GT_OreDictUnificator.get(OrePrefixes.ingot, aMaterial, 1L), aMaterial.mBlastFurnaceTemp * 2); + } + } + } + break; + } + } + + public boolean addBlastRecipe(ItemStack input1, ItemStack input2, + FluidStack fluid1, FluidStack fluid2, ItemStack output1, + ItemStack output2, int time, int euCost, Materials smeltInto) { + + //Set up variables. + ItemStack[] components; + int count = 0; + + if (smeltInto == Materials._NULL){ + //If the material is null then we probably don't want to try. + return false; + } + if (input1 != null && input2 != null){ + count = 2; + } + else if (input1 == null && input2 == null){ + //If both inputs are null, then we don't want to try. + return false; + } + else { + count = 1; + } + //Set up input components. + ItemStack configCircuit = ItemUtils.getGregtechCircuit(count); + components = new ItemStack[]{configCircuit, input1, input2}; + if (fluid1 != null || fluid2 != null){ + //If it uses an input fluid, we cannot handle this. So let's not try. (Annealed copper for example) + //return false; + if (fluid1 != null && fluid2 != null){ + //Cannot handle two input fluids + return false; + } + + FluidStack mInputfluidstack; + mInputfluidstack = (fluid1 != null) ? fluid1 : fluid2; + + //Try with new handler + //Add Blast Smelter Recipe. + return CORE.RA.addBlastSmelterRecipe( + components, + mInputfluidstack, + smeltInto.mSmeltInto.getMolten(144L), + 100, + MathUtils.roundToClosestInt(time*0.8), + euCost); // EU Cost + + } + + //Add Blast Smelter Recipe. + return CORE.RA.addBlastSmelterRecipe( + components, + smeltInto.mSmeltInto.getMolten(144L), + 100, + MathUtils.roundToClosestInt(time*0.8), + euCost); // EU Cost + + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_GTNH.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_GTNH.java new file mode 100644 index 0000000000..63c2d18783 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelterGT_GTNH.java @@ -0,0 +1,215 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import gregtech.api.util.*; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.ItemStackData; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.HashMap; +import java.util.Map; + +public class RecipeGen_BlastSmelterGT_GTNH { + + private static Map<String, FluidStack> mCachedIngotToFluidRegistry = new HashMap<String, FluidStack>(); + private static Map<String, String> mCachedHotToColdRegistry = new HashMap<String, String>(); + + private synchronized static void setIngotToFluid(final ItemStackData stack, final FluidStack fluid) { + if (stack != null && fluid != null) { + mCachedIngotToFluidRegistry.put(stack.getUniqueDataIdentifier(), fluid); + } + } + + private synchronized static void setHotToCold(final ItemStackData hot, final ItemStackData cold) { + if (hot != null && cold != null) { + mCachedHotToColdRegistry.put(hot.getUniqueDataIdentifier(), cold.getUniqueDataIdentifier()); + } + } + + private synchronized static FluidStack getFluidFromIngot(final ItemStackData ingot) { + ItemStackData h = ingot; + if (mCachedIngotToFluidRegistry.containsKey(h.getUniqueDataIdentifier())) { + Logger.MACHINE_INFO("[ABS] mCachedIngotToFluidRegistry contains Output Ingot."); + return mCachedIngotToFluidRegistry.get(h.getUniqueDataIdentifier()); + } + if (mCachedHotToColdRegistry.containsKey(h.getUniqueDataIdentifier())) { + Logger.MACHINE_INFO("[ABS] mCachedHotToColdRegistry contains Output Ingot."); + return mCachedIngotToFluidRegistry.get(mCachedHotToColdRegistry.get(h.getUniqueDataIdentifier())); + } + Logger.MACHINE_INFO("[ABS] Neither Cache contains Output Ingot."); + return null; + } + + private static boolean isValid(final ItemStack[] inputs, final ItemStack outputs[], final FluidStack[] fluidIn, final FluidStack fluidOut) { + if (inputs != null && outputs != null && fluidIn != null && fluidOut != null && inputs.length > 0 && outputs.length > 0) { + return true; + } + return false; + } + + public synchronized static boolean generateGTNHBlastSmelterRecipesFromEBFList() { + + //Make a counting object + int mSuccess = 0; + + Logger.INFO("[ABS] Starting recipe generation based on EBF recipe map."); + Logger.INFO("[ABS] Caching Ingots and their Molten fluid.."); + //First, we make sure that we have a valid recipe map of Ingots/Dusts -> Fluids + if (GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes.mRecipeList.size() > 0) { + //So, let's check every recipe + for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes.mRecipeList) { + ItemStack validInput = null; + FluidStack validOutput = null; + //If we the input is an ingot and it and the output are valid, map it to cache. + if (x.mInputs[0] != null) { + for(int tag: OreDictionary.getOreIDs(x.mInputs[0])) { + String oreName = OreDictionary.getOreName(tag).toLowerCase(); + String mType = "dust"; + if (CORE.GTNH) { + mType = "ingot"; + } + if(oreName.startsWith(mType) && !oreName.contains("double") && !oreName.contains("triple") && !oreName.contains("quad") && !oreName.contains("quintuple")) { + validInput = x.mInputs[0]; + } + } + } + if (x.mFluidOutputs[0] != null) { + validOutput = x.mFluidOutputs[0]; + } + if (validInput != null && validOutput != null) { + ItemStackData R = new ItemStackData(validInput); + setIngotToFluid(R, validOutput); + Logger.MACHINE_INFO("[ABS][I2F] Cached "+validInput.getDisplayName()+" to "+validOutput.getLocalizedName()+". Stored Under ID of "+R.getUniqueDataIdentifier()); + } + } + } + + Logger.INFO("[ABS] Caching Ingots and their Hot form..."); + //Second, we make sure that we have a valid recipe map of Hot Ingots -> Cold Ingots + if (GT_Recipe.GT_Recipe_Map.sVacuumRecipes.mRecipeList.size() > 0) { + //So, let's check every recipe + for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sVacuumRecipes.mRecipeList) { + ItemStack validInput = null; + ItemStack validOutput = null; + //If we the input is an ingot and it and the output are valid, map it to cache. + if (x.mInputs != null && x.mInputs.length > 0 && x.mInputs[0] != null) { + validInput = x.mInputs[0]; + } + if (x.mOutputs != null && x.mOutputs.length > 0 && x.mOutputs[0] != null) { + validOutput = x.mOutputs[0]; + } + if (validInput != null && validOutput != null) { + ItemStackData R1 = new ItemStackData(validInput); + ItemStackData R2 = new ItemStackData(validOutput); + setHotToCold(R1, R2); + Logger.MACHINE_INFO("[ABS][H2C] Cached "+validInput.getDisplayName()+" to "+validOutput.getDisplayName()+". Stored Under ID of "+R1.getUniqueDataIdentifier()+", links to ID "+R2.getUniqueDataIdentifier()); + } + } + } + + Logger.INFO("[ABS] Generating recipes based on existing EBF recipes."); + //Okay, so now lets Iterate existing EBF recipes. + if (GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.size() > 0) { + for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList) { + if (x == null) { + continue; + } + ItemStack[] inputs, outputs; + FluidStack[] inputsF; + int voltage, time, special; + boolean enabled; + inputs = x.mInputs; + outputs = x.mOutputs; + inputsF = x.mFluidInputs; + voltage = x.mEUt; + time = x.mDuration; + enabled = x.mEnabled; + special = x.mSpecialValue; + + //Check for GTNH, if it's found, continue to next recipe if the Temp is too high. + if (CORE.GTNH && special > 3600) { + Logger.MACHINE_INFO("[ABS] Skipping ABS addition for GTNH due to temp."); + continue; + } + else { + FluidStack mMoltenStack = null; + int mMoltenCount = 0; + //If We have a valid Output, let's try use our cached data to get it's molten form. + if (x.mOutputs != null && x.mOutputs[0] != null) { + mMoltenCount = x.mOutputs[0].stackSize; + ItemStackData R = new ItemStackData(x.mOutputs[0]); + Logger.MACHINE_INFO("[ABS] Found "+x.mOutputs[0].getDisplayName()+" as valid EBF output, finding it's fluid from the cache. We will require "+(144*mMoltenCount)+"L. Looking for ID "+R.getUniqueDataIdentifier()); + FluidStack tempFluid = getFluidFromIngot(R); + if (tempFluid != null) { + //Logger.MACHINE_INFO("[ABS] Got Fluid from Cache."); + mMoltenStack = FluidUtils.getFluidStack(tempFluid, mMoltenCount*144); + } + else { + Logger.MACHINE_INFO("[ABS] Failed to get Fluid from Cache."); + } + } + //If this recipe is enabled and we have a valid molten fluidstack, let's try add this recipe. + if (enabled && isValid(inputs, outputs, inputsF, mMoltenStack)) { + //Build correct input stack + ItemStack[] newInput = new ItemStack[inputs.length+1]; + int l = 1; + for (ItemStack y : inputs) { + newInput[l++] = y; + } + newInput[0] = CI.getNumberedCircuit(inputs.length); + //Logger.MACHINE_INFO("[ABS] Generating ABS recipe for "+mMoltenStack.getLocalizedName()+"."); + if (CORE.RA.addBlastSmelterRecipe(newInput, (inputsF.length > 0 ? inputsF[0] : null), mMoltenStack, 100, MathUtils.roundToClosestInt(time*0.8), voltage, special)) { + //Logger.MACHINE_INFO("[ABS] Success."); + mSuccess++; + } + else { + Logger.MACHINE_INFO("[ABS] Failure."); + } + } + else { + if (!enabled) { + Logger.MACHINE_INFO("[ABS] Failure. EBF recipe was not enabled."); + } + else { + Logger.MACHINE_INFO("[ABS] Failure. Invalid Inputs or Outputs."); + if (inputs == null) { + Logger.MACHINE_INFO("[ABS] Inputs were not Valid."); + } + else { + Logger.MACHINE_INFO("[ABS] inputs size: "+inputs.length); + } + if (outputs == null) { + Logger.MACHINE_INFO("[ABS] Outputs were not Valid."); + } + else { + Logger.MACHINE_INFO("[ABS] outputs size: "+outputs.length); + } + if (inputsF == null) { + Logger.MACHINE_INFO("[ABS] Input Fluids were not Valid."); + } + else { + Logger.MACHINE_INFO("[ABS] inputsF size: "+inputsF.length); + } + if (mMoltenStack == null) { + Logger.MACHINE_INFO("[ABS] Output Fluid were not Valid."); + } + } + } + } + } + } + else { + Logger.MACHINE_INFO("[ABS] Failure. Did not find any EBF recipes to iterate."); + } + + Logger.INFO("[ABS] Processed "+mSuccess+" recipes."); + return mSuccess > 0; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java new file mode 100644 index 0000000000..24c8eb488f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java @@ -0,0 +1,444 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeGen_DustGeneration extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_DustGeneration(final Material M){ + this(M, false); + } + + public RecipeGen_DustGeneration(final Material M, final boolean O){ + this.toGenerate = M; + this.disableOptional = O; + mRecipeGenMap.add(this); + final ItemStack normalDust = M.getDust(1); + final ItemStack smallDust = M.getSmallDust(1); + final ItemStack tinyDust = M.getTinyDust(1); + if (tinyDust != null && normalDust != null) { + if (RecipeUtils.addShapedRecipe( + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + normalDust)){ + Logger.INFO("9 Tiny dust to 1 Dust Recipe: "+M.getLocalizedName()+" - Success"); + } + else { + Logger.INFO("9 Tiny dust to 1 Dust Recipe: "+M.getLocalizedName()+" - Failed"); + } + + if (RecipeUtils.addShapedRecipe( + normalDust, null, null, + null, null, null, + null, null, null, + M.getTinyDust(9))){ + Logger.INFO("9 Tiny dust from 1 Recipe: "+M.getLocalizedName()+" - Success"); + } + else { + Logger.INFO("9 Tiny dust from 1 Recipe: "+M.getLocalizedName()+" - Failed"); + } + } + + if (smallDust != null && normalDust != null) { + if (RecipeUtils.addShapedRecipe( + smallDust, smallDust, null, + smallDust, smallDust, null, + null, null, null, + normalDust)){ + Logger.INFO("4 Small dust to 1 Dust Recipe: "+M.getLocalizedName()+" - Success"); + } + else { + Logger.INFO("4 Small dust to 1 Dust Recipe: "+M.getLocalizedName()+" - Failed"); + } + if (RecipeUtils.addShapedRecipe( + null, normalDust, null, + null, null, null, + null, null, null, + M.getSmallDust(4))){ + Logger.INFO("4 Small dust from 1 Dust Recipe: "+M.getLocalizedName()+" - Success"); + } + else { + Logger.INFO("4 Small dust from 1 Dust Recipe: "+M.getLocalizedName()+" - Failed"); + } + } + } + + @Override + public void run() { + generateRecipes(this.toGenerate, this.disableOptional); + } + + private void generateRecipes(final Material material, final boolean disableOptional){ + + Logger.INFO("Generating Shaped Crafting recipes for "+material.getLocalizedName()); + + final ItemStack normalDust = material.getDust(1); + final ItemStack smallDust = material.getSmallDust(1); + final ItemStack tinyDust = material.getTinyDust(1); + + final ItemStack[] inputStacks = material.getMaterialComposites(); + final ItemStack outputStacks = material.getDust(material.smallestStackSizeWhenProcessing); + + //Macerate blocks back to dusts. + final ItemStack materialBlock = material.getBlock(1); + final ItemStack materialFrameBox = material.getFrameBox(1); + + if (ItemUtils.checkForInvalidItems(materialBlock)) { + GT_ModHandler.addPulverisationRecipe(materialBlock, material.getDust(9)); + } + + if (ItemUtils.checkForInvalidItems(materialFrameBox)) { + GT_ModHandler.addPulverisationRecipe(materialFrameBox, material.getDust(2)); + } + + if (ItemUtils.checkForInvalidItems(smallDust) && ItemUtils.checkForInvalidItems(tinyDust)) { + generatePackagerRecipes(material); + } + + ItemStack ingot = material.getIngot(1); + if (ItemUtils.checkForInvalidItems(normalDust) && ItemUtils.checkForInvalidItems(ingot)) { + addFurnaceRecipe(material); + addMacerationRecipe(material); + } + + //Is this a composite? + if ((inputStacks != null) && !disableOptional){ + //Is this a composite? + Logger.WARNING("mixer length: "+inputStacks.length); + if ((inputStacks.length != 0) && (inputStacks.length <= 4)){ + //Log Input items + Logger.WARNING(ItemUtils.getArrayStackNames(inputStacks)); + final long[] inputStackSize = material.vSmallestRatio; + Logger.WARNING("mixer is stacksizeVar null? "+(inputStackSize != null)); + //Is smallest ratio invalid? + if (inputStackSize != null){ + //set stack sizes on an input ItemStack[] + for (short x=0;x<inputStacks.length;x++){ + if ((inputStacks[x] != null) && (inputStackSize[x] != 0)){ + inputStacks[x].stackSize = (int) inputStackSize[x]; + } + } + //Relog input values, with stack sizes + Logger.WARNING(ItemUtils.getArrayStackNames(inputStacks)); + + //Get us four ItemStacks to input into the mixer + ItemStack[] input = new ItemStack[4]; + + input[0] = (inputStacks.length >= 1) ? ((inputStacks[0] == null) ? null : inputStacks[0]) : null; + input[1] = (inputStacks.length >= 2) ? ((inputStacks[1] == null) ? null : inputStacks[1]) : null; + input[2] = (inputStacks.length >= 3) ? ((inputStacks[2] == null) ? null : inputStacks[2]) : null; + input[3] = (inputStacks.length >= 4) ? ((inputStacks[3] == null) ? null : inputStacks[3]) : null; + + + if (inputStacks.length == 1) { + input[1] = input[0]; + input[0] = CI.getNumberedCircuit(inputStacks.length+10); + } + else if (inputStacks.length == 2) { + input[2] = input[1]; + input[1] = input[0]; + input[0] = CI.getNumberedCircuit(inputStacks.length+10); + + } + else if (inputStacks.length == 3) { + input[3] = input[2]; + input[2] = input[1]; + input[1] = input[0]; + input[0] = CI.getNumberedCircuit(inputStacks.length+10); + } + + + /*for (int g = 0; g<4; g++) { + if(inputStacks.length > g) { + input[g] = inputStacks[g] != null ? inputStacks[g] : null; + } + else { + input[g] = CI.getNumberedCircuit(g+10); + break; + } + }*/ + + //Add mixer Recipe + FluidStack oxygen = GT_Values.NF; + if (material.getComposites() != null){ + for (final MaterialStack x : material.getComposites()){ + if (!material.getComposites().isEmpty()){ + if (x != null){ + if (x.getStackMaterial() != null){ + if (x.getStackMaterial().getDust(1) == null){ + if (x.getStackMaterial().getState() != MaterialState.SOLID && x.getStackMaterial().getState() != MaterialState.ORE && x.getStackMaterial().getState() != MaterialState.PLASMA){ + oxygen = x.getStackMaterial().getFluidStack(1000); + break; + } + } + } + } + } + } + } + + input = ItemUtils.cleanItemStackArray(input); + + //Add mixer Recipe + if (GT_Values.RA.addMixerRecipe( + input[0], input[1], + input[2], input[3], + oxygen, + null, + outputStacks, + (int) Math.max(material.getMass() * 2L * 1, 1), + material.vVoltageMultiplier)) //Was 6, but let's try 2. This makes Potin LV, for example. + { + Logger.WARNING("Dust Mixer Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Dust Mixer Recipe: "+material.getLocalizedName()+" - Failed"); + } + + //Add Shapeless recipe for low tier alloys. + /*if (tVoltageMultiplier <= 30){ + if (RecipeUtils.addShapedGregtechRecipe(inputStacks, outputStacks)){ + Logger.WARNING("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Failed"); + } + }*/ + } + } + } + + + + + + + } + + public static boolean addMixerRecipe_Standalone(final Material material){ + final ItemStack[] inputStacks = material.getMaterialComposites(); + final ItemStack outputStacks = material.getDust(material.smallestStackSizeWhenProcessing); + //Is this a composite? + if ((inputStacks != null)){ + //Is this a composite? + Logger.WARNING("mixer length: "+inputStacks.length); + if ((inputStacks.length >= 1) && (inputStacks.length <= 4)){ + //Log Input items + Logger.WARNING(ItemUtils.getArrayStackNames(inputStacks)); + final long[] inputStackSize = material.vSmallestRatio; + Logger.WARNING("mixer is stacksizeVar not null? "+(inputStackSize != null)); + //Is smallest ratio invalid? + if (inputStackSize != null){ + //set stack sizes on an input ItemStack[] + for (short x=0;x<inputStacks.length;x++){ + if ((inputStacks[x] != null) && (inputStackSize[x] != 0)){ + inputStacks[x].stackSize = (int) inputStackSize[x]; + } + } + //Relog input values, with stack sizes + Logger.WARNING(ItemUtils.getArrayStackNames(inputStacks)); + + //Get us four ItemStacks to input into the mixer + ItemStack input1, input2, input3, input4; + input1 = inputStacks[0]; + input2 = (inputStacks.length >= 2) ? (input2 = (inputStacks[1] == null) ? null : inputStacks[1]) : null; + input3 = (inputStacks.length >= 3) ? (input3 = (inputStacks[2] == null) ? null : inputStacks[2]) : null; + input4 = (inputStacks.length >= 4) ? (input4 = (inputStacks[3] == null) ? null : inputStacks[3]) : null; + + if (inputStacks.length == 1) { + input2 = input1; + input1 = CI.getNumberedCircuit(20); + } + else if (inputStacks.length == 2) { + input3 = input2; + input2 = input1; + input1 = CI.getNumberedCircuit(20); + + } + else if (inputStacks.length == 3) { + input4 = input3; + input3 = input2; + input2 = input1; + input1 = CI.getNumberedCircuit(20); + } + + //Add mixer Recipe + FluidStack oxygen = GT_Values.NF; + if (material.getComposites() != null){ + int compSlot = 0; + for (final MaterialStack x : material.getComposites()){ + if (!material.getComposites().isEmpty()){ + if (x != null){ + if (x.getStackMaterial() != null){ + if (x.getStackMaterial().getDust(1) == null){ + MaterialState f = x.getStackMaterial().getState(); + if (f == MaterialState.GAS || f == MaterialState.LIQUID || f == MaterialState.PURE_LIQUID || f == MaterialState.PURE_GAS){ + oxygen = x.getStackMaterial().getFluidStack((int) (material.vSmallestRatio[compSlot] * 1000)); + } + } + } + } + } + compSlot++; + } + + } + + //Add mixer Recipe + try { + if (GT_Values.RA.addMixerRecipe( + input1, input2, + input3, input4, + oxygen, + null, + outputStacks, + (int) Math.max(material.getMass() * 2L * 1, 1), + material.vVoltageMultiplier)) //Was 6, but let's try 2. This makes Potin LV, for example. + { + Logger.WARNING("Dust Mixer Recipe: "+material.getLocalizedName()+" - Success"); + return true; + } + else { + Logger.WARNING("Dust Mixer Recipe: "+material.getLocalizedName()+" - Failed"); + return false; + } + } + catch (Throwable t) { + t.printStackTrace(); + } + } + else { + Logger.WARNING("inputStackSize == NUll - "+material.getLocalizedName()); + } + } + else { + Logger.WARNING("InputStacks is out range 1-4 - "+material.getLocalizedName()); + } + } + else { + Logger.WARNING("InputStacks == NUll - "+material.getLocalizedName()); + } + return false; + } + + public static boolean generatePackagerRecipes(Material aMatInfo) { + AutoMap<Boolean> aResults = new AutoMap<Boolean>(); + //Small Dust + aResults.put(GT_Values.RA.addBoxingRecipe(GT_Utility.copyAmount(4L, new Object[]{aMatInfo.getSmallDust(4)}), ItemList.Schematic_Dust.get(0L, new Object[0]), aMatInfo.getDust(1), 100, 4)); + //Tiny Dust + aResults.put(GT_Values.RA.addBoxingRecipe(GT_Utility.copyAmount(9L, new Object[]{aMatInfo.getTinyDust(9)}), ItemList.Schematic_Dust.get(0L, new Object[0]), aMatInfo.getDust(1), 100, 4)); + + for (boolean b : aResults) { + if (!b) { + return false; + } + } + return true; + } + + private void addMacerationRecipe(Material aMatInfo){ + try { + Logger.MATERIALS("Adding Maceration recipe for "+aMatInfo.getLocalizedName()+" Ingot -> Dusts"); + final int chance = (aMatInfo.vTier*10)/MathUtils.randInt(10, 20); + GT_ModHandler.addPulverisationRecipe(aMatInfo.getIngot(1), aMatInfo.getDust(1), null, chance); + } + catch (Throwable t) { + t.printStackTrace(); + } + } + + private void addFurnaceRecipe(Material aMatInfo){ + + ItemStack aDust = aMatInfo.getDust(1); + ItemStack aOutput; + try { + if (aMatInfo.requiresBlastFurnace()) { + aOutput = aMatInfo.getHotIngot(1); + if (ItemUtils.checkForInvalidItems(aOutput)) { + if (addBlastFurnaceRecipe(aMatInfo, aDust, null, aOutput, null, aMatInfo.getMeltingPointK())){ + Logger.MATERIALS("Successfully added a blast furnace recipe for "+aMatInfo.getLocalizedName()); + } + else { + Logger.MATERIALS("Failed to add a blast furnace recipe for "+aMatInfo.getLocalizedName()); + } + } + else { + Logger.MATERIALS("Failed to add a blast furnace recipe for "+aMatInfo.getLocalizedName()); + } + } + else { + aOutput = aMatInfo.getIngot(1); + if (ItemUtils.checkForInvalidItems(aOutput)) { + if (CORE.RA.addSmeltingAndAlloySmeltingRecipe(aDust, aOutput)){ + Logger.MATERIALS("Successfully added a furnace recipe for "+aMatInfo.getLocalizedName()); + } + else { + Logger.MATERIALS("Failed to add a furnace recipe for "+aMatInfo.getLocalizedName()); + } + } + } + } + catch (Throwable t) { + t.printStackTrace(); + } + + } + + private boolean addBlastFurnaceRecipe(Material aMatInfo, final ItemStack input1, final ItemStack input2, final ItemStack output1, final ItemStack output2, final int tempRequired){ + + try { + int timeTaken = 125*aMatInfo.vTier*10; + + if (aMatInfo.vTier <= 4){ + timeTaken = 25*aMatInfo.vTier*10; + } + int aSlot = aMatInfo.vTier; + if (aSlot < 2) { + aSlot = 2; + } + long aVoltage = aMatInfo.vVoltageMultiplier; + + return GT_Values.RA.addBlastRecipe( + input1, + input2, + GT_Values.NF, GT_Values.NF, + output1, + output2, + timeTaken, + (int) aVoltage, + tempRequired); + } + catch (Throwable t) { + t.printStackTrace(); + return false; + } + } + +} + diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Extruder.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Extruder.java new file mode 100644 index 0000000000..cd43d6201c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Extruder.java @@ -0,0 +1,176 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.item.ItemStack; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_Recipe; + +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class RecipeGen_Extruder extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_Extruder(final Material M){ + this.toGenerate = M; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + private void generateRecipes(final Material material){ + + final ItemStack itemIngot = material.getIngot(1); + final ItemStack itemPlate = material.getPlate(1); + final ItemStack itemGear = material.getGear(1); + + final ItemStack shape_Plate = ItemList.Shape_Extruder_Plate.get(0); + final ItemStack shape_Ring = ItemList.Shape_Extruder_Ring.get(0); + final ItemStack shape_Gear = ItemList.Shape_Extruder_Gear.get(0); + final ItemStack shape_Rod = ItemList.Shape_Extruder_Rod.get(0); + final ItemStack shape_Bolt = ItemList.Shape_Extruder_Bolt.get(0); + final ItemStack shape_Block = ItemList.Shape_Extruder_Block.get(0); + final ItemStack shape_Ingot = ItemList.Shape_Extruder_Ingot.get(0); + + Logger.WARNING("Generating Extruder recipes for "+material.getLocalizedName()); + + + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getBlock(1))) { + //Ingot Recipe + if (addExtruderRecipe( + material.getBlock(1), + shape_Ingot, + material.getIngot(9), + (int) Math.max(material.getMass() * 2L * 1, 1), + material.vVoltageMultiplier)){ + Logger.WARNING("Extruder Ingot Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Extruder Ingot Recipe: "+material.getLocalizedName()+" - Failed"); + } + + //Block Recipe + if (addExtruderRecipe( + material.getIngot(9), + shape_Block, + material.getBlock(1), + (int) Math.max(material.getMass() * 2L * 1, 1), + material.vVoltageMultiplier)){ + Logger.WARNING("Extruder Block Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Extruder Block Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + + //Plate Recipe + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getPlate(1))) + if (addExtruderRecipe( + itemIngot, + shape_Plate, + itemPlate, + 10, + material.vVoltageMultiplier)){ + Logger.WARNING("Extruder Plate Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Extruder Plate Recipe: "+material.getLocalizedName()+" - Failed"); + } + + //Ring Recipe + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getRing(1))) + if (!material.isRadioactive){ + if (addExtruderRecipe( + itemIngot, + shape_Ring, + material.getRing(4), + (int) Math.max(material.getMass() * 2L * 1, 1), + material.vVoltageMultiplier)){ + Logger.WARNING("Extruder Ring Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Extruder Ring Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + + //Gear Recipe + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getGear(1))) + if (!material.isRadioactive){ + if (addExtruderRecipe( + material.getIngot(4), + shape_Gear, + itemGear, + (int) Math.max(material.getMass() * 5L, 1), + material.vVoltageMultiplier)){ + Logger.WARNING("Extruder Gear Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Extruder Gear Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + + //Rod Recipe + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) + if (addExtruderRecipe( + itemIngot, + shape_Rod, + material.getRod(2), + (int) Math.max(material.getMass() * 2L * 1, 1), + material.vVoltageMultiplier)){ + Logger.WARNING("Extruder Rod Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Extruder Rod Recipe: "+material.getLocalizedName()+" - Failed"); + } + + + //Bolt Recipe + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getBolt(1))) + if (!material.isRadioactive){ + if (addExtruderRecipe( + itemIngot, + shape_Bolt, + material.getBolt(8), + (int) Math.max(material.getMass() * 2L * 1, 1), + material.vVoltageMultiplier)){ + Logger.WARNING("Extruder Bolt Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Extruder Bolt Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + } + + + public static boolean addExtruderRecipe(final ItemStack aInput, final ItemStack aShape, final ItemStack aOutput, int aDuration, final int aEUt) { + if ((aInput == null) || (aShape == null) || (aOutput == null)) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("extruder", aOutput, aDuration)) <= 0) { + return false; + } + GT_Recipe.GT_Recipe_Map.sExtruderRecipes.addRecipe(true, new ItemStack[]{aInput, aShape}, new ItemStack[]{aOutput}, null, null, null, aDuration, aEUt, 0); + return true; + } + + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java new file mode 100644 index 0000000000..9fe86985f4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java @@ -0,0 +1,230 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeGen_FluidCanning implements Runnable { + + public static void init() { + FluidCanningRunnableHandler x = new FluidCanningRunnableHandler(); + x.run(); + } + + private static class FluidCanningRunnableHandler implements RunnableWithInfo<String> { + + @Override + public void run() { + mHasRun = true; + for (RecipeGen_FluidCanning aRecipe : mCache) { + aRecipe.run(); + } + } + + @Override + public String getInfoData() { + return "Fluid Canning Recipes"; + } + } + + private static boolean mHasRun = false; + + private static HashSet<RecipeGen_FluidCanning> mCache = new HashSet<RecipeGen_FluidCanning>(); + + private static void addRunnableToRecipeCache(RecipeGen_FluidCanning r) { + if (mHasRun) { + CORE.crash(); + } + mCache.add(r); + } + + protected boolean disableOptional; + + private final GT_Recipe recipe; + private final boolean isValid; + + public boolean valid() { + return isValid; + } + public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluid) { + this(aExtracting, aEmpty, aFull, aFluid, GT_Values.NF, null, null); + } + + public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluidIn, FluidStack aFluidOut) { + this(aExtracting, aEmpty, aFull, aFluidIn, aFluidOut, null, null); + } + + public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluid, Integer aDuration, Integer aEUt) { + this(aExtracting, aEmpty, aFull, aFluid, GT_Values.NF, aDuration, aEUt); + } + + // Alternative Constructor + public RecipeGen_FluidCanning(boolean aExtracting, ItemStack aEmpty, ItemStack aFull, FluidStack aFluidIn, FluidStack aFluidOut, Integer aDuration, Integer aEUt) { + ItemStack aInput; + ItemStack aOutput; + FluidStack aFluidInput; + FluidStack aFluidOutput; + + // Safety check on the duration + if (aDuration == null || aDuration <= 0) { + aDuration = (aFluidIn != null) ? (aFluidIn.amount / 62) : ((aFluidOut != null) ? (aFluidOut.amount / 62) : 10); + } + + // Safety check on the EU + if (aEUt == null || aEUt <= 0) { + if (aExtracting) { + aEUt = 2; + } + else { + aEUt = 1; + } + } + + // Set Item stacks correctly, invert if extraction recipe. + if (aExtracting) { + aInput = aFull; + aOutput = aEmpty; + aFluidInput = GT_Values.NF; + aFluidOutput = aFluidIn; + } + else { + aInput = aEmpty; + aOutput = aFull; + aFluidInput = aFluidIn; + aFluidOutput = aFluidOut != null ? aFluidOut : GT_Values.NF; + } + + //Check validity + + GTPP_Recipe aRecipe = new GTPP_Recipe( + true, + new ItemStack[] { aInput }, + new ItemStack[] { aOutput }, + null, + new int[] {10000}, + new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, + aDuration, + aEUt, + 0); + + + // Check Valid + boolean aTempValidityCheck = false; + //Logger.INFO("Validity Check."); + if (aExtracting) { + Logger.INFO("Extracting."); + if (aInput != null && aFluidOutput != null) { + //Logger.INFO("Pass."); + aTempValidityCheck = true; + } + } + else { + //Logger.INFO("Canning."); + if (aInput != null && aOutput != null && (aFluidInput != null || aFluidOutput != null)) { + //Logger.INFO("Pass."); + aTempValidityCheck = true; + } + } + + + if (aTempValidityCheck) { + // Valid Recipe + recipe = aRecipe; + disableOptional = aExtracting; + isValid = true; + //Logger.INFO("Passed Validity Check. Hash: "+recipe.hashCode()); + //Logger.INFO("Mapped as: "+(disableOptional ? "Extracting" : "Canning")); + addRunnableToRecipeCache(this); + } + else { + //Logger.INFO("Failed Validity Check."); + isValid = false; + disableOptional = aExtracting; + aRecipe.mEnabled = false; + aRecipe.mHidden = true; + recipe = null; + } + } + + @Override + public void run() { + Logger.INFO("Processing Recipe with Hash: "+recipe.hashCode()); + generateRecipes(); + } + + private void generateRecipes() { + if (isValid && recipe != null) { + //Logger.INFO("Processing "+(disableOptional ? "Extracting" : "Canning")+" Recipe."); + if (this.disableOptional) { + addFluidExtractionRecipe(recipe); + } + else { + addFluidCannerRecipe(recipe); + } + } + } + + private final boolean addFluidExtractionRecipe(GT_Recipe aRecipe) { + boolean result = false; + int aCount1 = GT_Recipe_Map.sFluidExtractionRecipes.mRecipeList.size(); + int aCount2 = aCount1; + GT_Recipe_Map.sFluidExtractionRecipes.addRecipe(aRecipe); + aCount1 = GT_Recipe_Map.sFluidExtractionRecipes.mRecipeList.size(); + result = aCount1 > aCount2; + if (result) { + //Logger.INFO("[FIND] Added Extraction recipe for "+ItemUtils.getArrayStackNames(aRecipe.mInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mOutputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidOutputs)); + } + else { + Logger.INFO("[ERROR] Failed adding Extraction recipe for "+ItemUtils.getArrayStackNames(aRecipe.mInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mOutputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidOutputs)); + //dumpStack(); + } + return result; + } + + private final boolean addFluidCannerRecipe(GT_Recipe aRecipe) { + boolean result = false; + int aCount1 = GT_Recipe_Map.sFluidCannerRecipes.mRecipeList.size(); + int aCount2 = aCount1; + GT_Recipe_Map.sFluidCannerRecipes.addRecipe(aRecipe); + aCount1 = GT_Recipe_Map.sFluidCannerRecipes.mRecipeList.size(); + result = aCount1 > aCount2; + if (result) { + //Logger.INFO("[FIND] Added Canning recipe for "+ItemUtils.getArrayStackNames(aRecipe.mInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mOutputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidOutputs)); + } + else { + Logger.INFO("[ERROR] Failed adding Canning recipe for "+ItemUtils.getArrayStackNames(aRecipe.mInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mOutputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidInputs)+", "+ItemUtils.getArrayStackNames(aRecipe.mFluidOutputs)); + //dumpStack(); + } + return result; + } + + private void dumpStack() { + int parents = 2; + for (int i=0;i<6;i++) { + Logger.INFO((disableOptional ? "EXTRACTING" : "CANNING")+" DEBUG | "+(i == 0 ? "Called from: " : "Parent: ")+ReflectionUtils.getMethodName(i+parents)); + } + + } + + private String buildLogString() { + int solidSize = getMapSize(GT_Recipe_Map.sCannerRecipes); + int fluidSize = getMapSize(GT_Recipe_Map.sFluidCannerRecipes); + return (disableOptional ? "EXTRACTING" : "CANNING")+" DEBUG | Solids: "+solidSize+" | Liquids: "+fluidSize+" | "; + } + + private final int getMapSize(GT_Recipe_Map aMap) { + return aMap.mRecipeList.size(); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java new file mode 100644 index 0000000000..e87fc08c90 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java @@ -0,0 +1,298 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class RecipeGen_Fluids extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_Fluids(final Material M) { + this(M, false); + } + + public RecipeGen_Fluids(final Material M, final boolean dO) { + this.toGenerate = M; + this.disableOptional = dO; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate, this.disableOptional); + } + + private void generateRecipes(final Material material, final boolean dO) { + + if (material == null) { + return; + } + + // Melting Shapes to fluid + if (material.getFluidStack(1) != null + && !material.getFluidStack(1).getUnlocalizedName().toLowerCase().contains("plasma")) { + + if (!material.requiresBlastFurnace()) { + + // Ingot + if (ItemUtils.checkForInvalidItems(material.getIngot(1))) + if (CORE.RA.addFluidExtractionRecipe( + material.getIngot(1), // Input + material.getFluidStack(144), // Fluid Output + 1 * 20, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING("144l fluid extractor from 1 ingot Recipe: " + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING("144l fluid extractor from 1 ingot Recipe: " + material.getLocalizedName() + + " - Failed"); + } + + // Plate + if (ItemUtils.checkForInvalidItems(material.getPlate(1))) + if (CORE.RA.addFluidExtractionRecipe( + material.getPlate(1), // Input + material.getFluidStack(144), // Fluid Output + 1 * 20, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING("144l fluid extractor from 1 plate Recipe: " + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING("144l fluid extractor from 1 plate Recipe: " + material.getLocalizedName() + + " - Failed"); + } + + // Double Plate + if (ItemUtils.checkForInvalidItems(material.getPlateDouble(1))) + if (CORE.RA.addFluidExtractionRecipe( + material.getPlateDouble(1), // Input + material.getFluidStack(288), // Fluid Output + 1 * 20, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING("144l fluid extractor from 1 double plate Recipe: " + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING("144l fluid extractor from 1 double plate Recipe: " + material.getLocalizedName() + + " - Failed"); + } + + // Nugget + if (ItemUtils.checkForInvalidItems(material.getNugget(1))) + if (CORE.RA.addFluidExtractionRecipe( + material.getNugget(1), // Input + material.getFluidStack(16), // Fluid Output + 16, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING("16l fluid extractor from 1 nugget Recipe: " + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING("16l fluid extractor from 1 nugget Recipe: " + material.getLocalizedName() + + " - Failed"); + } + + // Block + if (ItemUtils.checkForInvalidItems(material.getBlock(1))) + if (CORE.RA.addFluidExtractionRecipe( + material.getBlock(1), // Input + material.getFluidStack(144 * 9), // Fluid Output + 288, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING((144 * 9) + "l fluid extractor from 1 block Recipe: " + + material.getLocalizedName() + " - Success"); + } else { + Logger.WARNING((144 * 9) + "l fluid extractor from 1 block Recipe: " + + material.getLocalizedName() + " - Failed"); + } + + } + + // Making Shapes from fluid + + // Ingot + if (ItemUtils.checkForInvalidItems(material.getIngot(1))) + if (GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Ingot.get(0), // Item Shape + material.getFluidStack(144), // Fluid Input + material.getIngot(1), // output + 32, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + "144l fluid molder for 1 ingot Recipe: " + material.getLocalizedName() + " - Success"); + } else { + Logger.WARNING( + "144l fluid molder for 1 ingot Recipe: " + material.getLocalizedName() + " - Failed"); + } + + // Plate + if (ItemUtils.checkForInvalidItems(material.getPlate(1))) + if (GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Plate.get(0), // Item Shape + material.getFluidStack(144), // Fluid Input + material.getPlate(1), // output + 32, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + "144l fluid molder for 1 plate Recipe: " + material.getLocalizedName() + " - Success"); + } else { + Logger.WARNING( + "144l fluid molder for 1 plate Recipe: " + material.getLocalizedName() + " - Failed"); + } + + // Nugget + if (ItemUtils.checkForInvalidItems(material.getNugget(1))) + if (GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Nugget.get(0), // Item Shape + material.getFluidStack(16), // Fluid Input + material.getNugget(1), // output + 16, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + "16l fluid molder for 1 nugget Recipe: " + material.getLocalizedName() + " - Success"); + } else { + Logger.WARNING( + "16l fluid molder for 1 nugget Recipe: " + material.getLocalizedName() + " - Failed"); + } + + // Gears + if (ItemUtils.checkForInvalidItems(material.getGear(1))) + if (GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Gear.get(0), // Item Shape + material.getFluidStack(576), // Fluid Input + material.getGear(1), // output + 128, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + "576l fluid molder for 1 gear Recipe: " + material.getLocalizedName() + " - Success"); + } else { + Logger.WARNING("576l fluid molder for 1 gear Recipe: " + material.getLocalizedName() + " - Failed"); + } + + // Blocks + if (ItemUtils.checkForInvalidItems(material.getBlock(1))) + if (GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Block.get(0), // Item Shape + material.getFluidStack(144 * 9), // Fluid Input + material.getBlock(1), // output + 288, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING((144 * 9) + "l fluid molder from 1 block Recipe: " + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING((144 * 9) + "l fluid molder from 1 block Recipe: " + material.getLocalizedName() + + " - Failed"); + } + + if (CORE.GTNH) { + + // GTNH + + // Shape_Mold_Rod + // Shape_Mold_Rod_Long + // Shape_Mold_Bolt, + // Shape_Mold_Screw, + // Shape_Mold_Ring, + + + ItemList mold_Rod = ItemUtils.getValueOfItemList("Shape_Mold_Rod", null); + ItemList mold_Rod_Long = ItemUtils.getValueOfItemList("Shape_Mold_Rod_Long", null); + ItemList mold_Bolt = ItemUtils.getValueOfItemList("Shape_Mold_Bolt", null); + ItemList mold_Screw = ItemUtils.getValueOfItemList("Shape_Mold_Screw", null); + ItemList mold_Ring = ItemUtils.getValueOfItemList("Shape_Mold_Ring", null); + + // Rod + if (ItemUtils.checkForInvalidItems(material.getRod(1))) + if (mold_Rod != null && GT_Values.RA.addFluidSolidifierRecipe(mold_Rod.get(0), // Item Shape + material.getFluidStack(72), // Fluid Input + material.getRod(1), // output + 150, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING((144 * 9) + "l fluid molder from 1 rod Recipe: " + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING((144 * 9) + "l fluid molder from 1 rod Recipe: " + material.getLocalizedName() + + " - Failed"); + } + + // Rod Long + if (ItemUtils.checkForInvalidItems(material.getLongRod(1))) + if (mold_Rod_Long != null && GT_Values.RA.addFluidSolidifierRecipe(mold_Rod_Long.get(0), // Item + // Shape + material.getFluidStack(144), // Fluid Input + material.getLongRod(1), // output + 300, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING((144 * 9) + "l fluid molder from 1 rod long Recipe: " + + material.getLocalizedName() + " - Success"); + } else { + Logger.WARNING((144 * 9) + "l fluid molder from 1 rod long Recipe: " + + material.getLocalizedName() + " - Failed"); + } + + // Bolt + if (ItemUtils.checkForInvalidItems(material.getBolt(1))) + if (mold_Bolt != null && GT_Values.RA.addFluidSolidifierRecipe(mold_Bolt.get(0), // Item Shape + material.getFluidStack(18), // Fluid Input + material.getBolt(1), // output + 50, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING((144 * 9) + "l fluid molder from 1 bolt Recipe: " + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING((144 * 9) + "l fluid molder from 1 bolt Recipe: " + material.getLocalizedName() + + " - Failed"); + } + + // Screw + if (ItemUtils.checkForInvalidItems(material.getScrew(1))) + if (mold_Screw != null && GT_Values.RA.addFluidSolidifierRecipe(mold_Screw.get(0), // Item Shape + material.getFluidStack(18), // Fluid Input + material.getScrew(1), // output + 50, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING((144 * 9) + "l fluid molder from 1 screw Recipe: " + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING((144 * 9) + "l fluid molder from 1 screw Recipe: " + material.getLocalizedName() + + " - Failed"); + } + + // Ring + if (ItemUtils.checkForInvalidItems(material.getRing(1))) + if (mold_Ring != null && GT_Values.RA.addFluidSolidifierRecipe(mold_Ring.get(0), // Item Shape + material.getFluidStack(36), // Fluid Input + material.getRing(1), // output + 100, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING((144 * 9) + "l fluid molder from 1 ring Recipe: " + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING((144 * 9) + "l fluid molder from 1 ring Recipe: " + material.getLocalizedName() + + " - Failed"); + } + + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluorite.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluorite.java new file mode 100644 index 0000000000..b285d41652 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluorite.java @@ -0,0 +1,224 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +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.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.material.state.MaterialState; +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.RecipeUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeGen_Fluorite extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_Fluorite(final Material material){ + this.toGenerate = material; + mRecipeGenMap.add(this); + + + /** + * Shaped Crafting + */ + RecipeUtils.addShapedRecipe( + CI.craftingToolHammer_Hard, null, null, + material.getCrushedPurified(1), null, null, + null, null, null, + material.getDustPurified(1)); + + RecipeUtils.addShapedRecipe( + CI.craftingToolHammer_Hard, null, null, + material.getCrushed(1), null, null, + null, null, null, + material.getDustImpure(1)); + + RecipeUtils.addShapedRecipe( + CI.craftingToolHammer_Hard, null, null, + material.getCrushedCentrifuged(1), null, null, + null, null, null, + material.getDust(1)); + + + + final ItemStack normalDust = material.getDust(1); + final ItemStack smallDust = material.getSmallDust(1); + final ItemStack tinyDust = material.getTinyDust(1); + + if (RecipeUtils.addShapedRecipe( + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + normalDust)){ + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Failed"); + } + + if (RecipeUtils.addShapedRecipe( + normalDust, null, null, + null, null, null, + null, null, null, + material.getTinyDust(9))){ + Logger.WARNING("9 Tiny dust from 1 Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("9 Tiny dust from 1 Recipe: "+material.getLocalizedName()+" - Failed"); + } + + if (RecipeUtils.addShapedRecipe( + smallDust, smallDust, null, + smallDust, smallDust, null, + null, null, null, + normalDust)){ + Logger.WARNING("4 Small dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("4 Small dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Failed"); + } + + if (RecipeUtils.addShapedRecipe( + null, normalDust, null, + null, null, null, + null, null, null, + material.getSmallDust(4))){ + Logger.WARNING("4 Small dust from 1 Dust Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("4 Small dust from 1 Dust Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + public static void generateRecipes(final Material material){ + + int tVoltageMultiplier = MaterialUtils.getVoltageForTier(material.vTier); + + final ItemStack dustStone = ItemUtils.getItemStackOfAmountFromOreDict("dustStone", 1); + + + ItemStack tinyDustA = FLUORIDES.FLUORITE.getTinyDust(1); + ItemStack tinyDustB = FLUORIDES.FLUORITE.getTinyDust(1); + ItemStack matDust = FLUORIDES.FLUORITE.getDust(1); + ItemStack matDustA = FLUORIDES.FLUORITE.getDust(1); + + /** + * Package + */ + //Allow ore dusts to be packaged + if (ItemUtils.checkForInvalidItems(material.getSmallDust(1)) && ItemUtils.checkForInvalidItems(material.getTinyDust(1))) { + RecipeGen_DustGeneration.generatePackagerRecipes(material); + } + + + /** + * Macerate + */ + //Macerate ore to Crushed + if (GT_Values.RA.addPulveriserRecipe(material.getOre(1), new ItemStack[]{material.getCrushed(2)}, new int[]{10000}, 20*20, tVoltageMultiplier/2)){ + Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate ore to Crushed ore'"); + } + //Macerate Centrifuged to Pure Dust + if (GT_Values.RA.addPulveriserRecipe(material.getCrushedCentrifuged(1), new ItemStack[]{matDust, matDustA}, new int[]{10000, 1000}, 20*20, tVoltageMultiplier/2)){ + Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate Centrifuged ore to Pure Dust'"); + } + if (GT_ModHandler.addThermalCentrifugeRecipe(material.getCrushedPurified(1), (int) Math.min(5000L, Math.abs(material.getMass() * 20L)), material.getCrushedCentrifuged(1), tinyDustA, dustStone)){ + Logger.MATERIALS("[ThermalCentrifuge] Added Recipe: 'Washed ore to Centrifuged Ore' | Input: "+material.getCrushedPurified(1).getDisplayName()+" | Outputs: "+material.getCrushedCentrifuged(1).getDisplayName()+", "+tinyDustA.getDisplayName()+", "+dustStone.getDisplayName()+"."); + } + + GT_Values.RA.addChemicalBathRecipe( + FLUORIDES.FLUORITE.getCrushed(2), + FluidUtils.getFluidStack("hydrogen", 2000), + FLUORIDES.FLUORITE.getCrushedPurified(8), + FLUORIDES.FLUORITE.getDustImpure(4), + FLUORIDES.FLUORITE.getDustPurified(2), + new int[] { 10000, 5000, 1000 }, + 30 * 20, + 240); + + /** + * Forge Hammer + */ + if (GT_Values.RA.addForgeHammerRecipe(material.getCrushedCentrifuged(1), matDust, 10, tVoltageMultiplier/4)){ + Logger.MATERIALS("[ForgeHammer] Added Recipe: 'Crushed Centrifuged to Pure Dust'"); + } + + /** + * Centrifuge + */ + //Purified Dust to Clean + if (GT_Values.RA.addCentrifugeRecipe( + material.getDustPurified(1), null, + null, //In Fluid + null, //Out Fluid + matDust, tinyDustA,null, + null, null,null, + new int[]{10000, 10000}, //Chances + (int) Math.max(1L, material.getMass() * 8L), //Time + tVoltageMultiplier/2)){ //Eu + Logger.MATERIALS("[Centrifuge] Added Recipe: Purified Dust to Clean Dust"); + } + + //Impure Dust to Clean + if (GT_Values.RA.addCentrifugeRecipe( + material.getDustImpure(1), null, + null, //In Fluid + null, //Out Fluid + matDust, tinyDustB,null, + null, null,null, + new int[]{10000, 10000}, //Chances + (int) Math.max(1L, material.getMass() * 8L), //Time + tVoltageMultiplier/2)){ //Eu + Logger.MATERIALS("[Centrifuge] Added Recipe: Inpure Dust to Clean Dust"); + } + + // CaF2 + H2SO4 → CaSO4(solid) + 2 HF + FluidStack aGregtechHydro = FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 16000); + if (aGregtechHydro == null) { + aGregtechHydro = FluidUtils.getFluidStack("hydrofluoricacid", 16000); + } + + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(5), + FLUORIDES.FLUORITE.getDust(37), + }, + FluidUtils.getFluidStack("sulfuricacid", 8000), + aGregtechHydro, // Fluid output (slot 2) + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumSulfate", 15), + ItemUtils.getItemStackOfAmountFromOreDict("dustSilver", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustGold", 2), + ItemUtils.getItemStackOfAmountFromOreDict("dustTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 2) + }, + new int[] { 10000, 1000, 1000, 3000, 2000 }, + 10 * 60 * 20, + 240); // EU + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java new file mode 100644 index 0000000000..92d7f73ba4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java @@ -0,0 +1,260 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import gregtech.api.enums.GT_Values; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +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.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeGen_MaterialProcessing extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_MaterialProcessing(final Material M){ + this(M, false); + } + + public RecipeGen_MaterialProcessing(final Material M, final boolean O){ + this.toGenerate = M; + this.disableOptional = O; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate, this.disableOptional); + } + + private void generateRecipes(final Material material, final boolean disableOptional){ + if (disableOptional) { + return; + } + + if (material.getMaterialComposites().length > 1){ + Logger.MATERIALS("[Recipe Generator Debug] ["+material.getLocalizedName()+"]"); + final int tVoltageMultiplier = material.vVoltageMultiplier; + int[] partSizes = new int[99]; + if (material.vSmallestRatio != null) { + partSizes = new int[material.vSmallestRatio.length]; + for (int hu=0;hu<material.vSmallestRatio.length;hu++){ + partSizes[hu] = (int) material.vSmallestRatio[hu]; + } + } + AutoMap<Pair<Integer, Material>> componentMap = new AutoMap<Pair<Integer, Material>>(); + int alnsnfds = 0; + for (MaterialStack r : material.getComposites()){ + if (r != null){ + componentMap.put(new Pair<Integer, Material>(partSizes[alnsnfds], r.getStackMaterial())); + } + alnsnfds++; + } + + + + + + /** + * Centrifuge + */ + + //Process Dust + if (componentMap.size() > 0 && componentMap.size() <= 6){ + ItemStack mInternalOutputs[] = new ItemStack[6]; + int mChances[] = new int[6]; + int mCellCount = 0; + + int mTotalCount = 0; + + int mCounter = 0; + for (Pair<Integer, Material> f : componentMap){ + if (f.getValue().getState() != MaterialState.SOLID){ + Logger.MATERIALS("[Centrifuge] Found Fluid Component, adding "+f.getKey()+" cells of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getCell(f.getKey()); + mCellCount += f.getKey(); + mTotalCount += f.getKey(); + Logger.MATERIALS("[Centrifuge] In total, adding "+mCellCount+" cells for "+material.getLocalizedName()+" processing."); + } + else { + Logger.MATERIALS("[Centrifuge] Found Solid Component, adding "+f.getKey()+" dusts of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getDust(f.getKey()); + mTotalCount += f.getKey(); + } + } + + //Build Output Array + for (int g=0;g<mInternalOutputs.length;g++){ + Logger.MATERIALS("[Centrifuge] Is output["+g+"] valid with a chance? "+(mInternalOutputs[g] != null ? 10000 : 0)); + mChances[g] = (mInternalOutputs[g] != null ? 10000 : 0); + } + + ItemStack emptyCell = null; + if (mCellCount > 0){ + emptyCell = ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", mCellCount); + Logger.MATERIALS("[Centrifuge] Recipe now requires "+mCellCount+" empty cells as input."); + } + + ItemStack mainDust = material.getDust(material.smallestStackSizeWhenProcessing); + if (mainDust != null){ + Logger.MATERIALS("[Centrifuge] Recipe now requires "+material.smallestStackSizeWhenProcessing+"x "+mainDust.getDisplayName()+" as input."); + } + else { + mainDust = material.getDust(mTotalCount); + Logger.MATERIALS("[Centrifuge] Could not find valid input dust, trying alternative."); + if (mainDust != null){ + Logger.MATERIALS("[Centrifuge] Recipe now requires "+mTotalCount+"x "+mainDust.getDisplayName()+" as input."); + } + else { + Logger.MATERIALS("[Centrifuge] Could not find valid input dust, exiting."); + } + } + + for (int j=0;j<mInternalOutputs.length;j++){ + if (mInternalOutputs[j] == null){ + mInternalOutputs[j] = GT_Values.NI; + Logger.MATERIALS("[Centrifuge] Set slot "+j+" to null."); + } + else { + Logger.MATERIALS("[Centrifuge] Set slot "+j+" to "+mInternalOutputs[j].getDisplayName()+"."); + } + } + + try{ + if (addCentrifgeRecipe( + mainDust, + emptyCell, //input 2 + null, //Input fluid 1 + null, //Output fluid 1 + mInternalOutputs[0], + mInternalOutputs[1], + mInternalOutputs[2], + mInternalOutputs[3], + mInternalOutputs[4], + mInternalOutputs[5], + mChances, + 20*1*(tVoltageMultiplier/10), + tVoltageMultiplier)){ + Logger.MATERIALS("[Centrifuge] Generated Centrifuge recipe for "+material.getDust(1).getDisplayName()); + } + else { + Logger.MATERIALS("[Centrifuge] Failed to generate Centrifuge recipe for "+material.getDust(1).getDisplayName()); + } + } + catch(Throwable t){ + t.printStackTrace(); + } + } + else if (componentMap.size() > 6 && componentMap.size() <= 9){ + Logger.MATERIALS("[Issue][Electrolyzer] "+material.getLocalizedName()+" is composed of over 6 materials, so an electrolyzer recipe for processing cannot be generated. Trying to create one for the Dehydrator instead."); + + ItemStack mInternalOutputs[] = new ItemStack[9]; + int mChances[] = new int[9]; + int mCellCount = 0; + + int mTotalCount = 0; + + int mCounter = 0; + for (Pair<Integer, Material> f : componentMap){ + if (f.getValue().getState() != MaterialState.SOLID){ + Logger.MATERIALS("[Dehydrator] Found Fluid Component, adding "+f.getKey()+" cells of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getCell(f.getKey()); + mCellCount += f.getKey(); + mTotalCount += f.getKey(); + Logger.MATERIALS("[Dehydrator] In total, adding "+mCellCount+" cells for "+material.getLocalizedName()+" processing."); + } + else { + Logger.MATERIALS("[Dehydrator] Found Solid Component, adding "+f.getKey()+" dusts of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getDust(f.getKey()); + mTotalCount += f.getKey(); + } + } + + //Build Output Array + for (int g=0;g<mInternalOutputs.length;g++){ + Logger.MATERIALS("[Dehydrator] Is output["+g+"] valid with a chance? "+(mInternalOutputs[g] != null ? 10000 : 0)); + mChances[g] = (mInternalOutputs[g] != null ? 10000 : 0); + } + + ItemStack emptyCell = null; + if (mCellCount > 0){ + emptyCell = CI.emptyCells(mCellCount); + Logger.MATERIALS("[Dehydrator] Recipe now requires "+mCellCount+" empty cells as input."); + } + + ItemStack mainDust = material.getDust(material.smallestStackSizeWhenProcessing); + if (mainDust != null){ + Logger.MATERIALS("[Dehydrator] Recipe now requires "+material.smallestStackSizeWhenProcessing+"x "+mainDust.getDisplayName()+" as input."); + } + else { + mainDust = material.getDust(mTotalCount); + Logger.MATERIALS("[Dehydrator] Could not find valid input dust, trying alternative."); + if (mainDust != null){ + Logger.MATERIALS("[Dehydrator] Recipe now requires "+mTotalCount+"x "+mainDust.getDisplayName()+" as input."); + } + else { + Logger.MATERIALS("[Dehydrator] Could not find valid input dust, exiting."); + } + } + + for (int j=0;j<mInternalOutputs.length;j++){ + if (mInternalOutputs[j] == null){ + mInternalOutputs[j] = GT_Values.NI; + Logger.MATERIALS("[Dehydrator] Set slot "+j+" to null."); + } + else { + Logger.MATERIALS("[Dehydrator] Set slot "+j+" to "+mInternalOutputs[j].getDisplayName()+"."); + } + } + + try{ + + + if (CORE.RA.addDehydratorRecipe( + new ItemStack[]{mainDust, emptyCell}, + null, + null, + mInternalOutputs, + mChances, + 20*1*(tVoltageMultiplier/10), + tVoltageMultiplier)){ + Logger.MATERIALS("[Dehydrator] Generated Dehydrator recipe for "+material.getDust(1).getDisplayName()); + } + else { + Logger.MATERIALS("[Dehydrator] Failed to generate Dehydrator recipe for "+material.getDust(1).getDisplayName()); + } + } + catch(Throwable t){ + t.printStackTrace(); + } + + + } + + + + + + + + } + } + + public static boolean addCentrifgeRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, ItemStack aOutput5, ItemStack aOutput6, int[] aChances, int aDuration, int aEUt) { + return GT_Values.RA.addCentrifugeRecipe(aInput1, aInput2, aFluidInput, aFluidOutput, aOutput1, aOutput2, aOutput3, aOutput4, aOutput5, aOutput6, aChances, aDuration, aEUt); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MetalRecipe.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MetalRecipe.java new file mode 100644 index 0000000000..830fae78ab --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MetalRecipe.java @@ -0,0 +1,119 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +import java.util.HashSet; +import java.util.Set; + +public class RecipeGen_MetalRecipe extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_MetalRecipe(final Material M){ + this.toGenerate = M; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + private void generateRecipes(final Material material) { + + Logger.WARNING("Generating Metal recipes for "+material.getLocalizedName()); + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getBlock(1))) + if (GT_ModHandler.addCompressionRecipe( + material.getIngot(9), + material.getBlock(1) + )){ + Logger.WARNING("Compress Block Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Compress Block Recipe: "+material.getLocalizedName()+" - Failed"); + } + + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) + if (GT_Values.RA.addLatheRecipe( + material.getIngot(1), + material.getRod(1), + material.getSmallDust(2), + (int) Math.max(material.getMass() / 8L, 1L), + material.vVoltageMultiplier)){ + Logger.WARNING("Lathe Rod Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Lathe Rod Recipe: "+material.getLocalizedName()+" - Failed"); + } + + if (ItemUtils.checkForInvalidItems(material.getRod(1)) && ItemUtils.checkForInvalidItems(material.getBolt(1))) + if (GT_Values.RA.addCutterRecipe( + material.getRod(1), + material.getBolt(4), + null, + (int) Math.max(material.getMass() * 2L, 1L), + material.vVoltageMultiplier)){ + Logger.WARNING("Cut Bolt Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Cut Bolt Recipe: "+material.getLocalizedName()+" - Failed"); + } + + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getHotIngot(1))) + if (CORE.RA.addVacuumFreezerRecipe( + material.getHotIngot(1), + material.getIngot(1), + (int) Math.max(material.getMass() * 3L, 1L), + material.vVoltageMultiplier) + ){ + Logger.WARNING("Cool Hot Ingot Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Cool Hot Ingot Recipe: "+material.getLocalizedName()+" - Failed"); + } + + if (ItemUtils.checkForInvalidItems(material.getRod(1)) && ItemUtils.checkForInvalidItems(material.getLongRod(1))) { + if (GT_Values.RA.addForgeHammerRecipe( + material.getRod(2), + material.getLongRod(1), + (int) Math.max(material.getMass(), 1L), + 16)){ + Logger.WARNING("Hammer Long Rod Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Hammer Long Rod Recipe: "+material.getLocalizedName()+" - Failed"); + } + + GT_Values.RA.addCutterRecipe( + material.getLongRod(1), + material.getRod(2), + null, + (int) Math.max(material.getMass(), 1L), + 4); + } + + if (ItemUtils.checkForInvalidItems(material.getBolt(1)) && ItemUtils.checkForInvalidItems(material.getScrew(1))) + if (GT_Values.RA.addLatheRecipe( + material.getBolt(1), + material.getScrew(1), + null, + (int) Math.max(material.getMass() / 8L, 1L), + 4)){ + Logger.WARNING("Lathe Screw Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Lathe Screw Recipe: "+material.getLocalizedName()+" - Failed"); + } + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MultisUsingFluidInsteadOfCells.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MultisUsingFluidInsteadOfCells.java new file mode 100644 index 0000000000..a76322e4f4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MultisUsingFluidInsteadOfCells.java @@ -0,0 +1,187 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map_Internal; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeGen_MultisUsingFluidInsteadOfCells { + + + private static ItemStack mEmptyCell; + private static AutoMap<ItemStack> mItemsToIgnore = new AutoMap<ItemStack>(); + private static boolean mInit = false; + + private static void init() { + if (!mInit) { + mInit = true; + mItemsToIgnore.add(ItemUtils.simpleMetaStack(CI.emptyCells(1).getItem(), 8, 1)); + + + } + } + + private static boolean doesItemMatchIgnoringStackSize(ItemStack a, ItemStack b) { + if (a == null || b == null) { + return false; + } + if (a.getItem() == b.getItem()) { + if (a.getItemDamage() == b.getItemDamage()) { + return true; + } + } + return false; + } + + private static boolean isEmptyCell(ItemStack aCell) { + if (aCell == null) { + return false; + } + if (mEmptyCell == null) { + mEmptyCell = CI.emptyCells(1); + } + if (mEmptyCell != null) { + ItemStack aTempStack = mEmptyCell.copy(); + aTempStack.stackSize = aCell.stackSize; + if (GT_Utility.areStacksEqual(aTempStack, aCell)) { + return true; + } + } + return false; + } + + private synchronized static FluidStack getFluidFromItemStack(final ItemStack ingot) { + if (ingot == null) { + return null; + } + FluidStack aFluid = GT_Utility.getFluidForFilledItem(ingot, true); + if (aFluid != null) { + return aFluid; + } + return null; + } + + public synchronized static int generateRecipesNotUsingCells(GT_Recipe_Map aInputs, GTPP_Recipe_Map_Internal aOutputs) { + init(); + int aRecipesHandled = 0; + int aInvalidRecipesToConvert = 0; + int aOriginalCount = aInputs.mRecipeList.size(); + + recipe : for (GT_Recipe x : aInputs.mRecipeList) { + if (x != null) { + + ItemStack[] aInputItems = x.mInputs.clone(); + ItemStack[] aOutputItems = x.mOutputs.clone(); + FluidStack[] aInputFluids = x.mFluidInputs.clone(); + FluidStack[] aOutputFluids = x.mFluidOutputs.clone(); + + AutoMap<ItemStack> aInputItemsMap = new AutoMap<ItemStack>(); + AutoMap<ItemStack> aOutputItemsMap = new AutoMap<ItemStack>(); + AutoMap<FluidStack> aInputFluidsMap = new AutoMap<FluidStack>(); + AutoMap<FluidStack> aOutputFluidsMap = new AutoMap<FluidStack>(); + + // Iterate Inputs, Convert valid items into fluids + inputs : for (ItemStack aInputStack : aInputItems) { + FluidStack aFoundFluid = getFluidFromItemStack(aInputStack); + if (aFoundFluid == null) { + for (ItemStack aBadStack : mItemsToIgnore) { + if (doesItemMatchIgnoringStackSize(aInputStack, aBadStack)) { + continue recipe; // Skip this recipe entirely if we find an item we don't like + } + } + if (!isEmptyCell(aInputStack)) { + aInputItemsMap.add(aInputStack); + } + } + else { + aFoundFluid.amount = aFoundFluid.amount * aInputStack.stackSize; + aInputFluidsMap.add(aFoundFluid); + } + } + // Iterate Outputs, Convert valid items into fluids + outputs: for (ItemStack aOutputStack : aOutputItems) { + FluidStack aFoundFluid = getFluidFromItemStack(aOutputStack); + if (aFoundFluid == null) { + for (ItemStack aBadStack : mItemsToIgnore) { + if (doesItemMatchIgnoringStackSize(aOutputStack, aBadStack)) { + continue recipe; // Skip this recipe entirely if we find an item we don't like + } + } + if (!isEmptyCell(aOutputStack)) { + aOutputItemsMap.add(aOutputStack); + } + } + else { + aFoundFluid.amount = aFoundFluid.amount * aOutputStack.stackSize; + aOutputFluidsMap.add(aFoundFluid); + } + } + // Add Input fluids second + for (FluidStack aInputFluid : aInputFluids) { + aInputFluidsMap.add(aInputFluid); + } + // Add Output fluids second + for (FluidStack aOutputFluid : aOutputFluids) { + aOutputFluidsMap.add(aOutputFluid); + } + + // Make some new Arrays + ItemStack[] aNewItemInputs = new ItemStack[aInputItemsMap.size()]; + ItemStack[] aNewItemOutputs = new ItemStack[aOutputItemsMap.size()]; + FluidStack[] aNewFluidInputs = new FluidStack[aInputFluidsMap.size()]; + FluidStack[] aNewFluidOutputs = new FluidStack[aOutputFluidsMap.size()]; + + // Add AutoMap contents to Arrays + for (int i = 0; i < aInputItemsMap.size(); i++) { + aNewItemInputs[i] = aInputItemsMap.get(i); + } + for (int i = 0; i < aOutputItemsMap.size(); i++) { + aNewItemOutputs[i] = aOutputItemsMap.get(i); + } + for (int i = 0; i < aInputFluidsMap.size(); i++) { + aNewFluidInputs[i] = aInputFluidsMap.get(i); + } + for (int i = 0; i < aOutputFluidsMap.size(); i++) { + aNewFluidOutputs[i] = aOutputFluidsMap.get(i); + } + + if (!ItemUtils.checkForInvalidItems(aNewItemInputs, aNewItemOutputs)) { + aInvalidRecipesToConvert++; + continue recipe; // Skip this recipe entirely if we find an item we don't like + } + + // Add Recipe to map + GT_Recipe aNewRecipe = new GTPP_Recipe( + false, + aNewItemInputs, + aNewItemOutputs, + x.mSpecialItems, + x.mChances, + aNewFluidInputs, + aNewFluidOutputs, + x.mDuration, + x.mEUt, + x.mSpecialValue); + aOutputs.add(aNewRecipe); + aRecipesHandled++; + } + else { + aInvalidRecipesToConvert++; + } + } + + Logger.INFO("Generated Recipes for "+aOutputs.mNEIName); + Logger.INFO("Original Map contains "+aOriginalCount+" recipes."); + Logger.INFO("Output Map contains "+aRecipesHandled+" recipes."); + Logger.INFO("There were "+aInvalidRecipesToConvert+" invalid recipes."); + return aRecipesHandled; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java new file mode 100644 index 0000000000..f3ff935d6e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -0,0 +1,582 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +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.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.state.MaterialState; +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 net.minecraftforge.fluids.FluidStack; + +public class RecipeGen_Ore extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_Ore(final Material M){ + this(M, false); + } + + public RecipeGen_Ore(final Material M, final boolean O){ + this.toGenerate = M; + this.disableOptional = O; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate, this.disableOptional); + } + + private static Material mStone; + + private void generateRecipes(final Material material, final boolean disableOptional){ + + if (mStone == null) { + mStone = MaterialUtils.generateMaterialFromGtENUM(Materials.Stone); + } + + //if (material.getMaterialComposites().length > 1){ + Logger.MATERIALS("[Recipe Generator Debug] ["+material.getLocalizedName()+"]"); + int tVoltageMultiplier = MaterialUtils.getVoltageForTier(material.vTier); + + final ItemStack dustStone = ItemUtils.getItemStackOfAmountFromOreDict("dustStone", 1); + Material bonusA = null; //Ni + Material bonusB = null; //Tin + + if (material.getComposites().size() >= 1 && material.getComposites().get(0) != null){ + bonusA = material.getComposites().get(0).getStackMaterial(); + } + else { + bonusA = material; + } + + boolean allFailed = false; + + + //Setup Bonuses + ArrayList<Material> aMatComp = new ArrayList<Material>(); + for (Material j : MaterialUtils.getCompoundMaterialsRecursively(material)) { + aMatComp.add(j); + } + + if (aMatComp.size() < 3) { + while (aMatComp.size() < 3) { + aMatComp.add(material); + } + } + + AutoMap<Material> amJ = new AutoMap<Material>(); + int aIndexCounter = 0; + for (Material g : aMatComp) { + if (g.hasSolidForm()) { + if (getDust(g) != null && getTinyDust(g) != null) { + amJ.put(g); + } + } + } + + if (amJ.size() < 2) { + if (material.getComposites().size() >= 2 && material.getComposites().get(1) != null){ + bonusB = material.getComposites().get(1).getStackMaterial(); + //If Secondary Output has no solid output, try the third (If it exists) + if (!bonusB.hasSolidForm() && material.getComposites().size() >= 3 && material.getComposites().get(2) != null) { + bonusB = material.getComposites().get(2).getStackMaterial(); + //If Third Output has no solid output, try the Fourth (If it exists) + if (!bonusB.hasSolidForm() && material.getComposites().size() >= 4 && material.getComposites().get(3) != null) { + bonusB = material.getComposites().get(3).getStackMaterial(); + //If Fourth Output has no solid output, try the Fifth (If it exists) + if (!bonusB.hasSolidForm() && material.getComposites().size() >= 5 && material.getComposites().get(4) != null) { + bonusB = material.getComposites().get(4).getStackMaterial(); + //If Fifth Output has no solid output, default out to Stone dust. + if (!bonusB.hasSolidForm()) { + allFailed = true; + bonusB = mStone; + } + } + } + } + } + else { + allFailed = true; + } + } + else { + bonusA = amJ.get(0); + bonusB = amJ.get(1); + } + + //Default out if it's made of fluids or some shit. + if (bonusA == null) { + bonusA = tVoltageMultiplier > 100 ? material : mStone; + } + //Default out if it's made of fluids or some shit. + if (allFailed || bonusB == null) { + bonusB = tVoltageMultiplier > 100 ? material : mStone; + } + + AutoMap<Pair<Integer, Material>> componentMap = new AutoMap<Pair<Integer, Material>>(); + for (MaterialStack r : material.getComposites()){ + if (r != null){ + componentMap.put(new Pair<Integer, Material>(r.getPartsPerOneHundred(), r.getStackMaterial())); + } + } + + //Need two valid outputs + if (bonusA == null || bonusB == null || !bonusA.hasSolidForm() || !bonusB.hasSolidForm()) { + if (bonusA == null) { + bonusA = mStone; + } + if (bonusB == null) { + bonusB = mStone; + } + if (!bonusA.hasSolidForm()) { + bonusA = mStone; + } + if (!bonusB.hasSolidForm()) { + bonusB = mStone; + } + } + + ItemStack tinyDustA = getTinyDust(bonusA); + ItemStack tinyDustB = getTinyDust(bonusB); + ItemStack matDust = getDust(material); + ItemStack matDustA = getDust(bonusA); + ItemStack matDustB = getDust(bonusB); + + /** + * Package + */ + //Allow ore dusts to be packaged + if (ItemUtils.checkForInvalidItems(material.getSmallDust(1)) && ItemUtils.checkForInvalidItems(material.getTinyDust(1))) { + RecipeGen_DustGeneration.generatePackagerRecipes(material); + } + + + /** + * Macerate + */ + //Macerate ore to Crushed + if (GT_Values.RA.addPulveriserRecipe(material.getOre(1), new ItemStack[]{material.getCrushed(2)}, new int[]{10000}, 20*20, tVoltageMultiplier/2)){ + Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate ore to Crushed ore'"); + } + //Macerate Crushed to Impure Dust + if (GT_Values.RA.addPulveriserRecipe(material.getCrushed(1), new ItemStack[]{material.getDustImpure(1), matDustA}, new int[]{10000, 1000}, 20*20, tVoltageMultiplier/2)){ + Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate Crushed ore to Impure Dust'"); + } + //Macerate Washed to Purified Dust + if (GT_Values.RA.addPulveriserRecipe(material.getCrushedPurified(1), new ItemStack[]{material.getDustPurified(1), matDustA}, new int[]{10000, 1000}, 20*20, tVoltageMultiplier/2)){ + Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate Washed ore to Purified Dust'"); + } + //Macerate Centrifuged to Pure Dust + if (GT_Values.RA.addPulveriserRecipe(material.getCrushedCentrifuged(1), new ItemStack[]{matDust, matDustA}, new int[]{10000, 1000}, 20*20, tVoltageMultiplier/2)){ + Logger.MATERIALS("[Macerator] Added Recipe: 'Macerate Centrifuged ore to Pure Dust'"); + } + + /** + * Wash + */ + //Wash into Purified Crushed + /*if (GT_Values.RA.addOreWasherRecipe(material.getCrushed(1), material.getCrushedPurified(1), bonusA.getTinyDust(1), dustStone, FluidUtils.getWater(1000), 25*20, 16)){ + Logger.MATERIALS("[OreWasher] Added Recipe: 'Wash Crushed ore into Purified Crushed ore'"); + }*/ + //.08 compat method + if (GT_ModHandler.addOreWasherRecipe(material.getCrushed(1), 1000, material.getCrushedPurified(1), tinyDustA, dustStone)){ + Logger.MATERIALS("[OreWasher] Added Recipe: 'Wash Crushed ore into Purified Crushed ore'"); + } + + + + + + /** + * Thermal Centrifuge + */ + /*//Crushed ore to Centrifuged Ore + if (GT_Values.RA.addThermalCentrifugeRecipe(material.getCrushed(1), material.getCrushedCentrifuged(1), tinyDustB, dustStone, 25*20, 24)){ + Logger.MATERIALS("[ThermalCentrifuge] Added Recipe: 'Crushed ore to Centrifuged Ore'"); + } + //Washed ore to Centrifuged Ore + if (GT_Values.RA.addThermalCentrifugeRecipe(material.getCrushedPurified(1), material.getCrushedCentrifuged(1), bonusA.getTinyDust(1), dustStone, 25*20, 24)){ + Logger.MATERIALS("[ThermalCentrifuge] Added Recipe: 'Washed ore to Centrifuged Ore'"); + }*/ + + Logger.MATERIALS("material.getCrushed(1): "+(material.getCrushed(1) != null)); + Logger.MATERIALS("material.getCrushedPurified(1): "+(material.getCrushedPurified(1) != null)); + + Logger.MATERIALS("material.getTinyDust(1): "+(ItemUtils.getItemName(bonusA.getCrushed(1)))); + Logger.MATERIALS("material.getTinyDust(1): "+(ItemUtils.getItemName(bonusB.getCrushed(1)))); + + try { + //.08 compat + if (GT_ModHandler.addThermalCentrifugeRecipe(material.getCrushed(1), (int) Math.min(5000L, Math.abs(material.getMass() * 20L)), material.getCrushedCentrifuged(1), tinyDustB, dustStone)){ + Logger.MATERIALS("[ThermalCentrifuge] Added Recipe: 'Crushed ore to Centrifuged Ore' | Input: "+material.getCrushed(1).getDisplayName()+" | Outputs: "+material.getCrushedCentrifuged(1).getDisplayName()+", "+tinyDustB.getDisplayName()+", "+dustStone.getDisplayName()+"."); + } + } + catch (Throwable t) {} + try { + if (GT_ModHandler.addThermalCentrifugeRecipe(material.getCrushedPurified(1), (int) Math.min(5000L, Math.abs(material.getMass() * 20L)), material.getCrushedCentrifuged(1), tinyDustA, dustStone)){ + Logger.MATERIALS("[ThermalCentrifuge] Added Recipe: 'Washed ore to Centrifuged Ore' | Input: "+material.getCrushedPurified(1).getDisplayName()+" | Outputs: "+material.getCrushedCentrifuged(1).getDisplayName()+", "+tinyDustA.getDisplayName()+", "+dustStone.getDisplayName()+"."); + } + } + catch (Throwable t) {} + + + /** + * Forge Hammer + */ + if (GT_Values.RA.addForgeHammerRecipe(material.getCrushedCentrifuged(1), matDust, 10, tVoltageMultiplier/4)){ + Logger.MATERIALS("[ForgeHammer] Added Recipe: 'Crushed Centrifuged to Pure Dust'"); + } + if (GT_Values.RA.addForgeHammerRecipe(material.getCrushedPurified(1), material.getDustPurified(1), 10, tVoltageMultiplier/4)){ + Logger.MATERIALS("[ForgeHammer] Added Recipe: 'Crushed Purified to Purified Dust'"); + } + if (GT_Values.RA.addForgeHammerRecipe(material.getOre(1), material.getCrushed(1), 10, tVoltageMultiplier/4)){ + Logger.MATERIALS("[ForgeHammer] Added Recipe: 'Ore to Crushed'"); + } + + /** + * Centrifuge + */ + //Purified Dust to Clean + if (GT_Values.RA.addCentrifugeRecipe( + material.getDustPurified(1), null, + null, //In Fluid + null, //Out Fluid + matDust, tinyDustA,null, + null, null,null, + new int[]{10000, 10000}, //Chances + (int) Math.max(1L, material.getMass() * 8L), //Time + tVoltageMultiplier/2)){ //Eu + Logger.MATERIALS("[Centrifuge] Added Recipe: Purified Dust to Clean Dust"); + } + + //Impure Dust to Clean + if (GT_Values.RA.addCentrifugeRecipe( + material.getDustImpure(1), null, + null, //In Fluid + null, //Out Fluid + matDust, tinyDustB,null, + null, null,null, + new int[]{10000, 10000}, //Chances + (int) Math.max(1L, material.getMass() * 8L), //Time + tVoltageMultiplier/2)){ //Eu + Logger.MATERIALS("[Centrifuge] Added Recipe: Inpure Dust to Clean Dust"); + } + + + /** + * Electrolyzer + */ + + if (!disableOptional) { + //Process Dust + if (componentMap.size() > 0 && componentMap.size() <= 6){ + + ItemStack mInternalOutputs[] = new ItemStack[6]; + int mChances[] = new int[6]; + int mCellCount = 0; + + int mTotalCount = 0; + + int mCounter = 0; + for (Pair<Integer, Material> f : componentMap){ + if (f.getValue().getState() != MaterialState.SOLID){ + Logger.MATERIALS("[Electrolyzer] Found Fluid Component, adding "+f.getKey()+" cells of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getCell(f.getKey()); + mCellCount += f.getKey(); + mTotalCount += f.getKey(); + Logger.MATERIALS("[Electrolyzer] In total, adding "+mCellCount+" cells for "+material.getLocalizedName()+" processing."); + } + else { + Logger.MATERIALS("[Electrolyzer] Found Solid Component, adding "+f.getKey()+" dusts of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getDust(f.getKey()); + mTotalCount += f.getKey(); + } + } + + //Build Output Array + for (int g=0;g<mInternalOutputs.length;g++){ + Logger.MATERIALS("[Electrolyzer] Is output["+g+"] valid with a chance? "+(mInternalOutputs[g] != null ? 10000 : 0)); + mChances[g] = (mInternalOutputs[g] != null ? 10000 : 0); + } + + ItemStack emptyCell = null; + if (mCellCount > 0){ + emptyCell = ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", mCellCount); + Logger.MATERIALS("[Electrolyzer] Recipe now requires "+mCellCount+" empty cells as input."); + } + + ItemStack mainDust = material.getDust(material.smallestStackSizeWhenProcessing); + if (mainDust != null){ + Logger.MATERIALS("[Electrolyzer] Recipe now requires "+material.smallestStackSizeWhenProcessing+"x "+mainDust.getDisplayName()+" as input."); + } + else { + mainDust = material.getDust(mTotalCount); + Logger.MATERIALS("[Electrolyzer] Could not find valid input dust, trying alternative."); + if (mainDust != null){ + Logger.MATERIALS("[Electrolyzer] Recipe now requires "+mTotalCount+"x "+mainDust.getDisplayName()+" as input."); + } + else { + Logger.MATERIALS("[Electrolyzer] Could not find valid input dust, exiting."); + } + } + + for (int j=0;j<mInternalOutputs.length;j++){ + if (mInternalOutputs[j] == null){ + mInternalOutputs[j] = GT_Values.NI; + Logger.MATERIALS("[Electrolyzer] Set slot "+j+" to null."); + } + else { + Logger.MATERIALS("[Electrolyzer] Set slot "+j+" to "+mInternalOutputs[j].getDisplayName()+"."); + } + } + + try{ + if (addElectrolyzerRecipe( + mainDust, + emptyCell, //input 2 + null, //Input fluid 1 + null, //Output fluid 1 + mInternalOutputs[0], + mInternalOutputs[1], + mInternalOutputs[2], + mInternalOutputs[3], + mInternalOutputs[4], + mInternalOutputs[5], + mChances, + (int) Math.max(material.getMass() * 3L * 1, 1), + tVoltageMultiplier)){ + Logger.MATERIALS("[Electrolyzer] Generated Electrolyzer recipe for "+matDust.getDisplayName()); + } + else { + Logger.MATERIALS("[Electrolyzer] Failed to generate Electrolyzer recipe for "+matDust.getDisplayName()); + } + } + catch(Throwable t){ + t.printStackTrace(); + } + } + else if (componentMap.size() > 6 && componentMap.size() <= 9){ + Logger.MATERIALS("[Issue][Electrolyzer] "+material.getLocalizedName()+" is composed of over 6 materials, so an electrolyzer recipe for processing cannot be generated. Trying to create one for the Dehydrator instead."); + + ItemStack mInternalOutputs[] = new ItemStack[9]; + int mChances[] = new int[9]; + int mCellCount = 0; + + int mTotalCount = 0; + + int mCounter = 0; + for (Pair<Integer, Material> f : componentMap){ + if (f.getValue().getState() != MaterialState.SOLID && f.getValue().getState() != MaterialState.ORE){ + Logger.MATERIALS("[Dehydrator] Found Fluid Component, adding "+f.getKey()+" cells of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getCell(f.getKey()); + mCellCount += f.getKey(); + mTotalCount += f.getKey(); + Logger.MATERIALS("[Dehydrator] In total, adding "+mCellCount+" cells for "+material.getLocalizedName()+" processing."); + } + else { + Logger.MATERIALS("[Dehydrator] Found Solid Component, adding "+f.getKey()+" dusts of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getDust(f.getKey()); + mTotalCount += f.getKey(); + } + } + + //Build Output Array + for (int g=0;g<mInternalOutputs.length;g++){ + Logger.MATERIALS("[Dehydrator] Is output["+g+"] valid with a chance? "+(mInternalOutputs[g] != null ? 10000 : 0)); + mChances[g] = (mInternalOutputs[g] != null ? 10000 : 0); + } + + ItemStack emptyCell = null; + if (mCellCount > 0){ + emptyCell = ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", mCellCount); + Logger.MATERIALS("[Dehydrator] Recipe now requires "+mCellCount+" empty cells as input."); + } + + ItemStack mainDust = material.getDust(material.smallestStackSizeWhenProcessing); + if (mainDust != null){ + Logger.MATERIALS("[Dehydrator] Recipe now requires "+material.smallestStackSizeWhenProcessing+"x "+mainDust.getDisplayName()+" as input."); + } + else { + mainDust = material.getDust(mTotalCount); + Logger.MATERIALS("[Dehydrator] Could not find valid input dust, trying alternative."); + if (mainDust != null){ + Logger.MATERIALS("[Dehydrator] Recipe now requires "+mTotalCount+"x "+mainDust.getDisplayName()+" as input."); + } + else { + Logger.MATERIALS("[Dehydrator] Could not find valid input dust, exiting."); + } + } + + for (int j=0;j<mInternalOutputs.length;j++){ + if (mInternalOutputs[j] == null){ + mInternalOutputs[j] = GT_Values.NI; + Logger.MATERIALS("[Dehydrator] Set slot "+j+" to null."); + } + else { + Logger.MATERIALS("[Dehydrator] Set slot "+j+" to "+mInternalOutputs[j].getDisplayName()+"."); + } + } + + try{ + if (CORE.RA.addDehydratorRecipe( + new ItemStack[]{mainDust, emptyCell}, + null, + null, + mInternalOutputs, + mChances, + (int) Math.max(material.getMass() * 4L * 1, 1), + tVoltageMultiplier)){ + Logger.MATERIALS("[Dehydrator] Generated Dehydrator recipe for "+matDust.getDisplayName()); + Logger.MATERIALS("Inputs: "+mainDust.getDisplayName()+" x"+mainDust.stackSize+", "+(emptyCell == null ? "No Cells" : ""+emptyCell.getDisplayName()+" x"+emptyCell.stackSize)); + Logger.MATERIALS("Outputs "+ItemUtils.getArrayStackNames(mInternalOutputs)); + Logger.MATERIALS("Time: "+((int) Math.max(material.getMass() * 4L * 1, 1))); + Logger.MATERIALS("EU: "+tVoltageMultiplier); + } + else { + Logger.MATERIALS("[Dehydrator] Failed to generate Dehydrator recipe for "+matDust.getDisplayName()); + } + } + catch(Throwable t){ + t.printStackTrace(); + } + + + } + } + + + /** + * Shaped Crafting + */ + RecipeUtils.addShapedRecipe( + CI.craftingToolHammer_Hard, null, null, + material.getCrushedPurified(1), null, null, + null, null, null, + material.getDustPurified(1)); + + RecipeUtils.addShapedRecipe( + CI.craftingToolHammer_Hard, null, null, + material.getCrushed(1), null, null, + null, null, null, + material.getDustImpure(1)); + + RecipeUtils.addShapedRecipe( + CI.craftingToolHammer_Hard, null, null, + material.getCrushedCentrifuged(1), null, null, + null, null, null, + matDust); + + + + final ItemStack normalDust = matDust; + final ItemStack smallDust = material.getSmallDust(1); + final ItemStack tinyDust = material.getTinyDust(1); + + if (RecipeUtils.addShapedRecipe( + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + normalDust)){ + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Failed"); + } + + if (RecipeUtils.addShapedRecipe( + normalDust, null, null, + null, null, null, + null, null, null, + material.getTinyDust(9))){ + Logger.WARNING("9 Tiny dust from 1 Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("9 Tiny dust from 1 Recipe: "+material.getLocalizedName()+" - Failed"); + } + + + if (RecipeUtils.addShapedRecipe( + smallDust, smallDust, null, + smallDust, smallDust, null, + null, null, null, + normalDust)){ + Logger.WARNING("4 Small dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("4 Small dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Failed"); + } + + + if (RecipeUtils.addShapedRecipe( + null, normalDust, null, + null, null, null, + null, null, null, + material.getSmallDust(4))){ + Logger.WARNING("4 Small dust from 1 Dust Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("4 Small dust from 1 Dust Recipe: "+material.getLocalizedName()+" - Failed"); + } + + //} + } + + + public static boolean addElectrolyzerRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, ItemStack aOutput5, ItemStack aOutput6, int[] aChances, int aDuration, int aEUt) { + if (((aInput1 == null) && (aFluidInput == null)) || ((aOutput1 == null) && (aFluidOutput == null))) { + Logger.MATERIALS("[Electrolyzer] Either both inputs or outputs are null."); + return false; + } + if ((aInput1 != null) && ((aDuration = GregTech_API.sRecipeFile.get("electrolyzer", aInput1, aDuration)) <= 0)) { + Logger.MATERIALS("[Electrolyzer] Fail 1."); + return false; + } + if ((aFluidInput != null) && ((aDuration = GregTech_API.sRecipeFile.get("electrolyzer", aFluidInput.getFluid().getName(), aDuration)) <= 0)) { + Logger.MATERIALS("[Electrolyzer] Fail 2."); + return false; + } + GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.addRecipe(true, new ItemStack[]{aInput1, aInput2}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4, aOutput5, aOutput6}, null, aChances, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); + Logger.MATERIALS("[Electrolyzer] Recipe added."); + return true; + } + + public static ItemStack getTinyDust(Material m) { + ItemStack x = m.getTinyDust(1); + if (x == null) { + x = mStone.getDust(1); + } + return x; + } + + public static ItemStack getDust(Material m) { + ItemStack x = m.getDust(1); + if (x == null) { + x = mStone.getDust(1); + } + return x; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plasma.java new file mode 100644 index 0000000000..5f53defc2f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plasma.java @@ -0,0 +1,42 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import net.minecraft.item.ItemStack; + +public class RecipeGen_Plasma extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_Plasma(final Material M){ + this.toGenerate = M; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + private void generateRecipes(final Material material) { + // Cool Plasma + ItemStack aPlasmaCell = material.getPlasmaCell(1); + ItemStack aCell = material.getCell(1); + if (material.getPlasmaCell(1) != null){ + GT_Values.RA.addFuel(GT_Utility.copyAmount(1L, aPlasmaCell), GT_Utility.getFluidForFilledItem(aPlasmaCell, true) == null ? GT_Utility.getContainerItem(aPlasmaCell, true) : null, (int) Math.max(1024L, 1024L * material.getMass()), 4); + } + if (material.getCell(1) != null && material.getPlasmaCell(1) != null){ + GT_Values.RA.addVacuumFreezerRecipe(aPlasmaCell, aCell, (int) Math.max(material.getMass() * 2L, 1L)); + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java new file mode 100644 index 0000000000..56d11520d0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Plates.java @@ -0,0 +1,154 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; + +public class RecipeGen_Plates extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_Plates(final Material M){ + this.toGenerate = M; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + private void generateRecipes(final Material material){ + + final int tVoltageMultiplier = material.getMeltingPointK() >= 2800 ? 60 : 15; + final ItemStack ingotStackOne = material.getIngot(1); + final ItemStack ingotStackTwo = material.getIngot(2); + final ItemStack shape_Mold = ItemList.Shape_Mold_Plate.get(0); + final ItemStack plate_Single = material.getPlate(1); + final ItemStack plate_SingleTwo = material.getPlate(2); + final ItemStack plate_SingleNine = material.getPlate(9); + final ItemStack plate_Double = material.getPlateDouble(1); + final ItemStack block = material.getBlock(1); + + Logger.WARNING("Generating Plate recipes for "+material.getLocalizedName()); + + //Forge Hammer + if (ItemUtils.checkForInvalidItems(ingotStackTwo) && ItemUtils.checkForInvalidItems(plate_Single)) + if (addForgeHammerRecipe( + ingotStackTwo, + plate_Single, + (int) Math.max(material.getMass(), 1L), + material.vVoltageMultiplier)){ + Logger.WARNING("Forge Hammer Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Forge Hammer Recipe: "+material.getLocalizedName()+" - Failed"); + } + //Bender + if (ItemUtils.checkForInvalidItems(ingotStackOne) && ItemUtils.checkForInvalidItems(plate_Single)) + if (addBenderRecipe( + ingotStackOne, + plate_Single, + (int) Math.max(material.getMass() * 1L, 1L), + material.vVoltageMultiplier)){ + Logger.WARNING("Bender Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Bender Recipe: "+material.getLocalizedName()+" - Failed"); + } + //Alloy Smelter + if (ItemUtils.checkForInvalidItems(ingotStackTwo) && ItemUtils.checkForInvalidItems(plate_Single)) + if (GT_Values.RA.addAlloySmelterRecipe( + ingotStackTwo, + shape_Mold, + plate_Single, + (int) Math.max(material.getMass() * 2L, 1L), + material.vVoltageMultiplier)){ + Logger.WARNING("Alloy Smelter Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Alloy Smelter Recipe: "+material.getLocalizedName()+" - Failed"); + } + //Cutting Machine + if (ItemUtils.checkForInvalidItems(block) && ItemUtils.checkForInvalidItems(plate_Single)) + if (GT_Values.RA.addCutterRecipe( + block, + null, + plate_SingleNine, + (int) Math.max(material.getMass() * 10L, 1L), + material.vVoltageMultiplier)){ + Logger.WARNING("Cutting Machine Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("ACutting Machine Recipe: "+material.getLocalizedName()+" - Failed"); + } + + + //Making Double Plates + if (ItemUtils.checkForInvalidItems(ingotStackTwo) && ItemUtils.checkForInvalidItems(plate_Double)) + if (addBenderRecipe( + ingotStackTwo, + plate_Double, + (int) Math.max(material.getMass() * 2L, 1L), + material.vVoltageMultiplier)){ + Logger.WARNING("Bender Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Bender Recipe: "+material.getLocalizedName()+" - Failed"); + } + + if (ItemUtils.checkForInvalidItems(plate_SingleTwo) && ItemUtils.checkForInvalidItems(plate_Double)) + if (addBenderRecipe( + plate_SingleTwo, + plate_Double, + (int) Math.max(material.getMass() * 2L, 1L), + material.vVoltageMultiplier)){ + Logger.WARNING("Bender Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Bender Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + public static boolean addBenderRecipe(final ItemStack aInput1, final ItemStack aOutput1, int aDuration, final int aEUt) { + return GT_Values.RA.addBenderRecipe(aInput1, aOutput1, aDuration, aEUt); + } + + public static boolean addExtruderRecipe(final ItemStack aInput, final ItemStack aShape, final ItemStack aOutput, int aDuration, final int aEUt) { + if ((aInput == null) || (aShape == null) || (aOutput == null)) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("extruder", aOutput, aDuration)) <= 0) { + return false; + } + GT_Recipe.GT_Recipe_Map.sExtruderRecipes.addRecipe(true, new ItemStack[]{aInput, aShape}, new ItemStack[]{aOutput}, null, null, null, aDuration, aEUt, 0); + return true; + } + + public static boolean addForgeHammerRecipe(final ItemStack aInput1, final ItemStack aOutput1, final int aDuration, final int aEUt) { + if ((aInput1 == null) || (aOutput1 == null)) { + return false; + } + if (!GregTech_API.sRecipeFile.get("forgehammer", aOutput1, true)) { + return false; + } + GT_Recipe.GT_Recipe_Map.sHammerRecipes.addRecipe(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, aDuration, aEUt, 0); + return true; + } + + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java new file mode 100644 index 0000000000..acb7e5fe02 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java @@ -0,0 +1,373 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import static gregtech.api.enums.GT_Values.M; + +import java.util.ArrayList; +import java.util.Map; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +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.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class RecipeGen_Recycling implements Runnable { + + public static AutoMap<Runnable> mQueuedRecyclingGenerators = new AutoMap<Runnable>(); + + public static void executeGenerators() { + if (mQueuedRecyclingGenerators.size() > 0) { + for (Runnable R : mQueuedRecyclingGenerators.values()) { + R.run(); + } + } + } + + final Material toGenerate; + public static Map<String, ItemStack> mNameMap; + + public RecipeGen_Recycling(final Material M) { + this.toGenerate = M; + if (mNameMap == null){ + mNameMap = this.getNameMap(); + } + mQueuedRecyclingGenerators.put(this); + } + + @Override + public void run() { + if (mNameMap != null){ + generateRecipes(this.toGenerate); + } + } + + public static void generateRecipes(final Material material) { + + if (material != null) + Logger.WARNING("Generating Recycling recipes for " + material.getLocalizedName()); + + final OrePrefixes[] mValidPrefixesAsString = { OrePrefixes.ingot, OrePrefixes.ingotHot, OrePrefixes.nugget, + OrePrefixes.plate, OrePrefixes.plateDense, OrePrefixes.plateDouble, OrePrefixes.plateTriple, + OrePrefixes.plateQuadruple, OrePrefixes.plateQuintuple, OrePrefixes.stick, OrePrefixes.stickLong, + OrePrefixes.bolt, OrePrefixes.screw, OrePrefixes.ring, OrePrefixes.rotor, OrePrefixes.gearGt, + OrePrefixes.gearGtSmall, OrePrefixes.gear, OrePrefixes.block, OrePrefixes.cableGt01, OrePrefixes.cableGt02, + OrePrefixes.cableGt04, OrePrefixes.cableGt08, OrePrefixes.cableGt12, OrePrefixes.wireFine, OrePrefixes.wireGt01, + OrePrefixes.wireGt02, OrePrefixes.wireGt04, OrePrefixes.wireGt08, OrePrefixes.wireGt12, OrePrefixes.wireGt16, + OrePrefixes.foil, OrePrefixes.frameGt, OrePrefixes.pipeHuge, OrePrefixes.pipeLarge, OrePrefixes.pipeMedium, OrePrefixes.pipeSmall, OrePrefixes.pipeTiny, + }; + + int mSlotIndex = 0; + Pair<OrePrefixes, ItemStack>[] mValidPairs = new Pair[mValidPrefixesAsString.length]; + + for (int r=0;r<mValidPairs.length;r++){ + ItemStack temp = getItemStackOfAmountFromOreDictNoBroken(mValidPrefixesAsString[r].name()+Utils.sanitizeString(material.getLocalizedName()), 1); + if (temp != null){ + mValidPairs[mSlotIndex++] = new Pair<OrePrefixes, ItemStack>(mValidPrefixesAsString[r], temp.copy()); + } + } + + if (mValidPairs.length > 0){ + int validCounter = 0; + Pair<OrePrefixes, ItemStack>[] temp = mValidPairs; + for (Pair<OrePrefixes, ItemStack> temp2 : mValidPairs){ + if (temp2 != null){ + Logger.WARNING("Valid: "+temp2.getValue().getDisplayName()); + validCounter++; + } + } + Pair<OrePrefixes, ItemStack> temp3[] = new Pair[validCounter]; + int temp4 = 0; + for (Pair<OrePrefixes, ItemStack> r : mValidPairs){ + if (r != null){ + temp3[temp4++] = r; + } + } + if (temp3.length > 0){ + mValidPairs = temp3.clone(); + } + } + + if (mValidPrefixesAsString.length >= 1) { + for (final Pair<OrePrefixes, ItemStack> validPrefix : mValidPairs) { + try { + + if (material == null || validPrefix == null || material.getState() != MaterialState.SOLID || validPrefix.getKey() == OrePrefixes.ingotHot) { + continue; + } + + final ItemStack tempStack = validPrefix.getValue(); + final ItemStack mDust = getDust(material, validPrefix.getKey()); + final Pair<OrePrefixes, ItemStack> mData = getDustData(material, validPrefix.getKey()); + int mFluidAmount = (int) GT_Utility.translateMaterialToFluidAmount(validPrefix.getKey().mMaterialAmount, true); + + //Maceration + if (ItemUtils.checkForInvalidItems(tempStack)) { + // mValidItems[mSlotIndex++] = tempStack; + if ((mDust != null) && GT_ModHandler.addPulverisationRecipe(tempStack, mDust)) { + Logger.WARNING("Recycle Recipe: " + material.getLocalizedName() + " - Success - Recycle " + + tempStack.getDisplayName() + " and obtain " + mDust.getDisplayName()); + } + else { + Logger.WARNING("Recycle Recipe: " + material.getLocalizedName() + " - Failed"); + if (mDust == null) { + Logger.WARNING("Invalid Dust output."); + } + } + } + + //Arc Furnace + if (ItemUtils.checkForInvalidItems(tempStack)) { + + } + + //Fluid Extractor + if (ItemUtils.checkForInvalidItems(tempStack)) { + // mValidItems[mSlotIndex++] = tempStack; + if ((mDust != null) && CORE.RA.addFluidExtractionRecipe(tempStack, material.getFluidStack(mFluidAmount), 30, material.vVoltageMultiplier)) { + Logger.WARNING("Fluid Recycle Recipe: " + material.getLocalizedName() + " - Success - Recycle " + + tempStack.getDisplayName() + " and obtain " + mFluidAmount+"mb of "+material.getFluidStack(1).getLocalizedName()+"."); + } + else { + Logger.WARNING("Fluid Recycle Recipe: " + material.getLocalizedName() + " - Failed"); + if (mDust == null) { + Logger.WARNING("Invalid Dust output."); + } + } + } + + } + catch (final Throwable t) { + t.printStackTrace(); + // Utils.LOG_WARNING("Returning Null. Throwable Info: + // "+t.getMessage()); + // Utils.LOG_WARNING("Throwable Info: "+t.toString()); + // Utils.LOG_WARNING("Throwable Info: + // "+t.getCause().toString()); + } + + } + } + } + + public static Pair<OrePrefixes, ItemStack> getDustData(final Material aMaterial, final OrePrefixes aPrefix) { + return getDustData(aMaterial, aPrefix.mMaterialAmount); + } + + public static Pair<OrePrefixes, ItemStack> getDustData(final Material aMaterial, final long aMaterialAmount) { + ItemStack mDust = null; + OrePrefixes mPrefix = null; + + if (aMaterial == null || aMaterialAmount <= 0) { + return null; + } + if ((((aMaterialAmount % M) == 0) || (aMaterialAmount >= (M * 16)))) { + mDust = get(OrePrefixes.dust, aMaterial, aMaterialAmount / M); + mPrefix = OrePrefixes.dust; + } + if ((mDust == null) && ((((aMaterialAmount * 4) % M) == 0) || (aMaterialAmount >= (M * 8)))) { + mDust = get(OrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M); + mPrefix = OrePrefixes.dustSmall; + } + if ((mDust == null) && (((aMaterialAmount * 9) >= M))) { + mDust = get(OrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M); + mPrefix = OrePrefixes.dustTiny; + } + + if (mPrefix != null && mDust != null){ + Logger.WARNING("Built valid dust pair."); + return new Pair<OrePrefixes, ItemStack>(mPrefix, mDust); + } + else { + Logger.WARNING("mPrefix: "+(mPrefix!=null)); + Logger.WARNING("mDust: "+(mDust!=null)); + } + Logger.WARNING("Failed to build valid dust pair."); + return null; + } + + public static ItemStack getDust(final Material aMaterial, final OrePrefixes aPrefix) { + return aMaterial == null ? null : getDust(aMaterial, aPrefix.mMaterialAmount); + } + + public static ItemStack getDust(final Material aMaterial, final long aMaterialAmount) { + if (aMaterialAmount <= 0) { + return null; + } + ItemStack rStack = null; + if ((((aMaterialAmount % M) == 0) || (aMaterialAmount >= (M * 16)))) { + Logger.WARNING("Trying to get a Dust"); + rStack = get(OrePrefixes.dust, aMaterial, aMaterialAmount / M); + } + if ((rStack == null) && ((((aMaterialAmount * 4) % M) == 0) || (aMaterialAmount >= (M * 8)))) { + Logger.WARNING("Trying to get a Small Dust"); + rStack = get(OrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M); + } + if ((rStack == null) && (((aMaterialAmount * 9) >= M))) { + Logger.WARNING("Trying to get a Tiny Dust"); + rStack = get(OrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M); + } + return rStack; + } + + public static ItemStack get(final Object aName, final long aAmount) { + return get(aName, null, aAmount, true, true); + } + + public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount) { + return get(aName, aReplacement, aAmount, true, true); + } + + public static ItemStack get(final OrePrefixes aPrefix, final Material aMaterial, final long aAmount) { + return get(aPrefix, aMaterial, null, aAmount); + } + + public static ItemStack get(final OrePrefixes aPrefix, final Material aMaterial, final ItemStack aReplacement, + final long aAmount) { + return get(aPrefix.name()+Utils.sanitizeString(aMaterial.getLocalizedName()), aReplacement, aAmount, false, true); + } + + public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount, + final boolean aMentionPossibleTypos, final boolean aNoInvalidAmounts) { + if (aNoInvalidAmounts && (aAmount < 1L)) { + Logger.WARNING("Returning Null. Method: " + ReflectionUtils.getMethodName(0)); + Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(1)); + Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(2)); + Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(3)); + Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(4)); + return null; + } + if (!mNameMap.containsKey(aName.toString()) && aMentionPossibleTypos) { + Logger.WARNING("Unknown Key for Unification, Typo? " + aName); + } + return GT_Utility.copyAmount(aAmount, + new Object[] { mNameMap.get(aName.toString()), getFirstOre(aName, aAmount), aReplacement }); + } + + public static ItemStack getFirstOre(final Object aName, final long aAmount) { + if (GT_Utility.isStringInvalid(aName)) { + Logger.WARNING("Returning Null. Method: " + ReflectionUtils.getMethodName(0)); + Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(1)); + Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(2)); + Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(3)); + Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(4)); + return null; + } + final ItemStack tStack = mNameMap.get(aName.toString()); + if (GT_Utility.isStackValid(tStack)) { + Logger.WARNING("Found valid stack."); + return GT_Utility.copyAmount(aAmount, new Object[] { tStack }); + } + return GT_Utility.copyAmount(aAmount, getOres(aName).toArray()); + } + + public static ArrayList<ItemStack> getOres(final Object aOreName) { + final String aName = (aOreName == null) ? "" : aOreName.toString(); + final ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + if (GT_Utility.isStringValid(aName)) { + Logger.WARNING("Making a list of all OreDict entries for "+aOreName+"."); + if (rList.addAll(OreDictionary.getOres(aName))){ + Logger.WARNING("Added "+rList.size()+" elements to list."); + } + else { + Logger.WARNING("Failed to Add Collection from oreDictionary, forcing an entry."); + rList.add(ItemUtils.getItemStackOfAmountFromOreDict((String) aOreName, 1)); + } + } + return rList; + } + + @SuppressWarnings("unchecked") + public Map<String, ItemStack> getNameMap() { + Map<String, ItemStack> tempMap; + try { + tempMap = (Map<String, ItemStack>) FieldUtils.readStaticField(GT_OreDictUnificator.class, "sName2StackMap", + true); + if (tempMap != null) { + Logger.WARNING("Found 'sName2StackMap' in GT_OreDictUnificator.class."); + return tempMap; + } + } + catch (final IllegalAccessException e) { + e.printStackTrace(); + } + Logger.WARNING("Invalid map stored in GT_OreDictUnificator.class, unable to find sName2StackMap field."); + return null; + } + + public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, final int amount) { + + try { + + if (oredictName.contains("-") || oredictName.contains("_")) { + oredictName = Utils.sanitizeString(oredictName, new char[] {'-', '_'}); + } + else { + oredictName = Utils.sanitizeString(oredictName); + } + + // Adds a check to grab dusts using GT methodology if possible. + ItemStack returnValue = null; + if (oredictName.toLowerCase().contains("dust")) { + final String MaterialName = oredictName.toLowerCase().replace("dust", ""); + final Materials m = Materials.get(MaterialName); + if (m != null && m != Materials._NULL) { + returnValue = ItemUtils.getGregtechDust(m, amount); + if (ItemUtils.checkForInvalidItems(returnValue)) { + return returnValue; + } + } + } + if (returnValue == null) { + returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); + if (ItemUtils.checkForInvalidItems(returnValue)) { + return returnValue.copy(); + } + } + return null; + } catch (final Throwable t) { + return null; + } + } + + public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, final int amount) { + String mTemp = oredictName; + + // Banned Materials and replacements for GT5.8 compat. + + if (oredictName.toLowerCase().contains("ingotclay")) { + return ItemUtils.getSimpleStack(Items.clay_ball, amount); + } + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (oredictName.toLowerCase().contains("rutile")) { + mTemp = oredictName.replace("Rutile", "Titanium"); + } + if (oredictName.toLowerCase().contains("vanadiumsteel")) { + mTemp = oredictName.replace("VanadiumSteel", "StainlessSteel"); + } + } + final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(mTemp); + if (!oreDictList.isEmpty()) { + final ItemStack returnValue = oreDictList.get(0).copy(); + returnValue.stackSize = amount; + return returnValue; + } + return null; + //return getItemStackOfAmountFromOreDictNoBroken(mTemp, amount); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java new file mode 100644 index 0000000000..ea129a2b0e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java @@ -0,0 +1,264 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import java.util.HashSet; +import java.util.Set; + +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; +import net.minecraft.item.ItemStack; + +public class RecipeGen_ShapedCrafting extends RecipeGen_Base { + + public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); + static { + MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); + } + + public RecipeGen_ShapedCrafting(final Material M){ + this.toGenerate = M; + mRecipeGenMap.add(this); + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + private void generateRecipes(final Material material){ + Logger.WARNING("Generating Shaped Crafting recipes for "+material.getLocalizedName()); //TODO + + if (!CORE.GTNH) { + //Nuggets + if (ItemUtils.checkForInvalidItems(material.getNugget(1)) && ItemUtils.checkForInvalidItems(material.getIngot(1))) + GT_ModHandler.addShapelessCraftingRecipe( + material.getIngot(1), + new Object[]{ + material.getNugget(1), + material.getNugget(1), + material.getNugget(1), + material.getNugget(1), + material.getNugget(1), + material.getNugget(1), + material.getNugget(1), + material.getNugget(1), + material.getNugget(1) + }); + } + + //Plates + + //Single Plate Shaped/Shapeless + if (ItemUtils.checkForInvalidItems(material.getPlate(1)) && ItemUtils.checkForInvalidItems(material.getIngot(1))) + if (material.getPlate(1) != null && material.getIngot(1) != null) + GT_ModHandler.addCraftingRecipe( + material.getPlate(1), + gregtech.api.util.GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | gregtech.api.util.GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"h", "B", "I", + Character.valueOf('I'), + material.getIngot(1), + Character.valueOf('B'), + material.getIngot(1)}); + + if (ItemUtils.checkForInvalidItems(material.getPlate(1)) && ItemUtils.checkForInvalidItems(material.getIngot(1))) + GT_ModHandler.addShapelessCraftingRecipe( + material.getPlate(1), + new Object[]{gregtech.api.enums.ToolDictNames.craftingToolForgeHammer, + material.getIngot(1), + material.getIngot(1)}); + + //Double Plate Shaped/Shapeless + if (ItemUtils.checkForInvalidItems(material.getPlateDouble(1)) && ItemUtils.checkForInvalidItems(material.getPlate(1))) + GT_ModHandler.addCraftingRecipe( + material.getPlateDouble(1), + gregtech.api.util.GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | gregtech.api.util.GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"I", "B", "h", + Character.valueOf('I'), + material.getPlate(1), + Character.valueOf('B'), + material.getPlate(1)}); + + if (ItemUtils.checkForInvalidItems(material.getPlateDouble(1)) && ItemUtils.checkForInvalidItems(material.getPlate(1))) + GT_ModHandler.addShapelessCraftingRecipe( + material.getPlateDouble(1), + new Object[]{gregtech.api.enums.ToolDictNames.craftingToolForgeHammer, + material.getPlate(1), + material.getPlate(1)}); + + //Ring Recipe + if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getRing(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) { + if (CORE.GTNH){ + if (RecipeUtils.addShapedRecipe( + "craftingToolHardHammer", null, null, + "craftingToolFile", material.getRod(1), null, + null, null, null, + material.getRing(1))){ + Logger.WARNING("GT:NH Ring Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("GT:NH Ring Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + else { + if (RecipeUtils.addShapedRecipe( + "craftingToolHardHammer", null, null, + null, material.getRod(1), null, + null, null, null, + material.getRing(1))){ + Logger.WARNING("Ring Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Ring Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + } + + + //Framebox Recipe + if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getFrameBox(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) { + final ItemStack stackStick = material.getRod(1); + if (RecipeUtils.addShapedRecipe( + stackStick, stackStick, stackStick, + stackStick, "craftingToolWrench", stackStick, + stackStick, stackStick, stackStick, + material.getFrameBox(2))){ + Logger.WARNING("Framebox Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Framebox Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + + /*final int tVoltageMultiplier = material.getMeltingPointK() >= 1600 ? 60 : 15; + + + //Add a shapeless recipe for each dust this way - Compat mode. + ItemStack[] inputStacks = material.getMaterialComposites(); + ItemStack outputStacks = material.getDust(material.smallestStackSizeWhenProcessing); + + if (inputStacks.length > 0 && tVoltageMultiplier == 15){ + Utils.LOG_WARNING(ItemUtils.getArrayStackNames(inputStacks)); + long[] inputStackSize = material.vSmallestRatio; + if (inputStackSize != null){ + for (short x=0;x<inputStacks.length;x++){ + if (inputStacks[x] != null && inputStackSize[x] != 0) + inputStacks[x].stackSize = (int) inputStackSize[x]; + } + Utils.LOG_WARNING(ItemUtils.getArrayStackNames(inputStacks)); + if (RecipeUtils.buildShapelessRecipe( + outputStacks, + inputStacks + )){ + Utils.LOG_WARNING("Shapeless Crafting Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Utils.LOG_WARNING("Shapeless Crafting Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + } */ + + + //Shaped Recipe - Bolts + if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getBolt(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) { + if (RecipeUtils.addShapedRecipe( + "craftingToolSaw", null, null, + null, material.getRod(1), null, + null, null, null, + material.getBolt(2))){ + Logger.WARNING("Bolt Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Bolt Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + + //Shaped Recipe - Ingot to Rod + if (ItemUtils.checkForInvalidItems(material.getRod(1)) && ItemUtils.checkForInvalidItems(material.getIngot(1))) + if (RecipeUtils.addShapedRecipe( + "craftingToolFile", null, null, + null, material.getIngot(1), null, + null, null, null, + material.getRod(1))){ + Logger.WARNING("Rod Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Rod Recipe: "+material.getLocalizedName()+" - Failed"); + } + + + //Shaped Recipe - Long Rod to two smalls + if (ItemUtils.checkForInvalidItems(material.getRod(1)) && ItemUtils.checkForInvalidItems(material.getLongRod(1))) + if (RecipeUtils.addShapedRecipe( + "craftingToolSaw", null, null, + material.getLongRod(1), null, null, + null, null, null, + material.getRod(2))){ + Logger.WARNING("Rod Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Rod Recipe: "+material.getLocalizedName()+" - Failed"); + } + + //Two small to long rod + if (ItemUtils.checkForInvalidItems(material.getLongRod(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) + if (RecipeUtils.addShapedRecipe( + material.getRod(1), "craftingToolHardHammer", material.getRod(1), + null, null, null, + null, null, null, + material.getLongRod(1))){ + Logger.WARNING("Long Rod Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Long Rod Recipe: "+material.getLocalizedName()+" - Failed"); + } + + //Rotor Recipe + if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getRotor(1)) && ItemUtils.checkForInvalidItems(material.getRing(1)) && !material.isRadioactive && ItemUtils.checkForInvalidItems(material.getPlate(1)) && ItemUtils.checkForInvalidItems(material.getScrew(1))) { + if (RecipeUtils.addShapedRecipe( + material.getPlate(1), "craftingToolHardHammer", material.getPlate(1), + material.getScrew(1), material.getRing(1), "craftingToolFile", + material.getPlate(1), "craftingToolScrewdriver", material.getPlate(1), + material.getRotor(1))){ + Logger.WARNING("Rotor Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Rotor Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + //Gear Recipe + if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getGear(1)) && ItemUtils.checkForInvalidItems(material.getPlate(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) { + if (RecipeUtils.addShapedRecipe( + material.getRod(1), material.getPlate(1), material.getRod(1), + material.getPlate(1), "craftingToolWrench", material.getPlate(1), + material.getRod(1), material.getPlate(1), material.getRod(1), + material.getGear(1))){ + Logger.WARNING("Gear Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Gear Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + + //Screws + if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getScrew(1)) && ItemUtils.checkForInvalidItems(material.getBolt(1))) { + if (RecipeUtils.addShapedRecipe( + "craftingToolFile", material.getBolt(1), null, + material.getBolt(1), null, null, + null, null, null, + material.getScrew(1))){ + Logger.WARNING("Screw Recipe: "+material.getLocalizedName()+" - Success"); + } + else { + Logger.WARNING("Screw Recipe: "+material.getLocalizedName()+" - Failed"); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java new file mode 100644 index 0000000000..2e6de159d0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java @@ -0,0 +1,28 @@ +package gtPlusPlus.xmod.gregtech.loaders.misc; + +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_ProcessingArray_Manager; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; + +public class AddCustomMachineToPA { + + public static final void registerRecipeMapForID(int aID, GT_Recipe_Map aMap) { + Logger.INFO("Attempting to add map "+aMap.mNEIName+" to Processing Array for Meta Tile "+aID+". Success? "+GT_ProcessingArray_Manager.registerRecipeMapForMeta(aID, aMap)); + } + + public static final void registerRecipeMapBetweenRangeOfIDs(int aMin, int aMax, GT_Recipe_Map aMap) { + for (int i=aMin; i<=aMax;i++) { + registerRecipeMapForID(i, aMap); + } + } + + public static void register() { + + // Simple Washers + registerRecipeMapForID(767, GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes); + registerRecipeMapBetweenRangeOfIDs(31017, 31020, GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes); + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java new file mode 100644 index 0000000000..351a4cc546 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java @@ -0,0 +1,180 @@ +package gtPlusPlus.xmod.gregtech.loaders.misc; + +import java.util.concurrent.ConcurrentHashMap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.GT_Mod; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatBase; +import net.minecraftforge.common.AchievementPage; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; + +public class AssLineAchievements { + + public static int assReg = -1; + public static ConcurrentHashMap<String, Achievement> mAchievementMap; + public static ConcurrentHashMap<String, Boolean> mIssuedAchievementMap; + public static int adjX = 5; + public static int adjY = 9; + private static boolean active = true; + + public AssLineAchievements() { + Logger.INFO(active ? "Loading custom achievement page for Assembly Line recipes." + : "Achievements are disabled."); + Utils.registerEvent(this); + } + + private static boolean ready = false; + private static int recipeTotal = 0; + private static int recipeCount = 0; + private static void init() { + if (!ready) { + active = GT_Mod.gregtechproxy.mAchievements; + try { + recipeTotal = ((GT_Recipe.GT_Recipe_Map) StaticFields59.mAssLineVisualMapNEI.get(null)).mRecipeList.size(); + } catch (IllegalArgumentException | IllegalAccessException e) { + recipeTotal = 0; + } + mAchievementMap = new ConcurrentHashMap<String, Achievement>(); + mIssuedAchievementMap = new ConcurrentHashMap<String, Boolean>(); + ready = true; + } + + } + + public static void registerAchievements() { + if (active && mAchievementMap.size() > 0) { + AchievementPage.registerAchievementPage(new AchievementPage("GT Assembly Line", + (Achievement[]) mAchievementMap.values().toArray(new Achievement[mAchievementMap.size()]))); + } + else if (active) { + Logger.INFO("Unable to register custom achievement page for Assembly Line recipes."); + } + } + + public static Achievement registerAssAchievement(GT_Recipe recipe) { + init(); + String aSafeUnlocalName; + // Debugging + if (recipe == null) { + Logger.INFO( + "Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + return null; + } + if (recipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + return null; + } + ItemStack aStack = recipe.getOutput(0); + try { + aSafeUnlocalName = aStack.getUnlocalizedName(); + } catch (Throwable t) { + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + } + + Achievement aYouDidSomethingInGT; + if (mAchievementMap.get(aSafeUnlocalName) == null) { + assReg++; + recipeCount++; + aYouDidSomethingInGT = registerAchievement(aSafeUnlocalName, -(11 + assReg % 5), ((assReg) / 5) - 8, + recipe.getOutput(0), AchievementList.openInventory, false); + } + else { + aYouDidSomethingInGT = null; + } + if (recipeCount >= recipeTotal) { + Logger.INFO("Critical mass achieved. ["+recipeCount+"]"); + registerAchievements(); + } + + return aYouDidSomethingInGT; + } + + public static Achievement registerAchievement(String textId, int x, int y, ItemStack icon, + Achievement requirement, boolean special) { + if (!GT_Mod.gregtechproxy.mAchievements) { + return null; + } + Achievement achievement = new Achievement(textId, textId, adjX + x, adjY + y, icon, requirement); + if (special) { + achievement.setSpecial(); + } + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + mAchievementMap.put(textId, achievement); + return achievement; + } + + public static void issueAchievement(EntityPlayer entityplayer, String textId) { + if (entityplayer == null || !GT_Mod.gregtechproxy.mAchievements) { + return; + } + + entityplayer.triggerAchievement((StatBase) getAchievement(textId)); + } + + public static Achievement getAchievement(String textId) { + if (mAchievementMap.containsKey(textId)) { + Logger.INFO("Found Achivement: "+textId); + return (Achievement) mAchievementMap.get(textId); + } + return null; + } + + @SubscribeEvent + public void onItemPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack stack = event.item.getEntityItem(); + String aPickupUnlocalSafe = ItemUtils.getUnlocalizedItemName(stack); + if (player == null || stack == null) { + return; + } + + if (StaticFields59.sAssemblylineVisualRecipes == null) { + return; + } + + Logger.INFO("Trying to check for achievements"); + // Debug scanner unlocks all AL recipes in creative + if (player.capabilities.isCreativeMode && aPickupUnlocalSafe.equals("gt.metaitem.01.32761")) { + for (GT_Recipe recipe : StaticFields59.sAssemblylineVisualRecipes.mRecipeList) { + issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); + recipe.mHidden = false; + } + } + for (GT_Recipe recipe : StaticFields59.sAssemblylineVisualRecipes.mRecipeList) { + + String aSafeUnlocalName; + if (recipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + continue; + } + ItemStack aStack = recipe.getOutput(0); + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + if (aSafeUnlocalName.equals(aPickupUnlocalSafe)) { + issueAchievement(player, aSafeUnlocalName); + recipe.mHidden = false; + Logger.INFO("FOUND: " + aSafeUnlocalName + " | " + aPickupUnlocalSafe); + } + else { + //Logger.INFO(aSafeUnlocalName + " | " + aPickupUnlocalSafe); + } + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java new file mode 100644 index 0000000000..053c71c89d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java @@ -0,0 +1,207 @@ +package gtPlusPlus.xmod.gregtech.loaders.recipe; + +import java.util.HashMap; + +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.WeightedCollection; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeLoader_AlgaeFarm { + + private static final HashMap<Integer, AutoMap<GT_Recipe>> mRecipeCache = new HashMap<Integer, AutoMap<GT_Recipe>>(); + private static final HashMap<Integer, AutoMap<GT_Recipe>> mRecipeCompostCache = new HashMap<Integer, AutoMap<GT_Recipe>>(); + + public static final void generateRecipes() { + for (int i=0;i<10;i++) { + getTieredRecipeFromCache(i, false); + } + for (int i=0;i<10;i++) { + getTieredRecipeFromCache(i, true); + } + } + + public static GT_Recipe getTieredRecipeFromCache(int aTier, boolean aCompost) { + HashMap<Integer, AutoMap<GT_Recipe>> aMap = aCompost ? mRecipeCompostCache : mRecipeCache; + String aComp = aCompost ? "(Compost)" : ""; + + AutoMap<GT_Recipe> aTemp = aMap.get(aTier); + if (aTemp == null || aTemp.isEmpty()) { + aTemp = new AutoMap<GT_Recipe>(); + aMap.put(aTier, aTemp); + Logger.INFO("Tier "+aTier+aComp+" had no recipes, initialising new map."); + } + if (aTemp.size() < 500) { + Logger.INFO("Tier "+aTier+aComp+" has less than 500 recipes, generating "+(500 - aTemp.size())+"."); + for (int i=aTemp.size();i<500;i++) { + aTemp.put(generateBaseRecipe(aCompost, aTier)); + } + } + int aIndex = MathUtils.randInt(0, aTemp.isEmpty() ? 1 : aTemp.size()); + Logger.INFO("Using recipe with index of "+aIndex+". "+aComp); + return aTemp.get(aIndex); + } + + private static GT_Recipe generateBaseRecipe(boolean aUsingCompost, int aTier) { + + // Type Safety + if (aTier < 0) { + return null; + } + + WeightedCollection<Float> aOutputTimeMulti = new WeightedCollection<Float>(); + for (int i=100;i> 0;i--) { + float aValue = 0; + if (i < 10) { + aValue = 3f; + } + else if (i < 20) { + aValue = 2f; + } + else { + aValue = 1f; + } + aOutputTimeMulti.put(i, aValue); + } + + final int[] aDurations = new int[] { + 432000, + 378000, + 216000, + 162000, + 108000, + 81000, + 54000, + 40500, + 27000, + 20250, + 13500, + 6750, + 3375, + 1686, + 843, + 421 + }; + + ItemStack[] aInputs = new ItemStack[] {}; + + if (aUsingCompost) { + // Make it use 4 compost per tier if we have some available + ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, aTier * 4); + aInputs = new ItemStack[] {aCompost}; + // Boost Tier by one if using compost so it gets a speed boost + aTier++; + } + + // We set these elsewhere + ItemStack[] aOutputs = getOutputsForTier(aTier); + + GT_Recipe tRecipe = new GTPP_Recipe( + false, + aInputs, + aOutputs, + (Object) null, + new int[] {}, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {GT_Values.NF}, + (int) (aDurations[aTier] * aOutputTimeMulti.get() / 2), // Time + 0, + 0); + + tRecipe.mSpecialValue = tRecipe.hashCode(); + + return tRecipe; + } + + private static ItemStack[] getOutputsForTier(int aTier) { + + // Create an Automap to dump contents into + AutoMap<ItemStack> aOutputMap = new AutoMap<ItemStack>(); + + // Buff output by yielding 6-8 times more. + for (int i=0;i<MathUtils.randInt(4, 8);i++) { + // Add loot relevant to tier and also add any from lower tiers. + if (aTier >= 0) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(16, 32))); + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(32, 64))); + if (MathUtils.randInt(0, 10) > 9) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(8, 16))); + } + } + if (aTier >= 1) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(16, 32))); + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(16, 32))); + if (MathUtils.randInt(0, 10) > 9) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(4, 8))); + } + } + if (aTier >= 2) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(8, 16))); + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(16, 32))); + if (MathUtils.randInt(0, 10) > 9) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(4, 8))); + } + } + if (aTier >= 3) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(16, 32))); + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(2, 8))); + if (MathUtils.randInt(0, 10) > 9) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(8, 16))); + } + } + if (aTier >= 4) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(16, 32))); + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(32, 64))); + if (MathUtils.randInt(0, 10) > 9) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.randInt(4, 8))); + } + } + if (aTier >= 5) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.randInt(16, 32))); + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.randInt(16, 32))); + if (MathUtils.randInt(0, 10) > 9) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(1, 2))); + } + } + // Tier 6 is Highest for outputs + if (aTier >= 6) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.randInt(16, 32))); + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(8, 16))); + if (MathUtils.randInt(0, 10) > 9) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(8, 16))); + } + } + + // Iterate a special loop at higher tiers to provide more Red/Gold Algae. + for (int i2=0;i2<(9-aTier);i2++) { + if (aTier >= (6+i2)) { + int aMulti = i2 + 1; + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.randInt(4, 8*aMulti))); + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(4, 8*aMulti))); + if (MathUtils.randInt(0, 10) > 8) { + aOutputMap.put(ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.randInt(8, 16*aMulti))); + } + } + } + } + + + + // Map the AutoMap contents to an Itemstack Array. + ItemStack[] aOutputs = new ItemStack[aOutputMap.size()]; + for (int i=0;i<aOutputMap.size();i++) { + aOutputs[i] = aOutputMap.get(i); + } + + // Return filled ItemStack Array. + return aOutputs; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_GTNH.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_GTNH.java new file mode 100644 index 0000000000..0197142e96 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_GTNH.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.loaders.recipe; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gtPlusPlus.core.material.ELEMENT; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeLoader_GTNH { + + public static void generate() { + GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Ball.get(0L), new FluidStack(FluidRegistry.getFluid("ender"), 250), new ItemStack(Items.ender_pearl, 1, 0), 100, 30); + //MK4 + GT_Values.RA.addFusionReactorRecipe(Materials.Plutonium241.getMolten(144), Materials.Helium.getGas(1000), ELEMENT.getInstance().CURIUM.getFluidStack(144), 96, 98304, 500000000); + GT_Values.RA.addFusionReactorRecipe(ELEMENT.getInstance().CURIUM.getFluidStack(144), Materials.Helium.getPlasma(144), ELEMENT.getInstance().CALIFORNIUM.getFluidStack(144), 128, 196608, 750000000); + GT_Values.RA.addFusionReactorRecipe(Materials.Plutonium241.getMolten(144), Materials.Calcium.getPlasma(144), Materials.Flerovium.getMolten(144), 160, 196608, 1000000000); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_LFTR.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_LFTR.java new file mode 100644 index 0000000000..a09cbcce0d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_LFTR.java @@ -0,0 +1,173 @@ +package gtPlusPlus.xmod.gregtech.loaders.recipe; + +import gregtech.api.enums.Materials; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GasSpargingRecipeMap; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.material.nuclear.NUCLIDE; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeLoader_LFTR { + + private static AutoMap<Fluid> mNobleGases; + private static AutoMap<Fluid> mFluorideGases; + private static AutoMap<Fluid> mSpargeGases; + + private static void configureSparging() { + if (mSpargeGases == null) { + mSpargeGases = new AutoMap<Fluid>(); + mSpargeGases.add(Materials.Helium.getGas(1).getFluid()); + mSpargeGases.add(Materials.Fluorine.getGas(1).getFluid()); + } + if (mNobleGases == null) { + mNobleGases = new AutoMap<Fluid>(); + mNobleGases.add(mSpargeGases.get(0)); + mNobleGases.add(ELEMENT.getInstance().XENON.getFluid()); + mNobleGases.add(ELEMENT.getInstance().NEON.getFluid()); + mNobleGases.add(ELEMENT.getInstance().ARGON.getFluid()); + mNobleGases.add(ELEMENT.getInstance().KRYPTON.getFluid()); + mNobleGases.add(ELEMENT.getInstance().RADON.getFluid()); + } + if (mFluorideGases == null) { + mFluorideGases = new AutoMap<Fluid>(); + mFluorideGases.add(mSpargeGases.get(1)); + mFluorideGases.add(FLUORIDES.LITHIUM_FLUORIDE.getFluid()); + mFluorideGases.add(FLUORIDES.NEPTUNIUM_HEXAFLUORIDE.getFluid()); + mFluorideGases.add(FLUORIDES.TECHNETIUM_HEXAFLUORIDE.getFluid()); + mFluorideGases.add(FLUORIDES.SELENIUM_HEXAFLUORIDE.getFluid()); + mFluorideGases.add(FLUORIDES.THORIUM_TETRAFLUORIDE.getFluid()); + } + } + + public static void generate() { + // Fli2BeF4 + Thorium TetraFluoride = Uranium233 + //72k Ticks/hr + //1l/4t = 1000l/hr + //1l/40t = 1000l/10hr (Probably better) LiFBeF2ThF4UF4 + //1l/20t= 1000l/2.5hr LiFBeF2ZrF4UF4 + //1l/10t= 1000l/2.5hr LiFBeF2ZrF4U235 + + configureSparging(); + FluidStack Li2BeF4 = NUCLIDE.Li2BeF4.getFluidStack(200); + + //LiFBeF2ThF4UF4 - T3 + GT_Recipe LFTR1 = new GTPP_Recipe( + false, + new ItemStack[] {}, + new ItemStack[] {}, + null, new int[] {10000, 10000, 5000, 2500}, + new FluidStack[] { + NUCLIDE.LiFBeF2ThF4UF4.getFluidStack(100), + Li2BeF4 + }, + new FluidStack[] { + NUCLIDE.LiFBeF2UF4FP.getFluidStack(100), + NUCLIDE.LiFBeF2ThF4.getFluidStack(200), + FLUORIDES.URANIUM_HEXAFLUORIDE.getFluidStack(20), + FLUORIDES.URANIUM_HEXAFLUORIDE.getFluidStack(10) + }, + 400 * 20,//time + 0,//cost + 8192*4//fuel value + ); + + //LiFBeF2ZrF4UF4 - T2 + GT_Recipe LFTR2 = new GTPP_Recipe( + false, + new ItemStack[] {}, + new ItemStack[] {}, + null, new int[] {10000, 10000, 2500, 1250}, + new FluidStack[] { + NUCLIDE.LiFBeF2ZrF4UF4.getFluidStack(100), + Li2BeF4 + }, + new FluidStack[] { + NUCLIDE.LiFBeF2UF4FP.getFluidStack(50), + NUCLIDE.LiFBeF2ThF4.getFluidStack(100), + FLUORIDES.URANIUM_HEXAFLUORIDE.getFluidStack(10), + FLUORIDES.URANIUM_HEXAFLUORIDE.getFluidStack(5) + }, + 400 * 20,//time + 0,//cost + 8192//fuel value + ); + + //LiFBeF2ZrF4U235 - T1 + GT_Recipe LFTR3 = new GTPP_Recipe( + false, + new ItemStack[] {}, + new ItemStack[] {}, + null, new int[] {10000, 10000, 1000, 500}, + new FluidStack[] { + NUCLIDE.LiFBeF2ZrF4U235.getFluidStack(100), + Li2BeF4 + }, + new FluidStack[] { + NUCLIDE.LiFBeF2UF4FP.getFluidStack(25), + NUCLIDE.LiFThF4.getFluidStack(50), + FLUORIDES.URANIUM_HEXAFLUORIDE.getFluidStack(4), + FLUORIDES.URANIUM_HEXAFLUORIDE.getFluidStack(2) + }, + 100 *20,//time + 0,//cost + 8192//fuel value + ); + + // Sparging NEI Recipes + GasSpargingRecipeMap.addRecipe( + new FluidStack(mSpargeGases.get(0), 50), + NUCLIDE.LiFBeF2UF4FP.getFluidStack(50), + NUCLIDE.Sparged_LiFBeF2UF4FP.getFluidStack(50), + new FluidStack[] { + new FluidStack(mNobleGases.get(1), 10), + new FluidStack(mNobleGases.get(2), 10), + new FluidStack(mNobleGases.get(3), 10), + new FluidStack(mNobleGases.get(4), 10), + new FluidStack(mNobleGases.get(5), 10) + }, + new int[] { + 1000, 1000, 1000, 1000, 1000 + }); + + GasSpargingRecipeMap.addRecipe( + new FluidStack(mSpargeGases.get(1), 50), + NUCLIDE.LiFThF4.getFluidStack(50), + NUCLIDE.Sparged_LiFThF4.getFluidStack(50), + new FluidStack[] { + new FluidStack(mFluorideGases.get(1), 5), + new FluidStack(mFluorideGases.get(2), 5), + new FluidStack(mFluorideGases.get(3), 5), + new FluidStack(mFluorideGases.get(4), 5), + new FluidStack(mFluorideGases.get(5), 5) + }, + new int[] { + 500, 500, 500, 500, 500 + }); + + GasSpargingRecipeMap.addRecipe( + new FluidStack(mSpargeGases.get(1), 50), + NUCLIDE.LiFBeF2ThF4.getFluidStack(50), + NUCLIDE.Sparged_LiFBeF2ThF4.getFluidStack(50), + new FluidStack[] { + new FluidStack(mFluorideGases.get(1), 10), + new FluidStack(mFluorideGases.get(2), 10), + new FluidStack(mFluorideGases.get(3), 10), + new FluidStack(mFluorideGases.get(4), 10), + new FluidStack(mFluorideGases.get(5), 10) + }, + new int[] { + 1000, 1000, 1000, 1000, 1000 + }); + + GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.add(LFTR1); + GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.add(LFTR2); + GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.add(LFTR3); + + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_Nuclear.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_Nuclear.java new file mode 100644 index 0000000000..330d507115 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_Nuclear.java @@ -0,0 +1,695 @@ +package gtPlusPlus.xmod.gregtech.loaders.recipe; + +import static gtPlusPlus.core.lib.CORE.GTNH; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.chemistry.GenericChem; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.material.nuclear.NUCLIDE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeLoader_Nuclear { + + + + public static void generate() { + createRecipes(); + RecipeLoader_LFTR.generate(); + RecipeLoader_NuclearFuelProcessing.generate(); + } + + private static void createRecipes() { + autoclave(); + blastFurnace(); + centrifugeRecipes(); + chemicalBathRecipes(); + chemicalReactorRecipes(); + dehydratorRecipes(); + electroMagneticSeperator(); + fluidExtractorRecipes(); + fluidHeater(); + macerator(); + mixerRecipes(); + sifter(); + } + + private static void autoclave() { + + GT_Values.RA.addAutoclaveRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 9), + FluidUtils.getFluidStack("chlorine", 9 * 4 * 144), + ItemUtils.getItemStackOfAmountFromOreDict("pelletZirconium", 9), + 0, + 120 * 20, + 30); + + } + + private static void blastFurnace() { + + GT_Values.RA.addBlastRecipe( + FLUORIDES.LITHIUM_FLUORIDE.getDust(2), + FLUORIDES.BERYLLIUM_FLUORIDE.getDust(1), + GT_Values.NF, + GT_Values.NF, + NUCLIDE.Li2BeF4.getDust(3), + null, + 60 * 20, 2000, + 3000); + + GT_Values.RA.addBlastRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustZrCl4", 1), + null, + GT_Values.NF, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustCookedZrCl4", 1), + null, + 60 * 20, + 340, + 300); + + } + + + private static void centrifugeRecipes() { + + //Process Used Fuel Rods for Krypton + + //Uranium + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + ItemUtils.getItemStackFromFQRN("IC2:reactorUraniumSimpledepleted", 8), + GT_Values.NF, + ELEMENT.getInstance().KRYPTON.getFluidStack(60), + ItemList.IC2_Fuel_Rod_Empty.get(8), + ELEMENT.getInstance().URANIUM238.getDust(2), + ELEMENT.getInstance().URANIUM232.getSmallDust(1), + ELEMENT.getInstance().URANIUM233.getSmallDust(1), + ELEMENT.getInstance().URANIUM235.getSmallDust(1), + ELEMENT.getInstance().PLUTONIUM239.getTinyDust(1), + new int[] { 0, 0, 1000, 1000, 1000, 500 }, 500 * 20, 4000); + //Mox + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + ItemUtils.getItemStackFromFQRN("IC2:reactorMOXSimpledepleted", 8), + GT_Values.NF, + ELEMENT.getInstance().KRYPTON.getFluidStack(90), + ItemList.IC2_Fuel_Rod_Empty.get(8), + ELEMENT.getInstance().PLUTONIUM244.getDust(2), + ELEMENT.getInstance().PLUTONIUM241.getTinyDust(1), + ELEMENT.getInstance().PLUTONIUM239.getTinyDust(1), + ELEMENT.getInstance().PLUTONIUM238.getTinyDust(1), + ELEMENT.getInstance().PLUTONIUM239.getTinyDust(1), + new int[] { 0, 0, 500, 500, 500, 500 }, 750 * 20, 4000); + + //Thorium + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + ItemList.Depleted_Thorium_1.get(8), + GT_Values.NF, + ELEMENT.getInstance().KRYPTON.getFluidStack(30), + ItemList.IC2_Fuel_Rod_Empty.get(8), + ELEMENT.getInstance().THORIUM.getDust(2), + ELEMENT.getInstance().THORIUM232.getDust(1), + ELEMENT.getInstance().LUTETIUM.getSmallDust(1), + ELEMENT.getInstance().POLONIUM.getSmallDust(1), + ELEMENT.getInstance().THALLIUM.getTinyDust(1), + new int[] { 0, 0, 5000, 5000, 5000, 2500 }, 250 * 20, 4000); + + } + + + private static void chemicalBathRecipes() { + + int[] chances = {9000, 6000, 3000}; + GT_Values.RA.addChemicalBathRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustTin", 12), + FluidUtils.getFluidStack("chlorine", 2400), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 3), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 4), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 5), + chances, + 30 * 20, + 480); + + chances = new int[]{9000, 3000, 1000}; + GT_Values.RA.addChemicalBathRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustRutile", 5), + FluidUtils.getFluidStack("chlorine", 4000), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 3), + ItemUtils.getItemStackOfAmountFromOreDict("dustTitanium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustHafnium", 1), + chances, + 30 * 20, + 1024); + + GT_Values.RA.addChemicalBathRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumCarbonate", 10), + FluidUtils.getFluidStack("hydrofluoricacid", 10 * 144), + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumFluoride", 10), + null, + null, + new int[] {}, + 90 * 20, + 500); + + } + + + private static void chemicalReactorRecipes() { + + ItemStack aGtHydrofluoricAcid = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellHydrofluoricAcid_GT5U", 2); + + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumCarbonate", 5), // Input + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumHydroxide", 5), // Input + null, // Fluid Input + null, // Fluid Output + ItemUtils.getItemStackOfAmountFromOreDict("dustLi2CO3CaOH2", 10), + 600 * 20); + + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 5), // Input + null, // Input Stack 2 + FluidUtils.getFluidStack("hydrofluoricacid", 5 * 144), + FluidUtils.getFluidStack("water", 5 * 144), // Fluid Output + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumFluoride", 5), + 600 * 20); + + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustLithium7", 1), null, + FluidUtils.getFluidStack("sulfuricacid", 144 * 8), + FluidUtils.getFluidStack("sulfuriclithium", 144 * 2), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallLithium7", 1), + 20 * 20); + + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustLithium7", 16), + FluidUtils.getFluidStack("water", 1000), + FluidUtils.getFluidStack("lithiumhydroxide", 144 * 4), + CI.emptyCells(1), + 300 * 20); + + // LFTR Fuel Related Compounds + if (GTNH) { + // Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + ELEMENT.getInstance().OXYGEN.getCell(1), + ELEMENT.getInstance().HYDROGEN.getFluidStack(1000), + MISC_MATERIALS.HYDROXIDE.getFluidStack(2000), + CI.emptyCells(2), + GT_Values.NI, + 8 * 20, + 30); + // Beryllium Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + ELEMENT.getInstance().BERYLLIUM.getDust(7), + MISC_MATERIALS.HYDROXIDE.getFluidStack(1000), + FLUORIDES.BERYLLIUM_HYDROXIDE.getFluidStack(2000), + GT_Values.NI, + 8 * 20, + 30); + // Ammonium Bifluoride + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 1), + MISC_MATERIALS.AMMONIUM.getFluidStack(1000), + FLUORIDES.AMMONIUM_BIFLUORIDE.getFluidStack(2000), + CI.emptyCells(1), + 20 * 20, + 30); + if (aGtHydrofluoricAcid != null) { + // Ammonium Bifluoride + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + aGtHydrofluoricAcid, + MISC_MATERIALS.AMMONIUM.getFluidStack(1000), + FLUORIDES.AMMONIUM_BIFLUORIDE.getFluidStack(2000), + CI.emptyCells(2), + 40 * 20, + 30); + } + // Ammonium + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + ELEMENT.getInstance().HYDROGEN.getCell(1), + MISC_MATERIALS.AMMONIA.getFluidStack(1000), + MISC_MATERIALS.AMMONIUM.getFluidStack(2000), + CI.emptyCells(1), + GT_Values.NI, + 20 * 20, + 30); + } + + if (!GTNH) { + // Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + ELEMENT.getInstance().OXYGEN.getCell(1), + ELEMENT.getInstance().HYDROGEN.getFluidStack(1000), + MISC_MATERIALS.HYDROXIDE.getFluidStack(2000), + CI.emptyCells(2), + GT_Values.NI, + 8 * 20, + 30); + // Beryllium Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + ELEMENT.getInstance().BERYLLIUM.getDust(7), + MISC_MATERIALS.HYDROXIDE.getFluidStack(1000), + FLUORIDES.BERYLLIUM_HYDROXIDE.getFluidStack(2000), + GT_Values.NI, + 8 * 20, + 30); + // Ammonium Bifluoride + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 1), + MISC_MATERIALS.AMMONIUM.getFluidStack(1000), + FLUORIDES.AMMONIUM_BIFLUORIDE.getFluidStack(3000), + CI.emptyCells(1), + 20 * 20, + 30); + + if (aGtHydrofluoricAcid != null) { + // Ammonium Bifluoride + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + aGtHydrofluoricAcid, + MISC_MATERIALS.AMMONIUM.getFluidStack(1000), + FLUORIDES.AMMONIUM_BIFLUORIDE.getFluidStack(2000), + CI.emptyCells(2), + 40 * 20, + 30); + } + + // Ammonium + GT_Values.RA.addChemicalRecipe( + ItemUtils.getGregtechCircuit(3), + ELEMENT.getInstance().HYDROGEN.getCell(1), + MISC_MATERIALS.AMMONIA.getFluidStack(1000), + MISC_MATERIALS.AMMONIUM.getFluidStack(2000), + CI.emptyCells(1), + GT_Values.NI, + 20 * 20, + 30); + // Ammonia + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 3), + ItemUtils.getItemStackOfAmountFromOreDict("dustMagnetite", 0), + FluidUtils.getFluidStack("nitrogen", 1000), + FluidUtils.getFluidStack("ammonia", 1000), + CI.emptyCells(3), + 14 * 20); + } + + + //Technetium + GT_Values.RA.addChemicalRecipe( + CI.getNumberedAdvancedCircuit(22), + ItemUtils.getItemStackOfAmountFromOreDict("dustTechnetium99", 1), + FluidUtils.getFluidStack("sulfuricacid", 1000), + FluidUtils.getFluidStack("sulfuricacid", 144 * 2), + ItemUtils.getItemStackOfAmountFromOreDict("dustTechnetium", 1), + 100 * 20); + + // Sodium Hydroxide + GT_Values.RA.addChemicalRecipe( + CI.getNumberedBioCircuit(15), + ItemUtils.getItemStackOfAmountFromOreDict("dustSodiumHydroxide", 1), + FluidUtils.getFluidStack("hydrofluoricacid", 500), + FluidUtils.getWater(1000), + FLUORIDES.SODIUM_FLUORIDE.getDust(1), + 60 * 20); + + if (FluidUtils.doesFluidExist("hydrofluoricacid_gt5u")) { + GT_Values.RA.addChemicalRecipe( + CI.getNumberedBioCircuit(15), + ItemUtils.getItemStackOfAmountFromOreDict("dustSodiumHydroxide", 1), + FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 1000), + FluidUtils.getWater(1000), + FLUORIDES.SODIUM_FLUORIDE.getDust(1), + 60 * 20); + } + + } + + private static void dehydratorRecipes() { + + // Makes 7-Lithium + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(14), + ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricLithium", 1) + }, + FluidUtils.getFluidStack("sulfuriclithium", 440), + null, + new ItemStack[] { + CI.emptyCells(1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 3), + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSodium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustLithium7", 4) + }, + new int[] {10000, 10000, 10000, 10000, 10000}, + 30 * 20, + 30); + + // Makes Lithium Carbonate + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.emptyCells(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustLepidolite", 20) + }, // Item input (Array, up to 2) + FluidUtils.getFluidStack("sulfuricacid", 10000), + FluidUtils.getFluidStack("sulfuriclithium", 10000), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustPotassium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustAluminium", 4), + ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 10), + ItemUtils.getItemStackOfAmountFromOreDict("cellFluorine", 2), + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumCarbonate", 3), // LithiumCarbonate + }, // Output Array of Items - Upto 9, + new int[] { 10000, 10000, 10000, 10000, 10000 }, + 75 * 20, // Time in ticks + 1000); // EU + + // Calcium Hydroxide + if ((ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDict("dustQuicklime", 1))) || LoadedMods.IHL) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedBioCircuit(20), + ItemUtils.getItemStackOfAmountFromOreDict("dustQuicklime", 10) + }, + FluidUtils.getFluidStack("water", 10000), + null, // Fluid output (slot 2) + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumHydroxide", 20) + }, // Output + new int[] { 10000 }, + 120 * 20, // Time in ticks + 120); // EU + } + else { + Logger.INFO("[dustCalciumHydroxide] FAILED TO LOAD RECIPE"); + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDict("dustQuicklime", 1))) { + Logger.INFO("Could not find dustQuicklime, cannot make dustCalciumHydroxide."); + } + else if (!LoadedMods.IHL) { + Logger.INFO("IHL not loaded."); + } + } + + // 2 LiOH + CaCO3 + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(20), + ItemUtils.getItemStackOfAmountFromOreDict("dustLi2CO3CaOH2", 5) + }, // Item + null, // Fluid input (slot 1) + null, // Fluid output (slot 2) + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 2), + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumCarbonate", 3) + }, // Output + new int[] { 10000, 10000 }, + 120 * 20, // Time in ticks + 1000); // EU + + // LiOH Liquid to Dust + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(22) + }, + FluidUtils.getFluidStack("lithiumhydroxide", 144), + null, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 1) + }, + new int[] { 10000 }, + 1 * 20, // Time in ticks + 64); // EU + + // Zirconium Chloride -> TetraFluoride + FluidStack aHydrogenChloride = new FluidStack(GenericChem.HydrochloricAcid, 9000); + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(11), + ItemUtils.getItemStackOfAmountFromOreDict("dustCookedZrCl4", 9), + }, // Item + FluidUtils.getFluidStack("hydrofluoricacid", 9 * 144), + aHydrogenChloride, + new ItemStack[] { + FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getDust(9) + }, + new int[] { 10000 }, + 120 * 20, // Time in ticks + 500); // EU + + // Zirconium Chloride -> TetraFluoride + FluidStack aGregtechHydro = FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 1); + if (aGregtechHydro != null || Utils.getGregtechVersionAsInt() >= 50929) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(10), + ItemUtils.getItemStackOfAmountFromOreDict("dustCookedZrCl4", 9) + }, + FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 18 * 144), + aHydrogenChloride, + new ItemStack[] { + FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getDust(9) + }, + new int[] { 10000 }, + 240 * 20, // Time in ticks + 500); // EU + } + + // Be(OH)2 + 2 (NH4)HF2 → (NH4)2BeF4 + 2 H2O + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(6), + FLUORIDES.AMMONIUM_BIFLUORIDE.getCell(4) + }, + FLUORIDES.BERYLLIUM_HYDROXIDE.getFluidStack(2000), // Fluid input (slot 1) + FLUORIDES.AMMONIUM_TETRAFLUOROBERYLLATE.getFluidStack(6000), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellWater", 4) + }, + new int[] { 10000}, + 32 * 20, // Time in ticks + 64); // EU + + // (NH4)2BeF4 → 2 NH3 + 2 HF + BeF2 + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(17), + CI.emptyCells(5) + }, + FLUORIDES.AMMONIUM_TETRAFLUOROBERYLLATE.getFluidStack(5000), + null, + new ItemStack[] { + MISC_MATERIALS.AMMONIA.getCell(2), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 2), + FLUORIDES.BERYLLIUM_FLUORIDE.getCell(1) + }, + new int[] {10000, 10000, 10000}, + 5 * 60 * 20, + 120); + + } + + private static void electroMagneticSeperator() { + + // Zirconium + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedBauxite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustBauxite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallRutile", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetZirconium", 1), + new int[] { 10000, 2500, 4000 }, + 20 * 20, + 24); + + // Zircon + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedMagnetite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustMagnetite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallZircon", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyZircon", 1), + new int[] { 10000, 1250, 2500 }, + 20 * 20, + 24); + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedCassiterite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustCassiterite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallZircon", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyZircon", 1), + new int[] { 10000, 1250, 2500 }, + 20 * 20, + 24); + + } + + private static void fluidExtractorRecipes() { + + //FLiBe fuel + CORE.RA.addFluidExtractionRecipe( + NUCLIDE.Li2BeF4.getDust(1), + NUCLIDE.Li2BeF4.getFluidStack(144), + 100, + 500); + //LFTR Fuel 1 + CORE.RA.addFluidExtractionRecipe( + NUCLIDE.LiFBeF2ZrF4U235.getDust(1), + NUCLIDE.LiFBeF2ZrF4U235.getFluidStack(144), + 250, + 1000); + CORE.RA.addFluidExtractionRecipe( + NUCLIDE.LiFBeF2ZrF4UF4.getDust(1), + NUCLIDE.LiFBeF2ZrF4UF4.getFluidStack(144), + 150, + 1500); + CORE.RA.addFluidExtractionRecipe( + NUCLIDE.LiFBeF2ThF4UF4.getDust(1), + NUCLIDE.LiFBeF2ThF4UF4.getFluidStack(144), + 150, + 2000); + + //ZIRCONIUM_TETRAFLUORIDE + CORE.RA.addFluidExtractionRecipe( + FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getDust(1), + FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getFluidStack(144), + 200, + 512+256); + + } + + private static void macerator() { + + GT_ModHandler.addPulverisationRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("pelletZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZrCl4", 1)); + + } + + private static void mixerRecipes() { + + GT_Values.RA.addMixerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustUranium233", 4), + ItemUtils.getItemStackOfAmountFromOreDict("dustUranium235", 1), + null, + null, + FluidUtils.getFluidStack("hydrofluoricacid", 5000), + FLUORIDES.URANIUM_TETRAFLUORIDE.getFluidStack(5000), + null, + 3000, + 500); + + } + + + private static void sifter() { + + // Zirconium + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedIlmenite", 1), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyWroughtIron", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustHafnium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustHafnium", 1) }, + new int[] { 5000, 2500, 1000, 1000, 300, 300 }, + 20 * 30, + 500); + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedTin", 1), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyZinc", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1) }, + new int[] { 10000, 5000, 1500, 1000, 500, 500 }, + 20 * 30, + 500); + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedCassiterite", 1), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustCassiterite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1) }, + new int[] { 10000, 5000, 1500, 1000, 500, 500 }, + 20 * 30, + 500); + + // Radium + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedUranium", 1), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustUranium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyLead", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1) }, + new int[] { 10000, 5000, 1000, 500, 500, 500 }, + 20 * 30, + 500); + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedUraninite", 1), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustUraninite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyUranium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1) }, + new int[] { 10000, 5000, 500, 250, 250, 250 }, + 20 * 30, + 500); + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedPitchblende", 1), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustPitchblende", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyLead", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustRadium226", 1) }, + new int[] { 10000, 5000, 500, 250, 250, 250 }, + 20 * 30, + 500); + } + + private static void fluidHeater() { + + CORE.RA.addFluidHeaterRecipe( + FLUORIDES.SODIUM_FLUORIDE.getDust(1), + null, + FLUORIDES.SODIUM_FLUORIDE.getFluidStack(144), + 20 * 30, + 500); + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_NuclearFuelProcessing.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_NuclearFuelProcessing.java new file mode 100644 index 0000000000..c2c8c01f45 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_NuclearFuelProcessing.java @@ -0,0 +1,372 @@ +package gtPlusPlus.xmod.gregtech.loaders.recipe; + +import gregtech.api.enums.GT_Values; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.chemistry.NuclearChem; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.material.nuclear.NUCLIDE; +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 net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeLoader_NuclearFuelProcessing { + + public static void generate() { + + // Create Fuels + + final FluidStack aLithiumFluoride = FLUORIDES.LITHIUM_FLUORIDE.getFluidStack(100); + final FluidStack aBerylliumFluoride = FLUORIDES.BERYLLIUM_FLUORIDE.getFluidStack(100); + final FluidStack aThoriumFluoride = FLUORIDES.THORIUM_TETRAFLUORIDE.getFluidStack(100); + final FluidStack aZirconiumFluoride = FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getFluidStack(100); + final FluidStack aUraniumTetraFluoride = FLUORIDES.URANIUM_TETRAFLUORIDE.getFluidStack(100); + final FluidStack aUranium235 = ELEMENT.getInstance().URANIUM235.getFluidStack(1000); + final FluidStack aLiFBeF2ZrF4U235 = NUCLIDE.LiFBeF2ZrF4U235.getFluidStack(100); + final FluidStack aLiFBeF2ZrF4UF4 = NUCLIDE.LiFBeF2ZrF4UF4.getFluidStack(100); + final FluidStack aLiFBeF2ThF4UF4 = NUCLIDE.LiFBeF2ThF4UF4.getFluidStack(100); + + // 7LiF - BeF2 - ZrF4 - U235 - 590C + CORE.RA.addFissionFuel( + FluidUtils.getFluidStack(aLithiumFluoride, 550), + FluidUtils.getFluidStack(aBerylliumFluoride, 150), + FluidUtils.getFluidStack(aZirconiumFluoride, 60), + FluidUtils.getFluidStack(aUranium235, 240), + null, null, null, null, null, // Extra 5 inputs + FluidUtils.getFluidStack(aLiFBeF2ZrF4U235, 1000), + null, + 90 * 60 * 20, // Duration + MaterialUtils.getVoltageForTier(4) + ); + + // 7LiF - BeF2 - ZrF4 - UF4 - 650C + CORE.RA.addFissionFuel( + FluidUtils.getFluidStack(aLithiumFluoride, 600), + FluidUtils.getFluidStack(aBerylliumFluoride, 250), + FluidUtils.getFluidStack(aZirconiumFluoride, 80), + FluidUtils.getFluidStack(aUraniumTetraFluoride, 70), + null, null, null, null, null, // Extra 5 inputs + FluidUtils.getFluidStack(aLiFBeF2ZrF4UF4, 1000), + null, + 120 * 60 * 20, + MaterialUtils.getVoltageForTier(5) + ); + + // 7liF - BeF2 - ThF4 - UF4 - 566C + CORE.RA.addFissionFuel( + FluidUtils.getFluidStack(aLithiumFluoride, 580), + FluidUtils.getFluidStack(aBerylliumFluoride, 270), + FluidUtils.getFluidStack(aThoriumFluoride, 80), + FluidUtils.getFluidStack(aUraniumTetraFluoride, 70), + null, null, null, null, null, // Extra 5 inputs + FluidUtils.getFluidStack(aLiFBeF2ThF4UF4, 1000), + null, + 150 * 60 * 20, // Duration + MaterialUtils.getVoltageForTier(5) + ); + + + // Reprocess Fuels + + + // Reactor Blanket step 1 - Fluorination + CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(17), + ELEMENT.getInstance().FLUORINE.getCell(6), + NUCLIDE.LiFThF4.getFluidStack(10000), + new ItemStack[] { + CI.emptyCells(5), + FLUORIDES.LITHIUM_FLUORIDE.getCell(1), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233) + }, + new int[] {10000, 10000, 500, 500, 500, 250, 250, 250}, + NUCLIDE.UF6F2.getFluidStack(1500), + 20 * 60 * 10, + MaterialUtils.getVoltageForTier(5)); + CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(18), + ELEMENT.getInstance().FLUORINE.getCell(6), + NUCLIDE.LiFBeF2ThF4.getFluidStack(10000), + new ItemStack[] { + CI.emptyCells(4), + FLUORIDES.LITHIUM_FLUORIDE.getCell(1), + FLUORIDES.BERYLLIUM_FLUORIDE.getCell(1), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233) + }, + new int[] {10000, 10000, 10000, 1000, 1000, 1000, 500, 500, 500}, + NUCLIDE.UF6F2.getFluidStack(3000), + 20 * 60 * 10, + MaterialUtils.getVoltageForTier(5)); + + // Reactor Blanket step 1 - Fluorination + CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(7), + ELEMENT.getInstance().FLUORINE.getCell(6), + NUCLIDE.Sparged_LiFThF4.getFluidStack(10000), + new ItemStack[] { + CI.emptyCells(4), + FLUORIDES.LITHIUM_FLUORIDE.getCell(2), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233) + }, + new int[] {10000, 10000, 1000, 1000, 1000, 1000, 1000, 1000}, + NUCLIDE.UF6F2.getFluidStack(3000), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5)); + CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(8), + ELEMENT.getInstance().FLUORINE.getCell(6), + NUCLIDE.Sparged_LiFBeF2ThF4.getFluidStack(10000), + new ItemStack[] { + CI.emptyCells(2), + FLUORIDES.LITHIUM_FLUORIDE.getCell(2), + FLUORIDES.BERYLLIUM_FLUORIDE.getCell(2), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233), + ItemUtils.getSimpleStack(ModItems.dustProtactinium233) + }, + new int[] {10000, 10000, 10000, 2000, 2000, 2000, 2000, 2000, 2000}, + NUCLIDE.UF6F2.getFluidStack(6000), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5)); + + + // Reactor Blanket step 2 - Sorption + Cold Trap + CORE.RA.addColdTrapRecipe( + 8, + FLUORIDES.SODIUM_FLUORIDE.getCell(4), + NUCLIDE.UF6F2.getFluidStack(3000), + new ItemStack[] { + ELEMENT.getInstance().FLUORINE.getCell(2), + FLUORIDES.URANIUM_HEXAFLUORIDE.getCell(2), + ELEMENT.getInstance().URANIUM233.getDust(1), + ELEMENT.getInstance().URANIUM233.getDust(1), + ELEMENT.getInstance().URANIUM233.getDust(1) + }, + new int[] {10000, 10000, 3000, 2000, 1000}, + FLUORIDES.SODIUM_FLUORIDE.getFluidStack(2000), + 20 * 60 * 10, + MaterialUtils.getVoltageForTier(3)); + + + + + // Reactor Core step 0 - Process Burnt Salt + // Tier 1 Fuel - Gives back FLIBE and breeds U233 + /* CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(1), + CI.emptyCells(2), + new FluidStack(NuclearChem.Burnt_LiFBeF2ZrF4U235, 4000), + new ItemStack[] { + FLUORIDES.LITHIUM_FLUORIDE.getCell(1), + ELEMENT.getInstance().URANIUM233.getCell(1) + }, + new int[] {10000, 10000}, + NUCLIDE.LiFBeF2.getFluidStack(2000), + 20 * 60 * 60, + MaterialUtils.getVoltageForTier(3));*/ + + + + // LiBeF2UF4FP + F2 = LiFBeF2 & UF6F2FP + // Reactor Core step 1 - Process Burnt Salt + CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(1), + ELEMENT.getInstance().FLUORINE.getCell(1), + NUCLIDE.LiFBeF2UF4FP.getFluidStack(1000), + new ItemStack[] { + NUCLIDE.UF6F2FP.getCell(1) + }, + new int[] {10000}, + FluidUtils.getFluidStack(NuclearChem.Impure_LiFBeF2, 1000), + 20 * 60 * 120, + MaterialUtils.getVoltageForTier(3)); + + // LiBeF2UF4FP + F2 = LiFBeF2 & UF6F2FP + // Reactor Core step 1 - Process Burnt Salt + CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(1), + ELEMENT.getInstance().FLUORINE.getCell(3), + NUCLIDE.Sparged_LiFBeF2UF4FP.getFluidStack(1000), + new ItemStack[] { + CI.emptyCells(1), + NUCLIDE.UF6F2FP.getCell(2) + }, + new int[] {10000}, + FluidUtils.getFluidStack(NuclearChem.Impure_LiFBeF2, 2000), + 20 * 60 * 60, + MaterialUtils.getVoltageForTier(3)); + + + + // Reactor Core step 2A - Sorption + Cold Trap + CORE.RA.addColdTrapRecipe( + 8, + FLUORIDES.SODIUM_FLUORIDE.getCell(3), + NUCLIDE.UF6F2FP.getFluidStack(2000), + new ItemStack[] { + ELEMENT.getInstance().FLUORINE.getCell(1), + FLUORIDES.URANIUM_HEXAFLUORIDE.getCell(2), + ELEMENT.getInstance().PHOSPHORUS.getDust(1), + ELEMENT.getInstance().PHOSPHORUS.getDust(1), + ELEMENT.getInstance().PHOSPHORUS.getDust(1), + ELEMENT.getInstance().PHOSPHORUS.getDust(1), + ELEMENT.getInstance().PHOSPHORUS.getDust(1), + ELEMENT.getInstance().PHOSPHORUS.getDust(1), + ELEMENT.getInstance().PHOSPHORUS.getDust(1) + }, + new int[] {10000, 10000, 5000, 5000, 5000, 5000, 5000, 5000, 5000}, + FLUORIDES.SODIUM_FLUORIDE.getFluidStack(2000), + 20 * 60 * 10, + MaterialUtils.getVoltageForTier(4)); + + + // Reactor Core step 2B - Distillation + GT_Values.RA.addDistillationTowerRecipe( + FluidUtils.getFluidStack(NuclearChem.Impure_LiFBeF2, 1000), + new FluidStack[] { + NUCLIDE.LiFBeF2.getFluidStack(250) + }, + null, + 120 * 60 * 20, + MaterialUtils.getVoltageForTier(3)); + + + // UF6 -> UF4 reduction + // UF6 + LiFBeF2 + H2 -> LiFBeF2UF4 + HF + CORE.RA.addBlastRecipe( + new ItemStack[] { + FLUORIDES.URANIUM_HEXAFLUORIDE.getCell(1), + NUCLIDE.LiFBeF2.getCell(1) + }, + new FluidStack[] { + ELEMENT.getInstance().HYDROGEN.getFluidStack(2000) + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 2), + CI.emptyCells(1) + }, + new FluidStack[] { + NUCLIDE.LiFBeF2UF4.getFluidStack(3000) + }, + 20 * 60 * 10, + MaterialUtils.getVoltageForTier(4), + 6500); + + + + + // LiFBeF2ZrF4U235 - We can't add both ZrF4 and U235 here, so best we leave this disabled. + /*CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(8), + NUCLIDE.LiFBeF2UF4.getCell(9), + ELEMENT.getInstance().URANIUM235.getFluidStack(1000), + new ItemStack[] { + CI.emptyCells(9) + }, + new int[] {10000}, + NUCLIDE.LiFBeF2ZrF4U235.getFluidStack(10000), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(4));*/ + + // LiFBeF2ZrF4UF4 + /*CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(9), + NUCLIDE.LiFBeF2UF4.getCell(9), + FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getFluidStack(1000), + new ItemStack[] { + CI.emptyCells(9) + }, + new int[] {10000}, + NUCLIDE.LiFBeF2ZrF4UF4.getFluidStack(10000), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(9), + FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getCell(1), + NUCLIDE.LiFBeF2UF4.getFluidStack(9000), + new ItemStack[] { + CI.emptyCells(1) + }, + new int[] {10000}, + NUCLIDE.LiFBeF2ZrF4UF4.getFluidStack(10000), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5));*/ + + CORE.RA.addFissionFuel( + FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.getFluidStack(1000), + NUCLIDE.LiFBeF2UF4.getFluidStack(9000), + null, + null, + null, null, null, null, null, + NUCLIDE.LiFBeF2ZrF4UF4.getFluidStack(10000), + null, + 20 * 60 * 120, // Duration + MaterialUtils.getVoltageForTier(5) + ); + + // LiFBeF2ThF4UF4 + /*CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(10), + NUCLIDE.LiFBeF2UF4.getCell(9), + FLUORIDES.THORIUM_TETRAFLUORIDE.getFluidStack(1000), + new ItemStack[] { + CI.emptyCells(9) + }, + new int[] {10000}, + NUCLIDE.LiFBeF2ThF4UF4.getFluidStack(10000), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addReactorProcessingUnitRecipe( + CI.getNumberedAdvancedCircuit(10), + FLUORIDES.THORIUM_TETRAFLUORIDE.getCell(1), + NUCLIDE.LiFBeF2UF4.getFluidStack(9000), + new ItemStack[] { + CI.emptyCells(1) + }, + new int[] {10000}, + NUCLIDE.LiFBeF2ThF4UF4.getFluidStack(10000), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5));*/ + + + CORE.RA.addFissionFuel( + FLUORIDES.THORIUM_TETRAFLUORIDE.getFluidStack(1000), + NUCLIDE.LiFBeF2UF4.getFluidStack(9000), + null, + null, + null, null, null, null, null, + NUCLIDE.LiFBeF2ThF4UF4.getFluidStack(10000), + null, + 20 * 60 * 150, // Duration + MaterialUtils.getVoltageForTier(5) + ); + + + + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java new file mode 100644 index 0000000000..be4d6a8f7d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -0,0 +1,1851 @@ +package gtPlusPlus.xmod.gregtech.recipes; + +import static gregtech.GT_Mod.GT_FML_LOGGER; +import static gtPlusPlus.core.lib.CORE.GTNH; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.internal.IGT_RecipeAdder; +import gregtech.api.util.*; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; +import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.data.ArrayUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +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.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntity_RTG; +import gtPlusPlus.xmod.gregtech.recipes.machines.RECIPEHANDLER_MatterFabricator; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +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 { + + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + new ItemStack[] { aInput1, aInput2 }, + new ItemStack[] { aOutput }, + null, + new int[] {}, + new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + 0); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.mRecipeList.size(); + + + // RECIPEHANDLER_CokeOven.debug4(aInput1, aInput2, aFluidInput, + // aFluidOutput, aOutput, aDuration, aEUt); + /*if (aFluidInput == null && aInput2 != null) { + GTPP_Recipe.GTPP_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) { + GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1 }, + new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, + aEUt, 0); + } + else { + GTPP_Recipe.GTPP_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 aSize > aSize2; + + } + 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 addCokeOvenRecipe(int aCircuit, ItemStack aInput2, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int aDuration, int aEUt) { + return addCokeOvenRecipe(CI.getNumberedCircuit(aCircuit), aInput2, aFluidInputs, aFluidOutputs, aOutputs, aDuration, aEUt); + } + + @Override + public boolean addCokeOvenRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int aDuration, int aEUt) { + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + new ItemStack[] { aInput1, aInput2 }, + aOutputs, + null, + new int[] {}, + aFluidInputs, + aFluidOutputs, + Math.max(1, aDuration), + Math.max(1, aEUt), + 0); + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.mRecipeList.size(); + GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.add(aSpecialRecipe); + return GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.mRecipeList.size() > aSize; + } + + @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); + + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] {}, + new FluidStack[] {aFluidOutput}, + aDuration, + aEUt, + 0); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.addRecipe(aRecipe); + } + else { + // Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, + // new FluidStack[]{aFluidInput}, new + // FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] {aFluidInput}, + new FluidStack[] {aFluidOutput}, + aDuration, + aEUt, + 0); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.addRecipe(aRecipe); + } + 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) { + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] { aInputStack }, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] {}, + new FluidStack[] {aFluidOutput}, + aDuration, + aEUt, + 0); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.addRecipe(aRecipe); + } + else { + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] { aInputStack }, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] {aFluidInput}, + new FluidStack[] {aFluidOutput}, + aDuration, + aEUt, + 0); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.addRecipe(aRecipe); + } + 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; + } + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] { aInput }, + aOutput, + null, + new int[] {}, + new FluidStack[] { aFluid }, + new FluidStack[] {}, + aDuration, + aEUt, + 0); + GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(aRecipe); + // 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 != null && aInput.length > 0) { + 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 + + "mbs"); + } + if (((aInput == null || aInput.length == 0) && (aFluidInput == null)) || ((aOutputItems == null || aOutputItems.length == 0) && (aFluidOutput == null))) { + return false; + } + if (aOutputItems != null) { + Logger.WARNING("Recipe will output: " + ItemUtils.getArrayStackNames(aOutputItems)); + } + if (aFluidOutput != null) { + Logger.WARNING("Recipe will output: " + aFluidOutput.getFluid().getName()); + } + + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + aInput, + aOutputItems, + null, + aChances, + new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + 0); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.mRecipeList.size(); + + /*if (aInput.length == 1) { + Logger.WARNING("Dehydrator recipe only has a single input item."); + GTPP_Recipe.GTPP_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."); + GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, + aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, + 0); + }*/ + + return aSize > aSize2; + } + 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; + } + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + aInput, + aOutputStack, + null, + aChance, + new FluidStack[] { aInputFluid }, + new FluidStack[] { aOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + aSpecialValue); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.mRecipeList.size(); + + + /*GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.addRecipe(true, aInput, aOutputStack, null, + aChance, new FluidStack[] { aInputFluid }, new FluidStack[] { aOutput }, aDuration, aEUt, + aSpecialValue);*/ + + return aSize > aSize2; + } + + @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; + } + GTPP_Recipe.GTPP_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) { + return addFissionFuel(false, aInput1, aInput2, aInput3, aInput4, aInput5, aInput6, aInput7, aInput8, aInput9, aOutput1, aOutput2, aDuration, aEUt); + } + + @Override + public boolean addFissionFuel(final boolean aOptimise, 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) || (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 }; + + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + aOptimise, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + inputs, + outputs, + Math.max(1, aDuration), + Math.max(1, aEUt), + 0); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing.mRecipeList.size(); + + if (aSize > aSize2) { + Logger.INFO("Added Nuclear Fuel Recipe."); + return true; + } + return false; + } + + @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)) { + Logger.INFO("Bad output for Cyclotron Recipe."); + return false; + } + + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + aInputs, + aOutput, + null, + aChances, + new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + aSpecialValue); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.mRecipeList.size(); + + if (aSize > aSize2) { + Logger.INFO("Added Cyclotron Recipe."); + return true; + } + + Logger.INFO("Failed to add Cyclotron Recipe. Output: "+ItemUtils.getArrayStackNames(aOutput)); + 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; + } + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, + new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 }, + null, + new int[] {}, + new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + 0); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.mRecipeList.size(); + + /*GTPP_Recipe.GTPP_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 aSize > aSize2; + } + + // 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; + } + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + aInputs, + new ItemStack[] { aOutput1 }, + null, + new int[] {}, + new FluidStack[] {aFluidInput}, + new FluidStack[] {}, + aDuration, + aEUt, + 0); + GTPP_Recipe.GTPP_Recipe_Map.sComponentAssemblerRecipes.addRecipe(aRecipe); + 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; + } + + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + aInputs, + aOutputs, + null, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUtick, + aSpecial); + GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT.addRecipe(aRecipe); + + //GTPP_Recipe.GTPP_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; + } + + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + aInputs, + aOutputs, + null, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUtick, + aSpecial); + GTPP_Recipe.GTPP_Recipe_Map.sMultiblockElectrolyzerRecipes_GT.addRecipe(aRecipe); + //GTPP_Recipe.GTPP_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; + } + + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + aInputs, + aOutputs, + null, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUtick, + aSpecial); + GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.addRecipe(aRecipe); + /*if (GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial) != null) { + return true; + }*/ + return false; + + } + + public boolean addMultiblockMixerRecipe(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 Mixer 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; + } + + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + aInputs, + aOutputs, + null, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUtick, + aSpecial); + GTPP_Recipe.GTPP_Recipe_Map.sMultiblockMixerRecipes_GT.addRecipe(aRecipe); + return true; + } + + 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); + } + + @Override + public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) { + if ((aResearchItem==null)||(aResearchTime<=0)||(aInputs == null) || (aOutput == null) || aInputs.length>15 || aInputs.length<4) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("assemblingline", aOutput, aDuration)) <= 0) { + return false; + } + for(ItemStack tItem : aInputs){ + if(tItem==null){ + GT_FML_LOGGER.info("addAssemblingLineRecipe "+aResearchItem.getDisplayName()+" --> "+aOutput.getUnlocalizedName()+" there is some null item in that recipe"); + } + } + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Writes Research result", new Object[0])}, null, null, aResearchTime, 30, -201); + GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe(false, aInputs, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Reads Research result", new Object[0])}, aFluidInputs, null, aDuration, aEUt, 0,true); + GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe_AssemblyLine( aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt)); + return true; + } + + @Override + public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, Object[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) { + if ((aResearchItem==null)||(aResearchTime<=0)||(aInputs == null) || (aOutput == null) || aInputs.length>15 || aInputs.length<4) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("assemblingline", aOutput, aDuration)) <= 0) { + return false; + } + ItemStack[] tInputs = new ItemStack[aInputs.length]; + ItemStack[][] tAlts = new ItemStack[aInputs.length][]; + for(int i = 0; i < aInputs.length; i++){ + Object obj = aInputs[i]; + if (obj instanceof ItemStack) { + tInputs[i] = (ItemStack) obj; + tAlts[i] = null; + continue; + } else if (obj instanceof ItemStack[]) { + ItemStack[] aStacks = (ItemStack[]) obj; + if (aStacks.length > 0) { + tInputs[i] = aStacks[0]; + tAlts[i] = (ItemStack[]) Arrays.copyOf(aStacks, aStacks.length); + continue; + } + } else if (obj instanceof Object[]) { + Object[] objs = (Object[]) obj; + List<ItemStack> tList; + if (objs.length >= 2 && !(tList = GT_OreDictUnificator.getOres(objs[0])).isEmpty()) { + try { + int tAmount = ((Number) objs[1]).intValue(); + List<ItemStack> uList = new ArrayList<>(); + for (ItemStack tStack : tList) { + ItemStack uStack = GT_Utility.copyAmount(tAmount, tStack); + if (GT_Utility.isStackValid(uStack)) { + uList.add(uStack); + if (tInputs[i] == null) + tInputs[i] = uStack; + } + } + tAlts[i] = uList.toArray(new ItemStack[uList.size()]); + continue; + } catch (Exception t) {} + } + } + GT_FML_LOGGER.info("addAssemblingLineRecipe "+aResearchItem.getDisplayName()+" --> "+aOutput.getUnlocalizedName()+" there is some null item in that recipe"); + } + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Writes Research result", new Object[0])}, null, null, aResearchTime, 30, -201); + GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe(false,tInputs,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Reads Research result", new Object[0])},aFluidInputs,null,aDuration,aEUt,0,tAlts,true); + GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe_AssemblyLine( aResearchItem, aResearchTime, tInputs, aFluidInputs, aOutput, aDuration, aEUt, tAlts)); + return true; + } + + 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 GTPP_Recipe( + 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; + } + GTPP_Recipe aFusionCustom = new GTPP_Recipe( + 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; + } + GTPP_Recipe aFusionCustom = new GTPP_Recipe( + 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) { + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + false, + aInputs, + aOutputs, + null, + new int[] {}, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aLevel); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sVacuumFurnaceRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sVacuumFurnaceRecipes.addRecipe(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_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) { + // Generate Special Laser Recipe + GT_Recipe u = new GTPP_Recipe( + false, + new ItemStack[] { + aInput1, + aInput2, + }, + new ItemStack[] { + aOutput + }, + GregtechItemList.Laser_Lens_WoodsGlass.get(1), + new int[] { + 10000 + }, + new FluidStack[] {}, + new FluidStack[] {}, + time, + (int) eu, + 0); + return GT_Recipe.GT_Recipe_Map.sLaserEngraverRecipes.mRecipeList.add(u); + } + + @Override + public boolean addIrLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu) { + return addUvLaserRecipe(aInput1, aInput2, aOutput, time, eu); + } + + + @Override + public boolean addChemicalPlantRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int time, long eu, int aTier) { + return addChemicalPlantRecipe(aInputs, aInputFluids, aOutputs, aFluidOutputs, new int[] {}, time, eu, aTier); + } + + @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)); + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); + Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); + CORE.crash(); + } + + + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + false, + aInputs, + aOutputs, + null, + aChances, + aInputFluids, + aFluidOutputs, + time, + (int) eu, + aTier); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlantRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList.size(); + return aSize > aSize2; + } + + @Override + public boolean addBlastRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int time, long eu, int aHeat) { + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + 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; + } + } + + @Override + public boolean addDistilleryRecipe(ItemStack aCircuit, FluidStack aInput, FluidStack aOutput, ItemStack aSolidOutput, int aDuration, int aEUt, boolean aHidden) { + if (aInput != null && aOutput != null) { + if ((aDuration = GregTech_API.sRecipeFile.get("distillery", aOutput.getFluid().getUnlocalizedName(), + aDuration)) <= 0) { + return false; + } else { + GT_Recipe tRecipe = GT_Recipe_Map.sDistilleryRecipes.addRecipe(true, new ItemStack[]{aCircuit}, + new ItemStack[] {aSolidOutput}, (Object) null, new FluidStack[]{aInput}, new FluidStack[]{aOutput}, + aDuration, aEUt, 0); + if (aHidden && tRecipe != null) { + tRecipe.mHidden = true; + } + return true; + } + } else { + return false; + } + } + + @Override + public boolean addExtractorRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEUt) { + if (aInput != null && aOutput != null) { + if ((aDuration = GregTech_API.sRecipeFile.get("extractor", aInput, aDuration)) <= 0) { + return false; + } else { + GT_Recipe_Map.sExtractorRecipes.addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput}, + (Object) null, (FluidStack[]) null, (FluidStack[]) null, aDuration, aEUt, 0); + return true; + } + } else { + return false; + } + } + + @Override + public boolean addPulverisationRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3) { + //return GT_Values.RA.addPulveriserRecipe(arg0, arg1, arg2, arg3, arg4) + + aOutput1 = GT_OreDictUnificator.get(true, aOutput1); + aOutput2 = GT_OreDictUnificator.get(true, aOutput2); + aOutput3 = GT_OreDictUnificator.get(true, aOutput3); + if ((GT_Utility.isStackInvalid(aInput)) || (GT_Utility.isStackInvalid(aOutput1))) { + return false; + } + if (GT_Utility.getContainerItem(aInput, false) == null) { + + if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) { + GT_Utility.addSimpleIC2MachineRecipe(aInput, GT_ModHandler.getMaceratorRecipeList(), null, + new Object[] { aOutput1 }); + } + GT_Values.RA.addPulveriserRecipe(aInput, new ItemStack[] { aOutput1, aOutput2, aOutput3 }, + new int[] { 10000, 10000, 10000 }, 400, 2); + } + return true; + + } + + @Override + public boolean addMillingRecipe(Materials aMat, int aEU) { + return addMillingRecipe(MaterialUtils.generateMaterialFromGtENUM(aMat), aEU); + } + + @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(32); + ItemStack aMilledStackOres2 = aMat.getMilled(48); + ItemStack aMilledStackCrushed2 = aMat.getMilled(16); + + ItemStack aMillingBall_Alumina = GregtechItemList.Milling_Ball_Alumina.get(0); + ItemStack aMillingBall_Soapstone = GregtechItemList.Milling_Ball_Soapstone.get(0); + + // Inputs + ItemStack[] aInputsOre1 = new ItemStack[] { + CI.getNumberedCircuit(10), + 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 + }; + + ItemStack[][] aInputArray = new ItemStack[][] {aInputsOre1, aInputsOre2, aInputsCrushed1, aInputsCrushed2}; + ItemStack[][] aOutputArray = new ItemStack[][] {aOutputsOre1, aOutputsOre2, aOutputsCrushed1, aOutputsCrushed2}; + int[] aTime = new int[] {6000, 7500, 7500, 9000}; + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sOreMillRecipes.mRecipeList.size(); + int aSize2 = aSize; + + for (int i=0;i<4;i++) { + GTPP_Recipe aOreRecipe = new GTPP_Recipe( + false, + aInputArray[i], + aOutputArray[i], + null, + new int[] {}, + null, + null, + aTime[i], + aEU, + 0); + GTPP_Recipe.GTPP_Recipe_Map.sOreMillRecipes.add(aOreRecipe); + } + + aSize = GTPP_Recipe.GTPP_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 = GTPP_Recipe.GTPP_Recipe_Map.sFlotationCellRecipes.mRecipeList.size(); + int aSize2 = aSize; + + GT_Recipe aRecipe = new GTPP_Recipe( + 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); + + GTPP_Recipe.GTPP_Recipe_Map.sFlotationCellRecipes.add(aRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sFlotationCellRecipes.mRecipeList.size(); + + return aSize > aSize2; + } + + @Override + public boolean addpackagerRecipe(ItemStack aRecipeType, ItemStack aSmallDust, ItemStack aTinyDust, ItemStack aOutputStack1) { + AutoMap<Boolean> aResults = new AutoMap<Boolean>(); + //Dust 1 + aResults.put(GT_Values.RA.addBoxingRecipe(GT_Utility.copyAmount(4L, new Object[]{aSmallDust}), aRecipeType, aOutputStack1, 100, 4)); + //Dust 2 + aResults.put(GT_Values.RA.addBoxingRecipe(GT_Utility.copyAmount(9L, new Object[]{aTinyDust}), aRecipeType, aOutputStack1, 100, 4)); + for (boolean b : aResults) { + if (!b) { + return false; + } + } + return true; + } + + @Override + public boolean addFuelForRTG(ItemStack aFuelPellet, int aFuelDays, int aVoltage) { + int aSize1 = GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.mRecipeList.size(); + GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.addRecipe( + true, + new ItemStack[]{aFuelPellet}, + new ItemStack[]{}, + null, + null, + null, + 0, + aVoltage, + aFuelDays); + int aSize2 = GTPP_Recipe.GTPP_Recipe_Map.sRTGFuels.mRecipeList.size(); + + if (aSize2 > aSize1) { + long eu = GregtechMetaTileEntity_RTG.getTotalEUGenerated(GregtechMetaTileEntity_RTG.convertDaysToTicks(aFuelDays), aVoltage); + GT_MetaTileEntity_Hatch_Energy_RTG.registerPelletForHatch(aFuelPellet, eu); + return true; + } + else { + return false; + } + } + + + @Override + public boolean addColdTrapRecipe(int aCircuit, ItemStack aInput, FluidStack aFluidInput, ItemStack[] aOutputs, int[] aChances, FluidStack aFluidOutput, int aTime, int aEU) { + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedAdvancedCircuit(aCircuit), aInput}, + aOutputs, + null, + aChances, + new FluidStack[] {aFluidInput}, + new FluidStack[] {aFluidOutput}, + aTime, + aEU, + 0); + + int aSize = GTPP_Recipe_Map.sColdTrapRecipes.mRecipeList.size(); + GTPP_Recipe_Map.sColdTrapRecipes.add(aRecipe); + return GTPP_Recipe_Map.sColdTrapRecipes.mRecipeList.size() > aSize; + } + + + @Override + public boolean addReactorProcessingUnitRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, ItemStack[] aOutputs, int[] aChances, FluidStack aFluidOutput, int aTime, int aEU) { + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] {aInput1, aInput2}, + aOutputs, + null, + aChances, + new FluidStack[] {aFluidInput}, + new FluidStack[] {aFluidOutput}, + aTime, + aEU, + 0); + + int aSize = GTPP_Recipe_Map.sReactorProcessingUnitRecipes.mRecipeList.size(); + GTPP_Recipe_Map.sReactorProcessingUnitRecipes.add(aRecipe); + return GTPP_Recipe_Map.sReactorProcessingUnitRecipes.mRecipeList.size() > aSize; + } + + + @Override + public boolean addFluidHeaterRecipe(ItemStack aInput, FluidStack aFluidInput, FluidStack aOutput, int aDuration, int aEUt) { + if ((aInput == null && aFluidInput == null) || (aOutput == null)) { + return false; + } + GT_Recipe.GT_Recipe_Map.sFluidHeaterRecipes.addRecipe(true, new ItemStack[]{aInput}, null, null, new FluidStack[]{aFluidInput}, new FluidStack[]{aOutput}, aDuration, aEUt, 0); + return true; + } + + + @Override + public boolean addVacuumFreezerRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEUt) { + if ((aInput == null) || (aOutput == null)) { + return false; + } + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] {aInput}, + new ItemStack[] {aOutput}, + null, + new int[] {10000}, + new FluidStack[] {}, + new FluidStack[] {}, + aDuration, + aEUt, + 0); + + int aSize = GT_Recipe_Map.sVacuumRecipes.mRecipeList.size(); + GT_Recipe_Map.sVacuumRecipes.add(aRecipe); + return GT_Recipe_Map.sVacuumRecipes.mRecipeList.size() > aSize; + } + + + + + + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/RecipesToRemove.java b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/RecipesToRemove.java new file mode 100644 index 0000000000..99e3d5c4d9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/RecipesToRemove.java @@ -0,0 +1,57 @@ +package gtPlusPlus.xmod.gregtech.recipes; + +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.ORES; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class RecipesToRemove { + + public static void go() { + + Logger.INFO("Processing Gregtech recipe maps, removing recipes to suit GT++."); + + //Remove Rare Earth Centrifuging + //1 Rare Earth Dust - 25% chance for small piles of: neodymium, yttrium, lanthanum, cerium, cadmium, and caesium + //Replaced by advanced sifting recipe. + GT_Recipe aRareEarthCentrifuging = GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.findRecipe(null, false, 20, new FluidStack[] {}, new ItemStack[] {ItemUtils.getItemStackOfAmountFromOreDict("dustRareEarth", 1)}); + if (aRareEarthCentrifuging != null && aRareEarthCentrifuging.mEnabled) { + aRareEarthCentrifuging.mEnabled = false; + aRareEarthCentrifuging.mHidden = true; + GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.mRecipeList.remove(aRareEarthCentrifuging); + //GTPP_Recipe.GT_Recipe_Map_LargeCentrifuge.sMultiblockCentrifugeRecipes.mRecipeList.remove(aRareEarthCentrifuging); + GTPP_Recipe.GTPP_Recipe_Map.sMultiblockCentrifugeRecipes_GT.mRecipeList.remove(aRareEarthCentrifuging); + Logger.INFO("Removed vanilla GT Rare Earth processing."); + //Set the Chemical Symbol for Rare Earth now that we are giving it custom outputs + //Best not to set this unless the original recipe is removed. + /*Materials.RareEarth.mChemicalFormula = "(" + +ELEMENT.getInstance().YTTRIUM.vChemicalSymbol + +ELEMENT.getInstance().NEODYMIUM.vChemicalSymbol + +ELEMENT.getInstance().LANTHANUM.vChemicalSymbol + +ELEMENT.getInstance().CERIUM.vChemicalSymbol + +ELEMENT.getInstance().CADMIUM.vChemicalSymbol + +ELEMENT.getInstance().CAESIUM.vChemicalSymbol + +ELEMENT.getInstance().YTTERBIUM.vChemicalSymbol + +ELEMENT.getInstance().SAMARIUM.vChemicalSymbol + +ELEMENT.getInstance().GADOLINIUM.vChemicalSymbol+ + ")";*/ + + Material[] aLowTierOutputMaterials = new Material[] { + ORES.GREENOCKITE + }; + + + + + + + + } + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_AssemblyLine.java b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_AssemblyLine.java new file mode 100644 index 0000000000..15115647ae --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_AssemblyLine.java @@ -0,0 +1,20 @@ +package gtPlusPlus.xmod.gregtech.recipes.machines; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public class RECIPEHANDLER_AssemblyLine { + + public static boolean addAssemblylineRecipe( + ItemStack paramItemStack1, + int paramInt1, + ItemStack[] paramArrayOfItemStack, + FluidStack[] paramArrayOfFluidStack, + ItemStack paramItemStack2, + int paramInt2, int paramInt3){ + + return false; + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_CokeOven.java b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_CokeOven.java new file mode 100644 index 0000000000..cd06f86ef9 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_CokeOven.java @@ -0,0 +1,47 @@ +package gtPlusPlus.xmod.gregtech.recipes.machines; + +import net.minecraft.item.ItemStack; + +import gtPlusPlus.api.objects.Logger; +import net.minecraftforge.fluids.FluidStack; + +public class RECIPEHANDLER_CokeOven { + + public static void debug1(){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + Logger.WARNING("Walking Through CokeOven Recipe Creation."); + Logger.WARNING("My name is Ralph and I will be your humble host."); + } + public static void debug2(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, final FluidStack aFluidOutput, final ItemStack aOutput, final int aDuration, final int aEUt){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("Taking a step forward."); + Logger.WARNING("aInput1 == null && aFluidInput == null || aOutput == null && aFluidOutput == null"); + Logger.WARNING("aInput1:"+aInput1.toString()+" aInput2:"+aInput2.toString()+" aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Passed."); + } + public static void debug3(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, final FluidStack aFluidOutput, final ItemStack aOutput, final int aDuration, final int aEUt){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("Taking a step forward."); + Logger.WARNING("(aOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get(cokeoven, aOutput, aDuration)) <= 0)"); + Logger.WARNING("aInput1:"+aInput1.toString()+" aInput2:"+aInput2.toString()+" aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Passed."); + } + public static void debug4(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, final FluidStack aFluidOutput, final ItemStack aOutput, final int aDuration, final int aEUt){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("Taking a step forward."); + Logger.WARNING("(aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get(cokeoven, aFluidOutput.getFluid().getName(), aDuration)) <= 0)"); + Logger.WARNING("aInput1:"+aInput1.toString()+" aInput2:"+aInput2.toString()+" aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Passed."); + Logger.WARNING("aInput1:"+aInput1.toString()+" aInput2:"+aInput2.toString()+" aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + + } + public static void debug5(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, final FluidStack aFluidOutput, final ItemStack aOutput, final int aDuration, final int aEUt){ + Logger.INFO("Successfully added a Coke Oven recipe for: "+aOutput.getDisplayName()+" & "+aFluidOutput.getFluid().getName()+", Using "+aInput1.getDisplayName()+" & "+aInput2.getDisplayName()+" & liquid "+aFluidInput.getFluid().getName()+". This takes "+(aDuration/20)+" seconds for "+aEUt+"eu/t."); + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_Dehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_Dehydrator.java new file mode 100644 index 0000000000..402d47d3e5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_Dehydrator.java @@ -0,0 +1,82 @@ +package gtPlusPlus.xmod.gregtech.recipes.machines; + +import net.minecraft.item.ItemStack; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraftforge.fluids.FluidStack; + +public class RECIPEHANDLER_Dehydrator { + + public static void debug1(){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + Logger.WARNING("Walking Through Chemical Dehydrator Recipe Creation."); + Logger.WARNING("My name is Willus and I will be your humble host."); + } + public static void debug2(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, final FluidStack aFluidOutput, final ItemStack aOutput, final int aDuration, final int aEUt){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("Taking a step forward."); + Logger.WARNING("aInput1 == null && aFluidInput == null || aOutput == null && aFluidOutput == null"); + Logger.WARNING("aInput1:"+aInput1.toString()+" aInput2:"+aInput2.toString()+" aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Passed."); + } + public static void debug3(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, final FluidStack aFluidOutput, final ItemStack aOutput, final int aDuration, final int aEUt){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("Taking a step forward."); + Logger.WARNING("(aOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get(cokeoven, aOutput, aDuration)) <= 0)"); + Logger.WARNING("aInput1:"+aInput1.toString()+" aInput2:"+aInput2.toString()+" aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Passed."); + } + public static void debug4(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, final FluidStack aFluidOutput, final ItemStack aOutput, final int aDuration, final int aEUt){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("Taking a step forward."); + Logger.WARNING("(aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get(cokeoven, aFluidOutput.getFluid().getName(), aDuration)) <= 0)"); + Logger.WARNING("aInput1:"+aInput1.toString()+" aInput2:"+aInput2.toString()+" aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Passed."); + Logger.WARNING("aInput1:"+aInput1.toString()+" aInput2:"+aInput2.toString()+" aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + + } + public static void debug5(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, final FluidStack aFluidOutput, final ItemStack[] aOutput, final int aDuration, final int aEUt){ + + String inputAname; + String inputBname; + String inputFluidname; + String outputFluidName; + + if (aInput1 != null){ + inputAname = aInput1.getDisplayName(); + } + else { + inputAname = "null"; + } + + if (aInput2 != null){ + inputBname = aInput2.getDisplayName(); + } + else { + inputBname = "null"; + } + + if (aFluidInput != null){ + inputFluidname = aFluidInput.getFluid().getName(); + } + else { + inputFluidname = "null"; + } + + if (aFluidOutput != null){ + outputFluidName = aFluidOutput.getFluid().getName(); + } + else { + outputFluidName = "null"; + } + + Logger.INFO("Successfully added a Chemical Dehydrator recipe for: "+ItemUtils.getArrayStackNames(aOutput)+" & "+outputFluidName+", Using "+inputAname+" & "+inputBname+" & liquid "+inputFluidname+". This takes "+(aDuration/20)+" seconds for "+aEUt+"eu/t."); + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_MatterFabricator.java b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_MatterFabricator.java new file mode 100644 index 0000000000..df51f1ad77 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/machines/RECIPEHANDLER_MatterFabricator.java @@ -0,0 +1,55 @@ +package gtPlusPlus.xmod.gregtech.recipes.machines; + +import gtPlusPlus.api.objects.Logger; +import net.minecraftforge.fluids.FluidStack; + +public class RECIPEHANDLER_MatterFabricator { + + public static void debug1(){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + Logger.WARNING("Walking Through Matter Fabrication Recipe Creation."); + Logger.WARNING("My name is Ralph and I will be your humble host."); + } + public static void debug2(final FluidStack aFluidInput, final FluidStack aFluidOutput, final int aDuration, final int aEUt){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("Taking a step forward."); + Logger.WARNING("aInput1 == null && aFluidInput == null || aOutput == null && aFluidOutput == null"); + Logger.WARNING("aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Passed."); + } + public static void debug3(final FluidStack aFluidInput, final FluidStack aFluidOutput, final int aDuration, final int aEUt){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("Taking a step forward."); + Logger.WARNING("(aOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get(cokeoven, aOutput, aDuration)) <= 0)"); + Logger.WARNING("aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Passed."); + } + public static void debug4(final FluidStack aFluidInput, final FluidStack aFluidOutput, final int aDuration, final int aEUt){ + Logger.WARNING("=================================================================================="); + Logger.WARNING("Taking a step forward."); + Logger.WARNING("(aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get(cokeoven, aFluidOutput.getFluid().getName(), aDuration)) <= 0)"); + Logger.WARNING("aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Passed."); + Logger.WARNING("aFluidInput:"+aFluidInput.toString()+" aFluidOutput:"+aFluidOutput.toString()+" aDuration:"+aDuration+" aEU/t:"+aEUt); + + } + public static void debug5(final FluidStack aFluidInput, final FluidStack aFluidOutput, final int aDuration, final int aEUt){ + String a = "nothing"; + String b = ""; + + if (aFluidInput != null){ + a = aFluidInput.getFluid().getName(); + } + if (aFluidOutput != null){ + b = aFluidOutput.getFluid().getName(); + } + + Logger.INFO("Successfully added a Matter Fabrication recipe for: "+b+", Using "+" liquid "+a+". This takes "+(aDuration/20)+" seconds for "+aEUt+"eu/t."); + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + Logger.WARNING("=================================================================================="); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java new file mode 100644 index 0000000000..0817202e85 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/Gregtech4Content.java @@ -0,0 +1,85 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_AutoCrafter; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GT4Entity_ThermalBoiler; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.*; + +public class Gregtech4Content { + + // ID Range 828, 829, 833 - 850 + + public static void run() { + if (LoadedMods.Gregtech) { + workbenches(); + thermalBoiler(); + multiCrafter(); + tesseracts(); + shelves(); + } + } + + private static void workbenches() { + // Gregtech 4 Workbenches + //Utils.LOG_INFO("Gregtech 4 Content | Registering Workbenches."); + // Free //GregtechItemList.GT4_Workbench_Bronze.set(new + // GT_MetaTileEntity_BronzeCraftingTable(828, "workbench.bronze", + // "Bronze Workbench", 0).getStackForm(1L)); + } + + private static void tesseracts() { + // Gregtech 4 Tesseracts + Logger.INFO("Gregtech 4 Content | Registering Tesseracts."); + GregtechItemList.GT4_Tesseract_Generator + .set(new GT_MetaTileEntity_TesseractGenerator(833, "tesseract.generator", "Tesseract Generator", 4) + .getStackForm(1L)); + GregtechItemList.GT4_Tesseract_Terminal + .set(new GT_MetaTileEntity_TesseractTerminal(834, "tesseract.terminal", "Tesseract Terminal", 4) + .getStackForm(1L)); + } + + private static void shelves() { + // Gregtech 4 Shelves + Logger.INFO("Gregtech 4 Content | Registering Shelves."); + GregtechItemList.GT4_Shelf + .set(new GT4Entity_Shelf(870, "gtplusplus.shelf.wooden", "Wooden Shelf", "Usually used for books") + .getStackForm(1L)); + GregtechItemList.GT4_Shelf_Iron.set( + new GT4Entity_Shelf_Iron(871, "gtplusplus.shelf.iron", "Metal Shelf", "A heavy duty shelf") + .getStackForm(1L)); + GregtechItemList.GT4_Shelf_FileCabinet.set(new GT4Entity_Shelf_FileCabinet(872, "gtplusplus.shelf.filecabinet", + "File Cabinet", "Could look nice in your office").getStackForm(1L)); + GregtechItemList.GT4_Shelf_Desk.set( + new GT4Entity_Shelf_Desk(873, "gtplusplus.shelf.desk", "Metal encased Desk", "A place to study") + .getStackForm(1L)); + GregtechItemList.GT4_Shelf_Compartment.set(new GT4Entity_Shelf_Compartment(874, "gtplusplus.shelf.compartment", + "Compartment", "Stores Books & Things").getStackForm(1L)); + + //Custom Storage + GregtechItemList.GT4_Shelf_Large.set( + new GT4Entity_Shelf_Large(966, "gtplusplus.shelf.large", "Large Shelf", "A spacious shelf", 2048) + .getStackForm(1L)); + } + + private static void thermalBoiler() { + // Gregtech 4 Thermal Boiler + if (CORE.ConfigSwitches.enableMultiblock_ThermalBoiler){ + Logger.INFO("Gregtech 4 Content | Registering Thermal Boiler."); + GregtechItemList.GT4_Thermal_Boiler + .set(new GT4Entity_ThermalBoiler(875, "gtplusplus.thermal.boiler", "Thermal Boiler").getStackForm(1L)); + } + + } + + private static void multiCrafter() { + // Gregtech 4 Multiblock Auto-Crafter + Logger.INFO("Gregtech 4 Content | Registering Multiblock Crafter."); + GregtechItemList.GT4_Multi_Crafter.set( + new GT4Entity_AutoCrafter(876, "gtplusplus.autocrafter.multi", "Large Scale Auto-Assembler v1.01").getStackForm(1L)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAdvancedBoilers.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAdvancedBoilers.java new file mode 100644 index 0000000000..d50a8f3924 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAdvancedBoilers.java @@ -0,0 +1,104 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.recipe.RECIPES_MachineComponents; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GT_MetaTileEntity_Boiler_HV; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GT_MetaTileEntity_Boiler_LV; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GT_MetaTileEntity_Boiler_MV; + +public class GregtechAdvancedBoilers { + + public static void run() { + if (LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Advanced Boilers."); + run1(); + } + } + + private static void run1() { + // Boilers + GregtechItemList.Boiler_Advanced_LV + .set(new GT_MetaTileEntity_Boiler_LV(753, "Advanced Boiler [LV]", 1).getStackForm(1L)); + GregtechItemList.Boiler_Advanced_MV + .set(new GT_MetaTileEntity_Boiler_MV(754, "Advanced Boiler [MV]", 2).getStackForm(1L)); + GregtechItemList.Boiler_Advanced_HV + .set(new GT_MetaTileEntity_Boiler_HV(755, "Advanced Boiler [HV]", 3).getStackForm(1L)); + + ItemStack chassisT1 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemBoilerChassis", "Boiler_Chassis_T1", + 0, 1); + ItemStack chassisT2 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemBoilerChassis", "Boiler_Chassis_T1", + 1, 1); + ItemStack chassisT3 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemBoilerChassis", "Boiler_Chassis_T1", + 2, 1); + + // Make the Coil in each following recipe a hammer and a Screwdriver. + + // Chassis Recipes + GT_ModHandler.addCraftingRecipe(chassisT1, + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "WCW", "GMG", "WPW", Character.valueOf('M'), ItemList.Hull_ULV, Character.valueOf('P'), + OrePrefixes.pipeLarge.get(Materials.Bronze), Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Primitive), Character.valueOf('W'), + OrePrefixes.plate.get(Materials.Lead), Character.valueOf('G'), + OrePrefixes.pipeSmall.get(Materials.Copper) }); + + GT_ModHandler.addCraftingRecipe(chassisT2, + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "WCW", "GMG", "WPW", Character.valueOf('M'), ItemList.Hull_LV, Character.valueOf('P'), + OrePrefixes.pipeLarge.get(Materials.Steel), Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('W'), + OrePrefixes.plate.get(Materials.Steel), Character.valueOf('G'), + OrePrefixes.pipeSmall.get(Materials.Bronze) }); + + GT_ModHandler.addCraftingRecipe(chassisT3, + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "WCW", "GMG", "WPW", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('P'), + OrePrefixes.pipeLarge.get(Materials.StainlessSteel), Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), + OrePrefixes.plate.get(Materials.Aluminium), Character.valueOf('G'), + OrePrefixes.pipeSmall.get(Materials.Steel) }); + + ItemStack pipeTier1 = ItemUtils.getItemStackOfAmountFromOreDict(RECIPES_MachineComponents.pipeTier7, 1); + ItemStack pipeTier2 = ItemUtils.getItemStackOfAmountFromOreDict(RECIPES_MachineComponents.pipeTier8, 1); + ItemStack pipeTier3 = ItemUtils.getItemStackOfAmountFromOreDict(RECIPES_MachineComponents.pipeTier9, 1); + + // Boiler Recipes + GT_ModHandler.addCraftingRecipe(GregtechItemList.Boiler_Advanced_LV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "dCw", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_LV, Character.valueOf('P'), + pipeTier1, Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Basic), + Character.valueOf('W'), chassisT1, Character.valueOf('G'), + OrePrefixes.gear.get(Materials.Steel) }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Boiler_Advanced_MV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "dCw", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('P'), + pipeTier2, Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Good), + Character.valueOf('W'), chassisT2, Character.valueOf('G'), ALLOY.SILICON_CARBIDE.getGear(1) }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Boiler_Advanced_HV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "dCw", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('P'), + pipeTier3, Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Advanced), + Character.valueOf('W'), chassisT3, Character.valueOf('G'), ALLOY.SILICON_CARBIDE.getGear(1) }); + + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAdvancedMixer.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAdvancedMixer.java new file mode 100644 index 0000000000..3cefaa1bf7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAdvancedMixer.java @@ -0,0 +1,132 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import java.util.Collection; + +import gregtech.api.enums.ItemList; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_GT_Recipe; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GTPP_Recipe; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + +public class GregtechAdvancedMixer { + + private static int mID = 851; + + public static void run(){ + //generateMixerRecipeMap(); + run1(); + } + + private static GT_Recipe_Map map = GT_Recipe.GT_Recipe_Map.sMixerRecipes; + + private static boolean generateMixerRecipeMap(){ + if (GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.mRecipeList.size() == 0){ + GT_Recipe_Map oldMap = GT_Recipe.GT_Recipe_Map.sMixerRecipes; + GT_Recipe_Map map = GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes; + final Collection<GT_Recipe> x = oldMap.mRecipeList; + //Logger.INFO("Generating " + map.mUnlocalizedName + " Recipes."); + for (final GT_Recipe g : x) { + GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.add(g); + } + + if (GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.mRecipeList.size() > 0){ + return true; + } + else { + Logger.INFO("Failed to generate "+ map.mUnlocalizedName +" recipes."); + return false; + } + + } + return true; + } + + private static void run1(){ + GregtechItemList.Machine_Advanced_LV_Mixer.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(mID++, "advancedmachine.mixer.tier.01", + "Basic Combiner", 1, "Indeed, It does blend!", map, 4, 4, 32000, 0, 1, + "MixerAdvanced.png", "", false, false, 0, "MIXER", null + /*new Object[] { "GRG", "GEG", "CMC", Character.valueOf('M'), + ItemList.Machine_LV_Mixer, Character.valueOf('E'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('R'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('C'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, Character.valueOf('G'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE }*/).getStackForm(1L)); + GregtechItemList.Machine_Advanced_MV_Mixer.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(mID++, "advancedmachine.mixer.tier.02", + "Advanced Combiner I", 2, "Indeed, It does blend!", map, 4, 4, 32000, 0, 1, + "MixerAdvanced.png", "", false, false, 0, "MIXER", null + /*new Object[] { "GRG", "GEG", "CMC", Character.valueOf('M'), + ItemList.Machine_MV_Mixer, Character.valueOf('E'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('R'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('C'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, Character.valueOf('G'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE }*/).getStackForm(1L)); + GregtechItemList.Machine_Advanced_HV_Mixer.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(mID++, "advancedmachine.mixer.tier.03", + "Advanced Combiner II", 3, "Indeed, It does blend!", map, 4, 4, 32000, 0, 1, + "MixerAdvanced.png", "", false, false, 0, "MIXER", null + /*new Object[] { "GRG", "GEG", "CMC", Character.valueOf('M'), + ItemList.Machine_HV_Mixer, Character.valueOf('E'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('R'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('C'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, Character.valueOf('G'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE }*/).getStackForm(1L)); + GregtechItemList.Machine_Advanced_EV_Mixer.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(mID++, "advancedmachine.mixer.tier.04", + "Super Combiner I", 4, "Indeed, It does blend!", map, 4, 4, 32000, 0, 1, + "MixerAdvanced.png", "", false, false, 0, "MIXER", null + /*new Object[] { "GRG", "GEG", "CMC", Character.valueOf('M'), + ItemList.Machine_EV_Mixer, Character.valueOf('E'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('R'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('C'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, Character.valueOf('G'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE }*/).getStackForm(1L)); + GregtechItemList.Machine_Advanced_IV_Mixer.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(mID++, "advancedmachine.mixer.tier.05", + "Super Combiner II", 5, "Indeed, It does blend!", map, 4, 4, 32000, 0, 1, + "MixerAdvanced.png", "", false, false, 0, "MIXER", null + /*new Object[] { "GRG", "GEG", "CMC", Character.valueOf('M'), + ItemList.Machine_IV_Mixer, Character.valueOf('E'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('R'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('C'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, Character.valueOf('G'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE }*/).getStackForm(1L)); + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + try { + GregtechItemList.Machine_Advanced_LuV_Mixer.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(mID++, "advancedmachine.mixer.tier.06", + "Mega Combiner I", 6, "Indeed, It does blend!", map, 4, 4, 32000, 0, 1, + "MixerAdvanced.png", "", false, false, 0, "MIXER", null + /*new Object[] { "GRG", "GEG", "CMC", Character.valueOf('M'), + //ItemList.Machine_LuV_Mixer, Character.valueOf('E'), + ItemList.valueOf("Machine_LuV_Mixer"), Character.valueOf('E'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('R'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('C'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, Character.valueOf('G'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE }*/).getStackForm(1L)); + GregtechItemList.Machine_Advanced_ZPM_Mixer.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(mID++, "advancedmachine.mixer.tier.07", + "Mega Combiner II", 7, "Indeed, It does blend!", map, 4, 4, 32000, 0, 1, + "MixerAdvanced.png", "", false, false, 0, "MIXER", null + /*new Object[] { "GRG", "GEG", "CMC", Character.valueOf('M'), + //ItemList.Machine_ZPM_Mixer, Character.valueOf('E'), + ItemList.valueOf("Machine_ZPM_Mixer"), Character.valueOf('E'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('R'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('C'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, Character.valueOf('G'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE }*/).getStackForm(1L)); + GregtechItemList.Machine_Advanced_UV_Mixer.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(mID++, "advancedmachine.mixer.tier.08", + "Ultra Combiner I", 8, "Indeed, It does blend!", map, 4, 4, 32000, 0, 1, + "MixerAdvanced.png", "", false, false, 0, "MIXER", null + /*new Object[] { "GRG", "GEG", "CMC", Character.valueOf('M'), + //ItemList.Machine_UV_Mixer, Character.valueOf('E'), + ItemList.valueOf("Machine_UV_Mixer"), Character.valueOf('E'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('R'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.MOTOR, Character.valueOf('C'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, Character.valueOf('G'), + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PLATE }*/).getStackForm(1L)); + } + catch (Throwable t){} + } + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java new file mode 100644 index 0000000000..6ddc971f85 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java @@ -0,0 +1,55 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +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; + +public class GregtechAlgaeContent { + + public static void run() { + if (LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Algae Content."); + run1(); + } + } + + private static void run1() { + + // Algae Pond + GregtechItemList.AlgaeFarm_Controller.set(new GregtechMTE_AlgaePondBase(997, "algaefarm.controller.tier.single", "Algae Farm").getStackForm(1L)); + + // 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)); + + + int aTier = 0; + // Bronze + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, ModBlocks.blockCustomMachineCasings, 0, 10); + // Steel + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, GregTech_API.sBlockCasings2, 0, 16); + // Aluminium + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, ModBlocks.blockCustomMachineCasings, 1, 17); + // Stainless + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, GregTech_API.sBlockCasings4, 1, 49); + // Titanium + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, GregTech_API.sBlockCasings4, 2, 50); + // Tungsten + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, GregTech_API.sBlockCasings4, 0, 48); + // Laurenium + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, ModBlocks.blockCustomMachineCasings, 2, 84); + // Botmium + GregtechMTE_ChemicalPlant.registerMachineCasingForTier(aTier++, ModBlocks.blockCustomMachineCasings, 3, 11); + + + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAmazonWarehouse.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAmazonWarehouse.java new file mode 100644 index 0000000000..8adf580011 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAmazonWarehouse.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc.GMTE_AmazonPackager; + +public class GregtechAmazonWarehouse { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Amazon Warehouse Multiblock."); + run1(); + } + } + + private static void run1() { + // Amazon packager multiblock + GregtechItemList.Amazon_Warehouse_Controller.set(new GMTE_AmazonPackager(942, "amazonprime.controller.tier.single", "Amazon Warehousing Depot.").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechBedrockPlatforms.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechBedrockPlatforms.java new file mode 100644 index 0000000000..43a9402be2 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechBedrockPlatforms.java @@ -0,0 +1,18 @@ +/* +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.bedrock.GregtechMetaTileEntity_BedrockMiningPlatform1; + +public class GregtechBedrockPlatforms { + + //941-945 + + public static void run() { + Logger.INFO("Gregtech5u Content | Registering Bedrock Mining Platform."); + GregtechItemList.BedrockMiner_MKI.set(new GregtechMetaTileEntity_BedrockMiningPlatform1(941, "multimachine.tier.01.bedrockminer", "Experimental Deep Earth Drilling Platform - MK I").getStackForm(1)); + } + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechBufferDynamos.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechBufferDynamos.java new file mode 100644 index 0000000000..f236002505 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechBufferDynamos.java @@ -0,0 +1,64 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import static gtPlusPlus.core.recipe.common.CI.bitsd; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DynamoBuffer; + +public class GregtechBufferDynamos { + + private static int mID = 899; + public static void run() { + run2(); + } + + private static final void run2() { + GregtechItemList.Hatch_Buffer_Dynamo_ULV.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.00", "ULV Dynamo Hatch [Buffered]", 0).getStackForm(1L)); + GregtechItemList.Hatch_Buffer_Dynamo_LV.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.01", "LV Dynamo Hatch [Buffered]", 1).getStackForm(1L)); + GregtechItemList.Hatch_Buffer_Dynamo_MV.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.02", "MV Dynamo Hatch [Buffered]", 2).getStackForm(1L)); + GregtechItemList.Hatch_Buffer_Dynamo_HV.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.03", "HV Dynamo Hatch [Buffered]", 3).getStackForm(1L)); + GregtechItemList.Hatch_Buffer_Dynamo_EV.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.04", "EV Dynamo Hatch [Buffered]", 4).getStackForm(1L)); + GregtechItemList.Hatch_Buffer_Dynamo_IV.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.05", "IV Dynamo Hatch [Buffered]", 5).getStackForm(1L)); + GregtechItemList.Hatch_Buffer_Dynamo_LuV.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.06", "LuV Dynamo Hatch [Buffered]", 6).getStackForm(1L)); + GregtechItemList.Hatch_Buffer_Dynamo_ZPM.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.07", "ZPM Dynamo Hatch [Buffered]", 7).getStackForm(1L)); + GregtechItemList.Hatch_Buffer_Dynamo_UV.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.08", "UV Dynamo Hatch [Buffered]", 8).getStackForm(1L)); + GregtechItemList.Hatch_Buffer_Dynamo_MAX.set( + new GT_MetaTileEntity_Hatch_DynamoBuffer(mID++, "hatch.dynamo.buffer.tier.09", "Max Dynamo Hatch [Buffered]", 9).getStackForm(1L)); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_ULV.get(1L, new Object[0]), bitsd, + new Object[]{"TMC", 'M', ItemList.Hatch_Dynamo_ULV, 'T', CI.getTieredCircuit(0), 'C', OrePrefixes.cableGt04.get((Object) Materials.Lead)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_LV.get(1L, new Object[0]), bitsd, + new Object[]{"TMC", 'M', ItemList.Hatch_Dynamo_LV, 'T', CI.getTieredCircuit(1), 'C', OrePrefixes.cableGt04.get((Object) Materials.Tin)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_MV.get(1L, new Object[0]), bitsd, new Object[]{"TMC", 'M', + ItemList.Hatch_Dynamo_MV, 'T', CI.getTieredCircuit(2), 'C', OrePrefixes.cableGt04.get((Object) Materials.AnyCopper)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_HV.get(1L, new Object[0]), bitsd, + new Object[]{"TMC", 'M', ItemList.Hatch_Dynamo_HV, 'T', CI.getTieredCircuit(3), 'C', OrePrefixes.cableGt04.get((Object) Materials.Gold)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_EV.get(1L, new Object[0]), bitsd, new Object[]{"TMC", 'M', + ItemList.Hatch_Dynamo_EV, 'T', CI.getTieredCircuit(4), 'C', OrePrefixes.cableGt04.get((Object) Materials.Aluminium)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1L, new Object[0]), bitsd, new Object[]{"TMC", 'M', + ItemList.Hatch_Dynamo_IV, 'T', CI.getTieredCircuit(5), 'C', OrePrefixes.cableGt04.get((Object) Materials.Tungsten)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_LuV.get(1L, new Object[0]), bitsd, new Object[]{"TMC", + 'M', ItemList.Hatch_Dynamo_LuV, 'T', CI.getTieredCircuit(6), 'C', OrePrefixes.cableGt04.get((Object) Materials.VanadiumGallium)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_ZPM.get(1L, new Object[0]), bitsd, new Object[]{"TMC", + 'M', ItemList.Hatch_Dynamo_ZPM, 'T', CI.getTieredCircuit(7), 'C', OrePrefixes.cableGt04.get((Object) Materials.Naquadah)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_UV.get(1L, new Object[0]), bitsd, new Object[]{"TMC", 'M', + ItemList.Hatch_Dynamo_UV, 'T', CI.getTieredCircuit(8), 'C', OrePrefixes.wireGt12.get((Object) Materials.NaquadahAlloy)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Buffer_Dynamo_MAX.get(1L, new Object[0]), bitsd, new Object[]{"TMC", + 'M', ItemList.Hatch_Dynamo_MAX, 'T', CI.getTieredCircuit(9), 'C', OrePrefixes.wireGt04.get((Object) Materials.Superconductor)}); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechComponentAssembler.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechComponentAssembler.java new file mode 100644 index 0000000000..73d29b2174 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechComponentAssembler.java @@ -0,0 +1,532 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMachine_ComponentAssemblers; + +import java.util.ArrayList; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_GT_Recipe; +import gregtech.api.util.GTPP_Recipe; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraftforge.oredict.OreDictionary; + +public class GregtechComponentAssembler { + + public static void run() { + + if (!enableMachine_ComponentAssemblers) { + return; + } + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + Logger.INFO("Component Assemblers cannot be created in 5.08.33 during the pre-release. Please wait for 1.7.0 release."); + return; + } + + GregtechItemList.Machine_LV_Component_Maker.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(985, + "basicmachine.componentmaker.tier.01", "Basic Component Maker", 1, "Components, Unite!", + GTPP_Recipe.GTPP_Recipe_Map.sComponentAssemblerRecipes, 6, 1, 16000, 0, 1, "Assembler.png", "", false, + false, 0, "ASSEMBLER", + new Object[] { "ACA", "VMV", "WCW", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'V', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM, 'A', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE4 }).getStackForm(1L)); + GregtechItemList.Machine_MV_Component_Maker.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(986, + "basicmachine.componentmaker.tier.02", "Advanced Component Maker", 2, "Components, Unite!", + GTPP_Recipe.GTPP_Recipe_Map.sComponentAssemblerRecipes, 6, 1, 16000, 0, 1, "Assembler.png", "", false, + false, 0, "ASSEMBLER", + new Object[] { "ACA", "VMV", "WCW", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'V', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM, 'A', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE4 }).getStackForm(1L)); + GregtechItemList.Machine_HV_Component_Maker.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(987, + "basicmachine.componentmaker.tier.03", "Advanced Component Maker II", 3, "Components, Unite!", + GTPP_Recipe.GTPP_Recipe_Map.sComponentAssemblerRecipes, 6, 1, 16000, 0, 1, "Assembler.png", "", false, + false, 0, "ASSEMBLER", + new Object[] { "ACA", "VMV", "WCW", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'V', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM, 'A', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE4 }).getStackForm(1L)); + GregtechItemList.Machine_EV_Component_Maker.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(988, + "basicmachine.componentmaker.tier.04", "Advanced Component Maker III", 4, "Components, Unite!", + GTPP_Recipe.GTPP_Recipe_Map.sComponentAssemblerRecipes, 6, 1, 16000, 0, 1, "Assembler.png", "", false, + false, 0, "ASSEMBLER", + new Object[] { "ACA", "VMV", "WCW", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'V', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM, 'A', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE4 }).getStackForm(1L)); + GregtechItemList.Machine_IV_Component_Maker.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(989, + "basicmachine.componentmaker.tier.05", "Advanced Component Maker IV", 5, "Components, Unite!", + GTPP_Recipe.GTPP_Recipe_Map.sComponentAssemblerRecipes, 6, 1, 16000, 0, 1, "Assembler.png", "", false, + false, 0, "ASSEMBLER", + new Object[] { "ACA", "VMV", "WCW", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'V', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM, 'A', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE4 }).getStackForm(1L)); + GregtechItemList.Machine_LuV_Component_Maker.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(31012, + "basicmachine.componentmaker.tier.06", "Advanced Component Maker V", 6, "Components, Unite!", + GTPP_Recipe.GTPP_Recipe_Map.sComponentAssemblerRecipes, 6, 1, 24000, 0, 1, "Assembler.png", "", false, + false, 0, "ASSEMBLER", + new Object[] { "ACA", "VMV", "WCW", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'V', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM, 'A', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE4 }).getStackForm(1L)); + GregtechItemList.Machine_ZPM_Component_Maker.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(31013, + "basicmachine.componentmaker.tier.07", "Advanced Component Maker VI", 7, "Components, Unite!", + GTPP_Recipe.GTPP_Recipe_Map.sComponentAssemblerRecipes, 6, 1, 32000, 0, 1, "Assembler.png", "", false, + false, 0, "ASSEMBLER", + new Object[] { "ACA", "VMV", "WCW", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'V', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM, 'A', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE4 }).getStackForm(1L)); + GregtechItemList.Machine_UV_Component_Maker.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(31014, + "basicmachine.componentmaker.tier.08", "Advanced Component Maker VII", 8, "Components, Unite!", + GTPP_Recipe.GTPP_Recipe_Map.sComponentAssemblerRecipes, 6, 1, 48000, 0, 1, "Assembler.png", "", false, + false, 0, "ASSEMBLER", + new Object[] { "ACA", "VMV", "WCW", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'V', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.ROBOT_ARM, 'A', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PISTON, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE4 }).getStackForm(1L)); + + // Motors + // addRecipeMotor(0, Materials.Lead, 1, Materials.RedAlloy, 1, + // Materials.WroughtIron, Materials.IronMagnetic); + addRecipeMotor(1, Materials.Copper, 1, Materials.Tin, 1, Materials.Iron, Materials.IronMagnetic); + addRecipeMotor(2, Materials.Copper, 2, Materials.Copper, 1, Materials.Aluminium, Materials.SteelMagnetic); + addRecipeMotor(3, Materials.Copper, 4, Materials.Gold, 1, Materials.StainlessSteel, Materials.SteelMagnetic); + addRecipeMotor(4, Materials.Copper, 8, Materials.Aluminium, 1, Materials.Titanium, Materials.NeodymiumMagnetic); + addRecipeMotor(5, Materials.Copper, 16, Materials.Tungsten, 1, Materials.TungstenSteel, + Materials.NeodymiumMagnetic); + + // Pistons + // addRecipePiston(0, Materials.Lead, Materials.Lead); + addRecipePiston(1, Materials.Steel, Materials.Tin); + addRecipePiston(2, Materials.Aluminium, Materials.Copper); + addRecipePiston(3, Materials.StainlessSteel, Materials.Gold); + addRecipePiston(4, Materials.Titanium, Materials.Aluminium); + addRecipePiston(5, Materials.TungstenSteel, Materials.Tungsten); + + // Conveyors + // addRecipeConveyor(0, Materials.Lead); + addRecipeConveyor(1, Materials.Tin); + addRecipeConveyor(2, Materials.Copper); + addRecipeConveyor(3, Materials.Gold); + addRecipeConveyor(4, Materials.Aluminium); + addRecipeConveyor(5, Materials.Tungsten); + + // Pumps + // addRecipePump(0, Materials.Lead, Materials.Lead, Materials.Lead); + addRecipePump(1, Materials.Tin, Materials.Copper, Materials.Tin); + addRecipePump(2, Materials.Bronze, Materials.Steel, Materials.Copper); + addRecipePump(3, Materials.Steel, Materials.StainlessSteel, Materials.Gold); + addRecipePump(4, Materials.StainlessSteel, Materials.Titanium, Materials.Aluminium); + addRecipePump(5, Materials.TungstenSteel, Materials.TungstenSteel, Materials.Tungsten); + + // Robot Arms + // addRecipeRobotArm(0, Materials.Lead, Materials.Lead); + addRecipeRobotArm(1, Materials.Steel, Materials.Tin); + addRecipeRobotArm(2, Materials.Aluminium, Materials.Copper); + addRecipeRobotArm(3, Materials.StainlessSteel, Materials.Gold); + addRecipeRobotArm(4, Materials.Titanium, Materials.Aluminium); + addRecipeRobotArm(5, Materials.TungstenSteel, Materials.Tungsten); + + // Field Generators + // addRecipeFieldGenerator(0, Materials.Lead); + addRecipeFieldGenerator(1); + addRecipeFieldGenerator(2); + addRecipeFieldGenerator(3); + addRecipeFieldGenerator(4); + addRecipeFieldGenerator(5); + + // Emitters + // addRecipeEmitter(0, Materials.Lead, Materials.IronMagnetic); + addRecipeEmitter(1, Materials.Tin, Materials.Brass, Materials.Quartzite); + addRecipeEmitter(2, Materials.Copper, Materials.Electrum, Materials.NetherQuartz); + addRecipeEmitter(3, Materials.Gold, Materials.Chrome, Materials.Emerald); + addRecipeEmitter(4, Materials.Aluminium, Materials.Platinum, Materials.EnderPearl); + addRecipeEmitter(5, Materials.Tungsten, Materials.Osmium, Materials.EnderEye); + + // Sensors + // addRecipeSensor(0, Materials.WroughtIron, Materials.IronMagnetic, + // Materials.Apatite); + addRecipeSensor(1, Materials.Steel, Materials.Brass, Materials.Quartzite); + addRecipeSensor(2, Materials.Aluminium, Materials.Electrum, Materials.NetherQuartz); + addRecipeSensor(3, Materials.StainlessSteel, Materials.Chrome, Materials.Emerald); + addRecipeSensor(4, Materials.Titanium, Materials.Platinum, Materials.EnderPearl); + addRecipeSensor(5, Materials.TungstenSteel, Materials.Osmium, Materials.EnderEye); + + } + + private static boolean addRecipeMotor(int tier, Materials wire, int wirethickness, Materials cable, + int cablethickness, Materials stick, Materials magstick) { + try { + String mWT = "" + wirethickness; + String mCT = "" + cablethickness; + + if (wirethickness < 10) { + mWT = "0" + wirethickness; + } + if (cablethickness < 10) { + mCT = "0" + cablethickness; + } + + OrePrefixes prefixWire = OrePrefixes.getOrePrefix("wireGt" + mWT); + OrePrefixes prefixCable = OrePrefixes.getOrePrefix("cableGt" + mCT); + + ItemStack wireStack = ItemUtils.getGregtechOreStack(prefixWire, wire, 4); + ItemStack cableStack = ItemUtils.getGregtechOreStack(prefixCable, cable, 2); + ItemStack rodStack = ItemUtils.getGregtechOreStack(OrePrefixes.stick, stick, 2); + ItemStack magrodStack = ItemUtils.getGregtechOreStack(OrePrefixes.stick, magstick, 1); + + ItemStack Input[] = { wireStack, cableStack, rodStack, magrodStack }; + + return CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getElectricMotor(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + catch (Throwable t) { + return false; + } + } + + private static boolean addRecipePiston(int tier, Materials mat, Materials cable) { + try { + + OrePrefixes prefixCable = OrePrefixes.cableGt01; + ItemStack cableStack = ItemUtils.getGregtechOreStack(prefixCable, cable, 2); + ItemStack rodStack = ItemUtils.getGregtechOreStack(OrePrefixes.stick, mat, 2); + ItemStack plateStack = ItemUtils.getGregtechOreStack(OrePrefixes.plate, mat, 3); + ItemStack gearStack = ItemUtils.getGregtechOreStack(OrePrefixes.gearGtSmall, mat, 1); + ItemStack motorStack = CI.getElectricMotor(tier, 1); + + ItemStack Input[] = { plateStack, cableStack, rodStack, gearStack, motorStack }; + + return CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getElectricPiston(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + catch (Throwable t) { + return false; + } + } + + private static boolean addRecipeConveyor(int tier, Materials cable) { + try { + OrePrefixes prefixCable = OrePrefixes.cableGt01; + ItemStack cableStack = ItemUtils.getGregtechOreStack(prefixCable, cable, 1); + ItemStack motorStack = CI.getElectricMotor(tier, 2); + boolean mAdd[]; + final ArrayList<ItemStack> oreDictList = OreDictionary.getOres("plateAnyRubber"); + if (!oreDictList.isEmpty()) { + int mcount = 0; + mAdd = new boolean[oreDictList.size()]; + for (ItemStack mRubberType : oreDictList) { + final ItemStack returnValue = mRubberType.copy(); + returnValue.stackSize = 6; + ItemStack Input[] = { cableStack, motorStack, returnValue }; + mAdd[mcount++] = CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getConveyor(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + int added = 0; + for (boolean y : mAdd) { + if (y) { + added++; + } + } + if (added >= (oreDictList.size() / 2)) { + return true; + } + else { + return false; + } + } + else { + ItemStack Input[] = { cableStack, motorStack, + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateRubber", 6) }; + return CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getConveyor(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + + } + catch (Throwable t) { + return false; + } + } + + private static boolean addRecipePump(int tier, Materials main, Materials pipe, Materials cable) { + try { + ItemStack cableStack = ItemUtils.getGregtechOreStack(OrePrefixes.cableGt01, cable, 1); + ItemStack screwStack = ItemUtils.getGregtechOreStack(OrePrefixes.screw, main, 1); + ItemStack rotorStack = ItemUtils.getGregtechOreStack(OrePrefixes.rotor, main, 1); + ItemStack pipeStack = ItemUtils.getGregtechOreStack(OrePrefixes.pipeMedium, pipe, 1); + ItemStack motorStack = CI.getElectricMotor(tier, 1); + boolean mAdd[]; + final ArrayList<ItemStack> oreDictList = OreDictionary.getOres("ringAnyRubber"); + if (!oreDictList.isEmpty()) { + int mcount = 0; + mAdd = new boolean[oreDictList.size()]; + for (ItemStack mRubberType : oreDictList) { + final ItemStack returnValue = mRubberType.copy(); + returnValue.stackSize = 2; + ItemStack Input[] = { cableStack, screwStack, rotorStack, pipeStack, motorStack, returnValue }; + mAdd[mcount++] = CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getElectricPump(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + int added = 0; + for (boolean y : mAdd) { + if (y) { + added++; + } + } + if (added >= (oreDictList.size() / 2)) { + return true; + } + else { + return false; + } + } + else { + ItemStack Input[] = { cableStack, screwStack, rotorStack, pipeStack, motorStack, + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ringRubber", 2) }; + return CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getElectricPump(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + + } + catch (Throwable t) { + return false; + } + } + + private static boolean addRecipeRobotArm(int tier, Materials stick, Materials cable) { + try { + ItemStack cableStack = ItemUtils.getGregtechOreStack(OrePrefixes.cableGt01, cable, 3); + ItemStack rodStack = ItemUtils.getGregtechOreStack(OrePrefixes.stick, stick, 2); + ItemStack motorStack = CI.getElectricMotor(tier, 2); + ItemStack pistonStack = CI.getElectricPiston(tier, 1); + + boolean mAdd[]; + final ItemStack oreDictList[] = CI.getAllCircuitsOfTier(tier); + if (oreDictList.length > 0) { + int mcount = 0, added = 0; + mAdd = new boolean[oreDictList.length]; + for (ItemStack mCircuitType : oreDictList) { + final ItemStack returnValue = mCircuitType.copy(); + returnValue.stackSize = 1; + ItemStack Input[] = { returnValue, cableStack, rodStack, pistonStack, motorStack }; + mAdd[mcount++] = CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getRobotArm(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + for (boolean y : mAdd) { + if (y) { + added++; + } + } + if (added >= (oreDictList.length / 2)) { + return true; + } + else { + return false; + } + } + else { + ItemStack Input[] = { ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(tier), 1), cableStack, rodStack, pistonStack, motorStack }; + return CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getRobotArm(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + + + } + catch (Throwable t) { + return false; + } + } + + private static boolean addRecipeFieldGenerator(int tier) { + try { + ItemStack gem; + String mWT; + if (tier == 1) + mWT = "01"; + else if (tier == 2) + mWT = "02"; + else if (tier == 3) + mWT = "04"; + else if (tier == 4) + mWT = "08"; + else if (tier == 5) + mWT = "16"; + else + mWT = "01"; + + ItemStack eyeQuantum = ItemUtils.getValueOfItemList("QuantumEye", 1, ItemUtils.getSimpleStack(Items.ender_eye, 4)); + ItemStack starQuantum = ItemUtils.getValueOfItemList("QuantumStar", 1, ItemUtils.getSimpleStack(Items.nether_star, 4)); + + if (tier == 1) + gem = ItemUtils.getSimpleStack(Items.ender_pearl); + else if (tier == 2) + gem = ItemUtils.getSimpleStack(Items.ender_eye); + else if (tier == 3) + gem = eyeQuantum; + else if (tier == 4) + gem = ItemUtils.getSimpleStack(Items.nether_star); + else if (tier == 5) + gem = starQuantum; + else + gem = ItemUtils.getSimpleStack(Items.ender_pearl); + + OrePrefixes prefixWire = OrePrefixes.getOrePrefix("wireGt" + mWT); + ItemStack wireStack = ItemUtils.getGregtechOreStack(prefixWire, Materials.Osmium, 4); + + boolean mAdd[]; + final ItemStack oreDictList[] = CI.getAllCircuitsOfTier(tier); + if (oreDictList.length > 0) { + int mcount = 0, added = 0; + mAdd = new boolean[oreDictList.length]; + for (ItemStack mCircuitType : oreDictList) { + final ItemStack returnValue = mCircuitType.copy(); + returnValue.stackSize = 4; + ItemStack Input[] = { returnValue, wireStack, gem }; + mAdd[mcount++] = CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getFieldGenerator(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + for (boolean y : mAdd) { + if (y) { + added++; + } + } + if (added >= (oreDictList.length / 2)) { + return true; + } + else { + return false; + } + } + else { + ItemStack Input[] = { ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(tier), 4), wireStack, gem }; + return CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getFieldGenerator(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + + } + catch (Throwable t) { + return false; + } + } + + private static boolean addRecipeEmitter(int tier, Materials cable, Materials stick, Materials gem) { + try { + ItemStack cableStack = ItemUtils.getGregtechOreStack(OrePrefixes.cableGt01, cable, 2); + ItemStack gemstack = ItemUtils.getGregtechOreStack(OrePrefixes.gem, gem, 1); + ItemStack magrodStack = ItemUtils.getGregtechOreStack(OrePrefixes.stick, stick, 4); + + boolean mAdd[]; + final ItemStack oreDictList[] = CI.getAllCircuitsOfTier(tier); + if (oreDictList.length > 0) { + int mcount = 0, added = 0; + mAdd = new boolean[oreDictList.length]; + for (ItemStack mCircuitType : oreDictList) { + final ItemStack returnValue = mCircuitType.copy(); + returnValue.stackSize = 2; + ItemStack Input[] = { returnValue, cableStack, gemstack, magrodStack }; + mAdd[mcount++] = CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getEmitter(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + for (boolean y : mAdd) { + if (y) { + added++; + } + } + if (added >= (oreDictList.length / 2)) { + return true; + } + else { + return false; + } + } + else { + ItemStack Input[] = { ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(tier), 2), cableStack, gemstack, magrodStack }; + return CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getEmitter(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + + + + } + catch (Throwable t) { + return false; + } + } + + private static boolean addRecipeSensor(int tier, Materials plate, Materials rod, Materials gem) { + try { + ItemStack cableStack = ItemUtils.getGregtechOreStack(OrePrefixes.plate, plate, 4); + ItemStack magrodStack = ItemUtils.getGregtechOreStack(OrePrefixes.stick, rod, 1); + ItemStack gemStack = ItemUtils.getGregtechOreStack(OrePrefixes.gem, gem, 1); + + boolean mAdd[]; + final ItemStack oreDictList[] = CI.getAllCircuitsOfTier(tier); + if (oreDictList.length > 0) { + int mcount = 0, added = 0; + mAdd = new boolean[oreDictList.length]; + for (ItemStack mCircuitType : oreDictList) { + final ItemStack returnValue = mCircuitType.copy(); + returnValue.stackSize = 1; + ItemStack Input[] = { gemStack, cableStack, returnValue, magrodStack }; + mAdd[mcount++] = CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getSensor(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + for (boolean y : mAdd) { + if (y) { + added++; + } + } + if (added >= (oreDictList.length / 2)) { + return true; + } + else { + return false; + } + } + else { + ItemStack Input[] = { gemStack, cableStack, magrodStack, ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(tier), 1) }; + return CORE.RA.addComponentMakerRecipe(Input, GT_Values.NF, + CI.getSensor(tier, 1), (tier * 40), + ((int) GT_Values.V[tier] / 16) * 15); + } + + + } + catch (Throwable t) { + return false; + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java new file mode 100644 index 0000000000..9a5fa6f6de --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java @@ -0,0 +1,698 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import static gtPlusPlus.core.lib.CORE.GTNH; +import static gtPlusPlus.core.lib.LoadedMods.Gregtech; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; +import gregtech.api.util.GT_OreDictUnificator; +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.ELEMENT; +import gtPlusPlus.core.material.Material; +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.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GregtechMetaPipeEntityFluid; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GregtechMetaPipeEntity_Cable; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class GregtechConduits { + /** + * + * The Voltage Tiers. Use this Array instead of the old named Voltage Variables + * public static final long[] V = new long[] {0=8, 1=32, 2=128, 3=512, 4=2048, 5=8192, 6=32768, 7=131072, 8=524288, 9=Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE}; + * + */ + + private static OrePrefixes cableGt16; + static{ + if(GTNH) { + try { + cableGt16=(OrePrefixes) GT_Utility.getField(OrePrefixes.class,"cableGt16").get(null); + }catch (IllegalAccessException | NullPointerException e){ + e.printStackTrace(); + } + } + } + + //30000-30999 + + private static int BaseWireID = 30600; + private static int BasePipeID = 30700; + private static int BasePipeHexadecupleID = 30100; + + + public static void run() + { + if (Gregtech){ + Logger.INFO("Gregtech5u Content | Registering Custom Cables/Wires/Pipes."); + if (CORE.ConfigSwitches.enableCustom_Cables) { + run1(); + } + if (CORE.ConfigSwitches.enableCustom_Pipes) { + run2(); + run3(); + } + } + + } + + private static void run3() { + + if (Utils.getGregtechVersionAsInt() >= 50930) { + try { + Class<GT_MetaPipeEntity_Fluid> aPipeEntity = GT_MetaPipeEntity_Fluid.class; + Constructor<GT_MetaPipeEntity_Fluid> constructor = aPipeEntity.getConstructor(int.class, String.class, String.class, float.class, Materials.class, int.class, int.class, boolean.class, int.class); + if (constructor != null) { + Logger.INFO("Generating Hexadecuple pipes."); + generateFluidMultiPipes(constructor, Materials.Copper, MaterialUtils.getMaterialName(Materials.Copper), "Copper", BasePipeHexadecupleID++, 60, 1000, true); + generateFluidMultiPipes(constructor, Materials.Bronze, MaterialUtils.getMaterialName(Materials.Bronze), "Bronze", BasePipeHexadecupleID++, 120, 2000, true); + generateFluidMultiPipes(constructor, Materials.Steel, MaterialUtils.getMaterialName(Materials.Steel), "Steel", BasePipeHexadecupleID++, 240, 2500, true); + generateFluidMultiPipes(constructor, Materials.StainlessSteel, MaterialUtils.getMaterialName(Materials.StainlessSteel), "Stainless Steel", BasePipeHexadecupleID++, 360, 3000, true); + generateFluidMultiPipes(constructor, Materials.Titanium, MaterialUtils.getMaterialName(Materials.Titanium), "Titanium", BasePipeHexadecupleID++, 480, 5000, true); + generateFluidMultiPipes(constructor, Materials.TungstenSteel, MaterialUtils.getMaterialName(Materials.TungstenSteel), "Tungsten Steel", BasePipeHexadecupleID++, 600, 7500, true); + generateFluidMultiPipes(constructor, Materials.Plastic, MaterialUtils.getMaterialName(Materials.Plastic), "Plastic", BasePipeHexadecupleID++, 360, 350, true); + + Materials aPTFE = Materials.get("Polytetrafluoroethylene"); + if (aPTFE != null) { + generateFluidMultiPipes(constructor, aPTFE, MaterialUtils.getMaterialName(aPTFE), "PTFE", BasePipeHexadecupleID++, 480, 600, true); + } + } + else { + Logger.INFO("Failed during Hexadecuple pipe generation."); + } + + } catch (NoSuchMethodException | SecurityException e) { + Logger.INFO("Failed during Hexadecuple pipe generation. [Ecx]"); + e.printStackTrace(); + } + } + + + //Generate Heat Pipes + //GregtechItemList.HeatPipe_Tier_1.set(new GT_MetaPipeEntity_Heat(31021, "gtpp.pipe.heat.basic.01", "Lead Heat Pipe (500C)", Materials.Lead, 500).getStackForm(1L)); + //GregtechItemList.HeatPipe_Tier_2.set(new GT_MetaPipeEntity_Heat(31022, "gtpp.pipe.heat.basic.02", "Iron Heat Pipe (500C)", Materials.Iron, 500).getStackForm(1L)); + //GregtechItemList.HeatPipe_Tier_3.set(new GT_MetaPipeEntity_Heat(31023, "gtpp.pipe.heat.basic.03", "Silver Heat Pipe (1500C)", Materials.Silver, 1500).getStackForm(1L)); + + + + } + + private static void generateFluidMultiPipes(Constructor<GT_MetaPipeEntity_Fluid> aClazz, Materials aMaterial, String name, String displayName, int startID, int baseCapacity, int heatCapacity, boolean gasProof){ + GT_MetaPipeEntity_Fluid aPipe; + try { + aPipe = aClazz.newInstance(startID, "GT_Pipe_" + name + "_Hexadecuple", + "Hexadecuple " + displayName + " Fluid Pipe", 1.0F, aMaterial, baseCapacity, heatCapacity, gasProof, + 16); + if (aPipe == null) { + Logger.INFO("Failed to Generate "+aMaterial+" Hexadecuple pipes."); + } + else { + Logger.INFO("Generated "+aMaterial+" Hexadecuple pipes."); + GT_OreDictUnificator.registerOre("pipeHexadecuple" + aMaterial, aPipe.getStackForm(1L)); + } + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + Logger.INFO("Failed to Generate "+aMaterial+" Hexadecuple pipes. [Ecx]"); + e.printStackTrace(); + } + } + + private static void run1(){ + + if (LoadedMods.Big_Reactors){ + wireFactory("Blutonium", 8196, BaseWireID, 8, 32, 2, new short[]{28, 28, 218, 0}); + wireFactory("Cyanite", 512, BaseWireID+15, 2, 16, 4, new short[]{27, 130, 178, 0}); + wireFactory("Yellorium", 2048, BaseWireID+30, 4, 16, 2, new short[]{150, 195, 54, 0}); + } + + if (LoadedMods.EnderIO){ + wireFactory("RedstoneAlloy", 32, BaseWireID+45, 0, 2, 1, new short[]{178,34,34, 0}); + } + + if(!GTNH) { + customWireFactory(ALLOY.LEAGRISIUM, 512, BaseWireID + 56, 1, 2, 2); + customWireFactory(ELEMENT.getInstance().ZIRCONIUM, 128, BaseWireID + 67, 1, 2, 2); + customWireFactory(ALLOY.HG1223, 32768, BaseWireID + 78, 2, 8, 4); + customWireFactory(ALLOY.TRINIUM_TITANIUM, 2048, BaseWireID + 89, 1, 2, 16); + } + + + //superConductorFactory(GT_Materials.Superconductor, 524288, 30660, 0, 0, 8); + if (LoadedMods.Thaumcraft){ + //superConductorFactory(GT_Materials.Void, 512, 30661, 0, 0, 8); + } + } + + private static void run2(){ + generateNonGTFluidPipes(GT_Materials.Staballoy, ALLOY.STABALLOY, BasePipeID, 6250, 7500, true); + generateNonGTFluidPipes(GT_Materials.Tantalloy60, ALLOY.TANTALLOY_60, BasePipeID+5, 5000, 4250, true); + generateNonGTFluidPipes(GT_Materials.Tantalloy61, ALLOY.TANTALLOY_61, BasePipeID+10, 6000, 5800, true); + if (LoadedMods.Thaumcraft){ + generateNonGTFluidPipes(GT_Materials.Void, null, BasePipeID+15, 800, 25000, true); + } + generateGTFluidPipes(Materials.Europium, BasePipeID+20, 12000, 7500, true); + generateNonGTFluidPipes(GT_Materials.Potin, ALLOY.POTIN, BasePipeID+25, 480, 2000, true); + generateNonGTFluidPipes(GT_Materials.MaragingSteel300, ALLOY.MARAGING300, BasePipeID+30, 7000, 2500, true); + generateNonGTFluidPipes(GT_Materials.MaragingSteel350, ALLOY.MARAGING350, BasePipeID+35, 8000, 2500, true); + generateNonGTFluidPipes(GT_Materials.Inconel690, ALLOY.INCONEL_690, BasePipeID+40, 7500, 4800, true); + generateNonGTFluidPipes(GT_Materials.Inconel792, ALLOY.INCONEL_792, BasePipeID+45, 8000, 5500, true); + generateNonGTFluidPipes(GT_Materials.HastelloyX, ALLOY.HASTELLOY_X, BasePipeID+50, 10000, 4200, true); + + generateGTFluidPipes(Materials.Tungsten, BasePipeID+55, 4320, 7200, true); + if (LoadedMods.EnderIO){ + generateGTFluidPipes(Materials.DarkSteel, BasePipeID+60, 2320, 2750, true); + } + generateGTFluidPipes(Materials.Clay, BasePipeID+65, 100, 500, false); + generateGTFluidPipes(Materials.Lead, BasePipeID+70, 720, 1200, true); + + generateNonGTFluidPipes(GT_Materials.TriniumNaquadahCarbonite, ALLOY.TRINIUM_NAQUADAH_CARBON, 30500, 10, 250000, true); + + } + + private static void wireFactory(final String Material, final int Voltage, final int ID, final long insulatedLoss, final long uninsulatedLoss, final long Amps, final short[] rgb){ + @SuppressWarnings("deprecation") + final Materials T = Materials.valueOf(Material); + int V = GT_Utility.getTier(Voltage); + if (V == -1){ + Logger.ERROR("Failed to set voltage on "+Material+". Invalid voltage of "+Voltage+"V set."); + Logger.ERROR(Material+" has defaulted to 8v."); + V=0; + } + makeWires(T, ID, insulatedLoss, uninsulatedLoss, Amps, GT_Values.V[V], true, false, rgb); + } + + @SuppressWarnings("deprecation") + private static void makeWires(final Materials aMaterial, final int aStartID, final long aLossInsulated, final long aLoss, final long aAmperage, final long aVoltage, final boolean aInsulatable, final boolean aAutoInsulated, final short[] aRGB) + { + Logger.WARNING("Gregtech5u Content | Registered "+aMaterial.name() +" as a new material for Wire & Cable."); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt01, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 0, "wire." + aMaterial.name().toLowerCase() + ".01", "1x " + aMaterial.mDefaultLocalName + " Wire", 0.125F, aMaterial, aLoss, 1L * aAmperage, aVoltage, false, !aAutoInsulated, aRGB).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt02, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 1, "wire." + aMaterial.name().toLowerCase() + ".02", "2x " + aMaterial.mDefaultLocalName + " Wire", 0.25F, aMaterial, aLoss, 2L * aAmperage, aVoltage, false, !aAutoInsulated, aRGB).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt04, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 2, "wire." + aMaterial.name().toLowerCase() + ".04", "4x " + aMaterial.mDefaultLocalName + " Wire", 0.375F, aMaterial, aLoss, 4L * aAmperage, aVoltage, false, !aAutoInsulated, aRGB).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt08, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 3, "wire." + aMaterial.name().toLowerCase() + ".08", "8x " + aMaterial.mDefaultLocalName + " Wire", 0.50F, aMaterial, aLoss, 8L * aAmperage, aVoltage, false, !aAutoInsulated, aRGB).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt12, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 4, "wire." + aMaterial.name().toLowerCase() + ".12", "12x " + aMaterial.mDefaultLocalName + " Wire", GTNH?0.625F:0.75F, aMaterial, aLoss, 12L * aAmperage, aVoltage, false, !aAutoInsulated, aRGB).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.wireGt16, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 5, "wire." + aMaterial.name().toLowerCase() + ".16", "16x " + aMaterial.mDefaultLocalName + " Wire", GTNH?0.75F:1.0F, aMaterial, aLoss, 16L * aAmperage, aVoltage, false, !aAutoInsulated, aRGB).getStackForm(1L)); + if (aInsulatable) + { + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt01, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 6, "cable." + aMaterial.name().toLowerCase() + ".01", "1x " + aMaterial.mDefaultLocalName + " Cable", 0.25F, aMaterial, aLossInsulated, 1L * aAmperage, aVoltage, true, false, aRGB).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt02, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 7, "cable." + aMaterial.name().toLowerCase() + ".02", "2x " + aMaterial.mDefaultLocalName + " Cable", 0.375F, aMaterial, aLossInsulated, 2L * aAmperage, aVoltage, true, false, aRGB).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt04, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 8, "cable." + aMaterial.name().toLowerCase() + ".04", "4x " + aMaterial.mDefaultLocalName + " Cable", 0.5F, aMaterial, aLossInsulated, 4L * aAmperage, aVoltage, true, false, aRGB).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt08, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 9, "cable." + aMaterial.name().toLowerCase() + ".08", "8x " + aMaterial.mDefaultLocalName + " Cable", 0.625F, aMaterial, aLossInsulated, 8L * aAmperage, aVoltage, true, false, aRGB).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.cableGt12, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 10, "cable." + aMaterial.name().toLowerCase() + ".12", "12x " + aMaterial.mDefaultLocalName + " Cable", GTNH?0.75F:0.875F, aMaterial, aLossInsulated, 12L * aAmperage, aVoltage, true, false, aRGB).getStackForm(1L)); + if(GTNH){ + GT_OreDictUnificator.registerOre(cableGt16, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 11, "cable." + aMaterial.name().toLowerCase() + ".16", "16x " + aMaterial.mDefaultLocalName + " Cable", 0.875f, aMaterial, aLossInsulated, 16L * aAmperage, aVoltage, true, false, aRGB).getStackForm(1L)); + } + } + } + + private static void customWireFactory(final Material Material, final int Voltage, final int ID, final long insulatedLoss, final long uninsulatedLoss, final long Amps){ + int V = GT_Utility.getTier(Voltage); + if (V == -1){ + Logger.ERROR("Failed to set voltage on "+Material+". Invalid voltage of "+Voltage+"V set."); + Logger.ERROR(Material+" has defaulted to 8v."); + V=0; + } + makeCustomWires(Material, ID, insulatedLoss, uninsulatedLoss, Amps, GT_Values.V[V], true, false); + } + + private static void makeCustomWires(final Material aMaterial, final int aStartID, final long aLossInsulated, final long aLoss, final long aAmperage, final long aVoltage, final boolean aInsulatable, final boolean aAutoInsulated) + { + Logger.WARNING("Gregtech5u Content | Registered "+aMaterial.getLocalizedName() +" as a new material for Wire & Cable."); + registerOre(OrePrefixes.wireGt01, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 0, "wire." + aMaterial.getLocalizedName().toLowerCase() + ".01", "1x " + aMaterial.getLocalizedName() + " Wire", 0.125F, aLoss, 1L * aAmperage, aVoltage, false, !aAutoInsulated, aMaterial.getRGBA()).getStackForm(1L)); + registerOre(OrePrefixes.wireGt02, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 1, "wire." + aMaterial.getLocalizedName().toLowerCase() + ".02", "2x " + aMaterial.getLocalizedName() + " Wire", 0.25F, aLoss, 2L * aAmperage, aVoltage, false, !aAutoInsulated, aMaterial.getRGBA()).getStackForm(1L)); + registerOre(OrePrefixes.wireGt04, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 2, "wire." + aMaterial.getLocalizedName().toLowerCase() + ".04", "4x " + aMaterial.getLocalizedName() + " Wire", 0.375F, aLoss, 4L * aAmperage, aVoltage, false, !aAutoInsulated, aMaterial.getRGBA()).getStackForm(1L)); + registerOre(OrePrefixes.wireGt08, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 3, "wire." + aMaterial.getLocalizedName().toLowerCase() + ".08", "8x " + aMaterial.getLocalizedName() + " Wire", 0.50F, aLoss, 8L * aAmperage, aVoltage, false, !aAutoInsulated, aMaterial.getRGBA()).getStackForm(1L)); + registerOre(OrePrefixes.wireGt12, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 4, "wire." + aMaterial.getLocalizedName().toLowerCase() + ".12", "12x " + aMaterial.getLocalizedName() + " Wire", GTNH?0.625F:0.75F, aLoss, 12L * aAmperage, aVoltage, false, !aAutoInsulated, aMaterial.getRGBA()).getStackForm(1L)); + registerOre(OrePrefixes.wireGt16, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 5, "wire." + aMaterial.getLocalizedName().toLowerCase() + ".16", "16x " + aMaterial.getLocalizedName() + " Wire", GTNH?0.75F:1.0F, aLoss, 16L * aAmperage, aVoltage, false, !aAutoInsulated, aMaterial.getRGBA()).getStackForm(1L)); + if (aInsulatable) + { + registerOre(OrePrefixes.cableGt01, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 6, "cable." + aMaterial.getLocalizedName().toLowerCase() + ".01", "1x " + aMaterial.getLocalizedName() + " Cable", 0.25F, aLossInsulated, 1L * aAmperage, aVoltage, true, false, aMaterial.getRGBA()).getStackForm(1L)); + registerOre(OrePrefixes.cableGt02, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 7, "cable." + aMaterial.getLocalizedName().toLowerCase() + ".02", "2x " + aMaterial.getLocalizedName() + " Cable", 0.375F, aLossInsulated, 2L * aAmperage, aVoltage, true, false, aMaterial.getRGBA()).getStackForm(1L)); + registerOre(OrePrefixes.cableGt04, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 8, "cable." + aMaterial.getLocalizedName().toLowerCase() + ".04", "4x " + aMaterial.getLocalizedName() + " Cable", 0.5F, aLossInsulated, 4L * aAmperage, aVoltage, true, false, aMaterial.getRGBA()).getStackForm(1L)); + registerOre(OrePrefixes.cableGt08, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 9, "cable." + aMaterial.getLocalizedName().toLowerCase() + ".08", "8x " + aMaterial.getLocalizedName() + " Cable", 0.625F, aLossInsulated, 8L * aAmperage, aVoltage, true, false, aMaterial.getRGBA()).getStackForm(1L)); + registerOre(OrePrefixes.cableGt12, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 10, "cable." + aMaterial.getLocalizedName().toLowerCase() + ".12", "12x " + aMaterial.getLocalizedName() + " Cable", GTNH?0.75F:0.875F, aLossInsulated, 12L * aAmperage, aVoltage, true, false, aMaterial.getRGBA()).getStackForm(1L)); + if(GTNH){ + registerOre(cableGt16, aMaterial, new GregtechMetaPipeEntity_Cable(aStartID + 11, "cable." + aMaterial.getLocalizedName().toLowerCase() + ".16", "16x " + aMaterial.getLocalizedName() + " Cable", 0.875f, aLossInsulated, 16L * aAmperage, aVoltage, true, false, aMaterial.getRGBA()).getStackForm(1L)); + } + } + + } + + private static void superConductorFactory(final GT_Materials Material, final int Voltage, final int ID, final long insulatedLoss, final long uninsulatedLoss, final long Amps){ + final GT_Materials T = Material; + int V = 0; + if (Voltage == 8){ + V = 0; + } + else if (Voltage == 32){ + V = 1; + } + else if (Voltage == 128){ + V = 2; + } + else if (Voltage == 512){ + V = 3; + } + else if (Voltage == 2048){ + V = 4; + } + else if (Voltage == 8196){ + V = 5; + } + else if (Voltage == 32768){ + V = 6; + } + else if (Voltage == 131072){ + V = 7; + } + else if (Voltage == 524288){ + V = 8; + } + else if (Voltage == Integer.MAX_VALUE){ + V = 9; + } + else { + Logger.ERROR("Failed to set voltage on "+Material.name()+". Invalid voltage of "+Voltage+"V set."); + Logger.ERROR(Material.name()+" has defaulted to 8v."); + V = 0; + } + //makeWires(T, ID, 2L, 4L, 2L, GT_Values.V[V], true, false); + //makeSuperConductors(T, ID, insulatedLoss, uninsulatedLoss, Amps, GT_Values.V[V], true, false); + //makeWires(T, ID, bEC ? 2L : 2L, bEC ? 4L : 4L, 2L, gregtech.api.enums.GT_Values.V[V], true, false); + } + + + private static void generateGTFluidPipes(final Materials material, final int startID, final int transferRatePerSec, final int heatResistance, final boolean isGasProof){ + final int transferRatePerTick = transferRatePerSec/20; + final long mass = material.getMass(); + final long voltage = material.mMeltingPoint >= 2800 ? 64 : 16; + GT_OreDictUnificator.registerOre(OrePrefixes.pipeTiny.get(material), new GT_MetaPipeEntity_Fluid(startID, "GT_Pipe_"+material.mDefaultLocalName+"_Tiny", "Tiny "+material.mDefaultLocalName+" Fluid Pipe", 0.25F, material, transferRatePerTick*2, heatResistance, isGasProof).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeSmall.get(material), new GT_MetaPipeEntity_Fluid(startID+1, "GT_Pipe_"+material.mDefaultLocalName+"_Small", "Small "+material.mDefaultLocalName+" Fluid Pipe", 0.375F, material, transferRatePerTick*4, heatResistance, isGasProof).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(material), new GT_MetaPipeEntity_Fluid(startID+2, "GT_Pipe_"+material.mDefaultLocalName+"", ""+material.mDefaultLocalName+" Fluid Pipe", 0.5F, material, transferRatePerTick*12, heatResistance, isGasProof).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeLarge.get(material), new GT_MetaPipeEntity_Fluid(startID+3, "GT_Pipe_"+material.mDefaultLocalName+"_Large", "Large "+material.mDefaultLocalName+" Fluid Pipe", 0.75F, material, transferRatePerTick*24, heatResistance, isGasProof).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeHuge.get(material), new GT_MetaPipeEntity_Fluid(startID+4, "GT_Pipe_"+material.mDefaultLocalName+"_Huge", "Huge "+material.mDefaultLocalName+" Fluid Pipe", GTNH?0.875F:1.0F, material, transferRatePerTick*48, heatResistance, isGasProof).getStackForm(1L)); + //generatePipeRecipes(material.mDefaultLocalName, mass, voltage); + } + + private static void generateNonGTFluidPipes(final GT_Materials material, final Material myMaterial, final int startID, final int transferRatePerSec, final int heatResistance, final boolean isGasProof){ + final int transferRatePerTick = transferRatePerSec/10; + long mass; + if (myMaterial != null){ + mass = myMaterial.getMass(); + } + else { + mass = ELEMENT.getInstance().IRON.getMass(); + } + + int tVoltageMultiplier = (material.mBlastFurnaceTemp >= 2800) ? 64 : 16; + + GT_OreDictUnificator.registerOre(OrePrefixes.pipeTiny.get(material), new GregtechMetaPipeEntityFluid(startID, "GT_Pipe_"+material.mDefaultLocalName+"_Tiny", "Tiny "+material.mDefaultLocalName+" Fluid Pipe", 0.25F, material, transferRatePerTick*2, heatResistance, isGasProof).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeSmall.get(material), new GregtechMetaPipeEntityFluid(startID+1, "GT_Pipe_"+material.mDefaultLocalName+"_Small", "Small "+material.mDefaultLocalName+" Fluid Pipe", 0.375F, material, transferRatePerTick*4, heatResistance, isGasProof).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeMedium.get(material), new GregtechMetaPipeEntityFluid(startID+2, "GT_Pipe_"+material.mDefaultLocalName+"", ""+material.mDefaultLocalName+" Fluid Pipe", 0.5F, material, transferRatePerTick*12, heatResistance, isGasProof).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeLarge.get(material), new GregtechMetaPipeEntityFluid(startID+3, "GT_Pipe_"+material.mDefaultLocalName+"_Large", "Large "+material.mDefaultLocalName+" Fluid Pipe", 0.75F, material, transferRatePerTick*24, heatResistance, isGasProof).getStackForm(1L)); + GT_OreDictUnificator.registerOre(OrePrefixes.pipeHuge.get(material), new GregtechMetaPipeEntityFluid(startID+4, "GT_Pipe_"+material.mDefaultLocalName+"_Huge", "Huge "+material.mDefaultLocalName+" Fluid Pipe", GTNH?0.875F:1.0F, material, transferRatePerTick*48, heatResistance, isGasProof).getStackForm(1L)); + //generatePipeRecipes(material.mDefaultLocalName, mass, tVoltageMultiplier); + + } + + public static void generatePipeRecipes(final String materialName, final long Mass, final long vMulti){ + + String output = materialName.substring(0, 1).toUpperCase() + materialName.substring(1); + output = Utils.sanitizeString(output); + + if (output.equals("VoidMetal")){ + output = "Void"; + } + + Logger.INFO("Generating "+output+" pipes & respective recipes."); + + ItemStack pipeIngot = ItemUtils.getItemStackOfAmountFromOreDict("ingot"+output, 1); + ItemStack pipePlate = ItemUtils.getItemStackOfAmountFromOreDict("plate"+output, 1); + + if (pipeIngot == null){ + if (pipePlate != null){ + pipeIngot = pipePlate; + } + } + + //Check all pipes are not null + Logger.WARNING("Generated pipeTiny from "+ materialName +"? "+ ((ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Tiny"+output, 1) != null) ? true : false)); + Logger.WARNING("Generated pipeSmall from "+ materialName +"? "+ ((ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Small"+output, 1) != null) ? true : false)); + Logger.WARNING("Generated pipeNormal from "+ materialName +"? "+ ((ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Medium"+output, 1) != null) ? true : false)); + Logger.WARNING("Generated pipeLarge from "+ materialName +"? "+ ((ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Large"+output, 1) != null) ? true : false)); + Logger.WARNING("Generated pipeHuge from "+ materialName +"? "+ ((ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Huge"+output, 1) != null) ? true : false)); + + int eut = 120; + eut = (int) (8 * vMulti); + + + //Add the Three Shaped Recipes First + RecipeUtils.addShapedRecipe( + pipePlate, "craftingToolWrench", pipePlate, + pipePlate, null, pipePlate, + pipePlate, "craftingToolHardHammer", pipePlate, + ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Small"+output, 6)); + + RecipeUtils.addShapedRecipe( + pipePlate, pipePlate, pipePlate, + "craftingToolWrench", null, "craftingToolHardHammer", + pipePlate, pipePlate, pipePlate, + ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Medium"+output, 2)); + + RecipeUtils.addShapedRecipe( + pipePlate, "craftingToolHardHammer", pipePlate, + pipePlate, null, pipePlate, + pipePlate, "craftingToolWrench", pipePlate, + ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Large"+output, 1)); + + if (pipeIngot != null && ItemUtils.checkForInvalidItems(pipeIngot)) { + GT_Values.RA.addExtruderRecipe( + ItemUtils.getSimpleStack(pipeIngot, 1), + ItemList.Shape_Extruder_Pipe_Tiny.get(0), + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("pipe"+"Tiny"+output, 2), + 5, eut); + + GT_Values.RA.addExtruderRecipe( + ItemUtils.getSimpleStack(pipeIngot, 1), + ItemList.Shape_Extruder_Pipe_Small.get(0), + ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Small"+output, 1), + 10, eut); + + GT_Values.RA.addExtruderRecipe( + ItemUtils.getSimpleStack(pipeIngot, 3), + ItemList.Shape_Extruder_Pipe_Medium.get(0), + ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Medium"+output, 1), + 1*20, eut); + + GT_Values.RA.addExtruderRecipe( + ItemUtils.getSimpleStack(pipeIngot, 6), + ItemList.Shape_Extruder_Pipe_Large.get(0), + ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Large"+output, 1), + 2*20, eut); + + GT_Values.RA.addExtruderRecipe( + ItemUtils.getSimpleStack(pipeIngot, 12), + ItemList.Shape_Extruder_Pipe_Huge.get(0), + ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Huge"+output, 1), + 4*20, eut); + + } + + if ((eut < 512) && !output.equals("Void")){ + try { + final ItemStack pipePlateDouble = ItemUtils.getItemStackOfAmountFromOreDict("plateDouble"+output, 1).copy(); + if (pipePlateDouble != null) { + RecipeUtils.addShapedRecipe( + pipePlateDouble, "craftingToolHardHammer", pipePlateDouble, + pipePlateDouble, null, pipePlateDouble, + pipePlateDouble, "craftingToolWrench", pipePlateDouble, + ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Huge"+output, 1)); + } else { + Logger.INFO("Failed to add a recipe for "+materialName+" Huge pipes. Double plates probably do not exist."); + } + } + catch (Throwable t) { + t.printStackTrace(); + } + } + + + } + + public static boolean registerOre(OrePrefixes aPrefix, Material aMaterial, ItemStack aStack) { + return registerOre(aPrefix.get(Utils.sanitizeString(aMaterial.getLocalizedName())), aStack); + } + + public static boolean registerOre(Object aName, ItemStack aStack) { + if ((aName == null) || (GT_Utility.isStackInvalid(aStack))) + return false; + String tName = aName.toString(); + if (GT_Utility.isStringInvalid(tName)) + return false; + ArrayList<ItemStack> tList = GT_OreDictUnificator.getOres(tName); + for (int i = 0; i < tList.size(); ++i) + if (GT_Utility.areStacksEqual((ItemStack) tList.get(i), aStack, true)) + return false; + OreDictionary.registerOre(tName, GT_Utility.copyAmount(1L, new Object[] { aStack })); + return true; + } + + public static boolean generateWireRecipes(Material aMaterial){ + + //Adds manual crafting recipe + RecipeUtils.addShapedRecipe( + Utils.sanitizeString("plate"+aMaterial.getLocalizedName()), CI.craftingToolWireCutter, null, + null, null, null, + null, null, null, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1)); + + //Wire mill + GT_Values.RA.addWiremillRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("ingot"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 2), + 5*20, + 4); + + //Extruder + GT_Values.RA.addExtruderRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("ingot"+aMaterial.getLocalizedName()), 1), + ItemList.Shape_Extruder_Wire.get(0), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 2), + 196, + 96); + + GT_Values.RA.addUnboxingRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("cableGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + null, + 100, + 8); + + //Shapeless Down-Crafting + //2x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt02"+aMaterial.getLocalizedName()), 1)}, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 2) + ); + //4x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt04"+aMaterial.getLocalizedName()), 1)}, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 4) + ); + //8x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt08"+aMaterial.getLocalizedName()), 1)}, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 8) + ); + //12x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt12"+aMaterial.getLocalizedName()), 1)}, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 12) + ); + //16x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt16"+aMaterial.getLocalizedName()), 1)}, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 16) + ); + + + //1x -> 2x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1) + }, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt02"+aMaterial.getLocalizedName()), 1) + ); + + //2x -> 4x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt02"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt02"+aMaterial.getLocalizedName()), 1) + }, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt04"+aMaterial.getLocalizedName()), 1) + ); + + //4x -> 8x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt04"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt04"+aMaterial.getLocalizedName()), 1) + }, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt08"+aMaterial.getLocalizedName()), 1) + ); + + //8x -> 12x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt04"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt08"+aMaterial.getLocalizedName()), 1) + }, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt12"+aMaterial.getLocalizedName()), 1) + ); + + //12x -> 16x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt04"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt12"+aMaterial.getLocalizedName()), 1) + }, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt16"+aMaterial.getLocalizedName()), 1) + ); + + //8x -> 16x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt08"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt08"+aMaterial.getLocalizedName()), 1) + }, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt16"+aMaterial.getLocalizedName()), 1) + ); + + //1x -> 4x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1) + }, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt04"+aMaterial.getLocalizedName()), 1) + ); + + //1x -> 8x + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1) + }, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt08"+aMaterial.getLocalizedName()), 1) + ); + + + //Wire to Cable + //1x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 1), + CI.getNumberedCircuit(24), + FluidUtils.getFluidStack("molten.rubber", 144), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("cableGt01"+aMaterial.getLocalizedName()), 1), + 100, + 8); + //2x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt02"+aMaterial.getLocalizedName()), 1), + CI.getNumberedCircuit(24), + FluidUtils.getFluidStack("molten.rubber", 144), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("cableGt02"+aMaterial.getLocalizedName()), 1), + 100, + 8); + //4x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt04"+aMaterial.getLocalizedName()), 1), + CI.getNumberedCircuit(24), + FluidUtils.getFluidStack("molten.rubber", 288), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("cableGt04"+aMaterial.getLocalizedName()), 1), + 100, + 8); + //8x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt08"+aMaterial.getLocalizedName()), 1), + CI.getNumberedCircuit(24), + FluidUtils.getFluidStack("molten.rubber", 432), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("cableGt08"+aMaterial.getLocalizedName()), 1), + 100, + 8); + //12x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt12"+aMaterial.getLocalizedName()), 1), + CI.getNumberedCircuit(24), + FluidUtils.getFluidStack("molten.rubber", 576), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("cableGt12"+aMaterial.getLocalizedName()), 1), + 100, + 8); + + if(GTNH){ + //16x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt16"+aMaterial.getLocalizedName()), 1), + CI.getNumberedCircuit(24), + FluidUtils.getFluidStack("molten.rubber", 720), + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("cableGt16"+aMaterial.getLocalizedName()), 1), + 100, + 8); + } + + //Assemble small wires into bigger wires + + //2x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 2), + CI.getNumberedCircuit(2), + null, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt02"+aMaterial.getLocalizedName()), 1), + 100, + 8); + + //4x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 2), + CI.getNumberedCircuit(4), + null, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt04"+aMaterial.getLocalizedName()), 1), + 100, + 8); + + //8x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 2), + CI.getNumberedCircuit(8), + null, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt08"+aMaterial.getLocalizedName()), 1), + 100, + 8); + + //12x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 2), + CI.getNumberedCircuit(12), + null, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt12"+aMaterial.getLocalizedName()), 1), + 100, + 8); + + //16x + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt01"+aMaterial.getLocalizedName()), 2), + CI.getNumberedCircuit(16), + null, + ItemUtils.getItemStackOfAmountFromOreDict(Utils.sanitizeString("wireGt16"+aMaterial.getLocalizedName()), 1), + 100, + 8); + + return true; + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java new file mode 100644 index 0000000000..64e77393bd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java @@ -0,0 +1,217 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.*; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GT_MetaTileEntity_Hatch_CustomFluidBase; + +import java.lang.reflect.Constructor; + +public class GregtechCustomHatches { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Custom Fluid Hatches."); + run1(); + if (PollutionUtils.isPollutionEnabled()) { + run2(); + } + run3(); + run4(); + } + } + + private static void run1() { + + GregtechItemList.Hatch_Input_Cryotheum + .set(new GT_MetaTileEntity_Hatch_CustomFluidBase(FluidUtils.getFluidStack("cryotheum", 1).getFluid(), // Fluid + // to + // resitrct + // hatch + // to + 128000, // Capacity + 967, // ID + "hatch.cryotheum.input.tier.00", // unlocal name + "Cryotheum Cooling Hatch" // Local name + ).getStackForm(1L)); + + GregtechItemList.Hatch_Input_Pyrotheum + .set(new GT_MetaTileEntity_Hatch_CustomFluidBase(FluidUtils.getFluidStack("pyrotheum", 1).getFluid(), // Fluid + // to + // resitrct + // hatch + // to + 128000, // Capacity + 968, // ID + "hatch.pyrotheum.input.tier.00", // unlocal name + "Pyrotheum Heating Vent" // Local name + ).getStackForm(1L)); + + GregtechItemList.Hatch_Input_Naquadah.set(new GT_MetaTileEntity_Hatch_Naquadah(969, // ID + "hatch.naquadah.input.tier.00", // unlocal name + "Naquadah Reactor Input hatch" // Local name + ).getStackForm(1L)); + + + GregtechItemList.Hatch_Input_TurbineHousing.set(new GT_MetaTileEntity_Hatch_TurbineProvider(31025, // ID + "hatch.turbine.input.tier.00", // unlocal name + "Turbine Housing", // Local name + 8 + ).getStackForm(1L)); + + // Multiblock Control Core Bus + GregtechItemList.Hatch_Control_Core.set((new GT_MetaTileEntity_Hatch_ControlCore(30020, "hatch.control.adv", "Control Core Module", 1)).getStackForm(1L)); + + // Multiblock Air Intake Hatch + GregtechItemList.Hatch_Air_Intake.set(new GT_MetaTileEntity_Hatch_AirIntake(861, "hatch.air.intake.tier.00", "Air Intake Hatch", 5).getStackForm(1L)); + + // Steam Hatch + GregtechItemList.Hatch_Input_Steam + .set(new GT_MetaTileEntity_Hatch_CustomFluidBase(FluidUtils.getSteam(1).getFluid(), // Fluid + // to + // resitrct + // hatch + // to + 64000, // Capacity + 31040, // ID + "hatch.steam.input.tier.00", // unlocal name + "Steam Hatch" // Local name + ).getStackForm(1L)); + + + + + + } + + private static void run2() { + GregtechItemList.Hatch_Muffler_Adv_LV + .set((new GT_MetaTileEntity_Hatch_Muffler_Adv(30001, "hatch.muffler.adv.tier.01", "Advanced Muffler Hatch (LV)", 1)) + .getStackForm(1L)); + GregtechItemList.Hatch_Muffler_Adv_MV + .set((new GT_MetaTileEntity_Hatch_Muffler_Adv(30002, "hatch.muffler.adv.tier.02", "Advanced Muffler Hatch (MV)", 2)) + .getStackForm(1L)); + GregtechItemList.Hatch_Muffler_Adv_HV + .set((new GT_MetaTileEntity_Hatch_Muffler_Adv(30003, "hatch.muffler.adv.tier.03", "Advanced Muffler Hatch (HV)", 3)) + .getStackForm(1L)); + GregtechItemList.Hatch_Muffler_Adv_EV + .set((new GT_MetaTileEntity_Hatch_Muffler_Adv(30004, "hatch.muffler.adv.tier.04", "Advanced Muffler Hatch (EV)", 4)) + .getStackForm(1L)); + GregtechItemList.Hatch_Muffler_Adv_IV + .set((new GT_MetaTileEntity_Hatch_Muffler_Adv(30005, "hatch.muffler.adv.tier.05", "Advanced Muffler Hatch (IV)", 5)) + .getStackForm(1L)); + GregtechItemList.Hatch_Muffler_Adv_LuV + .set((new GT_MetaTileEntity_Hatch_Muffler_Adv(30006, "hatch.muffler.adv.tier.06", "Advanced Muffler Hatch (LuV)", 6)) + .getStackForm(1L)); + GregtechItemList.Hatch_Muffler_Adv_ZPM + .set((new GT_MetaTileEntity_Hatch_Muffler_Adv(30007, "hatch.muffler.adv.tier.07", "Advanced Muffler Hatch (ZPM)", 7)) + .getStackForm(1L)); + GregtechItemList.Hatch_Muffler_Adv_UV + .set((new GT_MetaTileEntity_Hatch_Muffler_Adv(30008, "hatch.muffler.adv.tier.08", "Advanced Muffler Hatch (UV)", 8)) + .getStackForm(1L)); + GregtechItemList.Hatch_Muffler_Adv_MAX + .set((new GT_MetaTileEntity_Hatch_Muffler_Adv(30009, "hatch.muffler.adv.tier.09", "Advanced Muffler Hatch (MAX)", 9)) + .getStackForm(1L)); + } + + private static void run3() { + /* + * Super Input Busses + */ + + int aStartID = 30021; + + GregtechItemList.Hatch_SuperBus_Input_ULV + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.00", "Super Bus (I) (ULV)", 0)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Input_LV + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.01", "Super Bus (I) (LV)", 1)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Input_MV + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.02", "Super Bus (I) (MV)", 2)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Input_HV + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.03", "Super Bus (I) (HV)", 3)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Input_EV + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.04", "Super Bus (I) (EV)", 4)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Input_IV + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.05", "Super Bus (I) (IV)", 5)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Input_LuV + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.06", "Super Bus (I) (LuV)", 6)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Input_ZPM + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.07", "Super Bus (I) (ZPM)", 7)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Input_UV + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.08", "Super Bus (I) (UV)", 8)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Input_MAX + .set(((IMetaTileEntity) makeInputBus(aStartID++, "hatch.superbus.input.tier.09", "Super Bus (I) (MAX)", 9)) + .getStackForm(1L)); + + /* + * Super Output Busses + */ + + GregtechItemList.Hatch_SuperBus_Output_ULV + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.00", "Super Bus (O) (ULV)", 0)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Output_LV + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.01", "Super Bus (O) (LV)", 1)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Output_MV + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.02", "Super Bus (O) (MV)", 2)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Output_HV + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.03", "Super Bus (O) (HV)", 3)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Output_EV + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.04", "Super Bus (O) (EV)", 4)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Output_IV + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.05", "Super Bus (O) (IV)", 5)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Output_LuV + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.06", "Super Bus (O) (LuV)", 6)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Output_ZPM + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.07", "Super Bus (O) (ZPM)", 7)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Output_UV + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.08", "Super Bus (O) (UV)", 8)) + .getStackForm(1L)); + GregtechItemList.Hatch_SuperBus_Output_MAX + .set(((IMetaTileEntity) makeOutputBus(aStartID++, "hatch.superbus.output.tier.09", "Super Bus (O) (MAX)", 9)) + .getStackForm(1L)); + } + + private static GT_MetaTileEntity_SuperBus_Input makeInputBus(int id, String unlocalizedName, String localizedName, int tier) { + return new GT_MetaTileEntity_SuperBus_Input(id, unlocalizedName, localizedName, tier); + } + + private static GT_MetaTileEntity_SuperBus_Output makeOutputBus(int id, String unlocalizedName, String localizedName, int tier) { + return new GT_MetaTileEntity_SuperBus_Output(id, unlocalizedName, localizedName, tier); + } + + private static void run4() { + int aID = 31060; + //41, "hatch.energy.tier.01", "LV Energy Hatch", 1 + Constructor aRTG = ReflectionUtils.getConstructor(GT_MetaTileEntity_Hatch_Energy_RTG.class, new Class[]{int.class, String.class, String.class, int.class, int.class}); + Object aHatch1 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[]{aID++, "hatch.energy.rtg.tier.01", "RTG Power Unit [LV]", 1, 9}); + Object aHatch2 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[]{aID++, "hatch.energy.rtg.tier.02", "RTG Power Unit [MV]", 2, 9}); + Object aHatch3 = ReflectionUtils.createNewInstanceFromConstructor(aRTG, new Object[]{aID++, "hatch.energy.rtg.tier.03", "RTG Power Unit [HV]", 3, 9}); + + GregtechItemList.Hatch_RTG_LV.set(((IMetaTileEntity) aHatch1).getStackForm(1L)); + GregtechItemList.Hatch_RTG_MV.set(((IMetaTileEntity) aHatch2).getStackForm(1L)); + GregtechItemList.Hatch_RTG_HV.set(((IMetaTileEntity) aHatch3).getStackForm(1L)); + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCyclotron.java new file mode 100644 index 0000000000..e095ed4cbe --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCyclotron.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_Cyclotron; + +public class GregtechCyclotron { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering COMET Cyclotron."); + run1(); + } + } + + private static void run1() { + GregtechItemList.COMET_Cyclotron + .set(new GregtechMetaTileEntity_Cyclotron(828, "cyclotron.tier.single", "COMET - Compact Cyclotron", 6) + .getStackForm(1L)); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java new file mode 100644 index 0000000000..a8b5aea0e6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java @@ -0,0 +1,193 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Dehydrator; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialDehydrator; +import net.minecraft.item.ItemStack; + +public class GregtechDehydrator { + public static void run() { + if (LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Chemical Dehydrators."); + if (CORE.ConfigSwitches.enableMachine_Dehydrators) { + run1(); + } + } + + } + + private static void run1() { + + /* + * + * public GT_MetaTileEntity_BasicMachine_GT_Recipe( int aID, String + * aName, String aNameRegional, int aTier, String aDescription, + * GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int + * aTankCapacity, int aGUIParameterA, int aGUIParameterB, String + * aGUIName, String aSound, boolean aSharedTank, boolean + * aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, + * Object[] aRecipe) { + * + */ + + //Basic + GregtechItemList.GT_Dehydrator_MV + .set(new GT_MetaTileEntity_Dehydrator( + 911, + "machine.dehydrator.tier.00", + "Basic Dehydrator I", + 2, + "This dehydrates your Grapes into Raisins.", + 16000) + .getStackForm(1L)); + + GregtechItemList.GT_Dehydrator_HV + .set(new GT_MetaTileEntity_Dehydrator( + 912, + "machine.dehydrator.tier.01", + "Basic Dehydrator II", + 3, + "This dehydrates your Grapes into Raisins.", + 32000) + .getStackForm(1L)); + + + //Chemical + + GregtechItemList.GT_Dehydrator_EV + .set(new GT_MetaTileEntity_Dehydrator( + 813, + "advancedmachine.dehydrator.tier.01", + "Chemical Dehydrator I", + 4, + "A hangover is the way your body reacts to dehydration.", + 48000) + .getStackForm(1L)); + + GregtechItemList.GT_Dehydrator_IV + .set(new GT_MetaTileEntity_Dehydrator( + 814, + "advancedmachine.dehydrator.tier.02", + "Chemical Dehydrator II", + 5, + "A hangover is the way your body reacts to dehydration.", + 48000) + .getStackForm(1L)); + + GregtechItemList.GT_Dehydrator_LuV + .set(new GT_MetaTileEntity_Dehydrator( + 815, + "advancedmachine.dehydrator.tier.03", + "Chemical Dehydrator III", + 6, + "You could probably make space icecream with this..", + 64000) + .getStackForm(1L)); + + GregtechItemList.GT_Dehydrator_ZPM + .set(new GT_MetaTileEntity_Dehydrator( + 816, + "advancedmachine.dehydrator.tier.04", + "Chemical Dehydrator IV", + 7, + "You can definitely make space icecream with this..", + 64000) + .getStackForm(1L)); + + //Advanced + GregtechItemList.Controller_Vacuum_Furnace.set(new GregtechMetaTileEntity_IndustrialDehydrator(995, "multimachine.adv.vacuumfurnace", "Utupu-Tanuri").getStackForm(1L)); + + + ItemStack coilWire1 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire", "coilWire1", 0, + 4); + ItemStack coilWire2 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:1", "coilWire2", 1, + 4); + ItemStack coilWire3 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:2", "coilWire3", 2, + 4); + ItemStack coilWire4 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:3", "coilWire4", 3, + 4); + ItemStack coilT1 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoil", "coil1", 0, 1); + ItemStack coilT2 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoil:1", "coil2", 1, 1); + ItemStack coilT3 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoil:2", "coil3", 2, 1); + ItemStack coilT4 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoil:3", "coil4", 3, 1); + ItemStack spoolT1 = ItemUtils.getItemStackOfAmountFromOreDict("pipeMediumBronze", 1); + ItemStack spoolT2 = ItemUtils.getItemStackOfAmountFromOreDict("pipeMediumSteel", 1); + ItemStack spoolT3 = ItemUtils.getItemStackOfAmountFromOreDict("pipeMediumStainlessSteel", 1); + ItemStack spoolT4 = ItemUtils.getItemStackOfAmountFromOreDict("pipeMediumTitanium", 1); + + // Make some coils by wrapping wire around a spool. + GT_Values.RA.addAssemblerRecipe(coilWire1, spoolT1, coilT1, 8 * 20, 120); + GT_Values.RA.addAssemblerRecipe(coilWire2, spoolT2, coilT2, 8 * 20, 240); + GT_Values.RA.addAssemblerRecipe(coilWire3, spoolT3, coilT3, 8 * 20, 480); + GT_Values.RA.addAssemblerRecipe(coilWire4, spoolT4, coilT4, 8 * 20, 960); + + // Add recipes for the Dehydrators. + + //Basic + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Dehydrator_MV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('P'), + ItemList.Robot_Arm_MV, Character.valueOf('E'), OrePrefixes.wireFine.get(Materials.RedAlloy), Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), + OrePrefixes.cableGt04.get(Materials.Copper), Character.valueOf('G'), + OrePrefixes.gearGt.get(Materials.Steel) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Dehydrator_HV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('P'), + ItemList.Robot_Arm_HV, Character.valueOf('E'), OrePrefixes.wireFine.get(Materials.Electrum), Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), + OrePrefixes.cableGt04.get(Materials.Silver), Character.valueOf('G'), + ALLOY.POTIN.getGear(1) }); + + //Chemical + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Dehydrator_EV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('P'), + ItemList.Robot_Arm_EV, Character.valueOf('E'), coilT1, Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Data), Character.valueOf('W'), + OrePrefixes.cableGt04.get(Materials.Aluminium), Character.valueOf('G'), + ALLOY.TUMBAGA.getGear(1) }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Dehydrator_IV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('P'), + ItemList.Robot_Arm_IV, Character.valueOf('E'), coilT2, Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('W'), + OrePrefixes.cableGt04.get(Materials.Tungsten), Character.valueOf('G'), + ALLOY.INCONEL_690.getGear(1) }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Dehydrator_LuV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('P'), + CI.robotArm_LuV, Character.valueOf('E'), coilT3, Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Master), Character.valueOf('W'), + OrePrefixes.cableGt04.get(Materials.Naquadah), Character.valueOf('G'), + ALLOY.HASTELLOY_N.getGear(1) }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Dehydrator_ZPM.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_ZPM, Character.valueOf('P'), + CI.robotArm_ZPM, Character.valueOf('E'), coilT4, Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Ultimate), Character.valueOf('W'), + OrePrefixes.cableGt04.get(Materials.Osmium), Character.valueOf('G'), + ALLOY.ZERON_100.getGear(1) }); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java new file mode 100644 index 0000000000..e82fade029 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java @@ -0,0 +1,94 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOreDictNames; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GT_MetaTileEntity_RfConvertor; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.creative.GregtechMetaCreativeEnergyBuffer; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaEnergyBuffer; + +public class GregtechEnergyBuffer +{ + + //Misc Items + //public static Item itemBufferCore; + + public static void run() + { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech){ + Logger.INFO("Gregtech5u Content | Registering Energy Buffer Blocks."); + run1(); + } + } + + private static void run1() + { + + //itemBufferCore = new Item().setUnlocalizedName("itemBufferCore").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemBufferCore"); + + //Registry + //GameRegistry.registerItem(itemBufferCore, "itemBufferCore"); + //LanguageRegistry.addName(itemBufferCore, "Buffer Core"); + //OreDictionary.registerOre("itemBufferCore", itemBufferCore); + + + //Energy Buffers + GregtechItemList.Energy_Buffer_1by1_ULV.set(new GregtechMetaEnergyBuffer(770, "energybuffer.tier.00", "Ultra Low Voltage Energy Buffer", 0, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_LV.set(new GregtechMetaEnergyBuffer(771, "energybuffer.tier.01", "Low Voltage Energy Buffer", 1, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_MV.set(new GregtechMetaEnergyBuffer(772, "energybuffer.tier.02", "Medium Voltage Energy Buffer", 2, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_HV.set(new GregtechMetaEnergyBuffer(773, "energybuffer.tier.03", "High Voltage Energy Buffer", 3, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_EV.set(new GregtechMetaEnergyBuffer(774, "energybuffer.tier.04", "Extreme Voltage Energy Buffer", 4, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_IV.set(new GregtechMetaEnergyBuffer(775, "energybuffer.tier.05", "Insane Voltage Energy Buffer", 5, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_LuV.set(new GregtechMetaEnergyBuffer(776, "energybuffer.tier.06", "Ludicrous Voltage Energy Buffer", 6, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_ZPM.set(new GregtechMetaEnergyBuffer(777, "energybuffer.tier.07", "ZPM Voltage Energy Buffer", 7, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_UV.set(new GregtechMetaEnergyBuffer(778, "energybuffer.tier.08", "Ultimate Voltage Energy Buffer", 8, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_MAX.set(new GregtechMetaEnergyBuffer(779, "energybuffer.tier.09", "MAX Voltage Energy Buffer", 9, "", 1).getStackForm(1L)); + // Creative Buffer Has Special ID + GregtechItemList.Energy_Buffer_CREATIVE + .set(new GregtechMetaCreativeEnergyBuffer(750, + "energybuffer.tier.xx", + "512V Creative Energy Buffer", 3, "", 0) + .getStackForm(1L)); + + if (LoadedMods.CoFHCore && CORE.ConfigSwitches.enableMachine_RF_Convetor) { + // RF Convertor Buffer Has Special ID + GregtechItemList.Energy_Buffer_RF_Convertor + .set(new GT_MetaTileEntity_RfConvertor(31022, + "energybuffer.rf.tier.01", + "RF Energy Convertor", 3, "", 0) + .getStackForm(1L)); + } + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_ULV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_ULV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Lead), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_LV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_LV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Tin), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_MV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.AnyCopper), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_HV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Gold), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_EV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Aluminium), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_IV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Tungsten), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_LuV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Osmium), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_ZPM.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_ZPM, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Osmium), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_UV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_UV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Osmium), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_MAX.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_MAX, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Superconductor), Character.valueOf('T'), GregtechOreDictNames.buffer_core }); + /*GT_ModHandler.addCraftingRecipe( + GregtechItemList.Energy_Buffer_1by1_MAX.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE + | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE + | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { + "WTW", "WMW", Character.valueOf('M'), + ItemList.Hull_MAX, Character.valueOf('W'), + OrePrefixes.wireGt08.get(Materials.Superconductor), + Character.valueOf('T'), GregtechOreDictNames.buffer_core });*/ + + + + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechFactoryGradeReplacementMultis.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechFactoryGradeReplacementMultis.java new file mode 100644 index 0000000000..8340b7088c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechFactoryGradeReplacementMultis.java @@ -0,0 +1,35 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialVacuumFreezer; +//import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced.GregtechMetaTileEntity_Adv_AssemblyLine; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced.GregtechMetaTileEntity_Adv_DistillationTower; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced.GregtechMetaTileEntity_Adv_EBF; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced.GregtechMetaTileEntity_Adv_Fusion_MK4; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced.GregtechMetaTileEntity_Adv_Implosion; + +public class GregtechFactoryGradeReplacementMultis { + + public static void run() { + run1(); + } + + private static void run1() { + Logger.INFO("Gregtech 5 Content | Registering Advanced GT Multiblock replacements."); + GregtechItemList.Machine_Adv_BlastFurnace.set(new GregtechMetaTileEntity_Adv_EBF(963, "multimachine.adv.blastfurnace", "Volcanus").getStackForm(1L)); + GregtechItemList.Machine_Adv_ImplosionCompressor.set(new GregtechMetaTileEntity_Adv_Implosion(964, "multimachine.adv.implosioncompressor", "Density^2").getStackForm(1L)); + GregtechItemList.Industrial_Cryogenic_Freezer.set(new GregtechMetaTileEntity_IndustrialVacuumFreezer(910, "multimachine.adv.industrialfreezer", "Cryogenic Freezer").getStackForm(1L)); + GregtechItemList.FusionComputer_UV2.set(new GregtechMetaTileEntity_Adv_Fusion_MK4(965, "fusioncomputer.tier.09", "FusionTech MK IV").getStackForm(1L)); + + + //31021 + GregtechItemList.Machine_Adv_DistillationTower.set(new GregtechMetaTileEntity_Adv_DistillationTower(31021, "multimachine.adv.distillationtower", "Dangote Distillus").getStackForm(1L)); + /*if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + GregtechItemList.Machine_Adv_AssemblyLine.set(new GregtechMetaTileEntity_Adv_AssemblyLine(31024, "multimachine.adv.assemblyline", "Compound Fabricator").getStackForm(1L)); + }*/ + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechFluidReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechFluidReactor.java new file mode 100644 index 0000000000..86146640fd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechFluidReactor.java @@ -0,0 +1,25 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_ChemicalReactor; + +public class GregtechFluidReactor { + + public static void run() { + + /* + * GregtechItemList.FluidReactor_LV .set(new + * GregtechMetaTileEntity_ChemicalReactor(31021, "chemicalplant.01.tier.01", + * "Chemical Plant I", 1) .getStackForm(1L)); GregtechItemList.FluidReactor_HV + * .set(new GregtechMetaTileEntity_ChemicalReactor(31022, + * "chemicalplant.01.tier.02", "Chemical Plant II", 3) .getStackForm(1L)); + * GregtechItemList.FluidReactor_IV .set(new + * GregtechMetaTileEntity_ChemicalReactor(31023, "chemicalplant.01.tier.03", + * "Chemical Plant III", 5) .getStackForm(1L)); + * GregtechItemList.FluidReactor_ZPM .set(new + * GregtechMetaTileEntity_ChemicalReactor(31024, "chemicalplant.01.tier.04", + * "Chemical Plant IV", 7) .getStackForm(1L)); + */ + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeneratorsULV b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeneratorsULV new file mode 100644 index 0000000000..d063d85b1f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeneratorsULV @@ -0,0 +1,15 @@ + + +public class GregtechGeneratorsULV { + public static void run(){ + + GregtechItemList.Generator_Diesel_ULV.set(new GT_MetaTileEntity_ULV_CombustionGenerator(960, "basicgenerator.diesel.tier.00", "Simple Combustion Generator", 0).getStackForm(1L)); + GregtechItemList.Generator_Gas_Turbine_ULV.set(new GT_MetaTileEntity_ULV_GasTurbine(961, "basicgenerator.gas.tier.00", "Simple Gas Turbine", 0).getStackForm(1L)); + GregtechItemList.Generator_Steam_Turbine_ULV.set(new GT_MetaTileEntity_ULV_SteamTurbine(962, "basicgenerator.steam.tier.00", "Simple Steam Turbine", 0).getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Generator_Diesel_ULV.get(1L, new Object[0]), bitsd, new Object[]{"PCP", "EME", "GWG", 'M', ItemList.Hull_ULV, 'P', GregtechItemList.Electric_Piston_ULV, 'E', GregtechItemList.Electric_Motor_ULV, 'C', OrePrefixes.circuit.get(Materials.Primitive), 'W', OrePrefixes.cableGt01.get(Materials.RedAlloy), 'G', OrePrefixes.gearGt.get(Materials.Bronze)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Generator_Gas_Turbine_ULV.get(1L, new Object[0]), bitsd, new Object[]{"CRC", "RMR", aTextMotorWire, 'M', ItemList.Hull_ULV, 'E', GregtechItemList.Electric_Motor_ULV, 'R', OrePrefixes.rotor.get(Materials.Tin), 'C', OrePrefixes.circuit.get(Materials.Primitive), 'W', OrePrefixes.cableGt01.get(Materials.RedAlloy)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Generator_Steam_Turbine_ULV.get(1L, new Object[0]), bitsd, new Object[]{"PCP", "RMR", aTextMotorWire, 'M', ItemList.Hull_ULV, 'E', GregtechItemList.Electric_Motor_ULV, 'R', OrePrefixes.rotor.get(Materials.Tin), 'C', OrePrefixes.circuit.get(Materials.Primitive), 'W', OrePrefixes.cableGt01.get(Materials.RedAlloy), 'P', OrePrefixes.pipeMedium.get(Materials.Copper)}); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeneratorsULV.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeneratorsULV.java new file mode 100644 index 0000000000..1663c9ada4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeneratorsULV.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.ULV.GT_MetaTileEntity_ULV_CombustionGenerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.ULV.GT_MetaTileEntity_ULV_GasTurbine; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.ULV.GT_MetaTileEntity_ULV_SteamTurbine; + +import static gtPlusPlus.core.recipe.common.CI.bitsd; + +public class GregtechGeneratorsULV { + public static void run(){ + + GregtechItemList.Generator_Diesel_ULV.set(new GT_MetaTileEntity_ULV_CombustionGenerator(960, "basicgenerator.diesel.tier.00", "Simple Combustion Generator", 0).getStackForm(1L)); + GregtechItemList.Generator_Gas_Turbine_ULV.set(new GT_MetaTileEntity_ULV_GasTurbine(961, "basicgenerator.gas.tier.00", "Simple Gas Turbine", 0).getStackForm(1L)); + GregtechItemList.Generator_Steam_Turbine_ULV.set(new GT_MetaTileEntity_ULV_SteamTurbine(962, "basicgenerator.steam.tier.00", "Simple Steam Turbine", 0).getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Generator_Diesel_ULV.get(1L, new Object[0]), bitsd, new Object[]{"PCP", "EME", "GWG", 'M', ItemList.Hull_ULV, 'P', GregtechItemList.Electric_Piston_ULV, 'E', GregtechItemList.Electric_Motor_ULV, 'C', OrePrefixes.circuit.get(Materials.Primitive), 'W', OrePrefixes.cableGt01.get(Materials.RedAlloy), 'G', OrePrefixes.gearGt.get(Materials.Bronze)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Generator_Gas_Turbine_ULV.get(1L, new Object[0]), bitsd, new Object[]{"CRC", "RMR", "EWE", 'M', ItemList.Hull_ULV, 'E', GregtechItemList.Electric_Motor_ULV, 'R', OrePrefixes.rotor.get(Materials.Tin), 'C', OrePrefixes.circuit.get(Materials.Primitive), 'W', OrePrefixes.cableGt01.get(Materials.RedAlloy)}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Generator_Steam_Turbine_ULV.get(1L, new Object[0]), bitsd, new Object[]{"PCP", "RMR", "EWE", 'M', ItemList.Hull_ULV, 'E', GregtechItemList.Electric_Motor_ULV, 'R', OrePrefixes.rotor.get(Materials.Tin), 'C', OrePrefixes.circuit.get(Materials.Primitive), 'W', OrePrefixes.cableGt01.get(Materials.RedAlloy), 'P', OrePrefixes.pipeMedium.get(Materials.Copper)}); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeothermalThermalGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeothermalThermalGenerator.java new file mode 100644 index 0000000000..2e7e96dd2f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechGeothermalThermalGenerator.java @@ -0,0 +1,68 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntityGeothermalGenerator; + +public class GregtechGeothermalThermalGenerator { + + public static void run() { + if (LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Geothermal Engines."); + if (CORE.ConfigSwitches.enableMachine_GeothermalEngines) { + run1(); + } + } + + } + + private static void run1() { + GregtechItemList.Geothermal_Engine_EV.set(new GregtechMetaTileEntityGeothermalGenerator(830, + "advancedgenerator.geothermalFuel.tier.01", "Basic Geothermal Engine", 4).getStackForm(1L)); + GregtechItemList.Geothermal_Engine_IV.set(new GregtechMetaTileEntityGeothermalGenerator(831, + "advancedgenerator.geothermalFuel.tier.02", "Turbo Geothermal Engine", 5).getStackForm(1L)); + GregtechItemList.Geothermal_Engine_LuV.set(new GregtechMetaTileEntityGeothermalGenerator(832, + "advancedgenerator.geothermalFuel.tier.03", "Vulcan Geothermal Engine", 6).getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Geothermal_Engine_EV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CEC", "GMG", "PWP", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('P'), + ItemList.Electric_Piston_EV, Character.valueOf('E'), ItemList.Electric_Motor_EV, + Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Ultimate), Character.valueOf('W'), + OrePrefixes.cableGt04.get(Materials.Aluminium), Character.valueOf('G'), + ALLOY.TANTALLOY_61.getGear(1) }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Geothermal_Engine_IV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CEC", "GMG", "PWP", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('P'), + ItemList.Electric_Piston_IV, Character.valueOf('E'), ItemList.Electric_Motor_IV, + Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Superconductor), + Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Platinum), Character.valueOf('G'), + ALLOY.STELLITE.getGear(1) }); + + final ItemStack INGREDIENT_1 = CI.electricPiston_LuV; + final ItemStack INGREDIENT_2 = CI.electricMotor_LuV; + GT_ModHandler.addCraftingRecipe(GregtechItemList.Geothermal_Engine_LuV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CEC", "GMG", "PWP", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('P'), + INGREDIENT_1, Character.valueOf('E'), INGREDIENT_2, Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Infinite), Character.valueOf('W'), + OrePrefixes.cableGt04.get(Materials.Tungsten), Character.valueOf('G'), + ALLOY.ZERON_100.getGear(1) }); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java new file mode 100644 index 0000000000..a69c91e93b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java @@ -0,0 +1,158 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import static gtPlusPlus.core.lib.CORE.GTNH; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTransformerHiAmp; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.item.ItemStack; + +public class GregtechHiAmpTransformer { + + + public static void run(){ + + long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED; + int mID = 877; + + String mHammerName = "Hammer"; + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + mHammerName = "Mallet"; + } + + GregtechItemList.Transformer_HA_LV_ULV.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.00", + "ULV Hi-Amp Transformer", 0, "LV -> ULV (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + GregtechItemList.Transformer_HA_MV_LV.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.01", + "LV Hi-Amp Transformer", 1, "MV -> LV (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + GregtechItemList.Transformer_HA_HV_MV.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.02", + "MV Hi-Amp Transformer", 2, "HV -> MV (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + GregtechItemList.Transformer_HA_EV_HV.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.03", + "HV Hi-Amp Transformer", 3, "EV -> HV (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + GregtechItemList.Transformer_HA_IV_EV.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.04", + "EV Hi-Amp Transformer", 4, "IV -> EV (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + GregtechItemList.Transformer_HA_LuV_IV.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.05", + "IV Hi-Amp Transformer", 5, "LuV -> IV (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + GregtechItemList.Transformer_HA_ZPM_LuV.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.06", + "LuV Hi-Amp Transformer", 6, "ZPM -> LuV (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + GregtechItemList.Transformer_HA_UV_ZPM.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.07", + "ZPM Hi-Amp Transformer", 7, "UV -> ZPM (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + if (!GTNH) { + GregtechItemList.Transformer_HA_MAX_UV.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.08", + "UV Hi-Amp Transformer", 8, "Any Voltage -> UV (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + } else { + GregtechItemList.Transformer_HA_MAX_UV.set(new GregtechMetaTransformerHiAmp(mID++, "transformer.ha.tier.08", + "UV Hi-Amp Transformer", 8, "UHV -> UV (Use Soft "+mHammerName+" to invert)").getStackForm(1L)); + } + ItemStack mItem_1; + ItemStack mItem_2; + ItemStack mItem_3; + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + mItem_1 = ItemUtils.simpleMetaStack(ItemUtils.getSimpleStack(StaticFields59.getBlockCasings5()).getItem(), 3, 1); + mItem_2 = ItemUtils.simpleMetaStack(ItemUtils.getSimpleStack(StaticFields59.getBlockCasings5()).getItem(), 4, 1); + mItem_3 = ItemUtils.simpleMetaStack(ItemUtils.getSimpleStack(StaticFields59.getBlockCasings5()).getItem(), 5, 1); + } + else { + mItem_1 = ItemList.Circuit_Elite.get(1); + mItem_2 = ItemList.Circuit_Master.get(1); + mItem_3 = ItemList.Circuit_Ultimate.get(1); + } + + if(!GTNH){ + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_LV_ULV.get(1L, new Object[0]), bitsd, + new Object[] { " BB", "CM ", " BB", Character.valueOf('M'), ItemList.Hull_ULV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Tin), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Lead) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_MV_LV.get(1L, new Object[0]), bitsd, + new Object[] { " BB", "CM ", " BB", Character.valueOf('M'), ItemList.Hull_LV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Copper), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Tin) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_HV_MV.get(1L, new Object[0]), bitsd, + new Object[] { " BB", "CM ", " BB", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Gold), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.AnnealedCopper) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_EV_HV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Aluminium), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Gold), Character.valueOf('K'), + ItemList.Casing_Coil_Cupronickel }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_IV_EV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Tungsten), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Aluminium), Character.valueOf('K'), + ItemList.Casing_Coil_Kanthal }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_LuV_IV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.VanadiumGallium), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Tungsten), Character.valueOf('K'), + ItemList.Casing_Coil_Nichrome }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_ZPM_LuV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Naquadah), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.VanadiumGallium), Character.valueOf('K'), + mItem_1 }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_UV_ZPM.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Hull_ZPM, Character.valueOf('C'), + OrePrefixes.wireGt04.get(Materials.NaquadahAlloy), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Naquadah), Character.valueOf('K'), + mItem_2 }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_MAX_UV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Hull_UV, Character.valueOf('C'), + OrePrefixes.wireGt01.get(Materials.Superconductor), Character.valueOf('B'), + OrePrefixes.wireGt04.get(Materials.NaquadahAlloy), Character.valueOf('K'), + mItem_3 }); + }else{ + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_LV_ULV.get(1L, new Object[0]), bitsd, + new Object[] { " BB", "CM ", " BB", Character.valueOf('M'), ItemList.Transformer_LV_ULV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Tin), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Lead) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_MV_LV.get(1L, new Object[0]), bitsd, + new Object[] { " BB", "CM ", " BB", Character.valueOf('M'), ItemList.Transformer_MV_LV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.AnyCopper), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Tin) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_HV_MV.get(1L, new Object[0]), bitsd, + new Object[] { " BB", "CM ", " BB", Character.valueOf('M'), ItemList.Transformer_HV_MV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Gold), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.AnyCopper) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_EV_HV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Transformer_EV_HV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Aluminium), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Gold), Character.valueOf('K'), + ItemList.Casing_Coil_Cupronickel }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_IV_EV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Transformer_IV_EV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Tungsten), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Aluminium), Character.valueOf('K'), + ItemList.Casing_Coil_Kanthal }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_LuV_IV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Transformer_LuV_IV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.VanadiumGallium), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Tungsten), Character.valueOf('K'), + ItemList.Casing_Coil_Nichrome }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_ZPM_LuV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Transformer_ZPM_LuV, Character.valueOf('C'), + OrePrefixes.wireGt16.get(Materials.Naquadah), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.VanadiumGallium), Character.valueOf('K'), + mItem_1 }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_UV_ZPM.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Transformer_UV_ZPM, Character.valueOf('C'), + OrePrefixes.wireGt04.get(Materials.NaquadahAlloy), Character.valueOf('B'), + OrePrefixes.wireGt16.get(Materials.Naquadah), Character.valueOf('K'), + mItem_2 }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Transformer_HA_MAX_UV.get(1L, new Object[0]), bitsd, + new Object[] { "KBB", "CM ", "KBB", Character.valueOf('M'), ItemList.Transformer_MAX_UV, Character.valueOf('C'), + OrePrefixes.wireGt01.get(Materials.Superconductor), Character.valueOf('B'), + OrePrefixes.wireGt04.get(Materials.NaquadahAlloy), Character.valueOf('K'), + mItem_3 }); + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialAlloySmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialAlloySmelter.java new file mode 100644 index 0000000000..6587e3a253 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialAlloySmelter.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialAlloySmelter; + +public class GregtechIndustrialAlloySmelter { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Alloy Smelter Multiblock."); + run1(); + } + + } + + private static void run1() { + GregtechItemList.Industrial_AlloySmelter.set(new GregtechMetaTileEntity_IndustrialAlloySmelter(31023, + "industrialalloysmelter.controller.tier.single", "Zyngen").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialArcFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialArcFurnace.java new file mode 100644 index 0000000000..fb8f69e865 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialArcFurnace.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialArcFurnace; + +public class GregtechIndustrialArcFurnace { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Arc Furnace Multiblock."); + run1(); + } + + } + + private static void run1() { + // Industrial Arc Furnace Multiblock + GregtechItemList.Industrial_Arc_Furnace.set(new GregtechMetaTileEntity_IndustrialArcFurnace(862, "industrialarcfurnace.controller.tier.single", "High Current Industrial Arc Furnace").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialBlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialBlastSmelter.java new file mode 100644 index 0000000000..15c2d9b238 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialBlastSmelter.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_AlloyBlastSmelter; + +public class GregtechIndustrialBlastSmelter { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Alloy Blast Smelter Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_AlloyBlastSmelter) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Alloy Blast Smelter Multiblock + GregtechItemList.Industrial_AlloyBlastSmelter.set(new GregtechMetaTileEntity_AlloyBlastSmelter(810, + "industrialsalloyamelter.controller.tier.single", "Alloy Blast Smelter").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCentrifuge.java new file mode 100644 index 0000000000..dfbe7304ef --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCentrifuge.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialCentrifuge; + +public class GregtechIndustrialCentrifuge { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Centrifuge Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialCentrifuge) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Centrifuge Multiblock + GregtechItemList.Industrial_Centrifuge.set(new GregtechMetaTileEntity_IndustrialCentrifuge(790, + "industrialcentrifuge.controller.tier.single", "Industrial Centrifuge").getStackForm(1L)); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCokeOven.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCokeOven.java new file mode 100644 index 0000000000..7afc73709a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCokeOven.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialCokeOven; + +public class GregtechIndustrialCokeOven { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Coke Oven Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialCokeOven) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Centrifuge Multiblock + GregtechItemList.Industrial_CokeOven.set(new GregtechMetaTileEntity_IndustrialCokeOven(791, + "industrialcokeoven.controller.tier.single", "Industrial Coke Oven").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCuttingFactory.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCuttingFactory.java new file mode 100644 index 0000000000..f6133f6bf3 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCuttingFactory.java @@ -0,0 +1,25 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialCuttingMachine; + +public class GregtechIndustrialCuttingFactory { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Cutting Factory Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialCuttingMachine) { + run1(); + } + } + } + + private static void run1() { + // Industrial Wire Factory Multiblock + GregtechItemList.Industrial_CuttingFactoryController.set(new GregtechMetaTileEntity_IndustrialCuttingMachine(992, + "industrialcuttingmachine.controller.tier.01", "Cutting Factory Controller").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElectrolyzer.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElectrolyzer.java new file mode 100644 index 0000000000..10d7510625 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElectrolyzer.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialElectrolyzer; + +public class GregtechIndustrialElectrolyzer { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Electrolyzer Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialElectrolyzer) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Electrolyzer Multiblock + GregtechItemList.Industrial_Electrolyzer.set(new GregtechMetaTileEntity_IndustrialElectrolyzer(796, + "industrialelectrolyzer.controller.tier.single", "Industrial Electrolyzer").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java new file mode 100644 index 0000000000..9e940dff26 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialElementDuplicator.java @@ -0,0 +1,20 @@ +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.GT_MetaTileEntity_Hatch_ElementalDataOrbHolder; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_ElementalDuplicator; + +public class GregtechIndustrialElementDuplicator { + + public static void run(){ + + Logger.INFO("Gregtech5u Content | Registering Elemental Duplicator Multiblock."); + + GregtechItemList.Controller_ElementalDuplicator.set(new GregtechMTE_ElementalDuplicator(31050, "gtpp.multimachine.replicator", "Elemental Duplicator").getStackForm(1L)); + GregtechItemList.Hatch_Input_Elemental_Duplicator.set(new GT_MetaTileEntity_Hatch_ElementalDataOrbHolder(31051, "hatch.input_bus.elementalorbholder", "Elemental Data Orb Storage", 7).getStackForm(1L)); + + } + +} + diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialExtruder.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialExtruder.java new file mode 100644 index 0000000000..51b2f4b0d5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialExtruder.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialExtruder; + +public class GregtechIndustrialExtruder { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Extrusion Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialExtrudingMachine) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Presser Multiblock + GregtechItemList.Industrial_Extruder.set(new GregtechMetaTileEntity_IndustrialExtruder(859, + "industrialextruder.controller.tier.single", "Industrial Extrusion Machine").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFishPond.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFishPond.java new file mode 100644 index 0000000000..681256a385 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFishPond.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_IndustrialFishingPond; + +public class GregtechIndustrialFishPond { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Fishing Pond Multiblock."); + //if (CORE.ConfigSwitches.enableMultiblock_IndustrialWashPlant) { + run1(); + //} + } + + } + + private static void run1() { + GregtechItemList.Industrial_FishingPond.set(new GregtechMetaTileEntity_IndustrialFishingPond(829, + "industrial.fishpond.controller.tier.single", "Zhuhai - Fishing Port").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFuelRefinery.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFuelRefinery.java new file mode 100644 index 0000000000..0b6dcb1b94 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFuelRefinery.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_Refinery; + +public class GregtechIndustrialFuelRefinery { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Fuel Processing and Refinery Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_NuclearFuelRefinery) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Maceration Stack Multiblock + GregtechItemList.Industrial_FuelRefinery.set(new GregtechMetaTileEntity_Refinery(835, + "industrialrefinery.controller.tier.single", "Reactor Fuel Processing Plant").getStackForm(1L)); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java new file mode 100644 index 0000000000..9bdcf231d0 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntityGeneratorArray; + +public class GregtechIndustrialGeneratorArray { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Generator Array Multiblock."); + //if (CORE.ConfigSwitches.enableMultiblock_IndustrialSifter) { // TODO + run1(); + //} + } + + } + + private static void run1() { + // Industrial Maceration Stack Multiblock + GregtechItemList.Generator_Array_Controller.set(new GregtechMetaTileEntityGeneratorArray( + 990, + "generatorarray.controller.tier.01", + "Large Generator Array").getStackForm(1L)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMacerator.java new file mode 100644 index 0000000000..c67296fc53 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMacerator.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialMacerator; + +public class GregtechIndustrialMacerator { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Maceration Stack Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialMacerationStack) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Maceration Stack Multiblock + GregtechItemList.Industrial_MacerationStack.set(new GregtechMetaTileEntity_IndustrialMacerator(797, + "industrialmacerator.controller.tier.single", "Maceration Stack Controller").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java new file mode 100644 index 0000000000..f07be17ffd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java @@ -0,0 +1,230 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_MassFabricator; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechIndustrialMassFabricator { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Matter Fabricator Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_MatterFabricator) { + generateRecipes(); + run1(); + } + } + + } + + private static void run1() { + // Industrial Matter Fabricator Multiblock + GregtechItemList.Industrial_MassFab.set(new GregtechMetaTileEntity_MassFabricator(799, + "industrialmassfab.controller.tier.single", "Matter Fabrication CPU").getStackForm(1L)); + } + + private static void generateRecipes() { + + //Generate Scrap->UUA Recipes + + + + //Basic UUA1 + GT_Recipe UUA_From_Scrap = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(9), ItemUtils.getSimpleStack(getScrapPile(), 9)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {Materials.UUAmplifier.getFluid(1)}, + 9*20, + 32, + 0); + //Basic UUA2 + GT_Recipe UUA_From_ScrapBoxes = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(19), ItemUtils.getSimpleStack(getScrapBox(), 1)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {Materials.UUAmplifier.getFluid(1)}, + 9*20, + 32, + 0); + + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(UUA_From_Scrap); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(UUA_From_ScrapBoxes); + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + //Basic UUM + GT_Recipe generateUUM = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(1)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 160*20, + 32, + 0); + + //Basic UUM + GT_Recipe generateUUMFromUUA = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(2)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {Materials.UUAmplifier.getFluid(1)}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 40*20, + 32, + 0); + + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUM); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUMFromUUA); + } + else { + + //Basic UUM + GT_Recipe generateUUM_LV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(15)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 160*20, + 256, + 0); + GT_Recipe generateUUM_MV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(14)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 160*20, + 512, + 0); + GT_Recipe generateUUM_HV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(13)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 160*20, + 1024, + 0); + GT_Recipe generateUUM_EV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(12)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 160*20, + 2048, + 0); + GT_Recipe generateUUM_IV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(11)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 160*20, + 4096, + 0); + + //Basic UUM + GT_Recipe generateUUMFromUUA_LV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(5)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {Materials.UUAmplifier.getFluid(1)}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 40*20, + 256, + 0); + GT_Recipe generateUUMFromUUA_MV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(4)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {Materials.UUAmplifier.getFluid(1)}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 40*20, + 512, + 0); + GT_Recipe generateUUMFromUUA_HV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(3)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {Materials.UUAmplifier.getFluid(1)}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 40*20, + 1024, + 0); + GT_Recipe generateUUMFromUUA_EV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(2)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {Materials.UUAmplifier.getFluid(1)}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 40*20, + 2048, + 0); + GT_Recipe generateUUMFromUUA_IV = new GTPP_Recipe( + false, + new ItemStack[] {CI.getNumberedCircuit(1)}, + new ItemStack[] {GT_Values.NI}, + null, null, + new FluidStack[] {Materials.UUAmplifier.getFluid(1)}, + new FluidStack[] {Materials.UUMatter.getFluid(1)}, + 40*20, + 4096, + 0); + + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUM_LV); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUM_MV); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUM_HV); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUM_EV); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUM_IV); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUMFromUUA_LV); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUMFromUUA_MV); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUMFromUUA_HV); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUMFromUUA_EV); + GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.add(generateUUMFromUUA_IV); + + } + + Logger.INFO("Generated "+GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes.mRecipeList.size()+" Matter Fabricator recipes."); + + + + + } + + + + public static ItemStack getScrapPile() { + return ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); + } + public static ItemStack getScrapBox() { + return ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); + } + +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMixer.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMixer.java new file mode 100644 index 0000000000..9c8673682c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMixer.java @@ -0,0 +1,27 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialMixer; + +public class GregtechIndustrialMixer { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Mixer Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialPlatePress) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Mixer Multiblock + GregtechItemList.Industrial_Mixer.set(new GregtechMetaTileEntity_IndustrialMixer(811, + "industrialmixer.controller.tier.single", "Industrial Mixing Machine").getStackForm(1L)); + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiMachine.java new file mode 100644 index 0000000000..40d6c12f0b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiMachine.java @@ -0,0 +1,25 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialMultiMachine; + +public class GregtechIndustrialMultiMachine { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Multi-Machine Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialMultiMachine) { + run1(); + } + } + + } + + private static void run1() { + GregtechItemList.Industrial_MultiMachine.set(new GregtechMetaTileEntity_IndustrialMultiMachine(860, + "industrialmultimachine.controller.tier.single", "Large Processing Factory").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiTank.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiTank.java new file mode 100644 index 0000000000..1d723784ac --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMultiTank.java @@ -0,0 +1,32 @@ +/* +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_MultiTank; + +public class GregtechIndustrialMultiTank { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Multitank controller blocks."); + if (CORE.ConfigSwitches.enableMultiblock_MultiTank) { + run1(); + } + } + + } + + private static void run1() { + GregtechItemList.Industrial_MultiTank + .set(new GregtechMetaTileEntity_MultiTank(827, "multitank.controller.tier.single", "Gregtech Multitank") + .getStackForm(1L)); + // GregtechItemList.Industrial_MultiTankDense.set(new + // GregtechMetaTileEntityMultiTankDense(828, + // "multitankdense.controller.tier.single", "Gregtech Dense + // Multitank").getStackForm(1L)); + + } +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialPlatePress.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialPlatePress.java new file mode 100644 index 0000000000..ecf1e73675 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialPlatePress.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialPlatePress; + +public class GregtechIndustrialPlatePress { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Press Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialPlatePress) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Presser Multiblock + GregtechItemList.Industrial_PlatePress.set(new GregtechMetaTileEntity_IndustrialPlatePress(792, + "industrialbender.controller.tier.single", "Industrial Material Press").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSifter.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSifter.java new file mode 100644 index 0000000000..15bf42c9d4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialSifter.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialSifter; + +public class GregtechIndustrialSifter { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Sifter Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialSifter) { // TODO + run1(); + } + } + + } + + private static void run1() { + // Industrial Maceration Stack Multiblock + GregtechItemList.Industrial_Sifter.set(new GregtechMetaTileEntity_IndustrialSifter(840, + "industrialsifter.controller.tier.single", "Large Sifter Control Block").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialThermalCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialThermalCentrifuge.java new file mode 100644 index 0000000000..01c04b4668 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialThermalCentrifuge.java @@ -0,0 +1,25 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialThermalCentrifuge; + +public class GregtechIndustrialThermalCentrifuge { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Thermal Centrifuge Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialThermalCentrifuge) { + run1(); + } + } + + } + + private static void run1() { + GregtechItemList.Industrial_ThermalCentrifuge.set(new GregtechMetaTileEntity_IndustrialThermalCentrifuge(849, + "industrialthermalcentrifuge.controller.tier.single", "Large Thermal Refinery").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialTreeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialTreeFarm.java new file mode 100644 index 0000000000..47dd3c265f --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialTreeFarm.java @@ -0,0 +1,28 @@ + +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntityTreeFarm; + +public class GregtechIndustrialTreeFarm { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Tree Farm Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer) { + run1(); + } + } + + } + + private static void run1() { + // Industrial Maceration Stack Multiblock + GregtechItemList.Industrial_TreeFarm + .set(new GregtechMetaTileEntityTreeFarm(836, "treefarm.controller.tier.single", "Tree Growth Simulator") + .getStackForm(1L)); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWashPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWashPlant.java new file mode 100644 index 0000000000..f66ebca60e --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWashPlant.java @@ -0,0 +1,25 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialWashPlant; + +public class GregtechIndustrialWashPlant { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Wash Plant Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialWashPlant) { + run1(); + } + } + + } + + private static void run1() { + GregtechItemList.Industrial_WashPlant.set(new GregtechMetaTileEntity_IndustrialWashPlant(850, + "industrialwashplant.controller.tier.single", "Ore Washing Plant").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWiremill.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWiremill.java new file mode 100644 index 0000000000..6d575991bd --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialWiremill.java @@ -0,0 +1,25 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialWireMill; + +public class GregtechIndustrialWiremill { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Wire Factory Multiblock."); + if (CORE.ConfigSwitches.enableMultiblock_IndustrialWireMill) { + run1(); + } + } + } + + private static void run1() { + // Industrial Wire Factory Multiblock + GregtechItemList.Industrial_WireFactory.set(new GregtechMetaTileEntity_IndustrialWireMill(798, + "industrialwiremill.controller.tier.single", "Wire Factory Controller").getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java new file mode 100644 index 0000000000..1bcd0f3300 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IronBlastFurnace; + +public class GregtechIronBlastFurnace { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Iron Blast Furnace."); + if (CORE.ConfigSwitches.enableMultiblock_IronBlastFurnace) { + run1(); + } + } + + } + + private static void run1() { + GregtechItemList.Machine_Iron_BlastFurnace.set(new GregtechMetaTileEntity_IronBlastFurnace(768, + "ironmachine.blastfurnace", "Iron Plated Blast Furnace").getStackForm(1L)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java new file mode 100644 index 0000000000..19c361be93 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java @@ -0,0 +1,23 @@ +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.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/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLFTR.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLFTR.java new file mode 100644 index 0000000000..cef60ba712 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLFTR.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_ReactorColdTrap; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_ReactorProcessingUnit; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_SpargeTower; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_NuclearReactor; + +public class GregtechLFTR { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Liquid Fluorine Thorium Reactor [LFTR]."); + if (CORE.ConfigSwitches.enableMultiblock_LiquidFluorideThoriumReactor) { + run1(); + } + } + + } + + private static void run1() { + // LFTR + GregtechItemList.ThoriumReactor.set(new GregtechMTE_NuclearReactor(751, "lftr.controller.single", "Thorium Reactor [LFTR]").getStackForm(1L)); + // Reactor Processing Units + GregtechItemList.ReactorProcessingUnit_IV.set(new GregtechMetaTileEntity_ReactorProcessingUnit(31031, "rpu.tier.01", "Reactor Processing Unit I", 5).getStackForm(1L)); + GregtechItemList.ReactorProcessingUnit_ZPM.set(new GregtechMetaTileEntity_ReactorProcessingUnit(31032, "rpu.tier.02", "Reactor Processing Unit II", 7).getStackForm(1L)); + // Cold Traps + GregtechItemList.ColdTrap_IV.set(new GregtechMetaTileEntity_ReactorColdTrap(31033, "coldtrap.tier.01", "Cold Trap I", 5).getStackForm(1L)); + GregtechItemList.ColdTrap_ZPM.set(new GregtechMetaTileEntity_ReactorColdTrap(31034, "coldtrap.tier.02", "Cold Trap II", 7).getStackForm(1L)); + // Sparge Tower + GregtechItemList.Controller_Sparge_Tower.set(new GregtechMetaTileEntity_SpargeTower(31035, "sparge.controller.single", "Sparge Tower Controller").getStackForm(1L)); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLargeTurbinesAndHeatExchanger.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLargeTurbinesAndHeatExchanger.java new file mode 100644 index 0000000000..9b9f5fd59b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechLargeTurbinesAndHeatExchanger.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; + +public class GregtechLargeTurbinesAndHeatExchanger { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Larger Turbines & Extra Large Heat Exchanger."); + run1(); + } + + } + + private static void run1() { + /* GregtechItemList.Large_Steam_Turbine.set(new GT_MTE_LargeTurbine_Steam(865, "multimachine.largerturbine", "XL Turbo Steam Turbine").getStackForm(1L)); + GregtechItemList.Large_HPSteam_Turbine.set(new GT_MTE_LargeTurbine_SHSteam(866, "multimachine.largerhpturbine", "XL Turbo HP Steam Turbine").getStackForm(1L)); + GregtechItemList.Hatch_Turbine_Rotor.set(new GT_MetaTileEntity_Hatch_Turbine(30010, "hatch.turbine", "Rotor Assembly", 8).getStackForm(1L)); + */ + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java new file mode 100644 index 0000000000..aea40c564c --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java @@ -0,0 +1,45 @@ +/* +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GTPP_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Plasma; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_MiniFusionPlant; + +public class GregtechMiniRaFusion { + + public static void run() { + // Register the Simple Fusion Entity. + GregtechItemList.Miniature_Fusion.set(new GregtechMTE_MiniFusionPlant(31015, "gtplusplus.fusion.single", "Helium Prime").getStackForm(1L)); + GregtechItemList.Plasma_Tank.set(new GT_MetaTileEntity_Hatch_Plasma(31016, "gtplusplus.tank.plasma", "Plasma Tank").getStackForm(1L)); + + } + + public static boolean generateSlowFusionrecipes() { + for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sFusionRecipes.mRecipeList){ + if (x.mEnabled) { + GT_Recipe y = x.copy(); + y.mDuration *= 16; + long z = y.mEUt * 4; + if (z > Integer.MAX_VALUE) { + y.mEnabled = false; + continue; + } + y.mEUt = (int) Math.min(Math.max(0, z), Integer.MAX_VALUE); + y.mCanBeBuffered = true; + GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes.add(y); + } + } + int mRecipeCount = GTPP_Recipe.GTPP_Recipe_Map.sSlowFusionRecipes.mRecipeList.size(); + if (mRecipeCount > 0) { + Logger.INFO("[Pocket Fusion] Generated "+mRecipeCount+" recipes for the Pocket Fusion Reactor."); + return true; + } + return false; + } + + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNaqReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNaqReactor.java new file mode 100644 index 0000000000..e2c63c77da --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNaqReactor.java @@ -0,0 +1,24 @@ +/* +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_LargeNaqReactor; + +public class GregtechNaqReactor { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Futuristic Naquadah Reactor {LNR]."); + run1(); + } + + } + + private static void run1() { + // LFTR + GregtechItemList.Controller_Naq_Reactor.set(new GregtechMTE_LargeNaqReactor(970, "lnr.controller.single", "Naquadah Reactor Mark XII").getStackForm(1L)); + + } +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java new file mode 100644 index 0000000000..6095413150 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java @@ -0,0 +1,182 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import net.minecraft.item.ItemStack; + +import gregtech.GT_Mod; +import gregtech.api.enums.*; +import gregtech.api.objects.MaterialStack; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechNitroDieselFix { + + @SuppressWarnings("unchecked") + public static void run(){ + if (CORE.ConfigSwitches.enableNitroFix){ + Logger.INFO("Gregtech5u Content | Attempting to Fix Nitro-Diesel production."); + try { + int mSub = Utils.getGregtechSubVersion(); + if (mSub != 0){ + if (mSub >= 30){ + Class mb = ReflectionUtils.getClass("gregtech.api.enums.MaterialBuilder"); + Object df = mb.getConstructor(int.class, TextureSet.class, String.class).newInstance(975, TextureSet.SET_FLUID, "Nitro-Diesel [Old]"); + if (mb.isInstance(df)){ + + Logger.INFO("[Nitro] Created new instance of Material builder, for Nitro fix."); + + //Get Methods + Method addFluid = mb.getDeclaredMethod("addFluid"); + Method addCell = mb.getDeclaredMethod("addCell"); + Method setColour = mb.getDeclaredMethod("setColor", Dyes.class); + Method setFuelPower = mb.getDeclaredMethod("setFuelPower", int.class); + Method setMaterials = mb.getDeclaredMethod("setMaterialList", List.class); + Method setTemp = mb.getDeclaredMethod("setLiquidTemperature", int.class); + Method setRGB = mb.getDeclaredMethod("setRGB", int.class, int.class, int.class); + Method construct = mb.getDeclaredMethod("constructMaterial"); + Logger.INFO("[Nitro] Got internal methods for setting fields."); + + //Invoke the methods + addFluid.invoke(df); + addCell.invoke(df); + setColour.invoke(df, Dyes.dyeLime); + setFuelPower.invoke(df, 512000); + setMaterials.invoke(df, Arrays.asList(new MaterialStack(Materials.Glyceryl, 1), new MaterialStack(Materials.Fuel, 4))); + setTemp.invoke(df, 295); + setRGB.invoke(df, 200, 255, 0); + Materials mNitroFix = (Materials) construct.invoke(df); + Logger.INFO("[Nitro] Invoked 8 method calls successfully."); + + GT_Mod.gregtechproxy.addFluid("NitroFuel_Old", "Nitro Diesel [Old]", mNitroFix, 1, 295, GT_OreDictUnificator.get(OrePrefixes.cell, mNitroFix, 1L), ItemUtils.getEmptyCell(), 1000); + Logger.INFO("[Nitro] Added a fluid."); + + + /** + * Reflectively get all the values to maintain 5.08.xx compat + */ + + + GT_Recipe_Map recipeMapMultiblockChemReactor; + recipeMapMultiblockChemReactor = (GT_Recipe_Map) FieldUtils.getDeclaredField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes", true).get(null); + + + + /** + * Do Recipe Stuff + */ + + //Set up some Variables + final Collection<GT_Recipe> xSingle = GT_Recipe.GT_Recipe_Map.sChemicalRecipes.mRecipeList; + final Collection<GT_Recipe> xMulti = recipeMapMultiblockChemReactor.mRecipeList; + final FluidStack mNitroStack = Materials.NitroFuel.getFluid(1000); + GT_Recipe toRemoveSingle[] = new GT_Recipe[99]; + GT_Recipe toRemoveMulti[] = new GT_Recipe[99]; + int mIndexSingle = 0; + int mIndexMulti = 0; + + //Iterate Single Block recipes for Nitro production. + for (GT_Recipe rnd : xSingle){ + for (FluidStack mOutputFluid : rnd.mFluidOutputs){ + if (mOutputFluid.isFluidEqual(mNitroStack)){ + toRemoveSingle[mIndexSingle++] = rnd; + } + } + } + Logger.INFO("[Nitro] Found "+mIndexSingle+" single block Chemical Reactor recipes to remove."); + + //Iterate Multi Block recipes for Nitro production. + for (GT_Recipe rnd : xMulti){ + for (FluidStack mOutputFluid : rnd.mFluidOutputs){ + if (mOutputFluid.isFluidEqual(mNitroStack)){ + toRemoveMulti[mIndexMulti++] = rnd; + } + } + } + Logger.INFO("[Nitro] Found "+mIndexMulti+" multi block Chemical Reactor recipes to remove."); + + //Remove Single Block recipes found. + int mRemovedSingle = 0; + int mRemovedMulti = 0; + for (GT_Recipe single : toRemoveSingle){ + if (GT_Recipe.GT_Recipe_Map.sChemicalRecipes.mRecipeList.remove(single)){ + mRemovedSingle++; + } + } + Logger.INFO("[Nitro] Removed "+mRemovedSingle+" single block Chemical Reactor recipes."); + + //Remove Multi Block recipes found. + for (GT_Recipe multi : toRemoveMulti){ + if (recipeMapMultiblockChemReactor.mRecipeList.remove(multi)){ + mRemovedMulti++; + } + } + Logger.INFO("[Nitro] Removed "+mRemovedMulti+" multi block Chemical Reactor recipes."); + + Materials mGlycerol = Materials.valueOf("Glycerol"); + Materials mLightFuel = Materials.valueOf("LightFuel"); + + //Build a New Recipe set + Materials mFuels[] = {mLightFuel, Materials.Fuel}; + for (Materials fuel : mFuels){ + boolean didAdd[] = new boolean[3]; + Logger.INFO("[Nitro] Getting ready to add back in the old nitro-diesel recipe to the mixer, using "+fuel.mDefaultLocalName+" as the fuel input."); + didAdd[0] = GT_Values.RA.addMixerRecipe(getCells(fuel, 4), getCells(mGlycerol, 1), GT_Values.NI, GT_Values.NI, GT_Values.NF, GT_Values.NF, getCells(mNitroFix, 5), 20, 30); + didAdd[1] = GT_Values.RA.addMixerRecipe(getCells(fuel, 4), GT_Values.NI, GT_Values.NI, GT_Values.NI, mGlycerol.getFluid(1000L),mNitroFix.getFluid(5000L), ItemList.Cell_Empty.get(4L), 20, 30); + didAdd[2] = GT_Values.RA.addMixerRecipe(getCells(mGlycerol, 1), GT_Values.NI,GT_Values.NI,GT_Values.NI, fuel.getFluid(4000L),mNitroFix.getFluid(5000L), ItemList.Cell_Empty.get(1L), 20, 30); + Logger.INFO("[Nitro] Did the recipes add? 1: "+didAdd[0]+" | 2: "+didAdd[1]+" | 3: "+didAdd[2]); + } + + for (Materials fuel : mFuels){ + boolean didAdd[] = new boolean[3]; + Logger.INFO("[Nitro] Getting ready to add back in the old nitro-diesel recipe to the chemical reactors, using "+fuel.mDefaultLocalName+" as the fuel input."); + didAdd[0] = GT_Values.RA.addChemicalRecipe(getCells(fuel, 4), getCells(mGlycerol, 1), GT_Values.NF, GT_Values.NF, getCells(mNitroFix, 5), 20); + didAdd[1] = GT_Values.RA.addChemicalRecipe(getCells(fuel, 4), GT_Values.NI, mGlycerol.getFluid(1000L),mNitroFix.getFluid(5000L), ItemList.Cell_Empty.get(4L), 20); + didAdd[2] = GT_Values.RA.addChemicalRecipe(getCells(mGlycerol, 1), GT_Values.NI, fuel.getFluid(4000L),mNitroFix.getFluid(5000L), ItemList.Cell_Empty.get(1L), 20); + Logger.INFO("[Nitro] Did the recipes add? 1: "+didAdd[0]+" | 2: "+didAdd[1]+" | 3: "+didAdd[2]); + } + + Logger.INFO("[Nitro] Getting ready to add back in the old glycerol recipe!"); + GT_Values.RA.addChemicalRecipe(getCells(Materials.Nitrogen, 1), getDust(Materials.Carbon, 1), Materials.Water.getFluid(2000L), mGlycerol.getFluid(3000L), ItemList.Cell_Empty.get(1), 3000); + Logger.INFO("[Nitro] Added recipes."); + + } + } + } + } + catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + Logger.INFO("[Nitro] ================ Error ================"); + e.printStackTrace(); + Logger.INFO("[Nitro] ================ Error ================"); + } + } + } + + + public static ItemStack getCells(Materials mat, int amount){ + String mName = MaterialUtils.getMaterialName(mat); + return ItemUtils.getItemStackOfAmountFromOreDict("cell"+mName, amount); + } + + public static ItemStack getDust(Materials mat, int amount){ + String mName = MaterialUtils.getMaterialName(mat); + return ItemUtils.getItemStackOfAmountFromOreDict("dust"+mName, amount); + } + + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java new file mode 100644 index 0000000000..c470243822 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java @@ -0,0 +1,57 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaAtmosphericReconditioner; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaPollutionCreator; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaPollutionDetector; + +public class GregtechPollutionDevices { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + if (PollutionUtils.isPollutionEnabled()) { + Logger.INFO("Gregtech5u Content | Registering Anti-Pollution Devices."); + run1(); + } + } + } + + private static void run1() { + if (CORE.ConfigSwitches.enableMachine_Pollution){ + // 759 + GregtechItemList.Pollution_Detector.set( + new GregtechMetaPollutionDetector(756, "pollutiondetector.01.tier.single", "Pollution Detection Device", + 0, "Tells you if you're living in Gwalior yet.", 0).getStackForm(1L)); + GregtechItemList.Pollution_Creator.set(new GregtechMetaPollutionCreator(951, "pollutioncreator.01.tier.single", + "Smog Device", 4, "Polluting the skies.", 0).getStackForm(1L)); + + GregtechItemList.Pollution_Cleaner_ULV.set(new GregtechMetaAtmosphericReconditioner(757, + "pollutioncleaner.01.tier.single", "Pollution Scrubber", 0).getStackForm(1L)); + GregtechItemList.Pollution_Cleaner_LV.set(new GregtechMetaAtmosphericReconditioner(758, + "pollutioncleaner.02.tier.single", "Upgraded Pollution Scrubber", 1).getStackForm(1L)); + GregtechItemList.Pollution_Cleaner_MV.set(new GregtechMetaAtmosphericReconditioner(759, + "pollutioncleaner.03.tier.single", "Advanced Pollution Scrubber", 2).getStackForm(1L)); + GregtechItemList.Pollution_Cleaner_HV.set(new GregtechMetaAtmosphericReconditioner(760, + "pollutioncleaner.04.tier.single", "Precision Pollution Scrubber", 3).getStackForm(1L)); + GregtechItemList.Pollution_Cleaner_EV.set(new GregtechMetaAtmosphericReconditioner(761, + "pollutioncleaner.05.tier.single", "Air Recycler", 4).getStackForm(1L)); + GregtechItemList.Pollution_Cleaner_IV.set(new GregtechMetaAtmosphericReconditioner(762, + "pollutioncleaner.06.tier.single", "Upgraded Air Recycler", 5).getStackForm(1L)); + GregtechItemList.Pollution_Cleaner_LuV.set(new GregtechMetaAtmosphericReconditioner(763, + "pollutioncleaner.07.tier.single", "Advanced Air Recycler", 6).getStackForm(1L)); + GregtechItemList.Pollution_Cleaner_ZPM.set(new GregtechMetaAtmosphericReconditioner(764, + "pollutioncleaner.08.tier.single", "Precision Air Recycler", 7).getStackForm(1L)); + GregtechItemList.Pollution_Cleaner_UV.set(new GregtechMetaAtmosphericReconditioner(765, + "pollutioncleaner.09.tier.single", "Atmospheric Cleaner", 8).getStackForm(1L)); + GregtechItemList.Pollution_Cleaner_MAX.set(new GregtechMetaAtmosphericReconditioner(766, + "pollutioncleaner.10.tier.single", "Biosphere Cleanser", 9).getStackForm(1L)); + } + + + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerBreakers.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerBreakers.java new file mode 100644 index 0000000000..3e9582b80a --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerBreakers.java @@ -0,0 +1,42 @@ +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.GT_MetaTileEntity_BasicBreaker; + +public class GregtechPowerBreakers { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Power Breakers."); + run1(); + } + + } + + private static void run1() { + //30200 + int aStartID = 30400; + GregtechItemList.BreakerBox_ULV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.00", + "Ultra Low Voltage Breaker Box", 0, "", 16)).getStackForm(1L)); + GregtechItemList.BreakerBox_LV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.01", + "Low Voltage Breaker Box", 1, "", 16)).getStackForm(1L)); + GregtechItemList.BreakerBox_MV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.02", + "Medium Voltage Breaker Box", 2, "", 16)).getStackForm(1L)); + GregtechItemList.BreakerBox_HV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.03", + "High Voltage Breaker Box", 3, "", 16)).getStackForm(1L)); + GregtechItemList.BreakerBox_EV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.04", + "Extreme Voltage Breaker Box", 16, "", 16)).getStackForm(1L)); + GregtechItemList.BreakerBox_IV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.05", + "Insane Voltage Breaker Box", 5, "", 16)).getStackForm(1L)); + GregtechItemList.BreakerBox_LuV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.06", + "Ludicrous Voltage Breaker Box", 6, "", 16)).getStackForm(1L)); + GregtechItemList.BreakerBox_ZPM.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.07", + "ZPM Voltage Breaker Box", 7, "", 16)).getStackForm(1L)); + GregtechItemList.BreakerBox_UV.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.08", + "Ultimate Voltage Breaker Box", 8, "", 16)).getStackForm(1L)); + GregtechItemList.BreakerBox_MAX.set((new GT_MetaTileEntity_BasicBreaker(aStartID++, "breaker.tier.09", + "MAX Voltage Breaker Box", 9, "", 16)).getStackForm(1L)); + + } +}
\ No newline at end of file diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java new file mode 100644 index 0000000000..9e94d633f6 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java @@ -0,0 +1,43 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; + +public class GregtechPowerSubStation { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Power Substation Node."); + if (CORE.ConfigSwitches.enableMultiblock_PowerSubstation) { + run1(); + } + } + + } + + private static void run1() { + // Steam Condensors + GregtechItemList.PowerSubStation.set(new GregtechMetaTileEntity_PowerSubStationController(812, + "substation.01.input.single", "Power Station Control Node").getStackForm(1L)); + int tID = 886; + GregtechItemList.Hatch_Input_Battery_MV.set(new GT_MetaTileEntity_Hatch_InputBattery(tID++, "hatch.input_battery.tier.00", "Charging Bus (MV)", 2).getStackForm(1L)); + GregtechItemList.Hatch_Input_Battery_EV.set(new GT_MetaTileEntity_Hatch_InputBattery(tID++, "hatch.input_battery.tier.01", "Charging Bus (EV)", 4).getStackForm(1L)); + + GregtechItemList.Hatch_Output_Battery_MV.set(new GT_MetaTileEntity_Hatch_OutputBattery(tID++, "hatch.output_battery.tier.00", "Discharging Bus (MV)", 2).getStackForm(1L)); + GregtechItemList.Hatch_Output_Battery_EV.set(new GT_MetaTileEntity_Hatch_OutputBattery(tID++, "hatch.output_battery.tier.01", "Discharging Bus (EV)", 4).getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Input_Battery_MV.get(1L, new Object[0]), CI.bitsd, new Object[]{"C", "M", 'M', ItemList.Hull_MV, 'C', ItemList.Battery_Buffer_2by2_MV}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Input_Battery_EV.get(1L, new Object[0]), CI.bitsd, new Object[]{"C", "M", 'M', ItemList.Hull_EV, 'C', ItemList.Battery_Buffer_4by4_EV}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Output_Battery_MV.get(1L, new Object[0]), CI.bitsd, new Object[]{"M", "C", 'M', ItemList.Hull_MV, 'C', ItemList.Battery_Buffer_2by2_MV}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Output_Battery_EV.get(1L, new Object[0]), CI.bitsd, new Object[]{"M", "C", 'M', ItemList.Hull_EV, 'C', ItemList.Battery_Buffer_4by4_EV}); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRTG.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRTG.java new file mode 100644 index 0000000000..a7332657ce --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRTG.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntity_RTG; + +public class GregtechRTG { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering RTG."); + run1(); + } + } + + private static void run1() { + GregtechItemList.RTG.set( + new GregtechMetaTileEntity_RTG(869, "basicgenerator.rtg.tier.01", "Radioisotope Thermoelectric Generator", 3) + .getStackForm(1L)); + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java new file mode 100644 index 0000000000..5a7d3a50d7 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java @@ -0,0 +1,128 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntityRocketFuelGenerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_LargeRocketEngine; + +public class GregtechRocketFuelGenerator { + + public static void run() { + if (LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Industrial Rocket Engines."); + if (CORE.ConfigSwitches.enableMachine_RocketEngines) { + run1(); + } + } + + } + + private static void run1() { + GregtechItemList.Controller_RocketEngine.set( + new GregtechMetaTileEntity_LargeRocketEngine(996, "gtpp.multimachine.rocketengine", "Rocketdyne F-1A Engine").getStackForm(1L)); + + + ItemList aDieselEngine = ItemUtils.getValueOfItemList("Machine_Multi_DieselEngine", ItemList.Machine_Multi_LargeBoiler_TungstenSteel); + + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Controller_RocketEngine.get(1L), + CI.bitsd, + new Object[]{ + "PCP", "EME", "GWG", + 'M', aDieselEngine, + 'P', ItemList.Electric_Piston_IV, + 'E', ItemList.Field_Generator_EV, + 'C', OrePrefixes.circuit.get(Materials.Master), + 'W', OrePrefixes.cableGt08.get(Materials.Platinum), + 'G', ALLOY.MARAGING350.getGear(1)}); + + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Casing_RocketEngine.get(1L), + CI.bitsd, + new Object[]{ + "PhP", "RFR", "PWP", + 'R', OrePrefixes.pipeLarge.get(Materials.TungstenSteel), + 'F', ItemList.Casing_RobustTungstenSteel, + 'P', ALLOY.NITINOL_60.getGear(1)}); + + GregtechItemList.Rocket_Engine_EV.set(new GregtechMetaTileEntityRocketFuelGenerator(793, + "advancedgenerator.rocketFuel.tier.01", "Basic Rocket Engine", 4).getStackForm(1L)); + GregtechItemList.Rocket_Engine_IV.set(new GregtechMetaTileEntityRocketFuelGenerator(794, + "advancedgenerator.rocketFuel.tier.02", "Advanced Rocket Engine", 5).getStackForm(1L)); + GregtechItemList.Rocket_Engine_LuV.set(new GregtechMetaTileEntityRocketFuelGenerator(795, + "advancedgenerator.rocketFuel.tier.03", "Turbo Rocket Engine", 6).getStackForm(1L)); + if (!CORE.GTNH) { + GT_ModHandler.addCraftingRecipe(GregtechItemList.Rocket_Engine_EV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"PCP", "EME", "GWG", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('P'), + ItemList.Electric_Piston_EV, Character.valueOf('E'), ItemList.Electric_Motor_EV, + Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Ultimate), Character.valueOf('W'), + OrePrefixes.cableGt02.get(Materials.Aluminium), Character.valueOf('G'), + ALLOY.TANTALLOY_61.getGear(1)}); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Rocket_Engine_IV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"PCP", "EME", "GWG", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('P'), + ItemList.Electric_Piston_IV, Character.valueOf('E'), ItemList.Electric_Motor_IV, + Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Superconductor), + Character.valueOf('W'), OrePrefixes.cableGt02.get(Materials.Platinum), Character.valueOf('G'), + ALLOY.STELLITE.getGear(1)}); + } + if (CORE.GTNH) { + GT_ModHandler.addCraftingRecipe(GregtechItemList.Rocket_Engine_EV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"PCP", "EME", "GWG", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('P'), + ItemList.Electric_Piston_EV, Character.valueOf('E'), ItemList.Electric_Motor_EV, + Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('W'), + OrePrefixes.cableGt02.get(Materials.Aluminium), Character.valueOf('G'), + ALLOY.TANTALLOY_61.getGear(1)}); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Rocket_Engine_IV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"PCP", "EME", "GWG", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('P'), + ItemList.Electric_Piston_IV, Character.valueOf('E'), ItemList.Electric_Motor_IV, + Character.valueOf('C'), OrePrefixes.circuit.get(Materials.Master), + Character.valueOf('W'), OrePrefixes.cableGt02.get(Materials.Platinum), Character.valueOf('G'), + ALLOY.STELLITE.getGear(1)}); + } + final ItemStack INGREDIENT_1 = CI.electricPiston_LuV; + final ItemStack INGREDIENT_2 = CI.electricMotor_LuV; + if (!CORE.GTNH) { + GT_ModHandler.addCraftingRecipe(GregtechItemList.Rocket_Engine_LuV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"PCP", "EME", "GWG", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('P'), + INGREDIENT_1, Character.valueOf('E'), INGREDIENT_2, Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Infinite), Character.valueOf('W'), + OrePrefixes.cableGt02.get(Materials.Tungsten), Character.valueOf('G'), + ALLOY.ZERON_100.getGear(1)}); + } + if (CORE.GTNH) { + GT_ModHandler.addCraftingRecipe(GregtechItemList.Rocket_Engine_LuV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[]{"PCP", "EME", "GWG", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('P'), + INGREDIENT_1, Character.valueOf('E'), INGREDIENT_2, Character.valueOf('C'), + OrePrefixes.circuit.get(Materials.Ultimate), Character.valueOf('W'), + OrePrefixes.cableGt02.get(Materials.Tungsten), Character.valueOf('G'), + ALLOY.ZERON_100.getGear(1)}); + } + } +} + diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSafeBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSafeBlock.java new file mode 100644 index 0000000000..124b5d114d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSafeBlock.java @@ -0,0 +1,118 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.*; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaSafeBlock; + +public class GregtechSafeBlock { + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Lockable Safe Blocks."); + if (CORE.ConfigSwitches.enableMachine_Safes) { + run1(); + } + } + + } + + private static void run1() { + + GregtechItemList.GT_Safe_ULV + .set(new GregtechMetaSafeBlock(780, "protection.playersafe.tier.00", "Ultra Low Voltage Player Safe", 0) + .getStackForm(1L)); + GregtechItemList.GT_Safe_LV + .set(new GregtechMetaSafeBlock(781, "protection.playersafe.tier.01", "Low Voltage Player Safe", 1) + .getStackForm(1L)); + GregtechItemList.GT_Safe_MV + .set(new GregtechMetaSafeBlock(782, "protection.playersafe.tier.02", "Medium Voltage Player Safe", 2) + .getStackForm(1L)); + GregtechItemList.GT_Safe_HV + .set(new GregtechMetaSafeBlock(783, "protection.playersafe.tier.03", "High Voltage Player Safe", 3) + .getStackForm(1L)); + GregtechItemList.GT_Safe_EV + .set(new GregtechMetaSafeBlock(784, "protection.playersafe.tier.04", "Extreme Voltage Player Safe", 4) + .getStackForm(1L)); + GregtechItemList.GT_Safe_IV + .set(new GregtechMetaSafeBlock(785, "protection.playersafe.tier.05", "Insane Voltage Player Safe", 5) + .getStackForm(1L)); + GregtechItemList.GT_Safe_LuV + .set(new GregtechMetaSafeBlock(786, "protection.playersafe.tier.06", "Ludicrous Voltage Player Safe", 6) + .getStackForm(1L)); + GregtechItemList.GT_Safe_ZPM + .set(new GregtechMetaSafeBlock(787, "protection.playersafe.tier.07", "ZPM Voltage Player Safe", 7) + .getStackForm(1L)); + GregtechItemList.GT_Safe_UV + .set(new GregtechMetaSafeBlock(788, "protection.playersafe.tier.08", "Ultimate Voltage Player Safe", 8) + .getStackForm(1L)); + GregtechItemList.GT_Safe_MAX + .set(new GregtechMetaSafeBlock(789, "protection.playersafe.tier.09", "MAX Voltage Player Safe", 9) + .getStackForm(1L)); + + // To-Do Change Recipes + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_ULV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_ULV, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Basic) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_LV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_LV, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Good) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_MV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Good), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Good) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_HV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Good), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Advanced) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_EV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Elite) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_IV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Master) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_LuV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Master) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_ZPM.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_ZPM, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Master) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_UV.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_UV, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Master), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Superconductor) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Safe_MAX.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "CMV", " X ", Character.valueOf('M'), ItemList.Hull_MAX, Character.valueOf('V'), + OrePrefixes.circuit.get(Materials.Master), Character.valueOf('C'), OreDictNames.craftingChest, + Character.valueOf('X'), OrePrefixes.circuit.get(Materials.Infinite) }); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSemiFluidgenerators.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSemiFluidgenerators.java new file mode 100644 index 0000000000..6b38415db1 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSemiFluidgenerators.java @@ -0,0 +1,20 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GT_MetaTileEntity_SemiFluidGenerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_LargeSemifluidGenerator; + +public class GregtechSemiFluidgenerators { + + public static void run(){ + GregtechItemList.Generator_SemiFluid_LV.set(new GT_MetaTileEntity_SemiFluidGenerator(837, "basicgenerator.semifluid.tier.01", + "Basic Semi-Fluid Generator", 1).getStackForm(1L)); + GregtechItemList.Generator_SemiFluid_MV.set(new GT_MetaTileEntity_SemiFluidGenerator(838, "basicgenerator.semifluid.tier.02", + "Advanced Semi-Fluid Generator", 2).getStackForm(1L)); + GregtechItemList.Generator_SemiFluid_HV.set(new GT_MetaTileEntity_SemiFluidGenerator(839, "basicgenerator.semifluid.tier.03", + "Turbo Semi-Fluid Generator", 3).getStackForm(1L)); + GregtechItemList.Controller_LargeSemifluidGenerator.set(new GregtechMetaTileEntity_LargeSemifluidGenerator(31026, "gtpp.multimachine.semifluidgenerator", "Large Semifluid Burner").getStackForm(1L)); + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSimpleWasher.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSimpleWasher.java new file mode 100644 index 0000000000..d2087b22f4 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSimpleWasher.java @@ -0,0 +1,109 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GTPP_Recipe; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_BasicWasher; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechSimpleWasher { + + public static void run() { + if (CORE.ConfigSwitches.enableMachine_SimpleWasher){ + generateDirtyDustRecipes(); + generateDirtyCrushedRecipes(); + // Register the Simple Washer Entity. + GregtechItemList.SimpleDustWasher_ULV + .set(new GregtechMetaTileEntity_BasicWasher(767, "simplewasher.01.tier.01", "Simple Washer I", 0) + .getStackForm(1L)); + + //People want them in higher tiers apparently + GregtechItemList.SimpleDustWasher_MV + .set(new GregtechMetaTileEntity_BasicWasher(31017, "simplewasher.01.tier.02", "Simple Washer II", 2) + .getStackForm(1L)); + GregtechItemList.SimpleDustWasher_EV + .set(new GregtechMetaTileEntity_BasicWasher(31018, "simplewasher.01.tier.03", "Simple Washer III", 4) + .getStackForm(1L)); + GregtechItemList.SimpleDustWasher_LuV + .set(new GregtechMetaTileEntity_BasicWasher(31019, "simplewasher.01.tier.04", "Simple Washer IV", 6) + .getStackForm(1L)); + GregtechItemList.SimpleDustWasher_UV + .set(new GregtechMetaTileEntity_BasicWasher(31020, "simplewasher.01.tier.05", "Simple Washer V", 8) + .getStackForm(1L)); + } + } + + private static boolean generateDirtyDustRecipes(){ + boolean disablePlat = CORE.GTNH; + int mRecipeCount = 0; + // Generate Recipe Map for the Dust Washer. + ItemStack dustClean; + ItemStack dustDirty; + for (Materials v : Materials.values()) { + if (disablePlat) { + if (v == Materials.Platinum || v == Materials.Osmium || v == Materials.Iridium || v == Materials.Palladium) { + continue; + } + } + + dustClean = GT_OreDictUnificator.get(OrePrefixes.dust, v, 1L); + dustDirty = GT_OreDictUnificator.get(OrePrefixes.dustImpure, v, 1L); + if (dustClean != null && dustDirty != null) { + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] { dustDirty }, + new ItemStack[] { dustClean }, + null, + new int[] {}, + new FluidStack[] { FluidUtils.getFluidStack("water", 100) }, + new FluidStack[] {}, + 5, + 8, + 0); + GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes.addRecipe(aRecipe); + } + } + + if (GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes.mRecipeList.size() > mRecipeCount){ + return true; + } + return false; + } + + private static boolean generateDirtyCrushedRecipes(){ + int mRecipeCount = GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes.mRecipeList.size(); + // Generate Recipe Map for the Dust Washer. + ItemStack crushedClean; + ItemStack crushedDirty; + for (Materials v : Materials.values()) { + crushedClean = GT_OreDictUnificator.get(OrePrefixes.crushedPurified, v, 1L); + crushedDirty = GT_OreDictUnificator.get(OrePrefixes.crushed, v, 1L); + if (crushedClean != null && crushedDirty != null) { + GTPP_Recipe aRecipe = new GTPP_Recipe( + false, + new ItemStack[] { crushedDirty }, + new ItemStack[] { crushedClean }, + null, + new int[] {}, + new FluidStack[] { FluidUtils.getFluidStack("water", 100) }, + new FluidStack[] {}, + 5, + 8, + 0); + GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes.addRecipe(aRecipe); + } + } + + if (GTPP_Recipe.GTPP_Recipe_Map.sSimpleWasherRecipes.mRecipeList.size() > mRecipeCount){ + return true; + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSolarGenerators.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSolarGenerators.java new file mode 100644 index 0000000000..45f78d660b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSolarGenerators.java @@ -0,0 +1,49 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.CORE.ConfigSwitches; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntitySolarGenerator; + +public class GregtechSolarGenerators { + public static void run() { + if (LoadedMods.Gregtech && ConfigSwitches.enableMachine_SolarGenerators) { + Logger.INFO("Gregtech5u Content | Registering Solar Generator Blocks."); + if (CORE.ConfigSwitches.enableMachine_SolarGenerators) { + run1(); + } + } + + } + + private static void run1() { + + GregtechItemList.GT_Solar_ULV.set(new GregtechMetaTileEntitySolarGenerator(800, "sunabsorber.tier.00", + "Ultra Low Voltage Solar Generator", 0).getStackForm(1L)); + GregtechItemList.GT_Solar_LV.set( + new GregtechMetaTileEntitySolarGenerator(801, "sunabsorber.tier.01", "Low Voltage Solar Generator", 1) + .getStackForm(1L)); + GregtechItemList.GT_Solar_MV.set(new GregtechMetaTileEntitySolarGenerator(802, "sunabsorber.tier.02", + "Medium Voltage Solar Generator", 2).getStackForm(1L)); + GregtechItemList.GT_Solar_HV.set( + new GregtechMetaTileEntitySolarGenerator(803, "sunabsorber.tier.03", "High Voltage Solar Generator", 3) + .getStackForm(1L)); + GregtechItemList.GT_Solar_EV.set(new GregtechMetaTileEntitySolarGenerator(804, "sunabsorber.tier.04", + "Extreme Voltage Solar Generator", 4).getStackForm(1L)); + GregtechItemList.GT_Solar_IV.set(new GregtechMetaTileEntitySolarGenerator(805, "sunabsorber.tier.05", + "Insane Voltage Solar Generator", 5).getStackForm(1L)); + GregtechItemList.GT_Solar_LuV.set(new GregtechMetaTileEntitySolarGenerator(806, "sunabsorber.tier.06", + "Ludicrous Voltage Solar Generator", 6).getStackForm(1L)); + GregtechItemList.GT_Solar_ZPM.set( + new GregtechMetaTileEntitySolarGenerator(807, "sunabsorber.tier.07", "ZPM Voltage Solar Generator", 7) + .getStackForm(1L)); + GregtechItemList.GT_Solar_UV.set(new GregtechMetaTileEntitySolarGenerator(808, "sunabsorber.tier.08", + "Ultimate Voltage Solar Generator", 8).getStackForm(1L)); + GregtechItemList.GT_Solar_MAX.set( + new GregtechMetaTileEntitySolarGenerator(809, "sunabsorber.tier.09", "MAX Voltage Solar Generator", 9) + .getStackForm(1L)); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSolarTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSolarTower.java new file mode 100644 index 0000000000..d7f8f7f4d5 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSolarTower.java @@ -0,0 +1,32 @@ +/* +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_SolarTower; +import gtPlusPlus.xmod.gregtech.common.tileentities.misc.TileEntitySolarHeater; + +public class GregtechSolarTower { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Solar Tower."); + run1(); + } + + } + + private static void run1() { + // Solar Tower + GregtechItemList.Industrial_Solar_Tower.set(new GregtechMetaTileEntity_SolarTower(863, "solartower.controller.tier.single", "Solar Tower").getStackForm(1L)); + GregtechItemList.Solar_Tower_Reflector.set( + new TileEntitySolarHeater( + 864, + "solarreflector.simple.single", + "Solar Reflector", + 8, + "Part of the Clean Green energy movement", + 0).getStackForm(1L)); + + } +}*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamCondenser.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamCondenser.java new file mode 100644 index 0000000000..60e6b31936 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamCondenser.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaCondensor; + +public class GregtechSteamCondenser { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Steam Condensor."); + if (CORE.ConfigSwitches.enableMachine_SteamConverter) { + run1(); + } + } + + } + + private static void run1() { + // Steam Condensors + GregtechItemList.Condensor_MAX.set( + new GregtechMetaCondensor(769, "steamcondensor.01.tier.single", "Steam Condensor").getStackForm(1L)); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamMultis.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamMultis.java new file mode 100644 index 0000000000..add0400d87 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSteamMultis.java @@ -0,0 +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.GT_MetaTileEntity_Hatch_Steam_BusInput; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusOutput; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.steam.GregtechMetaTileEntity_SteamMacerator; + +public class GregtechSteamMultis { + + public static void run(){ + + Logger.INFO("Gregtech5u Content | Registering Steam Multiblocks."); + + GregtechItemList.Controller_SteamMaceratorMulti.set(new GregtechMetaTileEntity_SteamMacerator(31041, "gtpp.multimachine.steam.macerator", "Steam Grinder").getStackForm(1L)); + + GregtechItemList.Hatch_Input_Bus_Steam.set(new GT_MetaTileEntity_Hatch_Steam_BusInput(31046, "hatch.input_bus.tier.steam", "Input Bus (Steam)", 0).getStackForm(1L)); + GregtechItemList.Hatch_Output_Bus_Steam.set(new GT_MetaTileEntity_Hatch_Steam_BusOutput(31047, "hatch.output_bus.tier.steam", "Output Bus (Steam)", 0).getStackForm(1L)); + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperChests.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperChests.java new file mode 100644 index 0000000000..5027e2d6e8 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperChests.java @@ -0,0 +1,73 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import static gtPlusPlus.core.recipe.common.CI.bitsd; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_ConnectableCrate; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; + +public class GregtechSuperChests { + + public static void run() { + int mId = 946; + + String aSuffix = ""; + if (CORE.GTNH) { + aSuffix = " [Disabled]"; + } + + GregtechItemList.Super_Chest_LV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.01", "Super Chest I"+aSuffix, 1)).getStackForm(1L)); + GregtechItemList.Super_Chest_MV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.02", "Super Chest II"+aSuffix, 2)).getStackForm(1L)); + GregtechItemList.Super_Chest_HV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.03", "Super Chest III"+aSuffix, 3)).getStackForm(1L)); + GregtechItemList.Super_Chest_EV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.04", "Super Chest IV"+aSuffix, 4)).getStackForm(1L)); + GregtechItemList.Super_Chest_IV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.05", "Super Chest V"+aSuffix, 5)).getStackForm(1L)); + + // Do not add Recipes for GTNH, hide them from NEI instead. + if (CORE.GTNH) { + ItemUtils.hideItemFromNEI(GregtechItemList.Super_Chest_LV.get(1L)); + ItemUtils.hideItemFromNEI(GregtechItemList.Super_Chest_MV.get(1L)); + ItemUtils.hideItemFromNEI(GregtechItemList.Super_Chest_HV.get(1L)); + ItemUtils.hideItemFromNEI(GregtechItemList.Super_Chest_EV.get(1L)); + ItemUtils.hideItemFromNEI(GregtechItemList.Super_Chest_IV.get(1L)); + } + else { + GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_LV.get(1L, new Object[0]), bitsd, + new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_LV, Character.valueOf('G'), + ItemList.Automation_ChestBuffer_LV, Character.valueOf('D'), + OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('P'), + OrePrefixes.plate.get(Materials.Invar)}); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_MV.get(1L, new Object[0]), bitsd, + new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('G'), + ItemList.Automation_ChestBuffer_MV, Character.valueOf('D'), OrePrefixes.circuit.get(Materials.Good), + Character.valueOf('P'), OrePrefixes.plate.get(Materials.Aluminium)}); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_HV.get(1L, new Object[0]), bitsd, + new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('G'), + ItemList.Automation_ChestBuffer_HV, Character.valueOf('D'), OrePrefixes.circuit.get(Materials.Advanced), + Character.valueOf('P'), OrePrefixes.plate.get(Materials.StainlessSteel)}); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_EV.get(1L, new Object[0]), bitsd, + new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('G'), + ItemList.Automation_ChestBuffer_EV, Character.valueOf('D'), OrePrefixes.circuit.get(Materials.Data), + Character.valueOf('P'), OrePrefixes.plate.get(Materials.Titanium)}); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Super_Chest_IV.get(1L, new Object[0]), bitsd, + new Object[]{"DPD", "PMP", "DGD", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('G'), + ItemList.Automation_ChestBuffer_IV, Character.valueOf('D'), + OrePrefixes.circuit.get(Materials.Elite), Character.valueOf('P'), + OrePrefixes.plate.get(Materials.Tungsten)}); + } + + //Test Thing + GregtechItemList.CrateStorage.set((new GT_MetaTileEntity_ConnectableCrate(GT_MetaTileEntity_ConnectableCrate.mCrateID, "crate.tier.01", "Interconnecting Storage Crate", 0)).getStackForm(1L)); + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperConductionPoint.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperConductionPoint.java new file mode 100644 index 0000000000..1376f4313d --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperConductionPoint.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +public class GregtechSuperConductionPoint { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + //Utils.LOG_INFO("Gregtech5u Content | Registering Super Conductor Input Node."); + run1(); + } + + } + + private static void run1() { + // Steam Condensors + //GregtechItemList.SuperConductorInputNode.set(new GregtechMetaTileEntitySuperCondensor(811, + // "superconductor.01.input.single", "Power Phase Shifting Station", 8).getStackForm(1L)); + + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTeslaTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTeslaTower.java new file mode 100644 index 0000000000..1c5181130b --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTeslaTower.java @@ -0,0 +1,17 @@ +/* +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc.GregtechMTE_TeslaTower; + +public class GregtechTeslaTower { + + public static void run() { + Logger.INFO("Gregtech5u Content | Registering Tesla Tower."); + GregtechItemList.TelsaTower.set(new GregtechMTE_TeslaTower(984, "multimachine.telsatower", "Tesla's Last Testament").getStackForm(1)); + + } + +} +*/ diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechThaumcraftDevices.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechThaumcraftDevices.java new file mode 100644 index 0000000000..398d2caf01 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechThaumcraftDevices.java @@ -0,0 +1,26 @@ +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.common.tileentities.machines.basic.GregtechMetaPollutionCreator; + +public class GregtechThaumcraftDevices { + + public static void run() { + if (LoadedMods.Gregtech && LoadedMods.Thaumcraft) { + Logger.INFO("Gregtech5u Content | Registering Thaumcraft content."); + run1(); + } + } + + private static void run1() { + //956-960 + GregtechItemList.Thaumcraft_Researcher.set(new GregtechMetaPollutionCreator(956, "thaumcraft.gtpp.machine.01", + "Arcane Researcher", 5, "Thinking for you.", 0).getStackForm(1L)); + + + + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechThreadedBuffers.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechThreadedBuffers.java new file mode 100644 index 0000000000..23c9f7e666 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechThreadedBuffers.java @@ -0,0 +1,136 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.ItemList; + +import gregtech.api.util.GT_Recipe; +import gregtech.common.tileentities.automation.GT_MetaTileEntity_SuperBuffer; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.creative.GT_MetaTileEntity_InfiniteItemHolder; +import net.minecraft.item.ItemStack; + +public class GregtechThreadedBuffers { + + public static void run() { + run2(); + } + + private static void run2() { + + GregtechItemList.Infinite_Item_Chest.set((new GT_MetaTileEntity_InfiniteItemHolder(31010, "infinite.chest.tier.01", "Infinite Item Chest", 1)).getStackForm(1L)); + + /* + * This file used to contain registration and recipes for GT++ threaded super buffers. Those have now been + * deprecated and replaced by the original GT super buffers. + * + * To avoid breaking existing bases, we've assigned the threaded super buffer metadata IDs to a copy of the GT + * super buffers, with a deprecation notice attached. We've also provided disassembler recipes that are the + * reverse of the original crafting recipes, allowing players to reclaim their original materials as well as + * convert the deprecated threaded super buffer metadata ID item back to the original GT super buffer metadata + * ID item. + */ + + final String deprecationNotice = "**DEPRECATED - Drop in disassembler!** "; + GregtechItemList.Automation_Threaded_SuperBuffer_ULV.set((new GT_MetaTileEntity_SuperBuffer(31000, "automation.superbuffer.tier.00.deprecated", deprecationNotice + "Ultra Low Voltage Super Buffer", 0)).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_LV.set((new GT_MetaTileEntity_SuperBuffer(31001, "automation.superbuffer.tier.01.deprecated", deprecationNotice + "Low Voltage Super Buffer", 1)).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_MV.set((new GT_MetaTileEntity_SuperBuffer(31002, "automation.superbuffer.tier.02.deprecated", deprecationNotice + "Medium Voltage Super Buffer", 2)).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_HV.set((new GT_MetaTileEntity_SuperBuffer(31003, "automation.superbuffer.tier.03.deprecated", deprecationNotice + "High Voltage Super Buffer", 3)).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_EV.set((new GT_MetaTileEntity_SuperBuffer(31004, "automation.superbuffer.tier.04.deprecated", deprecationNotice + "Extreme Voltage Super Buffer", 4)).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_IV.set((new GT_MetaTileEntity_SuperBuffer(31005, "automation.superbuffer.tier.05.deprecated", deprecationNotice + "Insane Voltage Super Buffer", 5)).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_LuV.set((new GT_MetaTileEntity_SuperBuffer(31006, "automation.superbuffer.tier.06.deprecated", deprecationNotice + "Ludicrous Voltage Super Buffer", 6)).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_ZPM.set((new GT_MetaTileEntity_SuperBuffer(31007, "automation.superbuffer.tier.07.deprecated", deprecationNotice + "ZPM Voltage Super Buffer", 7)).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_UV.set((new GT_MetaTileEntity_SuperBuffer(31008, "automation.superbuffer.tier.08.deprecated", deprecationNotice + "Ultimate Voltage Super Buffer", 8)).getStackForm(1L)); + GregtechItemList.Automation_Threaded_SuperBuffer_MAX.set((new GT_MetaTileEntity_SuperBuffer(31009, "automation.superbuffer.tier.09.deprecated", deprecationNotice + "Highly Ultimate Voltage Super Buffer", 9)).getStackForm(1L)); + + // These recipes are all 1 sec @ 32 EU/t + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_ULV.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_ULV.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + ItemList.Conveyor_Module_LV.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_LV.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_LV.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + ItemList.Conveyor_Module_LV.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_MV.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_MV.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + ItemList.Conveyor_Module_MV.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_HV.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_HV.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + ItemList.Conveyor_Module_HV.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_EV.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_EV.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + ItemList.Conveyor_Module_EV.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_IV.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_IV.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + ItemList.Conveyor_Module_IV.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_LuV.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_LuV.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + ItemList.Conveyor_Module_LuV.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_ZPM.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_ZPM.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + ItemList.Conveyor_Module_ZPM.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_UV.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_UV.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + ItemList.Conveyor_Module_UV.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + true, + new ItemStack[]{ GregtechItemList.Automation_Threaded_SuperBuffer_MAX.get(1L, new Object[0]) }, + new ItemStack[]{ + ItemList.Automation_SuperBuffer_MAX.get(1L, new Object[0]), + ItemList.Tool_DataOrb.get(1L, new Object[0]), + GregtechItemList.Conveyor_Module_MAX.get(1L, new Object[0]), + }, + null, null, null, 20, 32, -100); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredChunkloaders.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredChunkloaders.java new file mode 100644 index 0000000000..bbfd568e54 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredChunkloaders.java @@ -0,0 +1,28 @@ +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.common.tileentities.machines.basic.GregtechMetaTileEntityChunkLoader; + +public class GregtechTieredChunkloaders { + public static void run() { + if (LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Chunk Loaders."); + run1(); + } + } + + private static void run1() { + int ID = 943; + GregtechItemList.GT_Chunkloader_HV + .set(new GregtechMetaTileEntityChunkLoader(ID++, "chunkloader.tier.01", "Chunkloader MK I", 3) + .getStackForm(1L)); + GregtechItemList.GT_Chunkloader_IV + .set(new GregtechMetaTileEntityChunkLoader(ID++, "chunkloader.tier.02", "Chunkloader MK II", 5) + .getStackForm(1L)); + GregtechItemList.GT_Chunkloader_ZPM + .set(new GregtechMetaTileEntityChunkLoader(ID++, "chunkloader.tier.03", "Chunkloader MK III", 7) + .getStackForm(1L)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java new file mode 100644 index 0000000000..2a4a2b9f85 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java @@ -0,0 +1,58 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredTank; + +public class GregtechTieredFluidTanks { + public static void run() { + if (LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Portable Fluid Tanks."); + if (CORE.ConfigSwitches.enableMachine_FluidTanks) { + run1(); + } + } + + } + + private static void run1() { + int ID = 817; + if (CORE.GTNH) { + Logger.INFO("Only loading ULV-IV tier tanks for New Horizons Modpack."); + } + GregtechItemList.GT_FluidTank_ULV + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.00", "Ultra Low Voltage Fluid Tank", 0) + .getStackForm(1L)); + GregtechItemList.GT_FluidTank_LV + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.01", "Low Voltage Fluid Tank", 1) + .getStackForm(1L)); + GregtechItemList.GT_FluidTank_MV + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.02", "Medium Voltage Fluid Tank", 2) + .getStackForm(1L)); + GregtechItemList.GT_FluidTank_HV + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.03", "High Voltage Fluid Tank", 3) + .getStackForm(1L)); + if (!CORE.GTNH) { + GregtechItemList.GT_FluidTank_EV + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.04", "Extreme Voltage Fluid Tank", 4) + .getStackForm(1L)); + GregtechItemList.GT_FluidTank_IV + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.05", "Insane Voltage Fluid Tank", 5) + .getStackForm(1L)); + GregtechItemList.GT_FluidTank_LuV + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.06", "Ludicrous Voltage Fluid Tank", 6) + .getStackForm(1L)); + GregtechItemList.GT_FluidTank_ZPM + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.07", "ZPM Voltage Fluid Tank", 7) + .getStackForm(1L)); + GregtechItemList.GT_FluidTank_UV + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.08", "Ultimate Voltage Fluid Tank", 8) + .getStackForm(1L)); + GregtechItemList.GT_FluidTank_MAX + .set(new GT_MetaTileEntity_TieredTank(ID++, "fluidtank.tier.09", "MAX Voltage Fluid Tank", 9) + .getStackForm(1L)); + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTreeFarmerTE.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTreeFarmerTE.java new file mode 100644 index 0000000000..07139da024 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTreeFarmerTE.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GregtechMetaTreeFarmerStructural; + +public class GregtechTreeFarmerTE { + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Tree Farmer Structural Block."); + if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer) { + run1(); + } + } + } + + private static void run1() { + GregtechItemList.TreeFarmer_Structural.set( + new GregtechMetaTreeFarmerStructural(752, "treefarmer.structural", "Farm Keeper", 0).getStackForm(1L)); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java new file mode 100644 index 0000000000..ca90724400 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java @@ -0,0 +1,48 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; + +public class GregtechWirelessChargers { + + + public static void run(){ + + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Logger.INFO("Gregtech5u Content | Registering Wireless Chargers."); + + + long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED; + int mID = 890; + + Utils.registerEvent(new ChargingHelper()); + + GregtechItemList.Charger_LV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.01.tier.single", + "Wireless Charger MK I", 1, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_MV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.02.tier.single", + "Wireless Charger MK II", 2, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_HV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.03.tier.single", + "Wireless Charger MK III", 3, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_EV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.04.tier.single", + "Wireless Charger MK IV", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_IV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.05.tier.single", + "Wireless Charger MK V", 5, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_LuV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.06.tier.single", + "Wireless Charger MK VI", 6, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_ZPM.set(new GregtechMetaWirelessCharger(mID++, "wificharger.07.tier.single", + "Wireless Charger MK VII", 7, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_UV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.08.tier.single", + "Wireless Charger MK VIII", 8, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_MAX.set(new GregtechMetaWirelessCharger(mID++, "wificharger.09.tier.single", + "Wireless Charger MK IX", 9, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + + } + } + +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/NewHorizonsAccelerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/NewHorizonsAccelerator.java new file mode 100644 index 0000000000..d5b95a61bf --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/NewHorizonsAccelerator.java @@ -0,0 +1,99 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_ModHandler; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_WorldAccelerator; + +public class NewHorizonsAccelerator { + + public static void run() { + if (LoadedMods.Gregtech && !CORE.GTNH) { + Logger.INFO("New Horizons Content | Registering World Accelerators."); + if (CORE.ConfigSwitches.enableMachine_WorldAccelerators) { + run1(); + } + } + + } + + private static void run1() { + GregtechItemList.AcceleratorLV.set(new GT_MetaTileEntity_WorldAccelerator(841, + "basicmachine.accelerator.tier.01", "Basic World Accelerator", 1).getStackForm(1L)); + GregtechItemList.AcceleratorMV.set(new GT_MetaTileEntity_WorldAccelerator(842, + "basicmachine.accelerator.tier.02", "Advanced World Accelerator", 2).getStackForm(1L)); + GregtechItemList.AcceleratorHV.set(new GT_MetaTileEntity_WorldAccelerator(843, + "basicmachine.accelerator.tier.03", "Advanced World Accelerator II", 3).getStackForm(1L)); + GregtechItemList.AcceleratorEV.set(new GT_MetaTileEntity_WorldAccelerator(844, + "basicmachine.accelerator.tier.04", "Advanced World Accelerator III", 4).getStackForm(1L)); + GregtechItemList.AcceleratorIV.set(new GT_MetaTileEntity_WorldAccelerator(845, + "basicmachine.accelerator.tier.05", "Advanced World Accelerator IV", 5).getStackForm(1L)); + GregtechItemList.AcceleratorLuV.set(new GT_MetaTileEntity_WorldAccelerator(846, + "basicmachine.accelerator.tier.06", "Elite World Accelerator", 6).getStackForm(1L)); + GregtechItemList.AcceleratorZPM.set(new GT_MetaTileEntity_WorldAccelerator(847, + "basicmachine.accelerator.tier.07", "Elite World Accelerator II", 7).getStackForm(1L)); + GregtechItemList.AcceleratorUV.set(new GT_MetaTileEntity_WorldAccelerator(848, + "basicmachine.accelerator.tier.08", "Ultimate Time Anomaly", 8).getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.AcceleratorLV.get(1L), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "RMR", "PBC", "IMI", 'R', ItemList.Robot_Arm_LV, 'M', ItemList.Electric_Motor_LV, 'P', + ItemList.Electric_Pump_LV, 'B', ItemList.Hull_LV, 'C', ItemList.Conveyor_Module_LV, 'I', + ItemList.Electric_Piston_LV }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.AcceleratorMV.get(1L), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "RMR", "PBC", "IMI", 'R', ItemList.Robot_Arm_MV, 'M', ItemList.Electric_Motor_MV, 'P', + ItemList.Electric_Pump_MV, 'B', ItemList.Hull_MV, 'C', ItemList.Conveyor_Module_MV, 'I', + ItemList.Electric_Piston_MV }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.AcceleratorHV.get(1L), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "RMR", "PBC", "IMI", 'R', ItemList.Robot_Arm_HV, 'M', ItemList.Electric_Motor_HV, 'P', + ItemList.Electric_Pump_HV, 'B', ItemList.Hull_HV, 'C', ItemList.Conveyor_Module_HV, 'I', + ItemList.Electric_Piston_HV }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.AcceleratorEV.get(1L), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "RMR", "PBC", "IMI", 'R', ItemList.Robot_Arm_EV, 'M', ItemList.Electric_Motor_EV, 'P', + ItemList.Electric_Pump_EV, 'B', ItemList.Hull_EV, 'C', ItemList.Conveyor_Module_EV, 'I', + ItemList.Electric_Piston_EV }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.AcceleratorIV.get(1L), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "RMR", "PBC", "IMI", 'R', ItemList.Robot_Arm_IV, 'M', ItemList.Electric_Motor_IV, 'P', + ItemList.Electric_Pump_IV, 'B', ItemList.Hull_IV, 'C', ItemList.Conveyor_Module_IV, 'I', + ItemList.Electric_Piston_IV }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.AcceleratorLuV.get(1L), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "RMR", "PBC", "IMI", 'R', ItemList.Robot_Arm_LuV, 'M', ItemList.Electric_Motor_LuV, 'P', + ItemList.Electric_Pump_LuV, 'B', ItemList.Hull_LuV, 'C', ItemList.Conveyor_Module_LuV, 'I', + ItemList.Electric_Piston_LuV }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.AcceleratorZPM.get(1L), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "RMR", "PBC", "IMI", 'R', ItemList.Robot_Arm_ZPM, 'M', ItemList.Electric_Motor_ZPM, 'P', + ItemList.Electric_Pump_ZPM, 'B', ItemList.Hull_ZPM, 'C', ItemList.Conveyor_Module_ZPM, 'I', + ItemList.Electric_Piston_ZPM }); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.AcceleratorUV.get(1L), + GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "RMR", "PBC", "IMI", 'R', ItemList.Robot_Arm_UV, 'M', ItemList.Electric_Motor_UV, 'P', + ItemList.Electric_Pump_UV, 'B', ItemList.Hull_UV, 'C', ItemList.Conveyor_Module_UV, 'I', + ItemList.Electric_Piston_UV }); + } + +} |