diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-11-23 17:06:21 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-11-23 17:06:21 +1000 |
commit | 2941a6fedd2f615778c6ea95618dcf44721d3032 (patch) | |
tree | d29f1a2dfd0cf35a2bee3b1778a6c30cf87e3b82 /src/Java/gtPlusPlus | |
parent | dd3c71beeee4105829678a15f0b333bc0feb92c5 (diff) | |
download | GT5-Unofficial-2941a6fedd2f615778c6ea95618dcf44721d3032.tar.gz GT5-Unofficial-2941a6fedd2f615778c6ea95618dcf44721d3032.tar.bz2 GT5-Unofficial-2941a6fedd2f615778c6ea95618dcf44721d3032.zip |
+ Added Ink Sacs to Fish trap loot.
+ Added recycling recipes for all material components.
- Reduced rate of Sand from Fish Trap by 5%.
- Removed some logging.
$ Fixed Tooltip of Large Sifter stating it only required 9 Sieves, now says 18 as intended.
$ Fixed Recipe Recycling not working as intended.
Diffstat (limited to 'src/Java/gtPlusPlus')
6 files changed, 369 insertions, 139 deletions
diff --git a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java index 0b6848846b..6e529b3e92 100644 --- a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java +++ b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java @@ -19,8 +19,15 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; -import gtPlusPlus.xmod.gregtech.loaders.*; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_AlloySmelter; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Assembler; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_BlastSmelter; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_DustGeneration; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Extruder; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Fluids; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plates; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_ShapedCrafting; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -49,7 +56,7 @@ public class MaterialGenerator { } int sRadiation = 0; - if (ItemUtils.isRadioactive(materialName) || matInfo.vRadiationLevel != 0){ + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)){ sRadiation = matInfo.vRadiationLevel; } @@ -121,7 +128,7 @@ public class MaterialGenerator { temp = new BaseItemNugget(matInfo); temp = new BaseItemPlate(matInfo); temp = new BaseItemPlateDouble(matInfo); - } + } else if (matInfo.getState() == MaterialState.PURE_LIQUID){ FluidUtils.generateFluidNoPrefix(unlocalizedName, materialName, matInfo.getMeltingPointK(), C); return true; @@ -138,8 +145,9 @@ public class MaterialGenerator { RecipeGen_Fluids.generateRecipes(matInfo); RecipeGen_Plates.generateRecipes(matInfo); RecipeGen_ShapedCrafting.generateRecipes(matInfo); + RecipeGen_Recycling.generateRecipes(matInfo); return true; - } catch (Throwable t) + } catch (final Throwable t) { Utils.LOG_INFO(""+matInfo.getLocalizedName()+" failed to generate."); return false; @@ -158,7 +166,7 @@ public class MaterialGenerator { } int sRadiation = 0; - if (ItemUtils.isRadioactive(materialName) || matInfo.vRadiationLevel != 0){ + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)){ sRadiation = matInfo.vRadiationLevel; } @@ -172,6 +180,7 @@ public class MaterialGenerator { //Add A jillion Recipes - old code RecipeGen_DustGeneration.addMixerRecipe_Standalone(matInfo); RecipeGen_Fluids.generateRecipes(matInfo); + //RecipeGen_Recycling.generateRecipes(matInfo); } public static void generateNuclearMaterial(final Material matInfo){ @@ -209,7 +218,8 @@ public class MaterialGenerator { RecipeGen_Fluids.generateRecipes(matInfo); RecipeGen_Assembler.generateRecipes(matInfo); RecipeGen_DustGeneration.generateRecipes(matInfo, true); - } catch (Throwable t){ + RecipeGen_Recycling.generateRecipes(matInfo); + } catch (final Throwable t){ Utils.LOG_INFO(""+matInfo.getLocalizedName()+" failed to generate."); } } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 4f83afa197..365218e28e 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -280,18 +280,6 @@ public class RECIPES_GREGTECH { 120); } - - - - - - - - - - - - //TungstenCarbide if (Materials.get("TungstenCarbide") != null){ CORE.RA.addBlastSmelterRecipe( @@ -332,9 +320,49 @@ public class RECIPES_GREGTECH { }, FluidUtils.getFluidStack("molten.darksteel", 2*144), 0, - MathUtils.findPercentageOfInt(500*20, 80), + MathUtils.findPercentageOfInt(200*20, 80), 120); } + //Pulsating Iron + if (ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1), + ItemUtils.getSimpleStack(Items.ender_pearl) + }, + FluidUtils.getFluidStack("molten.pulsatingiron", 2*144), + 0, + MathUtils.findPercentageOfInt(8*20, 80), + 120); + } + //Energetic Alloy + if (ItemUtils.getItemStackOfAmountFromOreDict("dustEnergeticAlloy", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1), + ItemUtils.getSimpleStack(Items.glowstone_dust) + }, + FluidUtils.getFluidStack("molten.redstone", 144), + FluidUtils.getFluidStack("molten.energeticalloy", 144), + 0, + MathUtils.findPercentageOfInt(9*20, 80), + 120); + } + //Vibrant Alloy + if (ItemUtils.getItemStackOfAmountFromOreDict("dustVibrantAlloy", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustEnergeticAlloy", 1), + ItemUtils.getSimpleStack(Items.ender_pearl) + }, + FluidUtils.getFluidStack("molten.vibrantalloy", 144), + 0, + MathUtils.findPercentageOfInt(16*20, 80), + 480); + } } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java index bd2f8b727c..d73de219e4 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -9,7 +9,6 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.api.objects.XSTR; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -101,24 +100,24 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { int checkingSlot = 0; final ItemStack loot = this.generateLootForFishTrap().copy(); try { - //Utils.LOG_INFO("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); + //Utils.LOG_WARNING("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); for (final ItemStack contents : this.getInventory().getInventory()) { if (GT_Utility.areStacksEqual(loot, contents)){ if (contents.stackSize < contents.getMaxStackSize()) { - //Utils.LOG_INFO("3-Trying to add one more "+loot.getDisplayName()+"meta: "+loot.getItemDamage()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); + //Utils.LOG_WARNING("3-Trying to add one more "+loot.getDisplayName()+"meta: "+loot.getItemDamage()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); contents.stackSize++; this.markDirty(); - return true; + return true; } } checkingSlot++; } checkingSlot = 0; for (final ItemStack contents : this.getInventory().getInventory()) { - if (contents == null) { - //Utils.LOG_INFO("Adding Item To Empty Slot. "+(checkingSlot+1)); + if (contents == null) { + //Utils.LOG_WARNING("Adding Item To Empty Slot. "+(checkingSlot+1)); this.getInventory().setInventorySlotContents(checkingSlot, loot); this.markDirty(); return true; @@ -126,7 +125,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { checkingSlot++; } } - catch (NullPointerException n) { + catch (final NullPointerException n) { } } this.markDirty(); @@ -142,9 +141,12 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { else if (lootWeight <= 10) { loot = ItemUtils.getSimpleStack(Items.bone); } - else if (lootWeight <= 20) { + else if (lootWeight <= 15) { loot = ItemUtils.getSimpleStack(Blocks.sand); } + else if (lootWeight <= 20) { + loot = ItemUtils.simpleMetaStack(Items.dye, 0, 1); + } // Junk Loot else if (lootWeight <= 23) { if (LoadedMods.PamsHarvestcraft) { @@ -156,12 +158,12 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } // Pam Fish else if (lootWeight <= 99) { - Random xstr = new Random(); + final Random xstr = new Random(); loot = FishingHooks.getRandomFishable(xstr, 100); } else if (lootWeight == 100){ - int rareLoot = MathUtils.randInt(1, 10); + final int rareLoot = MathUtils.randInt(1, 10); if (rareLoot <= 4) { loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nuggetIron", 1); if (loot == null){ @@ -173,7 +175,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { if (loot == null){ loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotGold", 1); } - } + } else if (rareLoot <= 9){ loot = ItemUtils.getSimpleStack(Items.emerald); } @@ -192,47 +194,47 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { @Override public void updateEntity() { try{ - if (!this.worldObj.isRemote) { - this.tickCount++; - // Utils.LOG_WARNING("Ticking "+this.tickCount); - // Check if the Tile is within water once per second. - if ((this.tickCount % 20) == 0) { - this.isInWater = this.isSurroundedByWater(); - } - else { - - } + if (!this.worldObj.isRemote) { + this.tickCount++; + // Utils.LOG_WARNING("Ticking "+this.tickCount); + // Check if the Tile is within water once per second. + if ((this.tickCount % 20) == 0) { + this.isInWater = this.isSurroundedByWater(); + } + else { - if (this.isInWater) { - this.calculateTickrate(); - } + } - // Try add some loot once every 30 seconds. - if ((this.tickCount % this.baseTickRate) == 0) { if (this.isInWater) { - // Add loot - // Utils.LOG_WARNING("Adding Loot to the fishtrap at - // x["+this.locationX+"] y["+this.locationY+"] - // z["+this.locationZ+"] (Ticking for loot every - // "+this.baseTickRate+" ticks)"); - this.tryAddLoot(); - this.markDirty(); + this.calculateTickrate(); } - else { - Utils.LOG_INFO("This Trap does not have enough water around it."); - Utils.LOG_WARNING("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY - + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); - this.markDirty(); + + // Try add some loot once every 30 seconds. + if ((this.tickCount % this.baseTickRate) == 0) { + if (this.isInWater) { + // Add loot + // Utils.LOG_WARNING("Adding Loot to the fishtrap at + // x["+this.locationX+"] y["+this.locationY+"] + // z["+this.locationZ+"] (Ticking for loot every + // "+this.baseTickRate+" ticks)"); + this.tryAddLoot(); + this.markDirty(); + } + else { + Utils.LOG_WARNING("This Trap does not have enough water around it."); + Utils.LOG_WARNING("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY + + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); + this.markDirty(); + } + this.tickCount = 0; + } + if (this.tickCount > (this.baseTickRate + 500)) { + this.tickCount = 0; } - this.tickCount = 0; - } - if (this.tickCount > (this.baseTickRate + 500)) { - this.tickCount = 0; - } + } } - } - catch (Throwable t){} + catch (final Throwable t){} } public void calculateTickrate() { @@ -293,13 +295,6 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { "Crayfish", "Eel", "Frog", "Grouper", "Herring", "Jellyfish", "Mudfish", "Octopus", "Perch", "Scallop", "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna", "Turtle", "Walleye" }; - private static final ItemStack[] minecraftFish = { - ItemUtils.simpleMetaStack(Items.fish, 0, 1).copy(), - ItemUtils.simpleMetaStack(Items.fish, 1, 1).copy(), - ItemUtils.simpleMetaStack(Items.fish, 2, 1).copy(), - ItemUtils.simpleMetaStack(Items.fish, 3, 1).copy() - }; - public static void pamsHarvestCraftCompat() { for (int i = 0; i < harvestcraftFish.length; i++) { @@ -312,22 +307,22 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } @Override - public ItemStack getStackInSlot(int slot) { + public ItemStack getStackInSlot(final int slot) { return this.getInventory().getStackInSlot(slot); } @Override - public ItemStack decrStackSize(int slot, int count) { + public ItemStack decrStackSize(final int slot, final int count) { return this.getInventory().decrStackSize(slot, count); } @Override - public ItemStack getStackInSlotOnClosing(int slot) { + public ItemStack getStackInSlotOnClosing(final int slot) { return this.getInventory().getStackInSlotOnClosing(slot); } @Override - public void setInventorySlotContents(int slot, ItemStack stack) { + public void setInventorySlotContents(final int slot, final ItemStack stack) { this.getInventory().setInventorySlotContents(slot, stack); } @@ -337,7 +332,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { return this.getInventory().isUseableByPlayer(entityplayer); } @@ -346,7 +341,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); + this.getInventory().openInventory(); } @Override @@ -354,17 +349,17 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); + this.getInventory().closeInventory(); } @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { return this.getInventory().isItemValidForSlot(slot, itemstack); } @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - int[] accessibleSides = new int[this.getSizeInventory()]; + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; for (int r=0; r<this.getInventory().getSizeInventory(); r++){ accessibleSides[r]=r; } @@ -373,12 +368,12 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } @Override - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { return false; } @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { return true; } @@ -386,7 +381,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { return this.customName; } - public void setCustomName(String customName) { + public void setCustomName(final String customName) { this.customName = customName; } @@ -397,7 +392,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { @Override public boolean hasCustomInventoryName() { - return this.customName != null && !this.customName.equals(""); + return (this.customName != null) && !this.customName.equals(""); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSifter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSifter.java index 66841bdda5..d4272430de 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSifter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSifter.java @@ -14,7 +14,6 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.GT_Block_Machines; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -53,7 +52,7 @@ extends GregtechMeta_MultiBlockBase { "4x Output Bus (Any top or bottom edge casing)", "1x Maintenance Hatch (Any top or bottom edge casing)", "1x Energy Hatch (Any top or bottom edge casing)", - "9x Sieve Grate (Top and Middle 3x3)", + "18x Sieve Grate (Top and Middle 3x3)", "Sieve Casings for the rest (47)", CORE.GT_Tooltip}; } @@ -151,24 +150,25 @@ extends GregtechMeta_MultiBlockBase { //Make a recipe instance for the rest of the method. final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sSifterRecipes.findRecipe(this.getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); - if (tRecipe != null) - baseRecipe = tRecipe.copy(); + if (tRecipe != null) { + this.baseRecipe = tRecipe.copy(); + } - if (cloneRecipe != tRecipe || cloneRecipe == null){ - cloneRecipe = tRecipe.copy(); + if ((this.cloneRecipe != tRecipe) || (this.cloneRecipe == null)){ + this.cloneRecipe = tRecipe.copy(); Utils.LOG_WARNING("Setting Recipe"); - } - if (mInputStacks != tRecipe.mInputs || mInputStacks == null){ - mInputStacks = tRecipe.mInputs; + } + if ((this.mInputStacks != tRecipe.mInputs) || (this.mInputStacks == null)){ + this.mInputStacks = tRecipe.mInputs; Utils.LOG_WARNING("Setting Recipe Inputs"); } - if (cloneChances != tRecipe.mChances || cloneChances == null){ - cloneChances = tRecipe.mChances.clone(); + if ((this.cloneChances != tRecipe.mChances) || (this.cloneChances == null)){ + this.cloneChances = tRecipe.mChances.clone(); Utils.LOG_WARNING("Setting Chances"); } - for (int r=0;r<cloneChances.length;r++){ - Utils.LOG_WARNING("Original map Output["+r+"] chance = "+cloneChances[r]); + for (int r=0;r<this.cloneChances.length;r++){ + Utils.LOG_WARNING("Original map Output["+r+"] chance = "+this.cloneChances[r]); } Utils.LOG_WARNING("3.1"); @@ -178,24 +178,24 @@ extends GregtechMeta_MultiBlockBase { Utils.LOG_WARNING("3.2"); - if (cloneRecipe.mChances != null){ - outputChances = cloneRecipe.mChances.clone(); + if (this.cloneRecipe.mChances != null){ + outputChances = this.cloneRecipe.mChances.clone(); Utils.LOG_WARNING("3.3"); for (int r=0;r<outputChances.length;r++){ Utils.LOG_WARNING("Output["+r+"] chance = "+outputChances[r]); if (outputChances[r]<10000){ - int temp = outputChances[r]; - if (outputChances[r] < 8000 && outputChances[r] >= 1){ + final int temp = outputChances[r]; + if ((outputChances[r] < 8000) && (outputChances[r] >= 1)){ outputChances[r] = temp+1200; Utils.LOG_WARNING("Output["+r+"] chance now = "+outputChances[r]); } - else if (outputChances[r] < 9000 && outputChances[r] >= 8000){ + else if ((outputChances[r] < 9000) && (outputChances[r] >= 8000)){ outputChances[r] = temp+400; Utils.LOG_WARNING("Output["+r+"] chance now = "+outputChances[r]); } - else if (outputChances[r] <= 9900 && outputChances[r] >= 9000){ + else if ((outputChances[r] <= 9900) && (outputChances[r] >= 9000)){ outputChances[r] = temp+100; Utils.LOG_WARNING("Output["+r+"] chance now = "+outputChances[r]); } @@ -205,7 +205,7 @@ extends GregtechMeta_MultiBlockBase { Utils.LOG_WARNING("3.4"); //Rebuff Drop Rates for % output - cloneRecipe.mChances = outputChances; + this.cloneRecipe.mChances = outputChances; } @@ -213,24 +213,24 @@ extends GregtechMeta_MultiBlockBase { Utils.LOG_WARNING("4"); - final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), cloneRecipe, tInputs); + final int tValidOutputSlots = this.getValidOutputSlots(this.getBaseMetaTileEntity(), this.cloneRecipe, tInputs); Utils.LOG_WARNING("Sifter - Valid Output Hatches: "+tValidOutputSlots); //More than or one input if ((tInputList.size() > 0) && (tValidOutputSlots >= 1)) { - if ((cloneRecipe != null) && (cloneRecipe.isRecipeInputEqual(true, null, tInputs))) { - Utils.LOG_WARNING("Valid Recipe found - size "+cloneRecipe.mOutputs.length); + if ((this.cloneRecipe != null) && (this.cloneRecipe.isRecipeInputEqual(true, null, tInputs))) { + Utils.LOG_WARNING("Valid Recipe found - size "+this.cloneRecipe.mOutputs.length); this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); this.mEfficiencyIncrease = 10000; - this.mEUt = (-cloneRecipe.mEUt); - this.mMaxProgresstime = Math.max(1, (cloneRecipe.mDuration/5)); - final ItemStack[] outputs = new ItemStack[cloneRecipe.mOutputs.length]; - for (int i = 0; i < cloneRecipe.mOutputs.length; i++){ - if (this.getBaseMetaTileEntity().getRandomNumber(7500) < cloneRecipe.getOutputChance(i)){ + this.mEUt = (-this.cloneRecipe.mEUt); + this.mMaxProgresstime = Math.max(1, (this.cloneRecipe.mDuration/5)); + final ItemStack[] outputs = new ItemStack[this.cloneRecipe.mOutputs.length]; + for (int i = 0; i < this.cloneRecipe.mOutputs.length; i++){ + if (this.getBaseMetaTileEntity().getRandomNumber(7500) < this.cloneRecipe.getOutputChance(i)){ Utils.LOG_WARNING("Adding a bonus output"); - outputs[i] = cloneRecipe.getOutput(i); + outputs[i] = this.cloneRecipe.getOutput(i); } else { Utils.LOG_WARNING("Adding null output"); @@ -255,7 +255,7 @@ extends GregtechMeta_MultiBlockBase { final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; int tAmount = 0; - controller = false; + this.controller = false; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { for (int h = 0; h < 3; h++) { @@ -275,7 +275,7 @@ extends GregtechMeta_MultiBlockBase { // Sifter Floor/Roof inner 3x3 if (((i != -2) && (i != 2)) && ((j != -2) && (j != 2))) { - if (h != 0){ + if (h != 0){ if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(21))) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { Utils.LOG_MACHINE_INFO("Sifter Casing(s) Missing from one of the "+sHeight+" layers inner 3x3."); @@ -302,12 +302,12 @@ extends GregtechMeta_MultiBlockBase { tAmount++; } } - } + } else { //Dealt with inner 5x5, now deal with the exterior. //Deal with all 4 sides (Sifter walls) boolean checkController = false; - if (((xDir + i) != 0) || ((zDir + j) != 0) && h == 0) {//no controller + if (((xDir + i) != 0) || (((zDir + j) != 0) && (h == 0))) {//no controller checkController = true; } else { @@ -317,7 +317,7 @@ extends GregtechMeta_MultiBlockBase { if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(21))) { if (!checkController){ if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { - if (tTileEntity instanceof GregtechMetaTileEntity_IndustrialSifter || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == GregTech_API.sBlockMachines){ + if ((tTileEntity instanceof GregtechMetaTileEntity_IndustrialSifter) || (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == GregTech_API.sBlockMachines)){ if (h != 0){ Utils.LOG_MACHINE_INFO("Found a secondary controller at the wrong Y level."); return false; @@ -328,24 +328,24 @@ extends GregtechMeta_MultiBlockBase { Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } - } - - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 5) { - if (tTileEntity instanceof GregtechMetaTileEntity_IndustrialSifter || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == GregTech_API.sBlockMachines){ - } - else { - Utils.LOG_MACHINE_INFO("Sifter Casings Missing from somewhere in the "+sHeight+" layer edge."); - Utils.LOG_MACHINE_INFO("Incorrect Meta value for block, expected 5."); - Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)+"."); - return false; + + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 5) { + if ((tTileEntity instanceof GregtechMetaTileEntity_IndustrialSifter) || (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == GregTech_API.sBlockMachines)){ + + } + else { + Utils.LOG_MACHINE_INFO("Sifter Casings Missing from somewhere in the "+sHeight+" layer edge."); + Utils.LOG_MACHINE_INFO("Incorrect Meta value for block, expected 5."); + Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)+"."); + return false; + } } } - } - tAmount++; + tAmount++; } else { - tAmount++; + tAmount++; } } } @@ -383,7 +383,7 @@ extends GregtechMeta_MultiBlockBase { } public boolean ignoreController(final Block tTileEntity) { - if (!controller && (tTileEntity == GregTech_API.sBlockMachines)) { + if (!this.controller && (tTileEntity == GregTech_API.sBlockMachines)) { return true; } return false; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java index a8a4cf963f..46bf36c445 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java @@ -177,7 +177,7 @@ public class RecipeGen_DustGeneration implements Runnable{ //Add Shapeless recipe for low tier alloys. if (tVoltageMultiplier <= 30){ if (RecipeUtils.addShapedGregtechRecipe(inputStacks, outputStacks)){ - Utils.LOG_INFO("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Success"); + Utils.LOG_INFO("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Success"); } else { Utils.LOG_INFO("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Failed"); @@ -194,7 +194,7 @@ public class RecipeGen_DustGeneration implements Runnable{ } - public static boolean addMixerRecipe_Standalone(Material material){ + public static boolean addMixerRecipe_Standalone(final Material material){ final ItemStack[] inputStacks = material.getMaterialComposites(); final ItemStack outputStacks = material.getDust(material.smallestStackSizeWhenProcessing); //Is this a composite? @@ -264,14 +264,14 @@ public class RecipeGen_DustGeneration implements Runnable{ } else { Utils.LOG_INFO("inputStackSize == NUll - "+material.getLocalizedName()); - } + } } else { Utils.LOG_INFO("InputStacks is out range 1-4 - "+material.getLocalizedName()); - } + } } else { - Utils.LOG_INFO("InputStacks == NUll - "+material.getLocalizedName()); + Utils.LOG_INFO("InputStacks == NUll - "+material.getLocalizedName()); } return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java new file mode 100644 index 0000000000..cf48516354 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java @@ -0,0 +1,197 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import static gregtech.api.enums.GT_Values.M; + +import java.util.ArrayList; +import java.util.Map; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.ItemStack; + +public class RecipeGen_Recycling implements Runnable{ + + final Material toGenerate; + static Map mNameMap; + + public RecipeGen_Recycling(final Material M){ + this.toGenerate = M; + mNameMap = this.getNameMap(); + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + public static void generateRecipes(final Material material){ + + Utils.LOG_INFO("Generating Recycling recipes for "+material.getLocalizedName()); + + final OrePrefixes[] mValidPrefixesAsString = { + OrePrefixes.ingot, + OrePrefixes.ingotHot, + OrePrefixes.nugget, + OrePrefixes.plate, + OrePrefixes.plateDense, + OrePrefixes.plateDouble, + OrePrefixes.plateTriple, + OrePrefixes.plateQuadruple, + OrePrefixes.plateQuintuple, + OrePrefixes.stick, + OrePrefixes.stickLong, + OrePrefixes.bolt, + OrePrefixes.screw, + OrePrefixes.ring, + OrePrefixes.rotor, + OrePrefixes.gearGt, + OrePrefixes.gearGtSmall + }; + + Utils.LOG_INFO("Found "+mValidPrefixesAsString.length+" valid OreDict prefixes."); + if (mValidPrefixesAsString.length >= 1){ + for (final OrePrefixes validPrefix : mValidPrefixesAsString){ + + try { + final ItemStack tempStack = ItemUtils.getItemStackOfAmountFromOreDict(validPrefix+material.getLocalizedName(), 1); + + if ((tempStack != null) && (tempStack != ItemUtils.getSimpleStack(ModItems.AAA_Broken))){ + //mValidItems[mSlotIndex++] = tempStack; + final ItemStack mDust = getDust(material, validPrefix); + if ((mDust != null) && GT_ModHandler.addPulverisationRecipe(tempStack, mDust)){ + Utils.LOG_INFO("Recycle Recipe: "+material.getLocalizedName()+" - Success - Recycle "+tempStack.getDisplayName()+" and obtain "+mDust.getDisplayName()); + } + else { + Utils.LOG_INFO("Recycle Recipe: "+material.getLocalizedName()+" - Failed"); + if (mDust == null){ + Utils.LOG_INFO("Invalid Dust output."); + } + } + } + } catch (final Throwable t){ + t.printStackTrace(); + Utils.LOG_INFO("Returning Null. Throwable Info: "+t.getMessage()); + Utils.LOG_INFO("Throwable Info: "+t.toString()); + Utils.LOG_INFO("Throwable Info: "+t.getCause().toString()); + + } + + } + } + } + + + + public static ItemStack getDust(final Material aMaterial, final OrePrefixes aPrefix) { + return aMaterial == null ? null : getDust(aMaterial, aPrefix.mMaterialAmount); + } + + public static ItemStack getDust(final Material aMaterial, final long aMaterialAmount) { + if (aMaterialAmount <= 0) { + return null; + } + ItemStack rStack = null; + if ((((aMaterialAmount % M) == 0) || (aMaterialAmount >= (M * 16)))) { + rStack = get(OrePrefixes.dust, aMaterial, aMaterialAmount / M); + } + if ((rStack == null) && ((((aMaterialAmount * 4) % M) == 0) || (aMaterialAmount >= (M * 8)))) { + rStack = get(OrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M); + } + if ((rStack == null) && (((aMaterialAmount * 9) >= M))) { + rStack = get(OrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M); + } + if (rStack == null){ + Utils.LOG_INFO("Returning Null. Method: "+ReflectionUtils.getMethodName(0)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(1)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(2)); + } + + return rStack; + } + + public static ItemStack get(final Object aName, final long aAmount) { + return get(aName, null, aAmount, true, true); + } + + public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount) { + return get(aName, aReplacement, aAmount, true, true); + } + + public static ItemStack get(final OrePrefixes aPrefix, final Object aMaterial, final long aAmount) { + return get(aPrefix, aMaterial, null, aAmount); + } + + public static ItemStack get(final OrePrefixes aPrefix, final Object aMaterial, final ItemStack aReplacement, + final long aAmount) { + if (OrePrefixes.mPreventableComponents.contains(aPrefix) && aPrefix.mDisabledItems.contains(aMaterial)) { + return aReplacement; + } + return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); + } + + public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount, + final boolean aMentionPossibleTypos, final boolean aNoInvalidAmounts) { + if (aNoInvalidAmounts && (aAmount < 1L)) { + Utils.LOG_INFO("Returning Null. Method: "+ReflectionUtils.getMethodName(0)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(1)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(2)); + return null; + } + if (!mNameMap.containsKey(aName.toString()) && aMentionPossibleTypos) { + Utils.LOG_INFO("Unknown Key for Unification, Typo? " + aName); + } + return GT_Utility.copyAmount(aAmount, new Object[]{mNameMap.get(aName.toString()), + getFirstOre(aName, aAmount), aReplacement}); + } + + + public static ItemStack getFirstOre(final Object aName, final long aAmount) { + if (GT_Utility.isStringInvalid(aName)) { + Utils.LOG_INFO("Returning Null. Method: "+ReflectionUtils.getMethodName(0)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(1)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(2)); + return null; + } + final ItemStack tStack = (ItemStack) mNameMap.get(aName.toString()); + if (GT_Utility.isStackValid(tStack)) { + return GT_Utility.copyAmount(aAmount, new Object[]{tStack}); + } + return GT_Utility.copyAmount(aAmount, getOres(aName).toArray()); + } + + public static ArrayList<ItemStack> getOres(final Object aOreName) { + final String aName = (aOreName == null) ? "" : aOreName.toString(); + final ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + if (GT_Utility.isStringValid(aName)) { + rList.addAll(getOres(aName)); + } + return rList; + } + + public Map getNameMap(){ + Map<String, ItemStack> tempMap; + try { + tempMap = (Map<String, ItemStack>) FieldUtils.readStaticField(GT_OreDictUnificator.class, "sName2StackMap", true); + if (tempMap != null){ + return tempMap; + } + } + catch (final IllegalAccessException e) { + e.printStackTrace(); + } + Utils.LOG_INFO("Invalid map stored in GT_OreDictUnificator.class, unable to find sName2StackMap field."); + return null; + } + + + +} |