From eb5d82db5c30464e53ea87b2c1a9dcbc624bca18 Mon Sep 17 00:00:00 2001 From: 90 Date: Thu, 2 May 2024 19:35:39 +0100 Subject: [PATCH] Fix incorrect stack size, charge rates and recipe IDs for chemical and source cells Closes #119 --- .../integration/appmek/AppMekItems.java | 48 ++++++++++--------- .../integration/arseng/ArsEngItems.java | 15 +++++- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekItems.java b/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekItems.java index c45e615d..0616f022 100644 --- a/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekItems.java +++ b/forge/src/main/java/gripe/_90/megacells/integration/appmek/AppMekItems.java @@ -2,22 +2,24 @@ import java.util.List; -import org.jetbrains.annotations.NotNull; - -import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import appeng.api.stacks.AEKey; import appeng.core.definitions.ItemDefinition; import appeng.items.materials.MaterialItem; import appeng.items.storage.StorageTier; import appeng.items.tools.powered.AbstractPortableCell; import me.ramidzkh.mekae2.AMMenus; -import me.ramidzkh.mekae2.item.ChemicalPortableCellItem; +import me.ramidzkh.mekae2.ae2.MekanismKey; +import me.ramidzkh.mekae2.ae2.MekanismKeyType; import me.ramidzkh.mekae2.item.ChemicalStorageCell; +import mekanism.api.chemical.attribute.ChemicalAttributeValidator; import gripe._90.megacells.MEGACells; import gripe._90.megacells.definition.MEGAItems; import gripe._90.megacells.integration.appmek.item.RadioactiveCellItem; +import gripe._90.megacells.item.cell.MEGAPortableCell; public final class AppMekItems { public static void init() { @@ -34,16 +36,11 @@ public static void init() { public static final ItemDefinition CHEMICAL_CELL_64M = cell(MEGAItems.TIER_64M); public static final ItemDefinition CHEMICAL_CELL_256M = cell(MEGAItems.TIER_256M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_1M = - portable(MEGAItems.TIER_1M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_4M = - portable(MEGAItems.TIER_4M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_16M = - portable(MEGAItems.TIER_16M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_64M = - portable(MEGAItems.TIER_64M); - public static final ItemDefinition PORTABLE_CHEMICAL_CELL_256M = - portable(MEGAItems.TIER_256M); + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_1M = portable(MEGAItems.TIER_1M); + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_4M = portable(MEGAItems.TIER_4M); + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_16M = portable(MEGAItems.TIER_16M); + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_64M = portable(MEGAItems.TIER_64M); + public static final ItemDefinition PORTABLE_CHEMICAL_CELL_256M = portable(MEGAItems.TIER_256M); public static final ItemDefinition RADIOACTIVE_CELL_COMPONENT = MEGAItems.item("MEGA Radioactive Storage Component", "radioactive_cell_component", MaterialItem::new); @@ -67,19 +64,24 @@ private static ItemDefinition cell(StorageTier tier) { return MEGAItems.item( tier.namePrefix().toUpperCase() + " MEGA Chemical Storage Cell", "chemical_storage_cell_" + tier.namePrefix(), - p -> new ChemicalStorageCell(p, tier, MEGA_CHEMICAL_CELL_HOUSING)); + p -> new ChemicalStorageCell(p.stacksTo(1), tier, MEGA_CHEMICAL_CELL_HOUSING)); } - private static ItemDefinition portable(StorageTier tier) { + private static ItemDefinition portable(StorageTier tier) { return MEGAItems.item( tier.namePrefix().toUpperCase() + " Portable Chemical Cell", "portable_chemical_cell_" + tier.namePrefix(), - p -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, tier, p, 0x33528D) { - @NotNull - @Override - public ResourceLocation getRecipeId() { - return MEGACells.makeId("cells/portable/portable_chemical_cell_" + tier.namePrefix()); - } - }); + p -> + new MEGAPortableCell( + p, tier, MekanismKeyType.TYPE, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, 0x33528D) { + @Override + public boolean isBlackListed(ItemStack cellItem, AEKey requestedAddition) { + if (requestedAddition instanceof MekanismKey key) { + return !ChemicalAttributeValidator.DEFAULT.process(key.getStack()); + } else { + return true; + } + } + }); } } diff --git a/forge/src/main/java/gripe/_90/megacells/integration/arseng/ArsEngItems.java b/forge/src/main/java/gripe/_90/megacells/integration/arseng/ArsEngItems.java index 5a6a8062..45c06a2d 100644 --- a/forge/src/main/java/gripe/_90/megacells/integration/arseng/ArsEngItems.java +++ b/forge/src/main/java/gripe/_90/megacells/integration/arseng/ArsEngItems.java @@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; import appeng.core.definitions.ItemDefinition; import appeng.items.materials.MaterialItem; @@ -54,19 +55,29 @@ private static ItemDefinition cell(StorageTier tier) { return MEGAItems.item( tier.namePrefix().toUpperCase() + " MEGA Source Storage Cell", "source_storage_cell_" + tier.namePrefix(), - p -> new SourceCellItem(p, tier, MEGA_SOURCE_CELL_HOUSING)); + p -> new SourceCellItem(p.stacksTo(1), tier, MEGA_SOURCE_CELL_HOUSING)); } private static ItemDefinition portable(StorageTier tier) { return MEGAItems.item( tier.namePrefix().toUpperCase() + " Portable Source Cell", "portable_source_cell_" + tier.namePrefix(), - p -> new PortableSourceCellItem(p, tier) { + p -> new PortableSourceCellItem(p.stacksTo(1), tier) { @NotNull @Override public ResourceLocation getRecipeId() { return MEGACells.makeId("cells/portable/portable_source_cell_" + tier.namePrefix()); } + + @Override + public double getChargeRate(ItemStack stack) { + return super.getChargeRate(stack) * 2; + } + + @Override + public double getAEMaxPower(ItemStack stack) { + return super.getAEMaxPower(stack) * 8; + } }); } }