diff options
Diffstat (limited to 'src')
13 files changed, 991 insertions, 25 deletions
diff --git a/src/Java/miscutil/MiscUtils.java b/src/Java/miscutil/MiscUtils.java index 7291d03fed..9281429a91 100644 --- a/src/Java/miscutil/MiscUtils.java +++ b/src/Java/miscutil/MiscUtils.java @@ -18,7 +18,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; -@Mod(modid=CORE.MODID, name="Misc. Utils", version=CORE.VERSION, dependencies="required-after:Forge; after:IC2; after:gregtech; after:Railcraft; after:CompactWindmills; after:ForbiddenMagic; after:MorePlanet; after:PneumaticCraft; after:ExtraUtilities; after:Thaumcraft; after:rftools; after:simplyjetpacks; after:BigReactors; after:EnderIO;") +@Mod(modid=CORE.MODID, name="Misc. Utils", version=CORE.VERSION, dependencies="required-after:Forge; after:IC2; after:gregtech; after:Growthcraft; after:Railcraft; after:CompactWindmills; after:ForbiddenMagic; after:MorePlanet; after:PneumaticCraft; after:ExtraUtilities; after:Thaumcraft; after:rftools; after:simplyjetpacks; after:BigReactors; after:EnderIO;") public class MiscUtils implements ActionListener { diff --git a/src/Java/miscutil/core/block/general/fluids/FluidRegistryHandler.java b/src/Java/miscutil/core/block/general/fluids/FluidRegistryHandler.java index bf03203247..09f7236e33 100644 --- a/src/Java/miscutil/core/block/general/fluids/FluidRegistryHandler.java +++ b/src/Java/miscutil/core/block/general/fluids/FluidRegistryHandler.java @@ -40,8 +40,9 @@ public class FluidRegistryHandler { fluidJackDaniels.setTemperature(420); fluidJackDaniels.setViscosity(750); fluidJackDaniels.setGaseous(true); + fluidJackDaniels.setUnlocalizedName("fluidJackDaniels"); FluidRegistry.registerFluid(fluidJackDaniels); - blockFluidJackDaniels = new BlockFluidJackDaniels(fluidJackDaniels, Material.water).setBlockName("fluidJackDaniels"); + blockFluidJackDaniels = new BlockFluidJackDaniels(fluidJackDaniels, Material.water).setBlockName("fluidBlockJackDaniels"); GameRegistry.registerBlock(blockFluidJackDaniels, CORE.MODID + "_" + blockFluidJackDaniels.getUnlocalizedName().substring(5)); fluidJackDaniels.setUnlocalizedName(blockFluidJackDaniels.getUnlocalizedName()); } diff --git a/src/Java/miscutil/core/common/CommonProxy.java b/src/Java/miscutil/core/common/CommonProxy.java index 499ea28eb6..ac1aa32801 100644 --- a/src/Java/miscutil/core/common/CommonProxy.java +++ b/src/Java/miscutil/core/common/CommonProxy.java @@ -5,6 +5,7 @@ import miscutil.core.block.ModBlocks; import miscutil.core.creative.AddToCreativeTab; import miscutil.core.gui.ModGUI; import miscutil.core.handler.COMPAT_HANDLER; +import miscutil.core.handler.COMPAT_IntermodStaging; import miscutil.core.handler.events.PickaxeBlockBreakEventHandler; import miscutil.core.item.ModItems; import miscutil.core.lib.CORE; @@ -35,13 +36,15 @@ public class CommonProxy { Utils.LOG_WARNING("Development mode not set."); } AddToCreativeTab.initialiseTabs(); + //Apparently I should do this here. Might put it in Init for a test. + //Growthcraft_Handler.run(); } public void init(FMLInitializationEvent e) { //Debug Loading if (CORE.DEBUG){ DEBUG_INIT.registerHandlers(); - } + } ModItems.init(); ModBlocks.init(); MinecraftForge.EVENT_BUS.register(new PickaxeBlockBreakEventHandler()); @@ -50,6 +53,7 @@ public class CommonProxy { COMPAT_HANDLER.registerMyModsOreDictEntries(); COMPAT_HANDLER.registerGregtechMachines(); COMPAT_HANDLER.intermodOreDictionarySupport(); + COMPAT_IntermodStaging.load(); } public void postInit(FMLPostInitializationEvent e) { diff --git a/src/Java/miscutil/core/common/compat/COMPAT_IC2.java b/src/Java/miscutil/core/common/compat/COMPAT_IC2.java index c0b52c5250..8b25360f1f 100644 --- a/src/Java/miscutil/core/common/compat/COMPAT_IC2.java +++ b/src/Java/miscutil/core/common/compat/COMPAT_IC2.java @@ -1,7 +1,6 @@ package miscutil.core.common.compat; -import static miscutil.core.handler.COMPAT_HANDLER.AddRecipeQueue; import static miscutil.core.handler.COMPAT_HANDLER.RemoveRecipeQueue; import miscutil.core.recipe.ShapedRecipeObject; import miscutil.core.util.item.UtilsItems; @@ -43,11 +42,11 @@ public class COMPAT_IC2 { RemoveRecipeQueue.add("IC2:itemCable:6"); RemoveRecipeQueue.add("IC2:itemCable:10"); RemoveRecipeQueue.add("IC2:itemCable:13"); - RemoveRecipeQueue.add(itemCropnalyzer); - RemoveRecipeQueue.add(itemSolarHelmet); + //RemoveRecipeQueue.add(itemCropnalyzer); + //RemoveRecipeQueue.add(itemSolarHelmet); - AddRecipeQueue.add(Cropnalyzer); - AddRecipeQueue.add(SolarHelmet); + //AddRecipeQueue.add(Cropnalyzer); + //AddRecipeQueue.add(SolarHelmet); } } diff --git a/src/Java/miscutil/core/handler/COMPAT_IntermodStaging.java b/src/Java/miscutil/core/handler/COMPAT_IntermodStaging.java new file mode 100644 index 0000000000..b3c7934c9a --- /dev/null +++ b/src/Java/miscutil/core/handler/COMPAT_IntermodStaging.java @@ -0,0 +1,18 @@ +package miscutil.core.handler; + +import growthcraft.core.GrowthCraftCore; +import miscutil.core.intermod.growthcraft.Growthcraft_Handler; +import miscutil.core.lib.LoadedMods; + +public class COMPAT_IntermodStaging { + + public static void load(){ + if (LoadedMods.Growthcraft || GrowthCraftCore.instance != null){ + Growthcraft_Handler.run(); + } + + + } + + +} diff --git a/src/Java/miscutil/core/intermod/growthcraft/Growthcraft_Handler.java b/src/Java/miscutil/core/intermod/growthcraft/Growthcraft_Handler.java new file mode 100644 index 0000000000..96912df9bc --- /dev/null +++ b/src/Java/miscutil/core/intermod/growthcraft/Growthcraft_Handler.java @@ -0,0 +1,61 @@ +package miscutil.core.intermod.growthcraft; + +import growthcraft.api.cellar.Booze; +import growthcraft.api.cellar.CellarRegistry; +import growthcraft.cellar.block.BlockFluidBooze; +import growthcraft.cellar.item.ItemBoozeBottle; +import growthcraft.cellar.item.ItemBoozeBucketDEPRECATED; +import growthcraft.cellar.item.ItemBucketBooze; +import growthcraft.cellar.utils.BoozeRegistryHelper; +import growthcraft.hops.GrowthCraftHops; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.potion.Potion; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import cpw.mods.fml.common.registry.GameRegistry; + +public class Growthcraft_Handler { + + public static BlockFluidBooze[] jackDanielsWhiskeyFluids; + public static Item jackDaniels; + public static Item jackDanielsSeeds; + public static Item jackDanielsWhiskey; + public static Item jackDanielsWhiskeyBucket_deprecated; + public static ItemBucketBooze[] jackDanielsWhiskeyBuckets; + public static Fluid[] jackDanielsWhiskeyBooze; + //private static int internalColour = FluidRegistry.getFluid("fluidJackDaniels").getColor(); + private static int internalColour = 0000000; + + //Run me during Pre-Init + public static void run(){ + start(); + } + + private static void start(){ + jackDaniels = GrowthCraftHops.hops; + jackDanielsSeeds = GrowthCraftHops.hopSeeds; + + jackDanielsWhiskeyBooze = new Booze[5]; + jackDanielsWhiskeyFluids = new BlockFluidBooze[jackDanielsWhiskeyBooze.length]; + jackDanielsWhiskeyBuckets = new ItemBucketBooze[jackDanielsWhiskeyBooze.length]; + BoozeRegistryHelper.initializeBooze(jackDanielsWhiskeyBooze, jackDanielsWhiskeyFluids, jackDanielsWhiskeyBuckets, "grc.jackDanielsWhiskey", internalColour); + + jackDanielsWhiskey = new ItemBoozeBottle(6, -0.5F, jackDanielsWhiskeyBooze).setColor(internalColour).setTipsy(0.7F, 900).setPotionEffects(new int[] { Potion.digSpeed.id }, new int[] { 3600 }); + jackDanielsWhiskeyBucket_deprecated = new ItemBoozeBucketDEPRECATED(jackDanielsWhiskeyBooze).setColor(internalColour); + + + //GameRegistry.registerItem(jackDaniels, "grc.jackDaniels"); + //GameRegistry.registerItem(jackDanielsSeeds, "grc.jackDanielsSeeds"); + GameRegistry.registerItem(jackDanielsWhiskey, "grc.jackDanielsWhiskey"); + GameRegistry.registerItem(jackDanielsWhiskeyBucket_deprecated, "grc.jackDanielsWhiskey_bucket"); + + BoozeRegistryHelper.registerBooze(jackDanielsWhiskeyBooze, jackDanielsWhiskeyFluids, jackDanielsWhiskeyBuckets, jackDanielsWhiskey, "grc.jackDanielsWhiskey", jackDanielsWhiskeyBucket_deprecated); + + CellarRegistry.instance().brew().addBrewing(FluidRegistry.WATER, Items.wheat, jackDanielsWhiskeyBooze[4], 200, 60, 0.4F); + CellarRegistry.instance().brew().addBrewing(jackDanielsWhiskeyBooze[4], jackDaniels, jackDanielsWhiskeyBooze[0], 350, 60, 0.1F); + + + } + +} diff --git a/src/Java/miscutil/core/intermod/psychedelicraft/Psychedelicraft_Booze.java b/src/Java/miscutil/core/intermod/psychedelicraft/Psychedelicraft_Booze.java new file mode 100644 index 0000000000..9d0f1f2729 --- /dev/null +++ b/src/Java/miscutil/core/intermod/psychedelicraft/Psychedelicraft_Booze.java @@ -0,0 +1,11 @@ +package miscutil.core.intermod.psychedelicraft; + + +public class Psychedelicraft_Booze { + + public static void run(){ + //Psychedelicraft; + ivtoolkit + } + +} diff --git a/src/Java/miscutil/core/lib/LoadedMods.java b/src/Java/miscutil/core/lib/LoadedMods.java index 019ac09b89..7e234b970b 100644 --- a/src/Java/miscutil/core/lib/LoadedMods.java +++ b/src/Java/miscutil/core/lib/LoadedMods.java @@ -21,6 +21,7 @@ public class LoadedMods { public static boolean ForbiddenMagic = false; public static boolean CompactWindmills = false; public static boolean Railcraft = false; + public static boolean Growthcraft = false; public static boolean MiscUtils = true; //Dummy For MetaData Lookups in MT Wrapper @@ -89,6 +90,11 @@ public class LoadedMods { Railcraft = true; totalMods++; } + if (Loader.isModLoaded("Growthcraft") == true){ + Growthcraft = true; + totalMods++; + } + Utils.LOG_INFO("Content found for "+totalMods+" mods"); diff --git a/src/Java/miscutil/core/recipe/RECIPES_Machines.java b/src/Java/miscutil/core/recipe/RECIPES_Machines.java index e2949eb79c..6f74b873b4 100644 --- a/src/Java/miscutil/core/recipe/RECIPES_Machines.java +++ b/src/Java/miscutil/core/recipe/RECIPES_Machines.java @@ -440,9 +440,9 @@ public class RECIPES_Machines { //Industrial Coke Oven UtilsRecipe.recipeBuilder( - plateCobalt, circuitTier3, plateCobalt, + plateCobalt, circuitTier4, plateCobalt, machineCasing_HV, INPUT_RCCokeOvenBlock, machineCasing_HV, - plateCobalt, circuitTier3, plateCobalt, + plateCobalt, circuitTier5, plateCobalt, RECIPE_IndustrialCokeOvenController); //Coke Oven Frame Casing diff --git a/src/Java/miscutil/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/miscutil/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java new file mode 100644 index 0000000000..b807589d78 --- /dev/null +++ b/src/Java/miscutil/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -0,0 +1,805 @@ +package miscutil.gregtech.api.metatileentity.implementations.base; + +import static gregtech.api.enums.GT_Values.V; +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.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; + +import java.util.ArrayList; + +import miscutil.gregtech.api.gui.CONTAINER_MultiMachine; +import miscutil.gregtech.api.gui.GUI_MultiMachine; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GregtechMeta_MultiBlockBase extends MetaTileEntity { + + public static boolean disableMaintenance; + public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = true, mCrowbar = false, mRunningOnLoad = false; + public int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mUpdate = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0; + public ItemStack[] mOutputItems = null; + public FluidStack[] mOutputFluids = null; + public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Input>(); + public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Output>(); + public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>(); + public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<GT_MetaTileEntity_Hatch_OutputBus>(); + public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch_Dynamo>(); + public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<GT_MetaTileEntity_Hatch_Muffler>(); + public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>(); + public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<GT_MetaTileEntity_Hatch_Maintenance>(); + + public GregtechMeta_MultiBlockBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 2); + this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + } + + public GregtechMeta_MultiBlockBase(String aName) { + super(aName, 2); + this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + } + + public static boolean isValidMetaTileEntity(MetaTileEntity aMetaTileEntity) { + return aMetaTileEntity.getBaseMetaTileEntity() != null && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex > 0; + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + return aProgress; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setInteger("mEfficiency", mEfficiency); + aNBT.setInteger("mPollution", mPollution); + aNBT.setInteger("mRuntime", mRuntime); + + if (mOutputItems != null) for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + if (mOutputFluids != null) for (int i = 0; i < mOutputFluids.length; i++) + if (mOutputFluids[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + + aNBT.setBoolean("mWrench", mWrench); + aNBT.setBoolean("mScrewdriver", mScrewdriver); + aNBT.setBoolean("mSoftHammer", mSoftHammer); + aNBT.setBoolean("mHardHammer", mHardHammer); + aNBT.setBoolean("mSolderingTool", mSolderingTool); + aNBT.setBoolean("mCrowbar", mCrowbar); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mEUt = aNBT.getInteger("mEUt"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + if (mMaxProgresstime > 0) mRunningOnLoad = true; + mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + mEfficiency = aNBT.getInteger("mEfficiency"); + mPollution = aNBT.getInteger("mPollution"); + mRuntime = aNBT.getInteger("mRuntime"); + mOutputItems = new ItemStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + mOutputFluids = new FluidStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputFluids.length; i++) + mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + mWrench = aNBT.getBoolean("mWrench"); + mScrewdriver = aNBT.getBoolean("mScrewdriver"); + mSoftHammer = aNBT.getBoolean("mSoftHammer"); + mHardHammer = aNBT.getBoolean("mHardHammer"); + mSolderingTool = aNBT.getBoolean("mSolderingTool"); + mCrowbar = aNBT.getBoolean("mCrowbar"); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiblockDisplay.png"); + } + + @Override + public byte getTileEntityBaseType() { + return 2; + } + + @Override + public void onMachineBlockUpdate() { + mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (mEfficiency < 0) mEfficiency = 0; + if (--mUpdate == 0 || --mStartUpCheck == 0) { + mInputHatches.clear(); + mInputBusses.clear(); + mOutputHatches.clear(); + mOutputBusses.clear(); + mDynamoHatches.clear(); + mEnergyHatches.clear(); + mMufflerHatches.clear(); + mMaintenanceHatches.clear(); + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + } + if (mStartUpCheck < 0) { + if (mMachine) { + for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (!this.disableMaintenance) { + if (tHatch.mWrench) mWrench = true; + if (tHatch.mScrewdriver) mScrewdriver = true; + if (tHatch.mSoftHammer) mSoftHammer = true; + if (tHatch.mHardHammer) mHardHammer = true; + if (tHatch.mSolderingTool) mSolderingTool = true; + if (tHatch.mCrowbar) mCrowbar = true; + } else { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } + + tHatch.mWrench = false; + tHatch.mScrewdriver = false; + tHatch.mSoftHammer = false; + tHatch.mHardHammer = false; + tHatch.mSolderingTool = true; + tHatch.mCrowbar = false; + } + } + if (getRepairStatus() > 0) { + if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { + if (onRunningTick(mInventory[1])) { + if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) { + stopMachine(); + } + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputItems != null) for (ItemStack tStack : mOutputItems) + if (tStack != null) { + try { + GT_Mod.instance.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack); + } catch (Exception e) { + } + addOutput(tStack); + } + if (mOutputFluids != null && mOutputFluids.length == 1) { + for (FluidStack tStack : mOutputFluids) + if (tStack != null) { + addOutput(tStack); + } + } else if (mOutputFluids != null && mOutputFluids.length > 1) { + addFluidOutputs(mOutputFluids); + } + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + mOutputItems = null; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]); + if (mOutputFluids != null && mOutputFluids.length > 0) { + if (mOutputFluids.length > 1) { + GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "oilplant"); + } + } + } + } + } else { + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { + + if (aBaseMetaTileEntity.isAllowedToWork()) { + checkRecipe(mInventory[1]); + } + if (mMaxProgresstime <= 0) mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + stopMachine(); + } + } else { + stopMachine(); + } + } + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean polluteEnvironment(int aPollutionLevel) { + mPollution += aPollutionLevel; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (mPollution >= 10000) { + if (tHatch.polluteEnvironment()) { + mPollution -= 10000; + } + } else { + break; + } + } + } + return mPollution < 10000; + } + + /** + * Called every tick the Machine runs + */ + public boolean onRunningTick(ItemStack aStack) { + if (mEUt > 0) { + addEnergyOutput(((long) mEUt * mEfficiency) / 10000); + return true; + } + if (mEUt < 0) { + if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + stopMachine(); + return false; + } + } + return true; + } + + /** + * Checks if this is a Correct Machine Part for this kind of Machine (Turbine Rotor for example) + */ + //public abstract boolean isCorrectMachinePart(ItemStack aStack); + + /** + * Checks the Recipe + */ + public abstract boolean checkRecipe(ItemStack aStack); + + /** + * Checks the Machine. You have to assign the MetaTileEntities for the Hatches here. + */ + public abstract boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack); + + /** + * Gets the maximum Efficiency that spare Part can get (0 - 10000) + */ + public abstract int getMaxEfficiency(ItemStack aStack); + + /** + * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) + */ + public abstract int getPollutionPerTick(ItemStack aStack); + + /** + * Gets the damage to the ItemStack, usually 0 or 1. + */ + //public abstract int getDamageToComponent(ItemStack aStack); + + /** + * Gets the Amount of possibly outputted Items for loading the Output Stack Array from NBT. + * This should be the largest Amount that can ever happen legitimately. + */ + public abstract int getAmountOfOutputs(); + + /** + * If it explodes when the Component has to be replaced. + */ + public abstract boolean explodesOnComponentBreak(ItemStack aStack); + + public void stopMachine() { + mOutputItems = null; + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + public int getRepairStatus() { + return (mWrench ? 1 : 0) + (mScrewdriver ? 1 : 0) + (mSoftHammer ? 1 : 0) + (mHardHammer ? 1 : 0) + (mSolderingTool ? 1 : 0) + (mCrowbar ? 1 : 0); + } + + public int getIdealStatus() { + return 6; + } + + public boolean doRandomMaintenanceDamage() { + if (getRepairStatus() == 0) { + stopMachine(); + return false; + } + if (mRuntime++ > 1000) { + mRuntime = 0; + if (getBaseMetaTileEntity().getRandomNumber(6000) == 0) { + switch (getBaseMetaTileEntity().getRandomNumber(6)) { + case 0: + mWrench = false; + break; + case 1: + mScrewdriver = false; + break; + case 2: + mSoftHammer = false; + break; + case 3: + mHardHammer = false; + break; + case 4: + mSolderingTool = true; + break; + case 5: + mCrowbar = false; + break; + } + } + if (mInventory[1] != null && getBaseMetaTileEntity().getRandomNumber(2) == 0 && !mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { + if (mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { + NBTTagCompound tNBT = mInventory[1].getTagCompound(); + if (tNBT != null) { + NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents"); + if (!tNBT.getBoolean("mDis")) { + tNBT2 = new NBTTagCompound(); + Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]); + ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1); + int i = mInventory[1].getItemDamage(); + if (i == 170) { + ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Magnalium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 172) { + ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Titanium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 174) { + ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TungstenSteel, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 176) { + ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Americium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } + tNBT.setTag("GT.CraftingComponents", tNBT2); + tNBT.setBoolean("mDis", true); + mInventory[1].setTagCompound(tNBT); + + } + } + + ((GT_MetaGenerated_Tool) mInventory[1].getItem()).doDamage(mInventory[1], (long) Math.min(mEUt / 5, Math.pow(mEUt, 0.7))); + if (mInventory[1].stackSize == 0) mInventory[1] = null; + } + } + } + return true; + } + + public void explodeMultiblock() { + mInventory[1] = null; + for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mDynamoHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mEnergyHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mMaintenanceHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + getBaseMetaTile |
