diff options
Diffstat (limited to 'src/main/java/gregtech/api/util')
7 files changed, 272 insertions, 74 deletions
diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java index 4b0e4a5526..304a0f3c62 100644 --- a/src/main/java/gregtech/api/util/GT_BaseCrop.java +++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java @@ -1,23 +1,37 @@ package gregtech.api.util; +import cpw.mods.fml.common.Loader; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.objects.ItemData; +import gregtech.common.blocks.GT_Block_Ores; +import gregtech.common.blocks.GT_TileEntity_Ores; import ic2.api.crops.CropCard; import ic2.api.crops.Crops; import ic2.api.crops.ICropTile; +import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import speiger.src.crops.api.ICropCardInfo; import java.util.ArrayList; +import java.util.List; import java.util.Random; import static gregtech.api.enums.GT_Values.E; -public class GT_BaseCrop extends CropCard { +public class GT_BaseCrop extends CropCard implements ICropCardInfo { public static ArrayList<GT_BaseCrop> sCropList = new ArrayList<GT_BaseCrop>(); private String mName = E, mDiscoveredBy = "Gregorius Techneticies", mAttributes[]; - private int mTier = 0, mMaxSize = 0, mAfterHarvestSize = 0, mHarvestSize = 0, mStats[] = new int[5]; + private int mTier = 0, mMaxSize = 0, mAfterHarvestSize = 0, mHarvestSize = 0, mStats[] = new int[5], mGrowthSpeed = 0; private ItemStack mDrop = null, mSpecialDrops[] = null; + private Materials mBlock = null; + private static boolean bIc2NeiLoaded = Loader.isModLoaded("Ic2Nei"); /** * To create new Crops @@ -32,7 +46,26 @@ public class GT_BaseCrop extends CropCard { * @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 */ - public GT_BaseCrop(int aID, String aCropName, String aDiscoveredBy, ItemStack aDrop, ItemStack[] aSpecialDrops, ItemStack aBaseSeed, int aTier, int aMaxSize, int aGrowthSpeed, int aAfterHarvestSize, int aHarvestSize, int aStatChemical, int aStatFood, int aStatDefensive, int aStatColor, int aStatWeed, String[] aAttributes) { + 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, ItemStack aDrop, ItemStack[] aSpecialDrops) { + new GT_BaseCrop(aID, aCropName, aDiscoveredBy, aBaseSeed, aTier, aMaxSize, aGrowthSpeed, aAfterHarvestSize, aHarvestSize, aStatChemical, aStatFood, aStatDefensive, aStatColor, aStatWeed, aAttributes, null, aDrop, aSpecialDrops); + } + + /** + * To create new Crops + * + * @param aID Default ID + * @param aCropName Name of the Crop + * @param aDiscoveredBy The one who discovered the Crop + * @param aDrop The Item which is dropped by the Crop. must be != null + * @param aBaseSeed Baseseed to plant this Crop. null == crossbreed only + * @param aTier tier of the Crop. forced to be >= 1 + * @param aMaxSize maximum Size of the Crop. forced to be >= 3 + * @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; aID = GT_Config.addIDConfig(ConfigCategories.IDs.crops, mName.replaceAll(" ", "_"), aID); if (aDiscoveredBy != null && !aDiscoveredBy.equals(E)) mDiscoveredBy = aDiscoveredBy; @@ -41,7 +74,6 @@ public class GT_BaseCrop extends CropCard { mSpecialDrops = aSpecialDrops; mTier = Math.max(1, aTier); mMaxSize = Math.max(3, aMaxSize); -// mGrowthSpeed = aGrowthSpeed>0?aGrowthSpeed:mTier*300; mHarvestSize = Math.min(Math.max(aHarvestSize, 2), mMaxSize); mAfterHarvestSize = Math.min(Math.max(aAfterHarvestSize, 1), mMaxSize - 1); mStats[0] = aStatChemical; @@ -50,10 +82,31 @@ public class GT_BaseCrop extends CropCard { mStats[3] = aStatColor; mStats[4] = aStatWeed; mAttributes = aAttributes; + mBlock = aBlock; + if(GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.crops, aCropName, true)){ if (!Crops.instance.registerCrop(this, aID)) throw new GT_ItsNotMyFaultException("Make sure the Crop ID is valid!"); - if (aBaseSeed != null) Crops.instance.registerBaseSeed(aBaseSeed, aID, 1, 1, 1, 1); - sCropList.add(this); + if (aBaseSeed != null) Crops.instance.registerBaseSeed(aBaseSeed, this, 1, 1, 1, 1); + sCropList.add(this);} + } + if (bIc2NeiLoaded) { + try { + Class.forName("speiger.src.crops.api.CropPluginAPI").getMethod("registerCropInfo", Class.forName("speiger.src.crops.api.ICropCardInfo")).invoke(Class.forName("speiger.src.crops.api.CropPluginAPI").getField("instance"), this); + } catch (IllegalAccessException ex) { + bIc2NeiLoaded = false; + } catch (IllegalArgumentException ex) { + bIc2NeiLoaded = false; + } catch (java.lang.reflect.InvocationTargetException ex) { + bIc2NeiLoaded = false; + } catch (NoSuchFieldException ex) { + bIc2NeiLoaded = false; + } catch (NoSuchMethodException ex) { + bIc2NeiLoaded = false; + } catch (SecurityException ex) { + bIc2NeiLoaded = false; + } catch (ClassNotFoundException ex) { + bIc2NeiLoaded = false; + } } } @@ -63,6 +116,16 @@ public class GT_BaseCrop extends CropCard { } @Override + public int growthDuration(ICropTile aCrop) { + if (mGrowthSpeed < 200) return super.growthDuration(aCrop); + return tier() * mGrowthSpeed; + } + + public int getrootslength(ICropTile crop) { + return 5; + } + + @Override public String[] attributes() { return mAttributes; } @@ -74,6 +137,9 @@ public class GT_BaseCrop extends CropCard { @Override public final boolean canGrow(ICropTile aCrop) { + if (mBlock != null && aCrop.getSize() == mMaxSize - 1) { + return isBlockBelow(aCrop); + } return aCrop.getSize() < maxSize(); } @@ -111,7 +177,7 @@ public class GT_BaseCrop extends CropCard { @Override public ItemStack getGain(ICropTile aCrop) { int tDrop = 0; - if (mSpecialDrops != null && (tDrop = new Random().nextInt(mSpecialDrops.length + 4)) < mSpecialDrops.length && mSpecialDrops[tDrop] != null) { + if (mSpecialDrops != null && (tDrop = new Random().nextInt((mSpecialDrops.length*2) + 2)) < mSpecialDrops.length && mSpecialDrops[tDrop] != null) { return GT_Utility.copy(mSpecialDrops[tDrop]); } return GT_Utility.copy(mDrop); @@ -127,4 +193,62 @@ public class GT_BaseCrop extends CropCard { public int getOptimalHavestSize(ICropTile crop) { return maxSize(); } + + public boolean isBlockBelow(ICropTile aCrop) { + if (aCrop == null) { + return false; + } + for (int i = 1; i < this.getrootslength(aCrop); i++) { + Block tBlock = aCrop.getWorld().getBlock(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); + if ((tBlock instanceof GT_Block_Ores)) { + TileEntity tTileEntity = aCrop.getWorld().getTileEntity(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + Materials tMaterial = GregTech_API.sGeneratedMaterials[(((GT_TileEntity_Ores) tTileEntity).mMetaData % 1000)]; + if ((tMaterial != null) && (tMaterial != Materials._NULL)) { + if (tMaterial == mBlock) { + return true; + } else { + return false; + } + } + } + } else { + int tMetaID = aCrop.getWorld().getBlockMetadata(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); + ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID)); + if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore")) && (tAssotiation.mMaterial.mMaterial == mBlock)) { + return true; + } + if ((tAssotiation != null) && (tAssotiation.mPrefix == OrePrefixes.block) && (tAssotiation.mMaterial.mMaterial == mBlock)) { + return true; + } + } +// Block block = aCrop.getWorld().getBlock(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); +// if (block.isAir(aCrop.getWorld(), aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ)) { +// return false; +// } +// if (block == mBlock) { +// int tMeta = aCrop.getWorld().getBlockMetadata(aCrop.getLocation().posX, aCrop.getLocation().posY - i, aCrop.getLocation().posZ); +// if(mMeta < 0 || tMeta == mMeta){ +// return true;} +// } + } + return false; + } + + 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())); + return result; + } + return null; + } + + public ItemStack getDisplayItem() { + if (mSpecialDrops != null && mSpecialDrops[mSpecialDrops.length - 1] != null) { + return GT_Utility.copy(mSpecialDrops[mSpecialDrops.length - 1]); + } + return GT_Utility.copy(mDrop); + } + } diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 809a5219ce..83fe3ff509 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -53,7 +53,7 @@ public class GT_ModHandler { public static final List<IRecipe> sSingleNonBlockDamagableRecipeList = new ArrayList<IRecipe>(1000); private static final Map<String, ItemStack> sIC2ItemMap = new HashMap<String, ItemStack>(); private static final List<IRecipe> sAllRecipeList = Collections.synchronizedList(new ArrayList<IRecipe>(5000)), sBufferRecipeList = new ArrayList<IRecipe>(1000); - public static volatile int VERSION = 508; + public static volatile int VERSION = 509; public static Collection<String> sNativeRecipeClasses = new HashSet<String>(), sSpecialRecipeClasses = new HashSet<String>(); public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<GT_ItemStack>(); public static Object sBoxableWrapper = GT_Utility.callConstructor("gregtechmod.api.util.GT_IBoxableWrapper", 0, null, false); @@ -381,11 +381,11 @@ public class GT_ModHandler { /** * Adds to Furnace AND Alloysmelter AND Induction Smelter */ - public static boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput) { + public static boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput, boolean hidden) { if (aInput == null || aOutput == null) return false; boolean temp = false; 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)) + 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; return temp; @@ -1591,7 +1591,6 @@ public class GT_ModHandler { } else { tPlayer.inventory.mainInventory[i].stackSize--; } - if (tPlayer.inventoryContainer != null) tPlayer.inventoryContainer.detectAndSendChanges(); if (canUseElectricItem(aStack, 10000)) { return GT_ModHandler.useElectricItem(aStack, 10000, (EntityPlayer) aPlayer); diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index 39eabad202..b404299fad 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -32,7 +32,7 @@ public class GT_OreDictUnificator { private static final HashMap<String, ItemStack> sName2StackMap = new HashMap<String, ItemStack>(); private static final HashMap<GT_ItemStack, ItemData> sItemStack2DataMap = new HashMap<GT_ItemStack, ItemData>(); private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<GT_ItemStack>(); - public static volatile int VERSION = 508; + public static volatile int VERSION = 509; private static int isRegisteringOre = 0, isAddingOre = 0; private static boolean mRunThroughTheList = true; diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 90b004d307..71b0019980 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -34,7 +34,7 @@ import static gregtech.api.enums.GT_Values.*; * 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 static volatile int VERSION = 508; + 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. */ @@ -382,12 +382,12 @@ public class GT_Recipe { 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); - public static final GT_Recipe_Map sScannerFakeRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(3), "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 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 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 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); @@ -417,6 +417,8 @@ public class GT_Recipe { public static final GT_Recipe_Map sVacuumRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.vacuumfreezer", "Vacuum Freezer", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.chemicalreactor", "Chemical Reactor", null, RES_PATH_GUI + "basicmachines/ChemicalReactor", 2, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sDistillationRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.distillationtower", "Distillation Tower", null, RES_PATH_GUI + "basicmachines/Default", 2, 4, 0, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sCrakingRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.craker", "Oil Cracker", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 1, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.pyro", "Pyrolyse Oven", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sWiremillRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.wiremill", "Wiremill", null, RES_PATH_GUI + "basicmachines/Wiremill", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(400), "gt.recipe.metalbender", "Metal Bender", 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); @@ -439,8 +441,7 @@ public class GT_Recipe { public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.largenaquadahreactor", "Large Naquadah Reactor", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sFluidNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.fluidnaquadahreactor", "Fluid Naquadah Reactor", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map sAssemblylineRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(100), "gt.recipe.assemblyline", "Assemblyline", null, RES_PATH_GUI + "basicmachines/Default", 15, 1, 4, 0, 1, E, 1, E, false, false); - - /** + /** * HashMap of Recipes based on their Items */ diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java index 1d391cd835..611c8d34e2 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java @@ -1,5 +1,6 @@ package gregtech.api.util; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.*; import gregtech.api.enums.TC_Aspects.TC_AspectStack; @@ -119,7 +120,7 @@ public class GT_RecipeRegistrator { {"Scythe", s_I + s_P + s_H, s_R + s_F + s_P, s_R + " " + " "}, {"Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R} }; - public static volatile int VERSION = 508; + public static volatile int VERSION = 509; public static void registerMaterialRecycling(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) { if (GT_Utility.isStackInvalid(aStack)) return; @@ -147,7 +148,12 @@ public class GT_RecipeRegistrator { public static void registerReverseFluidSmelting(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) { if (aStack == null || aMaterial == null || aMaterial.mSmeltInto.mStandardMoltenFluid == null || !aMaterial.contains(SubTag.SMELTING_TO_FLUID) || (L * aMaterialAmount) / (M * aStack.stackSize) <= 0) return; - RA.addFluidSmelterRecipe(GT_Utility.copyAmount(1, aStack), aByproduct == null ? null : aByproduct.mMaterial.contains(SubTag.NO_SMELTING) || !aByproduct.mMaterial.contains(SubTag.METAL) ? aByproduct.mMaterial.contains(SubTag.FLAMMABLE) ? GT_OreDictUnificator.getDust(Materials.Ash, aByproduct.mAmount / 2) : aByproduct.mMaterial.contains(SubTag.UNBURNABLE) ? GT_OreDictUnificator.getDustOrIngot(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount) : null : GT_OreDictUnificator.getIngotOrDust(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount), aMaterial.mSmeltInto.getMolten((L * aMaterialAmount) / (M * aStack.stackSize)), 10000, (int) Math.max(1, (24 * aMaterialAmount) / M), Math.max(8, (int) Math.sqrt(2 * aMaterial.mSmeltInto.mStandardMoltenFluid.getTemperature()))); + ItemData tData = GT_OreDictUnificator.getItemData(aStack); + boolean tHide = (aMaterial != Materials.Iron)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes); + if(tHide && tData!=null&&tData.hasValidPrefixData()&&tData.mPrefix==OrePrefixes.ingot){ + tHide=false; + } + RA.addFluidSmelterRecipe(GT_Utility.copyAmount(1, aStack), aByproduct == null ? null : aByproduct.mMaterial.contains(SubTag.NO_SMELTING) || !aByproduct.mMaterial.contains(SubTag.METAL) ? aByproduct.mMaterial.contains(SubTag.FLAMMABLE) ? GT_OreDictUnificator.getDust(Materials.Ash, aByproduct.mAmount / 2) : aByproduct.mMaterial.contains(SubTag.UNBURNABLE) ? GT_OreDictUnificator.getDustOrIngot(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount) : null : GT_OreDictUnificator.getIngotOrDust(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount), aMaterial.mSmeltInto.getMolten((L * aMaterialAmount) / (M * aStack.stackSize)), 10000, (int) Math.max(1, (24 * aMaterialAmount) / M), Math.max(8, (int) Math.sqrt(2 * aMaterial.mSmeltInto.mStandardMoltenFluid.getTemperature())), tHide); } /** @@ -161,8 +167,10 @@ public class GT_RecipeRegistrator { return; aMaterialAmount /= aStack.stackSize; if(aMaterial==Materials.Naquadah||aMaterial==Materials.NaquadahEnriched)return; + + boolean tHide = (aMaterial != Materials.Iron)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes); if (aAllowAlloySmelter) - GT_ModHandler.addSmeltingAndAlloySmeltingRecipe(GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount)); + GT_ModHandler.addSmeltingAndAlloySmeltingRecipe(GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount),tHide); else GT_ModHandler.addSmeltingRecipe(GT_Utility.copyAmount(1, aStack), GT_OreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount)); } @@ -176,8 +184,13 @@ public class GT_RecipeRegistrator { aData = new ItemData(aData); if (!aData.hasValidMaterialData()) return; + boolean tIron = false; + for (MaterialStack tMaterial : aData.getAllMaterialStacks()) { + if (tMaterial.mMaterial == Materials.Iron||tMaterial.mMaterial == Materials.Copper || + tMaterial.mMaterial == Materials.WroughtIron||tMaterial.mMaterial == Materials.AnnealedCopper) tIron = true; + if (tMaterial.mMaterial.contains(SubTag.UNBURNABLE)) { tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto; continue; @@ -204,9 +217,9 @@ public class GT_RecipeRegistrator { } aData = new ItemData(aData); - - if (aData.mByProducts.length > 3) for (MaterialStack tMaterial : aData.getAllMaterialStacks()) + if (aData.mByProducts.length > 3) for (MaterialStack tMaterial : aData.getAllMaterialStacks()){ if (tMaterial.mMaterial == Materials.Ash) tMaterial.mAmount = 0; + } aData = new ItemData(aData); @@ -215,8 +228,9 @@ public class GT_RecipeRegistrator { long tAmount = 0; for (MaterialStack tMaterial : aData.getAllMaterialStacks()) tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); - - 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); + + 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), 96, tHide); } public static void registerReverseMacerating(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03, boolean aAllowHammer) { @@ -239,8 +253,8 @@ public class GT_RecipeRegistrator { long tAmount = 0; for (MaterialStack tMaterial : aData.getAllMaterialStacks()) tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); - - RA.addPulveriserRecipe(aStack, new ItemStack[]{GT_OreDictUnificator.getDust(aData.mMaterial), GT_OreDictUnificator.getDust(aData.getByProduct(0)), GT_OreDictUnificator.getDust(aData.getByProduct(1)), GT_OreDictUnificator.getDust(aData.getByProduct(2))}, null, (int) Math.max(16, tAmount / M), 4); + boolean tHide = (aData.mMaterial.mMaterial != Materials.Iron)&&(GT_Mod.gregtechproxy.mHideRecyclingRecipes); + RA.addPulveriserRecipe(aStack, new ItemStack[]{GT_OreDictUnificator.getDust(aData.mMaterial), GT_OreDictUnificator.getDust(aData.getByProduct(0)), GT_OreDictUnificator.getDust(aData.getByProduct(1)), GT_OreDictUnificator.getDust(aData.getByProduct(2))}, null, aData.mMaterial.mMaterial==Materials.Marble ? 1 : (int) Math.max(16, tAmount / M), 4, tHide); if (aAllowHammer) for (MaterialStack tMaterial : aData.getAllMaterialStacks()) if (tMaterial.mMaterial.contains(SubTag.CRYSTAL) && !tMaterial.mMaterial.contains(SubTag.METAL)) { diff --git a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java index 46e2fc57f4..e51c490519 100644 --- a/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Shaped_Recipe.java @@ -75,8 +75,7 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe implements IGT_CraftingRec tStack = GT_Utility.copyAmount(1, tStack); if(GT_Utility.isStackValid(tStack)){ GT_ModHandler.dischargeElectricItem(tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); - tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound())); - } + tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound()));} } } rNBT.setTag("GT.CraftingComponents", tNBT); diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 322252793e..c6d1ab5285 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -5,24 +5,26 @@ import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; import gregtech.api.damagesources.GT_DamageSources; import gregtech.api.enchants.Enchantment_Radioactivity; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; import gregtech.api.enums.SubTag; import gregtech.api.events.BlockScanningEvent; import gregtech.api.interfaces.IDebugableBlock; import gregtech.api.interfaces.IProjectileItem; import gregtech.api.interfaces.tileentity.*; -import gregtech.api.interfaces.metatileentity.*; import gregtech.api.items.GT_EnergyArmor_Item; import gregtech.api.items.GT_Generic_Item; import gregtech.api.net.GT_Packet_Sound; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.threads.GT_Runnable_Sound; +import gregtech.common.GT_Proxy; +import ic2.api.recipe.ICannerBottleRecipeManager; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.RecipeInputOreDict; import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.ICannerBottleRecipeManager; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -51,6 +53,7 @@ import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.MathHelper; +import net.minecraft.world.ChunkPosition; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; @@ -82,8 +85,8 @@ public class GT_Utility { private static final List<FluidContainerData> sFluidContainerList = new ArrayList<FluidContainerData>(); private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new HashMap<GT_ItemStack, FluidContainerData>(); private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new HashMap<GT_ItemStack, Map<Fluid, FluidContainerData>>(); - public static volatile int VERSION = 508; - public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true; + public static volatile int VERSION = 509; + public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false; public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new HashMap<GT_PlayedSound, Integer>(); private static int sBookCount = 0; @@ -334,6 +337,11 @@ public class GT_Utility { tClass.getCanonicalName(); BC_CHECK = true; } catch (Throwable e) {/**/} + try { + Class tClass = cofh.api.energy.IEnergyReceiver.class; + tClass.getCanonicalName(); + RF_CHECK = true; + } catch (Throwable e) {/**/} CHECK_ALL = false; } } @@ -803,25 +811,26 @@ public class GT_Utility { return copyMetaData(Items.feather.getDamage(aStack) + 1, aStack); return null; } + public static synchronized boolean removeIC2BottleRecipe(ItemStack aContainer, ItemStack aInput, Map<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> aRecipeList, ItemStack aOutput){ - if ((isStackInvalid(aInput) && isStackInvalid(aOutput) && isStackInvalid(aContainer)) || aRecipeList == null) return false; - boolean rReturn = false; - Iterator<Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput>> tIterator = aRecipeList.entrySet().iterator(); - aOutput = GT_OreDictUnificator.get(aOutput); - while (tIterator.hasNext()) { - Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> tEntry = tIterator.next(); - if (aInput == null || tEntry.getKey().matches(aContainer, aInput)) { - List<ItemStack> tList = tEntry.getValue().items; - if (tList != null) for (ItemStack tOutput : tList) - if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) { - tIterator.remove(); - rReturn = true; - break; - } - } + if ((isStackInvalid(aInput) && isStackInvalid(aOutput) && isStackInvalid(aContainer)) || aRecipeList == null) return false; + boolean rReturn = false; + Iterator<Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput>> tIterator = aRecipeList.entrySet().iterator(); + aOutput = GT_OreDictUnificator.get(aOutput); + while (tIterator.hasNext()) { + Map.Entry<ic2.api.recipe.ICannerBottleRecipeManager.Input, RecipeOutput> tEntry = tIterator.next(); + if (aInput == null || tEntry.getKey().matches(aContainer, aInput)) { + List<ItemStack> tList = tEntry.getValue().items; + if (tList != null) for (ItemStack tOutput : tList) + if (aOutput == null || areStacksEqual(GT_OreDictUnificator.get(tOutput), aOutput)) { + tIterator.remove(); + rReturn = true; + break; } - return rReturn; } + } + return rReturn; + } public static synchronized boolean removeSimpleIC2MachineRecipe(ItemStack aInput, Map<IRecipeInput, RecipeOutput> aRecipeList, ItemStack aOutput) { if ((isStackInvalid(aInput) && isStackInvalid(aOutput)) || aRecipeList == null) return false; @@ -1036,33 +1045,15 @@ public class GT_Utility { } public static boolean isOpaqueBlock(World aWorld, int aX, int aY, int aZ) { - boolean result; - try{ - result=aWorld.getBlock(aX, aY, aZ).isOpaqueCube(); - } catch (Throwable e) { - result=true; - } - return result; + return aWorld.getBlock(aX, aY, aZ).isOpaqueCube(); } public static boolean isBlockAir(World aWorld, int aX, int aY, int aZ) { - boolean result; - try{ - result=aWorld.getBlock(aX, aY, aZ).isAir(aWorld, aX, aY, aZ); - } catch (Throwable e) { - result=false; - } - return result; + return aWorld.getBlock(aX, aY, aZ).isAir(aWorld, aX, aY, aZ); } public static boolean hasBlockHitBox(World aWorld, int aX, int aY, int aZ) { - boolean result; - try{ - result=aWorld.getBlock(aX, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) != null; - } catch (Throwable e) { - result=false; - } - return result; + return aWorld.getBlock(aX, aY, aZ).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ) != null; } public static void setCoordsOnFire(World aWorld, int aX, int aY, int aZ, boolean aReplaceCenter) { @@ -1331,9 +1322,6 @@ public class GT_Utility { return loadItem(aNBT.getCompoundTag(aTagName)); } - /** - * Loads an ItemStack properly. - */ public static FluidStack loadFluid(NBTTagCompound aNBT, String aTagName) { return loadFluid(aNBT.getCompoundTag(aTagName)); } @@ -1355,7 +1343,7 @@ public class GT_Utility { } /** - * Loads an ItemStack properly. + * Loads an FluidStack properly. */ public static FluidStack loadFluid(NBTTagCompound aNBT) { if (aNBT == null) return null; @@ -1516,6 +1504,47 @@ public class GT_Utility { return false; } + public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) { + + + Random tRandom = new Random((aWorld.getSeed() + (aX / 96) + (7 * (aZ / 96)))); + int oil = tRandom.nextInt(3); + double amount = tRandom.nextInt(50) + tRandom.nextDouble(); + oil = tRandom.nextInt(4); +// System.out.println("Oil: "+(aX/96)+" "+(aZ/96)+" "+oil+" "+amount); +// amount = 40; + Fluid tFluid = null; + switch (oil) { + case 0: + tFluid = Materials.NatruralGas.mGas; + break; + case 1: + tFluid = Materials.OilLight.mFluid; + break; + case 2: + tFluid = Materials.OilMedium.mFluid; + break; + case 3: + tFluid = Materials.OilHeavy.mFluid; + break; + default: + tFluid = Materials.Oil.mFluid; + } + int tAmount = (int) (Math.pow(amount, 5) / 100); + ChunkPosition tPos = new ChunkPosition(aX/16, 1, aZ/16); + if(GT_Proxy.chunkData.containsKey(tPos)){ + int[] tInts = GT_Proxy.chunkData.get(tPos); + if(tInts.length>0){ + if(tInts[0]>=0){tAmount = tInts[0];} + } + GT_Proxy.chunkData.remove(tPos); + } + tAmount = tAmount - 5; + GT_Proxy.chunkData.put(tPos, new int[]{tAmount}); + + return new FluidStack(tFluid, tAmount); + } + 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; @@ -1703,6 +1732,11 @@ public class GT_Utility { if (D1) e.printStackTrace(GT_Log.err); } } + if (aPlayer.capabilities.isCreativeMode&>_Values.D1) { + FluidStack tFluid = getUndergroundOil(aWorld, aX, aZ); + tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName()); + } + try { if (tBlock instanceof IDebugableBlock) { rEUAmount += 500; @@ -1882,6 +1916,33 @@ public class GT_Utility { return tNBT.getString("author"); } + public static void setProspectionData(ItemStack aStack, int aX, int aY, int aZ, int aDim, FluidStack aFluid, String[] aOres) { + NBTTagCompound tNBT = getNBT(aStack); + String tData = aX + "," + aY + "," + aZ + "," + aDim + "," + (aFluid.amount / 5000) + "," + aFluid.getLocalizedName() + ","; + for (String tString : aOres) { + tData += tString + ","; + } + tNBT.setString("prospection", tData); + setNBT(aStack, tNBT); + } + + public static void convertProspectionData(ItemStack aStack) { + NBTTagCompound tNBT = getNBT(aStack); + String tData = tNBT.getString("prospection"); + String[] tDataArray = tData.split(","); + if (tDataArray.length > 6) { + tNBT.setString("author", "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2] + " Dim: " + tDataArray[3]); + NBTTagList tNBTList = new NBTTagList(); + String tOres = " Prospected Ores: "; + for (int i = 6; tDataArray.length > i; i++) { + tOres += (tDataArray[i] + " "); + } + tNBTList.appendTag(new NBTTagString("Prospection Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres)); + tNBT.setTag("pages", tNBTList); + } + setNBT(aStack, tNBT); + } + public static void addEnchantment(ItemStack aStack, Enchantment aEnchantment, int aLevel) { NBTTagCompound tNBT = getNBT(aStack), tEnchantmentTag; if (!tNBT.hasKey("ench", 9)) tNBT.setTag("ench", new NBTTagList()); @@ -1988,4 +2049,4 @@ public class GT_Utility { } } -} +}
\ No newline at end of file |