diff options
author | GlodBlock <1356392126@qq.com> | 2021-09-20 14:38:24 +0800 |
---|---|---|
committer | GlodBlock <1356392126@qq.com> | 2021-09-20 14:38:24 +0800 |
commit | b7be0dd5b192b19098e8e1c7d0fbc96cb99bfd1c (patch) | |
tree | ef92338f27b6a7ceb9432a5cf4d9e91407a66cda /src/main/java/GoodGenerator | |
parent | 445e8248743bf5f99fed078288d9f81038749942 (diff) | |
download | GT5-Unofficial-b7be0dd5b192b19098e8e1c7d0fbc96cb99bfd1c.tar.gz GT5-Unofficial-b7be0dd5b192b19098e8e1c7d0fbc96cb99bfd1c.tar.bz2 GT5-Unofficial-b7be0dd5b192b19098e8e1c7d0fbc96cb99bfd1c.zip |
add GUI and desc text fot YOTTank
Diffstat (limited to 'src/main/java/GoodGenerator')
6 files changed, 287 insertions, 181 deletions
diff --git a/src/main/java/GoodGenerator/Blocks/TEs/MetaTE/YottaFluidTankOutputHatch.java b/src/main/java/GoodGenerator/Blocks/TEs/MetaTE/YottaFluidTankOutputHatch.java deleted file mode 100644 index d53a01408e..0000000000 --- a/src/main/java/GoodGenerator/Blocks/TEs/MetaTE/YottaFluidTankOutputHatch.java +++ /dev/null @@ -1,133 +0,0 @@ -package GoodGenerator.Blocks.TEs.MetaTE; - -import GoodGenerator.Blocks.TEs.YottaFluidTank; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.render.TextureFactory; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; - -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; - -public class YottaFluidTankOutputHatch extends GT_MetaTileEntity_Hatch { - - private String mFluidName = ""; - private int mOutputSpeed = 0; - private int mX, mZ, mY; - private boolean isBound = false; - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFluidName = aNBT.getString("mFluidName"); - mOutputSpeed = aNBT.getInteger("mOutputSpeed"); - mX = aNBT.getInteger("mX"); - mZ = aNBT.getInteger("mZ"); - mY = aNBT.getInteger("mY"); - isBound = aNBT.getBoolean("isBound"); - super.loadNBTData(aNBT); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setString("mFluidName", mFluidName); - aNBT.setInteger("mOutputSpeed", mOutputSpeed); - aNBT.setInteger("mX", mX); - aNBT.setInteger("mZ", mZ); - aNBT.setInteger("mY", mY); - aNBT.setBoolean("isBound", isBound); - super.saveNBTData(aNBT); - } - - public YottaFluidTankOutputHatch(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Output Fluid From YOTTank."); - } - - public YottaFluidTankOutputHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 0, aDescription, aTextures); - } - - public void setFluid(FluidStack output) { - if (output == null) { - mFluidName = ""; - mOutputSpeed = 0; - return; - } - mFluidName = output.getFluid().getName(); - mOutputSpeed = output.amount; - } - - public void setControl(int x, int y, int z) { - mX = x; - mY = y; - mZ = z; - isBound = true; - } - - public void unBounded() { - isBound = false; - } - - public boolean isBounded() { - return isBound; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return true; - } - - @Override - public boolean isLiquidInput(byte aSide) { - return false; - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); - FluidStack tOutput = FluidRegistry.getFluidStack(mFluidName, mOutputSpeed); - IGregTechTileEntity tController = aBaseMetaTileEntity.getIGregTechTileEntity(mX, mY, mZ); - if (tTileEntity != null && tOutput != null && tController.getMetaTileEntity() instanceof YottaFluidTank && isBound) { - int tAmount = Math.min(tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tOutput, false), mOutputSpeed); - if (tAmount > 0) { - tOutput.amount = tAmount; - if (((YottaFluidTank) tController).reduceFluid(tAmount)) - tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tOutput, true); - } - } - if (tController == null || !(tController.getMetaTileEntity() instanceof YottaFluidTank)) isBound = false; - } - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new YottaFluidTankOutputHatch(mName, mTier, mDescriptionArray, mTextures); - } -} diff --git a/src/main/java/GoodGenerator/Blocks/TEs/YottaFluidTank.java b/src/main/java/GoodGenerator/Blocks/TEs/YottaFluidTank.java index e5adbe6f34..2d37997af4 100644 --- a/src/main/java/GoodGenerator/Blocks/TEs/YottaFluidTank.java +++ b/src/main/java/GoodGenerator/Blocks/TEs/YottaFluidTank.java @@ -1,7 +1,9 @@ package GoodGenerator.Blocks.TEs; -import GoodGenerator.Blocks.TEs.MetaTE.YottaFluidTankOutputHatch; +import GoodGenerator.Client.GUI.YOTTankGUIClient; +import GoodGenerator.Common.Container.YOTTankGUIContainer; import GoodGenerator.Loader.Loaders; +import GoodGenerator.util.DescTextLocalization; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; @@ -16,16 +18,22 @@ 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_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.input.Keyboard; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; +import static GoodGenerator.util.DescTextLocalization.BLUE_PRINT_INFO; import static GoodGenerator.util.StructureHelper.addFrame; import static GoodGenerator.util.StructureHelper.addTieredBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; @@ -44,10 +52,10 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen protected BigInteger mStorageCurrent = new BigInteger("0", 10); protected String mFluidName = ""; protected int glassMeta; + protected int maxCell; protected final String YOTTANK_BOTTOM = mName + "buttom"; protected final String YOTTANK_MID = mName + "mid"; protected final String YOTTANK_TOP = mName + "top"; - protected List<YottaFluidTankOutputHatch> mYottaOutput = new ArrayList<>(); public YottaFluidTank(int id, String name, String nameRegional) { super(id, name, nameRegional); @@ -65,6 +73,19 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen glassMeta = meta; } + public String getCap() { + return mStorage.toString(10); + } + + public String getStored() { + return mStorageCurrent.toString(10); + } + + public String getFluidName() { + if (mFluidName == null || mFluidName.equals("") || FluidRegistry.getFluidStack(mFluidName, 1) == null) return "Empty"; + return FluidRegistry.getFluidStack(mFluidName, 1).getLocalizedName(); + } + @Override public void loadNBTData(NBTTagCompound aNBT) { String tAmount = aNBT.getString("mStorage"); @@ -75,6 +96,7 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen mStorageCurrent = new BigInteger(tAmountCurrent, 10); mFluidName = aNBT.getString("mFluidName"); glassMeta = aNBT.getInteger("glassMeta"); + maxCell = aNBT.getInteger("maxCell"); super.loadNBTData(aNBT); } @@ -84,11 +106,14 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen aNBT.setString("mStorageCurrent", mStorageCurrent.toString(10)); aNBT.setString("mFluidName", mFluidName); aNBT.setInteger("glassMeta", glassMeta); + aNBT.setInteger("maxCell", maxCell); super.saveNBTData(aNBT); } @Override public boolean checkRecipe_EM(ItemStack aStack) { + this.mEUt = 0; + this.mMaxProgresstime = 20; return true; } @@ -103,10 +128,16 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen } } + private int calGlassTier(int meta) { + if (meta >= 1 && meta <= 6) return meta; + if (meta >= 7 && meta <= 12) return 1; + return 3; + } + @Override public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - for (YottaFluidTankOutputHatch tHatch : mYottaOutput) tHatch.unBounded(); - mYottaOutput.clear(); + mStorage = BigInteger.ZERO; + glassMeta = 0; if (!structureCheck_EM(YOTTANK_BOTTOM, 2, 0, 0)) return false; int cnt = 0; while (structureCheck_EM(YOTTANK_MID, 2, cnt + 1, 0)) { @@ -114,7 +145,15 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen } if (cnt > 15 || cnt < 1) return false; if (!structureCheck_EM(YOTTANK_TOP, 2, cnt + 2, 0)) return false; - return mMaintenanceHatches.size() == 1; + if (mMaintenanceHatches.size() == 1 && maxCell + 1 <= calGlassTier(glassMeta)) { + if (mStorage.compareTo(mStorageCurrent) < 0) mStorageCurrent = mStorage; + if (FluidRegistry.getFluidStack(mFluidName, 1) == null) { + mStorageCurrent = BigInteger.ZERO; + mFluidName = ""; + } + return true; + } + return false; } @Override @@ -194,7 +233,10 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen int finalI = i; out.add( onElementPass( - x -> x.mStorage = x.mStorage.add(calStorage(finalI)), + x -> { + x.mStorage = x.mStorage.add(calStorage(finalI)); + x.maxCell = Math.max(x.maxCell, finalI); + }, ofBlock(Loaders.yottaFluidTankCell, i) ) ); @@ -227,26 +269,38 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen if (aMetaTileEntity == null) { return false; } else { - if ((aMetaTileEntity instanceof YottaFluidTankOutputHatch) && boundOutput(aTileEntity)) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return true; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output)aMetaTileEntity); } } } return false; } - public boolean boundOutput(IGregTechTileEntity output) { - IMetaTileEntity tHatch = output.getMetaTileEntity(); - if (tHatch instanceof YottaFluidTankOutputHatch) { - YottaFluidTankOutputHatch Hatch = (YottaFluidTankOutputHatch) tHatch; - if (!Hatch.isBounded()) { - Hatch.setControl(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); - mYottaOutput.add(Hatch); - return true; - } + @Override + public String[] getDescription() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Fluid Tank") + .addInfo("Controller block for the YOTTank.") + .addInfo("The max output speed is decided by the amount of stored liquid and the capacity of output hatch.") + .addInfo("The max fluid cell tier is limited by the glass tier.") + .addInfo("HV glass for T1, EV glass for T2, IV glass for T3. . .") + .addInfo("The max height of the cell blocks is 15.") + .addInfo("The structure is too complex!") + .addInfo(BLUE_PRINT_INFO) + .addSeparator() + .beginVariableStructureBlock(5, 5, 1, 15, 5 ,5, false) + .addController("Front of the second layer") + .addInputHatch("Hint block with dot 1") + .addMaintenanceHatch("Hint block with dot 2") + .addOutputHatch("Hint block with dot 3") + .toolTipFinisher("Good Generator"); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getInformation(); + } else { + return tt.getStructureInformation(); } - return false; } public BigInteger calStorage(int meta) { @@ -258,38 +312,67 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen } @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new YOTTankGUIClient(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png"); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new YOTTankGUIContainer(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override public boolean onRunningTick(ItemStack aStack) { super.onRunningTick(aStack); - List<FluidStack> tStore = getStoredFluids(); - for (FluidStack tFluid : tStore) { - if (tFluid == null) continue; - if (mFluidName == null || mFluidName.equals("") || tFluid.getFluid().getName().equals(mFluidName)) { - if (mFluidName == null || mFluidName.equals("")) { - mFluidName = tFluid.getFluid().getName(); - } - if (mStorageCurrent.add(new BigInteger(tFluid.amount + "")).compareTo(mStorage) < 0) { - mStorageCurrent = mStorageCurrent.add(new BigInteger(tFluid.amount + "")); - tFluid.amount = 0; - } else { - BigInteger delta = mStorage.subtract(mStorageCurrent); - mStorageCurrent = mStorageCurrent.add(delta); - tFluid.amount -= delta.intValue(); + if (this.getBaseMetaTileEntity().isServerSide()) { + List<FluidStack> tStore = getStoredFluids(); + for (FluidStack tFluid : tStore) { + if (tFluid == null) continue; + if (mFluidName == null || mFluidName.equals("") || tFluid.getFluid().getName().equals(mFluidName)) { + if (mFluidName == null || mFluidName.equals("")) { + mFluidName = tFluid.getFluid().getName(); + } + if (mStorageCurrent.add(new BigInteger(tFluid.amount + "")).compareTo(mStorage) < 0) { + mStorageCurrent = mStorageCurrent.add(new BigInteger(tFluid.amount + "")); + tFluid.amount = 0; + } else { + BigInteger delta = mStorage.subtract(mStorageCurrent); + mStorageCurrent = mStorageCurrent.add(delta); + tFluid.amount -= delta.intValue(); + } } } - } - BigInteger outputAmount = mStorageCurrent.divide(new BigInteger("100", 10)); - if (outputAmount.compareTo(new BigInteger(Integer.MAX_VALUE + "", 10)) > 0) outputAmount = new BigInteger(Integer.MAX_VALUE + ""); - if (outputAmount.compareTo(BigInteger.ONE) <= 0) outputAmount = new BigInteger("1", 10); + BigInteger outputAmount = mStorageCurrent.divide(new BigInteger("100", 10)); + if (outputAmount.compareTo(new BigInteger(Integer.MAX_VALUE + "", 10)) > 0) outputAmount = new BigInteger(Integer.MAX_VALUE + ""); + if (outputAmount.compareTo(BigInteger.ONE) <= 0) outputAmount = new BigInteger("1", 10); - if (mStorageCurrent.compareTo(BigInteger.ZERO) <= 0) mFluidName = ""; + if (mStorageCurrent.compareTo(BigInteger.ZERO) <= 0) mFluidName = ""; - if (mFluidName != null && !mFluidName.equals("")) { - if (mYottaOutput.size() > 0) { - mYottaOutput.get(0).setFluid(FluidRegistry.getFluidStack(mFluidName, outputAmount.intValue())); - return true; + if (mFluidName != null && !mFluidName.equals("")) { + if (mOutputHatches.size() > 0) { + FluidStack tHatchFluid = mOutputHatches.get(0).mFluid; + FluidStack tOutput = FluidRegistry.getFluidStack(mFluidName, outputAmount.intValue()); + if (tHatchFluid != null && tHatchFluid.isFluidEqual(tOutput)) { + int leftSpace = mOutputHatches.get(0).getCapacity() - tHatchFluid.amount; + if (leftSpace < tOutput.amount) { + if (reduceFluid(leftSpace)) tHatchFluid.amount += leftSpace; + } + else { + if (reduceFluid(tOutput.amount)) tHatchFluid.amount += tOutput.amount; + } + } + else if (tHatchFluid == null) { + int leftSpace = mOutputHatches.get(0).getCapacity(); + if (leftSpace < tOutput.amount) { + if (reduceFluid(leftSpace)) mOutputHatches.get(0).fill(FluidRegistry.getFluidStack(mFluidName, leftSpace), true); + } + else { + if (reduceFluid(tOutput.amount)) mOutputHatches.get(0).fill(tOutput, true); + } + } + } } } - mYottaOutput.get(0).setFluid(null); return true; } @@ -307,7 +390,7 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen @Override public String[] getStructureDescription(ItemStack stackSize) { - return new String[0]; + return DescTextLocalization.addText("YOTTank.hint", 7); } @Override diff --git a/src/main/java/GoodGenerator/Client/GUI/YOTTankGUIClient.java b/src/main/java/GoodGenerator/Client/GUI/YOTTankGUIClient.java new file mode 100644 index 0000000000..160a562fa9 --- /dev/null +++ b/src/main/java/GoodGenerator/Client/GUI/YOTTankGUIClient.java @@ -0,0 +1,27 @@ +package GoodGenerator.Client.GUI; + +import GoodGenerator.Common.Container.YOTTankGUIContainer; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.StatCollector; + +public class YOTTankGUIClient extends GT_GUIContainer_MultiMachineEM { + + private final YOTTankGUIContainer containerYOTTank; + + public YOTTankGUIClient(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) { + super(new YOTTankGUIContainer(aInventoryPlayer, aTileEntity), aName, aTextureFile, true, true, true); + containerYOTTank = (YOTTankGUIContainer) this.mContainer; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + super.drawGuiContainerForegroundLayer(par1, par2); + if (this.mContainer.mDisplayErrorCode == 0) { + fontRendererObj.drawString(StatCollector.translateToLocal("gui.YOTTank.0") + " " + containerYOTTank.getCap() + " L", 7, 40, 16448255); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.YOTTank.1") + " " + containerYOTTank.getFluidName(), 7, 48, 16448255); + fontRendererObj.drawString(StatCollector.translateToLocal("gui.YOTTank.2") + " " + containerYOTTank.getStorage() + " L", 7, 56, 16448255); + } + } +} diff --git a/src/main/java/GoodGenerator/Common/Container/YOTTankGUIContainer.java b/src/main/java/GoodGenerator/Common/Container/YOTTankGUIContainer.java new file mode 100644 index 0000000000..9d0a980d83 --- /dev/null +++ b/src/main/java/GoodGenerator/Common/Container/YOTTankGUIContainer.java @@ -0,0 +1,133 @@ +package GoodGenerator.Common.Container; + +import GoodGenerator.Blocks.TEs.YottaFluidTank; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; + +import java.nio.ByteBuffer; + +public class YOTTankGUIContainer extends GT_Container_MultiMachineEM { + + private String currentStore = ""; + private String store = ""; + private String fluidName = ""; + + private ByteBuffer buffer; + + public YOTTankGUIContainer(InventoryPlayer inventoryPlayer, IGregTechTileEntity aTileEntity) { + super(inventoryPlayer, aTileEntity, true, true, true); + } + + @Override + public void addCraftingToCrafters(ICrafting clientHandle) { + buffer.putInt(0, currentStore.length()); + buffer.putInt(Integer.BYTES, store.length()); + buffer.putInt(Integer.BYTES * 2, fluidName.length()); + for (int i = 0; i < currentStore.length(); ++i) { + buffer.putChar(Integer.BYTES * 3 + Character.BYTES * i, currentStore.charAt(i)); + } + for (int i = 0; i < store.length(); ++i) { + buffer.putChar(Integer.BYTES * 3 + Character.BYTES * (i + currentStore.length()), store.charAt(i)); + } + for (int i = 0; i < fluidName.length(); ++i) { + buffer.putChar(Integer.BYTES * 3 + Character.BYTES * (i + currentStore.length() + store.length()), fluidName.charAt(i)); + } + sendStateUpdate(clientHandle); + super.addCraftingToCrafters(clientHandle); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (buffer == null) { + buffer = ByteBuffer.allocate(8192); + } + if(mTileEntity.isServerSide()) { + YottaFluidTank tile = (YottaFluidTank) mTileEntity.getMetaTileEntity(); + if (tile == null) return; + String newStored = tile.getStored(); + String newCap = tile.getCap(); + String newFluid = tile.getFluidName(); + boolean isUpdated = false; + if (!newStored.equals(currentStore) || !newCap.equals(store) || !newFluid.equals(fluidName)) { + currentStore = newStored; + store = newCap; + fluidName = newFluid; + buffer.putInt(0, currentStore.length()); + buffer.putInt(Integer.BYTES, store.length()); + buffer.putInt(Integer.BYTES * 2, fluidName.length()); + for (int i = 0; i < currentStore.length(); ++i) { + buffer.putChar(Integer.BYTES * 3 + Character.BYTES * i, currentStore.charAt(i)); + } + for (int i = 0; i < store.length(); ++i) { + buffer.putChar(Integer.BYTES * 3 + Character.BYTES * (i + currentStore.length()), store.charAt(i)); + } + for (int i = 0; i < fluidName.length(); ++i) { + buffer.putChar(Integer.BYTES * 3 + Character.BYTES * (i + currentStore.length() + store.length()), fluidName.charAt(i)); + } + isUpdated = true; + } + for (Object clientHandle : this.crafters) { + if (isUpdated) { + sendStateUpdate((ICrafting) clientHandle); + } + } + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return true; + } + + private void sendStateUpdate(ICrafting clientHandle) { + final int bytes = Integer.BYTES * 3 + Character.BYTES * (currentStore.length() + store.length() + fluidName.length()); + for (int i = 0; i < bytes; i++) { + clientHandle.sendProgressBarUpdate(this, i + 21, buffer.get(i)); + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int index, int value) { + super.updateProgressBar(index, value); + index = index - 21; + if(index >= 0 && index < buffer.capacity()) { + buffer.put(index, (byte) value); + } + } + + @SideOnly(Side.CLIENT) + public String getStorage() { + StringBuilder sb = new StringBuilder(); + int startP = Integer.BYTES * 3; + for (int i = 0; i < buffer.getInt(0); ++i) { + sb.append(buffer.getChar(startP + Character.BYTES * i)); + } + return sb.toString(); + } + + @SideOnly(Side.CLIENT) + public String getCap() { + StringBuilder sb = new StringBuilder(); + int startP = Integer.BYTES * 3 + Character.BYTES * buffer.getInt(0); + for (int i = 0; i < buffer.getInt(Integer.BYTES); ++i) { + sb.append(buffer.getChar(startP + Character.BYTES * i)); + } + return sb.toString(); + } + + @SideOnly(Side.CLIENT) + public String getFluidName() { + StringBuilder sb = new StringBuilder(); + int startP = Integer.BYTES * 3 + Character.BYTES * (buffer.getInt(0) + buffer.getInt(Integer.BYTES)); + for (int i = 0; i < buffer.getInt(Integer.BYTES * 2); ++i) { + sb.append(buffer.getChar(startP + Character.BYTES * i)); + } + return sb.toString(); + } +} diff --git a/src/main/java/GoodGenerator/Loader/Loaders.java b/src/main/java/GoodGenerator/Loader/Loaders.java index 1236fd8254..a40e997218 100644 --- a/src/main/java/GoodGenerator/Loader/Loaders.java +++ b/src/main/java/GoodGenerator/Loader/Loaders.java @@ -8,7 +8,6 @@ import GoodGenerator.Blocks.RegularBlock.TEBlock; import GoodGenerator.Blocks.TEs.*; import GoodGenerator.Blocks.TEs.MetaTE.NeutronAccelerator; import GoodGenerator.Blocks.TEs.MetaTE.NeutronSensor; -import GoodGenerator.Blocks.TEs.MetaTE.YottaFluidTankOutputHatch; import GoodGenerator.CrossMod.NEI.IMCForNEI; import GoodGenerator.Items.MyItemBlocks; import GoodGenerator.Items.MyItems; @@ -84,7 +83,6 @@ public class Loaders { public static ItemStack NS; public static ItemStack NA; public static ItemStack YFT; - public static ItemStack YFTOutput; public static ItemStack[] NeutronAccelerators = new ItemStack[9]; @@ -98,7 +96,6 @@ public class Loaders { Loaders.NS = new NeutronSensor(IDOffset + 11, "Neutron Sensor", "Neutron Sensor", 5).getStackForm(1L); Loaders.NA = new NeutronActivator(IDOffset + 12, "NeutronActivator", "Neutron Activator").getStackForm(1L); Loaders.YFT = new YottaFluidTank(IDOffset + 13, "YottaFluidTank", "YOTTank").getStackForm(1L); - Loaders.YFTOutput = new YottaFluidTankOutputHatch(IDOffset + 14, "YottaFluidTankOutput", "YOTTank Output Hatch", 5).getStackForm(1L); } public static void Register(){ diff --git a/src/main/java/GoodGenerator/util/ItemRefer.java b/src/main/java/GoodGenerator/util/ItemRefer.java index b28416e7d1..3a9404d1ea 100644 --- a/src/main/java/GoodGenerator/util/ItemRefer.java +++ b/src/main/java/GoodGenerator/util/ItemRefer.java @@ -78,7 +78,6 @@ public final class ItemRefer { public static ItemRefer YOTTank_Cell_T9 = getItemStack(yottaFluidTankCell, 8); public static ItemRefer YOTTank_Cell_T10 = getItemStack(yottaFluidTankCell, 9); public static ItemRefer YOTTank = getItemStack(YFT); - public static ItemRefer YOTTank_Output_Hatch = getItemStack(YFTOutput); public static ItemRefer Large_Naquadah_Reactor = getItemStack(MAR.copy()); |