-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11cb0d7
commit 6bd2a3a
Showing
6 changed files
with
262 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
forge/src/main/java/net/blay09/mods/excompressum/forge/compat/jei/ExpandedSieveRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package net.blay09.mods.excompressum.forge.compat.jei; | ||
|
||
import net.blay09.mods.excompressum.api.recipe.HeavySieveRecipe; | ||
import net.blay09.mods.excompressum.api.recipe.SieveRecipe; | ||
import net.blay09.mods.excompressum.api.sievemesh.CommonMeshType; | ||
import net.blay09.mods.excompressum.api.sievemesh.SieveMeshRegistryEntry; | ||
import net.blay09.mods.excompressum.loot.LootTableEntry; | ||
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.world.item.ItemStack; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class ExpandedSieveRecipe { | ||
|
||
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) { | ||
this.recipe = recipe; | ||
meshItems = new ArrayList<>(); | ||
if (recipe.getMinimumMesh() != null) { | ||
SieveMeshRegistryEntry minimumMesh = SieveMeshRegistry.getEntry(recipe.getMinimumMesh()); | ||
for (SieveMeshRegistryEntry mesh : SieveMeshRegistry.getEntries().values()) { | ||
if (mesh.getMeshLevel() >= minimumMesh.getMeshLevel()) { | ||
meshItems.add(mesh.getItemStack()); | ||
} | ||
} | ||
} else if (recipe.getMeshes() != null) { | ||
for (CommonMeshType meshType : recipe.getMeshes()) { | ||
for (SieveMeshRegistryEntry mesh : SieveMeshRegistry.getEntries().values()) { | ||
if (mesh.getMeshType() == meshType) { | ||
meshItems.add(mesh.getItemStack()); | ||
} | ||
} | ||
} | ||
} | ||
ingredient = recipe.getIngredient(); | ||
List<LootTableEntry> entries = LootTableUtils.getLootTableEntries(recipe.getLootTable()); | ||
outputs = LootTableUtils.mergeLootTableEntries(entries); | ||
outputItems = outputs.stream().map(MergedLootTableEntry::getItemStack).collect(Collectors.toList()); | ||
waterlogged = recipe.isWaterlogged(); | ||
} | ||
|
||
public SieveRecipe getRecipe() { | ||
return recipe; | ||
} | ||
|
||
public Ingredient getIngredient() { | ||
return ingredient; | ||
} | ||
|
||
public List<ItemStack> getMeshItems() { | ||
return meshItems; | ||
} | ||
|
||
public List<MergedLootTableEntry> getOutputs() { | ||
return outputs; | ||
} | ||
|
||
public List<ItemStack> getOutputItems() { | ||
return outputItems; | ||
} | ||
|
||
public boolean isWaterlogged() { | ||
return waterlogged; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...e/src/main/java/net/blay09/mods/excompressum/forge/compat/jei/SieveJeiRecipeCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package net.blay09.mods.excompressum.forge.compat.jei; | ||
|
||
import mezz.jei.api.constants.VanillaTypes; | ||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; | ||
import mezz.jei.api.gui.drawable.IDrawable; | ||
import mezz.jei.api.helpers.IGuiHelper; | ||
import mezz.jei.api.helpers.IJeiHelpers; | ||
import mezz.jei.api.recipe.IFocusGroup; | ||
import mezz.jei.api.recipe.RecipeIngredientRole; | ||
import mezz.jei.api.recipe.RecipeType; | ||
import mezz.jei.api.recipe.category.IRecipeCategory; | ||
import net.blay09.mods.excompressum.ExCompressum; | ||
import net.blay09.mods.excompressum.block.ModBlocks; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class SieveJeiRecipeCategory implements IRecipeCategory<ExpandedSieveRecipe> { | ||
|
||
public static final ResourceLocation UID = new ResourceLocation(ExCompressum.MOD_ID, "sieve"); | ||
public static final RecipeType<ExpandedSieveRecipe> TYPE = new RecipeType<>(UID, ExpandedSieveRecipe.class); | ||
private static final ResourceLocation texture = new ResourceLocation(ExCompressum.MOD_ID, "textures/gui/jei_heavy_sieve.png"); | ||
|
||
private final IDrawable background; | ||
private final IDrawable icon; | ||
|
||
public SieveJeiRecipeCategory(IJeiHelpers jeiHelpers) { | ||
final IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); | ||
this.background = guiHelper.createDrawable(texture, 0, 0, 166, 129); | ||
this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(ModBlocks.autoSieve)); | ||
} | ||
|
||
@Override | ||
public RecipeType<ExpandedSieveRecipe> getRecipeType() { | ||
return TYPE; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Component getTitle() { | ||
return Component.translatable(UID.toString()); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public IDrawable getBackground() { | ||
return background; | ||
} | ||
|
||
@Override | ||
public IDrawable getIcon() { | ||
return icon; | ||
} | ||
|
||
@Override | ||
public void setRecipe(IRecipeLayoutBuilder recipeLayoutBuilder, ExpandedSieveRecipe recipe, IFocusGroup focusGroup) { | ||
recipeLayoutBuilder.addSlot(RecipeIngredientRole.INPUT, 62, 10).addIngredients(recipe.getIngredient()); | ||
recipeLayoutBuilder.addSlot(RecipeIngredientRole.INPUT, 88, 10).addItemStacks(recipe.getMeshItems()); | ||
final var outputItems = recipe.getOutputItems(); | ||
for (int i = 0; i < outputItems.size(); i++) { | ||
final int slotX = 3 + (i % 9 * 18); | ||
final int slotY = 37 + (i / 9 * 18); | ||
recipeLayoutBuilder.addSlot(RecipeIngredientRole.OUTPUT, slotX, slotY).addItemStack(outputItems.get(i)); | ||
} | ||
} | ||
|
||
} |
81 changes: 81 additions & 0 deletions
81
shared/src/main/java/net/blay09/mods/excompressum/registry/sieve/SieveRecipeImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package net.blay09.mods.excompressum.registry.sieve; | ||
|
||
import net.blay09.mods.excompressum.api.recipe.HeavySieveRecipe; | ||
import net.blay09.mods.excompressum.api.recipe.SieveRecipe; | ||
import net.blay09.mods.excompressum.api.sievemesh.CommonMeshType; | ||
import net.blay09.mods.excompressum.registry.ExCompressumRecipe; | ||
import net.blay09.mods.excompressum.registry.ModRecipeTypes; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
import net.minecraft.world.item.crafting.RecipeSerializer; | ||
import net.minecraft.world.level.storage.loot.LootTable; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Set; | ||
|
||
public class SieveRecipeImpl extends ExCompressumRecipe implements SieveRecipe { | ||
|
||
private Ingredient ingredient; | ||
private LootTable lootTable; | ||
private boolean waterlogged; | ||
private CommonMeshType minimumMesh; | ||
private Set<CommonMeshType> meshes; | ||
|
||
public SieveRecipeImpl(ResourceLocation id, Ingredient ingredient, LootTable lootTable, boolean waterlogged, @Nullable CommonMeshType minimumMesh, @Nullable Set<CommonMeshType> meshes) { | ||
super(id, ModRecipeTypes.heavySieveRecipeType); | ||
this.ingredient = ingredient; | ||
this.lootTable = lootTable; | ||
this.waterlogged = waterlogged; | ||
this.minimumMesh = minimumMesh; | ||
this.meshes = meshes; | ||
} | ||
|
||
@Override | ||
public RecipeSerializer<?> getSerializer() { | ||
return ModRecipeTypes.heavySieveRecipeSerializer; | ||
} | ||
|
||
@Override | ||
public Ingredient getIngredient() { | ||
return ingredient; | ||
} | ||
|
||
@Override | ||
public LootTable getLootTable() { | ||
return lootTable; | ||
} | ||
|
||
public boolean isWaterlogged() { | ||
return waterlogged; | ||
} | ||
|
||
@Nullable | ||
public CommonMeshType getMinimumMesh() { | ||
return minimumMesh; | ||
} | ||
|
||
@Nullable | ||
public Set<CommonMeshType> getMeshes() { | ||
return meshes; | ||
} | ||
|
||
public void setIngredient(Ingredient ingredient) { | ||
this.ingredient = ingredient; | ||
} | ||
|
||
public void setLootTable(LootTable lootTable) { | ||
this.lootTable = lootTable; | ||
} | ||
|
||
public void setWaterlogged(boolean waterlogged) { | ||
this.waterlogged = waterlogged; | ||
} | ||
|
||
public void setMinimumMesh(@Nullable CommonMeshType minimumMesh) { | ||
this.minimumMesh = minimumMesh; | ||
} | ||
|
||
public void setMeshes(@Nullable Set<CommonMeshType> meshes) { | ||
this.meshes = meshes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters