diff --git a/build.gradle b/build.gradle index ba9aff1c..c364aee2 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ apply(plugin: "net.minecraftforge.gradle") apply plugin: 'org.spongepowered.mixin' group = "ninety" -version = "1.0.0-alpha.1" +version = "1.0.0-beta.1" repositories { maven { diff --git a/src/main/java/ninety/megacells/MEGACells.java b/src/main/java/ninety/megacells/MEGACells.java index b5ca5da1..7f7760bd 100644 --- a/src/main/java/ninety/megacells/MEGACells.java +++ b/src/main/java/ninety/megacells/MEGACells.java @@ -2,6 +2,8 @@ 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; @@ -11,8 +13,9 @@ import ninety.megacells.datagen.MEGADataGenerators; import ninety.megacells.init.MEGACellsClient; -import ninety.megacells.item.MEGACellType; +import ninety.megacells.integration.appmek.MEGAMekIntegration; import ninety.megacells.item.MEGAItems; +import ninety.megacells.item.util.MEGACellType; import ninety.megacells.util.MEGACellsUtil; import appeng.api.client.StorageCellModels; @@ -23,12 +26,22 @@ @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); @@ -39,8 +52,9 @@ public MEGACells() { } private void initCellModels() { - for (var cell : Stream.concat(MEGACellType.ITEM.getCells().stream(), MEGACellType.FLUID.getCells().stream()) - .toList()) { + for (var cell : Stream.concat( + MEGACellType.ITEM.getCells().stream(), + MEGACellType.FLUID.getCells().stream()).toList()) { StorageCellModels.registerModel(cell, MEGACellsUtil.makeId("block/drive/cells/" + MEGACellsUtil.getItemPath(cell))); } @@ -52,6 +66,7 @@ private void initCellModels() { StorageCellModels.registerModel(portableFluidCell, MEGACellsUtil.makeId("block/drive/cells/portable_mega_fluid_cell")); } + MEGAMekIntegration.initCellModels(); } private void initUpgrades() { @@ -75,6 +90,7 @@ private void initUpgrades() { 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 638333b5..0540dff0 100644 --- a/src/main/java/ninety/megacells/datagen/MEGABlockModelProvider.java +++ b/src/main/java/ninety/megacells/datagen/MEGABlockModelProvider.java @@ -8,20 +8,21 @@ import net.minecraftforge.common.data.ExistingFileHelper; import ninety.megacells.MEGACells; -import ninety.megacells.item.MEGACellType; +import ninety.megacells.item.util.MEGACellType; import ninety.megacells.util.MEGACellsUtil; import appeng.core.AppEng; public class MEGABlockModelProvider extends BlockModelProvider { - private static final ResourceLocation DRIVE_CELL = AppEng.makeId("block/drive/drive_cell"); + protected static final ResourceLocation DRIVE_CELL = AppEng.makeId("block/drive/drive_cell"); public MEGABlockModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) { super(generator, MEGACells.MODID, existingFileHelper); existingFileHelper.trackGenerated(DRIVE_CELL, MODEL); } + @Override protected void registerModels() { for (var cell : Stream.concat(MEGACellType.ITEM.getCells().stream(), MEGACellType.FLUID.getCells().stream()).toList()) { diff --git a/src/main/java/ninety/megacells/datagen/MEGADataGenerators.java b/src/main/java/ninety/megacells/datagen/MEGADataGenerators.java index 58885d23..9cea42fb 100644 --- a/src/main/java/ninety/megacells/datagen/MEGADataGenerators.java +++ b/src/main/java/ninety/megacells/datagen/MEGADataGenerators.java @@ -7,6 +7,10 @@ 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 { @@ -19,5 +23,11 @@ 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 f4adb129..f82b0f70 100644 --- a/src/main/java/ninety/megacells/datagen/MEGAItemModelProvider.java +++ b/src/main/java/ninety/megacells/datagen/MEGAItemModelProvider.java @@ -10,22 +10,24 @@ import net.minecraftforge.common.data.ExistingFileHelper; import ninety.megacells.MEGACells; -import ninety.megacells.item.MEGACellType; import ninety.megacells.item.MEGAItems; +import ninety.megacells.item.util.MEGACellType; import ninety.megacells.util.MEGACellsUtil; import appeng.core.AppEng; public class MEGAItemModelProvider extends ItemModelProvider { - private static final ResourceLocation STORAGE_CELL_LED = AppEng.makeId("item/storage_cell_led"); - private static final ResourceLocation PORTABLE_CELL_LED = AppEng.makeId("item/portable_cell_led"); + static final ResourceLocation STORAGE_CELL_LED = AppEng.makeId("item/storage_cell_led"); + static final ResourceLocation PORTABLE_CELL_LED = AppEng.makeId("item/portable_cell_led"); public MEGAItemModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) { super(generator, MEGACells.MODID, existingFileHelper); existingFileHelper.trackGenerated(STORAGE_CELL_LED, TEXTURE); + existingFileHelper.trackGenerated(PORTABLE_CELL_LED, TEXTURE); } + @Override protected void registerModels() { flatSingleLayer(MEGAItems.MEGA_ITEM_CELL_HOUSING.get()); flatSingleLayer(MEGAItems.MEGA_FLUID_CELL_HOUSING.get()); @@ -47,15 +49,15 @@ protected void registerModels() { } } - private void cell(Item cell) { + protected void cell(Item cell) { flatSingleLayer(cell).texture("layer1", STORAGE_CELL_LED); } - private void portable(Item cell) { + protected void portable(Item cell) { flatSingleLayer(cell).texture("layer1", PORTABLE_CELL_LED); } - private ItemModelBuilder flatSingleLayer(Item item) { + protected ItemModelBuilder flatSingleLayer(Item item) { String path = MEGACellsUtil.getItemPath(item); return singleTexture(path, mcLoc("item/generated"), "layer0", MEGACellsUtil.makeId("item/" + path)); } diff --git a/src/main/java/ninety/megacells/datagen/MEGARecipeProvider.java b/src/main/java/ninety/megacells/datagen/MEGARecipeProvider.java index f6922aed..ff40ac3d 100644 --- a/src/main/java/ninety/megacells/datagen/MEGARecipeProvider.java +++ b/src/main/java/ninety/megacells/datagen/MEGARecipeProvider.java @@ -12,7 +12,11 @@ import net.minecraft.data.recipes.ShapelessRecipeBuilder; import net.minecraft.world.item.Item; -import ninety.megacells.item.*; +import ninety.megacells.item.MEGAItems; +import ninety.megacells.item.MEGAPortableCell; +import ninety.megacells.item.MEGAStorageCell; +import ninety.megacells.item.util.IMEGACellType; +import ninety.megacells.item.util.MEGACellType; import ninety.megacells.util.MEGACellsUtil; import appeng.core.definitions.AEBlocks; @@ -23,6 +27,7 @@ public MEGARecipeProvider(DataGenerator generator) { super(generator); } + @Override protected void buildCraftingRecipes(@NotNull Consumer consumer) { // spotless:off component(consumer, AEItems.CELL_COMPONENT_64K.asItem(), MEGAItems.CELL_COMPONENT_1M.get(), AEItems.SKY_DUST.asItem()); @@ -56,12 +61,12 @@ private void component(Consumer consumer, Item preceding, Item o .save(consumer, MEGACellsUtil.makeId("cells/" + MEGACellsUtil.getItemPath(output))); } - private void cell(Consumer consumer, Item cellItem) { + protected void cell(Consumer consumer, Item cellItem) { var cell = (MEGAStorageCell) cellItem; var component = cell.getTier().getComponent(); - var housing = cell.getType().getHousing(); - var housingMaterial = cell.getType().housingMaterial; + var housing = cell.getType().housing(); + var housingMaterial = cell.getType().housingMaterial(); var componentPath = MEGACellsUtil.getItemPath(component); var cellPath = MEGACellsUtil.getItemPath(cellItem); @@ -84,9 +89,9 @@ private void cell(Consumer consumer, Item cellItem) { .save(consumer, MEGACellsUtil.makeId("cells/standard" + cellPath + "_with_housing")); } - private void portable(Consumer consumer, Item portableCellItem) { + protected void portable(Consumer consumer, Item portableCellItem) { var portableCell = (MEGAPortableCell) portableCellItem; - var housing = portableCell.type.getHousing(); + var housing = portableCell.type.housing(); ShapelessRecipeBuilder.shapeless(portableCell) .requires(AEBlocks.CHEST) .requires(portableCell.tier.getComponent()) @@ -97,15 +102,15 @@ private void portable(Consumer consumer, Item portableCellItem) .save(consumer, MEGACellsUtil.makeId("cells/portable/" + MEGACellsUtil.getItemPath(portableCell))); } - private void housing(Consumer consumer, MEGACellType type) { - var housing = type.getHousing(); - ShapedRecipeBuilder.shaped(type.getHousing()) + protected void housing(Consumer consumer, IMEGACellType type) { + var housing = type.housing(); + ShapedRecipeBuilder.shaped(type.housing()) .pattern("aba") .pattern("b b") .pattern("ddd") .define('a', AEBlocks.QUARTZ_VIBRANT_GLASS) .define('b', AEItems.SKY_DUST) - .define('d', type.housingMaterial) + .define('d', type.housingMaterial()) .unlockedBy("has_dusts/sky_stone", has(AEItems.SKY_DUST)) .save(consumer, MEGACellsUtil.makeId("cells/" + MEGACellsUtil.getItemPath(housing))); } diff --git a/src/main/java/ninety/megacells/init/MEGACellsClient.java b/src/main/java/ninety/megacells/init/MEGACellsClient.java index ea3818f9..bbbb1113 100644 --- a/src/main/java/ninety/megacells/init/MEGACellsClient.java +++ b/src/main/java/ninety/megacells/init/MEGACellsClient.java @@ -5,9 +5,10 @@ import net.minecraftforge.client.event.ColorHandlerEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import ninety.megacells.item.MEGACellType; +import ninety.megacells.integration.appmek.MEGAMekIntegration; import ninety.megacells.item.MEGAPortableCell; import ninety.megacells.item.MEGAStorageCell; +import ninety.megacells.item.util.MEGACellType; public class MEGACellsClient { public static void initialize() { @@ -26,5 +27,6 @@ private static void initItemColors(ColorHandlerEvent.Item event) { MEGACellType.FLUID.getPortableCells().stream()).toList()) { event.getItemColors().register(MEGAPortableCell::getColor, cell); } + MEGAMekIntegration.initItemColors(event); } } diff --git a/src/main/java/ninety/megacells/integration/appmek/ChemicalCellType.java b/src/main/java/ninety/megacells/integration/appmek/ChemicalCellType.java new file mode 100644 index 00000000..1691ec8a --- /dev/null +++ b/src/main/java/ninety/megacells/integration/appmek/ChemicalCellType.java @@ -0,0 +1,68 @@ +package ninety.megacells.integration.appmek; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.ItemTags; +import net.minecraft.tags.TagKey; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.Item; + +import me.ramidzkh.mekae2.AMMenus; +import me.ramidzkh.mekae2.ae2.MekanismKeyType; +import ninety.megacells.item.util.IMEGACellType; + +import appeng.api.stacks.AEKeyType; +import appeng.menu.me.common.MEStorageMenu; + +public enum ChemicalCellType implements IMEGACellType { + TYPE; + + @Override + public AEKeyType keyType() { + return MekanismKeyType.TYPE; + } + + @Override + public String affix() { + return "chemical"; + } + + @Override + public Item housing() { + return MEGAMekItems.MEGA_CHEMICAL_CELL_HOUSING; + } + + @Override + public TagKey housingMaterial() { + return ItemTags.create(new ResourceLocation("forge", "ingots/osmium")); + } + + @Override + public MenuType portableCellMenu() { + return AMMenus.PORTABLE_CHEMICAL_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; + } + + @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; + } +} diff --git a/src/main/java/ninety/megacells/integration/appmek/MEGAMekIntegration.java b/src/main/java/ninety/megacells/integration/appmek/MEGAMekIntegration.java new file mode 100644 index 00000000..94997c94 --- /dev/null +++ b/src/main/java/ninety/megacells/integration/appmek/MEGAMekIntegration.java @@ -0,0 +1,94 @@ +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 new file mode 100644 index 00000000..5e32cec5 --- /dev/null +++ b/src/main/java/ninety/megacells/integration/appmek/MEGAMekItems.java @@ -0,0 +1,24 @@ +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 new file mode 100644 index 00000000..df943425 --- /dev/null +++ b/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekBlockModelProvider.java @@ -0,0 +1,28 @@ +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 new file mode 100644 index 00000000..ba70f1a8 --- /dev/null +++ b/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekItemModelProvider.java @@ -0,0 +1,27 @@ +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 new file mode 100644 index 00000000..2feecfe3 --- /dev/null +++ b/src/main/java/ninety/megacells/integration/appmek/data/MEGAMekRecipeProvider.java @@ -0,0 +1,31 @@ +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 90b70c91..b85b3f76 100644 --- a/src/main/java/ninety/megacells/item/MEGAItems.java +++ b/src/main/java/ninety/megacells/item/MEGAItems.java @@ -11,11 +11,14 @@ import net.minecraftforge.registries.RegistryObject; import ninety.megacells.MEGACells; +import ninety.megacells.item.util.IMEGACellType; +import ninety.megacells.item.util.MEGACellTier; +import ninety.megacells.item.util.MEGACellType; import appeng.items.materials.MaterialItem; import appeng.items.materials.StorageComponentItem; -public class MEGAItems { +public final class MEGAItems { public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MEGACells.MODID); @@ -31,7 +34,7 @@ public static void init(IEventBus bus) { } }; - private static final Item.Properties props = new Item.Properties().tab(CREATIVE_TAB); + public static final Item.Properties props = new Item.Properties().tab(CREATIVE_TAB); 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)); @@ -42,17 +45,17 @@ public static void init(IEventBus bus) { public static final RegistryObject CELL_COMPONENT_64M = component(MEGACellTier._64M); public static final RegistryObject CELL_COMPONENT_256M = component(MEGACellTier._256M); - public static final RegistryObject ITEM_CELL_1M = cell(CELL_COMPONENT_1M, MEGACellTier._1M, MEGACellType.ITEM); - public static final RegistryObject ITEM_CELL_4M = cell(CELL_COMPONENT_4M, MEGACellTier._4M, MEGACellType.ITEM); - public static final RegistryObject ITEM_CELL_16M = cell(CELL_COMPONENT_16M, MEGACellTier._16M, MEGACellType.ITEM); - public static final RegistryObject ITEM_CELL_64M = cell(CELL_COMPONENT_64M, MEGACellTier._64M, MEGACellType.ITEM); - public static final RegistryObject ITEM_CELL_256M = cell(CELL_COMPONENT_256M, MEGACellTier._256M, MEGACellType.ITEM); + public static final RegistryObject ITEM_CELL_1M = cell(MEGACellTier._1M, MEGACellType.ITEM); + public static final RegistryObject ITEM_CELL_4M = cell(MEGACellTier._4M, MEGACellType.ITEM); + public static final RegistryObject ITEM_CELL_16M = cell(MEGACellTier._16M, MEGACellType.ITEM); + public static final RegistryObject ITEM_CELL_64M = cell(MEGACellTier._64M, MEGACellType.ITEM); + public static final RegistryObject ITEM_CELL_256M = cell(MEGACellTier._256M, MEGACellType.ITEM); - public static final RegistryObject FLUID_CELL_1M = cell(CELL_COMPONENT_1M, MEGACellTier._1M, MEGACellType.FLUID); - public static final RegistryObject FLUID_CELL_4M = cell(CELL_COMPONENT_4M, MEGACellTier._4M, MEGACellType.FLUID); - public static final RegistryObject FLUID_CELL_16M = cell(CELL_COMPONENT_16M, MEGACellTier._16M, MEGACellType.FLUID); - public static final RegistryObject FLUID_CELL_64M = cell(CELL_COMPONENT_64M, MEGACellTier._64M, MEGACellType.FLUID); - public static final RegistryObject FLUID_CELL_256M = cell(CELL_COMPONENT_256M, MEGACellTier._256M, MEGACellType.FLUID); + public static final RegistryObject FLUID_CELL_1M = cell(MEGACellTier._1M, MEGACellType.FLUID); + public static final RegistryObject FLUID_CELL_4M = cell(MEGACellTier._4M, MEGACellType.FLUID); + public static final RegistryObject FLUID_CELL_16M = cell(MEGACellTier._16M, MEGACellType.FLUID); + 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 PORTABLE_ITEM_CELL_1M = portable(MEGACellTier._1M, MEGACellType.ITEM); public static final RegistryObject PORTABLE_ITEM_CELL_4M = portable(MEGACellTier._4M, MEGACellType.ITEM); @@ -72,13 +75,13 @@ private static RegistryObject component(MEGACellTier cellTier) { () -> new StorageComponentItem(props, cellTier.kbFactor())); } - private static RegistryObject cell(RegistryObject component, MEGACellTier tier, MEGACellType type) { - return ITEMS.register(type.affix + "_storage_cell_" + tier.affix, - () -> new MEGAStorageCell(props.stacksTo(1), component.get(), tier, type)); + private static RegistryObject cell(MEGACellTier tier, IMEGACellType type) { + return ITEMS.register(type.affix() + "_storage_cell_" + tier.affix, + () -> new MEGAStorageCell(props.stacksTo(1), tier, type)); } - private static RegistryObject portable(MEGACellTier tier, MEGACellType type) { - return ITEMS.register("portable_" + type.affix + "_cell_" + tier.affix, + private static RegistryObject portable(MEGACellTier tier, IMEGACellType type) { + return ITEMS.register("portable_" + type.affix() + "_cell_" + tier.affix, () -> new MEGAPortableCell(props.stacksTo(1), tier, type)); } diff --git a/src/main/java/ninety/megacells/item/MEGAPortableCell.java b/src/main/java/ninety/megacells/item/MEGAPortableCell.java index 8548a91e..ff2c9caa 100644 --- a/src/main/java/ninety/megacells/item/MEGAPortableCell.java +++ b/src/main/java/ninety/megacells/item/MEGAPortableCell.java @@ -5,6 +5,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import ninety.megacells.item.util.IMEGACellType; +import ninety.megacells.item.util.MEGACellTier; import ninety.megacells.util.MEGACellsUtil; import appeng.api.upgrades.IUpgradeInventory; @@ -15,10 +17,10 @@ public class MEGAPortableCell extends PortableCellItem { public final MEGACellTier tier; - public final MEGACellType type; + public final IMEGACellType type; - public MEGAPortableCell(Properties props, MEGACellTier tier, MEGACellType type) { - super(type.key, type.portableMenu, makePortableTier(tier), props); + public MEGAPortableCell(Properties props, MEGACellTier tier, IMEGACellType type) { + super(type.keyType(), type.portableCellMenu(), makePortableTier(tier), props); this.tier = tier; this.type = type; } diff --git a/src/main/java/ninety/megacells/item/MEGAStorageCell.java b/src/main/java/ninety/megacells/item/MEGAStorageCell.java index ec606cc3..c1d8e116 100644 --- a/src/main/java/ninety/megacells/item/MEGAStorageCell.java +++ b/src/main/java/ninety/megacells/item/MEGAStorageCell.java @@ -1,17 +1,19 @@ package ninety.megacells.item; -import net.minecraft.world.level.ItemLike; +import ninety.megacells.item.util.IMEGACellType; +import ninety.megacells.item.util.MEGACellTier; +import ninety.megacells.item.util.MEGACellType; import appeng.items.storage.BasicStorageCell; public class MEGAStorageCell extends BasicStorageCell { private final MEGACellTier tier; - private final MEGACellType type; + private final IMEGACellType type; - public MEGAStorageCell(Properties properties, ItemLike coreItem, MEGACellTier tier, MEGACellType type) { - super(properties, coreItem, type.getHousing(), 2.5f + 0.5f * tier.index, tier.kbFactor(), - tier.kbFactor() * 8, type == MEGACellType.ITEM ? 63 : 5, type.key); + public MEGAStorageCell(Properties properties, MEGACellTier tier, IMEGACellType type) { + super(properties, tier.getComponent(), type.housing(), 2.5f + 0.5f * tier.index, tier.kbFactor(), + tier.kbFactor() * 8, type == MEGACellType.ITEM ? 63 : 5, type.keyType()); this.tier = tier; this.type = type; } @@ -20,7 +22,7 @@ public MEGACellTier getTier() { return this.tier; } - public MEGACellType getType() { + public IMEGACellType getType() { return this.type; } diff --git a/src/main/java/ninety/megacells/item/util/IMEGACellType.java b/src/main/java/ninety/megacells/item/util/IMEGACellType.java new file mode 100644 index 00000000..809c0dd6 --- /dev/null +++ b/src/main/java/ninety/megacells/item/util/IMEGACellType.java @@ -0,0 +1,26 @@ +package ninety.megacells.item.util; + +import java.util.List; + +import net.minecraft.tags.TagKey; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.Item; + +import appeng.api.stacks.AEKeyType; +import appeng.menu.me.common.MEStorageMenu; + +public interface IMEGACellType { + AEKeyType keyType(); + + String affix(); + + Item housing(); + + TagKey housingMaterial(); + + MenuType portableCellMenu(); + + List getCells(); + + List getPortableCells(); +} diff --git a/src/main/java/ninety/megacells/item/MEGACellTier.java b/src/main/java/ninety/megacells/item/util/MEGACellTier.java similarity index 84% rename from src/main/java/ninety/megacells/item/MEGACellTier.java rename to src/main/java/ninety/megacells/item/util/MEGACellTier.java index 61329a7a..51b30670 100644 --- a/src/main/java/ninety/megacells/item/MEGACellTier.java +++ b/src/main/java/ninety/megacells/item/util/MEGACellTier.java @@ -1,7 +1,9 @@ -package ninety.megacells.item; +package ninety.megacells.item.util; import net.minecraft.world.item.Item; +import ninety.megacells.item.MEGAItems; + public enum MEGACellTier { _1M(1, "1m"), _4M(2, "4m"), @@ -9,8 +11,8 @@ public enum MEGACellTier { _64M(4, "64m"), _256M(5, "256m"); - final int index; - final String affix; + public final int index; + public final String affix; MEGACellTier(int index, String affix) { this.index = index; @@ -30,5 +32,4 @@ public Item getComponent() { case _256M -> MEGAItems.CELL_COMPONENT_256M.get(); }; } - } diff --git a/src/main/java/ninety/megacells/item/MEGACellType.java b/src/main/java/ninety/megacells/item/util/MEGACellType.java similarity index 79% rename from src/main/java/ninety/megacells/item/MEGACellType.java rename to src/main/java/ninety/megacells/item/util/MEGACellType.java index 4f3d607e..5479d98b 100644 --- a/src/main/java/ninety/megacells/item/MEGACellType.java +++ b/src/main/java/ninety/megacells/item/util/MEGACellType.java @@ -1,4 +1,4 @@ -package ninety.megacells.item; +package ninety.megacells.item.util; import java.util.List; @@ -6,15 +6,15 @@ import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.Item; +import ninety.megacells.item.MEGAItems; + import appeng.api.stacks.AEKeyType; import appeng.datagen.providers.tags.ConventionTags; import appeng.menu.me.common.MEStorageMenu; -public enum MEGACellType { +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), - // CHEM(MekanismKeyType.TYPE, "chemical", AMItems.CHEMICAL_CELL_HOUSING.get(), AMMenus.PORTABLE_CHEMICAL_CELL_TYPE) - ; + FLUID(AEKeyType.fluids(), "fluid", ConventionTags.COPPER_INGOT, MEStorageMenu.PORTABLE_FLUID_CELL_TYPE); public final AEKeyType key; public final String affix; @@ -28,13 +28,33 @@ public enum MEGACellType { this.portableMenu = portableMenu; } - public Item getHousing() { + @Override + public AEKeyType keyType() { + return this.key; + } + + @Override + public String affix() { + return this.affix; + } + + public Item housing() { return switch (this) { case ITEM -> MEGAItems.MEGA_ITEM_CELL_HOUSING.get(); case FLUID -> MEGAItems.MEGA_FLUID_CELL_HOUSING.get(); }; } + @Override + public TagKey housingMaterial() { + return this.housingMaterial; + } + + @Override + public MenuType portableCellMenu() { + return this.portableMenu; + } + public List getCells() { return switch (this) { case ITEM -> List.of(MEGAItems.ITEM_CELL_1M.get(), MEGAItems.ITEM_CELL_4M.get(), diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index bf37c969..161085f5 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -20,6 +20,13 @@ ME Greater Accumulation Cells - For when kilobytes just won't do. ordering="AFTER" side="BOTH" +[[dependencies.megacells]] + modId="appmek" + mandatory=false + versionRange = "(,2.0.0)" + ordering="AFTER" + side="BOTH" + [[dependencies.megacells]] modId="forge" mandatory=true diff --git a/src/main/resources/assets/megacells/lang/en_us.json b/src/main/resources/assets/megacells/lang/en_us.json index d1119732..0353518a 100644 --- a/src/main/resources/assets/megacells/lang/en_us.json +++ b/src/main/resources/assets/megacells/lang/en_us.json @@ -3,6 +3,7 @@ "item.megacells.mega_item_cell_housing": "MEGA Item Cell Housing", "item.megacells.mega_fluid_cell_housing": "MEGA Fluid Cell Housing", + "item.megacells.mega_chemical_cell_housing": "MEGA Chemical Cell Housing", "item.megacells.cell_component_1m": "1M MEGA Storage Component", "item.megacells.cell_component_4m": "4M MEGA Storage Component", @@ -22,6 +23,12 @@ "item.megacells.fluid_storage_cell_64m": "64M MEGA Fluid Storage Cell", "item.megacells.fluid_storage_cell_256m": "256M MEGA Fluid Storage Cell", + "item.megacells.chemical_storage_cell_1m": "1M MEGA Chemical Storage Cell", + "item.megacells.chemical_storage_cell_4m": "4M MEGA Chemical Storage Cell", + "item.megacells.chemical_storage_cell_16m": "16M MEGA Chemical Storage Cell", + "item.megacells.chemical_storage_cell_64m": "64M MEGA Chemical Storage Cell", + "item.megacells.chemical_storage_cell_256m": "256M MEGA Chemical Storage Cell", + "item.megacells.portable_item_cell_1m": "1M Portable Item Cell", "item.megacells.portable_item_cell_4m": "4M Portable Item Cell", "item.megacells.portable_item_cell_16m": "16M Portable Item Cell", @@ -32,5 +39,11 @@ "item.megacells.portable_fluid_cell_4m": "4M Portable Fluid Cell", "item.megacells.portable_fluid_cell_16m": "16M Portable Fluid Cell", "item.megacells.portable_fluid_cell_64m": "64M Portable Fluid Cell", - "item.megacells.portable_fluid_cell_256m": "256M Portable Fluid Cell" + "item.megacells.portable_fluid_cell_256m": "256M Portable Fluid Cell", + + "item.megacells.portable_chemical_cell_1m": "1M Portable Chemical Cell", + "item.megacells.portable_chemical_cell_4m": "4M Portable Chemical Cell", + "item.megacells.portable_chemical_cell_16m": "16M Portable Chemical Cell", + "item.megacells.portable_chemical_cell_64m": "64M Portable Chemical Cell", + "item.megacells.portable_chemical_cell_256m": "256M Portable Chemical Cell" } diff --git a/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_16m.png b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_16m.png new file mode 100644 index 00000000..e34b50a7 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_16m.png differ diff --git a/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_1m.png b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_1m.png new file mode 100644 index 00000000..03f1211c Binary files /dev/null and b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_1m.png differ diff --git a/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_256m.png b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_256m.png new file mode 100644 index 00000000..39a28f0a Binary files /dev/null and b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_256m.png differ diff --git a/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_4m.png b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_4m.png new file mode 100644 index 00000000..c5e3f481 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_4m.png differ diff --git a/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_64m.png b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_64m.png new file mode 100644 index 00000000..ec42e59b Binary files /dev/null and b/src/main/resources/assets/megacells/textures/block/drive/cells/chemical_storage_cell_64m.png differ diff --git a/src/main/resources/assets/megacells/textures/block/drive/cells/portable_mega_chemical_cell.png b/src/main/resources/assets/megacells/textures/block/drive/cells/portable_mega_chemical_cell.png new file mode 100644 index 00000000..2c3b41f7 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/block/drive/cells/portable_mega_chemical_cell.png differ diff --git a/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_16m.png b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_16m.png new file mode 100644 index 00000000..dba980e5 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_16m.png differ diff --git a/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_1m.png b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_1m.png new file mode 100644 index 00000000..408e8b94 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_1m.png differ diff --git a/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_256m.png b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_256m.png new file mode 100644 index 00000000..673eeb3c Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_256m.png differ diff --git a/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_4m.png b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_4m.png new file mode 100644 index 00000000..a93c1f12 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_4m.png differ diff --git a/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_64m.png b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_64m.png new file mode 100644 index 00000000..f7b0f4a2 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/chemical_storage_cell_64m.png differ diff --git a/src/main/resources/assets/megacells/textures/item/mega_chemical_cell_housing.png b/src/main/resources/assets/megacells/textures/item/mega_chemical_cell_housing.png new file mode 100644 index 00000000..ad30ee13 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/mega_chemical_cell_housing.png differ diff --git a/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_16m.png b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_16m.png new file mode 100644 index 00000000..d3b8fa42 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_16m.png differ diff --git a/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_1m.png b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_1m.png new file mode 100644 index 00000000..ecf50313 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_1m.png differ diff --git a/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_256m.png b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_256m.png new file mode 100644 index 00000000..35759c91 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_256m.png differ diff --git a/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_4m.png b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_4m.png new file mode 100644 index 00000000..90fbf8fd Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_4m.png differ diff --git a/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_64m.png b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_64m.png new file mode 100644 index 00000000..ff84be73 Binary files /dev/null and b/src/main/resources/assets/megacells/textures/item/portable_chemical_cell_64m.png differ