diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
33 files changed, 4071 insertions, 1400 deletions
diff --git a/src/Java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java b/src/Java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java index 9d646e3eb5..95067300c8 100644 --- a/src/Java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java +++ b/src/Java/gtPlusPlus/xmod/bop/HANDLER_BiomesOPlenty.java @@ -1,16 +1,42 @@ package gtPlusPlus.xmod.bop; +import java.lang.reflect.Field; + import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; public class HANDLER_BiomesOPlenty { + + public static Item mPineCone; + + public static Block logs1; + public static Block logs2; + public static Block logs3; + public static Block logs4; + + public static Block leaves1; + public static Block leaves2; + public static Block leaves3; + public static Block leaves4; + public static Block colorizedLeaves1; + public static Block colorizedLeaves2; + public static Block saplings; + public static Block colorizedSaplings; + public static void preInit(){ - //if (LoadedMods.BiomesOPlenty){ - BOP_Block_Registrator.run(); - //} + BOP_Block_Registrator.run(); + if (LoadedMods.BiomesOPlenty){ + setFields(); + registerPineconeToOreDict(); + } } @@ -21,11 +47,135 @@ public class HANDLER_BiomesOPlenty { } public static void postInit(){ + BOP_Block_Registrator.recipes(); if (LoadedMods.BiomesOPlenty){ - BOP_Block_Registrator.recipes(); + } + } + private static void registerPineconeToOreDict() { + if (mPineCone != null) { + ItemStack aPinecone = ItemUtils.simpleMetaStack(mPineCone, 13, 1); + if (aPinecone != null) { + ItemUtils.addItemToOreDictionary(aPinecone, "pinecone"); + } + } + } + + public static ItemStack getStack(Block aBlock, int aMeta, int aSize) { + return ItemUtils.simpleMetaStack(aBlock, aMeta, aSize); } + + //BOPCBlocks.logs4 - 0 + //BOPCBlocks.colorizedLeaves2 - 1 + + private static void setFields() { + Field aBopMiscItem = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCItems"), "misc"); + + Field aBopBlock1 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs1"); + Field aBopBlock2 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs2"); + Field aBopBlock3 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs3"); + Field aBopBlock4 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs4"); + + Field aBopLeaves1 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves1"); + Field aBopLeaves2 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves2"); + Field aBopLeaves3 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves3"); + Field aBopLeaves4 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves4"); + + Field aBopColouredLeaves1 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves1"); + Field aBopColouredLeaves2 = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves2"); + + Field aBopSapling = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "saplings"); + Field aBopColouredSapling = ReflectionUtils.getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedSaplings"); + + if (aBopMiscItem != null) { + Item aMiscItem = (Item) ReflectionUtils.getFieldValue(aBopMiscItem); + if (aMiscItem != null) { + mPineCone = aMiscItem; + } + } + + + if (aBopBlock1 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock1); + if (aBlock != null) { + logs1 = aBlock; + } + } + if (aBopBlock2 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock2); + if (aBlock != null) { + logs2 = aBlock; + } + } + if (aBopBlock3 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock3); + if (aBlock != null) { + logs3 = aBlock; + } + } + if (aBopBlock4 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopBlock4); + if (aBlock != null) { + logs4 = aBlock; + } + } + + + if (aBopLeaves1 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves1); + if (aBlock != null) { + leaves1 = aBlock; + } + } + if (aBopLeaves2 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves2); + if (aBlock != null) { + leaves2 = aBlock; + } + } + if (aBopLeaves3 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves3); + if (aBlock != null) { + leaves3 = aBlock; + } + } + if (aBopLeaves4 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopLeaves4); + if (aBlock != null) { + leaves4 = aBlock; + } + } + + + if (aBopColouredLeaves1 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopColouredLeaves1); + if (aBlock != null) { + colorizedLeaves1 = aBlock; + } + } + if (aBopColouredLeaves2 != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopColouredLeaves2); + if (aBlock != null) { + colorizedLeaves2 = aBlock; + } + } + + + if (aBopSapling != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopSapling); + if (aBlock != null) { + saplings = aBlock; + } + } + if (aBopColouredSapling != null) { + Block aBlock = (Block) ReflectionUtils.getFieldValue(aBopColouredSapling); + if (aBlock != null) { + colorizedSaplings = aBlock; + } + } + } + } diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java b/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java index 2ee1587809..3716359d7a 100644 --- a/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/BOP_Block_Registrator.java @@ -16,6 +16,9 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.bop.blocks.pine.LeavesPineTree; +import gtPlusPlus.xmod.bop.blocks.pine.LogPineTree; +import gtPlusPlus.xmod.bop.blocks.pine.SaplingPineTree; import gtPlusPlus.xmod.bop.blocks.rainforest.LeavesRainforestTree; import gtPlusPlus.xmod.bop.blocks.rainforest.LogRainforestTree; import gtPlusPlus.xmod.bop.blocks.rainforest.SaplingRainforestTree; @@ -30,10 +33,14 @@ public class BOP_Block_Registrator { public static Block log_Rainforest; public static Block leaves_Rainforest; public static Block sapling_Rainforest; + public static Block log_Pine; + public static Block leaves_Pine; + public static Block sapling_Pine; //Runs Each tree Type separately public static final void run(){ registerTree_Rainforest(); + registerTree_Pine(); } @@ -47,10 +54,23 @@ public class BOP_Block_Registrator { return true; } + private static final boolean registerTree_Pine(){ + log_Pine = new LogPineTree(); + leaves_Pine = new LeavesPineTree(); + sapling_Pine = new SaplingPineTree(); + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(log_Pine), "logWood", true); + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(leaves_Pine), "treeLeaves", true); + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(sapling_Pine), "treeSapling", true); + return true; + } + public static final void recipes() { - //Rainforest Oak + // Rainforest Oak addLogRecipes(ItemUtils.getSimpleStack(log_Rainforest)); addSaplingRecipes(ItemUtils.getSimpleStack(sapling_Rainforest)); + // Pine + addLogRecipes(ItemUtils.getSimpleStack(log_Pine)); + addSaplingRecipes(ItemUtils.getSimpleStack(sapling_Pine)); } diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java b/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java index 264aaa2a20..5c86c45591 100644 --- a/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/base/LeavesBase.java @@ -55,16 +55,12 @@ public class LeavesBase extends BlockLeaves { @Override//Drops when Leaf is broken protected void func_150124_c(World world, int x, int y, int z, int meta, int randomChance){ - if (this.treeType.length == this.bonusDrops.length){ - for (int i = 0; i < this.treeType.length; ++i){ - if (this.bonusDrops[i] != null && world.rand.nextInt(randomChance) == 0){ - this.dropBlockAsItem(world, x, y, z, ItemUtils.getSimpleStack(this.bonusDrops[i], 1)); - } + Logger.INFO("Dropping Bonus Drops"); + for (int i = 0; i < this.bonusDrops.length; ++i){ + if (this.bonusDrops[i] != null && world.rand.nextInt(randomChance) == 0){ + this.dropBlockAsItem(world, x, y, z, ItemUtils.getSimpleStack(this.bonusDrops[i], 1)); } } - else { - Logger.WARNING("Unable to drop anything, Leaf Type array and Loot array are different sizes."); - } } /** diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LeavesPineTree.java b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LeavesPineTree.java new file mode 100644 index 0000000000..c942db14cf --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LeavesPineTree.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.bop.blocks.pine; + +import java.util.Random; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; +import gtPlusPlus.xmod.bop.blocks.base.LeavesBase; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class LeavesPineTree extends LeavesBase { + + public LeavesPineTree(){ + super("Pine", "pine", new ItemStack[]{}); + this.treeType = new String[] {"pine"}; + this.leafType = new String[][] {{"pine"},{"pine_opaque"}}; + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_){ + return Item.getItemFromBlock(BOP_Block_Registrator.sapling_Pine); + } + + @Override//Drops when Leaf is broken + protected void func_150124_c(World world, int x, int y, int z, int meta, int randomChance){ + Logger.INFO("Dropping Bonus Drops"); + if (MathUtils.randInt(0, 10) >= 9) { + this.dropBlockAsItem(world, x, y, z, ItemUtils.getSimpleStack(AgriculturalChem.mPinecone, MathUtils.randInt(1, 4))); + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LogPineTree.java b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LogPineTree.java new file mode 100644 index 0000000000..dee5bf02fd --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/LogPineTree.java @@ -0,0 +1,24 @@ +package gtPlusPlus.xmod.bop.blocks.pine; + +import gtPlusPlus.xmod.bop.blocks.base.LogBase; + +public class LogPineTree extends LogBase { + + public LogPineTree(){ + super("Pine Log", "pine", new String[]{"pine"}); + this.treeType = new String[] {"pine"}; + } + + /*@Override + @SideOnly(Side.CLIENT) + protected IIcon getSideIcon(int metaID){ + return this.textureSide[metaID % this.textureSide.length]; + } + + @Override + @SideOnly(Side.CLIENT) + protected IIcon getTopIcon(int metaID){ + return this.textureTop[metaID % this.textureTop.length]; + }*/ + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bop/blocks/pine/SaplingPineTree.java b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/SaplingPineTree.java new file mode 100644 index 0000000000..0ee04de899 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bop/blocks/pine/SaplingPineTree.java @@ -0,0 +1,55 @@ +package gtPlusPlus.xmod.bop.blocks.pine; + +import java.util.Random; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.bop.blocks.base.SaplingBase; +import gtPlusPlus.xmod.bop.world.features.trees.WorldGenPineTree; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenBigTree; +import net.minecraft.world.gen.feature.WorldGenTrees; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class SaplingPineTree extends SaplingBase { + + public SaplingPineTree(){ + super("Pine Sapling", "pine", new String[]{"pine"}); + } + + @Override + public void func_149878_d(World world, int x, int y, int z, Random rand){ + Logger.WARNING("func_149878_d - 1"); + if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(world, rand, x, y, z)) return; + rand.nextInt(10); + new WorldGenBigTree(true); + new WorldGenTrees(true); + int i1 = 0; + int j1 = 0; + boolean flag = false; + + Block block = Blocks.air; + + if (flag) + { + world.setBlock(x + i1, y, z + j1, block, 0, 4); + world.setBlock(x + i1 + 1, y, z + j1, block, 0, 4); + world.setBlock(x + i1, y, z + j1 + 1, block, 0, 4); + world.setBlock(x + i1 + 1, y, z + j1 + 1, block, 0, 4); + } + else + { + world.setBlock(x, y, z, block, 0, 4); + } + Object obj = new WorldGenPineTree(); + if (obj != null) { + world.setBlockToAir(x, y, z); + if (!((WorldGenerator) obj).generate(world, CORE.RANDOM, x, y, z)) { + world.setBlock(x, y, z, this, 0, 2); + } + } + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bop/world/features/trees/WorldGenPineTree.java b/src/Java/gtPlusPlus/xmod/bop/world/features/trees/WorldGenPineTree.java new file mode 100644 index 0000000000..831108ec99 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bop/world/features/trees/WorldGenPineTree.java @@ -0,0 +1,171 @@ +package gtPlusPlus.xmod.bop.world.features.trees; + +import java.util.Random; + +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenPineTree extends WorldGenAbstractTree{ + + public WorldGenPineTree() { + super(true); + } + + @Override + public boolean generate(World world, Random random, int x, int y, int z) { + while (world.isAirBlock(x, y, z) && y > 2) { + --y; + } + + Block aSoilBlock = world.getBlock(x, y, z); + + if (!canBlockSustainSapling(world, aSoilBlock, x, y, z)) { + return false; + } else { + int height; + int branches; + for (height = -2; height <= 2; ++height) { + for (branches = -2; branches <= 2; ++branches) { + if (world.isAirBlock(x + height, y - 1, z + branches) + && world.isAirBlock(x + height, y - 2, z + branches) + && !world.isAirBlock(x + height, y, z + branches)) { + return false; + } + } + } + + height = 2 + MathUtils.randInt(8, 16); + branches = 2 + MathUtils.randInt(6, 18); + int h = 1; + aSoilBlock.onPlantGrow(world, x, y - 1, z, x, y, z); + + int c; + int r = MathUtils.randInt(1, 3); + for (c = 0; c < height; ++c) { + this.buildBlock(world, x, y + h, z, BOP_Block_Registrator.log_Pine, 0); + h++; + if (c >= r && c % 2 == 0) { + this.generateBranch(world, random, x, y + h, z, c); + } + } + + this.generateTop(world, x, y + h, z); + return true; + } + } + + public void generateTop(World world, int x, int y, int z) { + for (int i = -1; i < 2; ++i) { + for (int j = -1; j < 2; ++j) { + this.buildBlock(world, x + i, y, z + j, BOP_Block_Registrator.leaves_Pine, 0); + } + } + + this.buildBlock(world, x, y, z, BOP_Block_Registrator.log_Pine, 0); + this.buildBlock(world, x + 1, y + 1, z, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x, y + 1, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x, y + 1, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 1, y + 1, z, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x, y + 2, z, BOP_Block_Registrator.leaves_Pine, 0); + } + + public void generateBranch(World world, Random rand, int x, int y, int z, int n) { + int var99999; + int var99998; + for (var99999 = -1; var99999 < 2; ++var99999) { + for (var99998 = -1; var99998 < 2; ++var99998) { + this.buildBlock(world, x + var99999, y, z + var99998, BOP_Block_Registrator.leaves_Pine, 0); + } + } + + var99999 = rand.nextInt(2); + var99998 = rand.nextInt(2); + int var99997 = rand.nextInt(2); + int var99996 = rand.nextInt(2); + if (n % 2 == 0) { + if (var99998 == 0) { + this.buildBlock(world, x + 1, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 2, y - 1, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + if (var99999 == 0) { + this.buildBlock(world, x + 2, y - 2, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x + 2, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + this.buildBlock(world, x + 1, y, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 2, y, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 2, y, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } + + if (var99997 == 0) { + this.buildBlock(world, x - 2, y - 1, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 1, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + if (var99996 == 0) { + this.buildBlock(world, x - 2, y - 2, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x - 2, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + this.buildBlock(world, x - 2, y, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 1, y, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 2, y, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + if (var99998 == 0) { + this.buildBlock(world, x + 2, y - 1, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 1, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + if (var99999 == 0) { + this.buildBlock(world, x + 2, y - 2, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x + 2, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + this.buildBlock(world, x + 2, y, z + 1, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x + 1, y, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + if (var99999 == 0) { + this.buildBlock(world, x + 2, y - 1, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x + 2, y, z + 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } + + if (var99997 == 0) { + this.buildBlock(world, x - 1, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 2, y - 1, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + if (var99996 == 0) { + this.buildBlock(world, x - 2, y - 2, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x - 2, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } else { + this.buildBlock(world, x - 1, y, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + this.buildBlock(world, x - 2, y, z - 1, BOP_Block_Registrator.leaves_Pine, 0); + if (var99996 == 0) { + this.buildBlock(world, x - 2, y - 1, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } else { + this.buildBlock(world, x - 2, y, z - 2, BOP_Block_Registrator.leaves_Pine, 0); + } + } + } + + this.buildBlock(world, x, y, z, BOP_Block_Registrator.log_Pine, 0); + this.buildBlock(world, x, y + 1, z, BOP_Block_Registrator.log_Pine, 0); + } + + public void buildBlock(World world, int x, int y, int z, Block block, int meta) { + if (world.isAirBlock(x, y, z) || world.getBlock(x, y, z).isLeaves(world, x, y, z)) { + world.setBlock(x, y, z, block, meta, 2); + } + } + + public boolean canBlockSustainSapling(World world, Block block, int x, int y, int z) { + return block.canSustainPlant(world, x, y, z, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 1cb499479f..7c1b854770 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -53,6 +53,7 @@ import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricButcherKnife; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricLighter; import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricSnips; import gtPlusPlus.xmod.gregtech.loaders.ProcessingToolHeadChoocher; +import gtPlusPlus.xmod.gregtech.loaders.misc.AddCustomMachineToPA; import gtPlusPlus.xmod.gregtech.loaders.misc.WoodCentrifuging; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; import gtPlusPlus.xmod.gregtech.recipes.RecipesToRemove; @@ -129,6 +130,9 @@ public class HANDLER_GT { if (ConfigSwitches.enableOldGTcircuits && !CORE.GTNH){ OldCircuitHandler.postInit(); } + + // Register custom singles to the PA + AddCustomMachineToPA.register(); // Register the No-Bonus Special Behaviour. diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 504533c406..b7662ca25e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -19,6 +19,12 @@ public enum GregtechItemList implements GregtechItemContainer { /** * Items */ + + // Advanced Hazmat Suit + Armour_Hazmat_Advanced_Helmet, + Armour_Hazmat_Advanced_Chest, + Armour_Hazmat_Advanced_Legs, + Armour_Hazmat_Advanced_Boots, //Gregtech Machine Parts Electric_Motor_LuV, Electric_Motor_ZPM, Electric_Motor_UV, Electric_Motor_MAX, @@ -49,6 +55,7 @@ public enum GregtechItemList implements GregtechItemContainer { //Recipe Circuit Circuit_BioRecipeSelector, + Circuit_T3RecipeSelector, //Circuits Old_Circuit_Primitive, Old_Circuit_Basic, Old_Circuit_Good, @@ -363,6 +370,9 @@ public enum GregtechItemList implements GregtechItemContainer { Casing_Turbine_LP, Casing_Turbine_HP, Casing_Turbine_Gas, Casing_Turbine_Plasma, + // Large Engine + Casing_Reinforced_Engine_Casing, + //Large Vacuum Furnace Casing_Vacuum_Furnace, Controller_Vacuum_Furnace, @@ -375,10 +385,13 @@ public enum GregtechItemList implements GregtechItemContainer { Controller_LargeSemifluidGenerator, // IsaMill - Controller_IsaMill_Controller, + Controller_IsaMill, Casing_IsaMill_Casing, Casing_IsaMill_Gearbox, Casing_IsaMill_Pipe, + + // Flotation Cell + Controller_Flotation_Cell, //---------------------------------------------------------------------------- @@ -402,6 +415,12 @@ public enum GregtechItemList implements GregtechItemContainer { //Control Core Hatch_Control_Core, + + // Milling Ball Bus + Bus_Milling_Balls, + + // Catalyst Bus + Bus_Catalysts, //Custom Fluid Hatches Hatch_Input_Cryotheum, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java new file mode 100644 index 0000000000..9596d41387 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java @@ -0,0 +1,282 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_Container; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.core.slots.SlotNoInput; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CONTAINER_HatchNbtConsumable extends GT_Container { + + public final int mInputslotCount; + private final int mTotalSlotCount; + + public CONTAINER_HatchNbtConsumable(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aInputslotCount) { + super(aInventoryPlayer, aTileEntity); + mInputslotCount = aInputslotCount; + mTotalSlotCount = aInputslotCount*2; + mTileEntity = aTileEntity; + if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { + addSlots(aInventoryPlayer); + if (doesBindPlayerInventory()) { + bindPlayerInventory(aInventoryPlayer); + } + detectAndSendChanges(); + } else { + aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; + } + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + if (mTotalSlotCount == 8) { + final int aSlotYStart = 26; + final int aSlotYFinish = aSlotYStart + (18*2); + final int aSlotXStart1 = 26; + final int aSlotXFinish1 = aSlotXStart1 + (18*2); + final int aSlotXStart2 = 116; + final int aSlotXFinish2 = aSlotXStart2 + (18*2); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } + else if (mTotalSlotCount == 18) { + int aSlotYStart = 20; + int aSlotYFinish = aSlotYStart + (18*3); + int aSlotXStart1 = 26; + int aSlotXFinish1 = aSlotXStart1 + (18*3); + int aSlotXStart2 = 98; + int aSlotXFinish2 = aSlotXStart2 + (18*3); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } + else if (mTotalSlotCount == 32) { + int aSlotYStart = 8; + int aSlotYFinish = aSlotYStart + (18*4); + int aSlotXStart1 = 8; + int aSlotXFinish1 = aSlotXStart1 + (18*4); + int aSlotXStart2 = 97; + int aSlotXFinish2 = aSlotXStart2 + (18*4); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } + } + + @Override + public int getSlotCount() { + return mTotalSlotCount; + } + + @Override + public int getShiftClickSlotCount() { + return mInputslotCount; + } + + /* + * Uselss stuff copied from GT + */ + + + public int mActive = 0, mMaxProgressTime = 0, mProgressTime = 0, mEnergy = 0, mSteam = 0, mSteamStorage = 0, mStorage = 0, mOutput = 0, mInput = 0, mID = 0, mDisplayErrorCode = 0; + private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, oEnergy = 0, oSteam = 0, oSteamStorage = 0, oStorage = 0, oOutput = 0, oInput = 0, oID = 0, oDisplayErrorCode = 0, mTimer = 0; + + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + mStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getEUCapacity()); + mEnergy = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredEU()); + mSteamStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getSteamCapacity()); + mSteam = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredSteam()); + mOutput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getOutputVoltage()); + mInput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getInputVoltage()); + mDisplayErrorCode = mTileEntity.getErrorDisplayID(); + mProgressTime = mTileEntity.getProgress(); + mMaxProgressTime = mTileEntity.getMaxProgress(); + mActive = mTileEntity.isActive() ? 1 : 0; + mTimer++; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + if (mTimer % 500 == 10 || oEnergy != mEnergy) { + var1.sendProgressBarUpdate(this, 0, mEnergy & 65535); + var1.sendProgressBarUpdate(this, 1, mEnergy >>> 16); + } + if (mTimer % 500 == 10 || oStorage != mStorage) { + var1.sendProgressBarUpdate(this, 2, mStorage & 65535); + var1.sendProgressBarUpdate(this, 3, mStorage >>> 16); + } + if (mTimer % 500 == 10 || oOutput != mOutput) { + var1.sendProgressBarUpdate(this, 4, mOutput); + } + if (mTimer % 500 == 10 || oInput != mInput) { + var1.sendProgressBarUpdate(this, 5, mInput); + } + if (mTimer % 500 == 10 || oDisplayErrorCode != mDisplayErrorCode) { + var1.sendProgressBarUpdate(this, 6, mDisplayErrorCode); + } + if (mTimer % 500 == 10 || oProgressTime != mProgressTime) { + var1.sendProgressBarUpdate(this, 11, mProgressTime & 65535); + var1.sendProgressBarUpdate(this, 12, mProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oMaxProgressTime != mMaxProgressTime) { + var1.sendProgressBarUpdate(this, 13, mMaxProgressTime & 65535); + var1.sendProgressBarUpdate(this, 14, mMaxProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oID != mID) { + var1.sendProgressBarUpdate(this, 15, mID); + } + if (mTimer % 500 == 10 || oActive != mActive) { + var1.sendProgressBarUpdate(this, 16, mActive); + } + if (mTimer % 500 == 10 || oSteam != mSteam) { + var1.sendProgressBarUpdate(this, 17, mSteam & 65535); + var1.sendProgressBarUpdate(this, 18, mSteam >>> 16); + } + if (mTimer % 500 == 10 || oSteamStorage != mSteamStorage) { + var1.sendProgressBarUpdate(this, 19, mSteamStorage & 65535); + var1.sendProgressBarUpdate(this, 20, mSteamStorage >>> 16); + } + } + + oID = mID; + oSteam = mSteam; + oInput = mInput; + oActive = mActive; + oOutput = mOutput; + oEnergy = mEnergy; + oStorage = mStorage; + oSteamStorage = mSteamStorage; + oProgressTime = mProgressTime; + oMaxProgressTime = mMaxProgressTime; + oDisplayErrorCode = mDisplayErrorCode; + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 0: + mEnergy = mEnergy & -65536 | par2; + break; + case 1: + mEnergy = mEnergy & 65535 | par2 << 16; + break; + case 2: + mStorage = mStorage & -65536 | par2; + break; + case 3: + mStorage = mStorage & 65535 | par2 << 16; + break; + case 4: + mOutput = par2; + break; + case 5: + mInput = par2; + break; + case 6: + mDisplayErrorCode = par2; + break; + case 11: + mProgressTime = mProgressTime & -65536 | par2; + break; + case 12: + mProgressTime = mProgressTime & 65535 | par2 << 16; + break; + case 13: + mMaxProgressTime = mMaxProgressTime & -65536 | par2; + break; + case 14: + mMaxProgressTime = mMaxProgressTime & 65535 | par2 << 16; + break; + case 15: + mID = par2; + break; + case 16: + mActive = par2; + break; + case 17: + mSteam = mSteam & -65536 | par2; + break; + case 18: + mSteam = mSteam & 65535 | par2 << 16; + break; + case 19: + mSteamStorage = mSteamStorage & -65536 | par2; + break; + case 20: + mSteamStorage = mSteamStorage & 65535 | par2 << 16; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return mTileEntity.isUseableByPlayer(player); + } + + public String trans(String aKey, String aEnglish){ + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + } + + private static class ViewingSlot extends SlotNoInput { + + public ViewingSlot(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return false; + } + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return true; + } + + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java new file mode 100644 index 0000000000..dd19571646 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java @@ -0,0 +1,59 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import gregtech.api.gui.GT_GUIContainer; + +public class GUI_HatchNbtConsumable extends GT_GUIContainer { + + private final String mName; + private final int mTotalSlotCount; + public final CONTAINER_HatchNbtConsumable mContainer; + + public GUI_HatchNbtConsumable(CONTAINER_HatchNbtConsumable aContainer, String aName) { + super(aContainer, RES_PATH_GUI + getTextureForGUI(aContainer.mInputslotCount*2)+".png"); + mContainer = aContainer; + mName = aName; + mTotalSlotCount = aContainer.mInputslotCount*2; + } + + private static final String getTextureForGUI(int aTotalSlotCOunt) { + if (aTotalSlotCOunt == 18) { + return "HatchNbtConsumable_3By3"; + } + else if (aTotalSlotCOunt == 32) { + return "HatchNbtConsumable_4By4"; + } + else { + return "HatchNbtConsumable_2By2"; + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + if (mTotalSlotCount == 18) { + fontRendererObj.drawString(mName, 8, 4, 4210752); + fontRendererObj.drawString("Stock", 25, 14, 4210752); + fontRendererObj.drawString("Active", 115, 14, 4210752); + } + else if (mTotalSlotCount == 32) { + //fontRendererObj.drawString("Slots: "+mTotalSlotCount, 8, 4, 4210752); + //fontRendererObj.drawString(mName, 8, 4, 4210752); + //fontRendererObj.drawString("Stock", 25, 16, 4210752); + //fontRendererObj.drawString("Active", 115, 16, 4210752); + } + else { + fontRendererObj.drawString(mName, 8, 4, 4210752); + fontRendererObj.drawString("Stock", 25, 16, 4210752); + fontRendererObj.drawString("Active", 115, 16, 4210752); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index 688433b3ac..bf36b56015 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -268,7 +268,8 @@ public interface IGregtech_RecipeAdder { public boolean addVacuumFurnaceRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt, int aLevel); - + + public boolean addVacuumFurnaceRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aLevel); public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu); public boolean addIrLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu); @@ -289,5 +290,9 @@ public interface IGregtech_RecipeAdder { public boolean addMillingRecipe(Materials aMat, int aEU); public boolean addMillingRecipe(Material aMat, int aEU); + public boolean addFlotationRecipe(Materials aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU); + public boolean addFlotationRecipe(Material aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU); + + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java new file mode 100644 index 0000000000..23f7b2a6a0 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java @@ -0,0 +1,63 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Hatch_Catalysts extends GT_MetaTileEntity_Hatch_NbtConsumable { + + public GT_MetaTileEntity_Hatch_Catalysts(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 7, 16, "Dedicated Catalyst Storage", false); + } + + public GT_MetaTileEntity_Hatch_Catalysts(String aName, String aDescription, ITexture[][][] aTextures) { + super(aName, 7, 16, aDescription, false, aTextures); + } + + public GT_MetaTileEntity_Hatch_Catalysts(String aName, String[] aDescription, ITexture[][][] aTextures) { + super(aName, 7, 16, aDescription[0], false, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { + return GT_MetaTileEntity_Hatch_Catalysts.class; + } + + @Override + public String getNameGUI() { + return "Catalyst Container"; + } + + @Override + public AutoMap<ItemStack> getItemsValidForUsageSlots() { + return new AutoMap<ItemStack>(); + } + + @Override + public boolean isItemValidForUsageSlot(ItemStack aStack) { + return ItemUtils.isCatalyst(aStack); + } + + @Override + public int getInputSlotCount() { + return 16; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java new file mode 100644 index 0000000000..6c28ab2e27 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java @@ -0,0 +1,63 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Hatch_MillingBalls extends GT_MetaTileEntity_Hatch_NbtConsumable { + + public GT_MetaTileEntity_Hatch_MillingBalls(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 6, 4, "Dedicated Milling Ball Storage", true); + } + + public GT_MetaTileEntity_Hatch_MillingBalls(String aName, String aDescription, ITexture[][][] aTextures) { + super(aName, 6, 4, aDescription, true, aTextures); + } + + public GT_MetaTileEntity_Hatch_MillingBalls(String aName, String[] aDescription, ITexture[][][] aTextures) { + super(aName, 6, 4, aDescription[0], true, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { + return GT_MetaTileEntity_Hatch_MillingBalls.class; + } + + @Override + public String getNameGUI() { + return "Ball Housing"; + } + + @Override + public AutoMap<ItemStack> getItemsValidForUsageSlots() { + return new AutoMap<ItemStack>(); + } + + @Override + public boolean isItemValidForUsageSlot(ItemStack aStack) { + return ItemUtils.isMillingBall(aStack); + } + + @Override + public int getInputSlotCount() { + return 4; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java new file mode 100644 index 0000000000..d1ce55d3f2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java @@ -0,0 +1,273 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; + +import java.lang.reflect.Constructor; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_HatchNbtConsumable; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_HatchNbtConsumable; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public abstract class GT_MetaTileEntity_Hatch_NbtConsumable extends GT_MetaTileEntity_Hatch { + + public GT_Recipe_Map mRecipeMap = null; + private final int mInputslotCount; + private final int mTotalSlotCount; + private final boolean mAllowDuplicateUsageTypes; + + public GT_MetaTileEntity_Hatch_NbtConsumable(int aID, String aName, String aNameRegional, int aTier, int aInputSlots, String aDescription, boolean aAllowDuplicateTypes) { + super(aID, aName, aNameRegional, aTier, aInputSlots*2, aDescription); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount()*2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + public GT_MetaTileEntity_Hatch_NbtConsumable(String aName, int aTier, int aInputSlots, String aDescription, boolean aAllowDuplicateTypes, ITexture[][][] aTextures) { + super(aName, aTier, aInputSlots*2, aDescription, aTextures); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount()*2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + public GT_MetaTileEntity_Hatch_NbtConsumable(String aName, int aTier, int aInputSlots, String[] aDescription, boolean aAllowDuplicateTypes, ITexture[][][] aTextures) { + super(aName, aTier, aInputSlots*2, aDescription[0], aTextures); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount()*2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + @Override + public abstract ITexture[] getTexturesActive(ITexture aBaseTexture); + + @Override + public abstract ITexture[] getTexturesInactive(ITexture aBaseTexture); + + public abstract int getInputSlotCount(); + + @Override + public final boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public final boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public final boolean isValidSlot(int aIndex) { + return aIndex < mInputslotCount; + } + + @Override + public final MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + Constructor<?> aConstructor = ReflectionUtils.getConstructor(getHatchEntityClass(), new Class[] {String.class, String[].class, ITexture[][][].class}); + GT_MetaTileEntity_Hatch_NbtConsumable aInstance = ReflectionUtils.createNewInstanceFromConstructor(aConstructor, new Object[] {mName, StaticFields59.getDescriptionArray(this), mTextures}); + if (aInstance instanceof GT_MetaTileEntity_Hatch_NbtConsumable) { + GT_MetaTileEntity_Hatch_NbtConsumable aMetaTile = (GT_MetaTileEntity_Hatch_NbtConsumable) aInstance; + return aMetaTile; + } + return null; + } + + public abstract Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass(); + + @Override + public final boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public final Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); + } + + @Override + public final Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + CONTAINER_HatchNbtConsumable aContainer = new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); + return new GUI_HatchNbtConsumable(aContainer, getNameGUI()); + } + + public abstract String getNameGUI(); + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + tryFillUsageSlots(); + } + } + + public final void updateSlots() { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] != null && mInventory[i].stackSize <= 0) { + mInventory[i] = null; + } + // Only moves items in the first four slots + if (i <= getSlotID_LastInput()) { + fillStacksIntoFirstSlots(); + } + } + } + + // Only moves items in the first four slots + protected final void fillStacksIntoFirstSlots() { + for (int i = 0; i <= getSlotID_LastInput() ; i++) { + for (int j = i + 1; j <= getSlotID_LastInput(); j++) { + if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + } + + private final void tryFillUsageSlots() { + int aSlotSpace = (mInputslotCount - getContentUsageSlots().size()); + if (aSlotSpace > 0) { + Logger.INFO("We have empty usage slots. "+aSlotSpace); + for (int i=getSlotID_FirstInput();i<=getSlotID_LastInput();i++) { + ItemStack aStackToTryMove = mInventory[i]; + if (aStackToTryMove != null && isItemValidForUsageSlot(aStackToTryMove)) { + Logger.INFO("Trying to move stack from input slot "+i); + if (moveItemFromStockToUsageSlots(aStackToTryMove)) { + Logger.INFO("Updating Slots."); + updateSlots(); + } + } + } + } + } + + private int getSlotID_FirstInput() { + return 0; + } + private int getSlotID_LastInput() { + return mInputslotCount-1; + } + private int getSlotID_FirstUsage() { + return mInputslotCount; + } + private int getSlotID_LastUsage() { + return mTotalSlotCount-1; + } + + + public final AutoMap<ItemStack> getContentUsageSlots() { + AutoMap<ItemStack> aItems = new AutoMap<ItemStack>(); + for (int i=mInputslotCount;i<mTotalSlotCount;i++) { + if (mInventory[i] != null) { + aItems.add(mInventory[i]); + } + } + return aItems; + } + + + public final boolean moveItemFromStockToUsageSlots(ItemStack aStack) { + return moveItemFromStockToUsageSlots(aStack, mAllowDuplicateUsageTypes); + } + + public final boolean moveItemFromStockToUsageSlots(ItemStack aStack, boolean aAllowMultiOfSameTypeInUsageSlots) { + if (aStack != null) { + if (aStack.stackSize > 0) { + + if (!isItemValidForUsageSlot(aStack)) { + Logger.INFO("Stack not valid: "+ItemUtils.getItemName(aStack)); + return false; + } + + // Copy the input stack into a new object + ItemStack aStackToMove = aStack.copy(); + // Set stack size of stack to move to 1. + aStackToMove.stackSize = 1; + // Did we set a stack in the usage slots? + boolean aDidSet = false; + // Did we find another of this item already in the usage slots? + boolean aFoundMatching = false; + // Continue processing with our new stack + // First check for duplicates + for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { + if (mInventory[i] != null) { + if (GT_Utility.areStacksEqual(aStackToMove, mInventory[i], true)) { + Logger.INFO("Found matching stack in slot "+i+"."); + aFoundMatching = true; + break; + } + } + } + // Then Move stack to Usage slots + for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { + if (mInventory[i] == null) { + if ((aFoundMatching && aAllowMultiOfSameTypeInUsageSlots) || !aFoundMatching) { + mInventory[i] = aStackToMove; + aDidSet = true; + Logger.INFO("Moving new stack to usage slots."); + break; + } + } + } + if (aDidSet) { + Logger.INFO("Depleting input stack size by 1."); + // Depleted one from the original input stack + aStack.stackSize--; + } + return aDidSet; + } + } + return false; + } + + @Override + public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() && isItemValidForUsageSlot(aStack); + } + + /** + * Items that get compared when checking for Usage Slot validity. + * Can return an empty map if isItemValidForUsageSlot() is overridden. + * @return + */ + public abstract AutoMap<ItemStack> getItemsValidForUsageSlots(); + + /** + * Checks if the given item is valid for Usage Slots. + * Can be overridden for easier handling if you already have methods to check this. + * @param aStack + * @return + */ + public boolean isItemValidForUsageSlot(ItemStack aStack) { + if (aStack != null) { + for (ItemStack aValid : getItemsValidForUsageSlots()) { + if (GT_Utility.areStacksEqual(aStack, aValid, true)) { + return true; + } + } + } + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java index be180bf4e9..a4a396e4cf 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java @@ -47,8 +47,8 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Structural Solar Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Salt Containment Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Thermally Insulated Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Flotation Cell Casings"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Reinforced Engine Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused @@ -64,6 +64,7 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs GregtechItemList.Casing_SolarTower_Structural.set(new ItemStack(this, 1, 6)); GregtechItemList.Casing_SolarTower_SaltContainment.set(new ItemStack(this, 1, 7)); GregtechItemList.Casing_SolarTower_HeatContainment.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_Reinforced_Engine_Casing.set(new ItemStack(this, 1, 9)); } public IIcon getIcon(int aSide, int aMeta) { @@ -88,6 +89,10 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs return TexturesGtBlock.Casing_Material_Stellite.getIcon(); case 8: return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + case 9: + return TexturesGtBlock.TEXTURE_CASING_FLOTATION.getIcon(); + case 10: + return TexturesGtBlock.Casing_Material_Talonite.getIcon(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 7903da8c6d..93322d2ef1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -281,6 +281,7 @@ public class TexturesGtBlock { public static final CustomIcon TEXTURE_CASING_ADVANCED_VOLCNUS = new CustomIcon("TileEntities/MACHINE_CASING_ADVANCED_VOLCANUS"); public static final CustomIcon TEXTURE_CASING_ROCKETDYNE = new CustomIcon("TileEntities/MACHINE_CASING_ROCKETDYNE"); public static final CustomIcon TEXTURE_CASING_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_GRINDING_FACTORY"); + public static final CustomIcon TEXTURE_CASING_FLOTATION = new CustomIcon("TileEntities/MACHINE_CASING_FLOTATION"); // Custom Pipes public static final CustomIcon TEXTURE_PIPE_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_PIPE_T1"); @@ -388,6 +389,13 @@ public class TexturesGtBlock { //Control Core Bus private static final CustomIcon Internal_Overlay_Hatch_Control_Core = new CustomIcon("iconsets/OVERLAY_CONTROL_CORE_BUS"); public static final CustomIcon Overlay_Hatch_Control_Core = Internal_Overlay_Hatch_Control_Core; + // Milling Ball Bus + private static final CustomIcon Internal_Overlay_Bus_Milling_Balls = new CustomIcon("iconsets/OVERLAY_MILLING_BALL_BUS"); + public static final CustomIcon Overlay_Bus_Milling_Balls = Internal_Overlay_Bus_Milling_Balls; + // Catalyst Bus + private static final CustomIcon Internal_Overlay_Bus_Catalyst = new CustomIcon("iconsets/OVERLAY_CATALYSTS"); + public static final CustomIcon Overlay_Bus_Catalyst = Internal_Overlay_Bus_Catalyst; + //Dimensional private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java new file mode 100644 index 0000000000..333939d800 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java @@ -0,0 +1,79 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.util.HashMap; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.data.AES; +import gtPlusPlus.xmod.gregtech.api.enums.CustomOrePrefix; +import net.minecraft.item.ItemStack; + +public class FlotationRecipeHandler { + + private static HashMap<String, Material> sMaterialMap = new HashMap<String, Material>(); + private static HashMap<String, ItemStack> sMilledMap = new HashMap<String, ItemStack>(); + private static final AES sEncodingHandler = new AES(); + + public static boolean registerOreType(Material aMaterial) { + String aMaterialKey = sEncodingHandler.encode(aMaterial.getUnlocalizedName()); + if (sMaterialMap.containsKey(aMaterialKey)) { + CORE.crash("Tried to register a Flotation material to an ID already in use. ID: "+aMaterialKey); + return false; + } + else { + sMaterialMap.put(aMaterialKey, aMaterial); + sMilledMap.put(aMaterialKey, aMaterial.getMilled(1)); + } + return true; + } + + public static int getHashForMaterial(Material aMaterial) { + return getMaterialsID(aMaterial).hashCode(); + } + + public static String getMaterialsID(Material aMaterial) { + for (String aKey : sMaterialMap.keySet()) { + if (sMaterialMap.get(aKey).equals(aMaterial)) { + return aKey; + } + } + return "BAD_MATERIAL_ID"; + } + + public static Material getMaterialOfMilledProduct(ItemStack aMilled) { + for (String aKey : sMilledMap.keySet()) { + ItemStack aTempMilledStack = sMilledMap.get(aKey); + if (GT_Utility.areStacksEqual(aTempMilledStack, aMilled, true)) { + return sMaterialMap.get(aKey); + } + } + return null; + } + + public static ItemStack findMilledStack(GT_Recipe aRecipe) { + if (aRecipe == null || aRecipe.mInputs == null || aRecipe.mInputs.length <= 0) { + return null; + } + return findMilledStack(aRecipe.mInputs); + } + + public static ItemStack findMilledStack(ItemStack[] aInputs) { + if (aInputs == null || aInputs.length <= 0) { + return null; + } + for (ItemStack aStack : aInputs) { + if (CustomOrePrefix.milled.get().contains(aStack)) { + return aStack; + } + } + return null; + } + + public static AES getEncoder() { + return sEncodingHandler; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java index 6201a782de..73a60889c6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -1,44 +1,26 @@ package gtPlusPlus.xmod.gregtech.common.render; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigInteger; +import java.io.*; import java.net.URL; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Base64; import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.List; import java.util.UUID; -import javax.crypto.Cipher; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import javax.xml.bind.DatatypeConverter; - import org.apache.commons.io.IOUtils; import org.lwjgl.opengl.GL11; import com.mojang.authlib.GameProfile; -import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.proxy.ClientProxy; -import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.AES; import gtPlusPlus.core.util.data.FileUtils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.sys.NetworkUtils; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelBiped; @@ -49,29 +31,28 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.common.UsernameCache; public class GTPP_CapeRenderer extends RenderPlayer { - private final ResourceLocation[] mCapes = { + private static final ResourceLocation[] mCapes = { new ResourceLocation("miscutils:textures/OrangeHD.png"), new ResourceLocation("miscutils:textures/FancyCapeHD.png"), new ResourceLocation("miscutils:textures/TesterCapeHD.png"), + new ResourceLocation("miscutils:textures/PatreonCapeHD.png"), new ResourceLocation("miscutils:textures/DevCapeHD.png"), - new ResourceLocation("miscutils:textures/PatreonCapeHD.png") }; + }; - private final ArrayList<String> mData; + private final boolean mInit; public GTPP_CapeRenderer() { - downloadCapeList(); - ArrayList<String> aTemp = new ArrayList<String>(); - try { - aTemp = returnDatData(); + mInit = init(); + } + + private final boolean init() { + if (mInit) { + return false; } - catch (Throwable t) { - aTemp = new ArrayList<String>(); - } - mData = aTemp; + return CapeUtils.init(); } private static boolean hasResourceChecked = false; @@ -80,107 +61,127 @@ public class GTPP_CapeRenderer extends RenderPlayer { private ResourceLocation tResource = null; public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { + + // Check we have set Render Manager if (this.renderManager == null) { hasSetRenderer = false; } + + // Set Render Manager if (!hasSetRenderer) { if (RenderManager.instance != null) { setRenderManager(RenderManager.instance); + hasSetRenderer = true; } - } - AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; - if (!ConfigSwitches.enableCustomCapes) { - aEvent.setCanceled(true); - Logger.WARNING("A1"); - return; - } - - if (hasResourceChecked) { - if (!hasCape && !CORE.DEVENV) { - aEvent.setCanceled(true); - Logger.WARNING("A2"); + } + + // Actually Render + if (hasSetRenderer) { + + // We have capes turned off, so let's not render. + if (!ConfigSwitches.enableCustomCapes) { return; } - } - // Make sure we don't keep checking on clients who dont have capes. - if (!hasResourceChecked) { - - // Time to Spliterate some data - Map<String, ResourceLocation> aPlayerData = new HashMap<String, ResourceLocation>(); - Map<String, String> aNameMap = new HashMap<String, String>(); - int i = 0; - if (!CORE.DEVENV) { - for (String s : mData) { - String[] aSplit = s.split("@"); - int a[] = new int[] { 0, mCapes.length - 1 }; - int aID = Integer.parseInt(aSplit[1]); - // Quick Check to prevent lag - Logger.WARNING("Trying to create UUID from - " + aSplit[0]); - UUID aPlayerID = UUID.fromString(aSplit[0]); - Logger.WARNING("Result: " + aPlayerID.toString()); - if (aPlayerID != null) { - if (UsernameCache.containsUUID(aPlayerID)) { - Logger.WARNING("UsernameCache contains a last known username for current players UUID."); - if (!UsernameCache.getLastKnownUsername(aPlayerID).toLowerCase() - .equals(ClientProxy.playerName)) { - Logger.WARNING("Last known name does not match current name. Checking next UUID."); - continue; - } else { - Logger.WARNING("Last known name does match current name."); - } - } else { - Logger.WARNING("UsernameCache did not hold results for current player, oops."); - continue; - } - } - String aPlayerName = this.getPlayerName("iteration-" + (i++), aSplit[0]); - aNameMap.put(aSplit[0], aPlayerName); - aPlayerData.put(aPlayerName, this.mCapes[Math.max(a[0], Math.min(aID, a[1]))]); + // We have already checked if this player has a cape, but since they do not, we best not render. + if (hasResourceChecked) { + if (!hasCape && !CORE.DEVENV) { + return; } } - // Set flag to only render this event if player has a cape. - for (String s : aNameMap.values()) { - if (s.toLowerCase().equals(ClientProxy.playerName)) { + // Allocate client player object + AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; + + // Make sure we don't keep checking on clients who dont have capes. + if (!hasResourceChecked) { + + // Get players UUID + String aPlayerUUID = aPlayer != null ? aPlayer.getGameProfile().getId().toString() : "BAD"; + + // If for whatever reason this fails, we just exit early. + if (aPlayerUUID.equals("BAD")) { + return; + } + + // Automatically allocate a Dev cape while in Dev mode. + if (tResource == null && CORE.DEVENV) { + tResource = mCapes[4]; hasCape = true; - tResource = aPlayerData.get(ClientProxy.playerName); - break; } - } - // Dev capes for dev mode. - if (CORE.DEVENV) { - hasCape = true; - tResource = mCapes[3]; - } + String aPlayerName = ClientProxy.playerName; - // Safety Check - if (tResource == null) { - if (aPlayerData.get(aPlayer.getDisplayName()) != null) { - tResource = aPlayerData.get(aPlayer.getDisplayName()); - } else { - hasCape = false; + // Check cape lists for the cape this player owns. + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mOrangeCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[0]; + hasCape = true; + break; + } + } } + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mMiscCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[1]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mBetaTestCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[2]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mPatreonCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[3]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair<String, String> aData : CapeUtils.mDevCapes) { + if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) { + tResource = mCapes[4]; + hasCape = true; + break; + } + } + } + hasResourceChecked = true; } - // Only run once. - hasResourceChecked = true; + if (hasResourceChecked) { + // We have met all the conditions, let's render that cape. + renderCapeOnPlayer(aEvent, aPlayer); + } } - if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() - || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { - aEvent.setCanceled(true); - Logger.WARNING("A3"); - return; - } + } + private final boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) { float aPartialTicks = aEvent.partialRenderTick; try { - if (tResource == null && CORE.DEVENV) { tResource = mCapes[3]; } + + // If player is invisible, don't render. + if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() + || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { + aEvent.setCanceled(true); + return false; + } if ((tResource != null) && (!aPlayer.getHideCape())) { bindTexture(tResource); @@ -221,14 +222,22 @@ public class GTPP_CapeRenderer extends RenderPlayer { GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); ((ModelBiped) this.mainModel).renderCloak(0.0625F); GL11.glPopMatrix(); + return true; } } catch (Throwable e) { - if (GT_Values.D1) { - e.printStackTrace(GT_Log.err); - } + } + return false; } + @SuppressWarnings("unused") + @Deprecated + /** + * Should be able to get the username from a UUID + * @param name - Players Name + * @param uuid - Players known UUID + * @return - The newest Player name + */ private String getPlayerName(String name, String uuid) { try { Logger.WORLD("[Capes++] Trying to UUID check " + name + "."); @@ -271,29 +280,242 @@ public class GTPP_CapeRenderer extends RenderPlayer { return name; } - private void downloadCapeList() { - if (!NetworkUtils.checkNetworkIsAvailableWithValidInterface()) { - return; - } - try { - File dat = new File(Utils.getMcDir(), "GTPP.dat"); - if (FileUtils.doesFileExist(dat)) { + + + private static class CapeUtils { + + private static char SPLIT_CHARACTER = '§'; + private static AES sAES; + + // UUID - Username + private static final AutoMap<Pair<String, String>> mOrangeCapes = new AutoMap<Pair<String, String>>(); + private static final AutoMap<Pair<String, String>> mMiscCapes = new AutoMap<Pair<String, String>>(); + private static final AutoMap<Pair<String, String>> mBetaTestCapes = new AutoMap<Pair<String, String>>(); + private static final AutoMap<Pair<String, String>> mPatreonCapes = new AutoMap<Pair<String, String>>(); + private static final AutoMap<Pair<String, String>> mDevCapes = new AutoMap<Pair<String, String>>(); + + private static final boolean init() { + CapeUtils.handleOldCapeCache(); + if (CORE.DEVENV) { + return true; + } + try { + if (shouldDownloadCapeList()) { + downloadCapeList(); + } + } + catch (Exception e) { + return false; + } + writeCacheToMaps(); + return true; + } + + + private static boolean shouldDownloadCapeList() { + if (!doesCapeCacheExistLocally()) { + return true; + } + if (isCapeCacheWeekOld()) { + return true; + } + return false; + } + + private static final boolean isCapeCacheWeekOld() { + if (!doesCapeCacheExistLocally()) { + return true; + } + else { + File dat = CapeUtils.getCapeCache(); Date dateLastMod = new Date(dat.lastModified()); Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000)); - if (!dateLastMod.before(dateNow)) { - return; + if (dateLastMod.before(dateNow)) { + return true; } } - InputStream inputStream = new URL("https://alkcorp.overminddl1.com/GTPP.dat").openStream(); - FileOutputStream fileOS = new FileOutputStream(dat); - IOUtils.copy(inputStream, fileOS); + return false; + } - } catch (Throwable t) { - Logger.INFO("Unable to download GT++ cape list."); + private static final void downloadCapeList() { + if (!NetworkUtils.checkNetworkIsAvailableWithValidInterface()) { + return; + } + try { + File dat = getCapeCache(); + File temp = allocateTempFile(); + InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream(); + FileOutputStream fileOS = new FileOutputStream(temp); + IOUtils.copy(inputStream, fileOS); + if (isDownloadedCapeListBigger(temp)) { + fileOS = new FileOutputStream(dat); + IOUtils.copy(inputStream, fileOS); + } + } catch (Throwable t) { + Logger.INFO("Unable to download GT++ cape list."); + } + } + + private static final boolean isDownloadedCapeListBigger(File aFile) { + double aExistingFileSize = (doesCapeCacheExistLocally() ? getCapeCache().length() : 0); + double aNewFileSize = aFile.length(); + if (aNewFileSize > aExistingFileSize) { + return true; + } + return false; + } + + private static void handleOldCapeCache() { + File aCacheFile = FileUtils.getFile("GTPP", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + aCacheFile.delete(); + } + } + + private static final boolean doesCapeCacheExistLocally() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + return true; + } + return false; + } + + private static final File getCapeCache() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + FileUtils.createFile(aCacheFile); + } + return aCacheFile; + } + + public static final List<String> getDataFromCache(){ + File aCacheFile = getCapeCache(); + List<String> aCache = FileUtils.readLines(aCacheFile); + if (aCache != null && !aCache.isEmpty()) { + return aCache; + } + return new AutoMap<String>(); + } + + private static final File allocateTempFile() { + File tempFile = null; + try { + tempFile = File.createTempFile("gtpp-", null); + } + catch (IOException e) { + e.printStackTrace(); + } + if (tempFile == null) { + tempFile = FileUtils.createFile("", "gtpp-"+MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE/2)), "tmp"); + } + tempFile.deleteOnExit(); + return tempFile; + } + + + public static final void writeCacheToMaps() { + List<String> aCacheData = getDataFromCache(); + if (aCacheData != null && !aCacheData.isEmpty()) { + if (sAES == null) { + sAES = new AES(); + } + AutoMap<String> aDecodedData = new AutoMap<String>(); + for (String aToDecode : aCacheData) { + aDecodedData.put(sAES.decode(aToDecode)); + } + if (!aDecodedData.isEmpty()) { + AutoMap<Pair<String, String>> aCapeType1 = new AutoMap<Pair<String, String>>(); + AutoMap<Pair<String, String>> aCapeType2 = new AutoMap<Pair<String, String>>(); + AutoMap<Pair<String, String>> aCapeType3 = new AutoMap<Pair<String, String>>(); + AutoMap<Pair<String, String>> aCapeType4 = new AutoMap<Pair<String, String>>(); + AutoMap<Pair<String, String>> aCapeType5 = new AutoMap<Pair<String, String>>(); + boolean didProcessStringData = false; + Logger.INFO("Decoded String Count: "+aDecodedData.size()); + for (String aToSplit : aDecodedData) { + String[] aSplitData = aToSplit.split(""+SPLIT_CHARACTER); + if (aSplitData != null && aSplitData.length >= 2) { + if (aSplitData[0] != null) { + Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]); + if (aCapeTypeID2 != null) { + int aCapeTypeID = aCapeTypeID2; + Pair<String, String> aFinalString = new Pair<String, String>("UUID: "+aSplitData[1], "Username: "+(aSplitData[2] != null && aSplitData[0].length() > 0 ? aSplitData[2] : "Not Specified")); + Logger.INFO("Cape Type: "+aCapeTypeID); + switch (aCapeTypeID) { + case 0: + aCapeType1.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType1.size()+" users."); + break; + case 1: + aCapeType2.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType2.size()+" users."); + break; + case 2: + aCapeType3.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType3.size()+" users."); + break; + case 3: + aCapeType4.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType4.size()+" users."); + break; + case 4: + aCapeType5.add(aFinalString); + Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType5.size()+" users."); + break; + default: + break; + } + } + } + } + } + if (!aCapeType1.isEmpty() || !aCapeType2.isEmpty() || !aCapeType3.isEmpty() || !aCapeType4.isEmpty() || !aCapeType5.isEmpty()) { + didProcessStringData = true; + } + else { + // did not process any data + } + if (didProcessStringData) { + if (!aCapeType1.isEmpty()) { + for (Pair<String, String> aUser : aCapeType1) { + Logger.INFO("Adding Generic cape for "+aUser.getKey()); + mOrangeCapes.add(aUser); + } + } + if (!aCapeType2.isEmpty()) { + for (Pair<String, String> aUser : aCapeType2) { + Logger.INFO("Adding Blue cape for "+aUser.getKey()); + mMiscCapes.add(aUser); + } + } + if (!aCapeType3.isEmpty()) { + for (Pair<String, String> aUser : aCapeType3) { + Logger.INFO("Adding Beta cape for "+aUser.getKey()); + mBetaTestCapes.add(aUser); + } + } + if (!aCapeType4.isEmpty()) { + for (Pair<String, String> aUser : aCapeType4) { + Logger.INFO("Adding Patreon cape for "+aUser.getKey()); + mPatreonCapes.add(aUser); + } + } + if (!aCapeType5.isEmpty()) { + for (Pair<String, String> aUser : aCapeType5) { + Logger.INFO("Adding Dev cape for "+aUser.getKey()); + mDevCapes.add(aUser); + } + } + } + } + else { + // No data decoded + } + } + else { + // Nothing was cached? + } } } - - /* TODO: fix this stuff \u002a\u002f\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0044\u0061\u0074\u0044\u0061\u0074\u0061\u0028\u0029\u007b\u000a\u0009\u0009\u0046\u0069\u006c\u0065\u0020\u0064\u0061\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0028\u0055\u0074\u0069\u006c\u0073\u002e\u0067\u0065\u0074\u004d\u0063\u0044\u0069\u0072\u0028\u0029\u002c\u0020\u0022\u0047\u0054\u0050\u0050\u002e\u0064\u0061\u0074\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0048\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u0028\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0020\u0062\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u0064\u0061\u0074\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006c\u0069\u006e\u0065\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0028\u006c\u0069\u006e\u0065\u0020\u003d\u0020\u0062\u0072\u002e\u0072\u0065\u0061\u0064\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0048\u002e\u0061\u0064\u0064\u0028\u006c\u0069\u006e\u0065\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0049\u004f\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u005b\u005d\u0020\u003d\u0020\u0048\u002e\u0067\u0065\u0074\u0028\u0030\u0029\u002e\u0073\u0070\u006c\u0069\u0074\u0028\u0022\u0025\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0020\u003a\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0073\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0020\u0026\u0026\u0020\u0073\u002e\u006c\u0065\u006e\u0067\u0074\u0068\u0028\u0029\u0020\u003e\u0020\u0030\u0020\u0026\u0026\u0020\u0021\u0073\u002e\u0065\u0071\u0075\u0061\u006c\u0073\u0028\u0022\u0020\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0073\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0030\u0030\u0031\u0020\u0030\u0031\u0030\u0031\u0030\u0030\u0031\u0022\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0031\u0030\u0030\u0020\u0030\u0031\u0031\u0030\u0031\u0031\u0031\u0022\u003b\u000a\u0009\u0009\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0068\u0020\u003a\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0029\u0020\u007b\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u003d\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0068\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0029\u003b\u000a\u0009\u0009\u0009\u0061\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0061\u0044\u0061\u0074\u0061\u003b\u0009\u0009\u000a\u0009\u007d\u000a\u0009\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006d\u0064\u0035\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0070\u0075\u0074\u0029\u0020\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u006d\u0064\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u004d\u0044\u0035\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u003d\u0020\u006d\u0064\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0069\u006e\u0070\u0075\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0028\u0031\u002c\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0029\u003b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0066\u006f\u0072\u006d\u0061\u0074\u0028\u0022\u0025\u0030\u0033\u0032\u0078\u0022\u002c\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0029\u003b\u000a\u0009\u007d\u000a\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0069\u006e\u0069\u0074\u0043\u0069\u0070\u0068\u0065\u0072\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0069\u006e\u0074\u0020\u006d\u006f\u0064\u0065\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u000a\u0009\u0009\u0009\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u004b\u0065\u0079\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u000a\u0009\u0009\u0009\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0028\u0074\u006f\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0028\u006d\u0064\u0035\u0028\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u0029\u002c\u0020\u0022\u0041\u0045\u0053\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0028\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0043\u0046\u0042\u0038\u002f\u004e\u006f\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0022\u0029\u003b\u000a\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u006d\u006f\u0064\u0065\u002c\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u002c\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0029\u003b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u003b\u000a\u0009\u007d\u000a\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0074\u006f\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0029\u0020\u007b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0044\u0061\u0074\u0061\u0074\u0079\u0070\u0065\u0043\u006f\u006e\u0076\u0065\u0072\u0074\u0065\u0072\u002e\u0070\u0061\u0072\u0073\u0065\u0048\u0065\u0078\u0042\u0069\u006e\u0061\u0072\u0079\u0028\u0073\u0029\u003b\u000a\u0009\u007d\u000a\u0009\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u0020\u007b\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0069\u006e\u0069\u0074\u0043\u0069\u0070\u0068\u0065\u0072\u0028\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0044\u0045\u0043\u0052\u0059\u0050\u0054\u005f\u004d\u004f\u0044\u0045\u002c\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u002c\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u003b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0020\u003d\u0020\u0042\u0061\u0073\u0065\u0036\u0034\u002e\u0067\u0065\u0074\u0044\u0065\u0063\u006f\u0064\u0065\u0072\u0028\u0029\u002e\u0064\u0065\u0063\u006f\u0064\u0065\u0028\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0029\u003b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0020\u003d\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0064\u006f\u0046\u0069\u006e\u0061\u006c\u0028\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0029\u003b\u000a\u0009\u0009\u0009\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u002c\u0020\u0022\u0055\u0054\u0046\u0038\u0022\u0029\u003b\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u003b\u000a\u0009\u007d\u002f\u002a */ - + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java index 2f00600af6..faaabbd159 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java @@ -183,7 +183,7 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); } else { - if (this.mTier < (CORE.GTNH ? GT_Values.V.length : 9)) { + if (this.mTier < (CORE.GTNH ? GT_Values.V.length-1 : 9)) { this.mTier++; } else { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java index 6a154051d5..31c9636cac 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -1,25 +1,28 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaTileEntity_IndustrialCuttingMachine extends GregtechMeta_MultiBlockBase { + + private boolean mCuttingMode = true; + public GregtechMetaTileEntity_IndustrialCuttingMachine(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -35,7 +38,7 @@ extends GregtechMeta_MultiBlockBase { @Override public String getMachineType() { - return "Cutting Machine"; + return "Cutting Machine / Slicing Machine"; } @Override @@ -74,7 +77,7 @@ extends GregtechMeta_MultiBlockBase { @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCutterRecipes; + return mCuttingMode ? GT_Recipe.GT_Recipe_Map.sCutterRecipes : GT_Recipe.GT_Recipe_Map.sSlicerRecipes; } @Override @@ -202,11 +205,22 @@ extends GregtechMeta_MultiBlockBase { return (byte) TAE.GTPP_INDEX(29); } - private boolean addToMachineList(final IGregTechTileEntity tTileEntity) { - return ((this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex()))); + @Override + public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mCuttingMode = Utils.invertBoolean(mCuttingMode); + String aMode = mCuttingMode ? "Cutting" : "Slicing"; + PlayerUtils.messagePlayer(aPlayer, "Mode: "+aMode); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mCuttingMode", mCuttingMode); } - private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { - return ((this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()))); + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mCuttingMode = aNBT.getBoolean("mCuttingMode"); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java index d06b7ed0d1..9dca082807 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java @@ -1,8 +1,13 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import org.apache.commons.lang3.ArrayUtils; + import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; @@ -11,15 +16,19 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_MillingBalls; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; @@ -30,6 +39,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase { @@ -40,7 +50,8 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase private static ITexture frontFace; private static ITexture frontFaceActive; - + + private ArrayList<GT_MetaTileEntity_Hatch_MillingBalls> mMillingBallBuses = new ArrayList<GT_MetaTileEntity_Hatch_MillingBalls>(); private static final DamageSource mIsaMillDamageSource = new DamageSource("gtpp.grinder").setDamageBypassesArmor(); public GregtechMetaTileEntity_IsaMill(int aID, String aName, String aNameRegional) { @@ -85,6 +96,20 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase return getMaxEfficiency(aStack) > 0; } + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MillingBalls) { + log("Found GT_MetaTileEntity_Hatch_MillingBalls"); + return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeDieselEngine.png"); } @@ -96,10 +121,15 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mMillingBallBuses.clear(); + } + } if (aTick % 20 == 0) { checkForEntities(aBaseMetaTileEntity, aTick); } + super.onPostTick(aBaseMetaTileEntity, aTick); } private final AutoMap<BlockPos> mFrontBlockPosCache = new AutoMap<BlockPos>(); @@ -401,4 +431,259 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase public int getEuDiscountForParallelism() { return 0; } + + /* + * Milling Ball Handling + */ + + @Override + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_MillingBalls tHatch : mMillingBallBuses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getContentUsageSlots()); + } + } + return tItems; + } + + + public int getMaxBallDurability(ItemStack aStack) { + return ItemGenericChemBase.getMaxBallDurability(aStack); + } + + private ItemStack findMillingBall(ItemStack[] aItemInputs) { + if (mMillingBallBuses.isEmpty() || mMillingBallBuses.size() > 1) { + return null; + } + else { + GT_MetaTileEntity_Hatch_MillingBalls aBus = mMillingBallBuses.get(0); + if (aBus != null) { + AutoMap<ItemStack> aAvailableItems = aBus.getContentUsageSlots(); + if (!aAvailableItems.isEmpty()) { + for (final ItemStack aInput : aItemInputs) { + if (ItemUtils.isMillingBall(aInput)) { + for (ItemStack aBall : aAvailableItems) { + if (GT_Utility.areStacksEqual(aBall, aInput, true)) { + Logger.INFO("Found a valid milling ball to use."); + return aBall; + } + } + } + } + } + } + } + return null; + } + + + private void damageMillingBall(ItemStack aStack) { + if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * 1))) { + int damage = getMillingBallDamage(aStack) + 1; + log("damage milling ball "+damage); + if (damage >= getMaxBallDurability(aStack)) { + log("consuming milling ball"); + aStack.stackSize -= 1; + } + else { + setDamage(aStack,damage); + } + } + else { + log("not damaging milling ball"); + } + } + + private int getMillingBallDamage(ItemStack aStack) { + return ItemGenericChemBase.getMillingBallDamage(aStack); + } + + private void setDamage(ItemStack aStack,int aAmount) { + ItemGenericChemBase.setMillingBallDamage(aStack, aAmount); + } + + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + // checks if it has a milling ball with enough durability + ItemStack tMillingBallRecipe = findMillingBall(aItemInputs); + if (tMillingBallRecipe == null) { + log("does not have milling ball"); + return false; + } + + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + log("aEUPercent "+aEUPercent); + log("mEUt "+tRecipe.mEUt); + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+1); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tEnergy: "+tEnergy); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < 1 && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List<ItemStack> splitStacks = new ArrayList<ItemStack>(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + + // Damage Milling ball once all is said and done. + if (tMillingBallRecipe != null) { + log("damaging milling ball"); + damageMillingBall(tMillingBallRecipe); + } + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java index aad16d3a56..f6cc06059b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.a import java.lang.reflect.Method; +import gregtech.GT_Mod; import gregtech.api.enums.Dyes; import gregtech.api.enums.GT_Values; import gregtech.api.enums.TAE; @@ -25,6 +26,7 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_FusionComputer { @@ -282,5 +284,96 @@ public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_Fus private boolean isFusionCoil(int aX, int aY, int aZ) { return (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getFusionCoil() && (getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getFusionCoilMeta())); } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (mEfficiency < 0) + mEfficiency = 0; + if (mRunningOnLoad && checkMachine(aBaseMetaTileEntity, mInventory[1])) { + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipe(mInventory[1]); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + mInputHatches.clear(); + mInputBusses.clear(); + mOutputHatches.clear(); + mOutputBusses.clear(); + mDynamoHatches.clear(); + mEnergyHatches.clear(); + mMufflerHatches.clear(); + mMaintenanceHatches.clear(); + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + } + if (mStartUpCheck < 0) { + if (mMachine) { + if (this.mEnergyHatches != null) { + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) { + long aVoltage = GT_Values.V[tHatch.mTier]; + if (aBaseMetaTileEntity.getStoredEU() + (aVoltage) < maxEUStore() + && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aVoltage, false)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(aVoltage, true); + } + } + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + stopMachine(); + } + if (getRepairStatus() > 0) { + if (mMaxProgresstime > 0) { + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputItems != null) + for (ItemStack tStack : mOutputItems) if (tStack != null) addOutput(tStack); + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) if (tStack != null) addOutput(tStack); + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + mOutputItems = null; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) { + try { + GT_Mod.instance.achievements.issueAchivementHatchFluid(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), mOutputFluids[0]); + } catch (Exception e) { + } + } + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) + checkRecipe(mInventory[1]); + } + } else { + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { + turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (checkRecipe(mInventory[1])) { + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + mMaxProgresstime = 0; + turnCasingActive(false); + } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); + } + } + if (mMaxProgresstime <= 0) + mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + this.mLastRecipe = null; + stopMachine(); + } + } else { + turnCasingActive(false); + this.mLastRecipe = null; + stopMachine(); + } + } + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) + | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java new file mode 100644 index 0000000000..1ceb6bd93f --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java @@ -0,0 +1,492 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase { + + public GregtechMTE_FrothFlotationCell(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_FrothFlotationCell(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_FrothFlotationCell(this.mName); + } + + @Override + public String getMachineType() { + return "Flotation Cell"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Process that milled ore!", + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + + @Override + public boolean isFacingValid(final byte aFacing) { + if (aFacing == 0 || aFacing > 1) { + return false; + } + return true; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + int aID = TAE.getIndexFromPage(2, 1); + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID]}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return Recipe_GT.Gregtech_Recipe_Map.sFlotationCellRecipes; + } + + @Override + public int getMaxParallelRecipes() { + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + Block aCasing1 = ModBlocks.blockCasings3Misc; + int aCasingMeta1 = 1; + Block aCasing2 = ModBlocks.blockSpecialMultiCasings; + int aCasingMeta2 = 9; + int aCasingCount1 = 0; + int aCasingCount2 = 0; + int aControllerY = aBaseMetaTileEntity.getYCoord(); + // Check adjacent blocks + for (byte side = 2; side < 6; side++) { + Block aBlock = aBaseMetaTileEntity.getBlockAtSide(side); + int aMeta = aBaseMetaTileEntity.getMetaIDAtSide(side); + if (this.isValidBlockForStructure(null, 0, false, aBlock, aMeta, aCasing1, aCasingMeta1)) { + aCasingCount1++; + } + else { + log("Bad block at Y:"+(aControllerY)); + return false; + } + } + // Check first layer + aControllerY--; + for (int x = -2; x < 3; x++) { + for (int z = -2; z < 3; z++) { + + int aWorldOffsetX = aBaseMetaTileEntity.getXCoord() + x; + int aWorldOffsetZ = aBaseMetaTileEntity.getZCoord() + z; + + // Don't check air + if ((x == -2 && z != 0) || (x == 2 && z != 0) || (z == -2 && x != 0) || (z == 2 && x != 0) || (x == 0 && z == 0)) { + continue; + } + else { + Block aBlock = aBaseMetaTileEntity.getBlock(aWorldOffsetX, aControllerY, aWorldOffsetZ); + int aMeta = aBaseMetaTileEntity.getMetaID(aWorldOffsetX, aControllerY, aWorldOffsetZ); + if (this.isValidBlockForStructure(null, 0, false, aBlock, aMeta, aCasing2, aCasingMeta2)) { + aCasingCount2++; + } + else { + log("Bad block at Y:"+(aControllerY)+", X:"+aWorldOffsetX+", Z:"+aWorldOffsetZ); + aBaseMetaTileEntity.getWorld().setBlock(aWorldOffsetX, aControllerY, aWorldOffsetZ, Blocks.bookshelf); + return false; + } + } + } + } + // Check circular tower + aControllerY--; + for (int y = aControllerY; y > (aControllerY-5); y--) { + for (int x = -2; x < 3; x++) { + for (int z = -2; z < 3; z++) { + + int aWorldOffsetX = aBaseMetaTileEntity.getXCoord() + x; + int aWorldOffsetZ = aBaseMetaTileEntity.getZCoord() + z; + + // Don't check air + if ((x == -2 && z != 0) || (x == 2 && z != 0) || (z == -2 && x != 0) || (z == 2 && x != 0) || (x == 0 && z == 0)) { + continue; + } + // Don't check air + else if ((x == -1 && z == 0) || (x == 1 && z == 0) || (z == -1 && x == 0) || (z == 1 && x == 0) || (x == 0 && z == 0)) { + continue; + } + else { + Block aBlock = aBaseMetaTileEntity.getBlock(aWorldOffsetX, y, aWorldOffsetZ); + int aMeta = aBaseMetaTileEntity.getMetaID(aWorldOffsetX, y, aWorldOffsetZ); + if (this.isValidBlockForStructure(null, 0, false, aBlock, aMeta, aCasing2, aCasingMeta2)) { + aCasingCount2++; + } + else { + log("Bad block at Y:"+(y)+", X:"+aWorldOffsetX+", Z:"+aWorldOffsetZ); + return false; + } + } + } + } + } + // Check Base + aControllerY -= 5; + for (int y = aControllerY; y > (aControllerY-2); y--) { + for (int x = -3; x < 4; x++) { + for (int z = -3; z < 4; z++) { + int aWorldOffsetX = aBaseMetaTileEntity.getXCoord() + x; + int aWorldOffsetZ = aBaseMetaTileEntity.getZCoord() + z; + if ((x == -3 && z == -3) || (x == 3 && z == 3) || (x == -3 && z == 3) || (x == 3 && z == -3)) { + continue; + } + else if ((x == -3 && z == -2) || (x == -2 && z == -3) || (x == 3 && z == 2) || (x == 2 && z == 3)) { + continue; + } + else if ((x == -2 && z == 3) || (x == -3 && z == 2) || (x == 3 && z == -2) || (x == 2 && z == -3)) { + continue; + } + else { + Block aBlock = aBaseMetaTileEntity.getBlock(aWorldOffsetX, y, aWorldOffsetZ); + int aMeta = aBaseMetaTileEntity.getMetaID(aWorldOffsetX, y, aWorldOffsetZ); + IGregTechTileEntity aTile = aBaseMetaTileEntity.getIGregTechTileEntity(aWorldOffsetX, y, aWorldOffsetZ); + if (this.isValidBlockForStructure(aTile, TAE.getIndexFromPage(2, 1), true, aBlock, aMeta, aCasing1, aCasingMeta1)) { + if (aTile == null) { + aCasingCount1++; + } + } + else { + log("Bad block at Y:"+(y)+", X:"+aWorldOffsetX+", Z:"+aWorldOffsetZ); + return false; + } + } + } + } + } + if (aCasingCount1 < 68) { + log("Inconel Casings found: "+aCasingCount1); + log("Inconel Casings required: 68"); + return false; + } + if (aCasingCount2 < 52) { + log("Flotation Casings found: "+aCasingCount2); + log("Flotation Casings required: 52"); + return false; + } + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + // Fix GT bug + if (this.getBaseMetaTileEntity().getFrontFacing() == 0 && this.getBaseMetaTileEntity().getBackFacing() == 1) { + log("Fixing Bad Facing. (GT Bug)"); + this.getBaseMetaTileEntity().setFrontFacing((byte) 1); + } + } + + @Override + public boolean checkRecipe(ItemStack arg0) { + return super.checkRecipeGeneric(); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + // Based on the Processing Array. A bit overkill, but very flexible. + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + + log("Running checkRecipeGeneric(1)"); + // Remember last recipe - an optimization for findRecipe() + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + log("BAD RETURN - 1"); + return false; + } + + /* + * + * Material Hash checks + * Makes sure we can only ever use one type of material in this flotation cell. + * + */ + int aExpectedMaterialHash; + // Set the hash of expected material type + if (mLockedOreType == -1) { + mLockedOreType = FlotationRecipeHandler.getHashForMaterial(FlotationRecipeHandler.getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(aRecipe))); + } + // Set the hash for this recipe check + aExpectedMaterialHash = mLockedOreType; + + // Compute hash of current inputs + int aFoundMaterialHash = FlotationRecipeHandler.getHashForMaterial(FlotationRecipeHandler.getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(aItemInputs))); + + // Check hashes match + if (aExpectedMaterialHash != aFoundMaterialHash) { + log("Did not find the correct milled type."); + log("Found: "+aFoundMaterialHash); + log("Expected: "+mLockedOreType); + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+aMaxParallelRecipes); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); + float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); + this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= parallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < parallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List<ItemStack> splitStacks = new ArrayList<ItemStack>(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + log("GOOD RETURN - 1"); + return true; + } + + /* + * Handle NBT + */ + + private int mLockedOreType = -1; + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (mLockedOreType != -1) { + aNBT.setInteger("mLockedOreType", mLockedOreType); + } + super.setItemNBT(aNBT); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (mLockedOreType != -1) { + aNBT.setInteger("mLockedOreType", mLockedOreType); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mLockedOreType = aNBT.getInteger("mLockedOreType"); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 81d1581724..9064921c6a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -21,11 +21,13 @@ import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -42,6 +44,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { private int mPipeCasingTier = 0; private int mCoilTier = 0; + private ArrayList<GT_MetaTileEntity_Hatch_Catalysts> mCatalystBuses = new ArrayList<GT_MetaTileEntity_Hatch_Catalysts>(); + public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -664,6 +668,19 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return 0; } + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts) { + log("Found GT_MetaTileEntity_Hatch_Catalysts"); + return addToMachineListInternal(mCatalystBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + public int getMachineCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { Block aInitStructureCheck; int aInitStructureCheckMeta; @@ -734,11 +751,16 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mCatalystBuses.clear(); + } + } // Silly Client Syncing if (aBaseMetaTileEntity.isClientSide()) { this.mSolidCasingTier = getCasingTierOnClientSide(); } + super.onPostTick(aBaseMetaTileEntity, aTick); } @Override @@ -771,6 +793,13 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { long tEnergy = getMaxInputEnergy(); log("Running checkRecipeGeneric(0)"); + // checks if it has a catalyst with enough durability + ItemStack tCatalystRecipe = findCatalyst(aItemInputs); + if (tCatalystRecipe == null) { + log("does not have catalyst"); + return false; + } + GT_Recipe tRecipe = findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); @@ -801,11 +830,10 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { // checks if it has enough catalyst durabilety ArrayList<ItemStack>tCatalysts = null; int tMaxParrallelCatalyst = aMaxParallelRecipes; - ItemStack tCatalystRecipe = findCatalyst(tRecipe.mInputs); if (tCatalystRecipe != null) { - log("has catalyst"); tCatalysts = new ArrayList<ItemStack>(); - tMaxParrallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes,tCatalysts); + tMaxParrallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes, tCatalysts); + log("Can process "+tMaxParrallelCatalyst+" recipes. If less than "+aMaxParallelRecipes+", catalyst does not have enough durability."); } if (tMaxParrallelCatalyst == 0) { @@ -842,20 +870,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return false; } - if (tCatalysts != null) { - log("damaging catalyst"); - for (int j = 0;j<parallelRecipes;j++) { - log("j = "+j); - for (int i = 0;i<tCatalysts.size();i++) { - log("i = "+i); - if (tCatalysts.get(i) != null && tCatalysts.get(i).stackSize != 0) { - damageCatalyst(tCatalysts.get(i)); - break; - } - } - } - } - // -- Try not to fail after this point - inputs have already been consumed! -- @@ -942,6 +956,12 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + // Damage catalyst once all is said and done. + if (tCatalystRecipe != null) { + log("damaging catalyst"); + damageCatalyst(tCatalystRecipe, parallelRecipes); + } + // Commit outputs this.mOutputItems = tOutputItems; this.mOutputFluids = tOutputFluids; @@ -954,23 +974,12 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return true; } - private int getCatalysts(ItemStack[] aItemInputs,ItemStack aRecipeCatalyst,int aMaxParrallel,ArrayList<ItemStack> aOutPut) { + private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParrallel, ArrayList<ItemStack> aOutPut) { int allowedParrallel = 0; for (final ItemStack aInput : aItemInputs) { - if (aRecipeCatalyst.isItemEqual(aInput)) { - if (aInput.stackSize == 1) { - int damage = getDamage(aInput) + aMaxParrallel; - if (damage > getMaxCatalystDurability() ) { - aOutPut.add(aInput); - allowedParrallel += aMaxParrallel + (getMaxCatalystDurability() - damage); - if (allowedParrallel >aMaxParrallel ) { - return aMaxParrallel; - } - continue; - } - } - aOutPut.add(aInput); - return aMaxParrallel; + if (aRecipeCatalyst.isItemEqual(aInput)) { + int aDurabilityRemaining = getMaxCatalystDurability() - getDamage(aInput); + return Math.min(aMaxParrallel, aDurabilityRemaining); } } return allowedParrallel; @@ -990,42 +999,36 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } - private void damageCatalyst(ItemStack aStack) { - if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { - int damage = getDamage(aStack) + 1; - log("damage catalyst "+damage); - if (damage >= getMaxCatalystDurability()) { - log("consume catalyst"); - ItemStack emptyCatalyst = CI.getEmptyCatalyst(1); - addOutput(emptyCatalyst); - setDamage(aStack,0); - aStack.stackSize -= 1; + private void damageCatalyst(ItemStack aStack, int parallelRecipes) { + for (int i=0; i<parallelRecipes; i++){ + if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { + int damage = getDamage(aStack) + 1; + log("damage catalyst "+damage); + if (damage >= getMaxCatalystDurability()) { + log("consume catalyst"); + addOutput(CI.getEmptyCatalyst(1)); + aStack = null; + } + else { + log("damaging catalyst"); + setDamage(aStack, damage); + } } else { - setDamage(aStack,damage); + log("not consuming catalyst"); } - } - else { - log("not consuming catalyst"); } + + + } private int getDamage(ItemStack aStack) { - if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setInteger("Damage", 0); - tagMain.setTag("catalyst", tagNBT); - aStack.setTagCompound(tagMain); - } - NBTTagCompound aNBT = aStack.getTagCompound(); - return aNBT.getCompoundTag("catalyst").getInteger("Damage"); + return ItemGenericChemBase.getCatalystDamage(aStack); } private void setDamage(ItemStack aStack,int aAmount) { - NBTTagCompound aNBT = aStack.getTagCompound(); - aNBT = aNBT.getCompoundTag("catalyst"); - aNBT.setInteger("Damage", aAmount); + ItemGenericChemBase.setCatalystDamage(aStack, aAmount); } @@ -1081,6 +1084,23 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { + /* + * Catalyst Handling + */ + + + + @Override + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_Catalysts tHatch : mCatalystBuses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getContentUsageSlots()); + } + } + return tItems; + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java index d4a25e03dd..da93fe212c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java @@ -46,9 +46,8 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base { } private void generateRecipes(final Material material, final boolean disableOptional){ - final int tVoltageMultiplier = material.vVoltageMultiplier; - Logger.WARNING("Generating Shaped Crafting recipes for "+material.getLocalizedName()); //TODO + Logger.WARNING("Generating Shaped Crafting recipes for "+material.getLocalizedName()); final ItemStack normalDust = material.getDust(1); final ItemStack smallDust = material.getSmallDust(1); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java new file mode 100644 index 0000000000..321cab4628 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AddCustomMachineToPA.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.loaders.misc; + +import java.lang.reflect.Method; + +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.util.reflect.ReflectionUtils; + +public class AddCustomMachineToPA { + + private static final boolean sDoesPatchExist; + private static final Class sManagerPA; + private static final Method sRegisterRecipeMapForMeta; + + static { + sDoesPatchExist = ReflectionUtils.doesClassExist("gregtech.api.util.GT_ProcessingArray_Manager"); + if (sDoesPatchExist) { + sManagerPA = ReflectionUtils.getClass("gregtech.api.util.GT_ProcessingArray_Manager"); + sRegisterRecipeMapForMeta = ReflectionUtils.getMethod(sManagerPA, "registerRecipeMapForMeta", int.class, GT_Recipe_Map.class); + } + else { + sManagerPA = null; + sRegisterRecipeMapForMeta = null; + } + } + + public static final void registerRecipeMapForID(int aID, GT_Recipe_Map aMap) { + if (sDoesPatchExist) { + ReflectionUtils.invokeNonBool(null, sRegisterRecipeMapForMeta, new Object[] {aID, aMap}); + } + + } + + public static final void registerRecipeMapBetweenRangeOfIDs(int aMin, int aMax, GT_Recipe_Map aMap) { + if (sDoesPatchExist) { + for (int i=aMin; i<=aMax;i++) { + ReflectionUtils.invokeNonBool(null, sRegisterRecipeMapForMeta, new Object[] {i, aMap}); + //GT_ProcessingArray_Manager.registerRecipeMapForMeta(i, aMap); + } + } + } + + public static void register() { + + // Simple Washers + registerRecipeMapForID(767, Recipe_GT.Gregtech_Recipe_Map.sSimpleWasherRecipes); + registerRecipeMapBetweenRangeOfIDs(31017, 31020, Recipe_GT.Gregtech_Recipe_Map.sSimpleWasherRecipes); + + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index cc3130af98..6b5d8d6802 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -11,14 +11,8 @@ import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.interfaces.internal.IGT_RecipeAdder; -import gregtech.api.util.CustomRecipeMap; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; +import gregtech.api.util.*; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.Recipe_GT; -import gregtech.api.util.SemiFluidFuelHandler; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; @@ -33,6 +27,7 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; import gtPlusPlus.xmod.gregtech.recipes.machines.RECIPEHANDLER_MatterFabricator; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -40,1118 +35,1138 @@ import net.minecraftforge.oredict.OreDictionary; public class GregtechRecipeAdder implements IGregtech_RecipeAdder { - @Override - public boolean addCokeOvenRecipe(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, - final FluidStack aFluidOutput, final ItemStack aOutput, int aDuration, final int aEUt) { - try { - try { - // RECIPEHANDLER_CokeOven.debug1(); - if (((aInput1 == null) /* && (aFluidInput == null) */) - || ((aOutput == null) || (aFluidOutput == null))) { - // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" - // aInput2:"+aInput2.toString()+" - // aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Something was null, returning false"); - return false; - } - - } - catch (final NullPointerException e) { - e.getStackTrace(); - } - try { - // RECIPEHANDLER_CokeOven.debug2(aInput1, aInput2, aFluidInput, - // aFluidOutput, aOutput, aDuration, aEUt); - if ((aOutput != null) - && ((aDuration = GregTech_API.sRecipeFile.get("cokeoven", aOutput, aDuration)) <= 0)) { - // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" - // aInput2:"+aInput2.toString()+" - // aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Something was null, returning false"); - return false; - } - - } - catch (final NullPointerException e) { - e.getStackTrace(); - } - try { - // RECIPEHANDLER_CokeOven.debug3(aInput1, aInput2, aFluidInput, - // aFluidOutput, aOutput, aDuration, aEUt); - if ((aFluidOutput == null) || ((aDuration = GregTech_API.sRecipeFile.get("cokeoven", - aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { - // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" - // aInput2:"+aInput2.toString()+" - // aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Something was null, returning false"); - return false; - } - - } - catch (final NullPointerException e) { - e.getStackTrace(); - } - try { - // RECIPEHANDLER_CokeOven.debug4(aInput1, aInput2, aFluidInput, - // aFluidOutput, aOutput, aDuration, aEUt); - if (aFluidInput == null && aInput2 != null) { - Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, - new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, - aEUt, 0); - } - else if (aFluidInput == null && aInput2 == null) { - Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1 }, - new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, - aEUt, 0); - } - else { - Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, - new ItemStack[] { aOutput }, null, null, new FluidStack[] { aFluidInput }, - new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - } - // RECIPEHANDLER_CokeOven.debug5(aInput1, aInput2, aFluidInput, - // aFluidOutput, aOutput, aDuration, aEUt); - - return true; - - } - catch (final NullPointerException e) { - Logger.WARNING("Something was null, returning false"); - return false; - } - } - catch (final Throwable e) { - // Logger.WARNING("aInput1:"+aInput1.toString()+" - // aInput2:"+aInput2.toString()+" - // aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Failed."); - e.getStackTrace(); - return false; - } - } - - @Override - public boolean addMatterFabricatorRecipe(final FluidStack aFluidInput, final FluidStack aFluidOutput, - final int aDuration, final int aEUt) { - try { - try { - // RECIPEHANDLER_MatterFabricator.debug1(); - if (aFluidOutput == null) { - // Utils.LOG_WARNING("aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" - // aDuration:"+aDuration+" aEU/t:"+aEUt); - Logger.WARNING("Something was null, returning false"); - return false; - } - - } - catch (final NullPointerException e) { - e.getStackTrace(); - } - try { - - // RECIPEHANDLER_MatterFabricator.debug4(aFluidInput, - // aFluidOutput, aDuration, aEUt); - if (aFluidInput == null) { - // Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, - // null, new FluidStack[]{aFluidOutput}, aDuration, aEUt, - // 0); - Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, null, null, null, null, - new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - } - else { - // Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, - // new FluidStack[]{aFluidInput}, new - // FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); - Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, null, null, null, - new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - } - RECIPEHANDLER_MatterFabricator.debug5(aFluidInput, aFluidOutput, aDuration, aEUt); - - return true; - - } - catch (final NullPointerException e) { - return false; - } - } - catch (final Throwable e) { - // Utils.LOG_WARNING("aFluidInput:"+aFluidInput.toString()+" - // aFluidOutput:"+aFluidOutput.toString()+" aDuration:"+aDuration+" - // aEU/t:"+aEUt); - Logger.WARNING("Failed."); - e.getStackTrace(); - return false; - } - } - - @Override - public boolean addMatterFabricatorRecipe(final ItemStack aInputStack, final FluidStack aFluidInput, - final FluidStack aFluidOutput, final int aDuration, final int aEUt) { - try { - try { - if ((aFluidOutput == null) || (aInputStack == null)) { - return false; - } - } - catch (final NullPointerException e) { - } - try { - if (aFluidInput == null) { - Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, new ItemStack[] { aInputStack }, - null, null, null, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - } - else { - Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, new ItemStack[] { aInputStack }, - null, null, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, - aEUt, 0); - } - RECIPEHANDLER_MatterFabricator.debug5(aFluidInput, aFluidOutput, aDuration, aEUt); - return true; - } - catch (final NullPointerException e) { - return false; - } - } - catch (final Throwable e) { - return false; - } - } - - @Override - public boolean addFuel(final ItemStack aInput1, final ItemStack aOutput1, final int aEU, final int aType) { - if (aInput1 == null) { - Logger.WARNING("Fuel Input is Invalid."); - return false; - } - // new GregtechRecipe(aInput1, aOutput1, - // GregTech_API.sRecipeFile.get("fuel_" + aType, aInput1, aEU), aType); - return true; - } - - /* - * @Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack - * aItemB, FluidStack aFluid, ItemStack[] aOutputItems, FluidStack - * aOutputFluid, int aDuration, int aEUt) { if ((aItemA == null) || (aItemB - * == null) || (aOutputItems == null)) { return false; } for (ItemStack - * tStack : aOutputItems) { if (tStack != null) { if ((aDuration = - * GregTech_API.sRecipeFile.get("dehydrator", aItemA, aDuration)) <= 0) { - * return false; } - * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, - * new ItemStack[]{aItemA, aItemB}, aOutputItems, null, null, null, - * aDuration, aEUt, 0); RECIPEHANDLER_Dehydrator.debug5(aItemA, aItemB, - * aFluid, aOutputFluid, aOutputItems, aDuration, aEUt); return true; } } - * return false; } - * @Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack - * aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt) { if ((aItemA - * == null) || (aItemB == null) || (aOutputItems == null)) { return false; } - * if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aItemA, - * aDuration)) <= 0) { return false; } - * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, - * new ItemStack[]{aItemA, aItemB}, aOutputItems, null, null, null, - * aDuration, aEUt, 0); RECIPEHANDLER_Dehydrator.debug5(aItemA, aItemB, - * null, null, aOutputItems, aDuration, aEUt); return true; } - * @Override public boolean addDehydratorRecipe(FluidStack aFluid, - * FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int - * aEUt){ if ((aFluid == null) || (aOutputFluid == null || aOutputItems == - * null)) { return false; } if ((aDuration = - * GregTech_API.sRecipeFile.get("dehydrator", aFluid.getUnlocalizedName(), - * aDuration)) <= 0) { return false; } - * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, - * null, aOutputItems, null, new FluidStack[]{aFluid}, new - * FluidStack[]{aOutputFluid}, aDuration, aEUt, 0); - * RECIPEHANDLER_Dehydrator.debug5(null, null, aFluid, aOutputFluid, - * aOutputItems, aDuration, aEUt); return true; } - */ - - @Override - public boolean addDehydratorRecipe(final ItemStack aInput, final FluidStack aFluid, final ItemStack[] aOutput, - int aDuration, final int aEUt) { - Logger.WARNING("Trying to add a Dehydrator recipe."); - try { - if ((aInput == null) || (aFluid == null) || (aOutput == null)) { - return false; - } - if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aInput, aDuration)) <= 0) { - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, new ItemStack[] { aInput }, - aOutput, null, new FluidStack[] { aFluid }, null, aDuration, aEUt, 0); - // RECIPEHANDLER_Dehydrator.debug5(aInput, null, aFluid, null, - // aOutput, aDuration, aEUt); - return true; - } - catch (final NullPointerException e) { - Logger.WARNING("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); - return false; - } - } - - @Override - public boolean addDehydratorRecipe(final ItemStack[] aInput, final FluidStack aFluidInput, - final FluidStack aFluidOutput, final ItemStack[] aOutputItems, final int[] aChances, int aDuration, - final int aEUt) throws IndexOutOfBoundsException { - Logger.WARNING("Trying to add a Dehydrator recipe."); - try { - if (aInput[0] != null) { - Logger.WARNING("Recipe requires input: " + aInput[0].getDisplayName() + " x" + aInput[0].stackSize); - } - if (aInput.length > 1) { - if (aInput[1] != null) { - Logger.WARNING("Recipe requires input: " + aInput[1].getDisplayName() + " x" + aInput[1].stackSize); - } - } - if (aFluidInput != null) { - Logger.WARNING("Recipe requires input: " + aFluidInput.getFluid().getName() + " " + aFluidInput.amount - + "mbst"); - } - if (((aInput[0] == null) && (aFluidInput == null)) || ((aOutputItems == null) && (aFluidOutput == null))) { - return false; - } - if ((aOutputItems != null) - && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aOutputItems[0], aDuration)) <= 0)) { - return false; - } - if (aOutputItems != null) { - Logger.WARNING("Recipe will output: " + ItemUtils.getArrayStackNames(aOutputItems)); - } - if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", - aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { - return false; - } - if (aFluidOutput != null) { - Logger.WARNING("Recipe will output: " + aFluidOutput.getFluid().getName()); - } - - if (aInput.length == 1) { - Logger.WARNING("Dehydrator recipe only has a single input item."); - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, - aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, - 0); - - } - else { - Logger.WARNING("Dehydrator recipe has two input items."); - Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, - aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, - 0); - - } - - return true; - } - catch (final NullPointerException e) { - Logger.WARNING("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); - return false; - } - } - - @Override - public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aOutput, final int aChance, int aDuration, - final int aEUt) { - return addBlastSmelterRecipe(aInput, null, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, 3700); - } - - @Override - public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, - final int aChance, int aDuration, final int aEUt) { - return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, 3700); - } - - @Override - public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, - final int aChance[], int aDuration, final int aEUt) { - return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, aOutputStack, aChance, aDuration, aEUt, 3700); - } - - @Override - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, - int aDuration, int aEUt, int aSpecialValue) { - return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, aSpecialValue); - } - - @Override - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, - int aDuration, int aEUt, int aSpecialValue) { - if ((aInput == null) || (aOutput == null)) { - Logger.WARNING("Fail - Input or Output was null."); - return false; - } - - if (aOutput.isFluidEqual(Materials.PhasedGold.getMolten(1))) { - aOutput = Materials.VibrantAlloy.getMolten(aOutput.amount); - } - if (aOutput.isFluidEqual(Materials.PhasedIron.getMolten(1))) { - aOutput = Materials.PulsatingIron.getMolten(aOutput.amount); - } - if ((aDuration = GregTech_API.sRecipeFile.get("blastsmelter", aOutput.getFluid().getName(), aDuration)) <= 0) { - Logger.WARNING("Recipe did not register."); - return false; - } - - for (int das = 0; das < aInput.length; das++) { - if (aInput[das] != null) { - Logger.WARNING("tMaterial[" + das + "]: " + aInput[das].getDisplayName() + ", Amount: " - + aInput[das].stackSize); - } - } - - ArrayUtils.removeNulls(aInput); - if (aInput.length <= 1) { - return false; - } - - - - Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes.addRecipe(true, aInput, aOutputStack, null, - aChance, new FluidStack[] { aInputFluid }, new FluidStack[] { aOutput }, aDuration, aEUt, - aSpecialValue); - return true; - } - - @Override - public boolean addLFTRRecipe(final ItemStack aInput1, final FluidStack aInput2, final ItemStack aOutput1, - final FluidStack aOutput2, final int aDuration, final int aEUt) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean addLFTRRecipe(final ItemStack aInput1, final ItemStack aInput2, final ItemStack aOutput1, - final int aDuration, final int aEUt) { - return false; - } - - @Override - public boolean addLFTRRecipe(final FluidStack aInput1, final FluidStack aInput2, final FluidStack aOutput1, - final int aDuration, final int aEUt) { - if ((aInput1 == null) || (aInput2 == null) || (aOutput1 == null) || (aDuration < 1) || (aEUt < 1)) { - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.addRecipe(null, - new FluidStack[] { aInput1, aInput2 }, new FluidStack[] { aOutput1 }, aDuration, aEUt, 16000); - return true; - } - - @Override - public boolean addFissionFuel(final FluidStack aInput1, final FluidStack aInput2, final FluidStack aInput3, - final FluidStack aInput4, final FluidStack aInput5, final FluidStack aInput6, final FluidStack aInput7, - final FluidStack aInput8, final FluidStack aInput9, final FluidStack aOutput1, final FluidStack aOutput2, - final int aDuration, final int aEUt) { - - if ((aInput1 == null) || (aInput2 == null) || (aOutput1 == null) || (aDuration < 1) || (aEUt < 1)) { - return false; - } - final FluidStack inputs[] = { aInput1, aInput2, aInput3, aInput4, aInput5, aInput6, aInput7, aInput8, aInput9 }; - final FluidStack outputs[] = { aOutput1, aOutput2 }; - // Recipe_GT.Gregtech_Recipe_Map.sFissionFuelProcessing.addRecipe(null, - // inputs, outputs, aDuration, aEUt, 0); - CustomRecipeMap.sFissionFuelProcessing.addRecipe(null, inputs, outputs, aDuration, aEUt, 0); - return true; - } - - @Override - public boolean addCyclotronRecipe(ItemStack aInputs, FluidStack aFluidInput, ItemStack[] aOutputs, - FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue) { - return addCyclotronRecipe(new ItemStack[] {aInputs}, aFluidInput, aOutputs, aFluidOutput, aChances, aDuration, aEUt, aSpecialValue); - } - - @Override - public boolean addCyclotronRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack[] aOutput, - FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue) { - if (aOutput == null || aOutput.length < 1 || !ItemUtils.checkForInvalidItems(aOutput)) { - return false; - } - if (Recipe_GT.Gregtech_Recipe_Map.sCyclotronRecipes.addRecipe(true, aInputs, aOutput, - null, aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, - Math.max(1, aDuration), Math.max(1, aEUt), aSpecialValue) != null) { - return true; - } - - return false; - } - - @Override - public boolean addMixerRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aInput3, ItemStack aInput4, - FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, - ItemStack aOutput4, int aDuration, int aEUt) { - if (((aInput1 == null) && (aFluidInput == null)) || ((aOutput1 == null) && (aFluidOutput == null))) { - return false; - } - if ((aOutput1 != null) - && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", aOutput1, aDuration)) <= 0)) { - return false; - } - if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", - aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sAdvancedMixerRecipes.addRecipe(true, - new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, - new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 }, null, null, - new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - return true; - } - - // Machine Component Assembler - @Override - public boolean addComponentMakerRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack aOutput1, - int aDuration, int aEUt) { - if (areItemsAndFluidsBothNull(aInputs, new FluidStack[] { aFluidInput })) { - return false; - } - if (aOutput1 == null) { - return false; - } - if ((aDuration = GregTech_API.sRecipeFile.get("machinecomponents", aOutput1, aDuration)) <= 0) { - return false; - } - if (GTNH) { - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sComponentAssemblerRecipes.addRecipe(true, aInputs, new ItemStack[] { aOutput1 }, - null, new FluidStack[] { aFluidInput }, null, aDuration, aEUt, 0); - return true; - } - - - public boolean addMultiblockCentrifugeRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial){ - if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { - return false; - } - - if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { - Logger.INFO("[Recipe] Error generating Large Centrifuge recipe."); - Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); - Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); - Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); - Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sMultiblockCentrifugeRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial); - return true; - } - - public boolean addMultiblockElectrolyzerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial){ - if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { - return false; - } - if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { - Logger.INFO("[Recipe] Error generating Large Electrolyzer recipe."); - Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); - Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); - Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); - Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); - return false; - } - Recipe_GT.Gregtech_Recipe_Map.sMultiblockElectrolyzerRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial); - return true; - } - - - public boolean addAdvancedFreezerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial) { - if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { - return false; - } - - if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { - Logger.INFO("[Recipe] Error generating Adv. Vac Freezer recipe."); - Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); - Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); - Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); - Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); - return false; - } - if (Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial) != null) { - return true; - } - return false; - - } - - public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, ItemStack aOutput, int a1, int a2) { - if (aInput1 instanceof String || aInput2 instanceof String) { - int mCompleted = 0; - if (aInput1 instanceof String && aInput2 instanceof String) { - List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); - List<ItemStack> x1 = OreDictionary.getOres((String) aInput2, false); - if (x != null && x.size() > 0 && x1 != null && x1.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - for (ItemStack r1 : x1) { - r1.stackSize = aAmount2; - if (GT_Values.RA.addAssemblerRecipe(r, r1, aOutput, a1, a2)) { - mCompleted++; - } - } - } - } - } - else if (aInput1 instanceof String) { - List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); - if (x != null && x.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - if (GT_Values.RA.addAssemblerRecipe(r, (ItemStack) aInput2, aOutput, a1, a2)) { - mCompleted++; - } - } - } - - } - else { - List<ItemStack> x = OreDictionary.getOres((String) aInput2, false); - if (x != null && x.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - if (GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, r, aOutput, a1, a2)) { - mCompleted++; - } - } - } - } - return mCompleted > 0; - } - else { - return GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, (ItemStack) aInput2, aOutput, a1, a2); - } - } - - public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, FluidStack aInputFluid, ItemStack aOutput, int a1, int a2) { - if (aInput1 instanceof String || aInput2 instanceof String) { - int mCompleted = 0; - if (aInput1 instanceof String && aInput2 instanceof String) { - List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); - List<ItemStack> x1 = OreDictionary.getOres((String) aInput2, false); - if (x != null && x.size() > 0 && x1 != null && x1.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - for (ItemStack r1 : x1) { - r1.stackSize = aAmount2; - if (GT_Values.RA.addAssemblerRecipe(r, r1, aInputFluid, aOutput, a1, a2)) { - mCompleted++; - } - } - } - } - } - else if (aInput1 instanceof String) { - List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); - if (x != null && x.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - if (GT_Values.RA.addAssemblerRecipe(r, (ItemStack) aInput2, aInputFluid, aOutput, a1, a2)) { - mCompleted++; - } - } - } - - } - else { - List<ItemStack> x = OreDictionary.getOres((String) aInput2, false); - if (x != null && x.size() > 0) { - for (ItemStack r : x) { - r.stackSize = aAmount1; - if (GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, r, aInputFluid, aOutput, a1, a2)) { - mCompleted++; - } - } - } - } - return mCompleted > 0; - } - else { - return GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, (ItemStack) aInput2, aInputFluid, aOutput, a1, a2); - } - } - - /* - * Reflection Based Recipe Additions with Fallbacks - */ - - private static final Method mSixSlotAssembly; - private static final Method mAssemblyLine; - private static final Method mScannerTT; - private static final Method[] mChemicalRecipe = new Method[3]; - private static final Method mLargeChemReactor; - private static final Method mPyroOven; - - static { - - //Get GT's RA class; - Class<? extends IGT_RecipeAdder> clazz = GT_Values.RA.getClass(); - - mChemicalRecipe[0] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, int.class); - - - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { - //6 Slot Assembler - mSixSlotAssembly = ReflectionUtils.getMethod(clazz, "addAssemblerRecipe", ItemStack[].class, FluidStack.class, ItemStack.class, int.class, int.class); - //Assembly Line - mAssemblyLine = ReflectionUtils.getMethod(clazz, "addAssemblylineRecipe", ItemStack.class, int.class, ItemStack[].class, FluidStack[].class, ItemStack.class, int.class, int.class); - - - Method T = null; - if (LoadedMods.TecTech) { - Class TTRecipeAdder = ReflectionUtils.getClass("com.github.technus.tectech.recipe.TT_recipeAdder"); - if (TTRecipeAdder != null) { - Method ttTest = ReflectionUtils.getMethod(TTRecipeAdder, "addResearchableAssemblylineRecipe", - ItemStack.class, int.class, int.class, int.class, int.class, Object[].class, - FluidStack[].class, ItemStack.class, int.class, int.class); - if (ttTest != null) { - T = ttTest; - } - else { - Method[] aDump = TTRecipeAdder.getDeclaredMethods(); - for (Method m : aDump) { - if (m != null) { - Logger.INFO("Found "+m.getName()+" | "+m.getModifiers()+" | "+ArrayUtils.toString(m.getParameters(), "EMPTY")+""); - if (m.getName().toLowerCase().equals("addresearchableassemblylinerecipe")){ - Logger.INFO("Types: "+ArrayUtils.toString(m.getParameterTypes())); - } - } - } - } - } - } - else { - T = null; - } - mScannerTT = T; - - mChemicalRecipe[1] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, int.class, int.class); - mChemicalRecipe[2] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, ItemStack.class, int.class); - - mLargeChemReactor = ReflectionUtils.getMethod(clazz, "addMultiblockChemicalRecipe", ItemStack[].class, FluidStack[].class, FluidStack[].class, ItemStack[].class, int.class, int.class); - - mPyroOven = ReflectionUtils.getMethod(clazz, "addPyrolyseRecipe", ItemStack.class, FluidStack.class, int.class, ItemStack.class, FluidStack.class, int.class, int.class); - - - - } - else { - mSixSlotAssembly = null; - mAssemblyLine = null; - mLargeChemReactor = null; - mScannerTT = null; - mPyroOven = null; - } - - - } - - - - - - - public boolean addSixSlotAssemblingRecipe(ItemStack[] aInputs, FluidStack aInputFluid, ItemStack aOutput1, int aDuration, int aEUt) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { - if (mSixSlotAssembly != null) { - try { - return (boolean) mSixSlotAssembly.invoke(GT_Values.RA, aInputs, aInputFluid, aOutput1, aDuration, aEUt); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - if (CORE.GTNH) { - return false; - } - } - } - } - return CORE.RA.addComponentMakerRecipe(aInputs, aInputFluid, aOutput1, aDuration, aEUt); - } - - public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs_OLD, ItemStack aOutput, int aDuration, int aEUt) { - - FluidStack[] aFluidInputs = new FluidStack[4]; - AutoMap<FluidStack> aNewFluidMap = new AutoMap<FluidStack>(); - if (aFluidInputs_OLD.length > 4) { - for (FluidStack s : aFluidInputs_OLD) { - aNewFluidMap.put(s); - } - for (int i = 0; i < 4; i++) { - aFluidInputs[i] = aNewFluidMap.get(i); - } - } - else { - aFluidInputs = aFluidInputs_OLD; - } - - - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - if (aInputs.length < 6 && aFluidInputs.length < 2) { - ItemStack[] aInputStack = new ItemStack[] {aResearchItem, aInputs[0], aInputs[1], aInputs[2], aInputs[3], aInputs[4]}; - return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); - } - return false; - } - else { - if ((aResearchItem==null)||(aResearchTime<=0)||(aInputs == null) || (aOutput == null) || aInputs.length>15 || aInputs.length<4) { - return false; - } - else { - if (mAssemblyLine != null) { - try { - if (!tryAddTecTechScannerRecipe(aResearchItem, aInputs, aFluidInputs, aOutput, aDuration, aEUt)) { - try { - Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus."); - } - catch (Throwable t) { - t.printStackTrace(); - } - } - return (boolean) mAssemblyLine.invoke(GT_Values.RA, aResearchItem, aResearchTime, aInputs, - aFluidInputs, aOutput, aDuration, aEUt); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - if (aInputs.length < 6 && aFluidInputs.length < 2) { - ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], - aInputs[2], aInputs[3], aInputs[4] }; - return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, - aEUt); - } - return false; - } - } else { - if (aInputs.length < 6 && aFluidInputs.length < 2) { - ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], aInputs[2], - aInputs[3], aInputs[4] }; - return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, - aEUt); - } - return false; - } - } - } - } - - private boolean tryAddTecTechScannerRecipe(ItemStack aResearchItem, Object[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int assDuration, int assEUt) { - if (!LoadedMods.TecTech) { - return true; - } - else { - - int compSec = (GT_Utility.getTier(assEUt)+1) * 16; - int compMax = (GT_Utility.getTier(assEUt)+1) * 10000; - - if (mScannerTT != null) { - try { - boolean aResult = (boolean) mScannerTT.invoke(null, aResearchItem, compMax, compSec, - (assEUt/2), 16, aInputs, aFluidInputs, aOutput, assDuration, assEUt); - Logger.INFO("Added TecTech Scanner Recipe for "+ItemUtils.getItemName(aResearchItem)+"? "+aResult); - return aResult; - - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus. [Severe]"); - e.printStackTrace(); - } - } - } - return false; - } - - - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, int time, int eu){ - return addChemicalRecipe(input1, input2, inputFluid, outputFluid, output, null, time, eu); - } - - @Override - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, Object object, int time, int eu) { - try { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - return (boolean) mChemicalRecipe[0].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time); - } - else { - return (boolean) mChemicalRecipe[1].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time, eu); - } - } - catch (Throwable t) { - return false; - } - } - - @Override - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time) { - try { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - return (boolean) mChemicalRecipe[0].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time); - } - else { - return (boolean) mChemicalRecipe[2].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, output2, time); - } - } - catch (Throwable t) { - return false; - } - } - - @Override - public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, int aCircuit, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time, int eu) { - if (aCircuit < 0 || aCircuit > 24) { - aCircuit = 22; - } - GT_Recipe aSpecialRecipe = new Recipe_GT( - false, - new ItemStack[] {input1, input2}, - new ItemStack[] {output, output2}, - CI.getNumberedCircuit(aCircuit), - new int[] {}, - new FluidStack[] {inputFluid}, - new FluidStack[] {outputFluid}, - time, - eu, - 0); - return GT_Recipe.GT_Recipe_Map.sChemicalRecipes.mRecipeList.add(aSpecialRecipe); - } - - @Override - public boolean addMultiblockChemicalRecipe(ItemStack[] itemStacks, FluidStack[] fluidStacks, FluidStack[] fluidStacks2, ItemStack[] outputs, int time, int eu) { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || mLargeChemReactor == null) { - return false; - } - try { - return (boolean) mLargeChemReactor.invoke(GT_Values.RA, itemStacks, fluidStacks, fluidStacks2, outputs, time, eu); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } - } - - - - - - - - - private boolean areItemsAndFluidsBothNull(final ItemStack[] items, final FluidStack[] fluids) { - boolean itemsNull = true; - if (items != null) { - for (final ItemStack itemStack : items) { - if (itemStack != null) { - itemsNull = false; - break; - } - } - } - boolean fluidsNull = true; - if (fluids != null) { - for (final FluidStack fluidStack : fluids) { - if (fluidStack != null) { - fluidsNull = false; - break; - } - } - } - return itemsNull && fluidsNull; - } - - @Override - public boolean addCompressorRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt) { - if ((aInput1 == null) || (aOutput1 == null)) { - return false; - } - if ((aInput1 != null) && ((aDuration = GregTech_API.sRecipeFile.get("compressor", aInput1, aDuration)) <= 0)) { - return false; - } - GT_Recipe.GT_Recipe_Map.sCompressorRecipes.addRecipe(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, aDuration, aEUt, 0); - return true; - } - - @Override - public boolean addBrewingRecipe(int aCircuit, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden) { - return addBrewingRecipe(CI.getNumberedCircuit(aCircuit), aInput, aOutput, aTime, aEu, aHidden); - } - - @Override - public boolean addBrewingRecipe(ItemStack aIngredient, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden) { - if ((aIngredient == null) || (aInput == null) || (aOutput == null)) { - return false; - } - if (!GregTech_API.sRecipeFile.get("brewing", aOutput.getUnlocalizedName(), true)) { - return false; - } - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBrewingRecipes.addRecipe(false, new ItemStack[]{aIngredient}, null, null, new FluidStack[]{aInput}, new FluidStack[]{aOutput}, aTime, aEu, 0); - if ((aHidden) && (tRecipe != null)) { - tRecipe.mHidden = true; - } - return true; - } - - - /** - * Lets me add recipes for GT 5.08 & 5.09, since someone broke the method headers. - */ - @Override - public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput) { - Method m = StaticFields59.mAddFurnaceRecipe; - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - try { - return (boolean) m.invoke(null, aDust, aOutput); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } - } - else { - try { - return (boolean) m.invoke(null, aDust, aOutput, true); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } - } - } - - @Override - public boolean addFluidExtractionRecipe(ItemStack input, FluidStack output, int aTime, int aEu) { - return MaterialGenerator.addFluidExtractionRecipe(GT_Values.NI, input, output, aTime, aEu); - } - - @Override - public boolean addFluidExtractionRecipe(ItemStack aEmpty, ItemStack aRemains, FluidStack aFluid, int aDuration, int aEU) { - return MaterialGenerator.addFluidExtractionRecipe(aEmpty, aRemains, aFluid, aDuration, aEU); - } - - @Override - public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn) { - return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, null); - } - - @Override - public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut) { - return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, rFluidOut); - } - - - @Override - public boolean addFluidCannerRecipe(ItemStack aFullContainer, ItemStack container, FluidStack rFluidIn, FluidStack rFluidOut, int aTime, int aEu) { - return MaterialGenerator.addFluidCannerRecipe(container, aFullContainer, rFluidIn, rFluidOut, aTime, aEu); - } - - /** - * Adds a Fusion reactor Recipe - * - * @param aInputStackA = first Input (not null, and respects StackSize) - * @param aInputStackB = second Input (not null, and respects StackSize) - * @param plasma = Output of the Fusion (can be null, and respects StackSize) - * @param aOutputChance = chance to output plasma (can be 0) - * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) - * @param aEu = The EU generated per Tick (can even be negative!) - * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) - */ - @Override - public boolean addFusionReactorRecipe(FluidStack aInputStackA, FluidStack aInputStackB, FluidStack plasma, - int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { - if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { - return false; - } - Recipe_GT aFusionCustom = new Recipe_GT( - true, - null, - null, - null, - new int[] {aOutputChance}, - new FluidStack[]{aInputStackA, aInputStackB}, - new FluidStack[]{plasma}, - aFusionDurationInTicks, - aEu, - aSpecial); - GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); - return true; - } - - - - - - - /** - * Adds a Fusion reactor Recipe - * - * @param aInputStackA = first Input (not null, and respects StackSize) - * @param aInputStackB = second Input (not null, and respects StackSize) - * @param plasma = Output of the Fusion (can be null, and respects StackSize) - * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) - * @param aEu = The EU generated per Tick (can even be negative!) - * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) - */ - @Override - public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, - int aFusionDurationInTicks, int aEu, int aSpecial) { - return addFusionReactorRecipe(aInputStackA, aInputStackB, plasma, 10000, aFusionDurationInTicks, aEu, aSpecial); - } - - - /** - * Adds a Fusion reactor Recipe - * - * @param aInputStackA = first Input (not null, and respects StackSize) - * @param aInputStackB = second Input (not null, and respects StackSize) - * @param plasma = Output of the Fusion (can be null, and respects StackSize) - * @param aOutputChance = chance to output plasma (can be 0) - * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) - * @param aEu = The EU generated per Tick (can even be negative!) - * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) - */ - @Override - public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, - int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { - if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { - return false; - } - Recipe_GT aFusionCustom = new Recipe_GT( - true, - new ItemStack[]{aInputStackA, aInputStackB}, - null, - null, - new int[] {aOutputChance}, - null, - new FluidStack[]{plasma}, - aFusionDurationInTicks, - aEu, - aSpecial); - GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); - return true; - - } - - @Override - public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue) { - return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); - } - - @Override - public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue) { - return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); - } - - - - - @Override - public boolean addVacuumFurnaceRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, - ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt, int aLevel) { - if (aInput1 != null && aOutput1 != null) { - if ((aDuration = GregTech_API.sRecipeFile.get("vacuumfurnace", aInput1, aDuration)) <= 0) { - return false; - } else { - Recipe_GT.Gregtech_Recipe_Map.sVacuumFurnaceRecipes.addRecipe(true, new ItemStack[]{aInput1, aInput2}, - new ItemStack[]{aOutput1, aOutput2}, (Object) null, (int[]) null, new FluidStack[]{aFluidInput}, - new FluidStack[]{aFluidOutput}, aDuration, aEUt, aLevel); - return true; - } - } else { - return false; - } - } + @Override + public boolean addCokeOvenRecipe(final ItemStack aInput1, final ItemStack aInput2, final FluidStack aFluidInput, + final FluidStack aFluidOutput, final ItemStack aOutput, int aDuration, final int aEUt) { + try { + try { + // RECIPEHANDLER_CokeOven.debug1(); + if (((aInput1 == null) /* && (aFluidInput == null) */) + || ((aOutput == null) || (aFluidOutput == null))) { + // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" + // aInput2:"+aInput2.toString()+" + // aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Something was null, returning false"); + return false; + } + + } + catch (final NullPointerException e) { + e.getStackTrace(); + } + try { + // RECIPEHANDLER_CokeOven.debug2(aInput1, aInput2, aFluidInput, + // aFluidOutput, aOutput, aDuration, aEUt); + if ((aOutput != null) + && ((aDuration = GregTech_API.sRecipeFile.get("cokeoven", aOutput, aDuration)) <= 0)) { + // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" + // aInput2:"+aInput2.toString()+" + // aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Something was null, returning false"); + return false; + } + + } + catch (final NullPointerException e) { + e.getStackTrace(); + } + try { + // RECIPEHANDLER_CokeOven.debug3(aInput1, aInput2, aFluidInput, + // aFluidOutput, aOutput, aDuration, aEUt); + if ((aFluidOutput == null) || ((aDuration = GregTech_API.sRecipeFile.get("cokeoven", + aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { + // Utils.LOG_WARNING("aInput1:"+aInput1.toString()+" + // aInput2:"+aInput2.toString()+" + // aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Something was null, returning false"); + return false; + } + + } + catch (final NullPointerException e) { + e.getStackTrace(); + } + try { + // RECIPEHANDLER_CokeOven.debug4(aInput1, aInput2, aFluidInput, + // aFluidOutput, aOutput, aDuration, aEUt); + if (aFluidInput == null && aInput2 != null) { + Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, + new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, + aEUt, 0); + } + else if (aFluidInput == null && aInput2 == null) { + Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1 }, + new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, + aEUt, 0); + } + else { + Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, + new ItemStack[] { aOutput }, null, null, new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + } + // RECIPEHANDLER_CokeOven.debug5(aInput1, aInput2, aFluidInput, + // aFluidOutput, aOutput, aDuration, aEUt); + + return true; + + } + catch (final NullPointerException e) { + Logger.WARNING("Something was null, returning false"); + return false; + } + } + catch (final Throwable e) { + // Logger.WARNING("aInput1:"+aInput1.toString()+" + // aInput2:"+aInput2.toString()+" + // aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aOutput:"+aOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Failed."); + e.getStackTrace(); + return false; + } + } + + @Override + public boolean addMatterFabricatorRecipe(final FluidStack aFluidInput, final FluidStack aFluidOutput, + final int aDuration, final int aEUt) { + try { + try { + // RECIPEHANDLER_MatterFabricator.debug1(); + if (aFluidOutput == null) { + // Utils.LOG_WARNING("aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" + // aDuration:"+aDuration+" aEU/t:"+aEUt); + Logger.WARNING("Something was null, returning false"); + return false; + } + + } + catch (final NullPointerException e) { + e.getStackTrace(); + } + try { + + // RECIPEHANDLER_MatterFabricator.debug4(aFluidInput, + // aFluidOutput, aDuration, aEUt); + if (aFluidInput == null) { + // Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, + // null, new FluidStack[]{aFluidOutput}, aDuration, aEUt, + // 0); + Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, null, null, null, null, + new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + } + else { + // Recipe_GT.Gregtech_Recipe_Map.sMatterFabRecipes.addRecipe(true, + // new FluidStack[]{aFluidInput}, new + // FluidStack[]{aFluidOutput}, aDuration, aEUt, 0); + Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, null, null, null, + new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + } + RECIPEHANDLER_MatterFabricator.debug5(aFluidInput, aFluidOutput, aDuration, aEUt); + + return true; + + } + catch (final NullPointerException e) { + return false; + } + } + catch (final Throwable e) { + // Utils.LOG_WARNING("aFluidInput:"+aFluidInput.toString()+" + // aFluidOutput:"+aFluidOutput.toString()+" aDuration:"+aDuration+" + // aEU/t:"+aEUt); + Logger.WARNING("Failed."); + e.getStackTrace(); + return false; + } + } + + @Override + public boolean addMatterFabricatorRecipe(final ItemStack aInputStack, final FluidStack aFluidInput, + final FluidStack aFluidOutput, final int aDuration, final int aEUt) { + try { + try { + if ((aFluidOutput == null) || (aInputStack == null)) { + return false; + } + } + catch (final NullPointerException e) { + } + try { + if (aFluidInput == null) { + Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, new ItemStack[] { aInputStack }, + null, null, null, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + } + else { + Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.addRecipe(true, new ItemStack[] { aInputStack }, + null, null, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, + aEUt, 0); + } + RECIPEHANDLER_MatterFabricator.debug5(aFluidInput, aFluidOutput, aDuration, aEUt); + return true; + } + catch (final NullPointerException e) { + return false; + } + } + catch (final Throwable e) { + return false; + } + } + + @Override + public boolean addFuel(final ItemStack aInput1, final ItemStack aOutput1, final int aEU, final int aType) { + if (aInput1 == null) { + Logger.WARNING("Fuel Input is Invalid."); + return false; + } + // new GregtechRecipe(aInput1, aOutput1, + // GregTech_API.sRecipeFile.get("fuel_" + aType, aInput1, aEU), aType); + return true; + } + + /* + * @Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack + * aItemB, FluidStack aFluid, ItemStack[] aOutputItems, FluidStack + * aOutputFluid, int aDuration, int aEUt) { if ((aItemA == null) || (aItemB + * == null) || (aOutputItems == null)) { return false; } for (ItemStack + * tStack : aOutputItems) { if (tStack != null) { if ((aDuration = + * GregTech_API.sRecipeFile.get("dehydrator", aItemA, aDuration)) <= 0) { + * return false; } + * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, + * new ItemStack[]{aItemA, aItemB}, aOutputItems, null, null, null, + * aDuration, aEUt, 0); RECIPEHANDLER_Dehydrator.debug5(aItemA, aItemB, + * aFluid, aOutputFluid, aOutputItems, aDuration, aEUt); return true; } } + * return false; } + * @Override public boolean addDehydratorRecipe(ItemStack aItemA, ItemStack + * aItemB, ItemStack[] aOutputItems, int aDuration, int aEUt) { if ((aItemA + * == null) || (aItemB == null) || (aOutputItems == null)) { return false; } + * if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aItemA, + * aDuration)) <= 0) { return false; } + * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, + * new ItemStack[]{aItemA, aItemB}, aOutputItems, null, null, null, + * aDuration, aEUt, 0); RECIPEHANDLER_Dehydrator.debug5(aItemA, aItemB, + * null, null, aOutputItems, aDuration, aEUt); return true; } + * @Override public boolean addDehydratorRecipe(FluidStack aFluid, + * FluidStack aOutputFluid, ItemStack[] aOutputItems, int aDuration, int + * aEUt){ if ((aFluid == null) || (aOutputFluid == null || aOutputItems == + * null)) { return false; } if ((aDuration = + * GregTech_API.sRecipeFile.get("dehydrator", aFluid.getUnlocalizedName(), + * aDuration)) <= 0) { return false; } + * Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, + * null, aOutputItems, null, new FluidStack[]{aFluid}, new + * FluidStack[]{aOutputFluid}, aDuration, aEUt, 0); + * RECIPEHANDLER_Dehydrator.debug5(null, null, aFluid, aOutputFluid, + * aOutputItems, aDuration, aEUt); return true; } + */ + + @Override + public boolean addDehydratorRecipe(final ItemStack aInput, final FluidStack aFluid, final ItemStack[] aOutput, + int aDuration, final int aEUt) { + Logger.WARNING("Trying to add a Dehydrator recipe."); + try { + if ((aInput == null) || (aFluid == null) || (aOutput == null)) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aInput, aDuration)) <= 0) { + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, new ItemStack[] { aInput }, + aOutput, null, new FluidStack[] { aFluid }, null, aDuration, aEUt, 0); + // RECIPEHANDLER_Dehydrator.debug5(aInput, null, aFluid, null, + // aOutput, aDuration, aEUt); + return true; + } + catch (final NullPointerException e) { + Logger.WARNING("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); + return false; + } + } + + @Override + public boolean addDehydratorRecipe(final ItemStack[] aInput, final FluidStack aFluidInput, + final FluidStack aFluidOutput, final ItemStack[] aOutputItems, final int[] aChances, int aDuration, + final int aEUt) throws IndexOutOfBoundsException { + Logger.WARNING("Trying to add a Dehydrator recipe."); + try { + if (aInput[0] != null) { + Logger.WARNING("Recipe requires input: " + aInput[0].getDisplayName() + " x" + aInput[0].stackSize); + } + if (aInput.length > 1) { + if (aInput[1] != null) { + Logger.WARNING("Recipe requires input: " + aInput[1].getDisplayName() + " x" + aInput[1].stackSize); + } + } + if (aFluidInput != null) { + Logger.WARNING("Recipe requires input: " + aFluidInput.getFluid().getName() + " " + aFluidInput.amount + + "mbst"); + } + if (((aInput[0] == null) && (aFluidInput == null)) || ((aOutputItems == null) && (aFluidOutput == null))) { + return false; + } + if ((aOutputItems != null) + && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", aOutputItems[0], aDuration)) <= 0)) { + return false; + } + if (aOutputItems != null) { + Logger.WARNING("Recipe will output: " + ItemUtils.getArrayStackNames(aOutputItems)); + } + if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("dehydrator", + aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { + return false; + } + if (aFluidOutput != null) { + Logger.WARNING("Recipe will output: " + aFluidOutput.getFluid().getName()); + } + + if (aInput.length == 1) { + Logger.WARNING("Dehydrator recipe only has a single input item."); + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, + aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, + 0); + + } + else { + Logger.WARNING("Dehydrator recipe has two input items."); + Recipe_GT.Gregtech_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, + aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, + 0); + + } + + return true; + } + catch (final NullPointerException e) { + Logger.WARNING("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); + return false; + } + } + + @Override + public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aOutput, final int aChance, int aDuration, + final int aEUt) { + return addBlastSmelterRecipe(aInput, null, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, 3700); + } + + @Override + public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, + final int aChance, int aDuration, final int aEUt) { + return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, 3700); + } + + @Override + public boolean addBlastSmelterRecipe(final ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, + final int aChance[], int aDuration, final int aEUt) { + return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, aOutputStack, aChance, aDuration, aEUt, 3700); + } + + @Override + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, + int aDuration, int aEUt, int aSpecialValue) { + return addBlastSmelterRecipe(aInput, aInputFluid, aOutput, new ItemStack[] {}, new int[] {aChance}, aDuration, aEUt, aSpecialValue); + } + + @Override + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, + int aDuration, int aEUt, int aSpecialValue) { + if ((aInput == null) || (aOutput == null)) { + Logger.WARNING("Fail - Input or Output was null."); + return false; + } + + if (aOutput.isFluidEqual(Materials.PhasedGold.getMolten(1))) { + aOutput = Materials.VibrantAlloy.getMolten(aOutput.amount); + } + if (aOutput.isFluidEqual(Materials.PhasedIron.getMolten(1))) { + aOutput = Materials.PulsatingIron.getMolten(aOutput.amount); + } + if ((aDuration = GregTech_API.sRecipeFile.get("blastsmelter", aOutput.getFluid().getName(), aDuration)) <= 0) { + Logger.WARNING("Recipe did not register."); + return false; + } + + for (int das = 0; das < aInput.length; das++) { + if (aInput[das] != null) { + Logger.WARNING("tMaterial[" + das + "]: " + aInput[das].getDisplayName() + ", Amount: " + + aInput[das].stackSize); + } + } + + ArrayUtils.removeNulls(aInput); + if (aInput.length <= 1) { + return false; + } + + + + Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes.addRecipe(true, aInput, aOutputStack, null, + aChance, new FluidStack[] { aInputFluid }, new FluidStack[] { aOutput }, aDuration, aEUt, + aSpecialValue); + return true; + } + + @Override + public boolean addLFTRRecipe(final ItemStack aInput1, final FluidStack aInput2, final ItemStack aOutput1, + final FluidStack aOutput2, final int aDuration, final int aEUt) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean addLFTRRecipe(final ItemStack aInput1, final ItemStack aInput2, final ItemStack aOutput1, + final int aDuration, final int aEUt) { + return false; + } + + @Override + public boolean addLFTRRecipe(final FluidStack aInput1, final FluidStack aInput2, final FluidStack aOutput1, + final int aDuration, final int aEUt) { + if ((aInput1 == null) || (aInput2 == null) || (aOutput1 == null) || (aDuration < 1) || (aEUt < 1)) { + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.addRecipe(null, + new FluidStack[] { aInput1, aInput2 }, new FluidStack[] { aOutput1 }, aDuration, aEUt, 16000); + return true; + } + + @Override + public boolean addFissionFuel(final FluidStack aInput1, final FluidStack aInput2, final FluidStack aInput3, + final FluidStack aInput4, final FluidStack aInput5, final FluidStack aInput6, final FluidStack aInput7, + final FluidStack aInput8, final FluidStack aInput9, final FluidStack aOutput1, final FluidStack aOutput2, + final int aDuration, final int aEUt) { + + if ((aInput1 == null) || (aInput2 == null) || (aOutput1 == null) || (aDuration < 1) || (aEUt < 1)) { + return false; + } + final FluidStack inputs[] = { aInput1, aInput2, aInput3, aInput4, aInput5, aInput6, aInput7, aInput8, aInput9 }; + final FluidStack outputs[] = { aOutput1, aOutput2 }; + // Recipe_GT.Gregtech_Recipe_Map.sFissionFuelProcessing.addRecipe(null, + // inputs, outputs, aDuration, aEUt, 0); + CustomRecipeMap.sFissionFuelProcessing.addRecipe(null, inputs, outputs, aDuration, aEUt, 0); + return true; + } + + @Override + public boolean addCyclotronRecipe(ItemStack aInputs, FluidStack aFluidInput, ItemStack[] aOutputs, + FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue) { + return addCyclotronRecipe(new ItemStack[] {aInputs}, aFluidInput, aOutputs, aFluidOutput, aChances, aDuration, aEUt, aSpecialValue); + } + + @Override + public boolean addCyclotronRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack[] aOutput, + FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue) { + if (aOutput == null || aOutput.length < 1 || !ItemUtils.checkForInvalidItems(aOutput)) { + return false; + } + if (Recipe_GT.Gregtech_Recipe_Map.sCyclotronRecipes.addRecipe(true, aInputs, aOutput, + null, aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), Math.max(1, aEUt), aSpecialValue) != null) { + return true; + } + + return false; + } + + @Override + public boolean addMixerRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aInput3, ItemStack aInput4, + FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, + ItemStack aOutput4, int aDuration, int aEUt) { + if (((aInput1 == null) && (aFluidInput == null)) || ((aOutput1 == null) && (aFluidOutput == null))) { + return false; + } + if ((aOutput1 != null) + && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", aOutput1, aDuration)) <= 0)) { + return false; + } + if ((aFluidOutput != null) && ((aDuration = GregTech_API.sRecipeFile.get("advancedmixer", + aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sAdvancedMixerRecipes.addRecipe(true, + new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, + new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 }, null, null, + new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + return true; + } + + // Machine Component Assembler + @Override + public boolean addComponentMakerRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack aOutput1, + int aDuration, int aEUt) { + if (areItemsAndFluidsBothNull(aInputs, new FluidStack[] { aFluidInput })) { + return false; + } + if (aOutput1 == null) { + return false; + } + if ((aDuration = GregTech_API.sRecipeFile.get("machinecomponents", aOutput1, aDuration)) <= 0) { + return false; + } + if (GTNH) { + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sComponentAssemblerRecipes.addRecipe(true, aInputs, new ItemStack[] { aOutput1 }, + null, new FluidStack[] { aFluidInput }, null, aDuration, aEUt, 0); + return true; + } + + + public boolean addMultiblockCentrifugeRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial){ + if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { + return false; + } + + if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { + Logger.INFO("[Recipe] Error generating Large Centrifuge recipe."); + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); + Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); + Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sMultiblockCentrifugeRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial); + return true; + } + + public boolean addMultiblockElectrolyzerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial){ + if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { + return false; + } + if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { + Logger.INFO("[Recipe] Error generating Large Electrolyzer recipe."); + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); + Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); + Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); + return false; + } + Recipe_GT.Gregtech_Recipe_Map.sMultiblockElectrolyzerRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial); + return true; + } + + + public boolean addAdvancedFreezerRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, ItemStack[] aOutputs, int[] aChances, int aDuration, int aEUtick, int aSpecial) { + if (areItemsAndFluidsBothNull(aInputs, aFluidInputs) || areItemsAndFluidsBothNull(aOutputs, aFluidOutputs) || aEUtick <= 0) { + return false; + } + + if (!ItemUtils.checkForInvalidItems(aInputs, aOutputs)) { + Logger.INFO("[Recipe] Error generating Adv. Vac Freezer recipe."); + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); + Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aFluidInputs)); + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(aOutputs)); + Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); + return false; + } + if (Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.addRecipe(true, aInputs, aOutputs, null, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUtick, aSpecial) != null) { + return true; + } + return false; + + } + + public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, ItemStack aOutput, int a1, int a2) { + if (aInput1 instanceof String || aInput2 instanceof String) { + int mCompleted = 0; + if (aInput1 instanceof String && aInput2 instanceof String) { + List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); + List<ItemStack> x1 = OreDictionary.getOres((String) aInput2, false); + if (x != null && x.size() > 0 && x1 != null && x1.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + for (ItemStack r1 : x1) { + r1.stackSize = aAmount2; + if (GT_Values.RA.addAssemblerRecipe(r, r1, aOutput, a1, a2)) { + mCompleted++; + } + } + } + } + } + else if (aInput1 instanceof String) { + List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); + if (x != null && x.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + if (GT_Values.RA.addAssemblerRecipe(r, (ItemStack) aInput2, aOutput, a1, a2)) { + mCompleted++; + } + } + } + + } + else { + List<ItemStack> x = OreDictionary.getOres((String) aInput2, false); + if (x != null && x.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + if (GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, r, aOutput, a1, a2)) { + mCompleted++; + } + } + } + } + return mCompleted > 0; + } + else { + return GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, (ItemStack) aInput2, aOutput, a1, a2); + } + } + + public boolean addAssemblerRecipeWithOreDict(Object aInput1, int aAmount1, Object aInput2, int aAmount2, FluidStack aInputFluid, ItemStack aOutput, int a1, int a2) { + if (aInput1 instanceof String || aInput2 instanceof String) { + int mCompleted = 0; + if (aInput1 instanceof String && aInput2 instanceof String) { + List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); + List<ItemStack> x1 = OreDictionary.getOres((String) aInput2, false); + if (x != null && x.size() > 0 && x1 != null && x1.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + for (ItemStack r1 : x1) { + r1.stackSize = aAmount2; + if (GT_Values.RA.addAssemblerRecipe(r, r1, aInputFluid, aOutput, a1, a2)) { + mCompleted++; + } + } + } + } + } + else if (aInput1 instanceof String) { + List<ItemStack> x = OreDictionary.getOres((String) aInput1, false); + if (x != null && x.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + if (GT_Values.RA.addAssemblerRecipe(r, (ItemStack) aInput2, aInputFluid, aOutput, a1, a2)) { + mCompleted++; + } + } + } + + } + else { + List<ItemStack> x = OreDictionary.getOres((String) aInput2, false); + if (x != null && x.size() > 0) { + for (ItemStack r : x) { + r.stackSize = aAmount1; + if (GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, r, aInputFluid, aOutput, a1, a2)) { + mCompleted++; + } + } + } + } + return mCompleted > 0; + } + else { + return GT_Values.RA.addAssemblerRecipe((ItemStack) aInput1, (ItemStack) aInput2, aInputFluid, aOutput, a1, a2); + } + } + + /* + * Reflection Based Recipe Additions with Fallbacks + */ + + private static final Method mSixSlotAssembly; + private static final Method mAssemblyLine; + private static final Method mScannerTT; + private static final Method[] mChemicalRecipe = new Method[3]; + private static final Method mLargeChemReactor; + private static final Method mPyroOven; + + static { + + //Get GT's RA class; + Class<? extends IGT_RecipeAdder> clazz = GT_Values.RA.getClass(); + + mChemicalRecipe[0] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, int.class); + + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + //6 Slot Assembler + mSixSlotAssembly = ReflectionUtils.getMethod(clazz, "addAssemblerRecipe", ItemStack[].class, FluidStack.class, ItemStack.class, int.class, int.class); + //Assembly Line + mAssemblyLine = ReflectionUtils.getMethod(clazz, "addAssemblylineRecipe", ItemStack.class, int.class, ItemStack[].class, FluidStack[].class, ItemStack.class, int.class, int.class); + + + Method T = null; + if (LoadedMods.TecTech) { + Class TTRecipeAdder = ReflectionUtils.getClass("com.github.technus.tectech.recipe.TT_recipeAdder"); + if (TTRecipeAdder != null) { + Method ttTest = ReflectionUtils.getMethod(TTRecipeAdder, "addResearchableAssemblylineRecipe", + ItemStack.class, int.class, int.class, int.class, int.class, Object[].class, + FluidStack[].class, ItemStack.class, int.class, int.class); + if (ttTest != null) { + T = ttTest; + } + else { + Method[] aDump = TTRecipeAdder.getDeclaredMethods(); + for (Method m : aDump) { + if (m != null) { + Logger.INFO("Found "+m.getName()+" | "+m.getModifiers()+" | "+ArrayUtils.toString(m.getParameters(), "EMPTY")+""); + if (m.getName().toLowerCase().equals("addresearchableassemblylinerecipe")){ + Logger.INFO("Types: "+ArrayUtils.toString(m.getParameterTypes())); + } + } + } + } + } + } + else { + T = null; + } + mScannerTT = T; + + mChemicalRecipe[1] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, int.class, int.class); + mChemicalRecipe[2] = ReflectionUtils.getMethod(clazz, "addChemicalRecipe", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, ItemStack.class, int.class); + + mLargeChemReactor = ReflectionUtils.getMethod(clazz, "addMultiblockChemicalRecipe", ItemStack[].class, FluidStack[].class, FluidStack[].class, ItemStack[].class, int.class, int.class); + + mPyroOven = ReflectionUtils.getMethod(clazz, "addPyrolyseRecipe", ItemStack.class, FluidStack.class, int.class, ItemStack.class, FluidStack.class, int.class, int.class); + + + + } + else { + mSixSlotAssembly = null; + mAssemblyLine = null; + mLargeChemReactor = null; + mScannerTT = null; + mPyroOven = null; + } + + + } + + + + + + + public boolean addSixSlotAssemblingRecipe(ItemStack[] aInputs, FluidStack aInputFluid, ItemStack aOutput1, int aDuration, int aEUt) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + if (mSixSlotAssembly != null) { + try { + return (boolean) mSixSlotAssembly.invoke(GT_Values.RA, aInputs, aInputFluid, aOutput1, aDuration, aEUt); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + if (CORE.GTNH) { + return false; + } + } + } + } + return CORE.RA.addComponentMakerRecipe(aInputs, aInputFluid, aOutput1, aDuration, aEUt); + } + + public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs_OLD, ItemStack aOutput, int aDuration, int aEUt) { + + FluidStack[] aFluidInputs = new FluidStack[4]; + AutoMap<FluidStack> aNewFluidMap = new AutoMap<FluidStack>(); + if (aFluidInputs_OLD.length > 4) { + for (FluidStack s : aFluidInputs_OLD) { + aNewFluidMap.put(s); + } + for (int i = 0; i < 4; i++) { + aFluidInputs[i] = aNewFluidMap.get(i); + } + } + else { + aFluidInputs = aFluidInputs_OLD; + } + + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (aInputs.length < 6 && aFluidInputs.length < 2) { + ItemStack[] aInputStack = new ItemStack[] {aResearchItem, aInputs[0], aInputs[1], aInputs[2], aInputs[3], aInputs[4]}; + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); + } + return false; + } + else { + if ((aResearchItem==null)||(aResearchTime<=0)||(aInputs == null) || (aOutput == null) || aInputs.length>15 || aInputs.length<4) { + return false; + } + else { + if (mAssemblyLine != null) { + try { + if (!tryAddTecTechScannerRecipe(aResearchItem, aInputs, aFluidInputs, aOutput, aDuration, aEUt)) { + try { + Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus."); + } + catch (Throwable t) { + t.printStackTrace(); + } + } + return (boolean) mAssemblyLine.invoke(GT_Values.RA, aResearchItem, aResearchTime, aInputs, + aFluidInputs, aOutput, aDuration, aEUt); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + if (aInputs.length < 6 && aFluidInputs.length < 2) { + ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], + aInputs[2], aInputs[3], aInputs[4] }; + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, + aEUt); + } + return false; + } + } else { + if (aInputs.length < 6 && aFluidInputs.length < 2) { + ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], aInputs[2], + aInputs[3], aInputs[4] }; + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, + aEUt); + } + return false; + } + } + } + } + + private boolean tryAddTecTechScannerRecipe(ItemStack aResearchItem, Object[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int assDuration, int assEUt) { + if (!LoadedMods.TecTech) { + return true; + } + else { + + int compSec = (GT_Utility.getTier(assEUt)+1) * 16; + int compMax = (GT_Utility.getTier(assEUt)+1) * 10000; + + if (mScannerTT != null) { + try { + boolean aResult = (boolean) mScannerTT.invoke(null, aResearchItem, compMax, compSec, + (assEUt/2), 16, aInputs, aFluidInputs, aOutput, assDuration, assEUt); + Logger.INFO("Added TecTech Scanner Recipe for "+ItemUtils.getItemName(aResearchItem)+"? "+aResult); + return aResult; + + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus. [Severe]"); + e.printStackTrace(); + } + } + } + return false; + } + + + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, int time, int eu){ + return addChemicalRecipe(input1, input2, inputFluid, outputFluid, output, null, time, eu); + } + + @Override + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, Object object, int time, int eu) { + try { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return (boolean) mChemicalRecipe[0].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time); + } + else { + return (boolean) mChemicalRecipe[1].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time, eu); + } + } + catch (Throwable t) { + return false; + } + } + + @Override + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time) { + try { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return (boolean) mChemicalRecipe[0].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, time); + } + else { + return (boolean) mChemicalRecipe[2].invoke(GT_Values.RA, input1, input2, inputFluid, outputFluid, output, output2, time); + } + } + catch (Throwable t) { + return false; + } + } + + @Override + public boolean addChemicalRecipe(ItemStack input1, ItemStack input2, int aCircuit, FluidStack inputFluid, FluidStack outputFluid, ItemStack output, ItemStack output2, int time, int eu) { + if (aCircuit < 0 || aCircuit > 24) { + aCircuit = 22; + } + GT_Recipe aSpecialRecipe = new Recipe_GT( + false, + new ItemStack[] {input1, input2}, + new ItemStack[] {output, output2}, + CI.getNumberedCircuit(aCircuit), + new int[] {}, + new FluidStack[] {inputFluid}, + new FluidStack[] {outputFluid}, + time, + eu, + 0); + return GT_Recipe.GT_Recipe_Map.sChemicalRecipes.mRecipeList.add(aSpecialRecipe); + } + + @Override + public boolean addMultiblockChemicalRecipe(ItemStack[] itemStacks, FluidStack[] fluidStacks, FluidStack[] fluidStacks2, ItemStack[] outputs, int time, int eu) { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || mLargeChemReactor == null) { + return false; + } + try { + return (boolean) mLargeChemReactor.invoke(GT_Values.RA, itemStacks, fluidStacks, fluidStacks2, outputs, time, eu); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + + + + + + + + + private boolean areItemsAndFluidsBothNull(final ItemStack[] items, final FluidStack[] fluids) { + boolean itemsNull = true; + if (items != null) { + for (final ItemStack itemStack : items) { + if (itemStack != null) { + itemsNull = false; + break; + } + } + } + boolean fluidsNull = true; + if (fluids != null) { + for (final FluidStack fluidStack : fluids) { + if (fluidStack != null) { + fluidsNull = false; + break; + } + } + } + return itemsNull && fluidsNull; + } + + @Override + public boolean addCompressorRecipe(ItemStack aInput1, ItemStack aOutput1, int aDuration, int aEUt) { + if ((aInput1 == null) || (aOutput1 == null)) { + return false; + } + if ((aInput1 != null) && ((aDuration = GregTech_API.sRecipeFile.get("compressor", aInput1, aDuration)) <= 0)) { + return false; + } + GT_Recipe.GT_Recipe_Map.sCompressorRecipes.addRecipe(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1}, null, null, null, aDuration, aEUt, 0); + return true; + } + + @Override + public boolean addBrewingRecipe(int aCircuit, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden) { + return addBrewingRecipe(CI.getNumberedCircuit(aCircuit), aInput, aOutput, aTime, aEu, aHidden); + } + + @Override + public boolean addBrewingRecipe(ItemStack aIngredient, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden) { + if ((aIngredient == null) || (aInput == null) || (aOutput == null)) { + return false; + } + if (!GregTech_API.sRecipeFile.get("brewing", aOutput.getUnlocalizedName(), true)) { + return false; + } + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBrewingRecipes.addRecipe(false, new ItemStack[]{aIngredient}, null, null, new FluidStack[]{aInput}, new FluidStack[]{aOutput}, aTime, aEu, 0); + if ((aHidden) && (tRecipe != null)) { + tRecipe.mHidden = true; + } + return true; + } + + + /** + * Lets me add recipes for GT 5.08 & 5.09, since someone broke the method headers. + */ + @Override + public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput) { + Method m = StaticFields59.mAddFurnaceRecipe; + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + return (boolean) m.invoke(null, aDust, aOutput); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + else { + try { + return (boolean) m.invoke(null, aDust, aOutput, true); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + } + + @Override + public boolean addFluidExtractionRecipe(ItemStack input, FluidStack output, int aTime, int aEu) { + return MaterialGenerator.addFluidExtractionRecipe(GT_Values.NI, input, output, aTime, aEu); + } + + @Override + public boolean addFluidExtractionRecipe(ItemStack aEmpty, ItemStack aRemains, FluidStack aFluid, int aDuration, int aEU) { + return MaterialGenerator.addFluidExtractionRecipe(aEmpty, aRemains, aFluid, aDuration, aEU); + } + + @Override + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn) { + return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, null); + } + + @Override + public boolean addFluidCannerRecipe(ItemStack aContainer, ItemStack aFullContainer, FluidStack rFluidIn, FluidStack rFluidOut) { + return MaterialGenerator.addFluidCannerRecipe(aContainer, aFullContainer, rFluidIn, rFluidOut); + } + + + @Override + public boolean addFluidCannerRecipe(ItemStack aFullContainer, ItemStack container, FluidStack rFluidIn, FluidStack rFluidOut, int aTime, int aEu) { + return MaterialGenerator.addFluidCannerRecipe(container, aFullContainer, rFluidIn, rFluidOut, aTime, aEu); + } + + /** + * Adds a Fusion reactor Recipe + * + * @param aInputStackA = first Input (not null, and respects StackSize) + * @param aInputStackB = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aOutputChance = chance to output plasma (can be 0) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + @Override + public boolean addFusionReactorRecipe(FluidStack aInputStackA, FluidStack aInputStackB, FluidStack plasma, + int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { + if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { + return false; + } + Recipe_GT aFusionCustom = new Recipe_GT( + true, + null, + null, + null, + new int[] {aOutputChance}, + new FluidStack[]{aInputStackA, aInputStackB}, + new FluidStack[]{plasma}, + aFusionDurationInTicks, + aEu, + aSpecial); + GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); + return true; + } + + + + + + + /** + * Adds a Fusion reactor Recipe + * + * @param aInputStackA = first Input (not null, and respects StackSize) + * @param aInputStackB = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + @Override + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, + int aFusionDurationInTicks, int aEu, int aSpecial) { + return addFusionReactorRecipe(aInputStackA, aInputStackB, plasma, 10000, aFusionDurationInTicks, aEu, aSpecial); + } + + + /** + * Adds a Fusion reactor Recipe + * + * @param aInputStackA = first Input (not null, and respects StackSize) + * @param aInputStackB = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aOutputChance = chance to output plasma (can be 0) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + @Override + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, + int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { + if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { + return false; + } + Recipe_GT aFusionCustom = new Recipe_GT( + true, + new ItemStack[]{aInputStackA, aInputStackB}, + null, + null, + new int[] {aOutputChance}, + null, + new FluidStack[]{plasma}, + aFusionDurationInTicks, + aEu, + aSpecial); + GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); + return true; + + } + + @Override + public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue) { + return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); + } + + @Override + public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue) { + return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); + } + + + + + @Override + public boolean addVacuumFurnaceRecipe(ItemStack aInput1, ItemStack aInput2, FluidStack aFluidInput, FluidStack aFluidOutput, + ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt, int aLevel) { + if (aInput1 != null && aOutput1 != null) { + return addVacuumFurnaceRecipe(new ItemStack[] {aInput1, aInput2}, new FluidStack[] {aFluidInput}, new ItemStack[] {aOutput1, aOutput2}, new FluidStack[] {aFluidOutput}, aDuration, aEUt, aLevel); + } + else { + return false; + } + } + + + @Override + public boolean addVacuumFurnaceRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aLevel) { + if (aInputs != null && aOutputs != null) { + Recipe_GT aSpecialRecipe = new Recipe_GT( + false, + aInputs, + aOutputs, + null, + new int[] {}, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aLevel); + + int aSize = Recipe_GT.Gregtech_Recipe_Map.sVacuumFurnaceRecipes.mRecipeList.size(); + int aSize2 = aSize; + Recipe_GT.Gregtech_Recipe_Map.sVacuumFurnaceRecipes.addRecipe(aSpecialRecipe); + aSize = Recipe_GT.Gregtech_Recipe_Map.sVacuumFurnaceRecipes.mRecipeList.size(); + return aSize > aSize2; + } else { + return false; + } + } @Override public boolean addUvLaserRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput, int time, long eu) { @@ -1190,7 +1205,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addChemicalPlantRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int[] aChances, int time, long eu, int aTier) { - + if (aInputs.length > 4 || aInputFluids.length > 4 || aOutputs.length > 4 || aFluidOutputs.length > 2) { Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(aInputs)); Logger.INFO("Fluid Inputs: "+ItemUtils.getArrayStackNames(aInputFluids)); @@ -1198,20 +1213,20 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { Logger.INFO("Fluid Outputs: "+ItemUtils.getArrayStackNames(aFluidOutputs)); CORE.crash(); } - - + + Recipe_GT aSpecialRecipe = new Recipe_GT( - false, - aInputs, - aOutputs, - null, - aChances, - aInputFluids, - aFluidOutputs, - time, - (int) eu, - aTier); - + false, + aInputs, + aOutputs, + null, + aChances, + aInputFluids, + aFluidOutputs, + time, + (int) eu, + aTier); + int aSize = Recipe_GT.Gregtech_Recipe_Map.sChemicalPlantRecipes.mRecipeList.size(); int aSize2 = aSize; Recipe_GT.Gregtech_Recipe_Map.sChemicalPlantRecipes.add(aSpecialRecipe); @@ -1222,35 +1237,35 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addBlastRecipe(ItemStack[] aInputs, FluidStack[] aInputFluids, ItemStack[] aOutputs, FluidStack[] aFluidOutputs, int time, long eu, int aHeat) { Recipe_GT aSpecialRecipe = new Recipe_GT( - false, - aInputs, - aOutputs, - null, - new int[] {}, - aInputFluids, - aFluidOutputs, - time, - (int) eu, - aHeat); - + false, + aInputs, + aOutputs, + null, + new int[] {}, + aInputFluids, + aFluidOutputs, + time, + (int) eu, + aHeat); + int aSize = GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.size(); int aSize2 = aSize; GT_Recipe.GT_Recipe_Map.sBlastRecipes.add(aSpecialRecipe); aSize = GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.size(); return aSize > aSize2; - + } @Override public boolean addPyrolyseRecipe(ItemStack aInput, FluidStack aFluidInput, int intCircuit, ItemStack aOutput, FluidStack aFluidOutput, int aDuration, int aEUt) { if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || mPyroOven == null) { - return false; - } - try { - return (boolean) mPyroOven.invoke(GT_Values.RA, aInput, aFluidInput, intCircuit, aOutput, aFluidOutput, aDuration, aEUt); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } + return false; + } + try { + return (boolean) mPyroOven.invoke(GT_Values.RA, aInput, aFluidInput, intCircuit, aOutput, aFluidOutput, aDuration, aEUt); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } } @Override @@ -1308,7 +1323,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { new int[] { 10000, 10000, 10000 }, 400, 2); } return true; - + } @Override @@ -1318,14 +1333,14 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addMillingRecipe(Material aMat, int aEU) { - + ItemStack aOreStack = aMat.getOre(16); ItemStack aCrushedStack = aMat.getCrushed(16); - + ItemStack aMilledStackOres1 = aMat.getMilled(64); - ItemStack aMilledStackCrushed1 = aMat.getMilled(48); + ItemStack aMilledStackCrushed1 = aMat.getMilled(32); ItemStack aMilledStackOres2 = aMat.getMilled(48); - ItemStack aMilledStackCrushed2 = aMat.getMilled(32); + ItemStack aMilledStackCrushed2 = aMat.getMilled(16); ItemStack aMillingBall_Alumina = GregtechItemList.Milling_Ball_Alumina.get(0); ItemStack aMillingBall_Soapstone = GregtechItemList.Milling_Ball_Soapstone.get(0); @@ -1336,38 +1351,38 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { aOreStack, aMillingBall_Alumina }; - + ItemStack[] aInputsOre2 = new ItemStack[] { CI.getNumberedCircuit(11), aOreStack, aMillingBall_Soapstone }; - + ItemStack[] aInputsCrushed1 = new ItemStack[] { CI.getNumberedCircuit(10), aCrushedStack, aMillingBall_Alumina }; - + ItemStack[] aInputsCrushed2 = new ItemStack[] { CI.getNumberedCircuit(11), aCrushedStack, aMillingBall_Soapstone }; - + // Outputs ItemStack[] aOutputsOre1 = new ItemStack[] { aMilledStackOres1 }; - + ItemStack[] aOutputsOre2 = new ItemStack[] { aMilledStackOres2 }; - + ItemStack[] aOutputsCrushed1 = new ItemStack[] { aMilledStackCrushed1 }; - + ItemStack[] aOutputsCrushed2 = new ItemStack[] { aMilledStackCrushed2 }; @@ -1378,26 +1393,66 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { int aSize = Recipe_GT.Gregtech_Recipe_Map.sOreMillRecipes.mRecipeList.size(); int aSize2 = aSize; - + for (int i=0;i<4;i++) { Recipe_GT aOreRecipe = new Recipe_GT( - false, - aInputArray[i], - aOutputArray[i], - null, - new int[] {}, - null, - null, - aTime[i], - aEU, - 0); + false, + aInputArray[i], + aOutputArray[i], + null, + new int[] {}, + null, + null, + aTime[i], + aEU, + 0); Recipe_GT.Gregtech_Recipe_Map.sOreMillRecipes.add(aOreRecipe); } - + aSize = Recipe_GT.Gregtech_Recipe_Map.sOreMillRecipes.mRecipeList.size(); return aSize > aSize2; } + @Override + public boolean addFlotationRecipe(Materials aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU) { + return addFlotationRecipe(MaterialUtils.generateMaterialFromGtENUM(aMat), aXanthate, aInputFluids, aOutputFluids, aTime, aEU); + } + + @Override + public boolean addFlotationRecipe(Material aMat, ItemStack aXanthate, FluidStack[] aInputFluids, FluidStack[] aOutputFluids, int aTime, int aEU) { + + FlotationRecipeHandler.registerOreType(aMat); + int aSpecialValue = FlotationRecipeHandler.getHashForMaterial(aMat); + + int aSize = Recipe_GT.Gregtech_Recipe_Map.sFlotationCellRecipes.mRecipeList.size(); + int aSize2 = aSize; + + GT_Recipe aRecipe = new Recipe_GT( + false, + new ItemStack[] { + ItemUtils.getSimpleStack(aXanthate, 32), + aMat.getMilled(64), + aMat.getMilled(64), + aMat.getMilled(64), + aMat.getMilled(64), + }, + new ItemStack[] { + + }, + null, + new int[] {}, + aInputFluids, + aOutputFluids, + aTime, + aEU, + aSpecialValue); + + Recipe_GT.Gregtech_Recipe_Map.sFlotationCellRecipes.add(aRecipe); + aSize = Recipe_GT.Gregtech_Recipe_Map.sFlotationCellRecipes.mRecipeList.size(); + + return aSize > aSize2; + } + diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java index 2c9f1d1943..08901a1a3b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae.GregtechMTE_AlgaePondBase; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant.GregtechMTE_ChemicalPlant; @@ -22,7 +23,8 @@ public class GregtechAlgaeContent { // Chemical Plant GregtechItemList.ChemicalPlant_Controller.set(new GregtechMTE_ChemicalPlant(998, "chemicalplant.controller.tier.single", "ExxonMobil Chemical Plant").getStackForm(1L)); - + + GregtechItemList.Bus_Catalysts.set((new GT_MetaTileEntity_Hatch_Catalysts(31030, "hatch.catalysts", "Catalyst Housing")).getStackForm(1L)); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java index 9c5fb483a7..19c361be93 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java @@ -1,13 +1,22 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_MillingBalls; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IsaMill; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_FrothFlotationCell; public class GregtechIsaMill { public static void run(){ + + Logger.INFO("Gregtech5u Content | Registering Milling Content."); - GregtechItemList.Controller_IsaMill_Controller.set(new GregtechMetaTileEntity_IsaMill(31027, "gtpp.multimachine.isamill", "IsaMill Grinding Machine").getStackForm(1L)); + GregtechItemList.Controller_IsaMill.set(new GregtechMetaTileEntity_IsaMill(31027, "gtpp.multimachine.isamill", "IsaMill Grinding Machine").getStackForm(1L)); + GregtechItemList.Controller_Flotation_Cell.set(new GregtechMTE_FrothFlotationCell(31028, "gtpp.multimachine.flotationcell", "Flotation Cell Regulator").getStackForm(1L)); + + // Milling Ball Bus + GregtechItemList.Bus_Milling_Balls.set((new GT_MetaTileEntity_Hatch_MillingBalls(31029, "hatch.milling", "Ball Housing")).getStackForm(1L)); } diff --git a/src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java b/src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java new file mode 100644 index 0000000000..18fb286d15 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/ic2/CustomInternalName.java @@ -0,0 +1,27 @@ +package gtPlusPlus.xmod.ic2; + +import gtPlusPlus.core.util.data.EnumUtils; +import ic2.core.init.InternalName; +import net.minecraftforge.common.util.EnumHelper; + +public class CustomInternalName { + + public static InternalName aHazmatHelmetEx; + public static InternalName aHazmatChestEx; + public static InternalName aHazmatLegsEx; + public static InternalName aHazmatBootsEx; + + public static void init() { + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatHelmetEx", new Class[] {}, new Object[] {}); + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatChestplateEx", new Class[] {}, new Object[] {}); + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatLeggingsEx", new Class[] {}, new Object[] {}); + EnumHelper.addEnum(InternalName.class, "itemArmorRubBootsEx", new Class[] {}, new Object[] {}); + aHazmatHelmetEx = EnumUtils.getValue(InternalName.class, "itemArmorHazmatHelmetEx"); + aHazmatChestEx = EnumUtils.getValue(InternalName.class, "itemArmorHazmatChestplateEx"); + aHazmatLegsEx = EnumUtils.getValue(InternalName.class, "itemArmorHazmatLeggingsEx"); + aHazmatBootsEx = EnumUtils.getValue(InternalName.class, "itemArmorRubBootsEx"); + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java b/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java index 862ba38748..8c8b2ea7ad 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java +++ b/src/Java/gtPlusPlus/xmod/ic2/item/IC2_Items.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.ic2.item; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.item.wearable.hazmat.ItemArmorHazmatEx; import gtPlusPlus.core.lib.LoadedMods; import net.minecraft.item.ItemStack; @@ -52,6 +53,8 @@ public class IC2_Items { rotor_Material_2 = new ItemStack (new CustomKineticRotor(1)); rotor_Material_3 = new ItemStack (new CustomKineticRotor(2)); rotor_Material_4 = new ItemStack (new CustomKineticRotor(3)); + + ItemArmorHazmatEx.init(); } } diff --git a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java index 6c43e2b6e0..1f5f9abe1d 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java +++ b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.ic2.recipe; import static gtPlusPlus.core.recipe.RECIPES_Tools.*; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import gregtech.api.enums.*; @@ -12,10 +13,15 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.ic2.item.IC2_Items; +import ic2.core.Ic2Items; public class RECIPE_IC2 { @@ -84,6 +90,7 @@ public class RECIPE_IC2 { public static void initRecipes() { checkForEnderIO(); + addAdvancedHazmat(); if (!CORE.GTNH) { //Rotor Blade Recipes @@ -236,4 +243,84 @@ public class RECIPE_IC2 { } + + private static void addAdvancedHazmat() { + + ItemStack[] aBasicHazmatPieces = new ItemStack[] { + Ic2Items.hazmatHelmet.copy(), + Ic2Items.hazmatChestplate.copy(), + Ic2Items.hazmatLeggings.copy(), + Ic2Items.hazmatBoots.copy() + }; + + Material aRubber = MaterialUtils.generateMaterialFromGtENUM(Materials.Rubber); + ItemStack aYellowWool = ItemUtils.getSimpleStack(Blocks.wool, 4, 1); + ItemStack aBlackWool = ItemUtils.getSimpleStack(Blocks.wool, 15, 1); + ItemStack aCoilIC2 = Ic2Items.coil; + ItemStack aPlateCobalt = CI.getTieredComponentOfMaterial(Materials.Cobalt, OrePrefixes.plate, 1); + ItemStack aGearSmallSteel = CI.getTieredComponentOfMaterial(Materials.Steel, OrePrefixes.gearGtSmall, 1); + ItemStack aGearSmallAluminium = CI.getTieredComponentOfMaterial(Materials.Aluminium, OrePrefixes.gearGtSmall, 1); + ItemStack aGearPotin = ALLOY.TUMBAGA.getGear(1); + ItemStack aGearSiliconCarbide = ALLOY.SILICON_CARBIDE.getGear(1); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[0], + ItemUtils.getSimpleStack(aYellowWool,16), + ItemUtils.getSimpleStack(aPlateCobalt, 4), + ItemUtils.getSimpleStack(aCoilIC2, 8), + ItemUtils.getSimpleStack(aGearSmallAluminium, 4), + }, + aRubber.getFluid(144 * 4), + GregtechItemList.Armour_Hazmat_Advanced_Helmet.get(1), + 30 * 20, + MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[1], + ItemUtils.getSimpleStack(aYellowWool, 64), + ItemUtils.getSimpleStack(aCoilIC2, 32), + ItemUtils.getSimpleStack(aPlateCobalt, 16), + ItemUtils.getSimpleStack(aGearSiliconCarbide, 8), + }, + aRubber.getFluid(144 * 10), + GregtechItemList.Armour_Hazmat_Advanced_Chest.get(1), + 90 * 20, + MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[2], + ItemUtils.getSimpleStack(aYellowWool, 32), + ItemUtils.getSimpleStack(aCoilIC2, 16), + ItemUtils.getSimpleStack(aPlateCobalt, 8), + ItemUtils.getSimpleStack(aGearSiliconCarbide, 4), + }, + aRubber.getFluid(144 * 8), + GregtechItemList.Armour_Hazmat_Advanced_Legs.get(1), + 75 * 20, + MaterialUtils.getVoltageForTier(2)); + + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(2), + aBasicHazmatPieces[3], + ItemUtils.getSimpleStack(aBlackWool, 16), + ItemUtils.getSimpleStack(aCoilIC2, 6), + ItemUtils.getSimpleStack(aGearSmallSteel, 8), + ItemUtils.getSimpleStack(aGearPotin, 4), + }, + aRubber.getFluid(144 * 6), + GregtechItemList.Armour_Hazmat_Advanced_Boots.get(1), + 45 * 20, + MaterialUtils.getVoltageForTier(2)); + + } } |