From aae22b028e4f6dbef91ff704db7aa1c031df7ff3 Mon Sep 17 00:00:00 2001 From: GlodBlock <1356392126@qq.com> Date: Sun, 9 Jan 2022 20:56:22 +0800 Subject: yottank ec2 support --- .../GTMetaTileEntity/DieselGenerator.java | 2 +- .../tileEntity/GTMetaTileEntity/YOTTAHatch.java | 141 +++++++++++++++++++++ .../blocks/tileEntity/LargeEssentiaGenerator.java | 4 +- .../blocks/tileEntity/YottaFluidTank.java | 24 +++- .../common/container/YOTTankGUIContainer.java | 4 +- .../java/goodgenerator/crossmod/LoadedList.java | 2 + .../crossmod/thaumcraft/Research.java | 6 +- src/main/java/goodgenerator/loader/Loaders.java | 3 + .../java/goodgenerator/loader/RecipeLoader_02.java | 15 +++ .../resources/assets/goodgenerator/lang/en_US.lang | 2 +- .../gregtech/textures/blocks/icons/YOTTAHatch.png | Bin 0 -> 187 bytes 11 files changed, 191 insertions(+), 12 deletions(-) create mode 100644 src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/YOTTAHatch.java create mode 100644 src/main/resources/assets/gregtech/textures/blocks/icons/YOTTAHatch.png (limited to 'src') 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 multiDefinition = null; + protected final ArrayList 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); } } } diff --git a/src/main/java/goodgenerator/common/container/YOTTankGUIContainer.java b/src/main/java/goodgenerator/common/container/YOTTankGUIContainer.java index 0a425e358e..5880f9e5fb 100644 --- a/src/main/java/goodgenerator/common/container/YOTTankGUIContainer.java +++ b/src/main/java/goodgenerator/common/container/YOTTankGUIContainer.java @@ -88,14 +88,14 @@ public class YOTTankGUIContainer extends GT_Container_MultiMachineEM { private void sendStateUpdate(ICrafting clientHandle) { final int bytes = Integer.BYTES * 3 + Character.BYTES * (currentStore.length() + store.length() + fluidName.length()); for (int i = 0; i < bytes; i++) { - clientHandle.sendProgressBarUpdate(this, i + 21, buffer.get(i)); + clientHandle.sendProgressBarUpdate(this, i + 300, buffer.get(i)); } } @SideOnly(Side.CLIENT) public void updateProgressBar(int index, int value) { super.updateProgressBar(index, value); - index = index - 21; + index = index - 300; if(index >= 0 && index < buffer.capacity()) { buffer.put(index, (byte) value); } diff --git a/src/main/java/goodgenerator/crossmod/LoadedList.java b/src/main/java/goodgenerator/crossmod/LoadedList.java index f3921f64b8..372b3004ab 100644 --- a/src/main/java/goodgenerator/crossmod/LoadedList.java +++ b/src/main/java/goodgenerator/crossmod/LoadedList.java @@ -7,11 +7,13 @@ public class LoadedList { public static boolean GTPP; public static boolean GTNH_CORE; public static boolean BOTDUSTRIES; + public static boolean EXTRA_CELLS; public static void init() { GTPP = Loader.isModLoaded("miscutils"); GTNH_CORE = Loader.isModLoaded("dreamcraft"); BOTDUSTRIES = Loader.isModLoaded("botdustries"); + EXTRA_CELLS = Loader.isModLoaded("extracells"); } } diff --git a/src/main/java/goodgenerator/crossmod/thaumcraft/Research.java b/src/main/java/goodgenerator/crossmod/thaumcraft/Research.java index 2eb3a4dbc0..123223872e 100644 --- a/src/main/java/goodgenerator/crossmod/thaumcraft/Research.java +++ b/src/main/java/goodgenerator/crossmod/thaumcraft/Research.java @@ -1,11 +1,11 @@ package goodgenerator.crossmod.thaumcraft; +import goodgenerator.crossmod.LoadedList; import goodgenerator.items.MyMaterial; import goodgenerator.util.DescTextLocalization; import goodgenerator.util.ItemRefer; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; -import cpw.mods.fml.common.Loader; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -220,7 +220,7 @@ public class Research{ } ); ItemStack broad = new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 6); - if (Loader.isModLoaded("dreamcraft")) broad = GT_ModHandler.getModItem("dreamcraft", "item.ArcaneSlate", 1); + if (LoadedList.GTNH_CORE) broad = GT_ModHandler.getModItem("dreamcraft", "item.ArcaneSlate", 1); GregTech_API.sThaumcraftCompat.addResearch( "ESSENTIA_UPGRADE_BLANK", "Upgrade your generator", @@ -375,7 +375,7 @@ public class Research{ } ); ItemStack meatDust = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.MeatRaw, 1); - if (Loader.isModLoaded("dreamcraft")) meatDust = GT_ModHandler.getModItem("dreamcraft", "GTNHBioItems", 1, 2); + if (LoadedList.GTNH_CORE) meatDust = GT_ModHandler.getModItem("dreamcraft", "GTNHBioItems", 1, 2); GregTech_API.sThaumcraftCompat.addResearch( "ESSENTIA_UPGRADE_VICTUS", "Essentia: VICTUS", diff --git a/src/main/java/goodgenerator/loader/Loaders.java b/src/main/java/goodgenerator/loader/Loaders.java index fcc7d0702d..3455751448 100644 --- a/src/main/java/goodgenerator/loader/Loaders.java +++ b/src/main/java/goodgenerator/loader/Loaders.java @@ -9,6 +9,7 @@ import goodgenerator.blocks.tileEntity.*; import goodgenerator.blocks.tileEntity.GTMetaTileEntity.DieselGenerator; import goodgenerator.blocks.tileEntity.GTMetaTileEntity.NeutronAccelerator; import goodgenerator.blocks.tileEntity.GTMetaTileEntity.NeutronSensor; +import goodgenerator.blocks.tileEntity.GTMetaTileEntity.YOTTAHatch; import goodgenerator.crossmod.LoadedList; import goodgenerator.crossmod.nei.IMCForNEI; import goodgenerator.crossmod.nei.NEI_Config; @@ -91,6 +92,7 @@ public class Loaders { public static ItemStack NS; public static ItemStack NA; public static ItemStack YFT; + public static ItemStack YFH; public static ItemStack[] NeutronAccelerators = new ItemStack[9]; public static ItemStack[] Generator_Diesel = new ItemStack[2]; @@ -107,6 +109,7 @@ public class Loaders { Loaders.NS = new NeutronSensor(IDOffset + 11, "Neutron Sensor", "Neutron Sensor", 5).getStackForm(1L); Loaders.NA = new NeutronActivator(IDOffset + 12, "NeutronActivator", "Neutron Activator").getStackForm(1L); Loaders.YFT = new YottaFluidTank(IDOffset + 13, "YottaFluidTank", "YOTTank").getStackForm(1L); + Loaders.YFH = new YOTTAHatch(IDOffset + 14, "YottaFluidTankHatch", "YOTHatch", 5).getStackForm(1); Loaders.Generator_Diesel[0] = new DieselGenerator(1113, "basicgenerator.diesel.tier.04", "Turbo Supercharging Combustion Generator", 4).getStackForm(1); Loaders.Generator_Diesel[1] = new DieselGenerator(1114, "basicgenerator.diesel.tier.05", "Ultimate Chemical Energy Releaser", 5).getStackForm(1); } diff --git a/src/main/java/goodgenerator/loader/RecipeLoader_02.java b/src/main/java/goodgenerator/loader/RecipeLoader_02.java index 94d1a63eed..71c2674222 100644 --- a/src/main/java/goodgenerator/loader/RecipeLoader_02.java +++ b/src/main/java/goodgenerator/loader/RecipeLoader_02.java @@ -169,6 +169,21 @@ public class RecipeLoader_02 { } ); + if (LoadedList.EXTRA_CELLS) { + GT_Values.RA.addAssemblerRecipe( + new ItemStack[]{ + ItemList.Hatch_Output_IV.get(1), + GT_ModHandler.getModItem("extracells", "part.base", 1, 9), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.CertusQuartz, 8), + GT_Utility.getIntegratedCircuit(1) + }, + Materials.Plastic.getMolten(144), + Loaders.YFH, + 200, + 1920 + ); + } + GT_Values.RA.addAssemblerRecipe( new ItemStack[]{ ItemList.Large_Fluid_Cell_Steel.get(12L), diff --git a/src/main/resources/assets/goodgenerator/lang/en_US.lang b/src/main/resources/assets/goodgenerator/lang/en_US.lang index 289d4a8b88..4ef8af71d0 100644 --- a/src/main/resources/assets/goodgenerator/lang/en_US.lang +++ b/src/main/resources/assets/goodgenerator/lang/en_US.lang @@ -260,7 +260,7 @@ YOTTank.hint.2=16x Borosilicate Glass Block of the same tier for every layer YOTTank.hint.3=9x Fluid Cell Block for every layer YOTTank.hint.4=1 - Input Hatch/YOTTank Casing YOTTank.hint.5=2 - Maintenance Hatch/YOTTank Casing -YOTTank.hint.6=3 - Output Hatch +YOTTank.hint.6=3 - Output Hatch/YOTHatch #Chat largeessentiagenerator.chat= Installed! diff --git a/src/main/resources/assets/gregtech/textures/blocks/icons/YOTTAHatch.png b/src/main/resources/assets/gregtech/textures/blocks/icons/YOTTAHatch.png new file mode 100644 index 0000000000..4e1c1963e2 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/icons/YOTTAHatch.png differ -- cgit