Add JEI compatibility for Compressed Sieve
This commit is contained in:
parent
f2f21f112f
commit
130cd47b5c
|
|
@ -18,61 +18,49 @@
|
|||
|
||||
package thedarkcolour.exdeorum.compat;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import thedarkcolour.exdeorum.material.DefaultMaterials;
|
||||
import thedarkcolour.exdeorum.material.MaterialRegistry;
|
||||
import thedarkcolour.exdeorum.registry.EItems;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CompatHelper {
|
||||
public static List<Item> getAvailableBarrels(boolean registered) {
|
||||
List<Item> barrels = new ArrayList<>();
|
||||
for (var material : DefaultMaterials.BARRELS) {
|
||||
if (registered == ModList.get().isLoaded(material.requiredModId)) {
|
||||
barrels.add(material.getItem());
|
||||
}
|
||||
}
|
||||
return barrels;
|
||||
public static List<ItemLike> getAvailableBarrels(boolean registered) {
|
||||
return getAvailableMaterials(DefaultMaterials.BARRELS, registered);
|
||||
}
|
||||
|
||||
public static List<Item> getAvailableSieves(boolean registered, boolean includeMechanical) {
|
||||
List<Item> sieves = new ArrayList<>();
|
||||
for (var material : DefaultMaterials.SIEVES) {
|
||||
if (registered == ModList.get().isLoaded(material.requiredModId)) {
|
||||
sieves.add(material.getItem());
|
||||
}
|
||||
}
|
||||
public static List<ItemLike> getAvailableSieves(boolean registered, boolean includeMechanical) {
|
||||
List<ItemLike> sieves = getAvailableMaterials(DefaultMaterials.SIEVES, registered);
|
||||
if (includeMechanical) {
|
||||
sieves.add(EItems.MECHANICAL_SIEVE.get());
|
||||
}
|
||||
|
||||
return sieves;
|
||||
}
|
||||
|
||||
public static List<Item> getAvailableLavaCrucibles(boolean registered) {
|
||||
List<Item> lavaCrucibles = new ArrayList<>();
|
||||
|
||||
for (var material : DefaultMaterials.LAVA_CRUCIBLES) {
|
||||
if (registered == ModList.get().isLoaded(material.requiredModId)) {
|
||||
lavaCrucibles.add(material.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
return lavaCrucibles;
|
||||
public static List<ItemLike> getAvailableLavaCrucibles(boolean registered) {
|
||||
return getAvailableMaterials(DefaultMaterials.LAVA_CRUCIBLES, registered);
|
||||
}
|
||||
|
||||
public static List<Item> getAvailableWaterCrucibles(boolean registered) {
|
||||
List<Item> waterCrucibles = new ArrayList<>();
|
||||
public static List<ItemLike> getAvailableWaterCrucibles(boolean registered) {
|
||||
return getAvailableMaterials(DefaultMaterials.WATER_CRUCIBLES, registered);
|
||||
}
|
||||
|
||||
for (var material : DefaultMaterials.WATER_CRUCIBLES) {
|
||||
public static List<ItemLike> getAvailableCompressedSieves(boolean registered) {
|
||||
return getAvailableMaterials(DefaultMaterials.COMPRESSED_SIEVES, registered);
|
||||
}
|
||||
|
||||
private static List<ItemLike> getAvailableMaterials(MaterialRegistry<?> registry, boolean registered) {
|
||||
List<ItemLike> materials = new ArrayList<>();
|
||||
|
||||
for (var material : registry) {
|
||||
if (registered == ModList.get().isLoaded(material.requiredModId)) {
|
||||
waterCrucibles.add(material.getItem());
|
||||
materials.add(material);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return waterCrucibles;
|
||||
return materials;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import java.util.Objects;
|
|||
public record GroupedSieveRecipe(Ingredient ingredient, ItemStack mesh, List<Result> results) {
|
||||
public static int maxSieveRows;
|
||||
|
||||
public static ImmutableList<GroupedSieveRecipe> getAllRecipesGrouped(RecipeType<SieveRecipe> recipeType) {
|
||||
public static ImmutableList<GroupedSieveRecipe> getAllRecipesGrouped(RecipeType<? extends SieveRecipe> recipeType) {
|
||||
maxSieveRows = 1;
|
||||
|
||||
// copy the list so we can do removals
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Ex Deorum
|
||||
* Copyright (c) 2024 thedarkcolour
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package thedarkcolour.exdeorum.compat.jei;
|
||||
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.recipe.RecipeType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import thedarkcolour.exdeorum.compat.GroupedSieveRecipe;
|
||||
import thedarkcolour.exdeorum.data.TranslationKeys;
|
||||
import thedarkcolour.exdeorum.material.DefaultMaterials;
|
||||
|
||||
class CompressedSieveCategory extends SieveCategory {
|
||||
CompressedSieveCategory(IGuiHelper helper) {
|
||||
super(helper, DefaultMaterials.OAK_COMPRESSED_SIEVE, Component.translatable(TranslationKeys.COMPRESSED_SIEVE_CATEGORY_TITLE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType<GroupedSieveRecipe> getRecipeType() {
|
||||
return ExDeorumJeiPlugin.COMPRESSED_SIEVE;
|
||||
}
|
||||
}
|
||||
|
|
@ -78,6 +78,7 @@ public class ExDeorumJeiPlugin implements IModPlugin {
|
|||
static final RecipeType<CrucibleRecipe> WATER_CRUCIBLE = RecipeType.create(ExDeorum.ID, "water_crucible", CrucibleRecipe.class);
|
||||
static final RecipeType<CrucibleHeatSourceRecipe> CRUCIBLE_HEAT_SOURCES = RecipeType.create(ExDeorum.ID, "crucible_heat_sources", CrucibleHeatSourceRecipe.class);
|
||||
static final RecipeType<GroupedSieveRecipe> SIEVE = RecipeType.create(ExDeorum.ID, "sieve", GroupedSieveRecipe.class);
|
||||
static final RecipeType<GroupedSieveRecipe> COMPRESSED_SIEVE = RecipeType.create(ExDeorum.ID, "compressed_sieve", GroupedSieveRecipe.class);
|
||||
static final RecipeType<HammerRecipe> HAMMER = RecipeType.create(ExDeorum.ID, "hammer", HammerRecipe.class);
|
||||
static final RecipeType<CrookJeiRecipe> CROOK = RecipeType.create(ExDeorum.ID, "crook", CrookJeiRecipe.class);
|
||||
|
||||
|
|
@ -99,34 +100,33 @@ public class ExDeorumJeiPlugin implements IModPlugin {
|
|||
registration.addRecipeCategories(new CrucibleCategory.WaterCrucible(helper, arrow));
|
||||
registration.addRecipeCategories(new CrucibleHeatSourcesCategory(registration.getJeiHelpers()));
|
||||
registration.addRecipeCategories(new SieveCategory(helper));
|
||||
registration.addRecipeCategories(new CompressedSieveCategory(helper));
|
||||
registration.addRecipeCategories(new HammerCategory(helper, arrow));
|
||||
registration.addRecipeCategories(new CrookCategory(registration.getJeiHelpers(), arrow));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
||||
var barrels = CompatHelper.getAvailableBarrels(true);
|
||||
var sieves = CompatHelper.getAvailableSieves(true, true);
|
||||
var lavaCrucibles = CompatHelper.getAvailableLavaCrucibles(true);
|
||||
var waterCrucibles = CompatHelper.getAvailableWaterCrucibles(true);
|
||||
|
||||
for (var barrel : barrels) {
|
||||
for (var barrel : CompatHelper.getAvailableBarrels(true)) {
|
||||
var stack = new ItemStack(barrel);
|
||||
registration.addRecipeCatalyst(stack, BARREL_COMPOST);
|
||||
registration.addRecipeCatalyst(stack, BARREL_MIXING);
|
||||
registration.addRecipeCatalyst(stack, BARREL_FLUID_MIXING);
|
||||
}
|
||||
for (var lavaCrucible : lavaCrucibles) {
|
||||
for (var lavaCrucible : CompatHelper.getAvailableLavaCrucibles(true)) {
|
||||
var stack = new ItemStack(lavaCrucible);
|
||||
registration.addRecipeCatalyst(stack, LAVA_CRUCIBLE);
|
||||
registration.addRecipeCatalyst(stack, CRUCIBLE_HEAT_SOURCES);
|
||||
}
|
||||
for (var waterCrucible : waterCrucibles) {
|
||||
for (var waterCrucible : CompatHelper.getAvailableWaterCrucibles(true)) {
|
||||
registration.addRecipeCatalyst(new ItemStack(waterCrucible), WATER_CRUCIBLE);
|
||||
}
|
||||
for (var sieve : sieves) {
|
||||
for (var sieve : CompatHelper.getAvailableSieves(true, true)) {
|
||||
registration.addRecipeCatalyst(new ItemStack(sieve), SIEVE);
|
||||
}
|
||||
for (var compressedSieve : CompatHelper.getAvailableCompressedSieves(true)) {
|
||||
registration.addRecipeCatalyst(new ItemStack(compressedSieve), COMPRESSED_SIEVE);
|
||||
}
|
||||
|
||||
registration.addRecipeCatalyst(new ItemStack(EItems.WOODEN_HAMMER.get()), HAMMER);
|
||||
registration.addRecipeCatalyst(new ItemStack(EItems.STONE_HAMMER.get()), HAMMER);
|
||||
|
|
@ -159,13 +159,11 @@ public class ExDeorumJeiPlugin implements IModPlugin {
|
|||
|
||||
var toRemove = new ArrayList<ItemStack>();
|
||||
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_ALUMINUM))
|
||||
toRemove.add(new ItemStack(EItems.ALUMINUM_ORE_CHUNK.get()));
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_ALUMINUM)) toRemove.add(new ItemStack(EItems.ALUMINUM_ORE_CHUNK.get()));
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_COBALT)) toRemove.add(new ItemStack(EItems.COBALT_ORE_CHUNK.get()));
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_SILVER)) toRemove.add(new ItemStack(EItems.SILVER_ORE_CHUNK.get()));
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_LEAD)) toRemove.add(new ItemStack(EItems.LEAD_ORE_CHUNK.get()));
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_PLATINUM))
|
||||
toRemove.add(new ItemStack(EItems.PLATINUM_ORE_CHUNK.get()));
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_PLATINUM)) toRemove.add(new ItemStack(EItems.PLATINUM_ORE_CHUNK.get()));
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_NICKEL)) toRemove.add(new ItemStack(EItems.NICKEL_ORE_CHUNK.get()));
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_URANIUM)) toRemove.add(new ItemStack(EItems.URANIUM_ORE_CHUNK.get()));
|
||||
if (RecipeUtil.isTagEmpty(EItemTags.ORES_OSMIUM)) toRemove.add(new ItemStack(EItems.OSMIUM_ORE_CHUNK.get()));
|
||||
|
|
@ -193,6 +191,7 @@ public class ExDeorumJeiPlugin implements IModPlugin {
|
|||
}
|
||||
registration.addRecipes(CROOK, crookRecipes);
|
||||
registration.addRecipes(SIEVE, GroupedSieveRecipe.getAllRecipesGrouped(ERecipeTypes.SIEVE.get()));
|
||||
registration.addRecipes(COMPRESSED_SIEVE, GroupedSieveRecipe.getAllRecipesGrouped(ERecipeTypes.COMPRESSED_SIEVE.get()));
|
||||
|
||||
addCrucibleHeatSources(registration);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import net.minecraft.ChatFormatting;
|
|||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.storage.loot.providers.number.BinomialDistributionGenerator;
|
||||
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
||||
import net.minecraft.world.level.storage.loot.providers.number.NumberProvider;
|
||||
|
|
@ -61,12 +62,16 @@ class SieveCategory implements IRecipeCategory<GroupedSieveRecipe> {
|
|||
private final IDrawable icon;
|
||||
private final Component title;
|
||||
|
||||
public SieveCategory(IGuiHelper helper) {
|
||||
SieveCategory(IGuiHelper helper, ItemLike icon, Component title) {
|
||||
this.background = Lazy.of(() -> helper.createBlankDrawable(WIDTH, ROW_START + 18 * GroupedSieveRecipe.maxSieveRows));
|
||||
this.slot = helper.getSlotDrawable();
|
||||
this.row = helper.createDrawable(ExDeorumJeiPlugin.EX_DEORUM_JEI_TEXTURE, 0, 0, 162, 18);
|
||||
this.icon = helper.createDrawableItemStack(new ItemStack(DefaultMaterials.OAK_SIEVE.getItem()));
|
||||
this.title = Component.translatable(TranslationKeys.SIEVE_CATEGORY_TITLE);
|
||||
this.icon = helper.createDrawableItemStack(new ItemStack(icon));
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
SieveCategory(IGuiHelper helper) {
|
||||
this(helper, DefaultMaterials.OAK_SIEVE, Component.translatable(TranslationKeys.SIEVE_CATEGORY_TITLE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ public class ExDeorumReiPlugin implements REIClientPlugin {
|
|||
for (var crucible : CompatHelper.getAvailableWaterCrucibles(false)) {
|
||||
builder.add(EntryStack.of(VanillaEntryTypes.ITEM, new ItemStack(crucible)));
|
||||
}
|
||||
for (var compressedSieve : CompatHelper.getAvailableCompressedSieves(false)) {
|
||||
builder.add(EntryStack.of(VanillaEntryTypes.ITEM, new ItemStack(compressedSieve)));
|
||||
}
|
||||
return builder.build();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package thedarkcolour.exdeorum.data;
|
|||
import thedarkcolour.exdeorum.ExDeorum;
|
||||
import thedarkcolour.exdeorum.client.screen.RedstoneControlWidget;
|
||||
import thedarkcolour.exdeorum.material.DefaultMaterials;
|
||||
import thedarkcolour.exdeorum.registry.EBlocks;
|
||||
import thedarkcolour.modkit.data.MKEnglishProvider;
|
||||
|
||||
class English {
|
||||
|
|
@ -74,6 +73,7 @@ class English {
|
|||
english.add(TranslationKeys.CROOK_CATEGORY_TITLE, "Crook");
|
||||
english.add(TranslationKeys.CROOK_CATEGORY_REQUIRES_STATE, "Requires properties:");
|
||||
english.add(TranslationKeys.SIEVE_CATEGORY_TITLE, "Sieve");
|
||||
english.add(TranslationKeys.COMPRESSED_SIEVE_CATEGORY_TITLE, "Compressed Sieve");
|
||||
english.add(TranslationKeys.SIEVE_RECIPE_CHANCE, "Chance: %s%%");
|
||||
english.add(TranslationKeys.SIEVE_RECIPE_AVERAGE_OUTPUT, "Avg. Output: %s");
|
||||
english.add(TranslationKeys.SIEVE_RECIPE_MIN_OUTPUT, "Min: %s");
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ public class TranslationKeys {
|
|||
public static final String CROOK_CATEGORY_TITLE = "gui." + ExDeorum.ID + ".category.crook";
|
||||
public static final String CROOK_CATEGORY_REQUIRES_STATE = "gui." + ExDeorum.ID + ".category.crook.requires_state";
|
||||
public static final String SIEVE_CATEGORY_TITLE = "gui." + ExDeorum.ID + ".category.sieve";
|
||||
public static final String COMPRESSED_SIEVE_CATEGORY_TITLE = "gui." + ExDeorum.ID + ".category.sieve";
|
||||
public static final String SIEVE_RECIPE_CHANCE = "gui." + ExDeorum.ID + ".category.sieve.chance";
|
||||
public static final String SIEVE_RECIPE_AVERAGE_OUTPUT = "gui." + ExDeorum.ID + ".category.sieve.average_output";
|
||||
public static final String SIEVE_RECIPE_MIN_OUTPUT = "gui." + ExDeorum.ID + ".category.sieve.min_output";
|
||||
|
|
|
|||
|
|
@ -20,12 +20,13 @@ package thedarkcolour.exdeorum.material;
|
|||
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public abstract class AbstractMaterial {
|
||||
public abstract class AbstractMaterial implements ItemLike {
|
||||
// The sound this block makes (a string corresponding to a field in SoundType or a JSON object with the five sound events used to create a sound type)
|
||||
public final SoundType soundType;
|
||||
// The hardness of the barrel when harvesting
|
||||
|
|
@ -63,4 +64,9 @@ public abstract class AbstractMaterial {
|
|||
public Block getBlock() {
|
||||
return this.block.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item asItem() {
|
||||
return this.item.get();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user