Skip to content

Commit

Permalink
Begin AppMek integration (MEGA Chemical Cells)
Browse files Browse the repository at this point in the history
This WILL look like shit for the time being.
  • Loading branch information
62832 committed May 13, 2022
1 parent 2e8ef7e commit 956f503
Show file tree
Hide file tree
Showing 38 changed files with 442 additions and 60 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/ninety/megacells/MEGACells.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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)));
}
Expand All @@ -52,6 +66,7 @@ private void initCellModels() {
StorageCellModels.registerModel(portableFluidCell,
MEGACellsUtil.makeId("block/drive/cells/portable_mega_fluid_cell"));
}
MEGAMekIntegration.initCellModels();
}

private void initUpgrades() {
Expand All @@ -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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/ninety/megacells/datagen/MEGADataGenerators.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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));
}
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/ninety/megacells/datagen/MEGARecipeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,6 +27,7 @@ public MEGARecipeProvider(DataGenerator generator) {
super(generator);
}

@Override
protected void buildCraftingRecipes(@NotNull Consumer<FinishedRecipe> consumer) {
// spotless:off
component(consumer, AEItems.CELL_COMPONENT_64K.asItem(), MEGAItems.CELL_COMPONENT_1M.get(), AEItems.SKY_DUST.asItem());
Expand Down Expand Up @@ -56,12 +61,12 @@ private void component(Consumer<FinishedRecipe> consumer, Item preceding, Item o
.save(consumer, MEGACellsUtil.makeId("cells/" + MEGACellsUtil.getItemPath(output)));
}

private void cell(Consumer<FinishedRecipe> consumer, Item cellItem) {
protected void cell(Consumer<FinishedRecipe> 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);
Expand All @@ -84,9 +89,9 @@ private void cell(Consumer<FinishedRecipe> consumer, Item cellItem) {
.save(consumer, MEGACellsUtil.makeId("cells/standard" + cellPath + "_with_housing"));
}

private void portable(Consumer<FinishedRecipe> consumer, Item portableCellItem) {
protected void portable(Consumer<FinishedRecipe> 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())
Expand All @@ -97,15 +102,15 @@ private void portable(Consumer<FinishedRecipe> consumer, Item portableCellItem)
.save(consumer, MEGACellsUtil.makeId("cells/portable/" + MEGACellsUtil.getItemPath(portableCell)));
}

private void housing(Consumer<FinishedRecipe> consumer, MEGACellType type) {
var housing = type.getHousing();
ShapedRecipeBuilder.shaped(type.getHousing())
protected void housing(Consumer<FinishedRecipe> 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)));
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/ninety/megacells/init/MEGACellsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<Item> housingMaterial() {
return ItemTags.create(new ResourceLocation("forge", "ingots/osmium"));
}

@Override
public MenuType<MEStorageMenu> portableCellMenu() {
return AMMenus.PORTABLE_CHEMICAL_CELL_TYPE;
}

@Override
public List<Item> getCells() {
var cells = new ArrayList<Item>();
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<Item> getPortableCells() {
var cells = new ArrayList<Item>();
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;
}
}
Loading

0 comments on commit 956f503

Please sign in to comment.