diff options
| author | GlodBlock <1356392126@qq.com> | 2022-01-09 20:56:22 +0800 |
|---|---|---|
| committer | GlodBlock <1356392126@qq.com> | 2022-01-09 20:56:22 +0800 |
| commit | aae22b028e4f6dbef91ff704db7aa1c031df7ff3 (patch) | |
| tree | 9e9ca8413dcda4cef0a8d4b018e0324eb264f290 /src/main/java/goodgenerator/blocks | |
| parent | 7347ae3204e40d7243d80b4babe50122a2446b30 (diff) | |
| download | GT5-Unofficial-aae22b028e4f6dbef91ff704db7aa1c031df7ff3.tar.gz GT5-Unofficial-aae22b028e4f6dbef91ff704db7aa1c031df7ff3.tar.bz2 GT5-Unofficial-aae22b028e4f6dbef91ff704db7aa1c031df7ff3.zip | |
yottank ec2 support
Diffstat (limited to 'src/main/java/goodgenerator/blocks')
4 files changed, 165 insertions, 6 deletions
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/DieselGenerator.java b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/DieselGenerator.java index 9f1d2b7005..2f080d6b32 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/DieselGenerator.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/DieselGenerator.java @@ -25,7 +25,7 @@ public class DieselGenerator extends GT_MetaTileEntity_BasicGenerator { super(aID, aName, aNameRegional, aTier, new String[]{ "Requires liquid Fuel", "Causes " + (int) (GT_Mod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond * (1.1 - aTier * 0.1)) + " Pollution per second"}); - mEfficiency = 100 - aTier * 5; + mEfficiency = 100 - aTier * 15; } public DieselGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/YOTTAHatch.java b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/YOTTAHatch.java new file mode 100644 index 0000000000..0b096c6e08 --- /dev/null +++ b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/YOTTAHatch.java @@ -0,0 +1,141 @@ +package goodgenerator.blocks.tileEntity.GTMetaTileEntity; + +import goodgenerator.blocks.tileEntity.YottaFluidTank; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.render.TextureFactory; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + +import java.math.BigInteger; + +public class YOTTAHatch extends GT_MetaTileEntity_Hatch { + + private static final IIconContainer textureFont = new Textures.BlockIcons.CustomIcon("icons/YOTTAHatch"); + + private YottaFluidTank host; + + public YOTTAHatch(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 0, "Special I/O port for EC2 Fluid Storage Bus."); + } + + public YOTTAHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + public void setTank(YottaFluidTank te) { + this.host = te; + } + + @Override + public int getCapacity() { + if (host == null || host.getBaseMetaTileEntity() == null || !host.getBaseMetaTileEntity().isActive()) return 0; + if (host.mStorage.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) >= 0) { + return Integer.MAX_VALUE; + } + else return host.mStorage.intValue(); + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (host == null || host.getBaseMetaTileEntity() == null || !host.getBaseMetaTileEntity().isActive()) return 0; + if (host.mFluidName == null || host.mFluidName.equals("") || host.mFluidName.equals(resource.getFluid().getName())) { + host.mFluidName = resource.getFluid().getName(); + if (host.mStorage.subtract(host.mStorageCurrent).compareTo(BigInteger.valueOf(resource.amount)) >= 0) { + if (doFill) + host.addFluid(resource.amount); + return resource.amount; + } + else { + int added = host.mStorage.subtract(host.mStorageCurrent).intValue(); + if (doFill) + host.addFluid(added); + return added; + } + } + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (host == null || host.getBaseMetaTileEntity() == null || !host.getBaseMetaTileEntity().isActive()) + return null; + if (host.mFluidName == null || host.mFluidName.equals("") || !host.mFluidName.equals(resource.getFluid().getName())) + return null; + int ready; + if (host.mStorageCurrent.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0) { + ready = Integer.MAX_VALUE; + } + else ready = host.mStorageCurrent.intValue(); + ready = Math.min(ready, resource.amount); + if (doDrain) { + host.reduceFluid(ready); + } + return new FluidStack(resource.getFluid(), ready); + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if (host == null || host.getBaseMetaTileEntity() == null || !host.getBaseMetaTileEntity().isActive()) + return null; + if (host.mFluidName == null || host.mFluidName.equals("")) + return null; + return this.drain(from, FluidRegistry.getFluidStack(host.mFluidName, maxDrain), doDrain); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + FluidTankInfo[] tankInfo = new FluidTankInfo[1]; + tankInfo[0] = new FluidTankInfo(null, 0); + if (host == null || host.getBaseMetaTileEntity() == null || !host.getBaseMetaTileEntity().isActive()) + return tankInfo; + FluidStack fluid = null; + if (host.mFluidName != null && !host.mFluidName.equals("")) { + int camt; + if (host.mStorageCurrent.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0) + camt = Integer.MAX_VALUE; + else camt = host.mStorageCurrent.intValue(); + fluid = FluidRegistry.getFluidStack(host.mFluidName, camt); + } + + tankInfo[0] = new FluidTankInfo(fluid, getCapacity()); + return tankInfo; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { + aBaseTexture, + TextureFactory.of(textureFont), + }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { + aBaseTexture, + TextureFactory.of(textureFont), + }; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new YOTTAHatch(mName, mTier, mDescriptionArray, mTextures); + } +} diff --git a/src/main/java/goodgenerator/blocks/tileEntity/LargeEssentiaGenerator.java b/src/main/java/goodgenerator/blocks/tileEntity/LargeEssentiaGenerator.java index 8a1e2a9805..1c3cc80602 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/LargeEssentiaGenerator.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/LargeEssentiaGenerator.java @@ -452,7 +452,7 @@ public class LargeEssentiaGenerator extends GT_MetaTileEntity_MultiblockBase_EM for (Aspect aspect: aspects.aspects.keySet()) { if (!isValidEssentia(aspect) || getPerAspectEnergy(aspect) == 0) continue; while (EUt <= (voltageLimit * ampLimit) && aspects.getAmount(aspect) > 0) { - EUt += getPerAspectEnergy(aspect); + EUt += getPerAspectEnergy(aspect) * mStableValue / 25; aspects.reduce(aspect, 1); if (aspects.getAmount(aspect) == 0) aspects.remove(aspect); @@ -460,7 +460,7 @@ public class LargeEssentiaGenerator extends GT_MetaTileEntity_MultiblockBase_EM } if (EUt == 0 && aspects.size() != 0) { if (!isValidEssentia(aspects.getAspects()[0]) || getPerAspectEnergy(aspects.getAspects()[0]) == 0) continue; - EUt += getPerAspectEnergy(aspects.getAspects()[0]); + EUt += getPerAspectEnergy(aspects.getAspects()[0]) * mStableValue / 25; aspects.reduce(aspects.getAspects()[0], 1); if (aspects.getAmount(aspects.getAspects()[0]) == 0) aspects.remove(aspects.getAspects()[0]); diff --git a/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java b/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java index c2ac9ae885..2eb1d65b1e 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java @@ -1,5 +1,6 @@ package goodgenerator.blocks.tileEntity; +import goodgenerator.blocks.tileEntity.GTMetaTileEntity.YOTTAHatch; import goodgenerator.client.GUI.YOTTankGUIClient; import goodgenerator.common.container.YOTTankGUIContainer; import goodgenerator.loader.Loaders; @@ -49,10 +50,11 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen private static final IIconContainer textureFontOff_Glow = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_QCHEST_GLOW"); protected IStructureDefinition<YottaFluidTank> multiDefinition = null; + protected final ArrayList<YOTTAHatch> mYottaHatch = new ArrayList<>(); - protected BigInteger mStorage = new BigInteger("0", 10); - protected BigInteger mStorageCurrent = new BigInteger("0", 10); - protected String mFluidName = ""; + public BigInteger mStorage = new BigInteger("0", 10); + public BigInteger mStorageCurrent = new BigInteger("0", 10); + public String mFluidName = ""; protected int glassMeta; protected int maxCell; protected final String YOTTANK_BOTTOM = mName + "buttom"; @@ -126,6 +128,17 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen } } + public boolean addFluid(int amount) { + BigInteger tmp = new BigInteger(amount + ""); + if (mStorage.subtract(mStorageCurrent).compareTo(tmp) < 0) { + return false; + } + else { + mStorageCurrent = mStorageCurrent.add(tmp); + return true; + } + } + private int calGlassTier(int meta) { if (meta >= 1 && meta <= 6) return meta; if (meta >= 7 && meta <= 12) return 1; @@ -136,6 +149,7 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mStorage = BigInteger.ZERO; glassMeta = 0; + mYottaHatch.clear(); if (!structureCheck_EM(YOTTANK_BOTTOM, 2, 0, 0)) return false; int cnt = 0; while (structureCheck_EM(YOTTANK_MID, 2, cnt + 1, 0)) { @@ -270,6 +284,10 @@ public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implemen if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output)aMetaTileEntity); + } else if (aMetaTileEntity instanceof YOTTAHatch) { + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((YOTTAHatch) aMetaTileEntity).setTank(this); + return this.mYottaHatch.add((YOTTAHatch)aMetaTileEntity); } } } |
