Skip to content

Commit

Permalink
Use AE2 capacity replace and disassembly recipes
Browse files Browse the repository at this point in the history
Closes #76
Closes #77
  • Loading branch information
ramidzkh committed Dec 8, 2024
1 parent 336b498 commit 81f4faf
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("net.neoforged.moddev") version "1.0.17"
id("net.neoforged.moddev") version "1.0.23"
id("com.matthewprenger.cursegradle") version "1.4.0"
id("com.diffplug.spotless") version "6.25.0"
id("com.modrinth.minotaur") version "2.8.7"
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
minecraft_version=1.21.1
neoforge_version=21.1.22
ae2_version=19.0.22-beta
mekanism_version=10.7.0.55
emi_version=1.1.12+1.21
jade_id=5427817
jei_version=19.9.1.124
jei_ae2_integration_id=5663887
neoforge_version=21.1.84
ae2_version=19.0.24
mekanism_version=10.7.7.64
emi_version=1.1.18+1.21.1
jade_id=5884231
jei_version=19.21.0.247
jei_ae2_integration_id=5748513

# Dev runtime options
## Set to "jei" or "emi" to pick which tooltip mod gets picked at runtime
Expand All @@ -14,7 +14,7 @@ runtime_itemlist_mod=emi

loader_version_range=[1,)
neo_version_range=[21.0,)
ae2_version_range=[19.0.20-beta,20.0.0)
ae2_version_range=[19.0.24,20.0.0)
mekanism_version_range=[10.7.0,11-)

org.gradle.caching=true
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/me/ramidzkh/mekae2/AMItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,15 @@ private static Item.Properties properties() {
AMItems::basic);

public static final DeferredItem<Item> CHEMICAL_CELL_1K = ITEMS.register("chemical_storage_cell_1k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_1K, CHEMICAL_CELL_HOUSING.get()));
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_1K));
public static final DeferredItem<Item> CHEMICAL_CELL_4K = ITEMS.register("chemical_storage_cell_4k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_4K, CHEMICAL_CELL_HOUSING.get()));
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_4K));
public static final DeferredItem<Item> CHEMICAL_CELL_16K = ITEMS.register("chemical_storage_cell_16k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_16K, CHEMICAL_CELL_HOUSING.get()));
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_16K));
public static final DeferredItem<Item> CHEMICAL_CELL_64K = ITEMS.register("chemical_storage_cell_64k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_64K, CHEMICAL_CELL_HOUSING.get()));
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_64K));
public static final DeferredItem<Item> CHEMICAL_CELL_256K = ITEMS.register("chemical_storage_cell_256k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_256K,
CHEMICAL_CELL_HOUSING.get()));
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_256K));

public static final DeferredItem<Item> PORTABLE_CHEMICAL_CELL_1K = ITEMS.register(
"portable_chemical_cell_1k",
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/me/ramidzkh/mekae2/data/RecipeProvider.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.ramidzkh.mekae2.data;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.CompletableFuture;

Expand All @@ -12,13 +14,19 @@
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.registries.DeferredItem;

import me.ramidzkh.mekae2.AMItems;
import me.ramidzkh.mekae2.AppliedMekanistics;

import appeng.core.definitions.AEBlocks;
import appeng.core.definitions.AEItems;
import appeng.recipes.game.StorageCellDisassemblyRecipe;
import appeng.recipes.game.StorageCellUpgradeRecipe;

public class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {

Expand Down Expand Up @@ -66,5 +74,71 @@ protected void buildRecipes(RecipeOutput output) {
.unlockedBy("has_energy_cell", has(AEBlocks.ENERGY_CELL))
.save(output);
}

// Copied from ae2 UpgradeRecipes.java
storageCellUpgradeRecipes(
output,
List.of(
new CellUpgradeTier("1k", AMItems.CHEMICAL_CELL_1K, AEItems.CELL_COMPONENT_1K),
new CellUpgradeTier("4k", AMItems.CHEMICAL_CELL_4K, AEItems.CELL_COMPONENT_4K),
new CellUpgradeTier("16k", AMItems.CHEMICAL_CELL_16K, AEItems.CELL_COMPONENT_16K),
new CellUpgradeTier("64k", AMItems.CHEMICAL_CELL_64K, AEItems.CELL_COMPONENT_64K),
new CellUpgradeTier("256k", AMItems.CHEMICAL_CELL_256K, AEItems.CELL_COMPONENT_256K)),
List.of(AMItems.CHEMICAL_CELL_HOUSING));
storageCellUpgradeRecipes(
output,
List.of(
new CellUpgradeTier("1k", AMItems.PORTABLE_CHEMICAL_CELL_1K, AEItems.CELL_COMPONENT_1K),
new CellUpgradeTier("4k", AMItems.PORTABLE_CHEMICAL_CELL_4K, AEItems.CELL_COMPONENT_4K),
new CellUpgradeTier("16k", AMItems.PORTABLE_CHEMICAL_CELL_16K, AEItems.CELL_COMPONENT_16K),
new CellUpgradeTier("64k", AMItems.PORTABLE_CHEMICAL_CELL_64K, AEItems.CELL_COMPONENT_64K),
new CellUpgradeTier("256k", AMItems.PORTABLE_CHEMICAL_CELL_256K, AEItems.CELL_COMPONENT_256K)),
List.of(AEBlocks.ME_CHEST, AEBlocks.ENERGY_CELL, AMItems.CHEMICAL_CELL_HOUSING));
}

private void storageCellUpgradeRecipes(RecipeOutput output, List<CellUpgradeTier> tiers,
List<ItemLike> additionalDisassemblyItems) {
for (int i = 0; i < tiers.size(); i++) {
var fromTier = tiers.get(i);
var inputCell = fromTier.cell().asItem();
var inputId = fromTier.cell().getId();
var resultComponent = fromTier.component().asItem();

cellDisassembly(output, additionalDisassemblyItems, fromTier);

// Allow a direct upgrade to any higher tier
for (int j = i + 1; j < tiers.size(); j++) {
var toTier = tiers.get(j);
var resultCell = toTier.cell().asItem();
var inputComponent = toTier.component().asItem();

var recipeId = inputId.withPath(path -> "upgrade/" + path + "_to_" + toTier.suffix);

output.accept(
recipeId,
new StorageCellUpgradeRecipe(
inputCell, inputComponent,
resultCell, resultComponent),
null);
}
}
}

private void cellDisassembly(RecipeOutput consumer, List<ItemLike> additionalReturn, CellUpgradeTier tier) {
List<ItemStack> results = new ArrayList<>();
for (var itemLike : additionalReturn) {
results.add(itemLike.asItem().getDefaultInstance());
}
results.add(tier.component.asItem().getDefaultInstance());

consumer.accept(
tier.cell.getId().withPrefix("cell_upgrade/"),
new StorageCellDisassemblyRecipe(
tier.cell.asItem(),
results),
null);
}

record CellUpgradeTier(String suffix, DeferredItem<Item> cell, ItemLike component) {
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.ramidzkh.mekae2.item;

import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;

import me.ramidzkh.mekae2.ae2.MekanismKey;
import me.ramidzkh.mekae2.ae2.MekanismKeyType;
Expand All @@ -13,9 +12,8 @@

public class ChemicalStorageCell extends BasicStorageCell {

public ChemicalStorageCell(Properties properties, StorageTier tier, ItemLike housingItem) {
super(properties, tier.componentSupplier().get(), housingItem, tier.idleDrain(), tier.bytes() / 1024,
tier.bytes() / 128, 5, MekanismKeyType.TYPE);
public ChemicalStorageCell(Properties properties, StorageTier tier) {
super(properties, tier.idleDrain(), tier.bytes() / 1024, tier.bytes() / 128, 5, MekanismKeyType.TYPE);
}

@Override
Expand Down

0 comments on commit 81f4faf

Please sign in to comment.