aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/common/tileentities
diff options
context:
space:
mode:
authorKiwi <42833050+Kiwi233@users.noreply.github.com>2021-08-02 20:46:25 +0800
committerGitHub <noreply@github.com>2021-08-02 20:46:25 +0800
commitc29700ed64f5e5f44e7bc1e5f37ec6be40c47974 (patch)
treef3bf4af7a6072402323756b84e2afcf2da0e5188 /src/main/java/common/tileentities
parent35dd2ba8e9861dc0df317777cc22a7f7b8c21e92 (diff)
parent2a78d724ac077912e0be3755390253be883f5950 (diff)
downloadGT5-Unofficial-c29700ed64f5e5f44e7bc1e5f37ec6be40c47974.tar.gz
GT5-Unofficial-c29700ed64f5e5f44e7bc1e5f37ec6be40c47974.tar.bz2
GT5-Unofficial-c29700ed64f5e5f44e7bc1e5f37ec6be40c47974.zip
Merge pull request #2 from GTNewHorizons/master
kekztech-0.5.6
Diffstat (limited to 'src/main/java/common/tileentities')
-rw-r--r--src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java1063
-rw-r--r--src/main/java/common/tileentities/GTMTE_ItemServer.java393
-rw-r--r--src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java281
-rw-r--r--src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java9
-rw-r--r--src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java45
-rw-r--r--src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java46
-rw-r--r--src/main/java/common/tileentities/GTMTE_SpaceElevator.java25
-rw-r--r--src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java217
-rw-r--r--src/main/java/common/tileentities/TE_BeamTransmitter.java47
-rw-r--r--src/main/java/common/tileentities/TE_ItemServerIOPort.java145
-rw-r--r--src/main/java/common/tileentities/TE_TFFTMultiHatch.java146
11 files changed, 1103 insertions, 1314 deletions
diff --git a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java
index 1c32525c4e..a12f4130cb 100644
--- a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java
+++ b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java
@@ -1,531 +1,534 @@
-package common.tileentities;
-
-import gregtech.api.enums.Textures.BlockIcons;
-import gregtech.api.gui.GT_GUIContainer_MultiMachine;
-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_Input;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
-import gregtech.api.objects.GT_RenderedTexture;
-import kekztech.MultiFluidHandler;
-import net.minecraft.block.Block;
-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.ChatComponentText;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraftforge.common.util.ForgeDirection;
-import net.minecraftforge.fluids.FluidStack;
-import org.lwjgl.input.Keyboard;
-
-import common.Blocks;
-import common.blocks.*;
-import util.MultiBlockTooltipBuilder;
-import util.Vector3i;
-import util.Vector3ic;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-
-public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase {
-
- private final static String glassNameIC2Reinforced = "blockAlloyGlass";
- private final static Block CASING = Blocks.tfftCasing;
- private final static Block_TFFTStorageFieldBlockT1 STORAGE_FIELD1 = (Block_TFFTStorageFieldBlockT1) Blocks.tfftStorageField1;
- private final static Block_TFFTStorageFieldBlockT2 STORAGE_FIELD2 = (Block_TFFTStorageFieldBlockT2) Blocks.tfftStorageField2;
- private final static Block_TFFTStorageFieldBlockT3 STORAGE_FIELD3 = (Block_TFFTStorageFieldBlockT3) Blocks.tfftStorageField3;
- private final static Block_TFFTStorageFieldBlockT4 STORAGE_FIELD4 = (Block_TFFTStorageFieldBlockT4) Blocks.tfftStorageField4;
- private final static Block_TFFTStorageFieldBlockT5 STORAGE_FIELD5 = (Block_TFFTStorageFieldBlockT5) Blocks.tfftStorageField5;
- private final static Block MULTI_HATCH = Blocks.tfftMultiHatch;
- private final static int CASING_TEXTURE_ID = 176;
-
- private MultiFluidHandler mfh;
- private HashSet<TE_TFFTMultiHatch> multiHatches = new HashSet<>();
-
- private int runningCost = 0;
- private boolean doVoidExcess = false;
- private byte fluidSelector = 0;
-
- public GTMTE_FluidMultiStorage(int aID, String aName, String aNameRegional) {
- super(aID, aName, aNameRegional);
- }
-
- public GTMTE_FluidMultiStorage(String aName) {
- super(aName);
- }
-
- @Override
- public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) {
- return new GTMTE_FluidMultiStorage(super.mName);
- }
-
- @Override
- public String[] getDescription() {
- final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
- b.addInfo("High-Tech fluid tank that can hold up to 25 different fluids!")
- .addInfo("Has 1/25th of the total capacity as capacity for each fluid.")
- .addInfo("Right clicking the controller with a screwdriver will turn on excess voiding.")
- .addInfo("Fluid storage amount and running cost depends on the storage field blocks used.")
- .addSeparator()
- .addInfo("Note on hatch locking:")
- .addInfo("Use an Integrated Circuit in the GUI slot to limit which fluid is output.")
- .addInfo("The index of a stored fluid can be obtained through the Tricorder.")
- .addSeparator()
- .beginStructureBlock(5, 9, 5)
- .addController("Top Center")
- .addEnergyHatch("Any top or bottom casing")
- .addOtherStructurePart("Inner 3x7x3 solid pillar", "Storage Field Blocks")
- .addOtherStructurePart("Outer 5x7x5 glass shell", "IC2 Reinforced Glass")
- .addMaintenanceHatch("Any top or bottom casing")
- .addIOHatches("Instead of any casing or glass, have to touch storage field.")
- .signAndFinalize("Kekzdealer");
- if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return b.getInformation();
- } else {
- return b.getStructureInformation();
- }
- }
-
- @Override
- public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex,
- boolean aActive, boolean aRedstone) {
- return aSide == aFacing
- ? new ITexture[]{BlockIcons.casingTexturePages[1][48],
- new GT_RenderedTexture(aActive
- ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE
- : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)}
- : new ITexture[]{BlockIcons.casingTexturePages[1][48]};
- }
-
- public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(),
- "MultiblockDisplay.png");
- }
-
- @Override
- public boolean isCorrectMachinePart(ItemStack var1) {
- return true;
- }
-
- @Override
- public boolean checkRecipe(ItemStack guiSlotItem) {
-
- super.mEfficiency = 10000 - (super.getIdealStatus() - super.getRepairStatus()) * 1000;
- super.mEfficiencyIncrease = 10000;
- super.mEUt = runningCost;
- super.mMaxProgresstime = 10;
-
- if(guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) {
- this.fluidSelector = (byte) guiSlotItem.getItemDamage();
- }
-
- // If there are no basic I/O hatches, let multi hatches handle it and skip a lot of code!
- if (multiHatches.size() > 0 && super.mInputHatches.size() == 0 && super.mOutputHatches.size() == 0) {
- return true;
- }
-
- // Suck in fluids
- final ArrayList<FluidStack> inputHatchFluids = super.getStoredFluids();
- if (inputHatchFluids.size() > 0) {
-
- for (FluidStack fluidStack : inputHatchFluids) {
-
- final int pushed = mfh.pushFluid(fluidStack, true);
- final FluidStack toDeplete = fluidStack.copy();
- toDeplete.amount = pushed;
- super.depleteInput(toDeplete);
- }
- }
-
- // Push out fluids
- if (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) {
- final FluidStack storedFluid = mfh.getFluid(fluidSelector);
- // Sum available output capacity
- int possibleOutput = 0;
- for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) {
- if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- } else if (outputHatch.getFluid() == null) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- }
- }
- // Output as much as possible
- final FluidStack tempStack = storedFluid.copy();
- tempStack.amount = possibleOutput;
- tempStack.amount = mfh.pullFluid(tempStack, fluidSelector, true);
- super.addOutput(tempStack);
-
- } else {
- for (FluidStack storedFluid : mfh.getFluids()) {
- // Sum available output capacity
- int possibleOutput = 0;
- for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) {
- if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- } else if (outputHatch.getFluid() == null) {
- possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
- }
- }
- // output as much as possible
- final FluidStack tempStack = storedFluid.copy();
- tempStack.amount = possibleOutput;
- // TODO possible concurrent modification exception as pullFluid calls remove() without an iterator
- tempStack.amount = mfh.pullFluid(tempStack, true);
- super.addOutput(tempStack);
- }
- }
-
- return true;
- }
-
- @Override
- public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
- super.onPostTick(aBaseMetaTileEntity, aTick);
-
- if (mfh != null) {
- mfh.setLock(!super.getBaseMetaTileEntity().isActive());
- mfh.setFluidSelector(fluidSelector);
- mfh.setDoVoidExcess(doVoidExcess);
- }
- }
-
- public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) {
- final Vector3i offset = new Vector3i();
-
- // either direction on z-axis
- if (forgeDirection.x() == 0 && forgeDirection.z() == -1) {
- offset.x = x;
- offset.y = y;
- offset.z = z;
- }
- if (forgeDirection.x() == 0 && forgeDirection.z() == 1) {
- offset.x = -x;
- offset.y = y;
- offset.z = -z;
- }
- // either direction on x-axis
- if (forgeDirection.x() == -1 && forgeDirection.z() == 0) {
- offset.x = z;
- offset.y = y;
- offset.z = -x;
- }
- if (forgeDirection.x() == 1 && forgeDirection.z() == 0) {
- offset.x = -z;
- offset.y = y;
- offset.z = x;
- }
- // either direction on y-axis
- if (forgeDirection.y() == -1) {
- offset.x = x;
- offset.y = z;
- offset.z = y;
- }
-
- return offset;
- }
-
- @Override
- public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) {
- // Figure out the vector for the direction the back face of the controller is facing
- final Vector3ic forgeDirection = new Vector3i(
- ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX,
- ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY,
- ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ
- );
- int minCasingAmount = 20;
- boolean formationChecklist = true; // If this is still true at the end, machine is good to go :)
- float runningCostAcc = 0;
- double fluidCapacityAcc = 0;
-
- multiHatches.clear();
-
- // Front segment
- for (int X = -2; X <= 2; X++) {
- for (int Y = -2; Y <= 2; Y++) {
- if (X == 0 && Y == 0) {
- continue; // Skip controller
- }
-
- // Get next TE
- final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0);
- final IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
-
- // Fluid hatches should touch the storage field.
- // Maintenance/Energy hatch can go anywhere
- if (X > -2 && X < 2 && Y > -2 && Y < 2) {
- if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- final Block b = thisController.getBlockOffset(offset.x(), offset.y(), offset.z());
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- // Also check for multi hatch
- if (b == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else if (b == MULTI_HATCH) {
- final TE_TFFTMultiHatch mh =
- (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity(
- thisController.getXCoord() + offset.x(),
- thisController.getYCoord() + offset.y(),
- thisController.getZCoord() + offset.z());
- multiHatches.add(mh);
- } else {
- formationChecklist = false;
- }
- }
- } else {
- if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else {
- formationChecklist = false;
- }
- }
- }
- }
- }
-
- // Middle seven long segment
- for (int X = -2; X <= 2; X++) {
- for (int Y = -2; Y <= 2; Y++) {
- for (int Z = -1; Z >= -7; Z--) {
- final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z);
- if (X > -2 && X < 2 && Y > -2 && Y < 2) {
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD1.getUnlocalizedName())) {
- runningCostAcc += 0.5f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT1.getCapacity();
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD2.getUnlocalizedName())) {
- runningCostAcc += 1.0f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT2.getCapacity();
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD3.getUnlocalizedName())) {
- runningCostAcc += 2.0f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT3.getCapacity();
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD4.getUnlocalizedName())) {
- runningCostAcc += 4.0f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT4.getCapacity();
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
- .equals(STORAGE_FIELD5.getUnlocalizedName())) {
- runningCostAcc += 8.0f;
- fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT5.getCapacity();
- } else {
- formationChecklist = false;
- }
- continue;
- }
-
- // Get next TE
- final IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
-
- // Corner allows only glass
- if (X == -2 && Y == -2 || X == 2 && Y == 2 || X == -2 && Y == 2 || X == 2 && Y == -2) {
- if (!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced))) {
- formationChecklist = false;
- }
- } else {
- // Tries to add TE as either of those kinds of hatches.
- // The number is the texture index number for the texture that needs to be painted over the hatch texture (TAE for GT++)
- if (!super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- // Also check for multi hatch
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == MULTI_HATCH) {
- final TE_TFFTMultiHatch mh =
- (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity(
- thisController.getXCoord() + offset.x(),
- thisController.getYCoord() + offset.y(),
- thisController.getZCoord() + offset.z());
- multiHatches.add(mh);
- } else if (!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced)) {
- formationChecklist = false;
- }
- }
- }
- }
- }
- }
-
- // Back segment
- for (int X = -2; X <= 2; X++) {
- for (int Y = -2; Y <= 2; Y++) {
- // Get next TE
- final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -8);
- final IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
-
- // Fluid hatches should touch the storage field.
- // Maintenance/Energy hatch can go anywhere
- if (X > -2 && X < 2 && Y > -2 && Y < 2) {
- if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == MULTI_HATCH) {
- final TE_TFFTMultiHatch mh =
- (TE_TFFTMultiHatch) thisController.getWorld().getTileEntity(
- thisController.getXCoord() + offset.x(),
- thisController.getYCoord() + offset.y(),
- thisController.getZCoord() + offset.z());
- multiHatches.add(mh);
- } else {
- formationChecklist = false;
- }
- }
- } else {
- if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
- if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Seems to be valid casing. Decrement counter.
- minCasingAmount--;
- } else {
- formationChecklist = false;
- }
- }
- }
- }
- }
-
- if (this.mEnergyHatches.size() < 1) {
- formationChecklist = false;
- }
-
- if (this.mMaintenanceHatches.size() < 1) {
- formationChecklist = false;
- }
-
- if (minCasingAmount > 0) {
- formationChecklist = false;
- }
-
- if (formationChecklist) {
- runningCost = Math.round(-runningCostAcc);
- // Update MultiFluidHandler in case storage cells have been changed
- final int capacityPerFluid = (int) Math.round(fluidCapacityAcc / 25.0f);
- if (mfh == null) {
- mfh = new MultiFluidHandler(capacityPerFluid);
- } else {
- if (mfh.getCapacity() != capacityPerFluid) {
- mfh = new MultiFluidHandler(capacityPerFluid, mfh.getFluids());
- }
- }
- for (TE_TFFTMultiHatch mh : multiHatches) {
- mh.setMultiFluidHandler(mfh);
- }
- }
-
- return formationChecklist;
- }
-
- @Override
- public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (doVoidExcess) {
- doVoidExcess = false;
- aPlayer.addChatComponentMessage(new ChatComponentText("Auto-voiding turned off"));
- } else {
- doVoidExcess = true;
- aPlayer.addChatComponentMessage(new ChatComponentText("Auto-voiding turned on"));
- }
- }
-
- @Override
- public String[] getInfoData() {
- final ArrayList<String> ll = mfh.getInfoData();
-
- ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET);
- ll.add("Auto-voiding: " + doVoidExcess);
- ll.add("Per-Fluid Capacity: " + mfh.getCapacity() + "L");
- ll.add("Running Cost: "
- // mEUt does not naturally reflect efficiency status. Do that here.
- + ((-super.mEUt) * 10000 / Math.max(1000, super.mEfficiency)) + "EU/t");
- ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus())
- ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET
- : EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET));
- ll.add("---------------------------------------------");
-
- final String[] a = new String[ll.size()];
- return ll.toArray(a);
- }
-
- @Override
- public void saveNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- nbt.setInteger("runningCost", runningCost);
- nbt.setBoolean("doVoidExcess", doVoidExcess);
-
- nbt.setInteger("capacityPerFluid", mfh.getCapacity());
- nbt.setTag("fluids", mfh.saveNBTData(new NBTTagCompound()));
-
- super.saveNBTData(nbt);
- }
-
- @Override
- public void loadNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- runningCost = nbt.getInteger("runningCost");
- doVoidExcess = nbt.getBoolean("doVoidExcess");
-
- mfh = new MultiFluidHandler();
- mfh.loadNBTData(nbt);
- for (TE_TFFTMultiHatch mh : multiHatches) {
- mh.setMultiFluidHandler(mfh);
- }
- super.loadNBTData(nbt);
- }
-
- @Override
- public boolean isGivingInformation() {
- return true;
- }
-
- @Override
- public int getMaxEfficiency(ItemStack var1) {
- return 10000;
- }
-
- @Override
- public int getPollutionPerTick(ItemStack var1) {
- return 0;
- }
-
- @Override
- public int getDamageToComponent(ItemStack var1) {
- return 0;
- }
-
- @Override
- public boolean explodesOnComponentBreak(ItemStack var1) {
- return false;
- }
+package common.tileentities;
+
+import common.Blocks;
+import common.blocks.*;
+import gregtech.api.enums.Textures.BlockIcons;
+import gregtech.api.gui.GT_GUIContainer_MultiMachine;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.*;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Utility;
+import kekztech.MultiFluidHandler;
+import net.minecraft.block.Block;
+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.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.input.Keyboard;
+import util.Vector3i;
+import util.Vector3ic;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+
+public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase {
+
+ private final static String glassNameIC2Reinforced = "blockAlloyGlass";
+ private final static Block CASING = Blocks.tfftCasing;
+ private final static Block_TFFTStorageFieldBlockT1 STORAGE_FIELD1 = (Block_TFFTStorageFieldBlockT1) Blocks.tfftStorageField1;
+ private final static Block_TFFTStorageFieldBlockT2 STORAGE_FIELD2 = (Block_TFFTStorageFieldBlockT2) Blocks.tfftStorageField2;
+ private final static Block_TFFTStorageFieldBlockT3 STORAGE_FIELD3 = (Block_TFFTStorageFieldBlockT3) Blocks.tfftStorageField3;
+ private final static Block_TFFTStorageFieldBlockT4 STORAGE_FIELD4 = (Block_TFFTStorageFieldBlockT4) Blocks.tfftStorageField4;
+ private final static Block_TFFTStorageFieldBlockT5 STORAGE_FIELD5 = (Block_TFFTStorageFieldBlockT5) Blocks.tfftStorageField5;
+ private final static int CASING_TEXTURE_ID = 176;
+
+ private MultiFluidHandler mfh;
+ private final HashSet<GTMTE_TFFTMultiHatch> sMultiHatches = new HashSet<>();
+
+ private int runningCost = 0;
+ private boolean doVoidExcess = false;
+ private byte fluidSelector = 0;
+
+ public GTMTE_FluidMultiStorage(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GTMTE_FluidMultiStorage(String aName) {
+ super(aName);
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) {
+ return new GTMTE_FluidMultiStorage(super.mName);
+ }
+
+ @Override
+ public String[] getDescription() {
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Fluid Tank")
+ .addInfo("High-Tech fluid tank that can hold up to 25 different fluids!")
+ .addInfo("Has 1/25th of the total capacity as capacity for each fluid.")
+ .addInfo("Right clicking the controller with a screwdriver will turn on excess voiding.")
+ .addInfo("Fluid storage amount and running cost depends on the storage field blocks used.")
+ .addSeparator()
+ .addInfo("Note on hatch locking:")
+ .addInfo("Use an Integrated Circuit in the GUI slot to limit which fluid is output.")
+ .addInfo("The index of a stored fluid can be obtained through the Tricorder.")
+ .addSeparator()
+ .beginStructureBlock(5, 9, 5, false)
+ .addController("Top Center")
+ .addCasingInfo("T.F.F.T. Casing", 20)
+ .addOtherStructurePart("Storage Field Blocks (Tier I-V)", "Inner 3x7x3 solid pillar")
+ .addOtherStructurePart("IC2 Reinforced Glass", "Outer 5x7x5 glass shell")
+ .addMaintenanceHatch("Any top or bottom casing")
+ .addEnergyHatch("Any top or bottom casing")
+ .addInputHatch("Instead of any casing or glass, has to touch storage field block")
+ .addOutputHatch("Instead of any casing or glass, has to touch storage field block")
+ .addStructureInfo("You can have a bunch of hatches")
+ .addOtherStructurePart("Multi I/O Hatches", "Instead of any casing or glass, has to touch storage field block")
+ .addStructureInfo("Use MIOH with conduits or fluid storage busses to see all fluids at once. If it's fixed.")
+ .addStructureInfo("Ask someone else why there's 4 versions, with 2 uncraftable ones")
+ .toolTipFinisher("KekzTech");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
+ }
+
+ @Override
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex,
+ boolean aActive, boolean aRedstone) {
+ return aSide == aFacing
+ ? new ITexture[]{BlockIcons.casingTexturePages[1][48],
+ new GT_RenderedTexture(aActive
+ ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE
+ : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)}
+ : new ITexture[]{BlockIcons.casingTexturePages[1][48]};
+ }
+
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(),
+ "MultiblockDisplay.png");
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack var1) {
+ return true;
+ }
+
+ @Override
+ public boolean checkRecipe(ItemStack guiSlotItem) {
+
+ super.mEfficiency = 10000 - (super.getIdealStatus() - super.getRepairStatus()) * 1000;
+ super.mEfficiencyIncrease = 10000;
+ super.mEUt = runningCost;
+ super.mMaxProgresstime = 10;
+
+ if(guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) {
+ this.fluidSelector = (byte) guiSlotItem.getItemDamage();
+ }
+
+ // If there are no basic I/O hatches, let multi hatches handle it and skip a lot of code!
+ if (sMultiHatches.size() > 0 && super.mInputHatches.size() == 0 && super.mOutputHatches.size() == 0) {
+ return true;
+ }
+
+ // Suck in fluids
+ final ArrayList<FluidStack> inputHatchFluids = super.getStoredFluids();
+ if (inputHatchFluids.size() > 0) {
+
+ for (FluidStack fluidStack : inputHatchFluids) {
+
+ final int pushed = mfh.pushFluid(fluidStack, true);
+ final FluidStack toDeplete = fluidStack.copy();
+ toDeplete.amount = pushed;
+ super.depleteInput(toDeplete);
+ }
+ }
+
+ // Push out fluids
+ if (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit")) {
+ final FluidStack storedFluid = mfh.getFluidCopy(fluidSelector);
+ // Sum available output capacity
+ int possibleOutput = 0;
+ for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) {
+ if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluid.getUnlocalizedName())) {
+ possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
+ } else if (outputHatch.getFluid() != null && outputHatch.getFluid().getUnlocalizedName().equals(storedFluid.getUnlocalizedName())) {
+ possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
+ } else if (outputHatch.getFluid() == null) {
+ possibleOutput += outputHatch.getCapacity() - outputHatch.getFluidAmount();
+ }
+ }
+ // Output as much as possible
+ final FluidStack tempStack = storedFluid.copy();
+ tempStack.amount = possibleOutput;
+ tempStack.amount = mfh.pullFluid(tempStack, fluidSelector, true);
+ super.addOutput(tempStack);
+
+ } else {
+ int tDistinct = mfh.getDistinctFluids();
+ int tDistinctCount = 0;
+ int tMaxDistinct = mfh.getMaxDistinctFluids();
+ for(int i = 0; i < tMaxDistinct && tDistinctCount< tDistinct;i++) {
+ final FluidStack storedFluidCopy = mfh.getFluidCopy(i);
+ if (storedFluidCopy == null)
+ continue;
+ tDistinctCount++;
+ storedFluidCopy.amount = 0;
+ // Calculate how much capacity all available Output Hatches offer
+ for (GT_MetaTileEntity_Hatch_Output outputHatch : super.mOutputHatches) {
+ if (outputHatch.isFluidLocked() && outputHatch.getLockedFluidName().equals(storedFluidCopy.getUnlocalizedName())) {
+ storedFluidCopy.amount += outputHatch.getCapacity() - outputHatch.getFluidAmount();
+ addFluidToHatch(storedFluidCopy,outputHatch);
+ } else if (outputHatch.getFluid() != null && outputHatch.getFluid().isFluidEqual(storedFluidCopy)) {
+ storedFluidCopy.amount += outputHatch.getCapacity() - outputHatch.getFluidAmount();
+ addFluidToHatch(storedFluidCopy,outputHatch);
+ } else if (!outputHatch.isFluidLocked() && outputHatch.getFluid() == null) {
+ storedFluidCopy.amount += outputHatch.getCapacity() - outputHatch.getFluidAmount();
+ addFluidToHatch(storedFluidCopy,outputHatch);
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public void addFluidToHatch(FluidStack aFluid, GT_MetaTileEntity_Hatch_Output aHatch) {
+ aFluid.amount = mfh.pullFluid(aFluid, true);
+ aHatch.fill(aFluid,true);
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+
+ if (mfh != null) {
+ mfh.setLock(!super.getBaseMetaTileEntity().isActive());
+ mfh.setFluidSelector(fluidSelector);
+ mfh.setDoVoidExcess(doVoidExcess);
+ }
+ }
+
+ public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) {
+ final Vector3i offset = new Vector3i();
+
+ // either direction on z-axis
+ if (forgeDirection.x() == 0 && forgeDirection.z() == -1) {
+ offset.x = x;
+ offset.y = y;
+ offset.z = z;
+ }
+ if (forgeDirection.x() == 0 && forgeDirection.z() == 1) {
+ offset.x = -x;
+ offset.y = y;
+ offset.z = -z;
+ }
+ // either direction on x-axis
+ if (forgeDirection.x() == -1 && forgeDirection.z() == 0) {
+ offset.x = z;
+ offset.y = y;
+ offset.z = -x;
+ }
+ if (forgeDirection.x() == 1 && forgeDirection.z() == 0) {
+ offset.x = -z;
+ offset.y = y;
+ offset.z = x;
+ }
+ // either direction on y-axis
+ if (forgeDirection.y() == -1) {
+ offset.x = x;
+ offset.y = z;
+ offset.z = y;
+ }
+
+ return offset;
+ }
+
+ @Override
+ public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) {
+ // Figure out the vector for the direction the back face of the controller is facing
+ final Vector3ic forgeDirection = new Vector3i(
+ ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX,
+ ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY,
+ ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ
+ );
+ int minCasingAmount = 20;
+ boolean formationChecklist = true; // If this is still true at the end, machine is good to go :)
+ float runningCostAcc = 0;
+ double fluidCapacityAcc = 0;
+
+ sMultiHatches.clear();
+
+ // Front segment
+ for (int X = -2; X <= 2; X++) {
+ for (int Y = -2; Y <= 2; Y++) {
+ if (X == 0 && Y == 0) {
+ continue; // Skip controller
+ }
+
+ // Get next TE
+ final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0);
+ final IGregTechTileEntity currentTE =
+ thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
+
+ // Fluid hatches should touch the storage field.
+ // Maintenance/Energy hatch can go anywhere
+ if (X > -2 && X < 2 && Y > -2 && Y < 2) {
+ if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !addMultiHatchToMachineList(currentTE, CASING_TEXTURE_ID)) {
+
+ // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
+ // Also check for multi hatch
+ if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ } else {
+ if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
+
+ // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
+ if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ }
+ }
+ }
+
+ // Middle seven long segment
+ for (int X = -2; X <= 2; X++) {
+ for (int Y = -2; Y <= 2; Y++) {
+ for (int Z = -1; Z >= -7; Z--) {
+ final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z);
+ if (X > -2 && X < 2 && Y > -2 && Y < 2) {
+ if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
+ .equals(STORAGE_FIELD1.getUnlocalizedName())) {
+ runningCostAcc += 0.5f;
+ fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT1.getCapacity();
+ } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
+ .equals(STORAGE_FIELD2.getUnlocalizedName())) {
+ runningCostAcc += 1.0f;
+ fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT2.getCapacity();
+ } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
+ .equals(STORAGE_FIELD3.getUnlocalizedName())) {
+ runningCostAcc += 2.0f;
+ fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT3.getCapacity();
+ } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
+ .equals(STORAGE_FIELD4.getUnlocalizedName())) {
+ runningCostAcc += 4.0f;
+ fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT4.getCapacity();
+ } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName()
+ .equals(STORAGE_FIELD5.getUnlocalizedName())) {
+ runningCostAcc += 8.0f;
+ fluidCapacityAcc += (float) Block_TFFTStorageFieldBlockT5.getCapacity();
+ } else {
+ formationChecklist = false;
+ }
+ continue;
+ }
+
+ // Get next TE
+ final IGregTechTileEntity currentTE =
+ thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
+
+ // Corner allows only glass
+ if (X == -2 && Y == -2 || X == 2 && Y == 2 || X == -2 && Y == 2 || X == 2 && Y == -2) {
+ if (!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced))) {
+ formationChecklist = false;
+ }
+ } else {
+ // Tries to add TE as either of those kinds of hatches.
+ // The number is the texture index number for the texture that needs to be painted over the hatch texture (TAE for GT++)
+ if (!super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !addMultiHatchToMachineList(currentTE, CASING_TEXTURE_ID)) {
+
+ // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
+ // Also check for multi hatch
+ if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else if (!thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameIC2Reinforced)) {
+ formationChecklist = false;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Back segment
+ for (int X = -2; X <= 2; X++) {
+ for (int Y = -2; Y <= 2; Y++) {
+ // Get next TE
+ final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, -8);
+ final IGregTechTileEntity currentTE =
+ thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
+
+ // Fluid hatches should touch the storage field.
+ // Maintenance/Energy hatch can go anywhere
+ if (X > -2 && X < 2 && Y > -2 && Y < 2) {
+ if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addInputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addOutputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !addMultiHatchToMachineList(currentTE, CASING_TEXTURE_ID)) {
+
+ // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
+ if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ } else {
+ if (!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
+ && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
+
+ // If it's not a hatch, is it the right casing for this machine? Check block and block meta.
+ if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
+ // Seems to be valid casing. Decrement counter.
+ minCasingAmount--;
+ } else {
+ formationChecklist = false;
+ }
+ }
+ }
+ }
+ }
+
+ if (this.mEnergyHatches.size() < 1) {
+ formationChecklist = false;
+ }
+
+ if (this.mMaintenanceHatches.size() != 1) {
+ formationChecklist = false;
+ }
+
+ if (minCasingAmount > 0) {
+ formationChecklist = false;
+ }
+
+ if (formationChecklist) {
+ runningCost = Math.round(-runningCostAcc);
+ // Update MultiFluidHandler in case storage cells have been changed
+ final int capacityPerFluid = (int) Math.round(fluidCapacityAcc / 25.0f);
+ if (mfh == null) {
+ mfh = MultiFluidHandler.newInstance(25, capacityPerFluid);
+ } else {
+ if (mfh.getCapacity() != capacityPerFluid) {
+ mfh = MultiFluidHandler.newAdjustedInstance(mfh, capacityPerFluid);
+ }
+ }
+ for (GTMTE_TFFTMultiHatch mh : sMultiHatches) {
+ mh.setMultiFluidHandler(mfh);
+ }
+ }
+
+ return formationChecklist;
+ }
+
+ public boolean addMultiHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) {
+ return false;
+ } else if (aMetaTileEntity instanceof GTMTE_TFFTMultiHatch) {
+ ((GTMTE_TFFTMultiHatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.sMultiHatches.add((GTMTE_TFFTMultiHatch)aMetaTileEntity);
+ } else {
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ doVoidExcess = !doVoidExcess;
+ GT_Utility.sendChatToPlayer(aPlayer, doVoidExcess ? "Auto-voiding enabled" : "Auto-voiding disabled");
+ }
+
+ @Override
+ public String[] getInfoData() {
+ final ArrayList<String> ll = mfh.getInfoData();
+
+ ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET);
+ ll.add("Auto-voiding: " + doVoidExcess);
+ ll.add("Per-Fluid Capacity: " + mfh.getCapacity() + "L");
+ ll.add("Running Cost: "
+ // mEUt does not naturally reflect efficiency status. Do that here.
+ + ((-super.mEUt) * 10000 / Math.max(1000, super.mEfficiency)) + "EU/t");
+ ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus())
+ ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET
+ : EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET));
+ ll.add("---------------------------------------------");
+
+ final String[] a = new String[ll.size()];
+ return ll.toArray(a);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound nbt) {
+ nbt = (nbt == null) ? new NBTTagCompound() : nbt;
+
+ nbt.setInteger("runningCost", runningCost);
+ nbt.setBoolean("doVoidExcess", doVoidExcess);
+
+ nbt.setInteger("capacityPerFluid", mfh.getCapacity());
+ nbt.setTag("fluids", mfh.saveNBTData(new NBTTagCompound()));
+
+ super.saveNBTData(nbt);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound nbt) {
+ nbt = (nbt == null) ? new NBTTagCompound() : nbt;
+
+ runningCost = nbt.getInteger("runningCost");
+ doVoidExcess = nbt.getBoolean("doVoidExcess");
+
+ mfh = MultiFluidHandler.loadNBTData(nbt);
+ for (GTMTE_TFFTMultiHatch mh : sMultiHatches) {
+ mh.setMultiFluidHandler(mfh);
+ }
+ super.loadNBTData(nbt);
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack var1) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack var1) {
+ return 0;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack var1) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack var1) {
+ return false;
+ }
} \ No newline at end of file
diff --git a/src/main/java/common/tileentities/GTMTE_ItemServer.java b/src/main/java/common/tileentities/GTMTE_ItemServer.java
deleted file mode 100644
index cfff360ce4..0000000000
--- a/src/main/java/common/tileentities/GTMTE_ItemServer.java
+++ /dev/null
@@ -1,393 +0,0 @@
-package common.tileentities;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-
-import org.lwjgl.input.Keyboard;
-
-import common.Blocks;
-import common.blocks.Block_ItemServerDrive;
-import common.blocks.Block_ItemServerIOPort;
-import common.blocks.Block_ItemServerRackCasing;
-import gregtech.api.enums.Textures.BlockIcons;
-import gregtech.api.gui.GT_GUIContainer_MultiMachine;
-import gregtech.api.interfaces.ITexture;
-import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
-import gregtech.api.objects.GT_RenderedTexture;
-import kekztech.MultiItemHandler;
-import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraftforge.common.util.ForgeDirection;
-import util.MultiBlockTooltipBuilder;
-import util.Vector3i;
-import util.Vector3ic;
-
-public class GTMTE_ItemServer extends GT_MetaTileEntity_MultiBlockBase {
-
- private static final int BASE_SEGMENT_ENERGY_COST = 1;
- private static final int BASE_PER_ITEM_CAPACITY = 1024;
- private static final int BASE_ITEM_TYPES_PER_SEGMENT = 4;
-
- private final Block_ItemServerDrive DRIVE = (Block_ItemServerDrive) Blocks.itemServerDrive;
- private final Block_ItemServerRackCasing CASING = (Block_ItemServerRackCasing) Blocks.itemServerRackCasing;
- private final Block_ItemServerIOPort IO_PORT = (Block_ItemServerIOPort) Blocks.itemServerIOPort;
- private final String ALU_FRAME_BOX_NAME = "gt.blockmachines";
- private final int ALU_FRAME_BOX_META = 6;
- private final int CASING_TEXTURE_ID = 176;
-
- private MultiItemHandler mih;
- private HashSet<TE_ItemServerIOPort> ioPorts = new HashSet<>();
- private int sliceCount = 0;
-
- public GTMTE_ItemServer(int aID, String aName, String aNameRegional) {
- super(aID, aName, aNameRegional);
- }
-
- public GTMTE_ItemServer(String aName) {
- super(aName);
- }
-
- @Override
- public IMetaTileEntity newMetaEntity(IGregTechTileEntity var1) {
- return new GTMTE_ItemServer(super.mName);
- }
-
- @Override
- public String[] getDescription() {
- final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
- b.addInfo("[W.I.P - Probably doesn't work]")
- .addInfo("High-Tech item storage!")
- .addInfo("Variable length: Slices 2-4 can be repeated as long as the total length does not exceed 16 blocks.")
- .addInfo("Each segment offers storage for 128 item types")
- .addInfo("Storage capacity per item depends on the controller configuration.")
- .addInfo("Insert an Integrated Circuit into the controller with your desired configuration.")
- .addInfo("The base configuration (0) is 1024 items per type. For each higher level, the capacity quadruples.")
- .addInfo("Each slice also adds 1EU/t of power consumption and doubles with rising configuration values.")
- .addInfo("Valid config values are from zero to eight.")
- .addSeparator()
- .beginStructureBlock(3, 5, 4)
- .addController("Front Bottom Center")
- .addEnergyHatch("Any casing")
- .addOtherStructurePart("Front slice", "3x5x1 Item Server Rack Casing")
- .addOtherStructurePart("2nd and 3rd slice, center", "1x4x1 Aluminium Frame Box")
- .addOtherStructurePart("2nd and 3rd slice, top", "3x1x1 Item Server Rack Casing")
- .addOtherStructurePart("2nd and 3rd slice, sides", "2x 1x4x1 Item Server Drive")
- .addOtherStructurePart("Back slice", "3x5x1 Item Server Rack Casing")
- .signAndFinalize("Kekzdealer");
- if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return b.getInformation();
- } else {
- return b.getStructureInformation();
- }
- }
-
- @Override
- public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex,
- boolean aActive, boolean aRedstone) {
- return aSide == aFacing
- ? new ITexture[]{BlockIcons.casingTexturePages[1][48],
- new GT_RenderedTexture(aActive
- ? BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE
- : BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)}
- : new ITexture[]{BlockIcons.casingTexturePages[1][48]};
- }
-
- public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(),
- "MultiblockDisplay.png");
- }
-
- @Override
- public boolean isCorrectMachinePart(ItemStack var1) {
- return true;
- }
-
- @Override
- public boolean checkRecipe(ItemStack guiSlotItem) {
- final int config = (guiSlotItem != null && guiSlotItem.getUnlocalizedName().equals("gt.integrated_circuit"))
- ? Math.min(8, guiSlotItem.getItemDamage()) : 0;
-
- this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000;
- this.mEfficiencyIncrease = 10000;
- this.mEUt = (int) -(BASE_SEGMENT_ENERGY_COST * sliceCount * Math.pow(2, config));
- super.mMaxProgresstime = 20;
-
- mih.setPerTypeCapacity((int) (BASE_PER_ITEM_CAPACITY * Math.pow(4, config)));
-
- return true;
- }
-
- @Override
- public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
- super.onPostTick(aBaseMetaTileEntity, aTick);
-
- if(mih != null) {
- mih.setLock(!super.getBaseMetaTileEntity().isActive());
- }
- }
-
- public Vector3ic rotateOffsetVector(Vector3ic forgeDirection, int x, int y, int z) {
- final Vector3i offset = new Vector3i();
-
- // either direction on z-axis
- if(forgeDirection.x() == 0 && forgeDirection.z() == -1) {
- offset.x = x;
- offset.y = y;
- offset.z = z;
- }
- if(forgeDirection.x() == 0 && forgeDirection.z() == 1) {
- offset.x = -x;
- offset.y = y;
- offset.z = -z;
- }
- // either direction on x-axis
- if(forgeDirection.x() == -1 && forgeDirection.z() == 0) {
- offset.x = z;
- offset.y = y;
- offset.z = -x;
- }
- if(forgeDirection.x() == 1 && forgeDirection.z() == 0) {
- offset.x = -z;
- offset.y = y;
- offset.z = x;
- }
-
- return offset;
- }
-
- @Override
- public boolean checkMachine(IGregTechTileEntity thisController, ItemStack guiSlotItem) {
- // Figure out the vector for the direction the back face of the controller is facing
- final Vector3ic forgeDirection = new Vector3i(
- ForgeDirection.getOrientation(thisController.getBackFacing()).offsetX,
- ForgeDirection.getOrientation(thisController.getBackFacing()).offsetY,
- ForgeDirection.getOrientation(thisController.getBackFacing()).offsetZ
- );
- boolean formationChecklist = true;
-
- // Front slice
- for(int X = -1; X <= 1; X++) {
- for(int Y = 0; Y <= 4; Y++) {
- if(X == 0 && Y == 0) {
- continue; // is controller
- }
-
- // Get next TE
- final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, 0);
- IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
-
- if(!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
-
- // Is casing or IO port?
- if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Is casing, but there's no casing requirements
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == IO_PORT) {
- final TE_ItemServerIOPort port =
- (TE_ItemServerIOPort) thisController.getWorld().getTileEntity(
- thisController.getXCoord() + offset.x(),
- thisController.getYCoord() + offset.y(),
- thisController.getZCoord() + offset.z());
- ioPorts.add(port);
- } else {
- formationChecklist = false;
- }
- }
- }
- }
-
- // Check slices
- int segmentsFound = 0;
- int zOffset = -1; // -1 is the first slice after the front one. It goes in negative direction.
-
- while(segmentsFound < 5) {
- if(checkSegment(thisController, forgeDirection, zOffset)) {
- segmentsFound++;
- zOffset -= 3; // Each segment is 3 blocks long, so progress Z by -3
-
- System.out.println("Item Server segment approved: " + segmentsFound);
- } else {
- System.out.println("Item Server segment rejected: " + (segmentsFound + 1));
- break;
- }
- }
-
- if(segmentsFound < 1) {
- System.out.println("At least one slice required for storage");
- formationChecklist = false;
- }
-
- if(this.mEnergyHatches.size() < 1) {
- System.out.println("At least one energy hatch is required!");
- formationChecklist = false;
- }
-
- if(this.mMaintenanceHatches.size() < 1) {
- System.out.println("You need a maintenance hatch to do maintenance.");
- formationChecklist = false;
- }
-
- if(formationChecklist) {
- sliceCount = segmentsFound;
-
- if(mih == null) {
- mih = new MultiItemHandler();
- mih.setItemTypeCapacity(segmentsFound * BASE_ITEM_TYPES_PER_SEGMENT);
- }
- System.out.println("Configuring " + ioPorts.size() + " ports");
- for(TE_ItemServerIOPort port : ioPorts) {
- port.setMultiItemHandler(mih);
- }
- }
-
- return formationChecklist;
- }
-
- public boolean checkSegment(IGregTechTileEntity thisController, Vector3ic forgeDirection, int zOffset) {
- boolean formationChecklist = true;
- // Slice by slice
- for(int Z = 0; Z >= -2; Z--) {
- // Is not back slice
- if(Z != -2) {
- // Left to right
- for(int X = -1; X <= 1; X++) {
- // Bottom to top
- for(int Y = 0; Y <= 4; Y++) {
- final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, zOffset + Z);
-
- // Server rack roof
- if(Y == 4) {
- final IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
-
- if(!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
- // Is casing or IO port?
- if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Is casing, but there's no casing requirements
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == IO_PORT) {
- final TE_ItemServerIOPort port =
- (TE_ItemServerIOPort) thisController.getWorld().getTileEntity(
- thisController.getXCoord() + offset.x(),
- thisController.getYCoord() + offset.y(),
- thisController.getZCoord() + offset.z());
- ioPorts.add(port);
- } else {
- formationChecklist = false;
- }
- }
- }
-
- // Middle wall is aluminium frame boxes
- else if(Y <= 3 && X == 0) {
- if(!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(ALU_FRAME_BOX_NAME))
- || !(thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z()) == ALU_FRAME_BOX_META)) {
- formationChecklist = false;
- }
- }
-
- // Side walls are item server drives
- else if(Y <= 3 && X != 0) {
- if(!(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == DRIVE)) {
- formationChecklist = false;
- }
- }
- }
- }
- } else {
- // Back slice
- for(int X = -1; X <= 1; X++) {
- for(int Y = 0; Y <= 4; Y++) {
-
- final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, zOffset + Z);
- IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
-
- if(!super.addMaintenanceToMachineList(currentTE, CASING_TEXTURE_ID)
- && !super.addEnergyInputToMachineList(currentTE, CASING_TEXTURE_ID)) {
- // Is casing or IO port?
- if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == CASING) {
- // Is casing, but there's no casing requirements
- } else if (thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == IO_PORT) {
- final TE_ItemServerIOPort port =
- (TE_ItemServerIOPort) thisController.getWorld().getTileEntity(
- thisController.getXCoord() + offset.x(),
- thisController.getYCoord() + offset.y(),
- thisController.getZCoord() + offset.z());
- ioPorts.add(port);
- } else {
- formationChecklist = false;
- }
- }
- }
- }
- }
- }
-
-
- return formationChecklist;
- }
-
- @Override
- public String[] getInfoData() {
- final ArrayList<String> ll = new ArrayList<>();//mfh.getInfoData();
-
- ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET);
- ll.add("Per-Item Capacity: " + mih.getPerTypeCapacity());
- ll.add("Item-Type Capacity: " + BASE_ITEM_TYPES_PER_SEGMENT * sliceCount);
- ll.add("Running Cost: "
- // mEUt does not naturally reflect efficiency status. Do that here.
- + ((-super.mEUt) * 10000 / Math.max(1000, super.mEfficiency)) + "EU/t");
- ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus())
- ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET
- : EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET));
- ll.add("---------------------------------------------");
-
- final String[] a = new String[ll.size()];
- return ll.toArray(a);
- }
-
- @Override
- public void saveNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- super.saveNBTData(nbt);
- }
-
- @Override
- public void loadNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- super.loadNBTData(nbt);
- }
-
- @Override
- public boolean isGivingInformation() {
- return true;
- }
-
- @Override
- public int getMaxEfficiency(ItemStack var1) {
- return 10000;
- }
-
- @Override
- public int getPollutionPerTick(ItemStack var1) {
- return 0;
- }
-
- @Override
- public int getDamageToComponent(ItemStack var1) {
- return 0;
- }
-
- @Override
- public boolean explodesOnComponentBreak(ItemStack var1) {
- return false;
- }
-}
diff --git a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
index fc743a56d3..b3d2c9fea3 100644
--- a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
+++ b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
@@ -11,11 +11,12 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine;
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.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -23,7 +24,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.input.Keyboard;
-import util.MultiBlockTooltipBuilder;
import util.Vector3i;
import util.Vector3ic;
@@ -51,14 +51,17 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
private final Set<GT_MetaTileEntity_Hatch_EnergyTunnel> mEnergyTunnelsTT = new HashSet<>();
private final Set<GT_MetaTileEntity_Hatch_DynamoTunnel> mDynamoTunnelsTT = new HashSet<>();
// Count the amount of capacitors of each tier in each slot (translate with meta - 1)
- private final int[] capacitors = new int[5];
+ private final int[] capacitors = new int[7];
private BigInteger capacity = BigInteger.ZERO;
private BigInteger stored = BigInteger.ZERO;
private BigInteger passiveDischargeAmount = BigInteger.ZERO;
- private BigInteger intputLastTick = BigInteger.ZERO;
+ private BigInteger inputLastTick = BigInteger.ZERO;
private BigInteger outputLastTick = BigInteger.ZERO;
private int repairStatusCache = 0;
+ private long mMaxEUIn = 0;
+ private long mMaxEUOut = 0;
+
public GTMTE_LapotronicSuperCapacitor(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
@@ -74,29 +77,34 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
@Override
public String[] getDescription() {
- final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
- b.addInfo("Power storage structure!")
- .addInfo("Looses energy equal to 1% of the total capacity every 24 hours.")
- .addInfo("EXCEPTION: Ultimate Capacitors only count as Lapotronic Capacitors (UV) for the")
- .addInfo("purpose of passive loss calculation. The full capacity is counted towards the actual power capacity.")
- .addSeparator()
- .addInfo("Glass shell has to be Tier - 2 of the highest capacitor tier")
- .addInfo("UV-Tier glass required for TecTech Laser Hatches")
- .addInfo("Modular height of 4 to 18 blocks.")
- .addSeparator()
- .beginStructureBlock(5, 4, 5)
- .addController("Front Bottom Center")
- .addDynamoHatch("Instead of any casing")
- .addEnergyHatch("Instead of any casing")
- .addOtherStructurePart("Lapotronic Capacitor Base", "5x2x5 base (at least 17x)")
- .addOtherStructurePart("Lapotronic Capacitor, (Really) Ultimate Capacitor", "Center 3x(1-15)x3 above base (9-135 blocks)")
- .addOtherStructurePart("Borosilicate Glass", "41-265x, Encase capacitor pillar")
- .addMaintenanceHatch("Instead of any casing")
- .signAndFinalize("Kekzdealer");
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Battery Buffer")
+ .addInfo("Power storage structure. Does not charge batteries or tools, however.")
+ .addInfo("Loses energy equal to 1% of the total capacity every 24 hours.")
+ .addInfo("Exception: Ultimate Capacitors only count as Lapotronic Capacitors (UV) for the")
+ .addInfo("purposes of passive loss calculation. The full capacity is counted towards the actual power capacity.")
+ .addSeparator()
+ .addInfo("Glass shell has to be Tier - 2 of the highest capacitor tier")
+ .addInfo("UV-tier glass required for TecTech Laser Hatches")
+ .addInfo("Add more or better capacitors to increase capacity")
+ .addSeparator()
+ .beginStructureBlock(5, 4, 5, false)
+ .addStructureInfo("Modular height of 4-18 blocks.")
+ .addController("Front center bottom")
+ .addOtherStructurePart("Lapotronic Super Capacitor Casing", "5x2x5 base (at least 17x)")
+ .addOtherStructurePart("Lapotronic Capacitor (EV-UV), Ultimate Capacitor (UHV)", "Center 3x(1-15)x3 above base (9-135 blocks)")
+ .addStructureInfo("You can also use the Empty Capacitor to save materials if you use it for less than half the blocks")
+ .addOtherStructurePart("Borosilicate Glass (any)", "41-265x, Encase capacitor pillar")
+ .addEnergyHatch("Any casing")
+ .addDynamoHatch("Any casing")
+ .addOtherStructurePart("Laser Target/Source Hatches", "Any casing, must be using UV-tier glass")
+ .addStructureInfo("You can have several I/O Hatches")
+ .addMaintenanceHatch("Any casing")
+ .toolTipFinisher("KekzTech");
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return b.getInformation();
+ return tt.getInformation();
} else {
- return b.getStructureInformation();
+ return tt.getStructureInformation();
}
}
@@ -184,6 +192,9 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
mDynamoHatchesTT.clear();
mEnergyTunnelsTT.clear();
mDynamoTunnelsTT.clear();
+
+ mMaxEUIn = 0;
+ mMaxEUOut = 0;
// Temp var for loss calculation
BigInteger tempCapacity = BigInteger.ZERO;
@@ -196,8 +207,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
}
final Vector3ic offset = rotateOffsetVector(forgeDirection, X, Y, Z);
- final IGregTechTileEntity currentTE =
- thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
+ final IGregTechTileEntity currentTE = thisController.getIGregTechTileEntityOffset(offset.x(), offset.y(), offset.z());
// Tries to add TE as either of those kinds of hatches.
// The number is the texture index number for the texture that needs to be painted over the hatch texture
@@ -229,14 +239,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
final int meta = thisController.getMetaIDOffset(offset.x(), offset.y(), offset.z());
if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()) == LSC_PART && (meta > 0)) {
// Add capacity
- if(meta <= 4){
- final long c = (long) (100000000L * Math.pow(10, meta - 1));
- tempCapacity = tempCapacity.add(BigInteger.valueOf(c));
- capacity = capacity.add(BigInteger.valueOf(c));
- } else if(meta <= 5){
- tempCapacity = tempCapacity.add(BigInteger.valueOf((long) (100000000L * Math.pow(10, 3))));
- capacity = capacity.add(MAX_LONG);
- }
+ tempCapacity = calculateTempCapacity(tempCapacity, meta);
capacitors[meta - 1]++;
} else if(thisController.getBlockOffset(offset.x(), offset.y(), offset.z()).getUnlocalizedName().equals(glassNameBorosilicate)){
firstGlassHeight = Y;
@@ -281,7 +284,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
}
}
- if(minCasingAmount > 0){
+ if(minCasingAmount > 0) {
formationChecklist = false;
}
@@ -290,11 +293,8 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
// Borosilicate glass after 5 are just recolours of 0
final int colourCorrectedMeta = firstGlassMeta > 5 ? 0 : firstGlassMeta;
for(int highestCapacitor = capacitors.length - 1; highestCapacitor >= 0; highestCapacitor--){
- if(capacitors[highestCapacitor] > 0){
- if(colourCorrectedMeta < highestCapacitor){
- formationChecklist = false;
- }
- break;
+ if(capacitors[highestCapacitor] > 0 && formationChecklist == true) {
+ formationChecklist = checkGlassTier(colourCorrectedMeta, highestCapacitor);
}
}
@@ -305,44 +305,115 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
}
mEnergyTunnelsTT.clear();
mDynamoTunnelsTT.clear();
-
}
+ //Check if enough (more than 50%) non-empty caps
+ double emptyCheck = ((double) capacitors[5]) / (double) (capacitors[0] + capacitors[1] + capacitors[2] + capacitors[3] + capacitors[4] + capacitors[6]);
+ if (emptyCheck > 0.5)
+ formationChecklist = false;
+
// Calculate total capacity
- capacity = BigInteger.ZERO;
- for(int i = 0; i < capacitors.length; i++){
- if(i <= 3){
- final long c = (long) (100000000L * Math.pow(10, i));
- capacity = capacity.add(
- BigInteger.valueOf(c).multiply(BigInteger.valueOf(capacitors[i])));
- } else {
- capacity = capacity.add(
- MAX_LONG.multiply(BigInteger.valueOf(capacitors[i])));
- }
- }
+ calculateCapacity();
+
// Calculate how much energy to void each tick
passiveDischargeAmount = new BigDecimal(tempCapacity).multiply(PASSIVE_DISCHARGE_FACTOR_PER_TICK).toBigInteger();
passiveDischargeAmount = recalculateLossWithMaintenance(super.getRepairStatus());
return formationChecklist;
}
+ public BigInteger calculateTempCapacity(BigInteger tempCapacity, int meta) {
+ switch(meta) {
+ case 1: tempCapacity = tempCapacity.add(BigInteger.valueOf(100000000L)); capacity = capacity.add(BigInteger.valueOf(100000000L)); break;
+ case 2: tempCapacity = tempCapacity.add(BigInteger.valueOf(1000000000L)); capacity = capacity.add(BigInteger.valueOf(1000000000L)); break;
+ case 3: tempCapacity = tempCapacity.add(BigInteger.valueOf(10000000000L)); capacity = capacity.add(BigInteger.valueOf(10000000000L)); break;
+ case 4: tempCapacity = tempCapacity.add(BigInteger.valueOf(100000000000L)); capacity = capacity.add(BigInteger.valueOf(100000000000L)); break;
+ case 5: tempCapacity = tempCapacity.add(BigInteger.valueOf(100000000000L)); capacity = capacity.add(MAX_LONG); break;
+ case 6: break;
+ case 7: tempCapacity = tempCapacity.add(BigInteger.valueOf(10000000L)); capacity = capacity.add(BigInteger.valueOf(10000000L)); break;
+ default: break;
+ }
+ return tempCapacity;
+ }
+
+ public boolean checkGlassTier(int colourCorrectedMeta, int highestCapacitor) {
+ Boolean check = true;
+ switch (highestCapacitor) {
+ case 0://For the empty/EV/IV caps, any BS glass works. The case is meta - 1
+ break;
+ case 1:
+ if(colourCorrectedMeta < highestCapacitor) {
+ check = false;
+ }
+ break;
+ case 2:
+ if(colourCorrectedMeta < highestCapacitor) {
+ check = false;
+ }
+ break;
+ case 3:
+ if(colourCorrectedMeta < highestCapacitor) {
+ check = false;
+ }
+ break;
+ case 4:
+ if(colourCorrectedMeta < highestCapacitor) {
+ check = false;
+ }
+ break;
+ case 5:
+ break;
+ case 6:
+ break;
+ default:
+ check = false;
+ }
+ return check; //Return false if it fails the check, otherwise true
+ }
+
+ public void calculateCapacity() {
+ capacity = BigInteger.ZERO;
+ for(int i = 0; i < capacitors.length; i++) {
+ switch(i) {
+ case 0: capacity = capacity.add(BigInteger.valueOf(100000000L).multiply(BigInteger.valueOf(capacitors[i]))); break;
+ case 1: capacity = capacity.add(BigInteger.valueOf(1000000000L).multiply(BigInteger.valueOf(capacitors[i]))); break;
+ case 2: capacity = capacity.add(BigInteger.valueOf(10000000000L).multiply(BigInteger.valueOf(capacitors[i]))); break;
+ case 3: capacity = capacity.add(BigInteger.valueOf(100000000000L).multiply(BigInteger.valueOf(capacitors[i]))); break;
+ case 4: capacity = capacity.add(MAX_LONG.multiply(BigInteger.valueOf(capacitors[i]))); break;
+ case 5: break;
+ case 6: capacity = capacity.add(BigInteger.valueOf(10000000L).multiply(BigInteger.valueOf(capacitors[i]))); break;
+ default: break;
+ }
+ }
+ }
+
@Override
public boolean addEnergyInputToMachineList(IGregTechTileEntity te, int aBaseCasingIndex) {
if (te == null) {
return false;
} else {
final IMetaTileEntity mte = te.getMetaTileEntity();
+
+ if (mte instanceof MetaTileEntity) {
+ mMaxEUIn += ((MetaTileEntity) mte).maxEUInput() * ((MetaTileEntity) mte).maxAmperesIn();
+ }
+
if (mte instanceof GT_MetaTileEntity_Hatch_Energy) {
// Add GT hatches
- ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex);
- return super.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) mte);
+ final GT_MetaTileEntity_Hatch_Energy tHatch = ((GT_MetaTileEntity_Hatch_Energy) mte);
+ tHatch.updateTexture(aBaseCasingIndex);
+
+ return super.mEnergyHatches.add(tHatch);
} else if(mte instanceof GT_MetaTileEntity_Hatch_EnergyTunnel) {
// Add TT Laser hatches
+ final GT_MetaTileEntity_Hatch_EnergyTunnel tHatch = ((GT_MetaTileEntity_Hatch_EnergyTunnel) mte);
+
return mEnergyTunnelsTT.add((GT_MetaTileEntity_Hatch_EnergyTunnel) mte);
} else if(mte instanceof GT_MetaTileEntity_Hatch_EnergyMulti) {
// Add TT hatches
- ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex);
- return mEnergyHatchesTT.add((GT_MetaTileEntity_Hatch_EnergyMulti) mte);
+ final GT_MetaTileEntity_Hatch_EnergyMulti tHatch = (GT_MetaTileEntity_Hatch_EnergyMulti) mte;
+ tHatch.updateTexture(aBaseCasingIndex);
+
+ return mEnergyHatchesTT.add(tHatch);
} else {
return false;
}
@@ -355,17 +426,28 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
return false;
} else {
final IMetaTileEntity mte = te.getMetaTileEntity();
+
+ if (mte instanceof MetaTileEntity) {
+ mMaxEUOut += ((MetaTileEntity) mte).maxEUOutput() * ((MetaTileEntity) mte).maxAmperesOut();
+ }
+
if (mte instanceof GT_MetaTileEntity_Hatch_Dynamo) {
// Add GT hatches
- ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex);
- return super.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) mte);
+ final GT_MetaTileEntity_Hatch_Dynamo tDynamo = (GT_MetaTileEntity_Hatch_Dynamo) mte;
+ tDynamo.updateTexture(aBaseCasingIndex);
+
+ return super.mDynamoHatches.add(tDynamo);
} else if(mte instanceof GT_MetaTileEntity_Hatch_DynamoTunnel) {
// Add TT Laser hatches
- return mDynamoTunnelsTT.add((GT_MetaTileEntity_Hatch_DynamoTunnel) mte);
+ final GT_MetaTileEntity_Hatch_DynamoTunnel tDynamo = (GT_MetaTileEntity_Hatch_DynamoTunnel) mte;
+
+ return mDynamoTunnelsTT.add(tDynamo);
} else if(mte instanceof GT_MetaTileEntity_Hatch_DynamoMulti) {
// Add TT hatches
- ((GT_MetaTileEntity_Hatch) mte).updateTexture(aBaseCasingIndex);
- return mDynamoHatchesTT.add((GT_MetaTileEntity_Hatch_DynamoMulti) mte);
+ final GT_MetaTileEntity_Hatch_DynamoMulti tDynamo = (GT_MetaTileEntity_Hatch_DynamoMulti) mte;
+ tDynamo.updateTexture(aBaseCasingIndex);
+
+ return mDynamoHatchesTT.add(tDynamo);
} else {
return false;
}
@@ -375,9 +457,11 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
@Override
public boolean onRunningTick(ItemStack stack){
// Reset I/O cache
- intputLastTick = BigInteger.ZERO;
+ inputLastTick = BigInteger.ZERO;
outputLastTick = BigInteger.ZERO;
+ //System.out.println(getBaseMetaTileEntity().)
+
// Draw energy from GT hatches
for(GT_MetaTileEntity_Hatch_Energy eHatch : super.mEnergyHatches) {
if(eHatch == null || eHatch.getBaseMetaTileEntity().isInvalidTileEntity()) {
@@ -387,7 +471,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
if(eHatch.getEUVar() >= power) {
eHatch.setEUVar(eHatch.getEUVar() - power);
stored = stored.add(BigInteger.valueOf(power));
- intputLastTick = intputLastTick.add(BigInteger.valueOf(power));
+ inputLastTick = inputLastTick.add(BigInteger.valueOf(power));
}
}
// Output energy to GT hatches
@@ -411,7 +495,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
if(eHatch.getEUVar() >= power) {
eHatch.setEUVar(eHatch.getEUVar() - power);
stored = stored.add(BigInteger.valueOf(power));
- intputLastTick = intputLastTick.add(BigInteger.valueOf(power));
+ inputLastTick = inputLastTick.add(BigInteger.valueOf(power));
}
}
// Output energy to TT hatches
@@ -436,7 +520,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
if(eHatch.getEUVar() >= power) {
eHatch.setEUVar(eHatch.getEUVar() - power);
stored = stored.add(BigInteger.valueOf(power));
- intputLastTick = intputLastTick.add(BigInteger.valueOf(power));
+ inputLastTick = inputLastTick.add(BigInteger.valueOf(power));
}
}
// Output energy to TT Laser hatches
@@ -460,6 +544,11 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
stored = stored.subtract(passiveDischargeAmount);
stored = (stored.compareTo(BigInteger.ZERO) <= 0) ? BigInteger.ZERO : stored;
+ IGregTechTileEntity tBMTE = this.getBaseMetaTileEntity();
+
+ tBMTE.injectEnergyUnits((byte)ForgeDirection.UNKNOWN.ordinal(), inputLastTick.longValue(), 1L);
+ tBMTE.drainEnergyUnits((byte)ForgeDirection.UNKNOWN.ordinal(), outputLastTick.longValue(), 1L);
+
return true;
}
@@ -500,13 +589,17 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
@Override
public String[] getInfoData() {
+ final IGregTechTileEntity tGTTE = getBaseMetaTileEntity();
+
final ArrayList<String> ll = new ArrayList<>();
ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET);
ll.add("Used Capacity: " + NumberFormat.getNumberInstance().format(stored) + "EU");
ll.add("Total Capacity: " + NumberFormat.getNumberInstance().format(capacity) + "EU");
ll.add("Passive Loss: " + NumberFormat.getNumberInstance().format(passiveDischargeAmount) + "EU/t");
- ll.add("EU IN: " + NumberFormat.getNumberInstance().format(intputLastTick) + "EU/t");
+ ll.add("EU IN: " + NumberFormat.getNumberInstance().format(inputLastTick) + "EU/t");
ll.add("EU OUT: " + NumberFormat.getNumberInstance().format(outputLastTick) + "EU/t");
+ ll.add("Avg EU IN: " + NumberFormat.getNumberInstance().format(tGTTE.getAverageElectricInput()));
+ ll.add("Avg EU OUT: " + NumberFormat.getNumberInstance().format(tGTTE.getAverageElectricOutput()));
ll.add("Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus())
? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET
: EnumChatFormatting.RED + "Has Problems" + EnumChatFormatting.RESET));
@@ -554,5 +647,57 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
@Override
public boolean explodesOnComponentBreak(ItemStack stack) { return false; }
-
+
+ //called by the getEUCapacity() function in BaseMetaTileEntity
+ @Override
+ public long maxEUStore()
+ {
+ return capacity.longValue();
+ }
+
+ //called by the getEUStored() function in BaseMetaTileEntity
+ @Override
+ public long getEUVar()
+ {
+ return stored.longValue();
+ }
+
+ /* all of these are needed for the injectEnergyUnits() and drainEnergyUnits()
+ in IGregTechTileEntity
+ */
+ @Override
+ public long maxEUInput()
+ {
+ return mMaxEUIn;
+ }
+
+ @Override
+ public long maxAmperesIn()
+ {
+ return 1L;
+ }
+
+ @Override
+ public long maxEUOutput()
+ {
+ return mMaxEUOut;
+ }
+
+ @Override
+ public long maxAmperesOut()
+ {
+ return 1L;
+ }
+
+ @Override
+ public boolean isEnetInput()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isEnetOutput()
+ {
+ return true;
+ }
}
diff --git a/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java b/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java
index 5e0b86ed69..ec720b9354 100644
--- a/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java
+++ b/src/main/java/common/tileentities/GTMTE_ModularNuclearReactor.java
@@ -16,7 +16,6 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
-import util.MultiBlockTooltipBuilder;
public class GTMTE_ModularNuclearReactor extends GT_MetaTileEntity_MultiBlockBase {
@@ -47,6 +46,8 @@ public class GTMTE_ModularNuclearReactor extends GT_MetaTileEntity_MultiBlockBas
@Override
public String[] getDescription() {
+ return new String[]{"Disabled"};
+ /*
final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
b.addInfo("Can be built, BUT DOES NOT WORK")
.addInfo("Converts fissile material and outputs power or heat")
@@ -75,18 +76,18 @@ public class GTMTE_ModularNuclearReactor extends GT_MetaTileEntity_MultiBlockBas
return b.getInformation();
} else {
return b.getStructureInformation();
- }
+ }*/
}
@Override
public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing,
final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
return aSide == aFacing
- ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID],
+ ? new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID),
new GT_RenderedTexture(aActive ?
Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE
: Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER)}
- : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID]};
+ : new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)};
}
// TODO: Opening UI crashes server. Controller isn't craftable right now.
diff --git a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java
index 76536f0e50..0bc05927aa 100644
--- a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java
+++ b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK1.java
@@ -17,6 +17,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
@@ -25,7 +26,6 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
-import util.MultiBlockTooltipBuilder;
import util.Vector3i;
import util.Vector3ic;
@@ -56,26 +56,29 @@ public class GTMTE_SOFuelCellMK1 extends GT_MetaTileEntity_MultiBlockBase {
@Override
public String[] getDescription() {
- final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
- b.addInfo("Oxidizes gas fuels to generate electricity without polluting the environment")
- .addInfo("Consumes 29,480EU worth of fuel with up to 97% efficiency each second")
- .addInfo("Steam production requires the SOFC to heat up completely first")
- .addInfo("Outputs " + EU_PER_TICK + "EU/t and " + STEAM_PER_SEC + "L/s Steam")
- .addInfo("Additionally requires " + OXYGEN_PER_SEC + "L/s Oxygen gas")
- .addSeparator()
- .beginStructureBlock(3, 3, 5)
- .addController("Front Center")
- .addDynamoHatch("Back Center")
- .addOtherStructurePart("YSZ Ceramic Electrolyte Unit", "3x, Center 1x1x3")
- .addOtherStructurePart("Reinforced Glass", "6x, touching the electrolyte units on the horizontal sides")
- .addCasingInfo("Clean Stainless Steel Casing", 12)
- .addMaintenanceHatch("Instead of any casing")
- .addIOHatches("Instead of any casing")
- .signAndFinalize("Kekzdealer");
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Gas Turbine")
+ .addInfo("Oxidizes gas fuels to generate electricity without polluting the environment")
+ .addInfo("Consumes 29,480EU worth of fuel with up to 97% efficiency each second")
+ .addInfo("Steam production requires the SOFC to heat up completely first")
+ .addInfo("Outputs " + EU_PER_TICK + "EU/t and " + STEAM_PER_SEC + "L/s Steam")
+ .addInfo("Additionally, requires " + OXYGEN_PER_SEC + "L/s Oxygen gas")
+ .addSeparator()
+ .beginStructureBlock(3, 3, 5, false)
+ .addController("Front center")
+ .addCasingInfo("Clean Stainless Steel Casing", 12)
+ .addOtherStructurePart("YSZ Ceramic Electrolyte Unit", "3x, Center 1x1x3")
+ .addOtherStructurePart("Reinforced Glass", "6x, touching the electrolyte units on the horizontal sides")
+ .addDynamoHatch("Back center")
+ .addMaintenanceHatch("Any casing")
+ .addInputHatch("Fuel, any casing")
+ .addInputHatch("Oxygen, any casing")
+ .addOutputHatch("Steam, any casing")
+ .toolTipFinisher("KekzTech");
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return b.getInformation();
+ return tt.getInformation();
} else {
- return b.getStructureInformation();
+ return tt.getStructureInformation();
}
}
@@ -83,11 +86,11 @@ public class GTMTE_SOFuelCellMK1 extends GT_MetaTileEntity_MultiBlockBase {
public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing,
final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
return aSide == aFacing
- ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID],
+ ? new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID),
new GT_RenderedTexture(aActive ?
Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE
: Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER)}
- : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID]};
+ : new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)};
}
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
diff --git a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java
index fb3fb7e9c7..a015887350 100644
--- a/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java
+++ b/src/main/java/common/tileentities/GTMTE_SOFuelCellMK2.java
@@ -16,6 +16,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
@@ -25,7 +26,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
-import util.MultiBlockTooltipBuilder;
+
import util.Vector3i;
import util.Vector3ic;
@@ -56,26 +57,29 @@ public class GTMTE_SOFuelCellMK2 extends GT_MetaTileEntity_MultiBlockBase {
@Override
public String[] getDescription() {
- final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
- b.addInfo("Oxidizes gas fuels to generate electricity without polluting the environment")
- .addInfo("Consumes 442,200EU worth of fuel with up to 97% efficiency each second")
- .addInfo("Steam production requires the SOFC to heat up completely first")
- .addInfo("Outputs " + EU_PER_TICK + "EU/t and " + STEAM_PER_SEC + "L/s Steam")
- .addInfo("Additionally requires " + OXYGEN_PER_SEC + "L/s Oxygen gas")
- .addSeparator()
- .beginStructureBlock(3, 3, 5)
- .addController("Front Center")
- .addDynamoHatch("Back Center")
- .addOtherStructurePart("GDC Ceramic Electrolyte Unit", "3x, Center 1x1x3")
- .addOtherStructurePart("Reinforced Glass", "6x, touching the electrolyte units on the horizontal sides")
- .addCasingInfo("Robust Tungstensteel Machine Casing", 12)
- .addMaintenanceHatch("Instead of any casing")
- .addIOHatches("Instead of any casing")
- .signAndFinalize("Kekzdealer");
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Gas Turbine")
+ .addInfo("Oxidizes gas fuels to generate electricity without polluting the environment")
+ .addInfo("Consumes 442,200EU worth of fuel with up to 97% efficiency each second")
+ .addInfo("Steam production requires the SOFC to heat up completely first")
+ .addInfo("Outputs " + EU_PER_TICK + "EU/t and " + STEAM_PER_SEC + "L/s Steam")
+ .addInfo("Additionally, requires " + OXYGEN_PER_SEC + "L/s Oxygen gas")
+ .addSeparator()
+ .beginStructureBlock(3, 3, 5, false)
+ .addController("Front center")
+ .addCasingInfo("Robust Tungstensteel Machine Casing", 12)
+ .addOtherStructurePart("GDC Ceramic Electrolyte Unit", "3x, Center 1x1x3")
+ .addOtherStructurePart("Reinforced Glass", "6x, touching the electrolyte units on the horizontal sides")
+ .addDynamoHatch("Back center")
+ .addMaintenanceHatch("Any casing")
+ .addInputHatch("Fuel, any casing")
+ .addInputHatch("Oxygen, any casing")
+ .addOutputHatch("Superheated Steam, any casing")
+ .toolTipFinisher("KekzTech");
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- return b.getInformation();
+ return tt.getInformation();
} else {
- return b.getStructureInformation();
+ return tt.getStructureInformation();
}
}
@@ -83,11 +87,11 @@ public class GTMTE_SOFuelCellMK2 extends GT_MetaTileEntity_MultiBlockBase {
public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing,
final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
return aSide == aFacing
- ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID],
+ ? new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID),
new GT_RenderedTexture(aActive ?
Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE
: Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER)}
- : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID]};
+ : new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)};
}
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
diff --git a/src/main/java/common/tileentities/GTMTE_SpaceElevator.java b/src/main/java/common/tileentities/GTMTE_SpaceElevator.java
index 8f7827f4be..3469528f78 100644
--- a/src/main/java/common/tileentities/GTMTE_SpaceElevator.java
+++ b/src/main/java/common/tileentities/GTMTE_SpaceElevator.java
@@ -12,12 +12,10 @@ import gregtech.api.objects.GT_RenderedTexture;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.input.Keyboard;
-import util.MultiBlockTooltipBuilder;
import util.Vector3i;
import util.Vector3ic;
@@ -58,6 +56,8 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase {
@Override
public String[] getDescription() {
+ return new String[]{"Disabled"};
+ /*
final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
b.addInfo("Access for your Space Station!")
.addInfo("Check out the wiki on my github if you are having trouble with the structure")
@@ -78,7 +78,7 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase {
return b.getInformation();
} else {
return b.getStructureInformation();
- }
+ }*/
}
@Override
@@ -140,6 +140,7 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase {
boolean formationChecklist = true;
int minCasingAmount = 320;
int firstCoilMeta = -1;
+ capacitors.clear();
// Base floor
for(int X = -7; X <= 7; X++){
@@ -215,6 +216,10 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase {
formationChecklist = false;
}
+ for(TE_SpaceElevatorCapacitor cap : capacitors){
+ cap.setIsDamaged(false);
+ }
+
return formationChecklist;
}
@@ -233,20 +238,6 @@ public class GTMTE_SpaceElevator extends GT_MetaTileEntity_MultiBlockBase {
}
@Override
- public void saveNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- super.saveNBTData(nbt);
- }
-
- @Override
- public void loadNBTData(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- super.loadNBTData(nbt);
- }
-
- @Override
public boolean isGivingInformation() {
return true;
}
diff --git a/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java
new file mode 100644
index 0000000000..fc2579604a
--- /dev/null
+++ b/src/main/java/common/tileentities/GTMTE_TFFTMultiHatch.java
@@ -0,0 +1,217 @@
+package common.tileentities;
+
+import client.GTTexture;
+import gregtech.api.enums.Textures;
+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.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Utility;
+import kekztech.MultiFluidHandler;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+
+import java.util.HashMap;
+
+public class GTMTE_TFFTMultiHatch extends GT_MetaTileEntity_Hatch {
+
+ private static final HashMap<Integer, Integer> vals = new HashMap<>();
+ static {
+ vals.put(3, 2000);
+ vals.put(5, 20000);
+ vals.put(7, 200000);
+ }
+ private static final int INV_SLOT_COUNT = 2;
+
+ private MultiFluidHandler mfh;
+ private boolean outputting = false;
+
+ public GTMTE_TFFTMultiHatch(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier, INV_SLOT_COUNT, new String[] {
+ "All-in-one access for the T.F.F.T",
+ "Right-click with a screwdriver to toggle auto-output",
+ "Throughput: " + vals.get(aTier) + "L/s per fluid"}
+ );
+ }
+
+ public GTMTE_TFFTMultiHatch(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, INV_SLOT_COUNT, aDescription, aTextures);
+ }
+
+ public GTMTE_TFFTMultiHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, INV_SLOT_COUNT, aDescription, aTextures);
+ }
+
+ public void setMultiFluidHandler(MultiFluidHandler mfh) {
+ this.mfh = mfh;
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setBoolean("outputting", outputting);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ outputting = aNBT.getBoolean("outputting");
+ }
+
+ @Override
+ public ITexture[] getTexturesActive(ITexture aBaseTexture) {
+ //return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_ON)};
+ return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_PIPE_STEEL)};
+ }
+
+ @Override
+ public ITexture[] getTexturesInactive(ITexture aBaseTexture) {
+ //return new ITexture[]{aBaseTexture, new GT_RenderedTexture(GTTexture.MULTI_HATCH_OFF)};
+ return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE)};
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) {
+ return new GTMTE_TFFTMultiHatch(super.mName, super.mTier, super.mDescriptionArray, super.mTextures);
+ }
+
+ @Override
+ public boolean isMachineBlockUpdateRecursive() {
+ return false;
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ outputting = !outputting;
+ GT_Utility.sendChatToPlayer(aPlayer, outputting ? "Auto-output enabled" : "Auto-output disabled");
+ }
+
+ @Override
+ public int getCapacity() {
+ return (mfh != null) ? mfh.getCapacity() : 0;
+ }
+
+ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPreTick(aBaseMetaTileEntity, aTick);
+ if (aBaseMetaTileEntity.isServerSide() && mfh != null) {
+ if(outputting && (aTick % 20 == 0)) {
+ doAutoOutputPerSecond(aBaseMetaTileEntity);
+ }
+ }
+ }
+
+ /**
+ * Handle the Multi Hatch's auto-output feature. Should be called once per second only.
+ * @param aBaseMetaTileEntity
+ * this MetaTileEntity
+ */
+ private void doAutoOutputPerSecond(IGregTechTileEntity aBaseMetaTileEntity) {
+ final ForgeDirection outSide = ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing());
+ final TileEntity adjacentTE = aBaseMetaTileEntity.getTileEntityOffset(outSide.offsetX, outSide.offsetY, outSide.offsetZ);
+ if(adjacentTE instanceof IFluidHandler) {
+ final IFluidHandler adjFH = (IFluidHandler) adjacentTE;
+ // Cycle through fluids
+ for(int i = 0; i < mfh.getDistinctFluids(); i++) {
+ final FluidStack fluidCopy = mfh.getFluidCopy(i);
+ // Make sure the adjacent IFluidHandler can accept this fluid
+ if(adjFH.canFill(outSide.getOpposite(), fluidCopy.getFluid())) {
+
+ // Limit to output rate
+ fluidCopy.amount = Math.min(fluidCopy.amount, vals.get(super.mTier));
+
+ // Test how much can be drawn
+ fluidCopy.amount = mfh.pullFluid(fluidCopy, false);
+
+ // Test how much can be filled (and fill if possible)
+ fluidCopy.amount = adjFH.fill(outSide.getOpposite(), fluidCopy, true);
+
+ // Actually deplete storage
+ mfh.pullFluid(fluidCopy, true);
+ }
+ }
+
+ }
+ }
+
+ @Override
+ public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
+ return (mfh != null) ? mfh.pushFluid(resource, doFill) : 0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
+ return (mfh != null) ? new FluidStack(resource.getFluid(), mfh.pullFluid(resource, doDrain)) : null;
+ }
+
+ /**
+ * Drains fluid out of 0th internal tank.
+ * If the TFFT Controller contains an Integrated Circuit, drain fluid
+ * from the slot equal to the circuit configuration.
+ *
+ * @param from
+ * Orientation the fluid is drained to.
+ * @param maxDrain
+ * Maximum amount of fluid to drain.
+ * @param doDrain
+ * If false, drain will only be simulated.
+ * @return FluidStack representing the Fluid and amount that was (or would have been, if
+ * simulated) drained.
+ */
+ @Override
+ public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
+ if(mfh != null) {
+ final FluidStack drain = mfh.getFluidCopy(0);
+ if(drain != null) {
+ // If there's no integrated circuit in the T.F.F.T. controller, output slot 0
+ final byte selectedSlot = (mfh.getSelectedFluid() == -1) ? 0 : mfh.getSelectedFluid();
+
+ return new FluidStack(
+ drain.getFluid(),
+ mfh.pullFluid(new FluidStack(drain.getFluid(), maxDrain), selectedSlot, doDrain)
+ );
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection from) {
+ if (mfh == null)
+ return null;
+ FluidStack[] fluids = mfh.getAllFluids();
+ int length = fluids.length;
+ int maxCapcity = mfh.getCapacity();
+ FluidTankInfo[] tankInfo = new FluidTankInfo[length];
+ for (int i = 0; i < length; i++) {
+ tankInfo[i] = new FluidTankInfo(fluids[i],maxCapcity);
+ }
+ return tankInfo;
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean canTankBeFilled() {
+ return true;
+ }
+
+ @Override
+ public boolean canTankBeEmptied() {
+ return true;
+ }
+}
diff --git a/src/main/java/common/tileentities/TE_BeamTransmitter.java b/src/main/java/common/tileentities/TE_BeamTransmitter.java
new file mode 100644
index 0000000000..74cb845fc4
--- /dev/null
+++ b/src/main/java/common/tileentities/TE_BeamTransmitter.java
@@ -0,0 +1,47 @@
+package common.tileentities;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import org.joml.Vector3i;
+import org.joml.Vector3ic;
+
+public class TE_BeamTransmitter extends TileEntity {
+
+ private final Vector3ic position;
+
+ private Vector3ic target = new Vector3i(10, 20, 10);
+ private double distanceCache;
+ private boolean distanceCacheValid = false;
+
+ public TE_BeamTransmitter() {
+ position = new Vector3i(super.xCoord, super.yCoord, super.zCoord);
+ }
+
+ public Vector3ic getTargetPosition() {
+ return target;
+ }
+
+ public double getDistanceFromTarget() {
+ if (!distanceCacheValid) {
+ distanceCache = position.distance(target);
+ distanceCacheValid = true;
+ }
+ return distanceCache;
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public double getMaxRenderDistanceSquared() {
+ // 4k is standard, 65k is what the vanilla beacon uses
+ return 65536.0D;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public AxisAlignedBB getRenderBoundingBox() {
+ // Make it so the beam is still rendered even when the source block is out of sight
+ return INFINITE_EXTENT_AABB;
+ }
+}
diff --git a/src/main/java/common/tileentities/TE_ItemServerIOPort.java b/src/main/java/common/tileentities/TE_ItemServerIOPort.java
deleted file mode 100644
index 0e96ff75b9..0000000000
--- a/src/main/java/common/tileentities/TE_ItemServerIOPort.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package common.tileentities;
-
-import kekztech.MultiItemHandler;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.ISidedInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-
-public class TE_ItemServerIOPort extends TileEntity implements ISidedInventory {
-
- private MultiItemHandler mih;
-
- private int tickCounter = 0;
-
- public void setMultiItemHandler(MultiItemHandler mih) {
- this.mih = mih;
- }
-
- @Override
- public void updateEntity() {
- if(mih != null) {
-
- tickCounter++;
- if(tickCounter >= 40) {
- mih.debugPrint();
- tickCounter = 0;
- }
- }
- }
-
- @Override
- public int getSizeInventory() {
- return (mih != null) ? mih.getItemTypeCapacity() : 0;
- }
-
- @Override
- public ItemStack getStackInSlot(int slot) {
- return (mih != null) ? mih.getStackInSlot(slot) : null;
- }
-
- @Override
- public ItemStack decrStackSize(int slot, int amount) {
- if(mih != null) {
- if(mih.getStackInSlot(slot) != null) {
- final ItemStack obtained = mih.getStackInSlot(slot).copy();
- obtained.stackSize = mih.reduceStackInSlot(slot, amount);
- super.markDirty();
- return obtained;
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- @Override
- public ItemStack getStackInSlotOnClosing(int slot) {
- return null;
- }
-
- @Override
- public void setInventorySlotContents(int slot, ItemStack itemStack) {
- System.out.println("Set slot: " + slot);
- if(mih != null) {
- if(itemStack == null) {
- return;
- } else {
- if(!mih.insertStackInSlot(slot, itemStack)) {
- final int delta = itemStack.stackSize - mih.getStackInSlot(slot).stackSize;
- if(delta < 0) {
- System.out.println("Set slot reduce: " + itemStack.getDisplayName());
- mih.reduceStackInSlot(slot, delta);
- } else {
- System.out.println("Set slot increase: " + itemStack.getDisplayName());
- mih.increaseStackInSlot(slot, delta);
- }
-
- } else {
- System.out.println("Allocated new slot for: " + itemStack.getDisplayName());
- }
- super.markDirty();
- }
- }
- }
-
- @Override
- public String getInventoryName() {
- return "Item Server IO Port";
- }
-
- @Override
- public boolean hasCustomInventoryName() {
- return true;
- }
-
- @Override
- public int getInventoryStackLimit() {
- return (mih != null) ? mih.getPerTypeCapacity() : 0;
- }
-
- @Override
- public boolean isUseableByPlayer(EntityPlayer player) {
- return true;
- }
-
- @Override
- public void openInventory() {
-
- }
-
- @Override
- public void closeInventory() {
-
- }
-
- @Override
- public boolean isItemValidForSlot(int slot, ItemStack itemStack) {
- return (mih != null) ? (mih.getStackInSlot(slot).isItemEqual(itemStack) || mih.getStackInSlot(slot) == null) : false;
- }
-
- @Override
- public int[] getAccessibleSlotsFromSide(int side) {
- if(mih != null) {
- final int[] as = new int[mih.getItemTypeCapacity()];
- for(int i = 0; i < mih.getItemTypeCapacity(); i++) {
- as[i] = i;
- }
- return as;
- } else {
- return new int[1];
- }
- }
-
- @Override
- public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
- return isItemValidForSlot(slot, itemStack);
- }
-
- @Override
- public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
- return (mih != null) ? true : false;
- }
-
-}
diff --git a/src/main/java/common/tileentities/TE_TFFTMultiHatch.java b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java
index c4f9451478..de274bb15e 100644
--- a/src/main/java/common/tileentities/TE_TFFTMultiHatch.java
+++ b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java
@@ -1,11 +1,6 @@
package common.tileentities;
-import java.util.Iterator;
-import java.util.List;
-
-import common.Blocks;
import kekztech.MultiFluidHandler;
-import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
@@ -14,14 +9,26 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
+@Deprecated
public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler {
- private static final int OUTPUT_PER_SECOND = 1000; // L/s
-
+ public static final int BASE_OUTPUT_PER_SECOND = 2000; // L/s
+
+ private byte facings = 0x0;
+
private MultiFluidHandler mfh;
private int tickCounter = 0;
private boolean autoOutput = false;
-
+
+ public boolean hasFacingOnSide(byte side) {
+ final byte key = (byte) Math.pow(0x2, side);
+ return (facings & key) == key;
+ }
+
+ public void setFacingToSide(byte side) {
+ facings = (byte) Math.pow(0x2, side);
+ }
+
public void setMultiFluidHandler(MultiFluidHandler mfh) {
this.mfh = mfh;
}
@@ -36,90 +43,19 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler {
@Override
public void updateEntity() {
- if(!autoOutput || mfh == null) {
- return;
- }
-
- tickCounter++;
- if(tickCounter >= 20) {
-
- final ForgeDirection d = getOutwardsFacingDirection();
- if(d == ForgeDirection.UNKNOWN) {
- return;
- }
- final TileEntity t = this.getWorldObj().getTileEntity(
- this.xCoord + d.offsetX,
- this.yCoord + d.offsetY,
- this.zCoord + d.offsetZ);
-
- if(t instanceof IFluidHandler) {
-
- final IFluidHandler fh = (IFluidHandler) t;
-
- // Cycle through fluids
- final Iterator<FluidStack> volumes = mfh.getFluids().iterator();
- while(volumes.hasNext()) {
- final FluidStack volume = volumes.next();
-
- // Remember for later
- final int oVolume = volume.amount;
-
- // Use API methods
- if(fh.canFill(d.getOpposite(), volume.getFluid())) {
-
- // Test how much can be output
- final FluidStack copy = volume.copy();
- copy.amount = Math.min(copy.amount, OUTPUT_PER_SECOND);
-
- // How much is drawn
- copy.amount = mfh.pullFluid(copy, false);
-
- // Test how much can be filled (and fill if possible)
- copy.amount = fh.fill(d.getOpposite(), copy, true);
-
- // Actually deplete storage
- mfh.pullFluid(copy, true);
-
- // Prevent ConcurrentModificationException
- if(copy.amount >= oVolume) {
- break;
- }
- }
- }
- }
-
- tickCounter = 0;
- }
- }
-
- private ForgeDirection getOutwardsFacingDirection() {
- // TODO Revisit this once the hatch has a facing side
- // Look up which side has the storage field block and choose the other side.
- // This is important so the tank doesn't output into itself in case
- // there is another hatch next to this one.
- for(ForgeDirection direction : ForgeDirection.values()) {
-
- final Block b = this.getWorldObj().getBlock(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ);
- if(b != null && (
- b.equals(Blocks.tfftStorageField1)
- || b.equals(Blocks.tfftStorageField2)
- || b.equals(Blocks.tfftStorageField3)
- || b.equals(Blocks.tfftStorageField4)
- || b.equals(Blocks.tfftStorageField5))) {
- return direction.getOpposite();
- }
- }
- return ForgeDirection.UNKNOWN;
+ // Removed deprecated code
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
- return (mfh != null) ? mfh.pushFluid(resource, doFill) : 0;
+ // Removed deprecated code
+ return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
- return (mfh != null) ? new FluidStack(resource.getFluid(), mfh.pullFluid(resource, doDrain)) : null;
+ // Removed deprecated code
+ return null;
}
/**
@@ -138,60 +74,40 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler {
*/
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
- if(mfh != null) {
- final FluidStack drain = mfh.getFluid(0);
- if(drain != null) {
- // If there's no integrated circuit in the T.F.F.T. controller, output slot 0
- final byte selectedSlot = (mfh.getSelectedFluid() == -1) ? 0 : mfh.getSelectedFluid();
-
- return new FluidStack(
- drain.getFluid(),
- mfh.pullFluid(new FluidStack(drain.getFluid(), maxDrain), selectedSlot, doDrain)
- );
- }
- }
+ // Removed deprecated code
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
- return (mfh != null) && mfh.couldPush(new FluidStack(fluid, 1));
+ // Removed deprecated code
+ return false;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
- return (mfh != null) && mfh.contains(new FluidStack(fluid, 1));
+ // Removed deprecated code
+ return false;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
- if(mfh == null) {
- return null;
- }
- final List<FluidStack> fluids = mfh.getFluids();
- final FluidTankInfo[] tankInfo = new FluidTankInfo[fluids.size()];
- for(int i = 0; i < tankInfo.length; i++) {
- tankInfo[i] = new FluidTankInfo(fluids.get(i), mfh.getCapacity());
- }
- return tankInfo;
+ // Removed deprecated code
+ return null;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- nbt.setBoolean("autoOutput", autoOutput);
-
super.writeToNBT(nbt);
+ nbt.setBoolean("autoOutput", autoOutput);
+ nbt.setByte("facings", facings);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
- nbt = (nbt == null) ? new NBTTagCompound() : nbt;
-
- autoOutput = nbt.getBoolean("autoOutput");
-
super.readFromNBT(nbt);
+ autoOutput = nbt.getBoolean("autoOutput");
+ facings = nbt.getByte("facings");
}