From 8a8e0391e359ccb51096ac9dd77cb61d614d712d Mon Sep 17 00:00:00 2001 From: 90 <90@national.shitposting.agency> Date: Fri, 13 May 2022 21:43:43 +0100 Subject: [PATCH] Register chem cells regardless of AppMek installation --- src/main/java/ninety/megacells/MEGACells.java | 34 +++---- .../datagen/MEGABlockModelProvider.java | 10 +- .../megacells/datagen/MEGADataGenerators.java | 10 -- .../datagen/MEGAItemModelProvider.java | 24 +++-- .../megacells/datagen/MEGARecipeProvider.java | 22 ++++- .../megacells/init/MEGACellsClient.java | 13 +-- .../integration/appmek/AppMekIntegration.java | 9 ++ .../integration/appmek/ChemicalCellType.java | 30 +++--- .../appmek/MEGAMekIntegration.java | 94 ------------------- .../integration/appmek/MEGAMekItems.java | 24 ----- .../data/MEGAMekBlockModelProvider.java | 28 ------ .../appmek/data/MEGAMekItemModelProvider.java | 27 ------ .../appmek/data/MEGAMekRecipeProvider.java | 31 ------ .../java/ninety/megacells/item/MEGAItems.java | 14 +++ .../megacells/item/MEGAPortableCell.java | 15 +++ .../megacells/item/MEGAStorageCell.java | 17 ++++ .../megacells/item/util/MEGACellType.java | 3 +- 17 files changed, 129 insertions(+), 276 deletions(-) create mode 100644 src/main/java/ninety/megacells/integration/appmek/AppMekIntegration.java delete mode 100644 src/main/java/ninety/megacells/integration/appmek/MEGAMekIntegration.java delete mode 100644 src/main/java/ninety/megacells/integration/appmek/MEGAMekItems.java delete mode 100644 src/main/java/ninety/megacells/integration/appmek/data/MEGAMekBlockModelProvider.java delete mode 100644 src/main/java/ninety/megacells/integration/appmek/data/MEGAMekItemModelProvider.java delete mode 100644 src/main/java/ninety/megacells/integration/appmek/data/MEGAMekRecipeProvider.java diff --git a/src/main/java/ninety/megacells/MEGACells.java b/src/main/java/ninety/megacells/MEGACells.java index 7f7760bd..66f91f9e 100644 --- a/src/main/java/ninety/megacells/MEGACells.java +++ b/src/main/java/ninety/megacells/MEGACells.java @@ -2,8 +2,6 @@ import java.util.stream.Stream; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; @@ -13,7 +11,7 @@ import ninety.megacells.datagen.MEGADataGenerators; import ninety.megacells.init.MEGACellsClient; -import ninety.megacells.integration.appmek.MEGAMekIntegration; +import ninety.megacells.integration.appmek.ChemicalCellType; import ninety.megacells.item.MEGAItems; import ninety.megacells.item.util.MEGACellType; import ninety.megacells.util.MEGACellsUtil; @@ -26,22 +24,12 @@ @Mod(MEGACells.MODID) public class MEGACells { - public static ResourceLocation makeId(String path) { - return new ResourceLocation(MEGACells.MODID, path); - } - - public static String getItemPath(Item item) { - return item.getRegistryName().getPath(); - } - public static final String MODID = "megacells"; public MEGACells() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); MEGAItems.init(bus); - bus.addGenericListener(Item.class, MEGAMekIntegration::registerItems); - bus.addListener(MEGADataGenerators::onGatherData); bus.addListener((FMLCommonSetupEvent event) -> { event.enqueueWork(this::initCellModels); @@ -52,9 +40,10 @@ public MEGACells() { } private void initCellModels() { - for (var cell : Stream.concat( + for (var cell : Stream.of( MEGACellType.ITEM.getCells().stream(), - MEGACellType.FLUID.getCells().stream()).toList()) { + MEGACellType.FLUID.getCells().stream(), + ChemicalCellType.TYPE.getCells().stream()).flatMap(s -> s).toList()) { StorageCellModels.registerModel(cell, MEGACellsUtil.makeId("block/drive/cells/" + MEGACellsUtil.getItemPath(cell))); } @@ -66,7 +55,10 @@ private void initCellModels() { StorageCellModels.registerModel(portableFluidCell, MEGACellsUtil.makeId("block/drive/cells/portable_mega_fluid_cell")); } - MEGAMekIntegration.initCellModels(); + for (var portable : ChemicalCellType.TYPE.getPortableCells()) { + StorageCellModels.registerModel(portable, + MEGACellsUtil.makeId("block/drive/cells/portable_mega_item_cell")); + } } private void initUpgrades() { @@ -80,17 +72,19 @@ private void initUpgrades() { Upgrades.add(AEItems.VOID_CARD, itemCell, 1, storageCellGroup); } - for (var fluidCell : MEGACellType.FLUID.getCells()) { + for (var fluidCell : Stream.concat( + MEGACellType.FLUID.getCells().stream(), ChemicalCellType.TYPE.getCells().stream()).toList()) { Upgrades.add(AEItems.INVERTER_CARD, fluidCell, 1, storageCellGroup); } - for (var portableCell : Stream.concat(MEGACellType.ITEM.getPortableCells().stream(), - MEGACellType.FLUID.getPortableCells().stream()).toList()) { + for (var portableCell : Stream.of( + MEGACellType.ITEM.getPortableCells().stream(), + MEGACellType.FLUID.getPortableCells().stream(), + ChemicalCellType.TYPE.getPortableCells().stream()).flatMap(s -> s).toList()) { Upgrades.add(AEItems.FUZZY_CARD, portableCell, 1, portableCellGroup); Upgrades.add(AEItems.INVERTER_CARD, portableCell, 1, portableCellGroup); Upgrades.add(AEItems.ENERGY_CARD, portableCell, 2, portableCellGroup); } - MEGAMekIntegration.initUpgrades(); } } diff --git a/src/main/java/ninety/megacells/datagen/MEGABlockModelProvider.java b/src/main/java/ninety/megacells/datagen/MEGABlockModelProvider.java index 0540dff0..65a41dcc 100644 --- a/src/main/java/ninety/megacells/datagen/MEGABlockModelProvider.java +++ b/src/main/java/ninety/megacells/datagen/MEGABlockModelProvider.java @@ -8,6 +8,7 @@ import net.minecraftforge.common.data.ExistingFileHelper; import ninety.megacells.MEGACells; +import ninety.megacells.integration.appmek.ChemicalCellType; import ninety.megacells.item.util.MEGACellType; import ninety.megacells.util.MEGACellsUtil; @@ -24,8 +25,10 @@ public MEGABlockModelProvider(DataGenerator generator, ExistingFileHelper existi @Override protected void registerModels() { - for (var cell : Stream.concat(MEGACellType.ITEM.getCells().stream(), - MEGACellType.FLUID.getCells().stream()).toList()) { + for (var cell : Stream.of( + MEGACellType.ITEM.getCells().stream(), + MEGACellType.FLUID.getCells().stream(), + ChemicalCellType.TYPE.getCells().stream()).flatMap(s -> s).toList()) { String path = "block/drive/cells/" + MEGACellsUtil.getItemPath(cell); withExistingParent(path, DRIVE_CELL).texture("cell", path); } @@ -35,5 +38,8 @@ protected void registerModels() { String portableFluidCell = "block/drive/cells/portable_mega_fluid_cell"; withExistingParent(portableFluidCell, DRIVE_CELL).texture("cell", portableFluidCell); + + String portableChemicalCell = "block/drive/cells/portable_mega_chemical_cell"; + withExistingParent(portableChemicalCell, DRIVE_CELL).texture("cell", portableChemicalCell); } } diff --git a/src/main/java/ninety/megacells/datagen/MEGADataGenerators.java b/src/main/java/ninety/megacells/datagen/MEGADataGenerators.java index 9cea42fb..58885d23 100644 --- a/src/main/java/ninety/megacells/datagen/MEGADataGenerators.java +++ b/src/main/java/ninety/megacells/datagen/MEGADataGenerators.java @@ -7,10 +7,6 @@ import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import ninety.megacells.MEGACells; -import ninety.megacells.integration.appmek.MEGAMekIntegration; -import ninety.megacells.integration.appmek.data.MEGAMekBlockModelProvider; -import ninety.megacells.integration.appmek.data.MEGAMekItemModelProvider; -import ninety.megacells.integration.appmek.data.MEGAMekRecipeProvider; @Mod.EventBusSubscriber(modid = MEGACells.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class MEGADataGenerators { @@ -23,11 +19,5 @@ public static void onGatherData(GatherDataEvent event) { generator.addProvider(new MEGAItemModelProvider(generator, existingFileHelper)); generator.addProvider(new MEGABlockModelProvider(generator, existingFileHelper)); generator.addProvider(new MEGARecipeProvider(generator)); - - if (MEGAMekIntegration.isLoaded()) { - generator.addProvider(new MEGAMekItemModelProvider(generator, existingFileHelper)); - generator.addProvider(new MEGAMekBlockModelProvider(generator, existingFileHelper)); - generator.addProvider(new MEGAMekRecipeProvider(generator)); - } } } diff --git a/src/main/java/ninety/megacells/datagen/MEGAItemModelProvider.java b/src/main/java/ninety/megacells/datagen/MEGAItemModelProvider.java index f82b0f70..1f9acb34 100644 --- a/src/main/java/ninety/megacells/datagen/MEGAItemModelProvider.java +++ b/src/main/java/ninety/megacells/datagen/MEGAItemModelProvider.java @@ -10,7 +10,9 @@ import net.minecraftforge.common.data.ExistingFileHelper; import ninety.megacells.MEGACells; +import ninety.megacells.integration.appmek.ChemicalCellType; import ninety.megacells.item.MEGAItems; +import ninety.megacells.item.util.MEGACellTier; import ninety.megacells.item.util.MEGACellType; import ninety.megacells.util.MEGACellsUtil; @@ -31,20 +33,22 @@ public MEGAItemModelProvider(DataGenerator generator, ExistingFileHelper existin protected void registerModels() { flatSingleLayer(MEGAItems.MEGA_ITEM_CELL_HOUSING.get()); flatSingleLayer(MEGAItems.MEGA_FLUID_CELL_HOUSING.get()); + flatSingleLayer(MEGAItems.MEGA_CHEMICAL_CELL_HOUSING.get()); - flatSingleLayer(MEGAItems.CELL_COMPONENT_1M.get()); - flatSingleLayer(MEGAItems.CELL_COMPONENT_4M.get()); - flatSingleLayer(MEGAItems.CELL_COMPONENT_16M.get()); - flatSingleLayer(MEGAItems.CELL_COMPONENT_64M.get()); - flatSingleLayer(MEGAItems.CELL_COMPONENT_256M.get()); + for (var tier : MEGACellTier.values()) { + flatSingleLayer(tier.getComponent()); + } - for (var storage : Stream.concat(MEGACellType.ITEM.getCells().stream(), MEGACellType.FLUID.getCells().stream()) - .toList()) { + for (var storage : Stream.of( + MEGACellType.ITEM.getCells().stream(), + MEGACellType.FLUID.getCells().stream(), + ChemicalCellType.TYPE.getCells().stream()).flatMap(s -> s).toList()) { cell(storage); } - for (var portable : Stream - .concat(MEGACellType.ITEM.getPortableCells().stream(), MEGACellType.FLUID.getPortableCells().stream()) - .toList()) { + for (var portable : Stream.of( + MEGACellType.ITEM.getPortableCells().stream(), + MEGACellType.FLUID.getPortableCells().stream(), + ChemicalCellType.TYPE.getPortableCells().stream()).flatMap(s -> s).toList()) { portable(portable); } } diff --git a/src/main/java/ninety/megacells/datagen/MEGARecipeProvider.java b/src/main/java/ninety/megacells/datagen/MEGARecipeProvider.java index ff40ac3d..89bafd4e 100644 --- a/src/main/java/ninety/megacells/datagen/MEGARecipeProvider.java +++ b/src/main/java/ninety/megacells/datagen/MEGARecipeProvider.java @@ -12,6 +12,8 @@ import net.minecraft.data.recipes.ShapelessRecipeBuilder; import net.minecraft.world.item.Item; +import ninety.megacells.integration.appmek.AppMekIntegration; +import ninety.megacells.integration.appmek.ChemicalCellType; import ninety.megacells.item.MEGAItems; import ninety.megacells.item.MEGAPortableCell; import ninety.megacells.item.MEGAStorageCell; @@ -45,6 +47,16 @@ protected void buildCraftingRecipes(@NotNull Consumer consumer) for (var portable : Stream.concat(MEGACellType.ITEM.getPortableCells().stream(), MEGACellType.FLUID.getPortableCells().stream()).toList()) { portable(consumer, portable); } + + if (AppMekIntegration.isAppMekLoaded()) { + housing(consumer, ChemicalCellType.TYPE); + for (var chemStorage : ChemicalCellType.TYPE.getCells()) { + cell(consumer, chemStorage); + } + for (var chemPortable : ChemicalCellType.TYPE.getPortableCells()) { + portable(consumer, chemPortable); + } + } // spotless:on } @@ -61,7 +73,7 @@ private void component(Consumer consumer, Item preceding, Item o .save(consumer, MEGACellsUtil.makeId("cells/" + MEGACellsUtil.getItemPath(output))); } - protected void cell(Consumer consumer, Item cellItem) { + private void cell(Consumer consumer, Item cellItem) { var cell = (MEGAStorageCell) cellItem; var component = cell.getTier().getComponent(); @@ -80,16 +92,16 @@ protected void cell(Consumer consumer, Item cellItem) { .define('c', component) .define('d', housingMaterial) .unlockedBy("has_" + componentPath, has(component)) - .save(consumer, MEGACellsUtil.makeId("cells/standard" + cellPath)); + .save(consumer, MEGACellsUtil.makeId("cells/standard/" + cellPath)); ShapelessRecipeBuilder.shapeless(cellItem) .requires(housing) .requires(component) .unlockedBy("has_" + componentPath, has(component)) .unlockedBy("has_" + MEGACellsUtil.getItemPath(housing), has(housing)) - .save(consumer, MEGACellsUtil.makeId("cells/standard" + cellPath + "_with_housing")); + .save(consumer, MEGACellsUtil.makeId("cells/standard/" + cellPath + "_with_housing")); } - protected void portable(Consumer consumer, Item portableCellItem) { + private void portable(Consumer consumer, Item portableCellItem) { var portableCell = (MEGAPortableCell) portableCellItem; var housing = portableCell.type.housing(); ShapelessRecipeBuilder.shapeless(portableCell) @@ -102,7 +114,7 @@ protected void portable(Consumer consumer, Item portableCellItem .save(consumer, MEGACellsUtil.makeId("cells/portable/" + MEGACellsUtil.getItemPath(portableCell))); } - protected void housing(Consumer consumer, IMEGACellType type) { + private void housing(Consumer consumer, IMEGACellType type) { var housing = type.housing(); ShapedRecipeBuilder.shaped(type.housing()) .pattern("aba") diff --git a/src/main/java/ninety/megacells/init/MEGACellsClient.java b/src/main/java/ninety/megacells/init/MEGACellsClient.java index bbbb1113..dde222b4 100644 --- a/src/main/java/ninety/megacells/init/MEGACellsClient.java +++ b/src/main/java/ninety/megacells/init/MEGACellsClient.java @@ -5,7 +5,7 @@ import net.minecraftforge.client.event.ColorHandlerEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import ninety.megacells.integration.appmek.MEGAMekIntegration; +import ninety.megacells.integration.appmek.ChemicalCellType; import ninety.megacells.item.MEGAPortableCell; import ninety.megacells.item.MEGAStorageCell; import ninety.megacells.item.util.MEGACellType; @@ -17,16 +17,17 @@ public static void initialize() { } private static void initItemColors(ColorHandlerEvent.Item event) { - for (var cell : Stream.concat( + for (var cell : Stream.of( MEGACellType.ITEM.getCells().stream(), - MEGACellType.FLUID.getCells().stream()).toList()) { + MEGACellType.FLUID.getCells().stream(), + ChemicalCellType.TYPE.getCells().stream()).flatMap(s -> s).toList()) { event.getItemColors().register(MEGAStorageCell::getColor, cell); } - for (var cell : Stream.concat( + for (var cell : Stream.of( MEGACellType.ITEM.getPortableCells().stream(), - MEGACellType.FLUID.getPortableCells().stream()).toList()) { + MEGACellType.FLUID.getPortableCells().stream(), + ChemicalCellType.TYPE.getPortableCells().stream()).flatMap(s -> s).toList()) { event.getItemColors().register(MEGAPortableCell::getColor, cell); } - MEGAMekIntegration.initItemColors(event); } } diff --git a/src/main/java/ninety/megacells/integration/appmek/AppMekIntegration.java b/src/main/java/ninety/megacells/integration/appmek/AppMekIntegration.java new file mode 100644 index 00000000..698a8c04 --- /dev/null +++ b/src/main/java/ninety/megacells/integration/appmek/AppMekIntegration.java @@ -0,0 +1,9 @@ +package ninety.megacells.integration.appmek; + +import net.minecraftforge.fml.ModList; + +public final class AppMekIntegration { + public static boolean isAppMekLoaded() { + return ModList.get().isLoaded("appmek"); + } +} diff --git a/src/main/java/ninety/megacells/integration/appmek/ChemicalCellType.java b/src/main/java/ninety/megacells/integration/appmek/ChemicalCellType.java index 1691ec8a..93edc458 100644 --- a/src/main/java/ninety/megacells/integration/appmek/ChemicalCellType.java +++ b/src/main/java/ninety/megacells/integration/appmek/ChemicalCellType.java @@ -1,6 +1,5 @@ package ninety.megacells.integration.appmek; -import java.util.ArrayList; import java.util.List; import net.minecraft.resources.ResourceLocation; @@ -11,6 +10,7 @@ import me.ramidzkh.mekae2.AMMenus; import me.ramidzkh.mekae2.ae2.MekanismKeyType; +import ninety.megacells.item.MEGAItems; import ninety.megacells.item.util.IMEGACellType; import appeng.api.stacks.AEKeyType; @@ -21,7 +21,7 @@ public enum ChemicalCellType implements IMEGACellType { @Override public AEKeyType keyType() { - return MekanismKeyType.TYPE; + return AppMekIntegration.isAppMekLoaded() ? MekanismKeyType.TYPE : AEKeyType.fluids(); } @Override @@ -31,7 +31,7 @@ public String affix() { @Override public Item housing() { - return MEGAMekItems.MEGA_CHEMICAL_CELL_HOUSING; + return MEGAItems.MEGA_CHEMICAL_CELL_HOUSING.get(); } @Override @@ -41,28 +41,22 @@ public TagKey housingMaterial() { @Override public MenuType portableCellMenu() { - return AMMenus.PORTABLE_CHEMICAL_CELL_TYPE; + return AppMekIntegration.isAppMekLoaded() + ? AMMenus.PORTABLE_CHEMICAL_CELL_TYPE + : MEStorageMenu.PORTABLE_FLUID_CELL_TYPE; } @Override public List getCells() { - var cells = new ArrayList(); - cells.add(MEGAMekItems.CHEMICAL_STORAGE_CELL_1M); - cells.add(MEGAMekItems.CHEMICAL_STORAGE_CELL_4M); - cells.add(MEGAMekItems.CHEMICAL_STORAGE_CELL_16M); - cells.add(MEGAMekItems.CHEMICAL_STORAGE_CELL_64M); - cells.add(MEGAMekItems.CHEMICAL_STORAGE_CELL_256M); - return cells; + return List.of(MEGAItems.CHEMICAL_CELL_1M.get(), MEGAItems.CHEMICAL_CELL_4M.get(), + MEGAItems.CHEMICAL_CELL_16M.get(), MEGAItems.CHEMICAL_CELL_64M.get(), + MEGAItems.CHEMICAL_CELL_256M.get()); } @Override public List getPortableCells() { - var cells = new ArrayList(); - cells.add(MEGAMekItems.PORTABLE_CHEMICAL_CELL_1M); - cells.add(MEGAMekItems.PORTABLE_CHEMICAL_CELL_4M); - cells.add(MEGAMekItems.PORTABLE_CHEMICAL_CELL_16M); - cells.add(MEGAMekItems.PORTABLE_CHEMICAL_CELL_64M); - cells.add(MEGAMekItems.PORTABLE_CHEMICAL_CELL_256M); - return cells; + return List.of(MEGAItems.PORTABLE_CHEMICAL_CELL_1M.get(), MEGAItems.PORTABLE_CHEMICAL_CELL_4M.get(), + MEGAItems.PORTABLE_CHEMICAL_CELL_16M.get(), MEGAItems.PORTABLE_CHEMICAL_CELL_64M.get(), + MEGAItems.PORTABLE_CHEMICAL_CELL_256M.get()); } } diff --git a/src/main/java/ninety/megacells/integration/appmek/MEGAMekIntegration.java b/src/main/java/ninety/megacells/integration/appmek/MEGAMekIntegration.java deleted file mode 100644 index 94997c94..00000000 --- a/src/main/java/ninety/megacells/integration/appmek/MEGAMekIntegration.java +++ /dev/null @@ -1,94 +0,0 @@ -package ninety.megacells.integration.appmek; - -import net.minecraft.world.item.Item; -import net.minecraftforge.client.event.ColorHandlerEvent; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.fml.ModList; - -import ninety.megacells.item.MEGAItems; -import ninety.megacells.item.MEGAPortableCell; -import ninety.megacells.item.MEGAStorageCell; -import ninety.megacells.item.util.MEGACellTier; -import ninety.megacells.util.MEGACellsUtil; - -import appeng.api.client.StorageCellModels; -import appeng.api.upgrades.Upgrades; -import appeng.core.definitions.AEItems; -import appeng.core.localization.GuiText; -import appeng.items.materials.MaterialItem; - -public class MEGAMekIntegration { - protected static Item cell(MEGACellTier tier) { - return new MEGAStorageCell(MEGAItems.props.stacksTo(1), tier, ChemicalCellType.TYPE) - .setRegistryName(MEGACellsUtil.makeId("chemical_storage_cell_" + tier.affix)); - } - - protected static Item portable(MEGACellTier tier) { - return new MEGAPortableCell(MEGAItems.props.stacksTo(1), tier, ChemicalCellType.TYPE) - .setRegistryName(MEGACellsUtil.makeId("portable_chemical_cell_" + tier.affix)); - } - - private static final Item HOUSING = new MaterialItem(MEGAItems.props) - .setRegistryName(MEGACellsUtil.makeId("mega_chemical_cell_housing")); - - public static void registerItems(RegistryEvent.Register event) { - if (isLoaded()) { - event.getRegistry().registerAll( - HOUSING, - cell(MEGACellTier._1M), - cell(MEGACellTier._4M), - cell(MEGACellTier._16M), - cell(MEGACellTier._64M), - cell(MEGACellTier._256M), - portable(MEGACellTier._1M), - portable(MEGACellTier._4M), - portable(MEGACellTier._16M), - portable(MEGACellTier._64M), - portable(MEGACellTier._256M)); - } - } - - public static void initUpgrades() { - if (isLoaded()) { - var storageCellGroup = GuiText.StorageCells.getTranslationKey(); - var portableCellGroup = GuiText.PortableCells.getTranslationKey(); - - for (var cell : ChemicalCellType.TYPE.getCells()) { - Upgrades.add(AEItems.INVERTER_CARD, cell, 1, storageCellGroup); - } - for (var portable : ChemicalCellType.TYPE.getPortableCells()) { - Upgrades.add(AEItems.FUZZY_CARD, portable, 1, portableCellGroup); - Upgrades.add(AEItems.INVERTER_CARD, portable, 1, portableCellGroup); - Upgrades.add(AEItems.ENERGY_CARD, portable, 2, portableCellGroup); - } - } - } - - public static void initCellModels() { - if (isLoaded()) { - for (var cell : ChemicalCellType.TYPE.getCells()) { - StorageCellModels.registerModel(cell, - MEGACellsUtil.makeId("block/drive/cells/" + MEGACellsUtil.getItemPath(cell))); - } - for (var portable : ChemicalCellType.TYPE.getPortableCells()) { - StorageCellModels.registerModel(portable, - MEGACellsUtil.makeId("block/drive/cells/portable_mega_item_cell")); - } - } - } - - public static void initItemColors(ColorHandlerEvent.Item event) { - if (isLoaded()) { - for (var cell : ChemicalCellType.TYPE.getCells()) { - event.getItemColors().register(MEGAStorageCell::getColor, cell); - } - for (var cell : ChemicalCellType.TYPE.getPortableCells()) { - event.getItemColors().register(MEGAPortableCell::getColor, cell); - } - } - } - - public static boolean isLoaded() { - return ModList.get().isLoaded("appmek"); - } -} diff --git a/src/main/java/ninety/megacells/integration/appmek/MEGAMekItems.java b/src/main/java/ninety/megacells/integration/appmek/MEGAMekItems.java deleted file mode 100644 index 5e32cec5..00000000 --- a/src/main/java/ninety/megacells/integration/appmek/MEGAMekItems.java +++ /dev/null @@ -1,24 +0,0 @@ -package ninety.megacells.integration.appmek; - -import net.minecraft.world.item.Item; -import net.minecraftforge.registries.ObjectHolder; - -import ninety.megacells.MEGACells; - -@ObjectHolder(MEGACells.MODID) -public class MEGAMekItems { - - public static final Item MEGA_CHEMICAL_CELL_HOUSING = null; - - public static final Item CHEMICAL_STORAGE_CELL_1M = null; - public static final Item CHEMICAL_STORAGE_CELL_4M = null; - public static final Item CHEMICAL_STORAGE_CELL_16M = null; - public static final Item CHEMICAL_STORAGE_CELL_64M = null; - public static final Item CHEMICAL_STORAGE_CELL_256M = null; - - public static final Item PORTABLE_CHEMICAL_CELL_1M = null; - public static final Item PORTABLE_CHEMICAL_CELL_4M = null; - public static final Item PORTABLE_CHEMICAL_CELL_16M = null; - public static final Item PORTABLE_CHEMICAL_CELL_64M = null; - public static final Item PORTABLE_CHEMICAL_CELL_256M = null; -} diff --git a/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekBlockModelProvider.java b/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekBlockModelProvider.java deleted file mode 100644 index df943425..00000000 --- a/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekBlockModelProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -package ninety.megacells.integration.appmek.data; - -import net.minecraft.data.DataGenerator; -import net.minecraftforge.common.data.ExistingFileHelper; - -import ninety.megacells.datagen.MEGABlockModelProvider; -import ninety.megacells.integration.appmek.ChemicalCellType; -import ninety.megacells.integration.appmek.MEGAMekIntegration; -import ninety.megacells.util.MEGACellsUtil; - -public class MEGAMekBlockModelProvider extends MEGABlockModelProvider { - - public MEGAMekBlockModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) { - super(generator, existingFileHelper); - } - - @Override - protected void registerModels() { - if (MEGAMekIntegration.isLoaded()) { - for (var cell : ChemicalCellType.TYPE.getCells()) { - String path = "block/drive/cells/" + MEGACellsUtil.getItemPath(cell); - withExistingParent(path, DRIVE_CELL).texture("cell", path); - } - String portableChemicalCell = "block/drive/cells/portable_mega_chemical_cell"; - withExistingParent(portableChemicalCell, DRIVE_CELL).texture("cell", portableChemicalCell); - } - } -} diff --git a/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekItemModelProvider.java b/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekItemModelProvider.java deleted file mode 100644 index ba70f1a8..00000000 --- a/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekItemModelProvider.java +++ /dev/null @@ -1,27 +0,0 @@ -package ninety.megacells.integration.appmek.data; - -import net.minecraft.data.DataGenerator; -import net.minecraftforge.common.data.ExistingFileHelper; - -import ninety.megacells.datagen.MEGAItemModelProvider; -import ninety.megacells.integration.appmek.ChemicalCellType; -import ninety.megacells.integration.appmek.MEGAMekIntegration; - -public class MEGAMekItemModelProvider extends MEGAItemModelProvider { - public MEGAMekItemModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) { - super(generator, existingFileHelper); - } - - @Override - protected void registerModels() { - if (MEGAMekIntegration.isLoaded()) { - flatSingleLayer(ChemicalCellType.TYPE.housing()); - for (var storage : ChemicalCellType.TYPE.getCells()) { - cell(storage); - } - for (var portable : ChemicalCellType.TYPE.getPortableCells()) { - portable(portable); - } - } - } -} diff --git a/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekRecipeProvider.java b/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekRecipeProvider.java deleted file mode 100644 index 2feecfe3..00000000 --- a/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekRecipeProvider.java +++ /dev/null @@ -1,31 +0,0 @@ -package ninety.megacells.integration.appmek.data; - -import java.util.function.Consumer; - -import ninety.megacells.integration.appmek.MEGAMekIntegration; -import org.jetbrains.annotations.NotNull; - -import net.minecraft.data.DataGenerator; -import net.minecraft.data.recipes.FinishedRecipe; - -import ninety.megacells.datagen.MEGARecipeProvider; -import ninety.megacells.integration.appmek.ChemicalCellType; - -public class MEGAMekRecipeProvider extends MEGARecipeProvider { - public MEGAMekRecipeProvider(DataGenerator generator) { - super(generator); - } - - @Override - protected void buildCraftingRecipes(@NotNull Consumer consumer) { - if (MEGAMekIntegration.isLoaded()) { - housing(consumer, ChemicalCellType.TYPE); - for (var storage : ChemicalCellType.TYPE.getCells()) { - cell(consumer, storage); - } - for (var portable : ChemicalCellType.TYPE.getPortableCells()) { - portable(consumer, portable); - } - } - } -} diff --git a/src/main/java/ninety/megacells/item/MEGAItems.java b/src/main/java/ninety/megacells/item/MEGAItems.java index b85b3f76..28e34804 100644 --- a/src/main/java/ninety/megacells/item/MEGAItems.java +++ b/src/main/java/ninety/megacells/item/MEGAItems.java @@ -11,6 +11,7 @@ import net.minecraftforge.registries.RegistryObject; import ninety.megacells.MEGACells; +import ninety.megacells.integration.appmek.ChemicalCellType; import ninety.megacells.item.util.IMEGACellType; import ninety.megacells.item.util.MEGACellTier; import ninety.megacells.item.util.MEGACellType; @@ -38,6 +39,7 @@ public static void init(IEventBus bus) { public static final RegistryObject MEGA_ITEM_CELL_HOUSING = ITEMS.register("mega_item_cell_housing", () -> new MaterialItem(props)); public static final RegistryObject MEGA_FLUID_CELL_HOUSING = ITEMS.register("mega_fluid_cell_housing", () -> new MaterialItem(props)); + public static final RegistryObject MEGA_CHEMICAL_CELL_HOUSING = ITEMS.register("mega_chemical_cell_housing", () -> new MaterialItem(props)); public static final RegistryObject CELL_COMPONENT_1M = component(MEGACellTier._1M); public static final RegistryObject CELL_COMPONENT_4M = component(MEGACellTier._4M); @@ -57,6 +59,12 @@ public static void init(IEventBus bus) { public static final RegistryObject FLUID_CELL_64M = cell(MEGACellTier._64M, MEGACellType.FLUID); public static final RegistryObject FLUID_CELL_256M = cell(MEGACellTier._256M, MEGACellType.FLUID); + public static final RegistryObject CHEMICAL_CELL_1M = cell(MEGACellTier._1M, ChemicalCellType.TYPE); + public static final RegistryObject CHEMICAL_CELL_4M = cell(MEGACellTier._4M, ChemicalCellType.TYPE); + public static final RegistryObject CHEMICAL_CELL_16M = cell(MEGACellTier._16M, ChemicalCellType.TYPE); + public static final RegistryObject CHEMICAL_CELL_64M = cell(MEGACellTier._64M, ChemicalCellType.TYPE); + public static final RegistryObject CHEMICAL_CELL_256M = cell(MEGACellTier._256M, ChemicalCellType.TYPE); + public static final RegistryObject PORTABLE_ITEM_CELL_1M = portable(MEGACellTier._1M, MEGACellType.ITEM); public static final RegistryObject PORTABLE_ITEM_CELL_4M = portable(MEGACellTier._4M, MEGACellType.ITEM); public static final RegistryObject PORTABLE_ITEM_CELL_16M = portable(MEGACellTier._16M, MEGACellType.ITEM); @@ -68,6 +76,12 @@ public static void init(IEventBus bus) { public static final RegistryObject PORTABLE_FLUID_CELL_16M = portable(MEGACellTier._16M, MEGACellType.FLUID); public static final RegistryObject PORTABLE_FLUID_CELL_64M = portable(MEGACellTier._64M, MEGACellType.FLUID); public static final RegistryObject PORTABLE_FLUID_CELL_256M = portable(MEGACellTier._256M, MEGACellType.FLUID); + + public static final RegistryObject PORTABLE_CHEMICAL_CELL_1M = portable(MEGACellTier._1M, ChemicalCellType.TYPE); + public static final RegistryObject PORTABLE_CHEMICAL_CELL_4M = portable(MEGACellTier._4M, ChemicalCellType.TYPE); + public static final RegistryObject PORTABLE_CHEMICAL_CELL_16M = portable(MEGACellTier._16M, ChemicalCellType.TYPE); + public static final RegistryObject PORTABLE_CHEMICAL_CELL_64M = portable(MEGACellTier._64M, ChemicalCellType.TYPE); + public static final RegistryObject PORTABLE_CHEMICAL_CELL_256M = portable(MEGACellTier._256M, ChemicalCellType.TYPE); // spotless:on private static RegistryObject component(MEGACellTier cellTier) { diff --git a/src/main/java/ninety/megacells/item/MEGAPortableCell.java b/src/main/java/ninety/megacells/item/MEGAPortableCell.java index ff2c9caa..27c781a1 100644 --- a/src/main/java/ninety/megacells/item/MEGAPortableCell.java +++ b/src/main/java/ninety/megacells/item/MEGAPortableCell.java @@ -1,10 +1,17 @@ package ninety.megacells.item; +import java.util.List; import java.util.Objects; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.level.Level; +import ninety.megacells.integration.appmek.AppMekIntegration; +import ninety.megacells.integration.appmek.ChemicalCellType; import ninety.megacells.item.util.IMEGACellType; import ninety.megacells.item.util.MEGACellTier; import ninety.megacells.util.MEGACellsUtil; @@ -55,4 +62,12 @@ private void onUpgradesChanged(ItemStack stack, IUpgradeInventory upgrades) { setAEMaxPowerMultiplier(stack, 1 + energyCards); } + @Override + public void appendHoverText(ItemStack stack, Level level, List lines, TooltipFlag advancedTooltips) { + super.appendHoverText(stack, level, lines, advancedTooltips); + if (!AppMekIntegration.isAppMekLoaded() && this.type == ChemicalCellType.TYPE) { + lines.add(new TextComponent("AppMek not installed.")); + } + } + } diff --git a/src/main/java/ninety/megacells/item/MEGAStorageCell.java b/src/main/java/ninety/megacells/item/MEGAStorageCell.java index c1d8e116..727d374d 100644 --- a/src/main/java/ninety/megacells/item/MEGAStorageCell.java +++ b/src/main/java/ninety/megacells/item/MEGAStorageCell.java @@ -1,5 +1,15 @@ package ninety.megacells.item; +import java.util.List; + +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.level.Level; + +import ninety.megacells.integration.appmek.AppMekIntegration; +import ninety.megacells.integration.appmek.ChemicalCellType; import ninety.megacells.item.util.IMEGACellType; import ninety.megacells.item.util.MEGACellTier; import ninety.megacells.item.util.MEGACellType; @@ -26,4 +36,11 @@ public IMEGACellType getType() { return this.type; } + @Override + public void appendHoverText(ItemStack stack, Level level, List lines, TooltipFlag advancedTooltips) { + super.appendHoverText(stack, level, lines, advancedTooltips); + if (!AppMekIntegration.isAppMekLoaded() && this.type == ChemicalCellType.TYPE) { + lines.add(new TextComponent("AppMek not installed.")); + } + } } diff --git a/src/main/java/ninety/megacells/item/util/MEGACellType.java b/src/main/java/ninety/megacells/item/util/MEGACellType.java index 5479d98b..caaa336f 100644 --- a/src/main/java/ninety/megacells/item/util/MEGACellType.java +++ b/src/main/java/ninety/megacells/item/util/MEGACellType.java @@ -14,7 +14,8 @@ public enum MEGACellType implements IMEGACellType { ITEM(AEKeyType.items(), "item", ConventionTags.IRON_INGOT, MEStorageMenu.PORTABLE_ITEM_CELL_TYPE), - FLUID(AEKeyType.fluids(), "fluid", ConventionTags.COPPER_INGOT, MEStorageMenu.PORTABLE_FLUID_CELL_TYPE); + FLUID(AEKeyType.fluids(), "fluid", ConventionTags.COPPER_INGOT, MEStorageMenu.PORTABLE_FLUID_CELL_TYPE), + ; public final AEKeyType key; public final String affix;