diff options
author | Alkalus <Draknyte1@hotmail.com> | 2020-03-31 12:33:16 +0100 |
---|---|---|
committer | Alkalus <Draknyte1@hotmail.com> | 2020-03-31 12:33:16 +0100 |
commit | 0908735fc15396f8313d7643e952c1f9ce124d53 (patch) | |
tree | 11e2deb87858c425b49a7c482976df5a3c9108b0 /src/Java | |
parent | d53cc950a01765cb8bc422c6f79661dd05c760ef (diff) | |
download | GT5-Unofficial-0908735fc15396f8313d7643e952c1f9ce124d53.tar.gz GT5-Unofficial-0908735fc15396f8313d7643e952c1f9ce124d53.tar.bz2 GT5-Unofficial-0908735fc15396f8313d7643e952c1f9ce124d53.zip |
+ Added Carbon Disulfide.
+ Added Hydrogen Sulfide if it doesn't exist.
+ Added Sodium Ethoxide.
+ Added Potassium Hydroxide.
+ Added Sodium Ethyl Xanthate.
+ Added Potassium Ethyl Xanthate.
+ Added Base work for Froth Flotation Multi.
Diffstat (limited to 'src/Java')
7 files changed, 730 insertions, 14 deletions
diff --git a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java index 903730f767..0111a5fa4d 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java +++ b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java @@ -19,6 +19,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; public class CommandEnableDebugWhileRunning implements ICommand @@ -33,14 +36,14 @@ public class CommandEnableDebugWhileRunning implements ICommand @Override public int compareTo(final Object o){ if (o instanceof Comparable<?>) { - @SuppressWarnings("unchecked") - Comparable<ICommand> a = (Comparable<ICommand>) o; - if (a.equals(this)) { - return 0; - } - else { - return -1; - } + @SuppressWarnings("unchecked") + Comparable<ICommand> a = (Comparable<ICommand>) o; + if (a.equals(this)) { + return 0; + } + else { + return -1; + } } return -1; } @@ -106,7 +109,42 @@ public class CommandEnableDebugWhileRunning implements ICommand String aItemDisplayName = ItemUtils.getItemName(aHeldItem); String aItemUnlocalName = ItemUtils.getUnlocalizedItemName(aHeldItem); String aNbtString = tryIterateNBTData(aHeldItem); - PlayerUtils.messagePlayer(P, "["+aItemUnlocalName+"]"+"["+aItemDisplayName+"] "+aNbtString); + AutoMap<String> aOreDictNames = new AutoMap<String>(); + + int[] aOreIDs = OreDictionary.getOreIDs(aHeldItem); + for (int id : aOreIDs) { + String aOreNameFromID = OreDictionary.getOreName(id); + if (aOreNameFromID != null && aOreNameFromID.length() > 0 && !aOreNameFromID.equals("Unknown")) { + aOreDictNames.add(aOreNameFromID); + } + } + + String aOreDictData = ""; + if (!aOreDictNames.isEmpty()) { + for (String tag : aOreDictNames) { + aOreDictData += (tag+","); + } + if (aOreDictData.endsWith(",")) { + aOreDictData = aOreDictData.substring(0, aOreDictData.length()-2); + } + } + + String aFluidContainerData = ""; + FluidStack aHeldItemFluid = FluidContainerRegistry.getFluidForFilledItem(aHeldItem); + if (aHeldItemFluid != null) { + aFluidContainerData = "["+aHeldItemFluid.getUnlocalizedName()+"]["+aHeldItemFluid.getLocalizedName()+"]"; + } + + PlayerUtils.messagePlayer(P, "["+aItemUnlocalName+"]"+"["+aItemDisplayName+"] "); + if (aFluidContainerData.length() > 0) { + PlayerUtils.messagePlayer(P, ""+aFluidContainerData); + } + if (!aOreDictNames.isEmpty()) { + PlayerUtils.messagePlayer(P, ""+aOreDictData); + } + if (aNbtString.length() > 0) { + PlayerUtils.messagePlayer(P, ""+aNbtString); + } } else { PlayerUtils.messagePlayer(P, "No item held."); @@ -146,7 +184,7 @@ public class CommandEnableDebugWhileRunning implements ICommand public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost){ return true; } - + public static String tryIterateNBTData(ItemStack aStack) { try { AutoMap<String> aItemDataTags = new AutoMap<String>(); diff --git a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java index ff55326031..bdcf4f09d9 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java @@ -3,6 +3,7 @@ package gtPlusPlus.core.item.chemistry; import static gtPlusPlus.core.lib.CORE.GTNH; import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; import gregtech.api.enums.TextureSet; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.minecraft.ItemPackage; @@ -19,6 +20,7 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.plugin.agrichem.BioRecipes; import gtPlusPlus.plugin.agrichem.block.AgrichemFluids; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -37,6 +39,7 @@ public class GenericChem extends ItemPackage { private static boolean usingGregtechNitricOxide = false; private static boolean usingGregtechNitrogenDioxide = false; + private static boolean usingGregtechHydricSulfur = false; /** * Materials @@ -94,6 +97,8 @@ public class GenericChem extends ItemPackage { public static Fluid Lithium_Peroxide; public static Fluid Nitric_Oxide; public static Fluid Nitrogen_Dioxide; + public static Fluid Carbon_Disulfide; + public static Fluid Hydrogen_Sulfide; /** * Items @@ -115,6 +120,11 @@ public class GenericChem extends ItemPackage { public static ItemStack mMillingBallAlumina; public static ItemStack mMillingBallSoapstone; + + public static ItemStack mSodiumEthoxide; + public static ItemStack mSodiumEthylXanthate; + public static ItemStack mPotassiumEthylXanthate; + public static ItemStack mPotassiumHydroxide; @@ -149,6 +159,10 @@ public class GenericChem extends ItemPackage { mPinkCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 6, 1); mMillingBallAlumina = ItemUtils.simpleMetaStack(mGenericChemItem1, 7, 1); mMillingBallSoapstone = ItemUtils.simpleMetaStack(mGenericChemItem1, 8, 1); + mSodiumEthoxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 9, 1); + mSodiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 10, 1); + mPotassiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 11, 1); + mPotassiumHydroxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 12, 1); } @@ -163,6 +177,10 @@ public class GenericChem extends ItemPackage { ItemUtils.addItemToOreDictionary(mPinkCatalyst, "catalystPlatinumRhodium"); ItemUtils.addItemToOreDictionary(mMillingBallAlumina, "millingballAlumina"); ItemUtils.addItemToOreDictionary(mMillingBallSoapstone, "millingballSoapstone"); + ItemUtils.addItemToOreDictionary(mSodiumEthoxide, "dustSodiumEthoxide"); + ItemUtils.addItemToOreDictionary(mSodiumEthylXanthate, "dustSodiumEthylXanthate"); + ItemUtils.addItemToOreDictionary(mPotassiumEthylXanthate, "dustPotassiumEthylXanthate"); + ItemUtils.addItemToOreDictionary(mPotassiumHydroxide, "dustPotassiumHydroxide"); } @@ -241,8 +259,15 @@ public class GenericChem extends ItemPackage { //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); + Carbon_Disulfide = FluidUtils.generateFluidNoPrefix("CarbonDisulfide", "Carbon Disulfide", 350, new short[]{175, 175, 175, 100}); - + if (FluidRegistry.isFluidRegistered("fluid.liquid_hydricsulfur") || MaterialUtils.doesMaterialExist("HydricSulfide")) { + usingGregtechHydricSulfur = true; + } + else { + Hydrogen_Sulfide = FluidUtils.generateFluidNoPrefix("HydrogenSulfide", "Hydrogen Sulfide", 446, new short[]{240, 130, 30, 100}); + } + } @Override @@ -281,17 +306,153 @@ public class GenericChem extends ItemPackage { if (!usingGregtechNitrogenDioxide) { recipeNitrogenDioxide(); } + if (!usingGregtechHydricSulfur) { + recipeHydricSulfur(); + } + else { + Hydrogen_Sulfide = FluidRegistry.getFluid("fluid.liquid_hydricsulfur"); + } // Add recipes if we are not using GT's fluid. if (!FluidRegistry.isFluidRegistered("hydrochloricacid_gt5u")) { recipeHydrochloricAcid(); } + + recipeCarbonDisulfide(); + recipeEthylXanthates(); + recipePotassiumHydroxide(); + registerFuels(); return true; } + private void recipePotassiumHydroxide() { + //Ca(OH)2 + K2CO3 → CaCO3 + 2 KOH + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(18), + ELEMENT.getInstance().POTASSIUM.getDust(4), + ELEMENT.getInstance().CARBON.getDust(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumHydroxide", 2), + }, + new FluidStack[] { + FluidUtils.getFluidStack("oxygen", 6000), + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumCarbonate", 2), + ItemUtils.getSimpleStack(mPotassiumHydroxide, 4) + + }, + new FluidStack[] { + + }, + 20 *60 * 2, + 120, + 2); + + } + + + private void recipeEthylXanthates() { + + //Potassium ethyl xanthate - CH3CH2OH + CS2 + KOH → CH3CH2OCS2K + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(17), + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumHydroxide", 2), + }, + new FluidStack[] { + FluidUtils.getFluidStack(BioRecipes.mEthanol, 1000), + FluidUtils.getFluidStack(Carbon_Disulfide, 1000), + }, + new ItemStack[] { + ItemUtils.getSimpleStack(mPotassiumEthylXanthate, 1) + }, + new FluidStack[] { + FluidUtils.getWater(1000) + }, + 20 *60, + 120, + 2); + + //Sodium ethyl xanthate - CH3CH2ONa + CS2 → CH3CH2OCS2Na + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(17), + ItemUtils.getSimpleStack(mSodiumEthoxide, 1) + }, + new FluidStack[] { + FluidUtils.getFluidStack(Carbon_Disulfide, 1000), + }, + new ItemStack[] { + ItemUtils.getSimpleStack(mPotassiumEthylXanthate, 1) + }, + new FluidStack[] { + + }, + 20 *60, + 120, + 2); + + } + + + private void recipeHydricSulfur() { + + ItemStack aCellHydricSulfide = ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenSulfide", 1); + GT_Values.RA.addChemicalRecipe( ELEMENT.getInstance().SULFUR.getDust(1), GT_Utility.getIntegratedCircuit(1), ELEMENT.getInstance().HYDROGEN.getFluid(2000), FluidUtils.getFluidStack(Hydrogen_Sulfide, 3000), GT_Values.NI, 60, 8); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(ELEMENT.getInstance().SULFUR.getDust(1), CI.emptyCells(3), ELEMENT.getInstance().HYDROGEN.getFluid(2000), GT_Values.NF, ItemUtils.getSimpleStack(aCellHydricSulfide, 3), GT_Values.NI, 60, 8); + + } + + + private void recipeCarbonDisulfide() { + + CORE.RA.addBlastRecipe( + new ItemStack[] { + CI.getNumberedCircuit(20), + ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 8), + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 16) + }, + new FluidStack[] { + + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustDarkAsh", 1) + }, + new FluidStack[] { + FluidUtils.getFluidStack(Carbon_Disulfide, 4000) + }, + 20 *60 * 10, + 30, + 1500); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(20), + ItemUtils.getSimpleStack(mBrownCatalyst, 0), + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 4) + }, + new FluidStack[] { + FluidUtils.getFluidStack(CoalTar.Coal_Gas, 1000), + }, + new ItemStack[] { + + }, + new FluidStack[] { + FluidUtils.getFluidStack(Carbon_Disulfide, 2000), + FluidUtils.getFluidStack(Hydrogen_Sulfide, 4000) + }, + 20 *60 * 5, + 30, + 2); + + + } + + private static void registerFuels() { // Burnables diff --git a/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java b/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java index 7fb5f207f6..0863faa38d 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java @@ -19,7 +19,7 @@ public class ItemGenericChemBase extends Item { final protected IIcon base[]; - final private int aMetaSize = 9; + final private int aMetaSize = 13; /* * 0 - Red Metal Catalyst //FeCu @@ -31,6 +31,10 @@ public class ItemGenericChemBase extends Item { * 6 - Pink Metal Catalyst //PtRh * 7 - Alumina Grinding Ball * 8 - Soapstone Grinding Ball + * 9 - Sodium Ethoxide // 2 Sodium + 1 Ethanol | 2 C2H5OH + 2 Na → 2 C2H5ONa + H2 + * 10 - Sodium Ethyl Xanthate //CH3CH2ONa + CS2 → CH3CH2OCS2Na + * 11 - Potassium Ethyl Xanthate //CH3CH2OH + CS2 + KOH → CH3CH2OCS2K + H2O + * 12 - Potassium Hydroxide // KOH */ public ItemGenericChemBase() { diff --git a/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java b/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java index 541f02cccd..f6a59e3900 100644 --- a/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java +++ b/src/Java/gtPlusPlus/plugin/agrichem/BioRecipes.java @@ -61,7 +61,7 @@ public class BioRecipes { private static Fluid mCarbonDioxide; private static Fluid mCarbonMonoxide; private static Fluid mEthylene; - private static Fluid mEthanol; + public static Fluid mEthanol; private static Fluid mChlorine; private static Fluid mHydrogen; private static Fluid mDilutedSulfuricAcid; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java index be180bf4e9..46201e9d81 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java @@ -47,7 +47,7 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Structural Solar Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Salt Containment Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Thermally Insulated Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Flotation Cell Casings"); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused @@ -88,6 +88,8 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs return TexturesGtBlock.Casing_Material_Stellite.getIcon(); case 8: return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + case 9: + return TexturesGtBlock.TEXTURE_CASING_FLOTATION.getIcon(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 7903da8c6d..cd32d15c3a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -281,6 +281,7 @@ public class TexturesGtBlock { public static final CustomIcon TEXTURE_CASING_ADVANCED_VOLCNUS = new CustomIcon("TileEntities/MACHINE_CASING_ADVANCED_VOLCANUS"); public static final CustomIcon TEXTURE_CASING_ROCKETDYNE = new CustomIcon("TileEntities/MACHINE_CASING_ROCKETDYNE"); public static final CustomIcon TEXTURE_CASING_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_GRINDING_FACTORY"); + public static final CustomIcon TEXTURE_CASING_FLOTATION = new CustomIcon("TileEntities/MACHINE_CASING_FLOTATION"); // Custom Pipes public static final CustomIcon TEXTURE_PIPE_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_PIPE_T1"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationPond.java new file mode 100644 index 0000000000..2d2aa4ab53 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationPond.java @@ -0,0 +1,510 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; +import ic2.core.init.BlocksItems; +import ic2.core.init.InternalName; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_FrothFlotationPond extends GregtechMeta_MultiBlockBase { + + private int mLevel = -1; + + public GregtechMTE_FrothFlotationPond(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTE_FrothFlotationPond(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMTE_FrothFlotationPond(this.mName); + } + + @Override + public String getMachineType() { + return "Algae Pond"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Grows Algae!", + "Controller Block for the Algae Farm", + "Provide compost to boost production by one tier", + "Size: 9x3x9 [WxHxL] (open)", + "X X", + "X X", + "XXXXXXXXX", + "Machine Casings (all bottom layer)", + "Sterile Farm Casings (rest)", + "Controller (front centered)", + "All hatches must be on the bottom layer", + "All hulls must be the same tier, this dictates machine speed", + "Does not require power or maintenance", + "1x Output Bus", + "1x Input Bus (optional)", + "1x Input Hatch (fill with water)", + }; + } + + @Override + public String getSound() { + return GregTech_API.sSoundList.get(Integer.valueOf(207)); + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + + int aID = TAE.getIndexFromPage(1, 15); + if (mLevel > -1) { + aID = mLevel; + } + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID]}; + } + + @Override + public boolean hasSlotInGUI() { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public int getMaxParallelRecipes() { + return 2; + } + + @Override + public int getEuDiscountForParallelism() { + return 0; + } + + @Override + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + + this.mLevel = 0; + + + // Get Facing direction + int mCurrentDirectionX; + int mCurrentDirectionZ; + + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + // Get Expected Tier +// Block aCasingBlock = aBaseMetaTileEntity.getBlockAtSide((byte) 3); +// int aCasingMeta = aBaseMetaTileEntity.getMetaIDAtSide((byte) 3); +// +// // Bad Casings +// if ((aCasingBlock != GregTech_API.sBlockCasings1) || aCasingMeta > 9) { +// Logger.INFO("is false"); +// return false; +// } +// else { + mLevel = this.getCasingTier(); + //} + int aID = TAE.getIndexFromPage(1, 15); + int tAmount = 0; + check : for (int i = mOffsetX_Lower; i <= mOffsetX_Upper; ++i) { + for (int j = mOffsetZ_Lower; j <= mOffsetZ_Upper; ++j) { + for (int h = -1; h < 2; ++h) { + if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + + Logger.INFO("X: " + i + " | Z: " + j+" | Tier: "+aID); + if (h == -1 && tTileEntity != null && addToMachineList(tTileEntity, aID)) { + continue; + } + else if (h != -1 && tTileEntity != null) { + Logger.INFO("Found hatch in wrong place, expected casing."); + return false; + } + + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + + if ((h >= 0) && (tBlock == ModBlocks.blockCasings2Misc) && (tMeta == 15) ) { + ++tAmount; + } + else if ((h == -1) && (tBlock == GregTech_API.sBlockCasings1) && (tMeta == mLevel) ) { + ++tAmount; + } + else if ((h == -1) && (tBlock == GregTech_API.sBlockCasings1) && (tMeta != mLevel) ) { + Logger.INFO("Found wrong tiered casing."); + return false; + } + else { + if ((i != mOffsetX_Lower && j != mOffsetZ_Lower && i != mOffsetX_Upper + && j != mOffsetZ_Upper) && (h == 0 || h == 1)) { + continue; + } else { + if (tBlock.getLocalizedName().contains("gt.blockmachines") || tBlock == Blocks.water + || tBlock == Blocks.flowing_water + || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + continue; + + } else { + Logger.INFO("[x] Did not form - Found: " + tBlock.getLocalizedName() + " | " + + tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(), + aBaseMetaTileEntity.getXCoord() + i, + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord() + j) + + " | Special Meta: " + + (tTileEntity == null ? "0" : tTileEntity.getMetaTileID())); + Logger.INFO("[x] Did not form - Found: " + + (aBaseMetaTileEntity.getXCoord() + xDir + i) + " | " + + aBaseMetaTileEntity.getYCoord() + " | " + + (aBaseMetaTileEntity.getZCoord() + zDir + j)); + break check; + } + } + + } + + } + } + } + } + if ((tAmount >= 64)) { + Logger.INFO("Made structure."); + this.getBaseMetaTileEntity().getWorld().markBlockForUpdate(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); + } else { + Logger.INFO("Did not make structure."); + } + return (tAmount >= 64); + } + + public boolean checkForWater() { + + // Get Facing direction + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int mCurrentDirectionX; + int mCurrentDirectionZ; + int mOffsetX_Lower = 0; + int mOffsetX_Upper = 0; + int mOffsetZ_Lower = 0; + int mOffsetZ_Upper = 0; + + mCurrentDirectionX = 4; + mCurrentDirectionZ = 4; + + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; + + // if (aBaseMetaTileEntity.fac) + + final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX + * mCurrentDirectionX; + final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ + * mCurrentDirectionZ; + + int tAmount = 0; + for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) { + for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) { + for (int h = 0; h < 2; h++) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + // byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + if (this.getStoredFluids() != null) { + for (FluidStack stored : this.getStoredFluids()) { + if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) { + if (stored.amount >= 1000) { + // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); + stored.amount -= 1000; + Block fluidUsed = Blocks.water; + aBaseMetaTileEntity.getWorld().setBlock( + aBaseMetaTileEntity.getXCoord() + xDir + i, + aBaseMetaTileEntity.getYCoord() + h, + aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed); + + } + } + } + } + } + tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { + ++tAmount; + // Logger.INFO("Found Water"); + } + } + } + } + + boolean isValidWater = tAmount >= 60; + + if (isValidWater) { + Logger.INFO("Filled structure."); + return true; + } + else { + return false; + } + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + this.fixAllMaintenanceIssue(); + // Silly Client Syncing + if (aBaseMetaTileEntity.isClientSide()) { + this.mLevel = getCasingTier(); + } + + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + + if (this.mLevel < 0) { + Logger.INFO("Bad Tier."); + return false; + } + + if (!checkForWater()) { + Logger.INFO("Not enough Water."); + return false; + } + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + Logger.INFO("Running checkRecipeGeneric(0)"); + + GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); + + this.mLastRecipe = tRecipe; + + if (tRecipe == null) { + return false; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + return false; + } + if (tRecipe.mInputs.length > 0) { + for (ItemStack aInputToConsume : tRecipe.mInputs) { + this.depleteInput(aInputToConsume); + } + } + + + // -- Try not to fail after this point - inputs have already been consumed! -- + + + this.mMaxProgresstime = (int)(tRecipe.mDuration); + this.mEUt = 0; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + Logger.INFO("Recipe time: "+this.mMaxProgresstime); + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + // Collect fluid outputs + FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length]; + for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) { + if (tRecipe.getFluidOutput(h) != null) { + tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); + tOutputFluids[h].amount *= aMaxParallelRecipes; + } + } + + // Collect output item types + ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + if (tRecipe.getOutput(h) != null) { + tOutputItems[h] = tRecipe.getOutput(h).copy(); + tOutputItems[h].stackSize = 0; + } + } + + // Set output item stack sizes (taking output chance into account) + for (int f = 0; f < tOutputItems.length; f++) { + if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { + for (int g = 0; g < aMaxParallelRecipes; g++) { + if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) + tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + + tOutputItems = removeNulls(tOutputItems); + + // Sanitize item stack size, splitting any stacks greater than max stack size + List<ItemStack> splitStacks = new ArrayList<ItemStack>(); + for (ItemStack tItem : tOutputItems) { + while (tItem.getMaxStackSize() < tItem.stackSize) { + ItemStack tmp = tItem.copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + splitStacks.add(tmp); + } + } + + if (splitStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[splitStacks.size()]; + tmp = splitStacks.toArray(tmp); + tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); + } + + // Strip empty stacks + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOutputItems) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + + // Commit outputs + this.mOutputItems = tOutputItems; + this.mOutputFluids = tOutputFluids; + updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + Logger.INFO("GOOD RETURN - 1"); + return true; + + } + + private boolean isUsingCompost(ItemStack[] aItemInputs) { + ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1); + for (ItemStack i : aItemInputs) { + if (GT_Utility.areStacksEqual(aCompost, i)) { + if (i.stackSize >= 8) { + return true; + } + else { + continue; + } + } + } + return false; + } + + + private final int getCasingTier() { + if (this == null || this.getBaseMetaTileEntity().getWorld() == null) { + return 0; + } + try { + Block aInitStructureCheck; + int aInitStructureCheckMeta; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir); + aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir); + if (aInitStructureCheck == GregTech_API.sBlockCasings1) { + return aInitStructureCheckMeta; + } + return 0; + } + catch (Throwable t) { + t.printStackTrace(); + return 0; + } + } + + + +} |