diff options
author | Sphyix <masifede2@gmail.com> | 2021-11-21 12:58:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-21 12:58:56 +0100 |
commit | abeecd2da02c7d38cb1c5b6e2fd5517c6f8a994b (patch) | |
tree | 64c5960fc9a0e9c7a4bb368adfb6fa6e9b5aa071 /src/main/java/gregtech/common/tileentities | |
parent | 01c243ee9f58c3f64fc883f931ad9a81813f894f (diff) | |
parent | 81f0b4801dfb0bd2d2a863e7a60f27af0daba463 (diff) | |
download | GT5-Unofficial-abeecd2da02c7d38cb1c5b6e2fd5517c6f8a994b.tar.gz GT5-Unofficial-abeecd2da02c7d38cb1c5b6e2fd5517c6f8a994b.tar.bz2 GT5-Unofficial-abeecd2da02c7d38cb1c5b6e2fd5517c6f8a994b.zip |
Merge branch 'GTNewHorizons:experimental' into experimental
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
21 files changed, 548 insertions, 345 deletions
diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java index 774639401a..480367095c 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java @@ -5,7 +5,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Buffer; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_Utility; import gregtech.common.gui.GT_Container_ChestBuffer; import gregtech.common.gui.GT_GUIContainer_ChestBuffer; import net.minecraft.entity.player.InventoryPlayer; @@ -70,7 +69,7 @@ public class GT_MetaTileEntity_ChestBuffer extends GT_MetaTileEntity_Buffer { protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { if (aTimer % tickRate[mTier] > 0) return; - if(aBaseMetaTileEntity.hasInventoryBeenModified()) { + if(this.bSortStacks && aBaseMetaTileEntity.hasInventoryBeenModified()) { fillStacksIntoFirstSlots(); } // mSuccess will be negative if the call is caused by the %200 aTimer, always try to push. Otherwise it will be positive. diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java index 4fb9deb5b4..96b991e767 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java @@ -175,7 +175,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa @Override public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCover) { - return GregTech_API.getCoverBehavior(aCover.toStack()).isSimpleCover(); + return GregTech_API.getCoverBehaviorNew(aCover.toStack()).isSimpleCover(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index 4d7a6c4af5..6d4b160a86 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -176,18 +176,21 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { moveOneDown(aBaseMetaTileEntity); } else { ChunkPosition oreBlockPos; - Block block; + int x = 0, y = 0, z = 0; + Block oreBlock; + int oreBlockMetadata = 0; do { oreBlockPos = oreBlockPositions.remove(0); - block = aBaseMetaTileEntity.getBlockOffset(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); + oreBlock = aBaseMetaTileEntity.getBlockOffset(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); + x = aBaseMetaTileEntity.getXCoord() + oreBlockPos.chunkPosX; + y = aBaseMetaTileEntity.getYCoord() + oreBlockPos.chunkPosY; + z = aBaseMetaTileEntity.getZCoord() + oreBlockPos.chunkPosZ; + oreBlockMetadata = getBaseMetaTileEntity().getWorld().getBlockMetadata(x, y, z); } // someone else might have removed the block - while (block == Blocks.air && !oreBlockPositions.isEmpty()); + while (!GT_Utility.isOre(oreBlock, oreBlockMetadata) && !oreBlockPositions.isEmpty()); - if (block != Blocks.air) { - mineBlock(aBaseMetaTileEntity, block, - aBaseMetaTileEntity.getXCoord() + oreBlockPos.chunkPosX, - aBaseMetaTileEntity.getYCoord() + oreBlockPos.chunkPosY, - aBaseMetaTileEntity.getZCoord() + oreBlockPos.chunkPosZ); + if (GT_Utility.isOre(oreBlock, oreBlockMetadata)) { + mineBlock(aBaseMetaTileEntity, oreBlock, x, y, z); } } } @@ -265,7 +268,15 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { mOutputItems[0] = drops.get(0); if (drops.size() > 1) mOutputItems[1] = drops.get(1); - aBaseMetaTileEntity.getWorld().setBlockToAir(x, y, z); + + short metaData = 0; + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntity(x, y, z); + if (tTileEntity instanceof GT_TileEntity_Ores) { + metaData = ((GT_TileEntity_Ores) tTileEntity).mMetaData; + } + + ItemStack cobble = GT_Utility.getCobbleForOre(block, metaData); + aBaseMetaTileEntity.getWorld().setBlock(x, y, z, Block.getBlockFromItem(cobble.getItem()), cobble.getItemDamage(), 3); if (debugBlockMiner) GT_Log.out.println("MINER: Mining GT ore block at " + x + " " + y + " " + z); } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java index 60056ec39d..79b363fac3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java @@ -144,16 +144,15 @@ public class GT_MetaTileEntity_PotionBrewer extends GT_MetaTileEntity_BasicMachi } private int setOutput(String aFluidName) { + if (getFillableStack().amount < 750) { + return 0; + } + this.mOutputFluid = FluidRegistry.getFluidStack(aFluidName, 750); if (this.mOutputFluid == null) { this.mOutputFluid = FluidRegistry.getFluidStack("potion.mundane", getFillableStack().amount); - getInputAt(0).stackSize -= 1; - getFillableStack().amount = 0; - return 2; - } - if (getFillableStack().amount < 750) { - return 0; } + getInputAt(0).stackSize -= 1; getFillableStack().amount -= 750; return 2; @@ -171,6 +170,6 @@ public class GT_MetaTileEntity_PotionBrewer extends GT_MetaTileEntity_BasicMachi @Override public int getCapacity() { - return 750; + return 6000; } } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java index eba61ad1b1..1573c951eb 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java @@ -15,6 +15,7 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.objects.ItemData; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_AssemblyLineUtils; import gregtech.api.util.GT_Assemblyline_Server; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; @@ -253,6 +254,7 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { if (failScanner) { return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } + String s = tRecipe.mOutput.getDisplayName(); if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { @@ -261,92 +263,19 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { s = tRecipe.mOutput.getDisplayName(); } this.mOutputItems[0] = GT_Utility.copyAmount(1L, getSpecialSlot()); - //remove possible old NBTTagCompound - this.mOutputItems[0].setTagCompound(new NBTTagCompound()); - GT_Utility.ItemNBT.setBookTitle(this.mOutputItems[0], s + " Construction Data"); + - NBTTagCompound tNBT = this.mOutputItems[0].getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); - } - - tNBT.setTag("output", tRecipe.mOutput.writeToNBT(new NBTTagCompound())); - tNBT.setInteger("time", tRecipe.mDuration); - tNBT.setInteger("eu", tRecipe.mEUt); - for (int i = 0; i < tRecipe.mInputs.length; i++) { - tNBT.setTag("" + i, tRecipe.mInputs[i].writeToNBT(new NBTTagCompound())); - } - for (int i = 0; i < tRecipe.mOreDictAlt.length; i++) { - if (tRecipe.mOreDictAlt[i] != null && tRecipe.mOreDictAlt[i].length > 0) { - tNBT.setInteger("a" + i, tRecipe.mOreDictAlt[i].length); - for (int j = 0; j < tRecipe.mOreDictAlt[i].length; j++) { - tNBT.setTag("a" + i + ":" + j, tRecipe.mOreDictAlt[i][j].writeToNBT(new NBTTagCompound())); - } - } - } - for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { - tNBT.setTag("f" + i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound())); - } - tNBT.setString("author", "Assembling Line Recipe Generator"); - NBTTagList tNBTList = new NBTTagList(); - s = tRecipe.mOutput.getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mOutput.getDisplayName()); - if (s == null) - s = tRecipe.mOutput.getDisplayName(); - } - tNBTList.appendTag(new NBTTagString("Construction plan for " + tRecipe.mOutput.stackSize + " " + s + ". Needed EU/t: " + tRecipe.mEUt + " Production time: " + (tRecipe.mDuration / 20))); - for (int i = 0; i < tRecipe.mInputs.length; i++) { - if (tRecipe.mOreDictAlt[i] != null) { - int count = 0; - StringBuilder tBuilder = new StringBuilder("Input Bus " + (i + 1) + ": "); - for (ItemStack tStack : tRecipe.mOreDictAlt[i]) { - if (tStack != null) { - s = tStack.getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(tStack.getDisplayName()); - if (s == null) - s = tStack.getDisplayName(); - } - - - tBuilder.append(count == 0 ? "" : "\nOr ").append(tStack.stackSize).append(" ").append(s); - count++; - } - } - if (count > 0) tNBTList.appendTag(new NBTTagString(tBuilder.toString())); - } else if (tRecipe.mInputs[i] != null) { - s = tRecipe.mInputs[i].getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mInputs[i].getDisplayName()); - if (s == null) - s = tRecipe.mInputs[i].getDisplayName(); - } - tNBTList.appendTag(new NBTTagString("Input Bus " + (i + 1) + ": " + tRecipe.mInputs[i].stackSize + " " + s)); - } - } - for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { - if (tRecipe.mFluidInputs[i] != null) { - s = tRecipe.mFluidInputs[i].getLocalizedName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mFluidInputs[i].getLocalizedName()); - if (s == null) - s = tRecipe.mFluidInputs[i].getLocalizedName(); - } - tNBTList.appendTag(new NBTTagString("Input Hatch " + (i + 1) + ": " + tRecipe.mFluidInputs[i].amount + "L " + s)); - } + // Use Assline Utils + if (GT_AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(this.mOutputItems[0], tRecipe)) { + aStack.stackSize -= 1; + calculateOverclockedNess(30, tRecipe.mResearchTime); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + getSpecialSlot().stackSize -= 1; + return 2; } - tNBT.setTag("pages", tNBTList); - - this.mOutputItems[0].setTagCompound(tNBT); - - aStack.stackSize -= 1; - calculateOverclockedNess(30, tRecipe.mResearchTime); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - getSpecialSlot().stackSize -= 1; - return 2; + } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java index 64651a3fc4..14663f7d68 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java @@ -46,6 +46,7 @@ import java.util.LinkedList; import java.util.Queue; public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_MetaTileEntity_BasicHull_NonElectric { + public static int minimalDistancePoints = 64; protected GT_MetaTileEntity_LongDistancePipelineBase mTarget = null, mSender = null; protected ChunkCoordinates mTargetPos = null; @@ -77,6 +78,8 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta aNBT.getInteger("target.y"), aNBT.getInteger("target.z") ); + if (getDistanceToSelf(mTargetPos) < minimalDistancePoints) + mTargetPos = null; } } @@ -210,9 +213,13 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta tGtTile.getFacingOffset((BaseMetaTileEntity)tTileEntity, ((BaseMetaTileEntity) tTileEntity).getFrontFacing()) )) { // If it's the same class, and we've scanned a wire in front of it (the input side), we've found our target - mTarget = tGtTile; - mTargetPos = tGtTile.getCoords(); - return; + // still need to check if it's distant enough + int distance = getDistanceToSelf(aCoords); + if (distance > minimalDistancePoints) { + mTarget = tGtTile; + mTargetPos = tGtTile.getCoords(); + return; + } } // Remove this block from the visited because we might end up back here from another wire that IS connected to the @@ -224,7 +231,13 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta } } - + + protected int getDistanceToSelf(ChunkCoordinates aCoords) { + return Math.abs(getBaseMetaTileEntity().getXCoord() - aCoords.posX) + + Math.abs(getBaseMetaTileEntity().getYCoord() - aCoords.posY) / 2 + + Math.abs(getBaseMetaTileEntity().getZCoord() - aCoords.posZ); + } + public ChunkCoordinates getFacingOffset(IGregTechTileEntity gt_tile, byte aSide) { return new ChunkCoordinates( gt_tile.getOffsetX(aSide, 1), gt_tile.getOffsetY(aSide, 1), gt_tile.getOffsetZ(aSide, 1) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 0a19536bf1..c2460213c8 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -17,8 +17,10 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_AssemblyLineUtils; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -156,117 +158,111 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu @Override public boolean checkRecipe(ItemStack aStack) { - if (GT_Values.D1) - GT_FML_LOGGER.info("Start ALine recipe check"); + if (GT_Values.D1) { + GT_FML_LOGGER.info("Start ALine recipe check"); + } ArrayList<ItemStack> tDataStickList = getDataItems(2); - if (tDataStickList.isEmpty()) return false; - if (GT_Values.D1) - GT_FML_LOGGER.info("Stick accepted, " + tDataStickList.size() + " Data Sticks found"); + if (tDataStickList.isEmpty()) { + return false; + } + if (GT_Values.D1) { + GT_FML_LOGGER.info("Stick accepted, " + tDataStickList.size() + " Data Sticks found"); + } - ItemStack[] tStack = new ItemStack[15]; - FluidStack[] tFluids = new FluidStack[4]; + ItemStack[] tStack = null; + FluidStack[] tFluids = null; boolean findRecipe = false; - nextDS: + + nextDataStick: for (ItemStack tDataStick : tDataStickList) { - NBTTagCompound tTag = tDataStick.getTagCompound(); - if (tTag == null) - continue; + GT_Recipe_AssemblyLine aFoundRecipe = GT_AssemblyLineUtils.findAssemblyLineRecipeFromDataStick(tDataStick); + + // Check if the recipe on the data stick is the current recipe for it's given output, if not we update it and continue to next. + if (!GT_AssemblyLineUtils.processDataStick(tDataStick)) { + continue; + } + + tStack = aFoundRecipe.mInputs; + tFluids = aFoundRecipe.mFluidInputs; + + // So here we check against the recipe found on the data stick. + // If we run into missing buses/hatches or bad inputs, we go to the next data stick. + // This check only happens if we have a valid up to date data stick. + + // Check Inputs allign + int aItemCount = aFoundRecipe.mInputs.length; for (int i = 0; i < 15; i++) { - int count = tTag.getInteger("a" + i); - if (!tTag.hasKey("" + i) && count <= 0) - continue; - if (mInputBusses.get(i) == null) { - continue nextDS; - } - - ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); - boolean flag = true; - if (count > 0) { - for (int j = 0; j < count; j++) { - tStack[i] = GT_Utility.loadItem(tTag, "a" + i + ":" + j); - if (tStack[i] == null) continue; - if (GT_Values.D1) - GT_FML_LOGGER.info("Item " + i + " : " + tStack[i].getUnlocalizedName()); - if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { - flag = false; - break; - } - } - } - if (flag) { - tStack[i] = GT_Utility.loadItem(tTag, "" + i); - if (tStack[i] == null) { - flag = false; - continue; - } - if (GT_Values.D1) - GT_FML_LOGGER.info("Item " + i + " : " + tStack[i].getUnlocalizedName()); - if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { - flag = false; + if (i >= aItemCount) { + continue; + } + else { + if (mInputBusses.get(i) == null) { + continue nextDataStick; } - } - if (GT_Values.D1) - GT_FML_LOGGER.info(i + (flag ? " not accepted" : " accepted")); - if (flag) - continue nextDS; - } - - if (GT_Values.D1) GT_FML_LOGGER.info("All Items done, start fluid check"); - for (int i = 0; i < 4; i++) { - if (!tTag.hasKey("f" + i)) continue; - tFluids[i] = GT_Utility.loadFluid(tTag, "f" + i); - if (tFluids[i] == null) continue; - if (GT_Values.D1) - GT_FML_LOGGER.info("Fluid " + i + " " + tFluids[i].getUnlocalizedName()); - if (mInputHatches.get(i) == null) { - continue nextDS; - } - FluidStack fluidInHatch = mInputHatches.get(i).mFluid; - if (!GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) { - if (GT_Values.D1) - GT_FML_LOGGER.info(i + " not accepted"); - continue nextDS; - } - if (GT_Values.D1) - GT_FML_LOGGER.info(i + " accepted"); + else { + ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); + if (!GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) || tStack[i].stackSize <= stackInSlot.stackSize) { + continue nextDataStick; + } + if (GT_Values.D1) { + GT_FML_LOGGER.info("Item: " + i + " accepted"); + } + } + } } - - if (GT_Values.D1) - GT_FML_LOGGER.info("Input accepted, check other values"); - if (!tTag.hasKey("output")) - continue; - mOutputItems = new ItemStack[]{GT_Utility.loadItem(tTag, "output")}; - if (mOutputItems[0] == null || !GT_Utility.isStackValid(mOutputItems[0])) - continue; - - if (!tTag.hasKey("time")) - continue; - int tMaxProgressTime = tTag.getInteger("time"); - if (tMaxProgressTime <= 0) - continue; - - if (!tTag.hasKey("eu")) - continue; - - if (GT_Values.D1) GT_FML_LOGGER.info("Check overclock"); - - calculateOverclockedNessMulti(tTag.getInteger("eu"), tMaxProgressTime, 1, getMaxInputVoltage()); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { - if (GT_Values.D1) GT_FML_LOGGER.info("Recipe too OP"); - continue; + + // Check Fluid Inputs allign + int aFluidCount = aFoundRecipe.mFluidInputs.length; + for (int i = 0; i < 4; i++){ + if (i >= aFluidCount) { + continue; + } + else { + if (mInputHatches.get(i) == null) { + continue nextDataStick; + } + else { + FluidStack fluidInHatch = mInputHatches.get(i).mFluid; + if (!GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) { + continue nextDataStick; + } + if (GT_Values.D1) { + GT_FML_LOGGER.info("Fluid:" + i + " accepted"); + } + } + } } - - if (GT_Values.D1) GT_FML_LOGGER.info("Find avaiable recipe"); - findRecipe = true; - break; + + if (GT_Values.D1) { + GT_FML_LOGGER.info("Check overclock"); + } + calculateOverclockedNessMulti(aFoundRecipe.mEUt, aFoundRecipe.mDuration, 1, getMaxInputVoltage()); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { + if (GT_Values.D1) { + GT_FML_LOGGER.info("Recipe too OP"); + } + continue; + } + if (GT_Values.D1) { + GT_FML_LOGGER.info("Find available recipe"); + } + findRecipe = true; } - if (!findRecipe) return false; + + // Best not to run this recipe. + if (!findRecipe || tStack == null || tStack.length <= 0 || tFluids == null || tFluids.length <= 0) { + return false; + } + - if (GT_Values.D1) GT_FML_LOGGER.info("All checked start consuming inputs"); + if (GT_Values.D1) { + GT_FML_LOGGER.info("All checked start consuming inputs"); + } for (int i = 0; i < 15; i++) { - if (tStack[i] == null) - continue; + if (tStack[i] == null) { + continue; + } ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); stackInSlot.stackSize -= tStack[i].stackSize; } @@ -280,13 +276,15 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu } } - if (this.mEUt > 0) - this.mEUt = -this.mEUt; + if (this.mEUt > 0) { + this.mEUt = -this.mEUt; + } this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; updateSlots(); - if (GT_Values.D1) - GT_FML_LOGGER.info("Recipe sucessfull"); + if (GT_Values.D1) { + GT_FML_LOGGER.info("Recipe sucessfull"); + } return true; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java index 905cb7c2f1..e58ec25bd0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java @@ -61,8 +61,9 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas .addController("Top center") .addCasingInfo("Plascrete", 20) .addStructureInfo(GT_Values.cleanroomGlass + "% of the Plascrete can be replaced with Reinforced Glass")//check + .addStructureInfo("Other material can be used in place of Plascrete. See config for detail")//check .addOtherStructurePart("Filter Machine Casing", "Top besides controller and edges") - .addEnergyHatch("LV or MV, any casing")//check + .addEnergyHatch("Any casing. Exactly one.")//check .addMaintenanceHatch("Any casing") .addStructureInfo("1x Reinforced Door (keep closed or efficiency will reduce)") .addStructureInfo("Up to 10 Machine Hulls for Item & Energy transfer through walls") diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java index e7634c6b62..fe68b13152 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -225,6 +225,7 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan mOutputHatchesByLayer.forEach(List::clear); mHeight = 1; mTopLayerFound = false; + mCasing = 0; // check base if (!checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0)) @@ -275,7 +276,7 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan @Override public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0); - int tTotalHeight = Math.max(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height + int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height for (int i = 1; i < tTotalHeight - 1; i++) { buildPiece(STRUCTURE_PIECE_LAYER_HINT, stackSize, hintsOnly, 1, i, 0); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index b55ae939b6..43498a59fe 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -12,6 +12,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.render.TextureFactory; @@ -19,8 +20,10 @@ import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_StructureUtility; import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; @@ -42,6 +45,7 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_AbstractMultiFurnace<GT_MetaTileEntity_ElectricBlastFurnace> implements IConstructable { private int mHeatingCapacity = 0; + private boolean isBussesSeparate = false; protected final ArrayList<GT_MetaTileEntity_Hatch_Output> mPollutionOutputHatches = new ArrayList<>(); protected final FluidStack[] pollutionFluidStacks = {Materials.CarbonDioxide.getGas(1000), Materials.CarbonMonoxide.getGas(1000), Materials.SulfurDioxide.getGas(1000)}; @@ -141,36 +145,60 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab @Override public boolean checkRecipe(ItemStack aStack) { - ItemStack[] tInputs = getCompactedInputs(); - FluidStack[] tFluids = getCompactedFluids(); + if(isBussesSeparate) { + FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); + for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { + ArrayList<ItemStack> tInputs = new ArrayList<>(); + tBus.mRecipeMap = getRecipeMap(); + + if (isValidMetaTileEntity(tBus)) { + for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { + tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + ItemStack[] tItems = tInputs.toArray(new ItemStack[0]); + if (processRecipe(tItems, tFluids)) { + return true; + } + } + return false; + } else { + return processRecipe(getCompactedInputs(), getCompactedFluids()); + } - if (tInputs.length <= 0) + } + protected boolean processRecipe(ItemStack[] tItems, FluidStack[] tFluids) { + if (tItems.length <= 0) return false; long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBlastRecipes.findRecipe( getBaseMetaTileEntity(), false, V[tTier], tFluids, - tInputs + tItems ); if (tRecipe == null) return false; if (this.mHeatingCapacity < tRecipe.mSpecialValue) return false; - if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) + if (!tRecipe.isRecipeInputEqual(true, tFluids, tItems)) + return false; + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return false; this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; + int tHeatCapacityDivTiers = (mHeatingCapacity - tRecipe.mSpecialValue) / 900; byte overclockCount = calculateOverclockednessEBF(tRecipe.mEUt, tRecipe.mDuration, tVoltage); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; if (this.mEUt > 0) { this.mEUt = (-this.mEUt); } @@ -191,7 +219,6 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab updateSlots(); return true; } - /** * Calcualtes overclocked ness using long integers * @@ -385,4 +412,22 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1,3,0); } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + isBussesSeparate = !isBussesSeparate; + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + isBussesSeparate); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("isBussesSeparate", isBussesSeparate); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + isBussesSeparate = aNBT.getBoolean("isBussesSeparate"); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java index 63b536fc72..87eddb7e13 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java @@ -11,6 +11,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMul import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Single_Recipe_Check; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -123,68 +124,98 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_En } @Override + public boolean supportsSingleRecipeLocking() { + return true; + } + + @Override public boolean checkRecipe(ItemStack aStack) { - ArrayList<ItemStack> tInputList = getStoredInputs(); - int tInputList_sS = tInputList.size(); - for (int i = 0; i < tInputList_sS - 1; i++) { - for (int j = i + 1; j < tInputList_sS; j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - tInputList_sS = tInputList.size(); - } else { - tInputList.remove(i--); - tInputList_sS = tInputList.size(); - break; + long tVoltage = getMaxInputVoltage(); + byte tier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe; + + if (mLockedToSingleRecipe && mSingleRecipeCheck != null) { + if (!mSingleRecipeCheck.checkRecipeInputsSingleStack(true)) { + return false; + } + + tRecipe = mSingleRecipeCheck.getRecipe(); + } else { + ArrayList<ItemStack> tInputList = getStoredInputs(); + int tInputList_sS = tInputList.size(); + for (int i = 0; i < tInputList_sS - 1; i++) { + for (int j = i + 1; j < tInputList_sS; j++) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + tInputList.remove(j--); + tInputList_sS = tInputList.size(); + } else { + tInputList.remove(i--); + tInputList_sS = tInputList.size(); + break; + } } } } - } - tInputList.add(mInventory[1]); - ItemStack[] inputs = tInputList.toArray(new ItemStack[0]); - - ArrayList<FluidStack> tFluidList = getStoredFluids(); - int tFluidList_sS = tFluidList.size(); - for (int i = 0; i < tFluidList_sS - 1; i++) { - for (int j = i + 1; j < tFluidList_sS; j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - tFluidList_sS = tFluidList.size(); - } else { - tFluidList.remove(i--); - tFluidList_sS = tFluidList.size(); - break; + tInputList.add(mInventory[1]); + ItemStack[] inputs = tInputList.toArray(new ItemStack[0]); + + ArrayList<FluidStack> tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; i++) { + for (int j = i + 1; j < tFluidList_sS; j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } } } } - } - FluidStack[] fluids = tFluidList.toArray(new FluidStack[0]); + FluidStack[] fluids = tFluidList.toArray(new FluidStack[0]); + + if (inputs.length == 0 && fluids.length == 0) { + return false; + } - if (inputs.length > 0 || fluids.length > 0) { - long tVoltage = getMaxInputVoltage(); - byte tier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.findRecipe(getBaseMetaTileEntity(), false, + GT_Single_Recipe_Check.Builder tSingleRecipeCheckBuilder = null; + if (mLockedToSingleRecipe) { + // We're locked to a single recipe, but haven't built the recipe checker yet. + // Build the checker on next successful recipe. + tSingleRecipeCheckBuilder = GT_Single_Recipe_Check.builder(this).setBefore(); + } + + tRecipe = GT_Recipe.GT_Recipe_Map.sMultiblockChemicalRecipes.findRecipe(getBaseMetaTileEntity(), false, false, gregtech.api.enums.GT_Values.V[tier], fluids, inputs); - if (tRecipe != null && tRecipe.isRecipeInputEqual(true, fluids, inputs)) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - calculatePerfectOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mOutputItems = tRecipe.mOutputs; - this.mOutputFluids = tRecipe.mFluidOutputs; - this.updateSlots(); - return true; + if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, fluids, inputs)) { + return false; + } + + if (mLockedToSingleRecipe) { + mSingleRecipeCheck = tSingleRecipeCheckBuilder.setAfter().setRecipe(tRecipe).build(); } } - return false; + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + calculatePerfectOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return false; + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mOutputItems = tRecipe.mOutputs; + this.mOutputFluids = tRecipe.mFluidOutputs; + this.updateSlots(); + return true; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index b168e44c41..50f28a83b4 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -17,7 +17,6 @@ import gregtech.common.blocks.GT_TileEntity_Ores; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -32,8 +31,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import org.lwjgl.input.Keyboard; - import static gregtech.api.enums.GT_Values.VN; public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase { @@ -109,21 +106,34 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile } private boolean processOreList(){ ChunkPosition oreBlockPos = null; + int x = 0, y = 0, z = 0; Block oreBlock = null; + int oreBlockMetadata = 0; - while ((oreBlock == null || oreBlock == Blocks.air) && !oreBlockPositions.isEmpty()) { + while ((oreBlock == null || !GT_Utility.isOre(oreBlock, oreBlockMetadata)) && !oreBlockPositions.isEmpty()) { oreBlockPos = oreBlockPositions.remove(0); - if (GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ, true)) - oreBlock = getBaseMetaTileEntity().getBlock(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); + x = oreBlockPos.chunkPosX; + y = oreBlockPos.chunkPosY; + z = oreBlockPos.chunkPosZ; + if (GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), x, y, z, true)) + oreBlock = getBaseMetaTileEntity().getBlock(x, y, z); + oreBlockMetadata = getBaseMetaTileEntity().getWorld().getBlockMetadata(x, y, z); } if (!tryConsumeDrillingFluid()) { oreBlockPositions.add(0, oreBlockPos); return false; } - if (oreBlock != null && oreBlock != Blocks.air) { - Collection<ItemStack> oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); - getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); + if (oreBlock != null && GT_Utility.isOre(oreBlock, oreBlockMetadata)) { + short metaData = 0; + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntity(x, y, z); + if (tTileEntity instanceof GT_TileEntity_Ores) { + metaData = ((GT_TileEntity_Ores) tTileEntity).mMetaData; + } + + Collection<ItemStack> oreBlockDrops = getBlockDrops(oreBlock, x, y, z); + ItemStack cobble = GT_Utility.getCobbleForOre(oreBlock, metaData); + getBaseMetaTileEntity().getWorld().setBlock(x, y, z, Block.getBlockFromItem(cobble.getItem()), cobble.getItemDamage(), 3); mOutputItems = getOutputByDrops(oreBlockDrops); } return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java index eab4e9c896..61fb394841 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PrimitiveBlastFurnace.java @@ -114,7 +114,7 @@ public abstract class GT_MetaTileEntity_PrimitiveBlastFurnace extends MetaTileEn @Override public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); + return (GregTech_API.getCoverBehaviorNew(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java index ad0f5bd7f8..a48f63c60a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -19,6 +19,7 @@ import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_ProcessingArray_Manager; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Single_Recipe_Check_Processing_Array; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -145,7 +146,16 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu } @Override + public boolean supportsSingleRecipeLocking() { + return true; + } + + @Override public boolean checkRecipe(ItemStack aStack) { + if (mLockedToSingleRecipe && mSingleRecipeCheck != null) { + return processLockedRecipe(); + } + if (!isCorrectMachinePart(mInventory[1])) { return false; } @@ -228,6 +238,15 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu return false; } + public boolean processLockedRecipe() { + GT_Single_Recipe_Check_Processing_Array tSingleRecipeCheck = (GT_Single_Recipe_Check_Processing_Array) mSingleRecipeCheck; + + int machines = Math.min(64, mInventory[1].stackSize << mMult); //Upped max Cap to 64 + int parallel = tSingleRecipeCheck.checkRecipeInputs(true, machines); + + return processRecipeOutputs(tSingleRecipeCheck.getRecipe(), tSingleRecipeCheck.getRecipeAmperage(), parallel); + } + public boolean processRecipe(ItemStack[] tInputs, FluidStack[] tFluids, GT_Recipe.GT_Recipe_Map map) { if (tInputs.length <= 0 && tFluids.length <= 0) return false; GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); @@ -236,54 +255,77 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu !isValidForLowGravity(tRecipe, getBaseMetaTileEntity().getWorld().provider.dimensionId)) return false; + GT_Single_Recipe_Check_Processing_Array.Builder tSingleRecipeCheckBuilder = null; + if (mLockedToSingleRecipe) { + // We're locked to a single recipe, but haven't built the recipe checker yet. + // Build the checker on next successful recipe. + tSingleRecipeCheckBuilder = GT_Single_Recipe_Check_Processing_Array.processingArrayBuilder(this).setBefore(); + } + + boolean recipeLocked = false; mLastRecipe = tRecipe; - this.mEUt = 0; - this.mOutputItems = null; - this.mOutputFluids = null; int machines = Math.min(64, mInventory[1].stackSize << mMult); //Upped max Cap to 64 int i = 0; for (; i < machines; i++) { if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - if (i == 0) { - return false; - } break; + } else if (mLockedToSingleRecipe && !recipeLocked) { + // We want to lock to a single run of the recipe. + mSingleRecipeCheck = + tSingleRecipeCheckBuilder + .setAfter() + .setRecipe(tRecipe) + .setRecipeAmperage(map.mAmperage) + .build(); + recipeLocked = true; } } - this.mMaxProgresstime = tRecipe.mDuration; + + return processRecipeOutputs(tRecipe, map.mAmperage, i); + } + + public boolean processRecipeOutputs(GT_Recipe aRecipe, int aAmperage, int parallel) { + this.mEUt = 0; + this.mOutputItems = null; + this.mOutputFluids = null; + if (parallel == 0) { + return false; + } + + this.mMaxProgresstime = aRecipe.mDuration; this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, map.mAmperage, GT_Values.V[tTier]); + calculateOverclockedNessMulti(aRecipe.mEUt, aRecipe.mDuration, aAmperage, GT_Values.V[tTier]); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return false; - this.mEUt = GT_Utility.safeInt(((long) this.mEUt * i) >> mMult, 1); + this.mEUt = GT_Utility.safeInt(((long) this.mEUt * parallel) >> mMult, 1); if (mEUt == Integer.MAX_VALUE - 1) return false; if (this.mEUt > 0) { this.mEUt = (-this.mEUt); } - ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; - for (int h = 0; h < tRecipe.mOutputs.length; h++) { - if (tRecipe.getOutput(h) != null) { - tOut[h] = tRecipe.getOutput(h).copy(); + ItemStack[] tOut = new ItemStack[aRecipe.mOutputs.length]; + for (int h = 0; h < aRecipe.mOutputs.length; h++) { + if (aRecipe.getOutput(h) != null) { + tOut[h] = aRecipe.getOutput(h).copy(); tOut[h].stackSize = 0; } } FluidStack tFOut = null; - if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); + if (aRecipe.getFluidOutput(0) != null) tFOut = aRecipe.getFluidOutput(0).copy(); for (int f = 0; f < tOut.length; f++) { - if (tRecipe.mOutputs[f] != null && tOut[f] != null) { - for (int g = 0; g < i; g++) { - if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) - tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; + if (aRecipe.mOutputs[f] != null && tOut[f] != null) { + for (int g = 0; g < parallel; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < aRecipe.getOutputChance(f)) + tOut[f].stackSize += aRecipe.mOutputs[f].stackSize; } } } if (tFOut != null) { int tSize = tFOut.amount; - tFOut.amount = tSize * i; + tFOut.amount = tSize * parallel; } this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.mOutputItems = Arrays.stream(tOut) @@ -353,8 +395,13 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_CubicMu @Override public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mSeparate = !mSeparate; - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + mSeparate); + if (aPlayer.isSneaking()) { + // Lock to single recipe + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } else { + mSeparate = !mSeparate; + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + mSeparate); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index ae96b82a23..9542c54ce0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -16,6 +16,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMul import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Single_Recipe_Check; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -129,19 +130,45 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu } @Override - public boolean checkRecipe(ItemStack aStack) { - ItemStack[] tInputs = getCompactedInputs(); - FluidStack[] tFluids = getCompactedFluids(); - - if (tInputs.length <= 0) - return false; + public boolean supportsSingleRecipeLocking() { + return true; + } + @Override + public boolean checkRecipe(ItemStack aStack) { long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + GT_Recipe tRecipe; - if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) - return false; + if (mLockedToSingleRecipe && mSingleRecipeCheck != null) { + if (!mSingleRecipeCheck.checkRecipeInputsSingleStack(true)) { + return false; + } + + tRecipe = mSingleRecipeCheck.getRecipe(); + } else { + ItemStack[] tInputs = getCompactedInputs(); + FluidStack[] tFluids = getCompactedFluids(); + + if (tInputs.length <= 0) + return false; + + GT_Single_Recipe_Check.Builder tSingleRecipeCheckBuilder = null; + if (mLockedToSingleRecipe) { + // We're locked to a single recipe, but haven't built the recipe checker yet. + // Build the checker on next successful recipe. + tSingleRecipeCheckBuilder = GT_Single_Recipe_Check.builder(this).setBefore(); + } + + tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + + if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) + return false; + + if (mLockedToSingleRecipe) { + mSingleRecipeCheck = tSingleRecipeCheckBuilder.setAfter().setRecipe(tRecipe).build(); + } + } this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java index b7f24f7e7a..843f2ff337 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java @@ -14,8 +14,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; - -import java.util.ArrayList; +import net.minecraftforge.fluids.FluidStack; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE; @@ -49,6 +48,8 @@ public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_CubicMult .addCasingInfo("Frost Proof Machine Casing", 16) .addEnergyHatch("Any casing", 1) .addMaintenanceHatch("Any casing", 1) + .addInputHatch("Any casing", 1) + .addOutputHatch("Any casing", 1) .addInputBus("Any casing", 1) .addOutputBus("Any casing", 1) .toolTipFinisher("Gregtech"); @@ -93,29 +94,29 @@ public class GT_MetaTileEntity_VacuumFreezer extends GT_MetaTileEntity_CubicMult @Override public boolean checkRecipe(ItemStack aStack) { - ArrayList<ItemStack> tInputList = getStoredInputs(); - for (ItemStack tInput : tInputList) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sVacuumRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, tInput); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, null, tInput)) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return false; - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - updateSlots(); - return true; + ItemStack[] tInputList = getCompactedInputs(); + FluidStack[] tFluidList = getCompactedFluids(); + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = getRecipeMap().findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluidList, tInputList); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, tFluidList, tInputList)) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return false; + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + updateSlots(); + return true; } } return false; diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java index 7110ed20f9..c7bd5d0029 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java @@ -34,7 +34,8 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti super(aID, aName, aNameRegional, aTier, 3, new String[]{ "This Chest stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + " Blocks", "Use a screwdriver to enable", - "voiding items on overflow" + "voiding items on overflow", + "Can keep its contents when harvested" }); } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java index 20d333783e..ca3289e218 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java @@ -3,11 +3,16 @@ package gregtech.common.tileentities.storage; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; public class GT_MetaTileEntity_QuantumChest extends GT_MetaTileEntity_DigitalChestBase { public int mItemCount = 0; public ItemStack mItemStack = null; + NBTTagList mInvData = null; + public GT_MetaTileEntity_QuantumChest(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier); } @@ -24,16 +29,53 @@ public class GT_MetaTileEntity_QuantumChest extends GT_MetaTileEntity_DigitalChe public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_QuantumChest(mName, mTier, mDescriptionArray, mTextures); } + @Override - protected String chestName(){ return "Quantum Chest"; } + public void setItemNBT(NBTTagCompound aNBT) { + mInvData = new NBTTagList(); + for (int i = 0; i < 3; i++) { + if (mInventory[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + tNBT.setByte("Count", (byte) mInventory[i].stackSize); + tNBT.setShort("Damage", (short) mInventory[i].getItemDamage()); + tNBT.setShort("id", (short) Item.getIdFromItem(mInventory[i].getItem())); + tNBT.setInteger("IntSlot", i); + if (mInventory[i].hasTagCompound()) { + tNBT.setTag("tag", mInventory[i].getTagCompound()); + } + mInvData.appendTag(tNBT); + } + } + if (mItemStack != null) + aNBT.setTag("mItemStack", getItemStack().writeToNBT(new NBTTagCompound())); + aNBT.setTag("Inventory", mInvData); + aNBT.setInteger("mItemCount", getItemCount()); + aNBT.setBoolean("mVoidOverflow", mVoidOverflow); + super.setItemNBT(aNBT); + } + @Override - protected int getItemCount() { return mItemCount; } + protected String chestName() { + return "Quantum Chest"; + } + + @Override + protected int getItemCount() { + return mItemCount; + } + @Override public void setItemCount(int aCount) { mItemCount = aCount; } + @Override - protected ItemStack getItemStack(){ return mItemStack; } + protected ItemStack getItemStack() { + return mItemStack; + } + @Override - protected void setItemStack(ItemStack s){ mItemStack = s; } + protected void setItemStack(ItemStack s) { + mItemStack = s; + } } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java index ea935f1360..1637a126e4 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java @@ -7,6 +7,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; @@ -16,8 +17,10 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK_GLOW; public class GT_MetaTileEntity_QuantumTank extends GT_MetaTileEntity_BasicTank { public GT_MetaTileEntity_QuantumTank(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, - "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid"); + super(aID, aName, aNameRegional, aTier, 3, new String[]{ + "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid", + "Can keep its contents when harvested" + }); } private static int commonSizeCompute(int tier) { @@ -51,6 +54,13 @@ public class GT_MetaTileEntity_QuantumTank extends GT_MetaTileEntity_BasicTank { } @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (mFluid != null && mFluid.amount > 0) + aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + super.setItemNBT(aNBT); + } + + @Override public boolean isSimpleMachine() { return true; } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java index e566ba9ed5..4614cc409e 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java @@ -3,11 +3,15 @@ package gregtech.common.tileentities.storage; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; public class GT_MetaTileEntity_SuperChest extends GT_MetaTileEntity_DigitalChestBase { public int mItemCount = 0; public ItemStack mItemStack = null; + NBTTagList mInvData = null; public GT_MetaTileEntity_SuperChest(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier); @@ -22,6 +26,30 @@ public class GT_MetaTileEntity_SuperChest extends GT_MetaTileEntity_DigitalChest } @Override + public void setItemNBT(NBTTagCompound aNBT) { + mInvData = new NBTTagList(); + for (int i = 0; i < 3; i++) { + if (mInventory[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + tNBT.setByte("Count", (byte) mInventory[i].stackSize); + tNBT.setShort("Damage", (short) mInventory[i].getItemDamage()); + tNBT.setShort("id", (short) Item.getIdFromItem(mInventory[i].getItem())); + tNBT.setInteger("IntSlot", i); + if (mInventory[i].hasTagCompound()) { + tNBT.setTag("tag", mInventory[i].getTagCompound()); + } + mInvData.appendTag(tNBT); + } + } + if (mItemStack != null) + aNBT.setTag("mItemStack", getItemStack().writeToNBT(new NBTTagCompound())); + aNBT.setTag("Inventory", mInvData); + aNBT.setInteger("mItemCount", getItemCount()); + aNBT.setBoolean("mVoidOverflow", mVoidOverflow); + super.setItemNBT(aNBT); + } + + @Override protected ItemStack getItemStack() { return mItemStack; } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java index edb69abb20..1aa9f98d82 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java @@ -7,6 +7,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; @@ -16,8 +17,10 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK_GLOW; public class GT_MetaTileEntity_SuperTank extends GT_MetaTileEntity_BasicTank { public GT_MetaTileEntity_SuperTank(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, - "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid"); + super(aID, aName, aNameRegional, aTier, 3, new String[]{ + "Stores " + GT_Utility.formatNumbers(commonSizeCompute(aTier)) + "L of fluid", + "Can keep its contents when harvested" + }); } private static int commonSizeCompute(int tier) { @@ -51,6 +54,13 @@ public class GT_MetaTileEntity_SuperTank extends GT_MetaTileEntity_BasicTank { } @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (mFluid != null && mFluid.amount > 0) + aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + super.setItemNBT(aNBT); + } + + @Override public boolean isSimpleMachine() { return true; } |