diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api')
4 files changed, 163 insertions, 27 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 898565352b..da2b24e38f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -278,7 +278,13 @@ public enum GregtechItemList implements GregtechItemContainer { //Tesla Tower TelsaTower, - Battery_Gem_1, Battery_Gem_2, Battery_Gem_3, + Battery_Gem_1, Battery_Gem_2, Battery_Gem_3, + + //Super Tier Chests + Super_Chest_LV, Super_Chest_MV, Super_Chest_HV, Super_Chest_EV, Super_Chest_IV, + + //Fish Pond + Casing_FishPond, Industrial_FishingPond, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java new file mode 100644 index 0000000000..8caf8fe575 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java @@ -0,0 +1,69 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; + +import java.util.Iterator; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +public class CONTAINER_SuperChest extends GT_ContainerMetaTile_Machine { + public int mContent = 0; + + public CONTAINER_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 0, 80, 17)); + this.addSlotToContainer(new GT_Slot_Output(this.mTileEntity, 1, 80, 53)); + this.addSlotToContainer(new GT_Slot_Render(this.mTileEntity, 2, 59, 42)); + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) { + if (this.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_TieredChest) { + this.mContent = ((GT_MetaTileEntity_TieredChest) this.mTileEntity.getMetaTileEntity()).mItemCount; + } else { + this.mContent = 0; + } + + Iterator var2 = this.crafters.iterator(); + + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 100, this.mContent & 65535); + var1.sendProgressBarUpdate(this, 101, this.mContent >>> 16); + } + + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 100 : + this.mContent = this.mContent & -65536 | par2; + break; + case 101 : + this.mContent = this.mContent & 65535 | par2 << 16; + } + + } + + public int getSlotCount() { + return 2; + } + + public int getShiftClickSlotCount() { + return 1; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java new file mode 100644 index 0000000000..259f589950 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_SuperChest.java @@ -0,0 +1,37 @@ +package gtPlusPlus.xmod.gregtech.api.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; + +public class GUI_SuperChest extends GT_GUIContainerMetaTile_Machine { + private final String mName; + + public GUI_SuperChest(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, + String aName) { + super(new CONTAINER_SuperChest(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/BasicTank.png"); + this.mName = aName; + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, + 4210752); + this.fontRendererObj.drawString(this.mName, 8, 6, 4210752); + if (this.mContainer != null) { + this.fontRendererObj.drawString("Item Amount", 10, 20, 16448255); + this.fontRendererObj.drawString( + GT_Utility.parseNumberToString(((CONTAINER_SuperChest) this.mContainer).mContent), 10, 30, + 16448255); + } + + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +}
\ No newline at end of file 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 0447cbcd20..e0da8e9fc2 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 @@ -5,12 +5,13 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import gregtech.api.GregTech_API; import gregtech.api.util.GT_Utility; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.ArrayUtils; import gregtech.api.enums.Materials; +import gregtech.api.gui.GT_Container_MultiMachine; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; @@ -19,9 +20,7 @@ import gregtech.api.metatileentity.implementations.*; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.PollutionUtils; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; @@ -57,21 +56,27 @@ GT_MetaTileEntity_MultiBlockBase { .getMetaTileEntity() == aMetaTileEntity) && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); } + + public abstract boolean hasSlotInGUI(); @Override - public Object getServerGUI(final int aID, - final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_MultiMachine(aPlayerInventory, - aBaseMetaTileEntity); + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + if (hasSlotInGUI()) { + return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } + else { + return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } } @Override - public Object getClientGUI(final int aID, - final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, - this.getLocalName(), "MultiblockDisplay.png"); + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + if (hasSlotInGUI()) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MultiblockDisplay.png"); + } + else { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MultiblockDisplay.png"); + } } @Override @@ -115,8 +120,10 @@ GT_MetaTileEntity_MultiBlockBase { public String getSound() { return ""; } - public boolean canBufferOutputs(final GT_Recipe aRecipe) { - // Count slots available in hatches + public boolean canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) { + // Count slots available in output buses + ArrayList<ItemStack> tBusStacks = new ArrayList<>(); + int tEmptySlots = 0; for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) { if (!isValidMetaTileEntity(tBus)) { @@ -127,12 +134,26 @@ GT_MetaTileEntity_MultiBlockBase { if (tBus.getStackInSlot(i) == null) { tEmptySlots++; } + else { + tBusStacks.add(tBus.getStackInSlot(i)); + } } } - // TODO: Check if any of the output stacks can stack with the stacks in the hatches? + int slotsNeeded = aRecipe.mOutputs.length; + for (final ItemStack tRecipeOutput: aRecipe.mOutputs) { + int amount = tRecipeOutput.stackSize * aParallelRecipes; + for (final ItemStack tBusStack : tBusStacks) { + if (GT_Utility.areStacksEqual(tBusStack, tRecipeOutput)) { + if (tBusStack.stackSize + amount <= tBusStack.getMaxStackSize()) { + slotsNeeded--; + break; + } + } + } + } // Enough open slots? - if (tEmptySlots < aRecipe.mOutputs.length) return false; + if (tEmptySlots < slotsNeeded) return false; // For each output fluid, make sure an output hatch can accept it. for (FluidStack tRecipeFluid: aRecipe.mFluidOutputs) { @@ -176,13 +197,17 @@ GT_MetaTileEntity_MultiBlockBase { ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { + // 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[]{}; - // Based on the Processing Array. A bit overkill, but very flexible. long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - int parallelRecipes = 0; GT_Recipe tRecipe = this.getRecipeMap().findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, @@ -195,7 +220,7 @@ GT_MetaTileEntity_MultiBlockBase { return false; } - if (!this.canBufferOutputs(tRecipe)) { + if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { return false; } @@ -203,12 +228,8 @@ GT_MetaTileEntity_MultiBlockBase { float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; float tTotalEUt = 0.0f; - // Reset outputs and progress stats - this.mEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[]{}; - this.mOutputFluids = new FluidStack[]{}; - + int parallelRecipes = 0; + // 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)) { @@ -221,6 +242,9 @@ GT_MetaTileEntity_MultiBlockBase { 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); |