diff options
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_BaseCrop.java | 5 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GT_ModHandler.java | 131 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GT_OreDictUnificator.java | 2 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Recipe.java | 116 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GT_RecipeRegistrator.java | 8 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Utility.java | 205 |
6 files changed, 349 insertions, 118 deletions
diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java index 38b88cc4fa..b9731f4899 100644 --- a/src/main/java/gregtech/api/util/GT_BaseCrop.java +++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java @@ -61,7 +61,6 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { * @param aGrowthSpeed how fast the Crop grows. if < 0 then its set to Tier*300 * @param aHarvestSize the size the Crop needs to be harvested. forced to be between 2 and max size * @param aBlock the block below needed for crop to grow. If null no block needed - * @param aMeta meta of the block below(-1 if no meta) */ public GT_BaseCrop(int aID, String aCropName, String aDiscoveredBy, ItemStack aBaseSeed, int aTier, int aMaxSize, int aGrowthSpeed, int aAfterHarvestSize, int aHarvestSize, int aStatChemical, int aStatFood, int aStatDefensive, int aStatColor, int aStatWeed, String[] aAttributes, Materials aBlock, ItemStack aDrop, ItemStack[] aSpecialDrops) { mName = aCropName; @@ -135,7 +134,7 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { @Override public final boolean canGrow(ICropTile aCrop) { - if (mBlock != null && aCrop.getSize() == mMaxSize - 1) { + if (GT_Mod.gregtechproxy.mCropNeedBlock && mBlock != null && aCrop.getSize() == mMaxSize - 1) { return isBlockBelow(aCrop); } return aCrop.getSize() < maxSize(); @@ -236,7 +235,7 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { public List<String> getCropInformation() { if (mBlock != null) { ArrayList<String> result = new ArrayList<String>(1); - result.add(String.format("Requires %s Ore or Block of %s as soil block to reach full growth.", mBlock.name(), mBlock.name())); + result.add(String.format("Requires %s Ore or Block of %s as soil block to reach full growth.", mBlock.mName, mBlock.mName)); return result; } return null; diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index df6071acac..a6086b986a 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -2,6 +2,7 @@ package gregtech.api.util; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.*; import gregtech.api.interfaces.IDamagableItem; @@ -183,7 +184,9 @@ public class GT_ModHandler { * Returns a Liquid Stack with given amount of distilled Water. */ public static FluidStack getDistilledWater(long aAmount) { - return FluidRegistry.getFluidStack("ic2distilledwater", (int) aAmount); + FluidStack tFluid = FluidRegistry.getFluidStack("ic2distilledwater", (int) aAmount); + if(tFluid==null)tFluid = getWater(aAmount); + return tFluid; } /** @@ -443,7 +446,8 @@ public class GT_ModHandler { if (aInput.stackSize == 1 && addSmeltingRecipe(aInput, aOutput)) temp = true; if (RA.addAlloySmelterRecipe(aInput, OrePrefixes.ingot.contains(aOutput) ? ItemList.Shape_Mold_Ingot.get(0) : OrePrefixes.block.contains(aOutput) ? ItemList.Shape_Mold_Block.get(0) : OrePrefixes.nugget.contains(aOutput) ? ItemList.Shape_Mold_Nugget.get(0) : null, aOutput, 130, 3,hidden)) temp = true; - if (addInductionSmelterRecipe(aInput, null, aOutput, null, aOutput.stackSize * 1600, 0)) temp = true; + if (GT_Mod.gregtechproxy.mTEMachineRecipes) + if (addInductionSmelterRecipe(aInput, null, aOutput, null, aOutput.stackSize * 1600, 0)) temp = true; return temp; } @@ -453,7 +457,7 @@ public class GT_ModHandler { public static boolean addLiquidTransposerRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) { aFullContainer = GT_OreDictUnificator.get(true, aFullContainer); if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false; - if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposer, aFullContainer, true)) + if (!GT_Mod.gregtechproxy.mTEMachineRecipes && !GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposer, aFullContainer, true)) return false; try { ThermalExpansion.addTransposerFill(aMJ * 10, aEmptyContainer, aFullContainer, aLiquid, true); @@ -467,7 +471,7 @@ public class GT_ModHandler { public static boolean addLiquidTransposerFillRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) { aFullContainer = GT_OreDictUnificator.get(true, aFullContainer); if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false; - if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposerfilling, aFullContainer, true)) + if (!GT_Mod.gregtechproxy.mTEMachineRecipes && !GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposerfilling, aFullContainer, true)) return false; try { ThermalExpansion.addTransposerFill(aMJ * 10, aEmptyContainer, aFullContainer, aLiquid, false); @@ -481,7 +485,7 @@ public class GT_ModHandler { public static boolean addLiquidTransposerEmptyRecipe(ItemStack aFullContainer, FluidStack aLiquid, ItemStack aEmptyContainer, int aMJ) { aEmptyContainer = GT_OreDictUnificator.get(true, aEmptyContainer); if (aFullContainer == null || aEmptyContainer == null || aLiquid == null) return false; - if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposeremptying, aFullContainer, true)) + if (!GT_Mod.gregtechproxy.mTEMachineRecipes && !GregTech_API.sRecipeFile.get(ConfigCategories.Machines.liquidtransposeremptying, aFullContainer, true)) return false; try { ThermalExpansion.addTransposerExtract(aMJ * 10, aFullContainer, aEmptyContainer, aLiquid, 100, false); @@ -495,9 +499,10 @@ public class GT_ModHandler { public static boolean addExtractionRecipe(ItemStack aInput, ItemStack aOutput) { aOutput = GT_OreDictUnificator.get(true, aOutput); if (aInput == null || aOutput == null) return false; - GT_Utility.removeSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null); + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null); if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.extractor, aInput, true)) return false; - GT_Utility.addSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null, aOutput); + RA.addExtractorRecipe(aInput, aOutput, 300, 2); + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.addSimpleIC2MachineRecipe(aInput, getExtractorRecipeList(), null, aOutput); return true; } @@ -549,18 +554,20 @@ public class GT_ModHandler { aOutput1 = GT_OreDictUnificator.get(true, aOutput1); aOutput2 = GT_OreDictUnificator.get(true, aOutput2); if (GT_Utility.isStackInvalid(aInput) || GT_Utility.isStackInvalid(aOutput1)) return false; - GT_Utility.removeSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null); + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null); if (GT_Utility.getContainerItem(aInput, false) == null) { - if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) { + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines && GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) { GT_Utility.addSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null, aOutput1); } - + addMagneticraftRecipe(aInput, aOutput1, aOutput2, aChance2, aOutput3, aChance3); + addImmersiveEngineeringRecipe(aInput, aOutput1, aOutput2, aChance2, aOutput3, aChance3); RA.addPulveriserRecipe(aInput, new ItemStack[]{aOutput1, aOutput2, aOutput3}, new int[]{10000, aChance2 <= 0 ? 1000 : 100 * aChance2, aChance3 <= 0 ? 1000 : 100 * aChance3}, 400, 2); if (!OrePrefixes.log.contains(aInput)) { + boolean aEnableTEMachineRecipes = GT_Mod.gregtechproxy.mTEMachineRecipes; if (Materials.Wood.contains(aOutput1)) { - if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) { + if (aEnableTEMachineRecipes && GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) { if (aOutput2 == null) ThermalExpansion.addSawmillRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1)); else @@ -579,7 +586,7 @@ public class GT_ModHandler { } } catch (Throwable e) {/*Do nothing*/} } - if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) { + if (aEnableTEMachineRecipes && GregTech_API.sRecipeFile.get(ConfigCategories.Machines.pulverization, aInput, true)) { if (aOutput2 == null) ThermalExpansion.addPulverizerRecipe(32000, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1)); else @@ -590,6 +597,27 @@ public class GT_ModHandler { } return true; } + + public static boolean addImmersiveEngineeringRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3){ + if(GregTech_API.mImmersiveEngineering && GT_Mod.gregtechproxy.mImmersiveEngineeringRecipes){ + blusunrize.immersiveengineering.common.IERecipes.addCrusherRecipe(aOutput1, aInput, 6000, aOutput2, 0.15f); + } + return true; + } + + public static boolean addMagneticraftRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3){ + if(GregTech_API.mMagneticraft && GT_Mod.gregtechproxy.mMagneticraftRecipes){ + ItemData tData = GT_OreDictUnificator.getAssociation(aInput); + if(tData!=null&&tData.mPrefix!=null){ + if(tData.mPrefix==OrePrefixes.ore||tData.mPrefix==OrePrefixes.oreBlackgranite||tData.mPrefix==OrePrefixes.oreEndstone||tData.mPrefix==OrePrefixes.oreNetherrack||tData.mPrefix==OrePrefixes.oreRedgranite){ + com.cout970.magneticraft.api.access.MgRecipeRegister.registerCrusherRecipe(aInput, aOutput1, aOutput2,(float)((float)aChance2/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent), aOutput3,(float)((float)aChance3/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent)); + }else if(tData.mPrefix==OrePrefixes.crushed||tData.mPrefix==OrePrefixes.crushedCentrifuged||tData.mPrefix==OrePrefixes.crushedPurified){ + com.cout970.magneticraft.api.access.MgRecipeRegister.registerGrinderRecipe(aInput, aOutput1, aOutput2,(float)((float)aChance2/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent), aOutput3,(float)((float)aChance3/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent)); + } + } + } + return true; + } /** * Adds a Recipe to the Sawmills of GregTech and ThermalCraft @@ -598,7 +626,7 @@ public class GT_ModHandler { aOutput1 = GT_OreDictUnificator.get(true, aOutput1); aOutput2 = GT_OreDictUnificator.get(true, aOutput2); if (aInput1 == null || aOutput1 == null) return false; - if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.sawmill, aInput1, true)) return false; + if (!GT_Mod.gregtechproxy.mTEMachineRecipes && !GregTech_API.sRecipeFile.get(ConfigCategories.Machines.sawmill, aInput1, true)) return false; try { ThermalExpansion.addSawmillRecipe(1600, aInput1, aOutput1, aOutput2, 100); } catch (Throwable e) {/*Do nothing*/} @@ -613,7 +641,8 @@ public class GT_ModHandler { aOutput1 = GT_OreDictUnificator.get(true, aOutput1); boolean temp = false; if (RA.addAlloySmelterRecipe(aInput1, aInput2, aOutput1, aDuration, aEUt)) temp = true; - if (addInductionSmelterRecipe(aInput1, aInput2, aOutput1, null, aDuration * aEUt * 2, 0)) temp = true; + if (GT_Mod.gregtechproxy.mTEMachineRecipes) + if (addInductionSmelterRecipe(aInput1, aInput2, aOutput1, null, aDuration * aEUt * 2, 0)) temp = true; return temp; } @@ -624,7 +653,7 @@ public class GT_ModHandler { aOutput1 = GT_OreDictUnificator.get(true, aOutput1); aOutput2 = GT_OreDictUnificator.get(true, aOutput2); if (aInput1 == null || aOutput1 == null || GT_Utility.getContainerItem(aInput1, false) != null) return false; - if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.inductionsmelter, aInput2 == null ? aInput1 : aOutput1, true)) + if (!GT_Mod.gregtechproxy.mTEMachineRecipes && !GregTech_API.sRecipeFile.get(ConfigCategories.Machines.inductionsmelter, aInput2 == null ? aInput1 : aOutput1, true)) return false; try { ThermalExpansion.addSmelterRecipe(aEnergy * 10, GT_Utility.copy(aInput1), aInput2 == null ? new ItemStack(Blocks.sand, 1, 0) : aInput2, aOutput1, aOutput2, aChance); @@ -642,6 +671,46 @@ public class GT_ModHandler { return true; } + /** + * Adds GT versions of the IC2 recipes from the supplied IC2RecipeList. + */ + public static void addIC2RecipesToGT(Map<IRecipeInput, RecipeOutput> aIC2RecipeList, GT_Recipe.GT_Recipe_Map aGTRecipeMap, boolean aAddGTRecipe, boolean aRemoveIC2Recipe, boolean aExcludeGTIC2Items) { + Map<ItemStack, ItemStack> aRecipesToRemove = new HashMap<>(); + for (Iterator i$ = aIC2RecipeList.entrySet().iterator(); i$.hasNext(); ) { + Entry tRecipe = (Map.Entry) i$.next(); + if (((RecipeOutput) tRecipe.getValue()).items.size() > 0) { + for (ItemStack tStack : ((IRecipeInput) tRecipe.getKey()).getInputs()) { + if (GT_Utility.isStackValid(tStack)) { + if (aAddGTRecipe && (aGTRecipeMap.findRecipe(null, false, Long.MAX_VALUE, null, tStack) == null)) { + if (aExcludeGTIC2Items && ((tStack.getUnlocalizedName().contains("gt.metaitem.01") || tStack.getUnlocalizedName().contains("gt.blockores") || tStack.getUnlocalizedName().contains("ic2.itemCrushed") || tStack.getUnlocalizedName().contains("ic2.itemPurifiedCrushed")))) continue; + try{ + switch (aGTRecipeMap.mUnlocalizedName) { + case "gt.recipe.macerator": + aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 300, 2, 0); + break; + case "gt.recipe.compressor": + aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 300, 2, 0); + break; + case "gt.recipe.extractor": + aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 300, 2, 0); + break; + case "gt.recipe.thermalcentrifuge": + aGTRecipeMap.addRecipe(true, new ItemStack[]{GT_Utility.copyAmount(((IRecipeInput) tRecipe.getKey()).getAmount(), tStack)}, (ItemStack[]) ((RecipeOutput) tRecipe.getValue()).items.toArray(), null, null, null, null, 500, 48, 0); + break; + } + }catch(Exception e){System.err.println(e);} + //System.out.println("#####Processed IC2 " + aGTRecipeMap.mUnlocalizedName + " Recipe: In(" + tStack.getUnlocalizedName() + ") - Out(" + ((RecipeOutput) tRecipe.getValue()).items.get(0).getUnlocalizedName() + ")"); + } + if (aRemoveIC2Recipe) aRecipesToRemove.put(tStack, ((RecipeOutput) tRecipe.getValue()).items.get(0)); + } + } + } + } + for (Entry<ItemStack, ItemStack> aEntry : aRecipesToRemove.entrySet()) { + GT_Utility.removeSimpleIC2MachineRecipe(aEntry.getKey(), aIC2RecipeList, aEntry.getValue()); + } + } + public static Map<IRecipeInput, RecipeOutput> getExtractorRecipeList() { try { return ic2.api.recipe.Recipes.extractor.getRecipes(); @@ -689,11 +758,14 @@ public class GT_ModHandler { */ public static boolean addThermalCentrifugeRecipe(ItemStack aInput, int aHeat, Object... aOutput) { if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; - GT_Utility.removeSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), null); + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), null); if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.thermalcentrifuge, aInput, true)) return false; - NBTTagCompound tNBT = new NBTTagCompound(); - tNBT.setInteger("minHeat", aHeat); - GT_Utility.addSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), tNBT, aOutput); + RA.addThermalCentrifugeRecipe(aInput, aOutput.length >= 1 ? (ItemStack)aOutput[0] : null, aOutput.length >= 2 ? (ItemStack)aOutput[1] : null, aOutput.length >= 3 ? (ItemStack)aOutput[2] : null, 500, 48); + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) { + NBTTagCompound tNBT = new NBTTagCompound(); + tNBT.setInteger("minHeat", aHeat); + GT_Utility.addSimpleIC2MachineRecipe(aInput, getThermalCentrifugeRecipeList(), tNBT, aOutput); + } return true; } @@ -702,11 +774,14 @@ public class GT_ModHandler { */ public static boolean addOreWasherRecipe(ItemStack aInput, int aWaterAmount, Object... aOutput) { if (aInput == null || aOutput == null || aOutput.length <= 0 || aOutput[0] == null) return false; - GT_Utility.removeSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), null); + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), null); if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.orewashing, aInput, true)) return false; - NBTTagCompound tNBT = new NBTTagCompound(); - tNBT.setInteger("amount", aWaterAmount); - GT_Utility.addSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), tNBT, aOutput); + RA.addOreWasherRecipe(aInput, (ItemStack)aOutput[0], (ItemStack)aOutput[1], (ItemStack)aOutput[2], GT_ModHandler.getWater(1000L), 500, 16); + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) { + NBTTagCompound tNBT = new NBTTagCompound(); + tNBT.setInteger("amount", aWaterAmount); + GT_Utility.addSimpleIC2MachineRecipe(aInput, getOreWashingRecipeList(), tNBT, aOutput); + } return true; } @@ -715,10 +790,11 @@ public class GT_ModHandler { */ public static boolean addCompressionRecipe(ItemStack aInput, ItemStack aOutput) { aOutput = GT_OreDictUnificator.get(true, aOutput); - if (aInput == null || aOutput == null) return false; - GT_Utility.removeSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null); + if (aInput == null || aOutput == null || GT_Utility.areStacksEqual(aInput, aOutput, true)) return false; + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.removeSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null); if (!GregTech_API.sRecipeFile.get(ConfigCategories.Machines.compression, aInput, true)) return false; - GT_Utility.addSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null, aOutput); + RA.addCompressorRecipe(aInput, aOutput, 300, 2); + if (GT_Mod.gregtechproxy.mAddGTRecipesToIC2Machines) GT_Utility.addSimpleIC2MachineRecipe(aInput, getCompressorRecipeList(), null, aOutput); return true; } @@ -1416,6 +1492,7 @@ public class GT_ModHandler { /** * Used in my own Macerator. Decreases StackSize of the Input if wanted. */ + @Deprecated public static ItemStack getMaceratorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { return GT_Utility.copy(getMachineOutput(aInput, getMaceratorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } @@ -1423,6 +1500,7 @@ public class GT_ModHandler { /** * Used in my own Extractor. Decreases StackSize of the Input if wanted. */ + @Deprecated public static ItemStack getExtractorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { return GT_Utility.copy(getMachineOutput(aInput, getExtractorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } @@ -1430,6 +1508,7 @@ public class GT_ModHandler { /** * Used in my own Compressor. Decreases StackSize of the Input if wanted. */ + @Deprecated public static ItemStack getCompressorOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { return GT_Utility.copy(getMachineOutput(aInput, getCompressorRecipeList(), aRemoveInput, new NBTTagCompound(), aOutputSlot)[0]); } diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index c8d95140a2..7552f5ea85 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -94,6 +94,8 @@ public class GT_OreDictUnificator { } public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, ItemStack aReplacement, long aAmount) { + //if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) aPrefix.mDynamicItems.add((Materials) aMaterial); + if (OrePrefixes.mPreventableComponents.contains(aPrefix) && aPrefix.mDisabledItems.contains(aMaterial)) return aReplacement; return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); } diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 06b70df0ae..72068ae247 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -33,7 +33,7 @@ import static gregtech.api.enums.GT_Values.*; * <p/> * I know this File causes some Errors, because of missing Main Functions, but if you just need to compile Stuff, then remove said erroreous Functions. */ -public class GT_Recipe { +public class GT_Recipe implements Comparable<GT_Recipe> { public static volatile int VERSION = 509; /** * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps. @@ -72,6 +72,11 @@ public class GT_Recipe { * If this Recipe needs the Output Slots to be completely empty. Needed in case you have randomised Outputs */ public boolean mNeedsEmptyOutput = false; + /** + * Used for describing recipes that do not fit the default recipe pattern (for example Large Boiler Fuels) + */ + private String[] neiDesc = null; + private GT_Recipe(GT_Recipe aRecipe) { mInputs = GT_Utility.copyStackArray((Object[]) aRecipe.mInputs); mOutputs = GT_Utility.copyStackArray((Object[]) aRecipe.mOutputs); @@ -173,6 +178,7 @@ public class GT_Recipe { // Diesel Generator case 0: GT_Recipe_Map.sDieselFuels.addRecipe(this); + GT_Recipe_Map.sLargeBoilerFakeFuels.addDieselRecipe(this); break; // Gas Turbine case 1: @@ -193,6 +199,7 @@ public class GT_Recipe { // Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator default: GT_Recipe_Map.sDenseLiquidFuels.addRecipe(this); + GT_Recipe_Map.sLargeBoilerFakeFuels.addDenseLiquidRecipe(this); break; } } @@ -424,8 +431,35 @@ public class GT_Recipe { return true; } - - public static class GT_Recipe_AssemblyLine{ + @Override + public int compareTo(GT_Recipe recipe) { + // first lowest tier recipes + // then fastest + // then with lowest special value + // then dry recipes + // then with fewer inputs + if (this.mEUt != recipe.mEUt) { + return this.mEUt - recipe.mEUt; + } else if (this.mDuration != recipe.mDuration) { + return this.mDuration - recipe.mDuration; + } else if (this.mSpecialValue != recipe.mSpecialValue) { + return this.mSpecialValue - recipe.mSpecialValue; + } else if (this.mFluidInputs.length != recipe.mFluidInputs.length) { + return this.mFluidInputs.length - recipe.mFluidInputs.length; + } else if (this.mInputs.length != recipe.mInputs.length) { + return this.mInputs.length - recipe.mInputs.length; + } + return 0; + } + + public String[] getNeiDesc() { + return neiDesc; + } + protected void setNeiDesc(String... neiDesc) { + this.neiDesc = neiDesc; + } + + public static class GT_Recipe_AssemblyLine{ public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<GT_Recipe_AssemblyLine>(); public ItemStack mResearchItem; @@ -454,10 +488,10 @@ public class GT_Recipe { */ public static final Collection<GT_Recipe_Map> sMappings = new ArrayList<GT_Recipe_Map>(); - public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map_OreWasher(new HashSet<GT_Recipe>(0), "ic.recipe.orewasher", "Ore Washing Plant", "ic2.blockOreWashingPlant", RES_PATH_GUI + "basicmachines/OreWasher", 1, 3, 1, 1, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map_ThermalCentrifuge(new HashSet<GT_Recipe>(0), "ic.recipe.thermalcentrifuge", "Thermal Centrifuge", "ic2.blockCentrifuge", RES_PATH_GUI + "basicmachines/ThermalCentrifuge", 1, 3, 1, 0, 2, E, 1, E, true, false); - public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map_Compressor(new HashSet<GT_Recipe>(0), "ic.recipe.compressor", "Compressor", "ic2.compressor", RES_PATH_GUI + "basicmachines/Compressor", 1, 1, 1, 0, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map_Extractor(new HashSet<GT_Recipe>(0), "ic.recipe.extractor", "Extractor", "ic2.extractor", RES_PATH_GUI + "basicmachines/Extractor", 1, 1, 1, 0, 1, E, 1, E, true, false); + public static final GT_Recipe_Map sOreWasherRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(120), "gt.recipe.orewasher", "Ore Washing Plant", null, RES_PATH_GUI + "basicmachines/OreWasher", 1, 3, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sThermalCentrifugeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(120), "gt.recipe.thermalcentrifuge", "Thermal Centrifuge", null, RES_PATH_GUI + "basicmachines/ThermalCentrifuge", 1, 3, 1, 0, 2, E, 1, E, true, true); + public static final GT_Recipe_Map sCompressorRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(1000), "gt.recipe.compressor", "Compressor", null, RES_PATH_GUI + "basicmachines/Compressor", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sExtractorRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(30), "gt.recipe.extractor", "Extractor", null, RES_PATH_GUI + "basicmachines/Extractor", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sRecyclerRecipes = new GT_Recipe_Map_Recycler(new HashSet<GT_Recipe>(0), "ic.recipe.recycler", "Recycler", "ic2.recycler", RES_PATH_GUI + "basicmachines/Recycler", 1, 1, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sFurnaceRecipes = new GT_Recipe_Map_Furnace(new HashSet<GT_Recipe>(0), "mc.recipe.furnace", "Furnace", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sMicrowaveRecipes = new GT_Recipe_Map_Microwave(new HashSet<GT_Recipe>(0), "gt.recipe.microwave", "Microwave", "smelting", RES_PATH_GUI + "basicmachines/E_Furnace", 1, 1, 1, 0, 1, E, 1, E, true, false); @@ -465,9 +499,9 @@ public class GT_Recipe { public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(300), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Scanner", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(3), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet<GT_Recipe>(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sRepicatorFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sReplicatorFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(30), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(30), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, false); - public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true); public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer(new HashSet<GT_Recipe>(100), "gt.recipe.printer", "Printer", null, RES_PATH_GUI + "basicmachines/Printer", 1, 1, 1, 1, 1, E, 1, E, true, true); @@ -477,11 +511,11 @@ public class GT_Recipe { public static final GT_Recipe_Map sMixerRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.mixer", "Mixer", null, RES_PATH_GUI + "basicmachines/Mixer", 4, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAutoclaveRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.autoclave", "Autoclave", null, RES_PATH_GUI + "basicmachines/Autoclave", 1, 1, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sElectroMagneticSeparatorRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.electromagneticseparator", "Electromagnetic Separator", null, RES_PATH_GUI + "basicmachines/ElectromagneticSeparator", 1, 3, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.polarizer", "Polarizer", null, RES_PATH_GUI + "basicmachines/Polarizer", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sMaceratorRecipes = new GT_Recipe_Map_Macerator(new HashSet<GT_Recipe>(16000), "gt.recipe.macerator", "Pulverizer", null, RES_PATH_GUI + "basicmachines/Macerator4", 1, 4, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sPolarizerRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.polarizer", "Electromagnetic Polarizer", null, RES_PATH_GUI + "basicmachines/Polarizer", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sMaceratorRecipes = new GT_Recipe_Map_Macerator(new HashSet<GT_Recipe>(10000), "gt.recipe.macerator", "Pulverization", null, RES_PATH_GUI + "basicmachines/Macerator4", 1, 4, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sFluidCannerRecipes = new GT_Recipe_Map_FluidCanner(new HashSet<GT_Recipe>(100), "gt.recipe.fluidcanner", "Fluid Canner", null, RES_PATH_GUI + "basicmachines/FluidCannerNEI", 1, 1, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sBrewingRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.brewer", "Brewery", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 0, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFluidCannerRecipes = new GT_Recipe_Map_FluidCanner(new HashSet<GT_Recipe>(100), "gt.recipe.fluidcanner", "Fluid Canning Machine", null, RES_PATH_GUI + "basicmachines/FluidCannerNEI", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sBrewingRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.brewer", "Brewing Machine", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 0, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sFluidHeaterRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.fluidheater", "Fluid Heater", null, RES_PATH_GUI + "basicmachines/FluidHeater", 1, 0, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sDistilleryRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.distillery", "Distillery", null, RES_PATH_GUI + "basicmachines/Distillery", 1, 0, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sFermentingRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.fermenter", "Fermenter", null, RES_PATH_GUI + "basicmachines/Fermenter", 0, 0, 0, 1, 1, E, 1, E, true, true); @@ -503,14 +537,16 @@ public class GT_Recipe { public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(400), "gt.recipe.metalbender", "Bending Machine", null, RES_PATH_GUI + "basicmachines/Bender", 2, 1, 2, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAlloySmelterRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(3000), "gt.recipe.alloysmelter", "Alloy Smelter", null, RES_PATH_GUI + "basicmachines/AlloySmelter", 2, 1, 2, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<GT_Recipe>(300), "gt.recipe.assembler", "Assembling Machine", null, RES_PATH_GUI + "basicmachines/Assembler", 2, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sCircuitAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<GT_Recipe>(300), "gt.recipe.circuitassembler", "Circuit Assembler", null, RES_PATH_GUI + "basicmachines/CircuitAssembler", 6, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sCannerRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(300), "gt.recipe.canner", "Canning Machine", null, RES_PATH_GUI + "basicmachines/Canner", 2, 2, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sCNCRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.cncmachine", "CNC Machine", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 2, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sLatheRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(400), "gt.recipe.lathe", "Lathe", null, RES_PATH_GUI + "basicmachines/Lathe", 1, 2, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCutterRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.cuttingsaw", "Cutting Machine", null, RES_PATH_GUI + "basicmachines/Cutter", 1, 2, 1, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sCutterRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.cuttingsaw", "CCutting Machine", null, RES_PATH_GUI + "basicmachines/Cutter", 1, 2, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sSlicerRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.slicer", "Slicing Machine", null, RES_PATH_GUI + "basicmachines/Slicer", 2, 1, 2, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sExtruderRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(1000), "gt.recipe.extruder", "Extruder", null, RES_PATH_GUI + "basicmachines/Extruder", 2, 1, 2, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.hammer", "Forge Hammer", null, RES_PATH_GUI + "basicmachines/Hammer", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet<GT_Recipe>(10), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.dieselgeneratorfuel", "Diesel Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); @@ -522,6 +558,7 @@ public class GT_Recipe { public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.fluidnaquadahreactor", "Naquadah Reactor MkIII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.hugenaquadahreactor", "Naquadah Reactor MkIV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sExtraHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.extrahugenaquadahreactor", "Naquadah Reactor MkV", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Large_Boiler_Fake_Fuels sLargeBoilerFakeFuels = new GT_Recipe_Map_Large_Boiler_Fake_Fuels(); /** * HashMap of Recipes based on their Items @@ -1364,4 +1401,55 @@ public class GT_Recipe { return super.containsInput(aFluid) || Dyes.isAnyFluidDye(aFluid); } } + + public static class GT_Recipe_Map_Large_Boiler_Fake_Fuels extends GT_Recipe_Map { + + public GT_Recipe_Map_Large_Boiler_Fake_Fuels(){ + super(new HashSet<GT_Recipe>(30), "gt.recipe.largeboilerfakefuels", "Large Boiler", null, RES_PATH_GUI + "basicmachines/Default", 1, 0, 1, 0, 1, E, 1, E, true , true); + GT_Recipe explanatoryRecipe = new GT_Recipe(true, new ItemStack[]{}, new ItemStack[]{}, null, null, null, null, 1, 1, 1); + explanatoryRecipe.setNeiDesc("Not all solid fuels are listed.", "Any item that burns in a", "vanilla furnace will burn in", "a Large Boiler."); + addRecipe(explanatoryRecipe); + } + + public GT_Recipe addDenseLiquidRecipe(GT_Recipe recipe) { + return addRecipe(recipe, ((double)recipe.mSpecialValue) / 10); + } + + public GT_Recipe addDieselRecipe(GT_Recipe recipe) { + return addRecipe(recipe,((double)recipe.mSpecialValue) / 40); + } + + public void addSolidRecipes(ItemStack ... itemStacks) { + for(ItemStack itemStack : itemStacks){ + addSolidRecipe(itemStack); + } + } + + public GT_Recipe addSolidRecipe(ItemStack fuelItemStack){ + return addRecipe(new GT_Recipe(true, new ItemStack[]{fuelItemStack}, new ItemStack[]{}, null, null, null, null, 1, 0, GT_ModHandler.getFuelValue(fuelItemStack) / 1600), ((double)GT_ModHandler.getFuelValue(fuelItemStack)) / 1600); + } + + private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime){ + recipe = new GT_Recipe(recipe); + //Some recipes will have a burn time like 15.9999999 and % always rounds down + double floatErrorCorrection = 0.0001; + + double bronzeBurnTime = baseBurnTime * 2 + floatErrorCorrection; + bronzeBurnTime -= bronzeBurnTime % 0.05; + double steelBurnTime = baseBurnTime * 1.5 + floatErrorCorrection; + steelBurnTime -= steelBurnTime % 0.05; + double titaniumBurnTime = baseBurnTime * 1.3 + floatErrorCorrection; + titaniumBurnTime -= titaniumBurnTime % 0.05; + double tungstensteelBurnTime = baseBurnTime * 1.2 + floatErrorCorrection; + tungstensteelBurnTime -= tungstensteelBurnTime % 0.05; + + recipe.setNeiDesc("Burn time in seconds:", + String.format("Bronze Boiler: %.2f", bronzeBurnTime), + String.format("Steel Boiler: %.2f", steelBurnTime), + String.format("Titanium Boiler: %.2f", titaniumBurnTime), + String.format("Tungstensteel Boiler: %.2f", tungstensteelBurnTime)); + return super.addRecipe(recipe); + } + + } } diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java index 5ea328ad4d..ad14439da0 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java @@ -212,7 +212,11 @@ public class GT_RecipeRegistrator { continue; } if (tMaterial.mMaterial.contains(SubTag.METAL)) { + if(GT_Mod.gregtechproxy.mArcSmeltIntoAnnealed){ tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto; + }else{ + tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mSmeltInto; + } continue; } tMaterial.mAmount = 0; @@ -232,7 +236,7 @@ public class GT_RecipeRegistrator { tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); boolean tHide = !tIron && GT_Mod.gregtechproxy.mHideRecyclingRecipes; - RA.addArcFurnaceRecipe(aStack, new ItemStack[]{GT_OreDictUnificator.getIngotOrDust(aData.mMaterial), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(0)), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(1)), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(2))}, null, (int) Math.max(16, tAmount / M), 90, tHide); + RA.addArcFurnaceRecipe(aStack, new ItemStack[]{GT_OreDictUnificator.getIngotOrDust(aData.mMaterial), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(0)), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(1)), GT_OreDictUnificator.getIngotOrDust(aData.getByProduct(2))}, null, (int) Math.max(16, tAmount / M), 96, tHide); } public static void registerReverseMacerating(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03, boolean aAllowHammer) { @@ -346,4 +350,4 @@ public class GT_RecipeRegistrator { } } } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 0cbe6b404f..7e38838728 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1463,7 +1463,21 @@ public class GT_Utility { if(aDimensionID<=1 && aDimensionID>=-1 && !GregTech_API.sDimensionalList.contains(aDimensionID)) return true; return !GregTech_API.sDimensionalList.contains(aDimensionID) && DimensionManager.isDimensionRegistered(aDimensionID); } - + + //public static boolean isRealDimension(int aDimensionID) { + // try { + // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("com.xcompwiz.mystcraft")) + // return true; + // } catch (Throwable e) {/*Do nothing*/} + // try { + // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("TwilightForest")) return true; + // } catch (Throwable e) {/*Do nothing*/} + // try { + // if (DimensionManager.getProvider(aDimensionID).getClass().getName().contains("galacticraft")) return true; + // } catch (Throwable e) {/*Do nothing*/} + // return GregTech_API.sDimensionalList.contains(aDimensionID); + //} + public static boolean moveEntityToDimensionAtCoords(Entity entity, int aDimension, double aX, double aY, double aZ) { //Credit goes to BrandonCore Author :!: @@ -1554,76 +1568,118 @@ public class GT_Utility { entity.fallDistance = 0; return true; } - - public static FluidStack undergroundOil(World aWorld, int aX, int aZ,boolean save,int sub) { - ChunkPosition tPos = new ChunkPosition(aX, 1, aZ); - int[] tInts = {0,0,0}; - if(GT_Proxy.chunkData.containsKey(tPos)){ - tInts = GT_Proxy.chunkData.get(tPos); - if(tInts.length>0){ - int type=tInts[0]>>28; - int amnt=tInts[0]-(type<<28)-sub; - if(type==0){//update old thing //IGNORES SAVE - chunk must be updated - GT_Proxy.chunkData.remove(tPos); - return setUndergroundOil(aWorld,aX,aZ,tPos,tInts); - } - if(save){//obvious? - //tInts[2]|=0x01; - if(amnt<=0) tInts[0] = type << 28; - else tInts[0] = (type << 28) + amnt; - GT_Proxy.chunkData.remove(tPos); - GT_Proxy.chunkData.put(tPos, tInts); - } - return getUndergroundOilFromInfo(type,amnt);//return negative amounts? if u extract too much - } - GT_Proxy.chunkData.remove(tPos);//remove broken - } - return setUndergroundOil(aWorld,aX,aZ,tPos,tInts);//will save if empty + + public static int getScaleCoordinates(double aValue, int aScale) { + return (int)Math.floor(aValue / aScale); } - private static FluidStack getUndergroundOilFromInfo(int type,int amnt){ - switch (type) {//0 is old system - case 1: - return new FluidStack(Materials.OilLight .mFluid,amnt); - case 2: - return new FluidStack(Materials.OilMedium.mFluid,amnt); - case 3: - return new FluidStack(Materials.OilHeavy .mFluid,amnt); - case 4: - return new FluidStack(Materials.Oil .mFluid,amnt); - } - return new FluidStack(Materials.NatruralGas.mGas,amnt);//5 + public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) { + return getUndergroundOil(aWorld, aX, aZ, false); } - private static FluidStack setUndergroundOil(World aWorld, int aX, int aZ,ChunkPosition tPos,int[] tInts) { - XSTR tRandom = new XSTR(aWorld.getSeed() ^ ((long)(aX / 6) + (long)(7000 * (aZ / 6)))); - int type=tRandom.nextInt(5);//type slowly changes - int amnt = (int)(Math.ceil(Math.pow(2D+(double)(tRandom.nextInt(48))+(new XSTR()).nextDouble(),8D)/200000D)); - //roughly uses 28 bits - FluidStack tFluidStack; - switch (type) {//0 is old system - case 1: - tFluidStack=new FluidStack(Materials.OilLight .mFluid,amnt); - break; - case 2: - tFluidStack=new FluidStack(Materials.OilMedium.mFluid,amnt); - break; - case 3: - tFluidStack=new FluidStack(Materials.OilHeavy .mFluid,amnt); - break; - case 4: - tFluidStack=new FluidStack(Materials.Oil .mFluid,amnt); - break; - default://case 0; -> 5 - type=5;//important, 0 is invalid ! - tFluidStack=new FluidStack(Materials.NatruralGas.mGas,amnt);//5 - } + public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ, boolean needConsumeOil) {//TODO RETROGEN!, CHECK FLUIDS AVAILABLE, REWORK - tInts[0]=(type<<28)+amnt;//here since the switch changes type - //tInts[2]|=0x01; - GT_Proxy.chunkData.put(tPos, tInts); - return tFluidStack; - } + if (GT_Mod.gregtechproxy.mUndergroundOil.CheckBlackList(aWorld.provider.dimensionId)) + return null; + + XSTR tRandom = new XSTR((aWorld.getSeed() + aWorld.provider.dimensionId * 2 + (getScaleCoordinates(aX,96)) + (7 * (getScaleCoordinates(aZ,96))))); + int tAmount = 0; + int tFluidId = 0; + int tDecreasePerOperationAmount = 5; + Fluid tFluid = null; +// System.out.println("Dimension: "+GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).Dimension); + try { + GT_UO_Fluid uoFluid = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).getRandomFluid(tRandom); + if (uoFluid != null) + { + tFluid = uoFluid.getFluid(); + tAmount = uoFluid.getRandomAmount(tRandom); + tDecreasePerOperationAmount = uoFluid.DecreasePerOperationAmount; + if (tFluid != null) + tFluidId = tFluid.getID(); + //System.out.println("Fluid: ("+tFluidId+")"+tFluid.getName()+" Amount:"+tAmount); + } + + } catch (Exception e) { + tAmount = 0; + tFluidId = 0; + } + + try { + ChunkPosition tPos = new ChunkPosition(getScaleCoordinates(aX,16), aWorld.provider.dimensionId, getScaleCoordinates(aZ,16)); + int[] tInts = new int[3]; + if(GT_Proxy.chunkData.containsKey(tPos)){ + tInts = GT_Proxy.chunkData.get(tPos); + if(tInts.length>0){ + if(tInts[0]>0){tAmount = tInts[0];} + } + if(tInts.length>2){ + if(tInts[2]>0&&tInts[2]!=tFluidId) + { + tFluidId = tInts[2]; + tFluid = FluidRegistry.getFluid(tFluidId); + } + } + GT_Proxy.chunkData.remove(tPos); + } + + if (needConsumeOil && tAmount >= 5000) + tAmount = tAmount - tDecreasePerOperationAmount; + + tInts[0] = tAmount; + tInts[2] = tFluidId; + GT_Proxy.chunkData.put(tPos, tInts); + } catch (Exception e) { + System.out.println("getUndergroundOil() - Error put data"); + } + if (tFluid!=null) + return new FluidStack(tFluid, tAmount); + return null; + } + + //private static FluidStack getUndergroundOilFromInfo(int type,int amnt){ + // switch (type) {//0 is old system + // case 1: + // return new FluidStack(Materials.OilLight .mFluid,amnt); + // case 2: + // return new FluidStack(Materials.OilMedium.mFluid,amnt); + // case 3: + // return new FluidStack(Materials.OilHeavy .mFluid,amnt); + // case 4: + // return new FluidStack(Materials.Oil .mFluid,amnt); + // } + // return new FluidStack(Materials.NatruralGas.mGas,amnt);//5 + //} + // + //private static FluidStack setUndergroundOil(World aWorld, int aX, int aZ,ChunkPosition tPos,int[] tInts) { + // XSTR tRandom = new XSTR(aWorld.getSeed() ^ ((long)(aX / 6) + (long)(7000 * (aZ / 6)))); + // int type=tRandom.nextInt(5);//type slowly changes + // int amnt = (int)(Math.ceil(Math.pow(2D+(double)(tRandom.nextInt(48))+(new XSTR()).nextDouble(),8D)/200000D)); + // //roughly uses 28 bits + // FluidStack tFluidStack; + // switch (type) {//0 is old system + // case 1: + // tFluidStack=new FluidStack(Materials.OilLight .mFluid,amnt); + // break; + // case 2: + // tFluidStack=new FluidStack(Materials.OilMedium.mFluid,amnt); + // break; + // case 3: + // tFluidStack=new FluidStack(Materials.OilHeavy .mFluid,amnt); + // break; + // case 4: + // tFluidStack=new FluidStack(Materials.Oil .mFluid,amnt); + // break; + // default://case 0; -> 5 + // type=5;//important, 0 is invalid ! + // tFluidStack=new FluidStack(Materials.NatruralGas.mGas,amnt);//5 + // } + // + // tInts[0]=(type<<28)+amnt;//here since the switch changes type + // //tInts[2]|=0x01; + // GT_Proxy.chunkData.put(tPos, tInts); + // return tFluidStack; + //} public static int getCoordinateScan(ArrayList<String> aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) { if (aList == null) return 0; @@ -1813,16 +1869,17 @@ public class GT_Utility { if (D1) e.printStackTrace(GT_Log.err); } } - if (aPlayer.capabilities.isCreativeMode) { - FluidStack tFluid = undergroundOil(aWorld, aX>>4, aZ>>4,false,0); - tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+" L"); + if (aPlayer.capabilities.isCreativeMode && GT_Values.D1) { + FluidStack tFluid = getUndergroundOil(aWorld, aX, aZ); + if (tFluid!=null) + tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+" L"); } // if(aPlayer.capabilities.isCreativeMode){ - ChunkPosition tPos = new ChunkPosition(aX>>4, 1, aZ>>4); + ChunkPosition tPos = new ChunkPosition(getScaleCoordinates(aX,16), aWorld.provider.dimensionId, getScaleCoordinates(aZ,16)); if(GT_Proxy.chunkData.containsKey(tPos)){ int[] tPollution = GT_Proxy.chunkData.get(tPos); - if(tPollution.length>1 && tPollution[1]>0){ - tList.add("Pollution in Chunk: "+EnumChatFormatting.RED+tPollution[1]+EnumChatFormatting.RESET+" gibbl"); + if(tPollution.length>1){ + tList.add("Pollution in Chunk: "+EnumChatFormatting.RED+tPollution[1]+EnumChatFormatting.RESET+" gibbl"); }else{ tList.add(EnumChatFormatting.GREEN+"No Pollution in Chunk! HAYO!"+EnumChatFormatting.RESET); } @@ -2071,7 +2128,9 @@ public class GT_Utility { tNBT.setString("prospection", tData); setNBT(aStack, tNBT); } - + + + public static void setAdvancedProspectionData( byte aTier, ItemStack aStack, |