实现shells的jei配方查看
This commit is contained in:
parent
b6e170cbca
commit
cd6fb8e5eb
2 changed files with 72 additions and 1 deletions
|
@ -0,0 +1,40 @@
|
|||
package com.atsuishio.superbwarfare.compat.jei;
|
||||
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import mezz.jei.api.constants.ModIds;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||
import net.minecraft.world.item.crafting.CraftingBookCategory;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.ShapedRecipe;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PotionMortarShellRecipeMaker {
|
||||
|
||||
public static List<CraftingRecipe> createRecipes() {
|
||||
String group = "jei.potion_mortar_shell";
|
||||
Ingredient ingredient = Ingredient.of(new ItemStack(ModItems.MORTAR_SHELL.get()));
|
||||
|
||||
return ForgeRegistries.POTIONS.getValues().stream()
|
||||
.<CraftingRecipe>map(potion -> {
|
||||
ItemStack input = PotionUtils.setPotion(new ItemStack(Items.LINGERING_POTION), potion);
|
||||
ItemStack output = PotionUtils.setPotion(new ItemStack(ModItems.POTION_MORTAR_SHELL.get(), 4), potion);
|
||||
|
||||
Ingredient potionIngredient = Ingredient.of(input);
|
||||
NonNullList<Ingredient> inputs = NonNullList.of(Ingredient.EMPTY,
|
||||
Ingredient.EMPTY, ingredient, Ingredient.EMPTY,
|
||||
ingredient, potionIngredient, ingredient,
|
||||
Ingredient.EMPTY, ingredient, Ingredient.EMPTY
|
||||
);
|
||||
ResourceLocation id = new ResourceLocation(ModIds.MINECRAFT_ID, group + "." + output.getDescriptionId());
|
||||
return new ShapedRecipe(id, group, CraftingBookCategory.MISC, 3, 3, inputs, output);
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
}
|
|
@ -4,22 +4,53 @@ import com.atsuishio.superbwarfare.ModUtils;
|
|||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.constants.RecipeTypes;
|
||||
import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter;
|
||||
import mezz.jei.api.registration.IRecipeRegistration;
|
||||
import mezz.jei.api.registration.ISubtypeRegistration;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.alchemy.Potion;
|
||||
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@JeiPlugin
|
||||
public class SbwJEIPlugin implements IModPlugin {
|
||||
|
||||
@Override
|
||||
public @NotNull ResourceLocation getPluginUid() {
|
||||
return new ResourceLocation(ModUtils.MODID, "jei_plugin");
|
||||
return ModUtils.loc("jei_plugin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes(@NotNull IRecipeRegistration registration) {
|
||||
registration.addItemStackInfo(new ItemStack(ModItems.ANCIENT_CPU.get()), Component.translatable("jei.superbwarfare.ancient_cpu"));
|
||||
registration.addItemStackInfo(new ItemStack(ModItems.CHARGING_STATION.get()), Component.translatable("jei.superbwarfare.charging_station"));
|
||||
|
||||
List<CraftingRecipe> specialCraftingRecipes = PotionMortarShellRecipeMaker.createRecipes();
|
||||
registration.addRecipes(RecipeTypes.CRAFTING, specialCraftingRecipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemSubtypes(ISubtypeRegistration registration) {
|
||||
registration.registerSubtypeInterpreter(ModItems.POTION_MORTAR_SHELL.get(), (stack, context) -> {
|
||||
if (!stack.hasTag()) {
|
||||
return IIngredientSubtypeInterpreter.NONE;
|
||||
}
|
||||
Potion potionType = PotionUtils.getPotion(stack);
|
||||
String potionTypeString = potionType.getName("");
|
||||
StringBuilder stringBuilder = new StringBuilder(potionTypeString);
|
||||
List<MobEffectInstance> effects = PotionUtils.getMobEffects(stack);
|
||||
for (MobEffectInstance effect : effects) {
|
||||
stringBuilder.append(";").append(effect);
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue