Skip to content

Commit

Permalink
feat: Allow most recipes to be bookmarked in JEI
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jul 4, 2024
1 parent ed00c24 commit 890ea1f
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

public class ChickenStickJeiRecipeCategory implements IRecipeCategory<ExpandedChickenStickRecipe> {

Expand Down Expand Up @@ -61,4 +62,8 @@ public void setRecipe(IRecipeLayoutBuilder recipeLayoutBuilder, ExpandedChickenS
}
}

@Override
public @Nullable ResourceLocation getRegistryName(ExpandedChickenStickRecipe recipe) {
return recipe.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

public class CompressedHammerJeiRecipeCategory implements IRecipeCategory<ExpandedCompressedHammerRecipe> {

Expand Down Expand Up @@ -60,4 +61,8 @@ public void setRecipe(IRecipeLayoutBuilder recipeLayoutBuilder, ExpandedCompress
}
}

@Override
public @Nullable ResourceLocation getRegistryName(ExpandedCompressedHammerRecipe recipe) {
return recipe.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

public class CraftChickenStickJeiRecipeCategory implements IRecipeCategory<CraftChickenStickRecipe> {

Expand Down Expand Up @@ -54,4 +55,8 @@ public void setRecipe(IRecipeLayoutBuilder recipeLayoutBuilder, CraftChickenStic
recipeLayoutBuilder.addSlot(RecipeIngredientRole.OUTPUT, 131, 21).addItemStack(recipe.getOutput());
}

@Override
public @Nullable ResourceLocation getRegistryName(CraftChickenStickRecipe recipe) {
return UID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

public class HammerJeiRecipeCategory implements IRecipeCategory<ExpandedHammerRecipe> {

Expand Down Expand Up @@ -60,4 +61,8 @@ public void setRecipe(IRecipeLayoutBuilder recipeLayoutBuilder, ExpandedHammerRe
}
}

@Override
public @Nullable ResourceLocation getRegistryName(ExpandedHammerRecipe recipe) {
return recipe.getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;


public class HeavySieveJeiRecipeCategory implements IRecipeCategory<ExpandedHeavySieveRecipe> {
Expand Down Expand Up @@ -64,4 +65,9 @@ public void setRecipe(IRecipeLayoutBuilder recipeLayoutBuilder, ExpandedHeavySie
}
}

@Override
public @Nullable ResourceLocation getRegistryName(ExpandedHeavySieveRecipe recipe) {
return recipe.getId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public void registerRecipes(IRecipeRegistration registry) {

final var heavySieveRecipes = recipeManager.getAllRecipesFor(ModRecipeTypes.heavySieveRecipeType);
for (final var recipe : heavySieveRecipes) {
expandedHeavySieveRecipes.add(new ExpandedHeavySieveRecipe(recipe.value()));
expandedHeavySieveRecipes.add(new ExpandedHeavySieveRecipe(recipe.id(), recipe.value()));
}
for (final var recipe : ExNihilo.getInstance().getHeavySieveRecipes()) {
expandedHeavySieveRecipes.add(new ExpandedHeavySieveRecipe(recipe));
expandedHeavySieveRecipes.add(new ExpandedHeavySieveRecipe(null, recipe));
}

final var generatedHeavySieveRecipes = recipeManager.getAllRecipesFor(ModRecipeTypes.generatedHeavySieveRecipeType);
Expand All @@ -61,34 +61,34 @@ public void registerRecipes(IRecipeRegistration registry) {

final var expandedSieveRecipes = new ArrayList<ExpandedSieveRecipe>();
for (final var recipe : ExNihilo.getInstance().getSieveRecipes()) {
expandedSieveRecipes.add(new ExpandedSieveRecipe(recipe));
expandedSieveRecipes.add(new ExpandedSieveRecipe(null, recipe));
}
registry.addRecipes(SieveJeiRecipeCategory.TYPE, expandedSieveRecipes);

List<ExpandedCompressedHammerRecipe> expandedCompressedHammerRecipes = new ArrayList<>();
final var compressedHammerRecipes = recipeManager.getAllRecipesFor(ModRecipeTypes.compressedHammerRecipeType);
for (final var recipe : compressedHammerRecipes) {
expandedCompressedHammerRecipes.add(new ExpandedCompressedHammerRecipe(recipe.value()));
expandedCompressedHammerRecipes.add(new ExpandedCompressedHammerRecipe(recipe.id(), recipe.value()));
}
for (final var recipe : ExNihilo.getInstance().getCompressedHammerRecipes()) {
expandedCompressedHammerRecipes.add(new ExpandedCompressedHammerRecipe(recipe));
expandedCompressedHammerRecipes.add(new ExpandedCompressedHammerRecipe(null, recipe));
}
registry.addRecipes(CompressedHammerJeiRecipeCategory.TYPE, expandedCompressedHammerRecipes);

List<ExpandedHammerRecipe> expandedHammerRecipes = new ArrayList<>();
final var hammerRecipes = recipeManager.getAllRecipesFor(ModRecipeTypes.hammerRecipeType);
for (final var recipe : hammerRecipes) {
expandedHammerRecipes.add(new ExpandedHammerRecipe(recipe.value()));
expandedHammerRecipes.add(new ExpandedHammerRecipe(recipe.id(), recipe.value()));
}
for (final var recipe : ExNihilo.getInstance().getHammerRecipes()) {
expandedHammerRecipes.add(new ExpandedHammerRecipe(recipe));
expandedHammerRecipes.add(new ExpandedHammerRecipe(null, recipe));
}
registry.addRecipes(HammerJeiRecipeCategory.TYPE, expandedHammerRecipes);

List<ExpandedChickenStickRecipe> expandedChickenStickRecipes = new ArrayList<>();
final var chickenStickRecipes = recipeManager.getAllRecipesFor(ModRecipeTypes.chickenStickRecipeType);
for (final var recipe : chickenStickRecipes) {
expandedChickenStickRecipes.add(new ExpandedChickenStickRecipe(recipe.value()));
expandedChickenStickRecipes.add(new ExpandedChickenStickRecipe(recipe.id(), recipe.value()));
}
registry.addRecipes(ChickenStickJeiRecipeCategory.TYPE, expandedChickenStickRecipes);

Expand Down Expand Up @@ -118,7 +118,7 @@ public void registerRecipes(IRecipeRegistration registry) {
final int pageSize = 45;
final var pages = Lists.partition(inputs, pageSize);
for (final var page : pages) {
expandedWoodenCrucibleRecipes.add(new ExpandedWoodenCrucibleRecipe(fluid, page));
expandedWoodenCrucibleRecipes.add(new ExpandedWoodenCrucibleRecipe(null, fluid, page));
}
}

Expand All @@ -138,7 +138,7 @@ private void loadGeneratedHeavySieveRecipe(Level level, boolean waterlogged, Gen
lootTable,
waterlogged,
List.of(mesh.getMeshType()));
outRecipes.add(new ExpandedHeavySieveRecipe(recipe));
outRecipes.add(new ExpandedHeavySieveRecipe(null, recipe));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;


public class SieveJeiRecipeCategory implements IRecipeCategory<ExpandedSieveRecipe> {
Expand Down Expand Up @@ -64,4 +65,9 @@ public void setRecipe(IRecipeLayoutBuilder recipeLayoutBuilder, ExpandedSieveRec
}
}

@Override
public @Nullable ResourceLocation getRegistryName(ExpandedSieveRecipe recipe) {
return recipe.getId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

public class WoodenCrucibleJeiRecipeCategory implements IRecipeCategory<ExpandedWoodenCrucibleRecipe> {

Expand Down Expand Up @@ -62,4 +63,9 @@ public void setRecipe(IRecipeLayoutBuilder recipeLayoutBuilder, ExpandedWoodenCr
}
}

@Override
public @Nullable ResourceLocation getRegistryName(ExpandedWoodenCrucibleRecipe recipe) {
return recipe.getId();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.blay09.mods.excompressum.loot.LootTableUtils;
import net.blay09.mods.excompressum.loot.MergedLootTableEntry;
import net.blay09.mods.excompressum.registry.chickenstick.ChickenStickRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;

Expand All @@ -12,11 +13,13 @@

public class ExpandedChickenStickRecipe {

private final ResourceLocation id;
private final Ingredient ingredient;
private final List<MergedLootTableEntry> outputs;
private final List<ItemStack> outputItems;

public ExpandedChickenStickRecipe(ChickenStickRecipe recipe) {
public ExpandedChickenStickRecipe(ResourceLocation id, ChickenStickRecipe recipe) {
this.id = id;
ingredient = recipe.getIngredient();
List<LootTableEntry> entries = LootTableUtils.getLootTableEntries(recipe.getLootTable());
outputs = LootTableUtils.mergeLootTableEntries(entries);
Expand All @@ -34,4 +37,8 @@ public List<MergedLootTableEntry> getOutputs() {
public List<ItemStack> getOutputItems() {
return outputItems;
}

public ResourceLocation getId() {
return id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.blay09.mods.excompressum.loot.LootTableEntry;
import net.blay09.mods.excompressum.loot.LootTableUtils;
import net.blay09.mods.excompressum.loot.MergedLootTableEntry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;

Expand All @@ -12,11 +13,13 @@

public class ExpandedCompressedHammerRecipe {

private final ResourceLocation id;
private final Ingredient ingredient;
private final List<MergedLootTableEntry> outputs;
private final List<ItemStack> outputItems;

public ExpandedCompressedHammerRecipe(CompressedHammerRecipe recipe) {
public ExpandedCompressedHammerRecipe(ResourceLocation id, CompressedHammerRecipe recipe) {
this.id = id;
ingredient = recipe.getIngredient();
List<LootTableEntry> entries = LootTableUtils.getLootTableEntries(recipe.getLootTable());
outputs = LootTableUtils.mergeLootTableEntries(entries);
Expand All @@ -34,4 +37,8 @@ public List<MergedLootTableEntry> getOutputs() {
public List<ItemStack> getOutputItems() {
return outputItems;
}

public ResourceLocation getId() {
return id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.blay09.mods.excompressum.loot.LootTableEntry;
import net.blay09.mods.excompressum.loot.LootTableUtils;
import net.blay09.mods.excompressum.loot.MergedLootTableEntry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;

Expand All @@ -12,11 +13,13 @@

public class ExpandedHammerRecipe {

private final ResourceLocation id;
private final Ingredient ingredient;
private final List<MergedLootTableEntry> outputs;
private final List<ItemStack> outputItems;

public ExpandedHammerRecipe(HammerRecipe recipe) {
public ExpandedHammerRecipe(ResourceLocation id, HammerRecipe recipe) {
this.id = id;
ingredient = recipe.getIngredient();
List<LootTableEntry> entries = LootTableUtils.getLootTableEntries(recipe.getLootTable());
outputs = LootTableUtils.mergeLootTableEntries(entries);
Expand All @@ -34,4 +37,8 @@ public List<MergedLootTableEntry> getOutputs() {
public List<ItemStack> getOutputItems() {
return outputItems;
}

public ResourceLocation getId() {
return id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.blay09.mods.excompressum.loot.LootTableUtils;
import net.blay09.mods.excompressum.loot.MergedLootTableEntry;
import net.blay09.mods.excompressum.registry.sievemesh.SieveMeshRegistry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;

Expand All @@ -13,14 +14,16 @@

public class ExpandedHeavySieveRecipe {

private final ResourceLocation id;
private final HeavySieveRecipe recipe;
private final Ingredient ingredient;
private final List<ItemStack> meshItems;
private final List<MergedLootTableEntry> outputs;
private final List<ItemStack> outputItems;
private final boolean waterlogged;

public ExpandedHeavySieveRecipe(HeavySieveRecipe recipe) {
public ExpandedHeavySieveRecipe(ResourceLocation id, HeavySieveRecipe recipe) {
this.id = id;
this.recipe = recipe;
meshItems = new ArrayList<>();
for (final var meshType : recipe.getMeshes()) {
Expand Down Expand Up @@ -61,4 +64,8 @@ public List<ItemStack> getOutputItems() {
public boolean isWaterlogged() {
return waterlogged;
}

public ResourceLocation getId() {
return id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.blay09.mods.excompressum.loot.LootTableUtils;
import net.blay09.mods.excompressum.loot.MergedLootTableEntry;
import net.blay09.mods.excompressum.registry.sievemesh.SieveMeshRegistry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;

Expand All @@ -14,14 +15,16 @@

public class ExpandedSieveRecipe {

private final ResourceLocation id;
private final SieveRecipe recipe;
private final Ingredient ingredient;
private final List<ItemStack> meshItems;
private final List<MergedLootTableEntry> outputs;
private final List<ItemStack> outputItems;
private final boolean waterlogged;

public ExpandedSieveRecipe(SieveRecipe recipe) {
public ExpandedSieveRecipe(ResourceLocation id, SieveRecipe recipe) {
this.id = id;
this.recipe = recipe;
meshItems = new ArrayList<>();
for (final var meshType : recipe.getMeshes()) {
Expand Down Expand Up @@ -61,4 +64,8 @@ public List<ItemStack> getOutputItems() {
public boolean isWaterlogged() {
return waterlogged;
}

public ResourceLocation getId() {
return id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.datafixers.util.Pair;
import net.blay09.mods.excompressum.registry.woodencrucible.WoodenCrucibleRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.material.Fluid;

Expand All @@ -10,11 +11,13 @@

public class ExpandedWoodenCrucibleRecipe {

private final ResourceLocation id;
private final Fluid fluid;
private final List<Pair<WoodenCrucibleRecipe, ItemStack>> entries;
private final List<ItemStack> inputs;

public ExpandedWoodenCrucibleRecipe(Fluid fluid, List<Pair<WoodenCrucibleRecipe, ItemStack>> entries) {
public ExpandedWoodenCrucibleRecipe(ResourceLocation id, Fluid fluid, List<Pair<WoodenCrucibleRecipe, ItemStack>> entries) {
this.id = id;
this.fluid = fluid;
this.entries = entries;

Expand All @@ -40,4 +43,8 @@ public WoodenCrucibleRecipe getEntryAt(int index) {
return entries.get(index).getFirst();
}

public ResourceLocation getId() {
return id;
}

}

0 comments on commit 890ea1f

Please sign in to comment.