diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
33 files changed, 1666 insertions, 326 deletions
diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java b/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java index ea9b61bb2e..f5e1d429f7 100644 --- a/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java @@ -10,9 +10,11 @@ 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.helpers.MaterialHelper; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.bop.blocks.rainforest.LeavesRainforestTree; import gtPlusPlus.xmod.bop.blocks.rainforest.LogRainforestTree; @@ -136,17 +138,41 @@ public class BOP_Block_Registrator { } public static void addPyrolyeOvenRecipes(final ItemStack logStack) { - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 1, Materials.Charcoal.getGems(20), Materials.Creosote.getFluid(4000L), 640, 64); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 2, Materials.Charcoal.getGems(20), Materials.Creosote.getFluid(4000L), 320, 96); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 3, Materials.Ash.getDust(4), Materials.OilHeavy.getFluid(200L), 320, 192); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 3, Materials.Charcoal.getGems(20), Materials.CharcoalByproducts.getGas(4000L), 640, 64); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 4, Materials.Charcoal.getGems(20), Materials.CharcoalByproducts.getGas(4000L), 320, 96); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 5, Materials.Charcoal.getGems(20), Materials.WoodGas.getGas(1500L), 640, 64); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 6, Materials.Charcoal.getGems(20), Materials.WoodGas.getGas(1500L), 320, 96); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 7, Materials.Charcoal.getGems(20), Materials.WoodVinegar.getFluid(3000L), 640, 64); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 8, Materials.Charcoal.getGems(20), Materials.WoodVinegar.getFluid(3000L), 320, 96); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 9, Materials.Charcoal.getGems(20), Materials.WoodTar.getFluid(1500L), 640, 64); - GT_Values.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 10, Materials.Charcoal.getGems(20), Materials.WoodTar.getFluid(1500L), 320, 96); + + Materials aOilHeavy = MaterialUtils.getMaterial("OilHeavy"); + Materials aCharcoalByproducts = MaterialUtils.getMaterial("CharcoalByproducts"); + Materials aWoodGas = MaterialUtils.getMaterial("WoodGas"); + Materials aWoodVinegar = MaterialUtils.getMaterial("WoodVinegar"); + Materials aWoodTar = MaterialUtils.getMaterial("WoodTar"); + + + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 1, MaterialHelper.getGems(Materials.Charcoal, 20), Materials.Creosote.getFluid(4000L), 640, 64); + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 2, MaterialHelper.getGems(Materials.Charcoal, 20), Materials.Creosote.getFluid(4000L), 320, 96); + + if (aOilHeavy != null) { + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 3, MaterialHelper.getDust(Materials.Ash, 4), aOilHeavy.getFluid(200L), 320, 192); + + } + if (aCharcoalByproducts != null) { + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 3, MaterialHelper.getGems(Materials.Charcoal, 20), aCharcoalByproducts.getGas(4000L), 640, 64); + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 4, MaterialHelper.getGems(Materials.Charcoal, 20), aCharcoalByproducts.getGas(4000L), 320, 96); + + } + if (aWoodGas != null) { + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 5, MaterialHelper.getGems(Materials.Charcoal, 20), aWoodGas.getGas(1500L), 640, 64); + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 6, MaterialHelper.getGems(Materials.Charcoal, 20), aWoodGas.getGas(1500L), 320, 96); + + } + if (aWoodVinegar != null) { + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 7, MaterialHelper.getGems(Materials.Charcoal, 20), aWoodVinegar.getFluid(3000L), 640, 64); + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 8, MaterialHelper.getGems(Materials.Charcoal, 20), aWoodVinegar.getFluid(3000L), 320, 96); + + } + if (aWoodTar != null) { + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), GT_Values.NF, 9, MaterialHelper.getGems(Materials.Charcoal, 20), aWoodTar.getFluid(1500L), 640, 64); + CORE.RA.addPyrolyseRecipe(GT_Utility.copyAmount(16L, logStack), Materials.Nitrogen.getGas(1000L), 10, MaterialHelper.getGems(Materials.Charcoal, 20), aWoodTar.getFluid(1500L), 320, 96); + + } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 42354e49e1..80839f0f64 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -19,9 +19,11 @@ 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.NoOutputBonusMultiBehaviour; import gtPlusPlus.australia.gen.gt.WorldGen_GT_Australia; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.OldCircuitHandler; @@ -30,8 +32,10 @@ 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.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; @@ -46,6 +50,7 @@ import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricButcherKnife; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricLighter; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricSnips; import gtPlusPlus.xmod.gregtech.loaders.ProcessingToolHeadChoocher; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; import gtPlusPlus.xmod.gregtech.recipes.RecipesToRemove; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechNitroDieselFix; @@ -123,6 +128,9 @@ public class HANDLER_GT { } + // Register the No-Bonus Special Behaviour. + Multiblock_API.registerSpecialMultiBehaviour(new NoOutputBonusMultiBehaviour()); + //Register some custom recipe maps for any enabled multiblocks. //MultiblockRecipeMapHandler.run(); } @@ -136,17 +144,22 @@ public class HANDLER_GT { RecipesToRemove.go(); convertPyroToCokeOven(); Meta_GT_Proxy.fixIC2FluidNames(); + RecipeLoader_AlgaeFarm.generateRecipes(); } private static void convertPyroToCokeOven() { - int aCount = 0; - for (GT_Recipe g : GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.mRecipeList) { - if (AddGregtechRecipe.importPyroRecipe(g)) { - aCount++; + 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."); } - } - Logger.INFO("Converted "+aCount+" Pyrolyse recipes into Industrial Coke Oven recipes."); - + } } private static GT_Recipe replaceItemInRecipeWithAnother(GT_Recipe aRecipe, ItemStack aExisting, ItemStack aNewItem) { @@ -349,6 +362,10 @@ public class HANDLER_GT { 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, @@ -360,13 +377,13 @@ public class HANDLER_GT { new Object[]{"PHP", "CMC", 'M', ItemList.Casing_ZPM, 'C', OrePrefixes.cableGt01.get(Materials.Naquadah), 'H', CI.getPlate(aTier_ZPM, 1), 'P', - OrePrefixes.plate.get(Materials.Polytetrafluoroethylene)}); + 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(Materials.Polytetrafluoroethylene)}); + 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', diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 3fc6d9d667..7c395392a3 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -113,6 +113,9 @@ public enum GregtechItemList implements GregtechItemContainer { Bomb_Cast_Set, Bomb_Cast_Broken, Bomb_Cast_Mold, + // Pellet Mold + Pellet_Mold, + //Charged Items for Tree Farms Farm_Processor_EV, Farm_Processor_IV, @@ -231,7 +234,9 @@ public enum GregtechItemList implements GregtechItemContainer { //Algae AlgaeFarm_Controller, - + + //Chemical Plant + ChemicalPlant_Controller, //GT4 autoCrafter GT4_Multi_Crafter, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index ceb2685b7f..83f052a983 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -275,5 +275,13 @@ public interface IGregtech_RecipeAdder { 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); + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java index f6bec1f402..6967c8eb33 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -1,7 +1,9 @@ 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; @@ -9,19 +11,39 @@ import gregtech.api.enums.GT_Values; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; -import gregtech.common.GT_Pollution; 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(); @@ -74,7 +96,14 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { this.mReleaseEnergy = false; this.mMetaTileEntity.onExplosion(); int i; - if (GT_Mod.gregtechproxy.mExplosionItemDrop) { + + 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)) { @@ -95,6 +124,38 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { } } + + + 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>(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java index 19ba932a02..2eb1d36791 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java @@ -11,11 +11,11 @@ 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.objects.XSTR; 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; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java index d9e2692b09..752321506d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java @@ -31,11 +31,11 @@ public class GT_MetaTileEntity_Hatch_TurbineProvider extends GT_MetaTileEntity_H } public GT_MetaTileEntity_Hatch_TurbineProvider(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); + super(aName, aTier, aDescription[0], aTextures); } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_TurbineProvider(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + return new GT_MetaTileEntity_Hatch_TurbineProvider(this.mName, this.mTier, this.mDescription, this.mTextures); } public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 827091301b..4a6cad20c3 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -6,6 +6,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.concurrent.TimeUnit; @@ -40,14 +41,15 @@ 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.AutoMap; import gtPlusPlus.api.objects.data.ConcurrentHashSet; import gtPlusPlus.api.objects.data.ConcurrentSet; import gtPlusPlus.api.objects.data.FlexiblePair; -import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.data.Triplet; 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; @@ -65,7 +67,6 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEn 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.objects.MultiblockRequirements; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -78,14 +79,10 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; -public abstract class GregtechMeta_MultiBlockBase -extends -GT_MetaTileEntity_MultiBlockBase { - +public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_MultiBlockBase { 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); @@ -102,11 +99,10 @@ GT_MetaTileEntity_MultiBlockBase { try { calculatePollutionReduction = GT_MetaTileEntity_Hatch_Muffler.class.getDeclaredMethod("calculatePollutionReduction", int.class); - } catch (NoSuchMethodException | SecurityException e) {} - - - //gregtech.api.util.GT_Recipe.GT_Recipe_Map.findRecipe(IHasWorldObjectAndCoords, GT_Recipe, boolean, long, FluidStack[], ItemStack, ItemStack...) + } catch (NoSuchMethodException | SecurityException e) {} + mCustomBehviours = new HashMap<String, SpecialMultiBehaviour>(); + } //Find Recipe Methods @@ -124,6 +120,10 @@ GT_MetaTileEntity_MultiBlockBase { 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>(); + // Custom Behaviour Map + private static final HashMap<String, SpecialMultiBehaviour> mCustomBehviours; + + public GregtechMeta_MultiBlockBase(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); @@ -471,15 +471,30 @@ GT_MetaTileEntity_MultiBlockBase { public String getSound() { return ""; } + public boolean canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) { + return canBufferOutputs(aRecipe, aParallelRecipes, true); + } + + public boolean canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes, boolean aAllow16SlotWithoutCheck) { Logger.INFO("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. + // Do it anyway, provided the multi allows it. Default behaviour is aAllow16SlotWithoutCheck = true. if (aRecipe == null || aRecipe.mOutputs.length > 16) { - return aRecipe == null ? false : true; + if (aRecipe == null) { + return false; + } + else if (aRecipe.mOutputs.length > 16) { + if (aAllow16SlotWithoutCheck) { + return true; + } + else { + // Do nothing, we want to check this recipe properly. + } + } } // Do we even need to check for item outputs? @@ -999,12 +1014,11 @@ GT_MetaTileEntity_MultiBlockBase { 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); - + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + log("Running checkRecipeGeneric(1)"); // Remember last recipe - an optimization for findRecipe() this.mLastRecipe = tRecipe; @@ -1013,6 +1027,50 @@ GT_MetaTileEntity_MultiBlockBase { log("BAD RETURN - 1"); return false; } + + + /* + * Check for Special Behaviours + */ + + // First populate the map if we need to. + if (mCustomBehviours == null || 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; + } + } + } + } + } if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { log("BAD RETURN - 2"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java new file mode 100644 index 0000000000..74655fb744 --- /dev/null +++ b/src/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/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index aad05f1730..430ae44d64 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -482,7 +482,7 @@ public class Meta_GT_Proxy { * @deprecated Use {@link StaticFields59#getFieldFromGregtechProxy(boolean,String)} instead */ public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { - return StaticFields59.getFieldFromGregtechProxy(fieldName); + return StaticFields59.getFieldFromGregtechProxy(client, fieldName); } public static void setCustomGregtechTooltip(String aNbtTagName, FormattedTooltipString aData) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index 9c552db3ad..814ed589f0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -18,6 +18,7 @@ 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; @@ -37,6 +38,7 @@ public class StaticFields59 { 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; @@ -79,8 +81,16 @@ public class StaticFields59 { } sAssemblylineVisualRecipes = aTemp; + mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); - Logger.INFO("[SH] Got Field: 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); @@ -148,6 +158,14 @@ public class StaticFields59 { } } + 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) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java index c62d47e904..01f655c355 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GTPP_Block_Machines.java @@ -15,13 +15,13 @@ 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.objects.XSTR; 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; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java index 4c534eb7bb..8e6a55c9c5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java @@ -66,6 +66,7 @@ extends GregtechMetaCasingBlocksAbstract { 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"); 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)); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java index 321ab43134..b624649789 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java @@ -138,7 +138,7 @@ extends GregtechMetaCasingBlocksAbstract { return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); case 15: default: - return TexturesGtBlock.Overlay_UU_Matter.getIcon(); + return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java index 561da54ceb..65b59ce151 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java @@ -9,6 +9,7 @@ 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; @@ -37,7 +38,7 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - PlayerUtils.messagePlayer(aPlayer, this.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); + PlayerUtils.messagePlayer(aPlayer, LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable)); return super.onCoverRightclick(aSide, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); } @@ -71,7 +72,7 @@ public class GTPP_Cover_ToggleVisual extends GT_CoverBehavior { } public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return this.trans("756", "Connectable: ") + getConnectionState(aCoverVariable); + return LangUtils.trans("756", "Connectable: ") + getConnectionState(aCoverVariable); } public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java new file mode 100644 index 0000000000..d51107bbf0 --- /dev/null +++ b/src/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/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java index c884114b79..35d78008c5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java @@ -10,10 +10,9 @@ 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.blocks.GT_Block_Ores_Abstract; -import gregtech.common.blocks.GT_TileEntity_Ores; 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; @@ -134,14 +133,15 @@ public class GTPP_Render_MachineBlock extends GT_Renderer_Block { 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[][]{((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 0), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 1), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 2), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 3), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 4), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 5)}) + 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; } @@ -190,7 +190,7 @@ public class GTPP_Render_MachineBlock extends GT_Renderer_Block { ITexture[][] tCovers = new ITexture[6][]; for (byte i = 0; i < 6; ++i) { - tCovers[i] = aTileEntity.getTexture(aBlock, i); + tCovers[i] = GT_MethodHelper.getTexture((TileEntity) aTileEntity, aBlock, i); arg15[i] = aTileEntity.getTextureUncovered(i); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java index 7717bf6379..b7e4618e07 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java @@ -13,12 +13,12 @@ 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.objects.XSTR; 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.Recipe_GT; +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; @@ -311,13 +311,6 @@ public class GregtechMetaTileEntity_ChemicalReactor extends GT_MetaTileEntity_Ba if (this.mProgresstime > 5) { this.mStuttering = false; } - - XSTR aXSTR = new XSTR(); - if (GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000) == 0) { - GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), - (String) GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), - aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()); - } } } else { aBaseMetaTileEntity.setActive(false); @@ -510,11 +503,6 @@ public class GregtechMetaTileEntity_ChemicalReactor extends GT_MetaTileEntity_Ba } @Override - public int checkRecipe(boolean skipOC) { - return super.checkRecipe(skipOC); - } - - @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); @@ -616,11 +604,6 @@ public class GregtechMetaTileEntity_ChemicalReactor extends GT_MetaTileEntity_Ba } @Override - protected void onEmptyingContainerWhenEmpty() { - super.onEmptyingContainerWhenEmpty(); - } - - @Override public void setItemNBT(NBTTagCompound aNBT) { super.setItemNBT(aNBT); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java index 064dc8372b..82de41f186 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java @@ -184,6 +184,8 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta return false; } + private volatile int mGraceTimer = 2; + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { /*if (this.getBaseMetaTileEntity().isActive()) { @@ -192,5 +194,19 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta } } */ 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/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index 69197c8140..ab7fb79c4b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -188,6 +188,8 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase } } } + + // TODO - Fix Casing Count return true; } @@ -420,6 +422,7 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase if (mGraceTimer-- == 0) { this.causeMaintenanceIssue(); this.stopMachine(); + mGraceTimer = 2; } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java index 23ca94e54d..6f9080673f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java @@ -17,16 +17,11 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; -import gregtech.common.GT_Pollution; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java index 004fd8d94e..fda79876f6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java @@ -3,32 +3,29 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.a 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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; -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.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.chemistry.AgriculturalChem; -import gtPlusPlus.core.util.math.MathUtils; 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; @@ -68,9 +65,8 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { "X X", "X X", "XXXXXXXXX", - "Can process (Tier * 10) recipes", "Machine Hulls (all bottom layer)", - "Sterile Farm Casings (all non-hatches)", + "Sterile Farm Casings (rest)", "Controller (front centered)", "All hatches must be on the bottom layer", "All hulls must be the same tier, this dictates machine speed", @@ -78,7 +74,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { "1x Output Bus", "1x Input Bus (optional)", "1x Input Hatch (fill with water)", - }; + }; } @Override @@ -116,7 +112,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { @Override public int getMaxParallelRecipes() { - return (this.mLevel+1) * 10; + return 2; } @Override @@ -161,13 +157,9 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { return false; } else { - mLevel = aCasingMeta; + mLevel = this.getCasingTierOnClientSide(); } - - - /* - * if (!(aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir))) { return false; } - */ + int aID = TAE.getIndexFromPage(1, 15); int tAmount = 0; check : for (int i = mOffsetX_Lower; i <= mOffsetX_Upper; ++i) { for (int j = mOffsetZ_Lower; j <= mOffsetZ_Upper; ++j) { @@ -175,8 +167,8 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) { IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - Logger.INFO("X: " + i + " | Z: " + j+" | Tier: "+mLevel); - if (h == -1 && tTileEntity != null && addToMachineList(tTileEntity, mLevel)) { + Logger.INFO("X: " + i + " | Z: " + j+" | Tier: "+aID); + if (h == -1 && tTileEntity != null && addToMachineList(tTileEntity, aID)) { continue; } else if (h != -1 && tTileEntity != null) { @@ -231,14 +223,15 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { } if ((tAmount >= 64)) { Logger.INFO("Made structure."); + this.getBaseMetaTileEntity().getWorld().markBlockForUpdate(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); } else { Logger.INFO("Did not make structure."); } return (tAmount >= 64); } - public boolean checkForWater() { - + public boolean checkForWater() { + // Get Facing direction IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; @@ -296,9 +289,9 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { } } } - + boolean isValidWater = tAmount >= 60; - + if (isValidWater) { Logger.INFO("Filled structure."); return true; @@ -341,7 +334,12 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); - this.fixAllMaintenanceIssue(); + this.fixAllMaintenanceIssue(); + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mLevel = getCasingTierOnClientSide(); + } + } @Override @@ -357,20 +355,10 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { if (this.mLevel < 0) { Logger.INFO("Bad Tier."); return false; - } - - if (mRecipeCache.isEmpty()) { - Logger.INFO("Generating Recipes."); - generateRecipes(); } - - if (mRecipeCache.isEmpty() || !checkForWater()) { - if (mRecipeCache.isEmpty()) { - Logger.INFO("No Recipes."); - } - if (!checkForWater()) { - Logger.INFO("Not enough Water."); - } + + if (!checkForWater()) { + Logger.INFO("Not enough Water."); return false; } @@ -382,7 +370,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { Logger.INFO("Running checkRecipeGeneric(0)"); - GT_Recipe tRecipe = getTieredRecipeFromCache(this.mLevel); + GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); this.mLastRecipe = tRecipe; @@ -390,7 +378,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { return false; } - if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { + if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes, false)) { return false; } @@ -398,33 +386,11 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { // -- 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 * 24); - + this.mMaxProgresstime = (int)(tRecipe.mDuration); this.mEUt = 0; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << mLevel - 1) * (1 << mLevel - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << mLevel - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(mLevel - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - + this.mEfficiencyIncrease = 10000; + Logger.INFO("Recipe time: "+this.mMaxProgresstime); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); // Collect fluid outputs @@ -508,115 +474,29 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase { } return false; } - - private GT_Recipe generateAlgaeOutput(boolean aUsingCompost) { - - // Type Safety - if (this.mLevel < 0) { - return null; + + @SideOnly(Side.CLIENT) + private final int getCasingTierOnClientSide() { + if (this == null || this.getBaseMetaTileEntity().getWorld() == null) { + return 0; } - int[] aBrownChance = new int[] { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, - 5, 5, - 6, 7, 8, 9, 10 - }; - int[] aGoldChance = new int[] { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, - 3, 3, 3, - 4, 4, - 5 - }; - int[] aRedChance = new int[] { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 2 - }; - - ItemStack aAlgaeBasic = ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(20, 60)); - ItemStack aAlgaeBasic2 = ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(20, 60)); - ItemStack aAlgaeGreen = ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(10, 60)); - ItemStack aAlgaeBrown = ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.getRandomFromArray(aBrownChance)); - ItemStack aAlgaeGoldenBrown = ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.getRandomFromArray(aGoldChance)); - ItemStack aAlgaeRed = ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.getRandomFromArray(aRedChance)); - - // Make it use 8 compost if we have some available - ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 8); - ItemStack[] aInputs = new ItemStack[] {}; - if (aUsingCompost) { - aInputs = new ItemStack[] { - aCompost - }; + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, -1, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, -1, 0); + if (aInitStructureCheck == GregTech_API.sBlockCasings1) { + return aInitStructureCheckMeta; + } + return 0; } - - ItemStack[] aOutputs = new ItemStack[] { - aAlgaeBasic, aAlgaeBasic2, aAlgaeGreen, - aAlgaeBrown, aAlgaeGoldenBrown, - aAlgaeRed - }; - - // 20 ticks per second, 60 seconds per minute, 20 minutes per MC day, divide by 24 portions. - int aMinecraftHour = (20 * 60 * 20 / 24); - - GT_Recipe tRecipe = new Recipe_GT( - false, - aInputs, - aOutputs, - (Object) null, - new int[] {}, - new FluidStack[] {GT_Values.NF}, - new FluidStack[] {GT_Values.NF}, - aMinecraftHour * MathUtils.randInt(24, 72), // Time - 0, - 0); - - - return tRecipe; - } - - - - - private static final HashMap<Integer, AutoMap<GT_Recipe>> mRecipeCache = new HashMap<Integer, AutoMap<GT_Recipe>>(); - - private final void generateRecipes() { - for (int i=0;i<10;i++) { - getTieredRecipeFromCache(i); + catch (Throwable t) { + t.printStackTrace(); + return 0; } } - public GT_Recipe getTieredRecipeFromCache(int aTier) { - - AutoMap<GT_Recipe> aTemp = mRecipeCache.get(aTier); - if (aTemp == null || aTemp.isEmpty()) { - aTemp = new AutoMap<GT_Recipe>(); - mRecipeCache.put(aTier, aTemp); - } - if (aTemp.size() < 500) { - for (int i=aTemp.size();i<500;i++) { - aTemp.put(generateAlgaeOutput(false)); - } - } - int aIndex = MathUtils.randInt(0, aTemp.isEmpty() ? 1 : aTemp.size()); - return aTemp.get(aIndex); - } - - - - - - - - - } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java new file mode 100644 index 0000000000..654d036bf8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -0,0 +1,823 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant; + +import static gregtech.api.enums.GT_Values.E; + +import java.util.HashSet; + +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_TieredMachineBlock; +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.Recipe_GT; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +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.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +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.minecraftforge.common.util.ForgeDirection; + +public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { + + private int mSolidCasingTier = 0; + private int mMachineCasingTier = 0; + private int mPipeCasingTier = 0; + private int mCoilTier = 0; + + /** + * Internal Recipe Map which holds the actual recipes, backed by the real map, shown by NEI. + */ + private static final GT_Recipe_Map mFluidChemicalReactorRecipes = new GT_Recipe_Map( + new HashSet<GT_Recipe>(100), + "gt.recipe.fluidchemicaleactor", + "Chemical Plant", + null, + CORE.MODID+":textures/gui/FluidReactor", + 0, + 0, + 0, + 2, + 1, + "Tier: ", + 1, + E, + true, + false); + + + public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_ChemicalPlant(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_ChemicalPlant(this.mName); + } + + @Override + public String getMachineType() { + return "Chemical Plant"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Heavy Industry, now right at your doorstep!", + "Controller Block for the Chemical Plant", + "27 Coils", + "18 Pipe Casings", + "57 Tiered Machine Casings", + "80+ Solid Casings", + "Hatch tier is limited to Machine Casing tier", + }; + } + + @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) { + + } + // Check the Tier Client Side + int aTier = mSolidCasingTier; + + if (aTier == 1) { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[16]; + } + else if (aTier == 2) { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[49]; + } + else if (aTier == 3) { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[50]; + } + else if (aTier == 4) { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[48]; + } + else { + aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[11]; + } + + + 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 false; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (mFluidChemicalReactorRecipes.mRecipeList.isEmpty() || mFluidChemicalReactorRecipes.mRecipeList.size() != Recipe_GT.Gregtech_Recipe_Map.sFluidChemicalReactorRecipes.mRecipeList.size()) { + if (!mFluidChemicalReactorRecipes.mRecipeList.isEmpty()) { + mFluidChemicalReactorRecipes.mRecipeList.clear(); + } + for (Recipe_GT i : Recipe_GT.Gregtech_Recipe_Map.sFluidChemicalReactorRecipes.mRecipeList) { + mFluidChemicalReactorRecipes.add(i); + } + } + return mFluidChemicalReactorRecipes; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public int getMaxParallelRecipes() { + return 2 * getPipeCasingTier(); + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + private int getSolidCasingTier() { + return mSolidCasingTier; + } + + private int getMachineCasingTier() { + return mMachineCasingTier; + } + private int getPipeCasingTier() { + return mPipeCasingTier; + } + private int getCoilTier() { + return mCoilTier; + } + + private int getCasingTextureID() { + // Check the Tier Client Side + int aTier = mSolidCasingTier; + + if (aTier == 1) { + return 16; + } + else if (aTier == 2) { + return 49; + } + else if (aTier == 3) { + return 50; + } + else if (aTier == 4) { + return 48; + } + else { + return 11; + } + } + + 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 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"); + } + + private static boolean isBlockSolidCasing(Block aBlock, int aMeta) { + if (aBlock == null) { + return false; + } + if (aBlock == GregTech_API.sBlockCasings2 && aMeta == 0) { + return true; + } + if (aBlock == GregTech_API.sBlockCasings4) { + int aMetaStainlessCasing = 1; + int aMetaTitaniumCasing = 2; + int aMetaTungstenCasing = 0; + if (aMeta == aMetaStainlessCasing || aMeta == aMetaTitaniumCasing || aMeta == aMetaTungstenCasing) { + return true; + } + } + return false; + } + private static boolean isBlockMachineCasing(Block aBlock, int aMeta) { + Block aCasingBlock1 = GregTech_API.sBlockCasings1; + if (aBlock == aCasingBlock1) { + if (aMeta > 9 || aMeta < 0) { + return false; + } + else { + return true; + } + } + else { + return false; + } + } + private static boolean isBlockPipeCasing(Block aBlock, int aMeta) { + Block aCasingBlock2 = GregTech_API.sBlockCasings2; + if (aBlock == aCasingBlock2) { + int aMetaBronzePipeCasing = 12; + int aMetaSteelPipeCasing = 13; + int aMetaTitaniumPipeCasing = 14; + int aMetaTungstenPipeCasing = 15; + if (aMeta > aMetaTungstenPipeCasing || aMeta < aMetaBronzePipeCasing) { + return false; + } + else { + return true; + } + } + else { + return false; + } + } + + private static AutoMap<Integer> mValidCoilMetaCache; + + private static boolean isBlockCoil(Block aBlock, int aMeta) { + Block aCasingBlock; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + aCasingBlock = StaticFields59.getBlockCasings5(); + } + else { + aCasingBlock = GregTech_API.sBlockCasings1; + } + // Cache the meta values for later + if (mValidCoilMetaCache == null || mValidCoilMetaCache.isEmpty()) { + AutoMap<Integer> aValidCoilMeta = new AutoMap<Integer>(); + // Only use the right meta values available. + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + aValidCoilMeta = Meta_GT_Proxy.GT_ValidHeatingCoilMetas; + } + else { + aValidCoilMeta.put(12); + aValidCoilMeta.put(13); + aValidCoilMeta.put(14); + } + mValidCoilMetaCache = aValidCoilMeta; + } + if (aBlock == aCasingBlock) { + for (int i: mValidCoilMetaCache.values()) { + if (i == aMeta) { + return true; + } + } + } + return false; + } + + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 3; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 3; + + int tAmount = 0; + Logger.INFO("Checking ChemPlant Structure"); + + // Require Air above controller + boolean aAirCheck = aBaseMetaTileEntity.getAirOffset(0, 1, 0); + + if (!aAirCheck) { + Logger.INFO("No Air Above Controller"); + return false; + } else { + + //String aName = aInitStructureCheck != null ? ItemUtils.getLocalizedNameOfBlock(aInitStructureCheck, aInitStructureCheckMeta) : "Air"; + + mSolidCasingTier = getSolidCasingTierCheck(aBaseMetaTileEntity, xDir, zDir); + mMachineCasingTier = getMachineCasingTierCheck(aBaseMetaTileEntity, xDir, zDir); + + Logger.INFO("Initial Casing Check Complete, Solid Casing Tier: "+mSolidCasingTier+", Machine Casing Tier: "+mMachineCasingTier); + + int aSolidCasingCount = 0; + int aMachineCasingCount = 0; + int aPipeCount = 0; + int aCoilCount = 0; + + aSolidCasingCount = checkSolidCasings(aBaseMetaTileEntity, aStack, xDir, zDir); + aMachineCasingCount = checkMachineCasings(aBaseMetaTileEntity, aStack, xDir, zDir); + aPipeCount = checkPipes(aBaseMetaTileEntity, aStack, xDir, zDir); + aCoilCount = checkCoils(aBaseMetaTileEntity, aStack, xDir, zDir); + + Logger.INFO("Casing Counts: "); + Logger.INFO("Solid: "+aSolidCasingCount+", Machine: "+aMachineCasingCount); + Logger.INFO("Pipe: "+aPipeCount+", Coil: "+aCoilCount); + + + Logger.INFO("Casing Tiers: "); + Logger.INFO("Solid: "+getSolidCasingTier()+", Machine: "+getMachineCasingTier()); + Logger.INFO("Pipe: "+getPipeCasingTier()+", Coil: "+getCoilTier()); + + // Attempt to sync fields here, so that it updates client side values. + aBaseMetaTileEntity.getWorld().markBlockForUpdate(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()); + + + + // Minimum 80/93 Solid Casings + if (aSolidCasingCount < 80) { + Logger.INFO("Not enough solid casings. Found "+aSolidCasingCount+", require: 80."); + return false; + } + if (aMachineCasingCount != 57) { + Logger.INFO("Not enough machine casings. Found "+aMachineCasingCount+", require: 57."); + return false; + } + if (aPipeCount != 18) { + Logger.INFO("Not enough pipe casings. Found "+aPipeCount+", require: 18."); + return false; + } + if (aCoilCount != 27) { + Logger.INFO("Not enough coils. Found "+aCoilCount+", require: 27."); + return false; + } + + Logger.INFO("Structure Check Complete!"); + + return true; + } + } + + + public int checkCoils(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + int tAmount = 0; + int aCurrentCoilMeta = -1; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 8; h++) { + if (h == 1 || h == 3 || h == 5) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, h, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, h, aOffsetZ + j); + if (isBlockCoil(aBlock, aMeta)) { + if (aCurrentCoilMeta < 0) { + aCurrentCoilMeta = aMeta; + } + if (aCurrentCoilMeta != aMeta) { + return tAmount; + } + else { + tAmount++; + } + } + } + } + } + } + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + this.mCoilTier = (aCurrentCoilMeta+1); + } + else { + if (aCurrentCoilMeta == 12) { + this.mCoilTier = 1; + } + else if (aCurrentCoilMeta == 13) { + this.mCoilTier = 2; + } + else if (aCurrentCoilMeta == 14) { + this.mCoilTier = 3; + } + else { + this.mCoilTier = 0; + } + } + + return tAmount; + } + + + public int checkPipes(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + int tAmount = 0; + int aCurrentPipeMeta = -1; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 8; h++) { + if (h == 2 || h == 4) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, h, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, h, aOffsetZ + j); + if (isBlockPipeCasing(aBlock, aMeta)) { + if (aCurrentPipeMeta < 0) { + aCurrentPipeMeta = aMeta; + } + if (aCurrentPipeMeta != aMeta) { + return tAmount; + } + else { + tAmount++; + } + } + } + } + } + } + + if (aCurrentPipeMeta == 12) { + this.mPipeCasingTier = 1; + } + else if (aCurrentPipeMeta == 13) { + this.mPipeCasingTier = 2; + } + else if (aCurrentPipeMeta == 14) { + this.mPipeCasingTier = 3; + } + else if (aCurrentPipeMeta == 15) { + this.mPipeCasingTier = 4; + } + else { + this.mPipeCasingTier = 0; + } + + return tAmount; + } + + + public int checkSolidCasings(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + + int tAmount = 0; + + // Only check a 7x7 ring + for (int i = -3; i < 4; i++) { + for (int j = -3; j < 4; j++) { + // If we are on the 7x7 ring, proceed + if (i == -3 || i == 3 || j == -3 || j == 3) { + IGregTechTileEntity aTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(aOffsetX + i, 0, aOffsetZ + j); + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, 0, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, 0, aOffsetZ + j); + + if (aTileEntity != null) { + + if (this.addToMachineList(aTileEntity)) { + tAmount++; + } + else { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + Logger.INFO("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aTileEntity.getInventoryName()); + return tAmount; + } + //Handle controller + if (aMetaTileEntity instanceof GregtechMTE_ChemicalPlant) { + continue; + } + else { + Logger.INFO("Error counting Bottom Layer Casing Ring. Bad Tile Entity. Found "+aMetaTileEntity.getInventoryName()); + return tAmount; + } + } + } + else { + if (isBlockSolidCasing(aBlock, aMeta)) { + tAmount++; + } + else { + Logger.INFO("Error counting Bottom Layer Casing Ring. Found "+aBlock.getLocalizedName()+":"+aMeta); + return tAmount; + } + } + } + } + } + + // Check 5 layers Pillars + for (int r=1;r<6;r++) { + // Check Each Pillar/Corner + for (int aPillar=0;aPillar<4;aPillar++) { + int i = 0; + int j = 0; + if (aPillar == 0) { + i = -3; + j = -3; + } + else if (aPillar == 1) { + i = 3; + j = 3; + } + else if (aPillar == 2) { + i = -3; + j = 3; + } + else if (aPillar == 3) { + i = 3; + j = -3; + } + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, r, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, r, aOffsetZ + j); + if (isBlockSolidCasing(aBlock, aMeta)) { + tAmount++; + } + else { + Logger.INFO("Error counting Pillars. Found "+ItemUtils.getLocalizedNameOfBlock(aBlock, aMeta)); + return tAmount; + } + } + } + + + // Check top layer 7x7 + for (int i = -3; i < 4; i++) { + for (int j = -3; j < 4; j++) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, 6, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, 6, aOffsetZ + j); + if (isBlockSolidCasing(aBlock, aMeta)) { + tAmount++; + } + else { + Logger.INFO("Error counting Top Layer casings. Found "+ItemUtils.getLocalizedNameOfBlock(aBlock, aMeta)); + return tAmount; + } + } + } + + return tAmount; + } + + + public int checkMachineCasings(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack, int aOffsetX, int aOffsetZ) { + int tAmount = 0; + int aHeight = 0; + // Iterate once for each layer + for (int aIteration=0;aIteration<3;aIteration++) { + // Dynamically set height + aHeight = (aIteration == 0 ? 0 : aIteration == 1 ? 1 : 5); + // Only check a 5x5 area + for (int i = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + // If we are on the 5x5 ring, proceed + if (i == -2 || i == 2 || j == -2 || j == 2) { + // If the second axis is on the outer ring, continue + if (i < -2 || i > 2 || j < -2 || j > 2) { + continue; + } + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, aHeight, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, aHeight, aOffsetZ + j); + if (isBlockMachineCasing(aBlock, aMeta)) { + tAmount++; + } + else { + return tAmount; + } + } + } + } + } + + // Check bottom layer inner 3x3 + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + Block aBlock = aBaseMetaTileEntity.getBlockOffset(aOffsetX + i, 0, aOffsetZ + j); + int aMeta = aBaseMetaTileEntity.getMetaIDOffset(aOffsetX + i, 0, aOffsetZ + j); + if (isBlockMachineCasing(aBlock, aMeta)) { + tAmount++; + } + else { + return tAmount; + } + } + } + + return tAmount; + } + + public int getSolidCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + 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); + } + if (aInitStructureCheck == GregTech_API.sBlockCasings2) { + int aMetaSteelCasing = 0; + if (aInitStructureCheckMeta == aMetaSteelCasing) { + return 1; + } + } + else if (aInitStructureCheck == GregTech_API.sBlockCasings4) { + int aMetaStainlessCasing = 1; + int aMetaTitaniumCasing = 2; + int aMetaTungstenCasing = 0; + if (aInitStructureCheckMeta == aMetaStainlessCasing) { + return 2; + } + else if (aInitStructureCheckMeta == aMetaTitaniumCasing) { + return 3; + } + else if (aInitStructureCheckMeta == aMetaTungstenCasing) { + return 4; + } + } + return 0; + } + + public int getMachineCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + Logger.INFO(""+xDir+", "+zDir); + if (xDir == 0) { + if (zDir > 0) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 0, 1); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 0, 1); + } + else { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(0, 0, -1); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(0, 0, -1); + } + + } + else { + if (xDir > 0) { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(1, 0, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(1, 0, 0); + } + else { + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(-1, 0, 0); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(-1, 0, 0); + } + } + + if (isBlockMachineCasing(aInitStructureCheck, aInitStructureCheckMeta)) { + Logger.INFO("Using Meta "+aInitStructureCheckMeta); + return aInitStructureCheckMeta; + } + return 0; + } + + + + + + + + + + + + + + + + + + + + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mSolidCasingTier = getCasingTierOnClientSide(); + } + + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + + + @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); + } + if (aInitStructureCheck == GregTech_API.sBlockCasings2) { + int aMetaSteelCasing = 0; + if (aInitStructureCheckMeta == aMetaSteelCasing) { + return 1; + } + } + else if (aInitStructureCheck == GregTech_API.sBlockCasings4) { + int aMetaStainlessCasing = 1; + int aMetaTitaniumCasing = 2; + int aMetaTungstenCasing = 0; + if (aInitStructureCheckMeta == aMetaStainlessCasing) { + return 2; + } + else if (aInitStructureCheckMeta == aMetaTitaniumCasing) { + return 3; + } + else if (aInitStructureCheckMeta == aMetaTungstenCasing) { + return 4; + } + } + return 0; + } + catch (Throwable t) { + t.printStackTrace(); + return 0; + } + + } + + + + + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java index fbf61598d3..40994040bd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_FluidCanning.java @@ -1,29 +1,55 @@ 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.Materials; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.MaterialGenerator; +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 extends RecipeGen_Base { - - public final static Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); - static { - MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); +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; @@ -95,13 +121,18 @@ public class RecipeGen_FluidCanning extends RecipeGen_Base { // 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; } } @@ -110,11 +141,14 @@ public class RecipeGen_FluidCanning extends RecipeGen_Base { if (aTempValidityCheck) { // Valid Recipe recipe = aRecipe; - mRecipeGenMap.add(this); disableOptional = aExtracting; - isValid = true; + 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; @@ -125,40 +159,54 @@ public class RecipeGen_FluidCanning extends RecipeGen_Base { @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) { - if (aRecipe != null) { - int aCount1 = GT_Recipe_Map.sFluidExtractionRecipes.mRecipeList.size(); - int aCount2 = aCount1; - GT_Recipe_Map.sFluidExtractionRecipes.addRecipe(aRecipe); - aCount1 = GT_Recipe_Map.sFluidExtractionRecipes.mRecipeList.size(); - return aCount1 > aCount2; + 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 false; + return result; } - private final boolean addFluidCannerRecipe(GT_Recipe recipe2) { - if (recipe2 != null) { - int aCount1 = GT_Recipe_Map.sFluidCannerRecipes.mRecipeList.size(); - int aCount2 = aCount1; - GT_Recipe_Map.sFluidCannerRecipes.addRecipe(recipe2); - aCount1 = GT_Recipe_Map.sFluidCannerRecipes.mRecipeList.size(); - return aCount1 > aCount2; + 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 false; + return result; } private void dumpStack() { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java new file mode 100644 index 0000000000..8a4ae1344a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_AlgaeFarm.java @@ -0,0 +1,202 @@ +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.Recipe_GT; +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 Recipe_GT( + false, + aInputs, + aOutputs, + (Object) null, + new int[] {}, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {GT_Values.NF}, + (int) (aDurations[aTier] * aOutputTimeMulti.get()), // 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>(); + + // 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 i=0;i<(9-aTier);i++) { + if (aTier >= (6+i)) { + int aMulti = i + 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/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index cd853dfb0d..efac0222af 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -7,11 +7,15 @@ import java.lang.reflect.Method; import java.util.List; import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.interfaces.internal.IGT_RecipeAdder; import gregtech.api.util.CustomRecipeMap; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; import gregtech.api.util.SemiFluidFuelHandler; @@ -680,6 +684,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { private static final Method mScannerTT; private static final Method[] mChemicalRecipe = new Method[3]; private static final Method mLargeChemReactor; + private static final Method mPyroOven; static { @@ -729,6 +734,8 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { 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); + } @@ -737,6 +744,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { mAssemblyLine = null; mLargeChemReactor = null; mScannerTT = null; + mPyroOven = null; } @@ -1006,18 +1014,18 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { } @Override - public boolean addFluidExtractionRecipe(ItemStack input, ItemStack input2, FluidStack output, int aTime, int aEu) { - return MaterialGenerator.addFluidExtractionRecipe(input, input2, output, aTime, aEu); + 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 aFullContainer, ItemStack container, FluidStack rFluidIn) { - return MaterialGenerator.addFluidCannerRecipe(container, aFullContainer, rFluidIn, null); + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn) { + return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, null); } @Override - public boolean addFluidCannerRecipe(ItemStack aFullContainer, ItemStack container, FluidStack rFluidIn, FluidStack rFluidOut) { - return MaterialGenerator.addFluidCannerRecipe(container, aFullContainer, rFluidIn, rFluidOut); + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut) { + return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, rFluidOut); } @@ -1176,6 +1184,15 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addFluidReactorRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, 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(); + } + + Recipe_GT aSpecialRecipe = new Recipe_GT( false, aInputs, @@ -1217,6 +1234,76 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { } + @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; + + } + diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java index 57a726f7e8..2c9f1d1943 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java @@ -4,6 +4,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; 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 { @@ -15,10 +16,13 @@ public class GregtechAlgaeContent { } private static void run1() { - // Industrial Centrifuge Multiblock - GregtechItemList.AlgaeFarm_Controller.set( - new GregtechMTE_AlgaePondBase(997, "algaefarm.controller.tier.single", "Algae Farm").getStackForm(1L)); + + // 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)); + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java index 9f67363302..54e4fbf024 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechCustomHatches.java @@ -8,6 +8,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +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_Muffler_Adv; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Naquadah; @@ -68,7 +69,13 @@ public class GregtechCustomHatches { "hatch.turbine.input.tier.00", // unlocal name "Turbine Housing", // Local name 8 - ).getStackForm(1L)); + ).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)); @@ -105,12 +112,7 @@ public class GregtechCustomHatches { .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)); - - //GT++ multiblock Control Core Bus - GregtechItemList.Hatch_Control_Core - .set((new GT_MetaTileEntity_Hatch_ControlCore(30020, "hatch.control.adv", "Control Core Module", 1)) - .getStackForm(1L)); + .getStackForm(1L)); } private static void run3() { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java index bbe2d10273..c470243822 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPollutionDevices.java @@ -2,8 +2,8 @@ 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.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_AirIntake; 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; @@ -12,8 +12,8 @@ public class GregtechPollutionDevices { public static void run() { if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { - Logger.INFO("Gregtech5u Content | Registering Anti-Pollution Devices."); - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (PollutionUtils.isPollutionEnabled()) { + Logger.INFO("Gregtech5u Content | Registering Anti-Pollution Devices."); run1(); } } @@ -50,7 +50,6 @@ public class GregtechPollutionDevices { "pollutioncleaner.10.tier.single", "Biosphere Cleanser", 9).getStackForm(1L)); } - GregtechItemList.Hatch_Air_Intake.set(new GT_MetaTileEntity_Hatch_AirIntake(861, "hatch.air.intake.tier.00", "Air Intake Hatch", 5).getStackForm(1L)); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java index b8dd8e4767..2d548a57b7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java @@ -12,6 +12,7 @@ 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.Utils; 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; @@ -32,12 +33,15 @@ public class GregtechRocketFuelGenerator { GregtechItemList.Controller_RocketEngine.set( new GregtechMetaTileEntity_LargeRocketEngine(996, "gtpp.multimachine.rocketengine", "Rocketdyne F-1A Engine").getStackForm(1L)); + + ItemList aDieselEngine = Utils.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', ItemList.Machine_Multi_DieselEngine, + 'M', aDieselEngine, 'P', ItemList.Electric_Piston_IV, 'E', ItemList.Field_Generator_EV, 'C', OrePrefixes.circuit.get(Materials.Master), diff --git a/src/Java/gtPlusPlus/xmod/ic2/item/CustomKineticRotor.java b/src/Java/gtPlusPlus/xmod/ic2/item/CustomKineticRotor.java index e433396a1b..92d711101b 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/item/CustomKineticRotor.java +++ b/src/Java/gtPlusPlus/xmod/ic2/item/CustomKineticRotor.java @@ -6,6 +6,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; import ic2.api.item.IKineticRotor; import ic2.core.IC2; import ic2.core.block.kineticgenerator.gui.GuiWaterKineticGenerator; @@ -24,7 +25,7 @@ public class CustomKineticRotor extends Item implements IKineticRotor { private final int mTier; @SideOnly(Side.CLIENT) - private final IIcon[] mTextures = new IIcon[6]; + private IIcon[] mTextures; private static final String[] mRegistrationNames = new String[] { "itemwoodrotor", "itemironrotor", "itemsteelrotor", "itemwcarbonrotor" @@ -267,6 +268,7 @@ public class CustomKineticRotor extends Item implements IKineticRotor { @Override public void registerIcons(IIconRegister iconRegister) { int aIndex = 0; + mTextures = new IIcon[6]; for (String y : mUnlocalNames) { mTextures[aIndex++] = iconRegister.registerIcon(IC2.textureDomain + ":" + "rotors/" + y); } diff --git a/src/Java/gtPlusPlus/xmod/reliquary/util/ReliquaryRecipeHandler.java b/src/Java/gtPlusPlus/xmod/reliquary/util/ReliquaryRecipeHandler.java index b79a4f45a5..1133e67fe6 100644 --- a/src/Java/gtPlusPlus/xmod/reliquary/util/ReliquaryRecipeHandler.java +++ b/src/Java/gtPlusPlus/xmod/reliquary/util/ReliquaryRecipeHandler.java @@ -2,7 +2,6 @@ package gtPlusPlus.xmod.reliquary.util; import static gtPlusPlus.core.lib.CORE.GTNH; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gtPlusPlus.api.objects.Logger; @@ -45,7 +44,7 @@ public class ReliquaryRecipeHandler { Logger.INFO("Finished removing original recipes."); // Add new recipes - if (GT_Values.RA.addChemicalRecipe(ALLOY.ENERGYCRYSTAL.getDust(4), ReliquaryItems.emptyVial(), FluidUtils.getHotWater(2000), null, ReliquaryItems.glowingWater(), 20 * 30, 500)) { + if (CORE.RA.addChemicalRecipe(ALLOY.ENERGYCRYSTAL.getDust(4), ReliquaryItems.emptyVial(), FluidUtils.getHotWater(2000), null, ReliquaryItems.glowingWater(), 20 * 30, 500)) { Logger.INFO("Added new recipe for Glowing Water."); } if (CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] {ItemUtils.simpleMetaStack(Items.ender_eye, 0, 32), CI.getFieldGenerator(5, GTNH ? 8 : 4), CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 16 : 8), CI.getEmitter(3, 20)}, FluidUtils.getUUM(50), ReliquaryItems.emptyVoidTear(), 20 * 2000, 2000)){ diff --git a/src/Java/gtPlusPlus/xmod/thermalfoundation/recipe/TF_Gregtech_Recipes.java b/src/Java/gtPlusPlus/xmod/thermalfoundation/recipe/TF_Gregtech_Recipes.java index 3de15ce6be..85485b5565 100644 --- a/src/Java/gtPlusPlus/xmod/thermalfoundation/recipe/TF_Gregtech_Recipes.java +++ b/src/Java/gtPlusPlus/xmod/thermalfoundation/recipe/TF_Gregtech_Recipes.java @@ -12,6 +12,7 @@ import gregtech.api.util.GT_OreDictUnificator; import cofh.lib.util.helpers.ItemHelper; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.thermalfoundation.item.TF_Items; import net.minecraftforge.fluids.FluidRegistry; @@ -25,34 +26,23 @@ public class TF_Gregtech_Recipes { private static void start(){ //Get Items to work with - final ItemStack dust_Cryotheum = TF_Items.itemDustCryotheum.copy(); - final ItemStack dust_Pyrotheum = TF_Items.itemDustPyrotheum.copy(); - final ItemStack dust_Blizz = TF_Items.itemDustBlizz.copy(); - final ItemStack dust_Blizz3 = ItemUtils.simpleMetaStack(TF_Items.itemMaterial, 2, 3); - final ItemStack rod_Blizz = TF_Items.itemRodBlizz.copy(); + final ItemStack dust_Cryotheum = ItemUtils.getItemStackOfAmountFromOreDict("dustCryotheum", 1); + final ItemStack dust_Pyrotheum = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Pyrotheum, 1L); + final ItemStack dust_Blizz = ItemUtils.getItemStackOfAmountFromOreDict("dustBlizz", 1); + final ItemStack dust_Blizz3 = ItemUtils.getItemStackOfAmountFromOreDict("dustBlizz", 3); + final ItemStack rod_Blizz = ItemUtils.getItemStackOfAmountFromOreDict("stickBlizz", 1); + final FluidStack moltenBlaze = getFluidStack("molten.blaze", 1440); //Gelid Cryotheum - Logger.INFO("Adding Recipes for Gelid Cryotheum"); - CORE.RA.addFluidExtractionRecipe(dust_Cryotheum, getFluidStack("cryotheum", 250), 200, 240); GT_Values.RA.addChemicalBathRecipe((GT_OreDictUnificator.get(OrePrefixes.ore, Materials.Cinnabar, 1L)), getFluidStack("cryotheum", 144), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Cinnabar, 3L), GT_Values.NI, GT_Values.NI, null, 400, 30); //Blizz Powder - Logger.INFO("Adding Recipes for Blizz Powder"); GT_Values.RA.addChemicalBathRecipe(new ItemStack(Items.snowball, 4), moltenBlaze, dust_Blizz, GT_Values.NI, GT_Values.NI, null, 400, 240); //Blizz Rod - Logger.INFO("Adding Recipes for Blizz Rod"); GT_Values.RA.addVacuumFreezerRecipe(new ItemStack(Items.blaze_rod), rod_Blizz, (int) Math.max((Materials.Blaze.getMass()*4) * 3L, 1L)); - GT_ModHandler.addPulverisationRecipe(rod_Blizz, dust_Blizz3, new ItemStack(Items.snowball, 1), 50, false); - - //Blazing Pyrotheum - Logger.INFO("Adding Recipes for Blazing Pyrotheum"); - CORE.RA.addFluidExtractionRecipe(dust_Pyrotheum, getFluidStack("pyrotheum", 250), 200, 240); - - //Ender Fluid - CORE.RA.addFluidExtractionRecipe(ItemUtils.getSimpleStack(Items.ender_pearl), getFluidStack("ender", 250), 100, 30); - + GT_ModHandler.addPulverisationRecipe(rod_Blizz, dust_Blizz3, new ItemStack(Items.snowball, 1), 50, false); ItemStack dustCoal = ItemUtils.getItemStackOfAmountFromOreDict("dustCoal", 1); ItemStack dustSulfur = ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 1); @@ -105,14 +95,7 @@ public class TF_Gregtech_Recipes { } private static FluidStack getFluidStack(final String fluidName, final int amount){ - Logger.WARNING("Trying to get a fluid stack of "+fluidName); - try { - return FluidRegistry.getFluidStack(fluidName, amount); - } - catch (final Throwable e){ - return null; - } - + return FluidUtils.getFluidStack(fluidName, amount); } } |