From a173703c77ca211de58a030735b53cd545a2b500 Mon Sep 17 00:00:00 2001 From: NotMyWing Date: Sun, 9 Jun 2024 18:44:45 +1100 Subject: [PATCH] barebones --- dependencies.gradle | 2 + gradle.properties | 2 +- .../neeve/nae2/common/features/Features.java | 6 +++ .../integration/jei/JEICellCategory.java | 19 +++++++- .../nae2/common/items/cells/DenseGasCell.java | 25 +++++++++++ .../registration/definitions/Items.java | 45 +++++++++++++++++++ .../registration/definitions/Materials.java | 32 ++++++++++++- .../resources/assets/nae2/lang/en_us.lang | 8 ++++ 8 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 src/main/java/co/neeve/nae2/common/items/cells/DenseGasCell.java diff --git a/dependencies.gradle b/dependencies.gradle index 766cc05..f45f239 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -29,4 +29,6 @@ dependencies { implementation rfg.deobf("curse.maven:gregtechceu-557242:4951281") implementation rfg.deobf("curse.maven:actually-additions-228404:3117927") implementation rfg.deobf("curse.maven:codechicken-lib-1-8-242818:2779848") + implementation rfg.deobf("curse.maven:mekanism-energistics-1027681:5408319") + implementation rfg.deobf("curse.maven:mekanism-ce-399904:5351260") } diff --git a/gradle.properties b/gradle.properties index 0c73a66..a491528 100644 --- a/gradle.properties +++ b/gradle.properties @@ -84,7 +84,7 @@ curseForgeProjectId= # Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible], # and the name is the CurseForge project slug of the other mod. # Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft -curseForgeRelations=requiredDependency:ae2-extended-life;requiredDependency:mixin-booter +curseForgeRelations=requiredDependency:ae2-extended-life;requiredDependency:mixin-booter;optionalDependency:mekanism-energistics # This project's release type on CurseForge and/or Modrinth # Allowed types: release, beta, alpha releaseType=release diff --git a/src/main/java/co/neeve/nae2/common/features/Features.java b/src/main/java/co/neeve/nae2/common/features/Features.java index 509e6e0..03de78d 100644 --- a/src/main/java/co/neeve/nae2/common/features/Features.java +++ b/src/main/java/co/neeve/nae2/common/features/Features.java @@ -33,6 +33,12 @@ public boolean isEnabled() { } }, DENSE_CELLS(EnumSet.allOf(DenseCellFeatures.class)), + DENSE_GAS_CELLS() { + @Override + public boolean isEnabled() { + return Platform.isModLoaded("mekeng") && super.isEnabled(); + } + }, DENSE_CPU_COPROCESSORS("dense.coprocessor"), DENSE_FLUID_CELLS(), EXPOSER(); diff --git a/src/main/java/co/neeve/nae2/common/integration/jei/JEICellCategory.java b/src/main/java/co/neeve/nae2/common/integration/jei/JEICellCategory.java index 89c0aa2..8bd32e7 100644 --- a/src/main/java/co/neeve/nae2/common/integration/jei/JEICellCategory.java +++ b/src/main/java/co/neeve/nae2/common/integration/jei/JEICellCategory.java @@ -11,10 +11,12 @@ import appeng.api.storage.data.IItemList; import appeng.client.render.StackSizeRenderer; import appeng.fluids.client.render.FluidStackSizeRenderer; +import appeng.util.Platform; import appeng.util.item.AEItemStack; import co.neeve.nae2.Tags; import com.github.bsideup.jabel.Desugar; import com.google.common.collect.ImmutableList; +import com.mekeng.github.common.me.storage.IGasStorageChannel; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import mezz.jei.Internal; @@ -81,6 +83,8 @@ private static String getStorageChannelUnits(IStorageChannel storageChannel) return "items"; } else if (storageChannel instanceof IFluidStorageChannel) { return "buckets"; + } else if (Platform.isModLoaded("mekeng") && storageChannel instanceof IGasStorageChannel) { + return "buckets"; } else { return "units"; } @@ -187,7 +191,8 @@ public void drawExtras(@NotNull Minecraft minecraft) { var format = NumberFormat.getInstance(); var storedItemCount = this.cellInfo.cellInv.getStoredItemCount(); - var transferFactor = this.cellInfo.channel().transferFactor(); + var transferFactor = this.getTransferFactor(); + var capacity = (this.cellInfo.cellInv.getRemainingItemCount() + storedItemCount) / transferFactor; var byteLoss = this.cellInfo.cellInv.getBytesPerType() * this.cellInfo.cellInv.getStoredItemTypes(); var capacityLoss = byteLoss * this.cellInfo.channel.getUnitsPerByte() / transferFactor; @@ -211,6 +216,16 @@ public void drawExtras(@NotNull Minecraft minecraft) { } } + private int getTransferFactor() { + final int transferFactor; + if (Platform.isModLoaded("mekeng") && this.cellInfo.channel instanceof IGasStorageChannel) { + transferFactor = 1000; + } else { + transferFactor = this.cellInfo.channel().transferFactor(); + } + return transferFactor; + } + @Override public @NotNull List getTooltipStrings(int mouseX, int mouseY) { if (this.cellInfo != null && mouseX > 0 && mouseY > 0 && mouseX < WIDTH && mouseY < TOTAL_HEIGHT - GRID_HEIGHT - 2) { @@ -243,7 +258,7 @@ private ITooltipCallback getCallBack(CellInfo> cell var unitName = I18n.format("nae2.jei.cellview." + getStorageChannelUnits(cellInfo.channel())); tooltip.add(I18n.format("nae2.jei.cellview.hover.stored", - format.format(stackSize / (double) this.cellInfo.channel.transferFactor()), unitName)); + format.format(stackSize / (double) this.getTransferFactor()), unitName)); tooltip.add(I18n.format("nae2.jei.cellview.used", format.format(cellInfo.cellInv().getBytesPerType() + Math.ceil(stackSize / (double) cellInfo.channel().getUnitsPerByte())))); } diff --git a/src/main/java/co/neeve/nae2/common/items/cells/DenseGasCell.java b/src/main/java/co/neeve/nae2/common/items/cells/DenseGasCell.java new file mode 100644 index 0000000..37c3b35 --- /dev/null +++ b/src/main/java/co/neeve/nae2/common/items/cells/DenseGasCell.java @@ -0,0 +1,25 @@ +package co.neeve.nae2.common.items.cells; + +import appeng.core.Api; +import co.neeve.nae2.common.registration.definitions.Materials; +import com.mekeng.github.common.me.data.IAEGasStack; +import com.mekeng.github.common.me.storage.IGasStorageChannel; +import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.NotNull; + +public class DenseGasCell extends DenseCell { + public DenseGasCell(Materials.MaterialType whichCell, int kilobytes) { + super(whichCell, kilobytes); + } + + @NotNull + @Override + public IGasStorageChannel getChannel() { + return Api.INSTANCE.storage().getStorageChannel(IGasStorageChannel.class); + } + + @Override + public int getTotalTypes(@NotNull ItemStack cellItem) { + return 15; + } +} diff --git a/src/main/java/co/neeve/nae2/common/registration/definitions/Items.java b/src/main/java/co/neeve/nae2/common/registration/definitions/Items.java index c3e9679..32d25ec 100644 --- a/src/main/java/co/neeve/nae2/common/registration/definitions/Items.java +++ b/src/main/java/co/neeve/nae2/common/registration/definitions/Items.java @@ -11,6 +11,7 @@ import co.neeve.nae2.common.features.Features; import co.neeve.nae2.common.items.VirtualPattern; import co.neeve.nae2.common.items.cells.DenseFluidCell; +import co.neeve.nae2.common.items.cells.DenseGasCell; import co.neeve.nae2.common.items.cells.DenseItemCell; import co.neeve.nae2.common.items.cells.handlers.VoidCellHandler; import co.neeve.nae2.common.items.cells.vc.VoidFluidCell; @@ -44,6 +45,10 @@ public class Items implements Definitions { private final IItemDefinition storageCellFluid1024K; private final IItemDefinition storageCellFluid4096K; private final IItemDefinition storageCellFluid16384K; + private final IItemDefinition storageCellGas256K; + private final IItemDefinition storageCellGas1024K; + private final IItemDefinition storageCellGas4096K; + private final IItemDefinition storageCellGas16384K; private final IItemDefinition virtualPattern; public Items(Registry registry) { @@ -139,6 +144,30 @@ public Items(Registry registry) { .features(Features.DENSE_FLUID_CELLS) .build()); + this.storageCellGas256K = this.registerById(registry.item("storage_cell_gas_256k", () -> + new DenseGasCell(Materials.MaterialType.CELL_GAS_PART_256K, + (int) Math.pow(2, 8))) + .features(Features.DENSE_GAS_CELLS) + .build()); + + this.storageCellGas1024K = this.registerById(registry.item("storage_cell_gas_1024k", () -> + new DenseGasCell(Materials.MaterialType.CELL_GAS_PART_1024K, + (int) Math.pow(2, 10))) + .features(Features.DENSE_GAS_CELLS) + .build()); + + this.storageCellGas4096K = this.registerById(registry.item("storage_cell_gas_4096k", () -> + new DenseGasCell(Materials.MaterialType.CELL_GAS_PART_4096K, + (int) Math.pow(2, 12))) + .features(Features.DENSE_GAS_CELLS) + .build()); + + this.storageCellGas16384K = this.registerById(registry.item("storage_cell_gas_16384k", () -> + new DenseGasCell(Materials.MaterialType.CELL_GAS_PART_16384K, + (int) Math.pow(2, 14))) + .features(Features.DENSE_GAS_CELLS) + .build()); + registry.addBootstrapComponent((IPostInitComponent) r -> { var items = AEApi.instance().definitions().items(); var cellDef = items.cell1k(); @@ -237,4 +266,20 @@ public IItemDefinition storageCellFluid4096K() { public IItemDefinition storageCellFluid16384K() { return this.storageCellFluid16384K; } + + public IItemDefinition storageCellGas256K() { + return this.storageCellGas256K; + } + + public IItemDefinition storageCellGas1024K() { + return this.storageCellGas1024K; + } + + public IItemDefinition storageCellGas4096K() { + return this.storageCellGas4096K; + } + + public IItemDefinition storageCellGas16384K() { + return this.storageCellGas16384K; + } } diff --git a/src/main/java/co/neeve/nae2/common/registration/definitions/Materials.java b/src/main/java/co/neeve/nae2/common/registration/definitions/Materials.java index f1a8cb2..ce5c97f 100644 --- a/src/main/java/co/neeve/nae2/common/registration/definitions/Materials.java +++ b/src/main/java/co/neeve/nae2/common/registration/definitions/Materials.java @@ -37,6 +37,11 @@ public class Materials implements DamagedDefinitions cachedValues; private final String id; diff --git a/src/main/resources/assets/nae2/lang/en_us.lang b/src/main/resources/assets/nae2/lang/en_us.lang index 3061051..b014dce 100644 --- a/src/main/resources/assets/nae2/lang/en_us.lang +++ b/src/main/resources/assets/nae2/lang/en_us.lang @@ -18,6 +18,10 @@ item.nae2.storage_cell_fluid_256k.name=§c256k§r ME Fluid Storage Cell item.nae2.storage_cell_fluid_1024k.name=§61024k§r ME Fluid Storage Cell item.nae2.storage_cell_fluid_4096k.name=§e4096k§r ME Fluid Storage Cell item.nae2.storage_cell_fluid_16384k.name=§a16384k§r ME Fluid Storage Cell +item.nae2.storage_cell_gas_256k.name=§c256k§r ME Gas Storage Cell +item.nae2.storage_cell_gas_1024k.name=§61024k§r ME Gas Storage Cell +item.nae2.storage_cell_gas_4096k.name=§e4096k§r ME Gas Storage Cell +item.nae2.storage_cell_gas_16384k.name=§a16384k§r ME Gas Storage Cell # Materials item.nae2.material.cell_part_void.name=ME Void Storage Component @@ -29,6 +33,10 @@ item.nae2.material.cell_part_fluid_256k.name=§c256k§r ME Fluid Storage Compone item.nae2.material.cell_part_fluid_1024k.name=§61024k§r ME Fluid Storage Component item.nae2.material.cell_part_fluid_4096k.name=§e4096k§r ME Fluid Storage Component item.nae2.material.cell_part_fluid_16384k.name=§a16384k§r ME Fluid Storage Component +item.nae2.material.cell_part_gas_256k.name=§c256k§r ME Gas Storage Component +item.nae2.material.cell_part_gas_1024k.name=§61024k§r ME Gas Storage Component +item.nae2.material.cell_part_gas_4096k.name=§e4096k§r ME Gas Storage Component +item.nae2.material.cell_part_gas_16384k.name=§a16384k§r ME Gas Storage Component # Parts item.nae2.part.beam_former.name=ME Beam Former