diff options
author | â€huajijam <strhuaji@gmail.com> | 2019-05-17 23:26:41 +0800 |
---|---|---|
committer | â€huajijam <strhuaji@gmail.com> | 2019-05-17 23:26:41 +0800 |
commit | 5920c6db3ff62d89ba41db4eda59cc6d70ddce3b (patch) | |
tree | d4d6d5036e8cb95d2232066f0ee257f59b5aa967 /src/Java/gtPlusPlus/xmod/gregtech/api | |
parent | 787c31758d2ea3259f8da9c5c7ffd4b28429eb9a (diff) | |
parent | cacc2915ef0039e3460817e4f116d44cf8e44e5f (diff) | |
download | GT5-Unofficial-5920c6db3ff62d89ba41db4eda59cc6d70ddce3b.tar.gz GT5-Unofficial-5920c6db3ff62d89ba41db4eda59cc6d70ddce3b.tar.bz2 GT5-Unofficial-5920c6db3ff62d89ba41db4eda59cc6d70ddce3b.zip |
Automatic synchronization
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api')
8 files changed, 468 insertions, 73 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 68fe121081..933ec227ba 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -313,6 +313,10 @@ public enum GregtechItemList implements GregtechItemContainer { //Larger Turbines Large_Steam_Turbine, Large_HPSteam_Turbine, Casing_Turbine_Shaft, Casing_Turbine_LP, Casing_Turbine_HP, + + //Large Vacuum Furnace + Casing_Vacuum_Furnace, + Controller_Vacuum_Furnace, @@ -427,6 +431,7 @@ public enum GregtechItemList implements GregtechItemContainer { //Debug machine Pollution_Creator, + Garbage_Collector_Debug_Machine, //Basically is an automatic Cauldron @@ -582,9 +587,14 @@ public enum GregtechItemList implements GregtechItemContainer { */ //Fluid Void Covers - Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, - + Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, + //Fake Hull Covers + FakeMachineCasingPlate_ULV, FakeMachineCasingPlate_LV, + FakeMachineCasingPlate_MV, FakeMachineCasingPlate_HV, + FakeMachineCasingPlate_EV, FakeMachineCasingPlate_IV, + FakeMachineCasingPlate_LuV, FakeMachineCasingPlate_ZPM, + FakeMachineCasingPlate_UV, FakeMachineCasingPlate_MAX, //---------------------------------------------------------------------------- diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java new file mode 100644 index 0000000000..721fe053ae --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java @@ -0,0 +1,51 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.slots.SlotAirFilter; +import net.minecraft.entity.player.InventoryPlayer; + + +public class CONTAINER_Hatch_Muffler_Advanced extends GT_ContainerMetaTile_Machine { + + public long maxEU = 0; + public long storedEU = 0; + + public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new SlotAirFilter(this.mTileEntity, 1, 80, 35)); + } + + @Override + public int getSlotCount() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } + + @Override + public void updateProgressBar(final int id, final int value) { + super.updateProgressBar(id, value); + switch (id) { + default: + break; + } + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java index 503b36e157..dcab57c380 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java @@ -4,21 +4,16 @@ import java.util.Iterator; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Output; import gregtech.api.gui.GT_Slot_Render; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.slots.SlotLockedInput; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_Large; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; public class CONTAINER_SuperChest extends GT_ContainerMetaTile_Machine { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java new file mode 100644 index 0000000000..4b998f6487 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java @@ -0,0 +1,46 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_Hatch_Muffler_Advanced extends GT_GUIContainerMetaTile_Machine { + + String mName = ""; + long maxPower = 0; + long storedPower = 0; + + public GUI_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { + super(new CONTAINER_Hatch_Muffler_Advanced(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 8, 8, 16448255); + /* + * ReflectionUtils.setField(this.fontRendererObj, "underlineStyle", true); + * ReflectionUtils.setField(this.fontRendererObj, "italicStyle", true); + * ReflectionUtils.setField(this.fontRendererObj, "boldStyle", true); boolean + * isBold = ReflectionUtils.getField(this.fontRendererObj, "boldStyle"); + * this.fontRendererObj.drawString("Insert Air Filters - Bold: "+isBold, 8, 18, + * 16448255); + */ + if (this.mContainer != null) { + //this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + //this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + //this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + //this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index 721facd8d0..e4a15d34ea 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -117,7 +117,7 @@ public interface IGregtech_RecipeAdder { * @param aEUt = EU per tick needed for heating up (must be >= 0) * @return true if the Recipe got added, otherwise false. */ - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int aChance, int aDuration, int aEUt); + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, int aDuration, int aEUt); public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, int aChance, int aDuration, int aEUt, int aSpecialValue); @@ -134,7 +134,7 @@ public interface IGregtech_RecipeAdder { * @param aSpecialValue = Stores the Required Temp for the Recipe * @return true if the Recipe got added, otherwise false. */ - public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int aChance, int aDuration, int aEUt, int aSpecialValue); + public boolean addBlastSmelterRecipe(ItemStack[] aInput, FluidStack aInputFluid, FluidStack aOutput, ItemStack[] aOutputStack, int[] aChance, int aDuration, int aEUt, int aSpecialValue); public boolean addLFTRRecipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, int aDuration, int aEUt); @@ -252,4 +252,9 @@ public interface IGregtech_RecipeAdder { * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) */ public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial); + + + boolean addVacuumFurnaceRecipe(ItemStack aInput1, ItemStack aInput2, + FluidStack aFluidInput, FluidStack aFluidOutput, ItemStack aOutput1, + ItemStack aOutput2, int aDuration, int aEUt, int aLevel); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java index 2832941bdd..5fa1fc8aba 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java @@ -1,11 +1,19 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.item.general.ItemAirFilter; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_Hatch_Muffler_Advanced; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_Hatch_Muffler_Advanced; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; @@ -13,11 +21,11 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch_Muffler { + protected int SLOT_FILTER = 0; + @Override public void onConfigLoad(GT_Config aConfig) { super.onConfigLoad(aConfig); @@ -38,27 +46,30 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch public GT_MetaTileEntity_Hatch_Muffler_Adv(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); } public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); } public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription[0], aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); } public String[] getDescription() { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - - String[] mDescArray = StaticFields59.getDescriptionArray(this); - - String[] desc = new String[mDescArray.length + 4]; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + String[] mDescArray = StaticFields59.getDescriptionArray(this); + String[] desc = new String[mDescArray.length + 6]; System.arraycopy(mDescArray, 0, desc, 0, mDescArray.length); desc[mDescArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; - desc[mDescArray.length + 1] = "Requires extra Air on the exhaust face"; - desc[mDescArray.length + 2] = "Reduces Pollution to " + this.calculatePollutionReduction(100) + "%"; - desc[mDescArray.length + 3] = "Recovers " + (105 - this.calculatePollutionReduction(100)) + desc[mDescArray.length + 1] = "Requires 3 Air on the exhaust face"; + desc[mDescArray.length + 2] = "Requires Air Filters"; + desc[mDescArray.length + 3] = "Mufflers require T2 Filters from IV-"+GT_Values.VN[9]; + desc[mDescArray.length + 4] = "Reduces Pollution to " + this.calculatePollutionReductionForTooltip(100) + "%"; + desc[mDescArray.length + 5] = "Recovers " + (105 - this.calculatePollutionReductionForTooltip(100)) + "% of CO2/CO/SO2"; return desc; } @@ -76,7 +87,7 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public boolean isValidSlot(int aIndex) { - return false; + return aIndex == SLOT_FILTER; } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -88,24 +99,33 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; - //aBaseMetaTileEntity.openGUI(aPlayer); + aBaseMetaTileEntity.openGUI(aPlayer); return true; } - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, - IGregTechTileEntity aBaseMetaTileEntity) { - return null; + + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity); } - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, - IGregTechTileEntity aBaseMetaTileEntity) { - return null; + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity, "Advanced Muffler", "machine_Charger.png"); + } + + private boolean airCheck() { + if ( + this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()) && + this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 1) && + this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 2) + ) { + return true; + } + return false; } public boolean polluteEnvironment() { - if (this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()) && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 1)) { + if (airCheck() && damageAirFilter()) { int aEmission = this.calculatePollutionReduction(10000); PollutionUtils.addPollution(this.getBaseMetaTileEntity(), aEmission); //Logger.INFO("Outputting "+aEmission+"gbl"); @@ -116,30 +136,134 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } } + + public int calculatePollutionReductionForTooltip(int aPollution) { + return (int) (aPollution * Math.pow(0.64D, (double) (this.mTier - 1))); + } + public int calculatePollutionReduction(int aPollution) { - return (int) ((double) aPollution * Math.pow(0.64D, (double) (this.mTier - 1))); + double aVal1 = aPollution * Math.pow(0.64D, (double) (this.mTier - 1)); + int aVal2 = (int) aVal1; + if (!hasValidFilter()) { + aVal2 = (int) ((double) aPollution * Math.pow(0.7D, (double) (this.mTier - 1)));; + } + return aVal2; } public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; + if (aIndex == this.SLOT_FILTER) { + if (isAirFilter(aStack)) { + return true; + } + } + return false; + } + + private ItemStack getInventoryStack() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length-1 >= this.SLOT_FILTER) { + return this.mInventory[this.SLOT_FILTER]; + } + } + return null; + } + + private void breakAirFilter() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length-1 >= this.SLOT_FILTER) { + Logger.INFO("Breaking Filter"); + this.mInventory[this.SLOT_FILTER] = null; + } + } } public boolean hasValidFilter() { - return false; + return isAirFilter(getInventoryStack()); } - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + + //Logger.INFO("A1"); + super.onPostTick(aBaseMetaTileEntity, aTick); - String aParticleName; - if (hasValidFilter()) { - aParticleName = "cloud"; - } else { - aParticleName = "smoke"; + + //Logger.INFO("A2"); + + String aParticleName; + if ((aTick % 2) == 0){ + aParticleName = "cloud"; } - if (aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive()) { - this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); + else { + aParticleName = "smoke"; + } + + //Logger.INFO("A3"); + + if (aBaseMetaTileEntity.isClientSide()) { + //Logger.INFO("B1"); + if (this.getBaseMetaTileEntity().isActive()) { + //Logger.INFO("C1"); + this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); + } + //return; + } + else { + //Logger.INFO("B2"); + if (this.getInventoryStack() == null) { + //Logger.INFO("D1"); + //Logger.INFO("Empty - "+this.mInventory.length); + } + else { + //Logger.INFO("D2"); + Logger.INFO("Has Item"); + } } + //Logger.INFO("A4"); + + + + } + + public boolean isAirFilter(ItemStack filter){ + if (filter == null) { + return false; + } + if (filter.getItem() instanceof ItemAirFilter){ + + if (this.mTier < 5) { + return true; + } + else { + if (filter.getItemDamage() == 1) { + return true; + } + } + } + return false; + } + public boolean damageAirFilter(){ + ItemStack filter = getInventoryStack(); + if (filter == null) { + return false; + } + + if (isAirFilter(filter)){ + long currentUse = ItemAirFilter.getFilterDamage(filter); + Logger.INFO("Filter Damage: "+currentUse); + //Remove broken Filter + if ((filter.getItemDamage() == 0 && currentUse >= 50-1) || (filter.getItemDamage() == 1 && currentUse >= 2500-1)){ + breakAirFilter(); + return false; + } + else { + //Do Damage + ItemAirFilter.setFilterDamage(filter, currentUse+1); + Logger.INFO("Filter Damage now: "+currentUse); + return true; + } + } + return false; } public void pollutionParticles(World aWorld, String name) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java index bed80d8d13..b395bbbabe 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -8,7 +8,6 @@ import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index e352712138..0e1ef0e47e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -1,10 +1,10 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; -import static gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -48,6 +48,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; @@ -539,26 +540,149 @@ GT_MetaTileEntity_MultiBlockBase { } + /* + * public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] + * aFluidInputs, int aMaxParallelRecipes, int aEUPercent, int + * aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { // Based on + * the Processing Array. A bit overkill, but very flexible. + * + * + * if (this.doesMachineBoostOutput()) { log("Boosting."); return + * checkRecipeBoostedOutputs(aItemInputs, aFluidInputs, aMaxParallelRecipes, + * aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); } + * + * + * //Control Core to control the Multiblocks behaviour. int aControlCoreTier = + * getControlCoreTier(); + * + * //If no core, return false; if (aControlCoreTier > 0) { + * log("Control core found."); } + * + * + * // Reset outputs and progress stats this.mEUt = 0; this.mMaxProgresstime = 0; + * this.mOutputItems = new ItemStack[]{}; this.mOutputFluids = new + * FluidStack[]{}; + * + * long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, + * GT_Utility.getTier(tVoltage)); log("Running checkRecipeGeneric(0)"); + * + * //Check to see if Voltage Tier > Control Core Tier if (tTier > + * aControlCoreTier) { + * log("Control core found is lower tier than power tier. OK"); tTier = (byte) + * aControlCoreTier; } + * + * tTier = (byte) MathUtils.getValueWithinRange(tTier, 0, 9); + * + * GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( + * getBaseMetaTileEntity(), mLastRecipe, false, + * gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + * + * log("Running checkRecipeGeneric(1)"); // Remember last recipe - an + * optimization for findRecipe() this.mLastRecipe = tRecipe; + * + * if (tRecipe == null) { log("BAD RETURN - 1"); return false; } + * + * if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { + * log("BAD RETURN - 2"); return false; } + * + * // EU discount float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; float + * tTotalEUt = 0.0f; + * + * int parallelRecipes = 0; + * + * log("parallelRecipes: "+parallelRecipes); + * log("aMaxParallelRecipes: "+aMaxParallelRecipes); + * log("tTotalEUt: "+tTotalEUt); log("tVoltage: "+tVoltage); + * log("tRecipeEUt: "+tRecipeEUt); Logger.INFO("EU1: "+tRecipeEUt); // Count + * recipes to do in parallel, consuming input items and fluids and considering + * input voltage limits for (; parallelRecipes < aMaxParallelRecipes && + * tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { if + * (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + * log("Broke at "+parallelRecipes+"."); break; } + * log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); tTotalEUt + * += tRecipeEUt; Logger.INFO("EU2: "+tTotalEUt); } + * + * if (parallelRecipes == 0) { log("BAD RETURN - 3"); return false; } + * + * Logger.INFO("EU3: "+tTotalEUt); + * + * // -- Try not to fail after this point - inputs have already been consumed! + * -- + * + * + * // Convert speed bonus to duration multiplier // e.g. 100% speed bonus = 200% + * speed = 100%/200% = 50% recipe duration. aSpeedBonusPercent = Math.max(-99, + * aSpeedBonusPercent); float tTimeFactor = 100.0f / (100.0f + + * aSpeedBonusPercent); this.mMaxProgresstime = (int)(tRecipe.mDuration * + * tTimeFactor * 10000); + * + * int aTempEu = (int) Math.floor(tTotalEUt); Logger.INFO("EU4: "+aTempEu); + * this.mEUt = (int) aTempEu; + * + * + * this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + * this.mEfficiencyIncrease = 10000; + * + * // Overclock if (this.mEUt <= 16) { this.mEUt = (this.mEUt * (1 << tTier - 1) + * * (1 << tTier - 1)); this.mMaxProgresstime = (this.mMaxProgresstime / (1 << + * tTier - 1)); } else { while (this.mEUt <= + * gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 4; + * this.mMaxProgresstime /= 2; } } + * + * if (this.mEUt > 0) { this.mEUt = (-this.mEUt); } + * + * 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 + * *= parallelRecipes; } } + * + * // 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 < parallelRecipes; 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(); + * + * log("GOOD RETURN - 1"); return true; } + */ + public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - - if (this.doesMachineBoostOutput()) { - log("Boosting."); - return checkRecipeBoostedOutputs(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); - } - - - //Control Core to control the Multiblocks behaviour. - int aControlCoreTier = getControlCoreTier(); - - //If no core, return false; - if (aControlCoreTier > 0) { - log("Control core found."); - } + // Based on the Processing Array. A bit overkill, but very flexible. // Reset outputs and progress stats @@ -571,15 +695,8 @@ GT_MetaTileEntity_MultiBlockBase { byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); log("Running checkRecipeGeneric(0)"); - //Check to see if Voltage Tier > Control Core Tier - if (tTier > aControlCoreTier) { - log("Control core found is lower tier than power tier. OK"); - tTier = (byte) aControlCoreTier; - } - tTier = (byte) MathUtils.getValueWithinRange(tTier, 0, 9); - - GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( + GT_Recipe tRecipe = findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); @@ -635,7 +752,7 @@ GT_MetaTileEntity_MultiBlockBase { this.mEUt = (int)Math.ceil(tTotalEUt); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; + this.mEfficiencyIncrease = 10000; // Overclock if (this.mEUt <= 16) { @@ -718,8 +835,7 @@ GT_MetaTileEntity_MultiBlockBase { log("GOOD RETURN - 1"); return true; - } - +} @@ -1136,6 +1252,47 @@ GT_MetaTileEntity_MultiBlockBase { ItemStack guiSlot = this.mInventory[1]; return guiSlot; } + + protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { + boolean result = false; + if (this.mInventory[1] == null) { + this.mInventory[1] = aNewGuiSlotContents != null ? aNewGuiSlotContents.copy() : null; + aNewGuiSlotContents = null; + this.updateSlots(); + result = true; + } + return result; + } + + protected boolean clearGUIItemSlot() { + return setGUIItemStack(null); + } + + + public ItemStack findItemInInventory(Item aSearchStack) { + return findItemInInventory(aSearchStack, 0); + } + + public ItemStack findItemInInventory(Item aSearchStack, int aMeta) { + return findItemInInventory(ItemUtils.simpleMetaStack(aSearchStack, aMeta, 1)); + } + + public ItemStack findItemInInventory(ItemStack aSearchStack) { + if (aSearchStack != null && this.mInputBusses.size() > 0) { + for (GT_MetaTileEntity_Hatch_InputBus bus : this.mInputBusses) { + if (bus != null) { + for (ItemStack uStack : bus.mInventory) { + if (uStack != null) { + if (aSearchStack.getClass().isInstance(uStack.getItem())) { + return uStack; + } + } + } + } + } + } + return null; + } @Override public void updateSlots() { @@ -1208,6 +1365,14 @@ GT_MetaTileEntity_MultiBlockBase { if (aTileEntity == null) { return false; } + + //Check type + /* + * Class <?> aHatchType = ReflectionUtils.getTypeOfGenericObject(aList); if + * (!aHatchType.isInstance(aTileEntity)) { return false; } + */ + + if (aList.isEmpty()) { if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { |