diff options
author | Alkalus <Draknyte1@hotmail.com> | 2020-04-04 16:57:56 +0100 |
---|---|---|
committer | Alkalus <Draknyte1@hotmail.com> | 2020-04-04 16:57:56 +0100 |
commit | acf7193504fba4a7165d2ba5732cc9ce5f35ec55 (patch) | |
tree | 1fb97da489c70c4cc7f134fe5b5aeef2b944979a /src/Java/gtPlusPlus/xmod | |
parent | 35f473d3f79d3b4f30e2cd02885a6e685d66fb45 (diff) | |
download | GT5-Unofficial-acf7193504fba4a7165d2ba5732cc9ce5f35ec55.tar.gz GT5-Unofficial-acf7193504fba4a7165d2ba5732cc9ce5f35ec55.tar.bz2 GT5-Unofficial-acf7193504fba4a7165d2ba5732cc9ce5f35ec55.zip |
+ Added a new base bus type.
+ Added the Ball Housing bus.
+ Added the Catalyst Housing bus.
+ Added the Reinforced Engine Casing.
+ Made the Flotation Cell Regulator actually load.
$ Fixed Tooltips on Milling Balls & Catalysts.
$ Added improved item handling for Milling Balls.
$ Added improved item handling for Catalysts.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
13 files changed, 1157 insertions, 76 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 504533c406..173b260d57 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -363,6 +363,9 @@ public enum GregtechItemList implements GregtechItemContainer { Casing_Turbine_LP, Casing_Turbine_HP, Casing_Turbine_Gas, Casing_Turbine_Plasma, + // Large Engine + Casing_Reinforced_Engine_Casing, + //Large Vacuum Furnace Casing_Vacuum_Furnace, Controller_Vacuum_Furnace, @@ -375,10 +378,13 @@ public enum GregtechItemList implements GregtechItemContainer { Controller_LargeSemifluidGenerator, // IsaMill - Controller_IsaMill_Controller, + Controller_IsaMill, Casing_IsaMill_Casing, Casing_IsaMill_Gearbox, Casing_IsaMill_Pipe, + + // Flotation Cell + Controller_Flotation_Cell, //---------------------------------------------------------------------------- @@ -402,6 +408,12 @@ public enum GregtechItemList implements GregtechItemContainer { //Control Core Hatch_Control_Core, + + // Milling Ball Bus + Bus_Milling_Balls, + + // Catalyst Bus + Bus_Catalysts, //Custom Fluid Hatches Hatch_Input_Cryotheum, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java new file mode 100644 index 0000000000..9596d41387 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_HatchNbtConsumable.java @@ -0,0 +1,282 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_Container; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.core.slots.SlotNoInput; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CONTAINER_HatchNbtConsumable extends GT_Container { + + public final int mInputslotCount; + private final int mTotalSlotCount; + + public CONTAINER_HatchNbtConsumable(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, int aInputslotCount) { + super(aInventoryPlayer, aTileEntity); + mInputslotCount = aInputslotCount; + mTotalSlotCount = aInputslotCount*2; + mTileEntity = aTileEntity; + if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { + addSlots(aInventoryPlayer); + if (doesBindPlayerInventory()) { + bindPlayerInventory(aInventoryPlayer); + } + detectAndSendChanges(); + } else { + aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; + } + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + if (mTotalSlotCount == 8) { + final int aSlotYStart = 26; + final int aSlotYFinish = aSlotYStart + (18*2); + final int aSlotXStart1 = 26; + final int aSlotXFinish1 = aSlotXStart1 + (18*2); + final int aSlotXStart2 = 116; + final int aSlotXFinish2 = aSlotXStart2 + (18*2); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } + else if (mTotalSlotCount == 18) { + int aSlotYStart = 20; + int aSlotYFinish = aSlotYStart + (18*3); + int aSlotXStart1 = 26; + int aSlotXFinish1 = aSlotXStart1 + (18*3); + int aSlotXStart2 = 98; + int aSlotXFinish2 = aSlotXStart2 + (18*3); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } + else if (mTotalSlotCount == 32) { + int aSlotYStart = 8; + int aSlotYFinish = aSlotYStart + (18*4); + int aSlotXStart1 = 8; + int aSlotXFinish1 = aSlotXStart1 + (18*4); + int aSlotXStart2 = 97; + int aSlotXFinish2 = aSlotXStart2 + (18*4); + int aSlotID = 0; + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart1; x < aSlotXFinish1; x += 18) { + addSlotToContainer(new Slot(mTileEntity, aSlotID++, x, y)); + } + } + for (int y = aSlotYStart; y < aSlotYFinish; y += 18) { + for (int x = aSlotXStart2; x < aSlotXFinish2; x += 18) { + addSlotToContainer(new ViewingSlot(mTileEntity, aSlotID++, x, y)); + } + } + } + } + + @Override + public int getSlotCount() { + return mTotalSlotCount; + } + + @Override + public int getShiftClickSlotCount() { + return mInputslotCount; + } + + /* + * Uselss stuff copied from GT + */ + + + public int mActive = 0, mMaxProgressTime = 0, mProgressTime = 0, mEnergy = 0, mSteam = 0, mSteamStorage = 0, mStorage = 0, mOutput = 0, mInput = 0, mID = 0, mDisplayErrorCode = 0; + private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, oEnergy = 0, oSteam = 0, oSteamStorage = 0, oStorage = 0, oOutput = 0, oInput = 0, oID = 0, oDisplayErrorCode = 0, mTimer = 0; + + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; + mStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getEUCapacity()); + mEnergy = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredEU()); + mSteamStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getSteamCapacity()); + mSteam = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredSteam()); + mOutput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getOutputVoltage()); + mInput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getInputVoltage()); + mDisplayErrorCode = mTileEntity.getErrorDisplayID(); + mProgressTime = mTileEntity.getProgress(); + mMaxProgressTime = mTileEntity.getMaxProgress(); + mActive = mTileEntity.isActive() ? 1 : 0; + mTimer++; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + if (mTimer % 500 == 10 || oEnergy != mEnergy) { + var1.sendProgressBarUpdate(this, 0, mEnergy & 65535); + var1.sendProgressBarUpdate(this, 1, mEnergy >>> 16); + } + if (mTimer % 500 == 10 || oStorage != mStorage) { + var1.sendProgressBarUpdate(this, 2, mStorage & 65535); + var1.sendProgressBarUpdate(this, 3, mStorage >>> 16); + } + if (mTimer % 500 == 10 || oOutput != mOutput) { + var1.sendProgressBarUpdate(this, 4, mOutput); + } + if (mTimer % 500 == 10 || oInput != mInput) { + var1.sendProgressBarUpdate(this, 5, mInput); + } + if (mTimer % 500 == 10 || oDisplayErrorCode != mDisplayErrorCode) { + var1.sendProgressBarUpdate(this, 6, mDisplayErrorCode); + } + if (mTimer % 500 == 10 || oProgressTime != mProgressTime) { + var1.sendProgressBarUpdate(this, 11, mProgressTime & 65535); + var1.sendProgressBarUpdate(this, 12, mProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oMaxProgressTime != mMaxProgressTime) { + var1.sendProgressBarUpdate(this, 13, mMaxProgressTime & 65535); + var1.sendProgressBarUpdate(this, 14, mMaxProgressTime >>> 16); + } + if (mTimer % 500 == 10 || oID != mID) { + var1.sendProgressBarUpdate(this, 15, mID); + } + if (mTimer % 500 == 10 || oActive != mActive) { + var1.sendProgressBarUpdate(this, 16, mActive); + } + if (mTimer % 500 == 10 || oSteam != mSteam) { + var1.sendProgressBarUpdate(this, 17, mSteam & 65535); + var1.sendProgressBarUpdate(this, 18, mSteam >>> 16); + } + if (mTimer % 500 == 10 || oSteamStorage != mSteamStorage) { + var1.sendProgressBarUpdate(this, 19, mSteamStorage & 65535); + var1.sendProgressBarUpdate(this, 20, mSteamStorage >>> 16); + } + } + + oID = mID; + oSteam = mSteam; + oInput = mInput; + oActive = mActive; + oOutput = mOutput; + oEnergy = mEnergy; + oStorage = mStorage; + oSteamStorage = mSteamStorage; + oProgressTime = mProgressTime; + oMaxProgressTime = mMaxProgressTime; + oDisplayErrorCode = mDisplayErrorCode; + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 0: + mEnergy = mEnergy & -65536 | par2; + break; + case 1: + mEnergy = mEnergy & 65535 | par2 << 16; + break; + case 2: + mStorage = mStorage & -65536 | par2; + break; + case 3: + mStorage = mStorage & 65535 | par2 << 16; + break; + case 4: + mOutput = par2; + break; + case 5: + mInput = par2; + break; + case 6: + mDisplayErrorCode = par2; + break; + case 11: + mProgressTime = mProgressTime & -65536 | par2; + break; + case 12: + mProgressTime = mProgressTime & 65535 | par2 << 16; + break; + case 13: + mMaxProgressTime = mMaxProgressTime & -65536 | par2; + break; + case 14: + mMaxProgressTime = mMaxProgressTime & 65535 | par2 << 16; + break; + case 15: + mID = par2; + break; + case 16: + mActive = par2; + break; + case 17: + mSteam = mSteam & -65536 | par2; + break; + case 18: + mSteam = mSteam & 65535 | par2 << 16; + break; + case 19: + mSteamStorage = mSteamStorage & -65536 | par2; + break; + case 20: + mSteamStorage = mSteamStorage & 65535 | par2 << 16; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return mTileEntity.isUseableByPlayer(player); + } + + public String trans(String aKey, String aEnglish){ + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + } + + private static class ViewingSlot extends SlotNoInput { + + public ViewingSlot(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return false; + } + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return true; + } + + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java new file mode 100644 index 0000000000..dd19571646 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_HatchNbtConsumable.java @@ -0,0 +1,59 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import gregtech.api.gui.GT_GUIContainer; + +public class GUI_HatchNbtConsumable extends GT_GUIContainer { + + private final String mName; + private final int mTotalSlotCount; + public final CONTAINER_HatchNbtConsumable mContainer; + + public GUI_HatchNbtConsumable(CONTAINER_HatchNbtConsumable aContainer, String aName) { + super(aContainer, RES_PATH_GUI + getTextureForGUI(aContainer.mInputslotCount*2)+".png"); + mContainer = aContainer; + mName = aName; + mTotalSlotCount = aContainer.mInputslotCount*2; + } + + private static final String getTextureForGUI(int aTotalSlotCOunt) { + if (aTotalSlotCOunt == 18) { + return "HatchNbtConsumable_3By3"; + } + else if (aTotalSlotCOunt == 32) { + return "HatchNbtConsumable_4By4"; + } + else { + return "HatchNbtConsumable_2By2"; + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + if (mTotalSlotCount == 18) { + fontRendererObj.drawString(mName, 8, 4, 4210752); + fontRendererObj.drawString("Stock", 25, 14, 4210752); + fontRendererObj.drawString("Active", 115, 14, 4210752); + } + else if (mTotalSlotCount == 32) { + //fontRendererObj.drawString("Slots: "+mTotalSlotCount, 8, 4, 4210752); + //fontRendererObj.drawString(mName, 8, 4, 4210752); + //fontRendererObj.drawString("Stock", 25, 16, 4210752); + //fontRendererObj.drawString("Active", 115, 16, 4210752); + } + else { + fontRendererObj.drawString(mName, 8, 4, 4210752); + fontRendererObj.drawString("Stock", 25, 16, 4210752); + fontRendererObj.drawString("Active", 115, 16, 4210752); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java new file mode 100644 index 0000000000..23f7b2a6a0 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java @@ -0,0 +1,63 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Hatch_Catalysts extends GT_MetaTileEntity_Hatch_NbtConsumable { + + public GT_MetaTileEntity_Hatch_Catalysts(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 7, 16, "Dedicated Catalyst Storage", false); + } + + public GT_MetaTileEntity_Hatch_Catalysts(String aName, String aDescription, ITexture[][][] aTextures) { + super(aName, 7, 16, aDescription, false, aTextures); + } + + public GT_MetaTileEntity_Hatch_Catalysts(String aName, String[] aDescription, ITexture[][][] aTextures) { + super(aName, 7, 16, aDescription[0], false, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Catalyst)}; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { + return GT_MetaTileEntity_Hatch_Catalysts.class; + } + + @Override + public String getNameGUI() { + return "Catalyst Container"; + } + + @Override + public AutoMap<ItemStack> getItemsValidForUsageSlots() { + return new AutoMap<ItemStack>(); + } + + @Override + public boolean isItemValidForUsageSlot(ItemStack aStack) { + return ItemUtils.isCatalyst(aStack); + } + + @Override + public int getInputSlotCount() { + return 16; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java new file mode 100644 index 0000000000..6c28ab2e27 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java @@ -0,0 +1,63 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Hatch_MillingBalls extends GT_MetaTileEntity_Hatch_NbtConsumable { + + public GT_MetaTileEntity_Hatch_MillingBalls(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 6, 4, "Dedicated Milling Ball Storage", true); + } + + public GT_MetaTileEntity_Hatch_MillingBalls(String aName, String aDescription, ITexture[][][] aTextures) { + super(aName, 6, 4, aDescription, true, aTextures); + } + + public GT_MetaTileEntity_Hatch_MillingBalls(String aName, String[] aDescription, ITexture[][][] aTextures) { + super(aName, 6, 4, aDescription[0], true, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(TexturesGtBlock.Overlay_Bus_Milling_Balls)}; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { + return GT_MetaTileEntity_Hatch_MillingBalls.class; + } + + @Override + public String getNameGUI() { + return "Ball Housing"; + } + + @Override + public AutoMap<ItemStack> getItemsValidForUsageSlots() { + return new AutoMap<ItemStack>(); + } + + @Override + public boolean isItemValidForUsageSlot(ItemStack aStack) { + return ItemUtils.isMillingBall(aStack); + } + + @Override + public int getInputSlotCount() { + return 4; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java new file mode 100644 index 0000000000..d1ce55d3f2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java @@ -0,0 +1,273 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; + +import java.lang.reflect.Constructor; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_HatchNbtConsumable; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_HatchNbtConsumable; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public abstract class GT_MetaTileEntity_Hatch_NbtConsumable extends GT_MetaTileEntity_Hatch { + + public GT_Recipe_Map mRecipeMap = null; + private final int mInputslotCount; + private final int mTotalSlotCount; + private final boolean mAllowDuplicateUsageTypes; + + public GT_MetaTileEntity_Hatch_NbtConsumable(int aID, String aName, String aNameRegional, int aTier, int aInputSlots, String aDescription, boolean aAllowDuplicateTypes) { + super(aID, aName, aNameRegional, aTier, aInputSlots*2, aDescription); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount()*2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + public GT_MetaTileEntity_Hatch_NbtConsumable(String aName, int aTier, int aInputSlots, String aDescription, boolean aAllowDuplicateTypes, ITexture[][][] aTextures) { + super(aName, aTier, aInputSlots*2, aDescription, aTextures); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount()*2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + public GT_MetaTileEntity_Hatch_NbtConsumable(String aName, int aTier, int aInputSlots, String[] aDescription, boolean aAllowDuplicateTypes, ITexture[][][] aTextures) { + super(aName, aTier, aInputSlots*2, aDescription[0], aTextures); + mInputslotCount = getInputSlotCount(); + mTotalSlotCount = getInputSlotCount()*2; + mAllowDuplicateUsageTypes = aAllowDuplicateTypes; + } + + @Override + public abstract ITexture[] getTexturesActive(ITexture aBaseTexture); + + @Override + public abstract ITexture[] getTexturesInactive(ITexture aBaseTexture); + + public abstract int getInputSlotCount(); + + @Override + public final boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public final boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public final boolean isValidSlot(int aIndex) { + return aIndex < mInputslotCount; + } + + @Override + public final MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + Constructor<?> aConstructor = ReflectionUtils.getConstructor(getHatchEntityClass(), new Class[] {String.class, String[].class, ITexture[][][].class}); + GT_MetaTileEntity_Hatch_NbtConsumable aInstance = ReflectionUtils.createNewInstanceFromConstructor(aConstructor, new Object[] {mName, StaticFields59.getDescriptionArray(this), mTextures}); + if (aInstance instanceof GT_MetaTileEntity_Hatch_NbtConsumable) { + GT_MetaTileEntity_Hatch_NbtConsumable aMetaTile = (GT_MetaTileEntity_Hatch_NbtConsumable) aInstance; + return aMetaTile; + } + return null; + } + + public abstract Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass(); + + @Override + public final boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public final Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); + } + + @Override + public final Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + CONTAINER_HatchNbtConsumable aContainer = new CONTAINER_HatchNbtConsumable(aPlayerInventory, aBaseMetaTileEntity, mInputslotCount); + return new GUI_HatchNbtConsumable(aContainer, getNameGUI()); + } + + public abstract String getNameGUI(); + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { + fillStacksIntoFirstSlots(); + tryFillUsageSlots(); + } + } + + public final void updateSlots() { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] != null && mInventory[i].stackSize <= 0) { + mInventory[i] = null; + } + // Only moves items in the first four slots + if (i <= getSlotID_LastInput()) { + fillStacksIntoFirstSlots(); + } + } + } + + // Only moves items in the first four slots + protected final void fillStacksIntoFirstSlots() { + for (int i = 0; i <= getSlotID_LastInput() ; i++) { + for (int j = i + 1; j <= getSlotID_LastInput(); j++) { + if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + } + + private final void tryFillUsageSlots() { + int aSlotSpace = (mInputslotCount - getContentUsageSlots().size()); + if (aSlotSpace > 0) { + Logger.INFO("We have empty usage slots. "+aSlotSpace); + for (int i=getSlotID_FirstInput();i<=getSlotID_LastInput();i++) { + ItemStack aStackToTryMove = mInventory[i]; + if (aStackToTryMove != null && isItemValidForUsageSlot(aStackToTryMove)) { + Logger.INFO("Trying to move stack from input slot "+i); + if (moveItemFromStockToUsageSlots(aStackToTryMove)) { + Logger.INFO("Updating Slots."); + updateSlots(); + } + } + } + } + } + + private int getSlotID_FirstInput() { + return 0; + } + private int getSlotID_LastInput() { + return mInputslotCount-1; + } + private int getSlotID_FirstUsage() { + return mInputslotCount; + } + private int getSlotID_LastUsage() { + return mTotalSlotCount-1; + } + + + public final AutoMap<ItemStack> getContentUsageSlots() { + AutoMap<ItemStack> aItems = new AutoMap<ItemStack>(); + for (int i=mInputslotCount;i<mTotalSlotCount;i++) { + if (mInventory[i] != null) { + aItems.add(mInventory[i]); + } + } + return aItems; + } + + + public final boolean moveItemFromStockToUsageSlots(ItemStack aStack) { + return moveItemFromStockToUsageSlots(aStack, mAllowDuplicateUsageTypes); + } + + public final boolean moveItemFromStockToUsageSlots(ItemStack aStack, boolean aAllowMultiOfSameTypeInUsageSlots) { + if (aStack != null) { + if (aStack.stackSize > 0) { + + if (!isItemValidForUsageSlot(aStack)) { + Logger.INFO("Stack not valid: "+ItemUtils.getItemName(aStack)); + return false; + } + + // Copy the input stack into a new object + ItemStack aStackToMove = aStack.copy(); + // Set stack size of stack to move to 1. + aStackToMove.stackSize = 1; + // Did we set a stack in the usage slots? + boolean aDidSet = false; + // Did we find another of this item already in the usage slots? + boolean aFoundMatching = false; + // Continue processing with our new stack + // First check for duplicates + for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { + if (mInventory[i] != null) { + if (GT_Utility.areStacksEqual(aStackToMove, mInventory[i], true)) { + Logger.INFO("Found matching stack in slot "+i+"."); + aFoundMatching = true; + break; + } + } + } + // Then Move stack to Usage slots + for (int i = getSlotID_FirstUsage(); i <= getSlotID_LastUsage(); i++) { + if (mInventory[i] == null) { + if ((aFoundMatching && aAllowMultiOfSameTypeInUsageSlots) || !aFoundMatching) { + mInventory[i] = aStackToMove; + aDidSet = true; + Logger.INFO("Moving new stack to usage slots."); + break; + } + } + } + if (aDidSet) { + Logger.INFO("Depleting input stack size by 1."); + // Depleted one from the original input stack + aStack.stackSize--; + } + return aDidSet; + } + } + return false; + } + + @Override + public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == getBaseMetaTileEntity().getFrontFacing() && isItemValidForUsageSlot(aStack); + } + + /** + * Items that get compared when checking for Usage Slot validity. + * Can return an empty map if isItemValidForUsageSlot() is overridden. + * @return + */ + public abstract AutoMap<ItemStack> getItemsValidForUsageSlots(); + + /** + * Checks if the given item is valid for Usage Slots. + * Can be overridden for easier handling if you already have methods to check this. + * @param aStack + * @return + */ + public boolean isItemValidForUsageSlot(ItemStack aStack) { + if (aStack != null) { + for (ItemStack aValid : getItemsValidForUsageSlots()) { + if (GT_Utility.areStacksEqual(aStack, aValid, true)) { + return true; + } + } + } + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java index 46201e9d81..a4a396e4cf 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java @@ -47,8 +47,8 @@ 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", "Flotation Cell Casings"); // Unused - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); // Unused + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Flotation Cell Casings"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Reinforced Engine Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused @@ -64,6 +64,7 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs GregtechItemList.Casing_SolarTower_Structural.set(new ItemStack(this, 1, 6)); GregtechItemList.Casing_SolarTower_SaltContainment.set(new ItemStack(this, 1, 7)); GregtechItemList.Casing_SolarTower_HeatContainment.set(new ItemStack(this, 1, 8)); + GregtechItemList.Casing_Reinforced_Engine_Casing.set(new ItemStack(this, 1, 9)); } public IIcon getIcon(int aSide, int aMeta) { @@ -90,6 +91,8 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); case 9: return TexturesGtBlock.TEXTURE_CASING_FLOTATION.getIcon(); + case 10: + return TexturesGtBlock.Casing_Material_Talonite.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 cd32d15c3a..93322d2ef1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -389,6 +389,13 @@ public class TexturesGtBlock { //Control Core Bus private static final CustomIcon Internal_Overlay_Hatch_Control_Core = new CustomIcon("iconsets/OVERLAY_CONTROL_CORE_BUS"); public static final CustomIcon Overlay_Hatch_Control_Core = Internal_Overlay_Hatch_Control_Core; + // Milling Ball Bus + private static final CustomIcon Internal_Overlay_Bus_Milling_Balls = new CustomIcon("iconsets/OVERLAY_MILLING_BALL_BUS"); + public static final CustomIcon Overlay_Bus_Milling_Balls = Internal_Overlay_Bus_Milling_Balls; + // Catalyst Bus + private static final CustomIcon Internal_Overlay_Bus_Catalyst = new CustomIcon("iconsets/OVERLAY_CATALYSTS"); + public static final CustomIcon Overlay_Bus_Catalyst = Internal_Overlay_Bus_Catalyst; + //Dimensional private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java index d06b7ed0d1..9dca082807 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java @@ -1,8 +1,13 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; +import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; + +import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import org.apache.commons.lang3.ArrayUtils; + import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; @@ -11,15 +16,19 @@ 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 gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_MillingBalls; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; @@ -30,6 +39,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase { @@ -40,7 +50,8 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase private static ITexture frontFace; private static ITexture frontFaceActive; - + + private ArrayList<GT_MetaTileEntity_Hatch_MillingBalls> mMillingBallBuses = new ArrayList<GT_MetaTileEntity_Hatch_MillingBalls>(); private static final DamageSource mIsaMillDamageSource = new DamageSource("gtpp.grinder").setDamageBypassesArmor(); public GregtechMetaTileEntity_IsaMill(int aID, String aName, String aNameRegional) { @@ -85,6 +96,20 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase return getMaxEfficiency(aStack) > 0; } + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MillingBalls) { + log("Found GT_MetaTileEntity_Hatch_MillingBalls"); + return addToMachineListInternal(mMillingBallBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeDieselEngine.png"); } @@ -96,10 +121,15 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mMillingBallBuses.clear(); + } + } if (aTick % 20 == 0) { checkForEntities(aBaseMetaTileEntity, aTick); } + super.onPostTick(aBaseMetaTileEntity, aTick); } private final AutoMap<BlockPos> mFrontBlockPosCache = new AutoMap<BlockPos>(); @@ -401,4 +431,259 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase public int getEuDiscountForParallelism() { return 0; } + + /* + * Milling Ball Handling + */ + + @Override + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_MillingBalls tHatch : mMillingBallBuses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getContentUsageSlots()); + } + } + return tItems; + } + + + public int getMaxBallDurability(ItemStack aStack) { + return ItemGenericChemBase.getMaxBallDurability(aStack); + } + + private ItemStack findMillingBall(ItemStack[] aItemInputs) { + if (mMillingBallBuses.isEmpty() || mMillingBallBuses.size() > 1) { + return null; + } + else { + GT_MetaTileEntity_Hatch_MillingBalls aBus = mMillingBallBuses.get(0); + if (aBus != null) { + AutoMap<ItemStack> aAvailableItems = aBus.getContentUsageSlots(); + if (!aAvailableItems.isEmpty()) { + for (final ItemStack aInput : aItemInputs) { + if (ItemUtils.isMillingBall(aInput)) { + for (ItemStack aBall : aAvailableItems) { + if (GT_Utility.areStacksEqual(aBall, aInput, true)) { + Logger.INFO("Found a valid milling ball to use."); + return aBall; + } + } + } + } + } + } + } + return null; + } + + + private void damageMillingBall(ItemStack aStack) { + if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * 1))) { + int damage = getMillingBallDamage(aStack) + 1; + log("damage milling ball "+damage); + if (damage >= getMaxBallDurability(aStack)) { + log("consuming milling ball"); + aStack.stackSize -= 1; + } + else { + setDamage(aStack,damage); + } + } + else { + log("not damaging milling ball"); + } + } + + private int getMillingBallDamage(ItemStack aStack) { + return ItemGenericChemBase.getMillingBallDamage(aStack); + } + + private void setDamage(ItemStack aStack,int aAmount) { + ItemGenericChemBase.setMillingBallDamage(aStack, aAmount); + } + + + @Override + 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. + + // 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)); + long tEnergy = getMaxInputEnergy(); + log("Running checkRecipeGeneric(0)"); + + // checks if it has a milling ball with enough durability + ItemStack tMillingBallRecipe = findMillingBall(aItemInputs); + if (tMillingBallRecipe == null) { + log("does not have milling ball"); + return false; + } + + GT_Recipe tRecipe = 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; + } + + aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes); + if (aMaxParallelRecipes == 0) { + log("BAD RETURN - 2"); + return false; + } + + // EU discount + float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + log("aEUPercent "+aEUPercent); + log("mEUt "+tRecipe.mEUt); + + int parallelRecipes = 0; + + log("parallelRecipes: "+parallelRecipes); + log("aMaxParallelRecipes: "+1); + log("tTotalEUt: "+tTotalEUt); + log("tVoltage: "+tVoltage); + log("tEnergy: "+tEnergy); + log("tRecipeEUt: "+tRecipeEUt); + // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits + for (; parallelRecipes < 1 && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) { + if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + log("Broke at "+parallelRecipes+"."); + break; + } + log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); + tTotalEUt += tRecipeEUt; + } + + if (parallelRecipes == 0) { + log("BAD RETURN - 3"); + return false; + } + + // -- 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); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + 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()]); + + + // Damage Milling ball once all is said and done. + if (tMillingBallRecipe != null) { + log("damaging milling ball"); + damageMillingBall(tMillingBallRecipe); + } + + // 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; + } + } 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 index 2d2aa4ab53..b04a068376 100644 --- 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 @@ -81,13 +81,18 @@ public class GregtechMTE_FrothFlotationPond extends GregtechMeta_MultiBlockBase return GregTech_API.sSoundList.get(Integer.valueOf(207)); } + + @Override + public boolean isFacingValid(final byte aFacing) { + Logger.INFO("Facing: "+aFacing); + return aFacing == 1; + } + @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; - } + int aID = TAE.getIndexFromPage(2, 1); + 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)}; } @@ -105,11 +110,6 @@ public class GregtechMTE_FrothFlotationPond extends GregtechMeta_MultiBlockBase } @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override public int getMaxParallelRecipes() { return 2; } @@ -122,8 +122,11 @@ public class GregtechMTE_FrothFlotationPond extends GregtechMeta_MultiBlockBase @Override public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + this.mLevel = 0; - + if (this.mLevel == 0) { + return false; + } // Get Facing direction int mCurrentDirectionX; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 81d1581724..9064921c6a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -21,11 +21,13 @@ import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -42,6 +44,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { private int mPipeCasingTier = 0; private int mCoilTier = 0; + private ArrayList<GT_MetaTileEntity_Hatch_Catalysts> mCatalystBuses = new ArrayList<GT_MetaTileEntity_Hatch_Catalysts>(); + public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -664,6 +668,19 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return 0; } + @Override + public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Catalysts) { + log("Found GT_MetaTileEntity_Hatch_Catalysts"); + return addToMachineListInternal(mCatalystBuses, aMetaTileEntity, aBaseCasingIndex); + } + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + public int getMachineCasingTierCheck(IGregTechTileEntity aBaseMetaTileEntity, int xDir, int zDir) { Block aInitStructureCheck; int aInitStructureCheckMeta; @@ -734,11 +751,16 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate == 1 || this.mStartUpCheck == 1) { + this.mCatalystBuses.clear(); + } + } // Silly Client Syncing if (aBaseMetaTileEntity.isClientSide()) { this.mSolidCasingTier = getCasingTierOnClientSide(); } + super.onPostTick(aBaseMetaTileEntity, aTick); } @Override @@ -771,6 +793,13 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { long tEnergy = getMaxInputEnergy(); log("Running checkRecipeGeneric(0)"); + // checks if it has a catalyst with enough durability + ItemStack tCatalystRecipe = findCatalyst(aItemInputs); + if (tCatalystRecipe == null) { + log("does not have catalyst"); + return false; + } + GT_Recipe tRecipe = findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); @@ -801,11 +830,10 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { // checks if it has enough catalyst durabilety ArrayList<ItemStack>tCatalysts = null; int tMaxParrallelCatalyst = aMaxParallelRecipes; - ItemStack tCatalystRecipe = findCatalyst(tRecipe.mInputs); if (tCatalystRecipe != null) { - log("has catalyst"); tCatalysts = new ArrayList<ItemStack>(); - tMaxParrallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes,tCatalysts); + tMaxParrallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes, tCatalysts); + log("Can process "+tMaxParrallelCatalyst+" recipes. If less than "+aMaxParallelRecipes+", catalyst does not have enough durability."); } if (tMaxParrallelCatalyst == 0) { @@ -842,20 +870,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return false; } - if (tCatalysts != null) { - log("damaging catalyst"); - for (int j = 0;j<parallelRecipes;j++) { - log("j = "+j); - for (int i = 0;i<tCatalysts.size();i++) { - log("i = "+i); - if (tCatalysts.get(i) != null && tCatalysts.get(i).stackSize != 0) { - damageCatalyst(tCatalysts.get(i)); - break; - } - } - } - } - // -- Try not to fail after this point - inputs have already been consumed! -- @@ -942,6 +956,12 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + // Damage catalyst once all is said and done. + if (tCatalystRecipe != null) { + log("damaging catalyst"); + damageCatalyst(tCatalystRecipe, parallelRecipes); + } + // Commit outputs this.mOutputItems = tOutputItems; this.mOutputFluids = tOutputFluids; @@ -954,23 +974,12 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { return true; } - private int getCatalysts(ItemStack[] aItemInputs,ItemStack aRecipeCatalyst,int aMaxParrallel,ArrayList<ItemStack> aOutPut) { + private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParrallel, ArrayList<ItemStack> aOutPut) { int allowedParrallel = 0; for (final ItemStack aInput : aItemInputs) { - if (aRecipeCatalyst.isItemEqual(aInput)) { - if (aInput.stackSize == 1) { - int damage = getDamage(aInput) + aMaxParrallel; - if (damage > getMaxCatalystDurability() ) { - aOutPut.add(aInput); - allowedParrallel += aMaxParrallel + (getMaxCatalystDurability() - damage); - if (allowedParrallel >aMaxParrallel ) { - return aMaxParrallel; - } - continue; - } - } - aOutPut.add(aInput); - return aMaxParrallel; + if (aRecipeCatalyst.isItemEqual(aInput)) { + int aDurabilityRemaining = getMaxCatalystDurability() - getDamage(aInput); + return Math.min(aMaxParrallel, aDurabilityRemaining); } } return allowedParrallel; @@ -990,42 +999,36 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { } - private void damageCatalyst(ItemStack aStack) { - if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { - int damage = getDamage(aStack) + 1; - log("damage catalyst "+damage); - if (damage >= getMaxCatalystDurability()) { - log("consume catalyst"); - ItemStack emptyCatalyst = CI.getEmptyCatalyst(1); - addOutput(emptyCatalyst); - setDamage(aStack,0); - aStack.stackSize -= 1; + private void damageCatalyst(ItemStack aStack, int parallelRecipes) { + for (int i=0; i<parallelRecipes; i++){ + if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { + int damage = getDamage(aStack) + 1; + log("damage catalyst "+damage); + if (damage >= getMaxCatalystDurability()) { + log("consume catalyst"); + addOutput(CI.getEmptyCatalyst(1)); + aStack = null; + } + else { + log("damaging catalyst"); + setDamage(aStack, damage); + } } else { - setDamage(aStack,damage); + log("not consuming catalyst"); } - } - else { - log("not consuming catalyst"); } + + + } private int getDamage(ItemStack aStack) { - if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setInteger("Damage", 0); - tagMain.setTag("catalyst", tagNBT); - aStack.setTagCompound(tagMain); - } - NBTTagCompound aNBT = aStack.getTagCompound(); - return aNBT.getCompoundTag("catalyst").getInteger("Damage"); + return ItemGenericChemBase.getCatalystDamage(aStack); } private void setDamage(ItemStack aStack,int aAmount) { - NBTTagCompound aNBT = aStack.getTagCompound(); - aNBT = aNBT.getCompoundTag("catalyst"); - aNBT.setInteger("Damage", aAmount); + ItemGenericChemBase.setCatalystDamage(aStack, aAmount); } @@ -1081,6 +1084,23 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { + /* + * Catalyst Handling + */ + + + + @Override + public ArrayList<ItemStack> getStoredInputs() { + ArrayList<ItemStack> tItems = super.getStoredInputs(); + for (GT_MetaTileEntity_Hatch_Catalysts tHatch : mCatalystBuses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + tItems.addAll(tHatch.getContentUsageSlots()); + } + } + return tItems; + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java index 2c9f1d1943..08901a1a3b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_Catalysts; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae.GregtechMTE_AlgaePondBase; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant.GregtechMTE_ChemicalPlant; @@ -22,7 +23,8 @@ public class GregtechAlgaeContent { // Chemical Plant GregtechItemList.ChemicalPlant_Controller.set(new GregtechMTE_ChemicalPlant(998, "chemicalplant.controller.tier.single", "ExxonMobil Chemical Plant").getStackForm(1L)); - + + GregtechItemList.Bus_Catalysts.set((new GT_MetaTileEntity_Hatch_Catalysts(31030, "hatch.catalysts", "Catalyst Housing")).getStackForm(1L)); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java index 9c5fb483a7..8719061f7c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIsaMill.java @@ -1,13 +1,22 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers.GT_MetaTileEntity_Hatch_MillingBalls; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IsaMill; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_FrothFlotationPond; public class GregtechIsaMill { public static void run(){ + + Logger.INFO("Gregtech5u Content | Registering Milling Content."); - GregtechItemList.Controller_IsaMill_Controller.set(new GregtechMetaTileEntity_IsaMill(31027, "gtpp.multimachine.isamill", "IsaMill Grinding Machine").getStackForm(1L)); + GregtechItemList.Controller_IsaMill.set(new GregtechMetaTileEntity_IsaMill(31027, "gtpp.multimachine.isamill", "IsaMill Grinding Machine").getStackForm(1L)); + GregtechItemList.Controller_Flotation_Cell.set(new GregtechMTE_FrothFlotationPond(31028, "gtpp.multimachine.flotationcell", "Flotation Cell Regulator").getStackForm(1L)); + + // Milling Ball Bus + GregtechItemList.Bus_Milling_Balls.set((new GT_MetaTileEntity_Hatch_MillingBalls(31029, "hatch.milling", "Ball Housing")).getStackForm(1L)); } |