mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
re-added JEI compat
This commit is contained in:
parent
5db697abb1
commit
5b7df8bd45
7 changed files with 121 additions and 133 deletions
|
@ -24,7 +24,7 @@ if (System.getenv('BUILD_NUMBER') != null) {
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'official', version: '1.18'
|
mappings channel: 'official', version: '1.18.1'
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
|
@ -102,11 +102,10 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'net.minecraftforge:forge:1.18-38.0.14'
|
minecraft 'net.minecraftforge:forge:1.18.1-39.0.5'
|
||||||
|
|
||||||
// TODO JEI
|
compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47:api")
|
||||||
/* compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.6.1.75:api")
|
runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.47")
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.6.1.75")*/
|
|
||||||
|
|
||||||
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61:api")
|
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61:api")
|
||||||
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61")
|
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61")
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/*
|
|
||||||
package de.ellpeck.naturesaura.compat.jei;
|
package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -8,14 +7,14 @@ import de.ellpeck.naturesaura.recipes.AltarRecipe;
|
||||||
import mezz.jei.api.constants.VanillaTypes;
|
import mezz.jei.api.constants.VanillaTypes;
|
||||||
import mezz.jei.api.gui.IRecipeLayout;
|
import mezz.jei.api.gui.IRecipeLayout;
|
||||||
import mezz.jei.api.gui.drawable.IDrawable;
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
|
||||||
import mezz.jei.api.helpers.IGuiHelper;
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -40,8 +39,8 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public Component getTitle() {
|
||||||
return I18n.format("container." + JEINaturesAuraPlugin.ALTAR + ".name");
|
return new TranslatableComponent("container." + JEINaturesAuraPlugin.ALTAR + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,9 +56,9 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
|
||||||
@Override
|
@Override
|
||||||
public void setIngredients(AltarRecipe altarRecipe, IIngredients iIngredients) {
|
public void setIngredients(AltarRecipe altarRecipe, IIngredients iIngredients) {
|
||||||
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
||||||
builder.add(altarRecipe.input.getMatchingStacks());
|
builder.add(altarRecipe.input.getItems());
|
||||||
if (altarRecipe.catalyst != Ingredient.EMPTY)
|
if (altarRecipe.catalyst != Ingredient.EMPTY)
|
||||||
builder.add(altarRecipe.catalyst.getMatchingStacks());
|
builder.add(altarRecipe.catalyst.getItems());
|
||||||
if (altarRecipe.requiredType != null)
|
if (altarRecipe.requiredType != null)
|
||||||
builder.add(altarRecipe.getDimensionBottle());
|
builder.add(altarRecipe.getDimensionBottle());
|
||||||
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
|
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
|
||||||
|
@ -68,17 +67,16 @@ public class AltarCategory implements IRecipeCategory<AltarRecipe> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(IRecipeLayout iRecipeLayout, AltarRecipe recipe, IIngredients iIngredients) {
|
public void setRecipe(IRecipeLayout iRecipeLayout, AltarRecipe recipe, IIngredients iIngredients) {
|
||||||
IGuiItemStackGroup group = iRecipeLayout.getItemStacks();
|
var group = iRecipeLayout.getItemStacks();
|
||||||
group.init(0, true, 0, 18);
|
group.init(0, true, 0, 18);
|
||||||
group.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
|
group.set(0, Arrays.asList(recipe.input.getItems()));
|
||||||
group.init(1, false, 80, 18);
|
group.init(1, false, 80, 18);
|
||||||
group.set(1, recipe.output);
|
group.set(1, recipe.output);
|
||||||
group.init(2, true, 26, 18);
|
group.init(2, true, 26, 18);
|
||||||
group.set(2, recipe.catalyst == Ingredient.EMPTY ?
|
group.set(2, recipe.catalyst == Ingredient.EMPTY ?
|
||||||
Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getMatchingStacks()));
|
Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getItems()));
|
||||||
group.init(3, true, 51, 18);
|
group.init(3, true, 51, 18);
|
||||||
if (recipe.requiredType != null)
|
if (recipe.requiredType != null)
|
||||||
group.set(3, recipe.getDimensionBottle());
|
group.set(3, recipe.getDimensionBottle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -1,32 +1,28 @@
|
||||||
/*
|
|
||||||
package de.ellpeck.naturesaura.compat.jei;
|
package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.platform.Lighting;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.math.Vector3f;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
|
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
|
||||||
import mezz.jei.api.constants.VanillaTypes;
|
import mezz.jei.api.constants.VanillaTypes;
|
||||||
import mezz.jei.api.gui.IRecipeLayout;
|
import mezz.jei.api.gui.IRecipeLayout;
|
||||||
import mezz.jei.api.gui.drawable.IDrawable;
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
|
||||||
import mezz.jei.api.helpers.IGuiHelper;
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.item.SpawnEggItem;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.vector.Quaternion;
|
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -35,48 +31,53 @@ import java.util.Map;
|
||||||
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecipe> {
|
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecipe> {
|
||||||
|
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
private final Map<EntityType, Entity> entityCache = new HashMap<>();
|
private final Map<EntityType<?>, Entity> entityCache = new HashMap<>();
|
||||||
|
|
||||||
public AnimalSpawnerCategory(IGuiHelper helper) {
|
public AnimalSpawnerCategory(IGuiHelper helper) {
|
||||||
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/animal_spawner.png"), 0, 0, 72, 86);
|
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/animal_spawner.png"), 0, 0, 72, 86);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderEntity(MatrixStack matrixstack, int x, int y, float scale, float yaw, float pitch, LivingEntity entity) {
|
private static void renderEntity(PoseStack matrixstack, int x, int y, float scale, float yaw, float pitch, LivingEntity entity) {
|
||||||
float f = (float) Math.atan(yaw / 40.0F);
|
var f = (float) Math.atan(yaw / 40.0F);
|
||||||
float f1 = (float) Math.atan(pitch / 40.0F);
|
var f1 = (float) Math.atan(pitch / 40.0F);
|
||||||
RenderSystem.pushMatrix();
|
var posestack = RenderSystem.getModelViewStack();
|
||||||
RenderSystem.translatef((float) x, (float) y, 1050.0F);
|
posestack.pushPose();
|
||||||
RenderSystem.scalef(1.0F, 1.0F, -1.0F);
|
posestack.translate(x, y, 1050.0D);
|
||||||
|
posestack.scale(1.0F, 1.0F, -1.0F);
|
||||||
|
RenderSystem.applyModelViewMatrix();
|
||||||
matrixstack.translate(0.0D, 0.0D, 1000.0D);
|
matrixstack.translate(0.0D, 0.0D, 1000.0D);
|
||||||
matrixstack.scale(scale, scale, scale);
|
matrixstack.scale(scale, scale, scale);
|
||||||
Quaternion quaternion = Vector3f.ZP.rotationDegrees(180.0F);
|
var quaternion = Vector3f.ZP.rotationDegrees(180.0F);
|
||||||
Quaternion quaternion1 = Vector3f.XP.rotationDegrees(f1 * 20.0F);
|
var quaternion1 = Vector3f.XP.rotationDegrees(f1 * 20.0F);
|
||||||
quaternion.multiply(quaternion1);
|
quaternion.mul(quaternion1);
|
||||||
matrixstack.rotate(quaternion);
|
matrixstack.mulPose(quaternion);
|
||||||
float f2 = entity.renderYawOffset;
|
var f2 = entity.yBodyRot;
|
||||||
float f3 = entity.rotationYaw;
|
var f3 = entity.getYRot();
|
||||||
float f4 = entity.rotationPitch;
|
var f4 = entity.getXRot();
|
||||||
float f5 = entity.prevRotationYawHead;
|
var f5 = entity.yHeadRotO;
|
||||||
float f6 = entity.rotationYawHead;
|
var f6 = entity.yHeadRot;
|
||||||
entity.renderYawOffset = 180.0F + f * 20.0F;
|
entity.yBodyRot = 180.0F + f * 20.0F;
|
||||||
entity.rotationYaw = 180.0F + f * 40.0F;
|
entity.setYRot(180.0F + f * 40.0F);
|
||||||
entity.rotationPitch = -f1 * 20.0F;
|
entity.setXRot(-f1 * 20.0F);
|
||||||
entity.rotationYawHead = entity.rotationYaw;
|
entity.yHeadRot = entity.getYRot();
|
||||||
entity.prevRotationYawHead = entity.rotationYaw;
|
entity.yHeadRotO = entity.getYRot();
|
||||||
EntityRendererManager entityrenderermanager = Minecraft.getInstance().getRenderManager();
|
Lighting.setupForEntityInInventory();
|
||||||
quaternion1.conjugate();
|
var entityrenderermanager = Minecraft.getInstance().getEntityRenderDispatcher();
|
||||||
entityrenderermanager.setCameraOrientation(quaternion1);
|
quaternion1.conj();
|
||||||
|
entityrenderermanager.overrideCameraOrientation(quaternion1);
|
||||||
entityrenderermanager.setRenderShadow(false);
|
entityrenderermanager.setRenderShadow(false);
|
||||||
IRenderTypeBuffer.Impl buff = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
|
var buff = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||||
entityrenderermanager.renderEntityStatic(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, matrixstack, buff, 15728880);
|
entityrenderermanager.render(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, matrixstack, buff, 15728880);
|
||||||
buff.finish();
|
buff.endBatch();
|
||||||
entityrenderermanager.setRenderShadow(true);
|
entityrenderermanager.setRenderShadow(true);
|
||||||
entity.renderYawOffset = f2;
|
entity.yBodyRot = f2;
|
||||||
entity.rotationYaw = f3;
|
entity.setYRot(f3);
|
||||||
entity.rotationPitch = f4;
|
entity.setXRot(f4);
|
||||||
entity.prevRotationYawHead = f5;
|
entity.yHeadRotO = f5;
|
||||||
entity.rotationYawHead = f6;
|
entity.yHeadRot = f6;
|
||||||
RenderSystem.popMatrix();
|
posestack.popPose();
|
||||||
|
RenderSystem.applyModelViewMatrix();
|
||||||
|
Lighting.setupFor3DItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,8 +91,8 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public Component getTitle() {
|
||||||
return I18n.format("container." + JEINaturesAuraPlugin.SPAWNER + ".name");
|
return new TranslatableComponent("container." + JEINaturesAuraPlugin.SPAWNER + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,38 +108,37 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
|
||||||
@Override
|
@Override
|
||||||
public void setIngredients(AnimalSpawnerRecipe animalSpawnerRecipe, IIngredients iIngredients) {
|
public void setIngredients(AnimalSpawnerRecipe animalSpawnerRecipe, IIngredients iIngredients) {
|
||||||
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
||||||
for (Ingredient ing : animalSpawnerRecipe.ingredients)
|
for (var ing : animalSpawnerRecipe.ingredients)
|
||||||
builder.add(ing.getMatchingStacks());
|
builder.add(ing.getItems());
|
||||||
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
|
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
|
||||||
iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(SpawnEggItem.getEgg(animalSpawnerRecipe.entity)));
|
iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(ForgeSpawnEggItem.fromEntityType(animalSpawnerRecipe.entity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(IRecipeLayout iRecipeLayout, AnimalSpawnerRecipe recipe, IIngredients iIngredients) {
|
public void setRecipe(IRecipeLayout iRecipeLayout, AnimalSpawnerRecipe recipe, IIngredients iIngredients) {
|
||||||
IGuiItemStackGroup group = iRecipeLayout.getItemStacks();
|
var group = iRecipeLayout.getItemStacks();
|
||||||
for (int i = 0; i < recipe.ingredients.length; i++) {
|
for (var i = 0; i < recipe.ingredients.length; i++) {
|
||||||
group.init(i, true, i * 18, 68);
|
group.init(i, true, i * 18, 68);
|
||||||
group.set(i, Arrays.asList(recipe.ingredients[i].getMatchingStacks()));
|
group.set(i, Arrays.asList(recipe.ingredients[i].getItems()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(AnimalSpawnerRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) {
|
public void draw(AnimalSpawnerRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
|
||||||
Minecraft minecraft = Minecraft.getInstance();
|
var minecraft = Minecraft.getInstance();
|
||||||
Entity entity = this.entityCache.get(recipe.entity);
|
var entity = this.entityCache.get(recipe.entity);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
entity = recipe.makeEntity(minecraft.level, BlockPos.ZERO);
|
entity = recipe.makeEntity(minecraft.level, BlockPos.ZERO);
|
||||||
this.entityCache.put(recipe.entity, entity);
|
this.entityCache.put(recipe.entity, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
matrixStack.push();
|
matrixStack.pushPose();
|
||||||
float size = Math.max(1F, Math.max(recipe.entity.getWidth(), recipe.entity.getHeight()));
|
var size = Math.max(1F, Math.max(recipe.entity.getWidth(), recipe.entity.getHeight()));
|
||||||
renderEntity(matrixStack, 35, 55, 100F / size * 0.4F, 40, size * 0.5F, (LivingEntity) entity);
|
renderEntity(matrixStack, 35, 55, 100F / size * 0.4F, 40, size * 0.5F, (LivingEntity) entity);
|
||||||
matrixStack.pop();
|
matrixStack.popPose();
|
||||||
|
|
||||||
String name = recipe.entity.getName().getString();
|
var name = recipe.entity.getDescription().getString();
|
||||||
minecraft.fontRenderer.drawStringWithShadow(matrixStack, name, 36 - minecraft.fontRenderer.getStringWidth(name) / 2F, 55, 0xFFFFFF);
|
minecraft.font.drawShadow(matrixStack, name, 36 - minecraft.font.width(name) / 2F, 55, 0xFFFFFF);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
/*
|
|
||||||
package de.ellpeck.naturesaura.compat.jei;
|
package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
import de.ellpeck.naturesaura.items.ItemAuraBottle;
|
import de.ellpeck.naturesaura.items.ItemAuraBottle;
|
||||||
import de.ellpeck.naturesaura.items.ItemEffectPowder;
|
import de.ellpeck.naturesaura.items.ItemEffectPowder;
|
||||||
|
@ -11,16 +9,14 @@ import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||||
import mezz.jei.api.IModPlugin;
|
import mezz.jei.api.IModPlugin;
|
||||||
import mezz.jei.api.JeiPlugin;
|
import mezz.jei.api.JeiPlugin;
|
||||||
import mezz.jei.api.helpers.IGuiHelper;
|
import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter;
|
||||||
import mezz.jei.api.ingredients.subtypes.ISubtypeInterpreter;
|
|
||||||
import mezz.jei.api.registration.IRecipeCatalystRegistration;
|
import mezz.jei.api.registration.IRecipeCatalystRegistration;
|
||||||
import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
||||||
import mezz.jei.api.registration.IRecipeRegistration;
|
import mezz.jei.api.registration.IRecipeRegistration;
|
||||||
import mezz.jei.api.registration.ISubtypeRegistration;
|
import mezz.jei.api.registration.ISubtypeRegistration;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.item.crafting.RecipeManager;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
@JeiPlugin
|
@JeiPlugin
|
||||||
public class JEINaturesAuraPlugin implements IModPlugin {
|
public class JEINaturesAuraPlugin implements IModPlugin {
|
||||||
|
@ -37,7 +33,7 @@ public class JEINaturesAuraPlugin implements IModPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||||
IGuiHelper helper = registry.getJeiHelpers().getGuiHelper();
|
var helper = registry.getJeiHelpers().getGuiHelper();
|
||||||
registry.addRecipeCategories(
|
registry.addRecipeCategories(
|
||||||
new TreeRitualCategory(helper),
|
new TreeRitualCategory(helper),
|
||||||
new AltarCategory(helper),
|
new AltarCategory(helper),
|
||||||
|
@ -48,14 +44,14 @@ public class JEINaturesAuraPlugin implements IModPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerItemSubtypes(ISubtypeRegistration registration) {
|
public void registerItemSubtypes(ISubtypeRegistration registration) {
|
||||||
registration.registerSubtypeInterpreter(ModItems.EFFECT_POWDER, stack -> ItemEffectPowder.getEffect(stack).toString());
|
registration.registerSubtypeInterpreter(ModItems.EFFECT_POWDER, (stack, context) -> ItemEffectPowder.getEffect(stack).toString());
|
||||||
registration.registerSubtypeInterpreter(ModItems.AURA_BOTTLE, stack -> ItemAuraBottle.getType(stack).getName().toString());
|
registration.registerSubtypeInterpreter(ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString());
|
||||||
|
|
||||||
ISubtypeInterpreter auraInterpreter = stack -> {
|
var auraInterpreter = (IIngredientSubtypeInterpreter<ItemStack>) (stack, context) -> {
|
||||||
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
|
var container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
|
||||||
if (container != null)
|
if (container != null)
|
||||||
return String.valueOf(container.getStoredAura());
|
return String.valueOf(container.getStoredAura());
|
||||||
return ISubtypeInterpreter.NONE;
|
return IIngredientSubtypeInterpreter.NONE;
|
||||||
};
|
};
|
||||||
registration.registerSubtypeInterpreter(ModItems.AURA_CACHE, auraInterpreter);
|
registration.registerSubtypeInterpreter(ModItems.AURA_CACHE, auraInterpreter);
|
||||||
registration.registerSubtypeInterpreter(ModItems.AURA_TROVE, auraInterpreter);
|
registration.registerSubtypeInterpreter(ModItems.AURA_TROVE, auraInterpreter);
|
||||||
|
@ -72,11 +68,10 @@ public class JEINaturesAuraPlugin implements IModPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerRecipes(IRecipeRegistration registration) {
|
public void registerRecipes(IRecipeRegistration registration) {
|
||||||
RecipeManager manager = Minecraft.getInstance().level.getRecipeManager();
|
var manager = Minecraft.getInstance().level.getRecipeManager();
|
||||||
registration.addRecipes(manager.getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null), TREE_RITUAL);
|
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE), TREE_RITUAL);
|
||||||
registration.addRecipes(manager.getRecipes(ModRecipes.ALTAR_TYPE, null, null), ALTAR);
|
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE), ALTAR);
|
||||||
registration.addRecipes(manager.getRecipes(ModRecipes.OFFERING_TYPE, null, null), OFFERING);
|
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE), OFFERING);
|
||||||
registration.addRecipes(manager.getRecipes(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null), SPAWNER);
|
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE), SPAWNER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/*
|
|
||||||
package de.ellpeck.naturesaura.compat.jei;
|
package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -11,9 +10,10 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||||
import mezz.jei.api.helpers.IGuiHelper;
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public Component getTitle() {
|
||||||
return I18n.format("container." + JEINaturesAuraPlugin.OFFERING + ".name");
|
return new TranslatableComponent("container." + JEINaturesAuraPlugin.OFFERING + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,8 +53,8 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
|
||||||
@Override
|
@Override
|
||||||
public void setIngredients(OfferingRecipe offeringRecipe, IIngredients iIngredients) {
|
public void setIngredients(OfferingRecipe offeringRecipe, IIngredients iIngredients) {
|
||||||
iIngredients.setInputs(VanillaTypes.ITEM, ImmutableList.<ItemStack>builder()
|
iIngredients.setInputs(VanillaTypes.ITEM, ImmutableList.<ItemStack>builder()
|
||||||
.add(offeringRecipe.input.getMatchingStacks())
|
.add(offeringRecipe.input.getItems())
|
||||||
.add(offeringRecipe.startItem.getMatchingStacks()).build());
|
.add(offeringRecipe.startItem.getItems()).build());
|
||||||
iIngredients.setOutput(VanillaTypes.ITEM, offeringRecipe.output);
|
iIngredients.setOutput(VanillaTypes.ITEM, offeringRecipe.output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,11 +62,10 @@ public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
|
||||||
public void setRecipe(IRecipeLayout recipeLayout, OfferingRecipe recipe, IIngredients ingredients) {
|
public void setRecipe(IRecipeLayout recipeLayout, OfferingRecipe recipe, IIngredients ingredients) {
|
||||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
||||||
group.init(0, true, 0, 14);
|
group.init(0, true, 0, 14);
|
||||||
group.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
|
group.set(0, Arrays.asList(recipe.input.getItems()));
|
||||||
group.init(1, false, 65, 14);
|
group.init(1, false, 65, 14);
|
||||||
group.set(1, recipe.output);
|
group.set(1, recipe.output);
|
||||||
group.init(2, true, 27, 0);
|
group.init(2, true, 27, 0);
|
||||||
group.set(2, Arrays.asList(recipe.startItem.getMatchingStacks()));
|
group.set(2, Arrays.asList(recipe.startItem.getItems()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/*
|
|
||||||
package de.ellpeck.naturesaura.compat.jei;
|
package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -7,14 +6,13 @@ import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
|
||||||
import mezz.jei.api.constants.VanillaTypes;
|
import mezz.jei.api.constants.VanillaTypes;
|
||||||
import mezz.jei.api.gui.IRecipeLayout;
|
import mezz.jei.api.gui.IRecipeLayout;
|
||||||
import mezz.jei.api.gui.drawable.IDrawable;
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
|
||||||
import mezz.jei.api.helpers.IGuiHelper;
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@ -37,8 +35,8 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public Component getTitle() {
|
||||||
return I18n.format("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name");
|
return new TranslatableComponent("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,28 +52,27 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
|
||||||
@Override
|
@Override
|
||||||
public void setIngredients(TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) {
|
public void setIngredients(TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) {
|
||||||
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
||||||
for (Ingredient ing : treeRitualRecipe.ingredients)
|
for (var ing : treeRitualRecipe.ingredients)
|
||||||
builder.add(ing.getMatchingStacks());
|
builder.add(ing.getItems());
|
||||||
builder.add(treeRitualRecipe.saplingType.getMatchingStacks());
|
builder.add(treeRitualRecipe.saplingType.getItems());
|
||||||
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
|
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
|
||||||
iIngredients.setOutput(VanillaTypes.ITEM, treeRitualRecipe.result);
|
iIngredients.setOutput(VanillaTypes.ITEM, treeRitualRecipe.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(IRecipeLayout iRecipeLayout, TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) {
|
public void setRecipe(IRecipeLayout iRecipeLayout, TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) {
|
||||||
IGuiItemStackGroup group = iRecipeLayout.getItemStacks();
|
var group = iRecipeLayout.getItemStacks();
|
||||||
|
|
||||||
group.init(0, true, 34, 34);
|
group.init(0, true, 34, 34);
|
||||||
group.set(0, Arrays.asList(treeRitualRecipe.saplingType.getMatchingStacks()));
|
group.set(0, Arrays.asList(treeRitualRecipe.saplingType.getItems()));
|
||||||
|
|
||||||
group.init(1, true, 124, 34);
|
group.init(1, true, 124, 34);
|
||||||
group.set(1, treeRitualRecipe.result);
|
group.set(1, treeRitualRecipe.result);
|
||||||
|
|
||||||
int[][] positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}};
|
var positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}};
|
||||||
for (int i = 0; i < treeRitualRecipe.ingredients.length; i++) {
|
for (var i = 0; i < treeRitualRecipe.ingredients.length; i++) {
|
||||||
group.init(i + 2, true, positions[i][0] - 1, positions[i][1] - 1);
|
group.init(i + 2, true, positions[i][0] - 1, positions[i][1] - 1);
|
||||||
group.set(i + 2, Arrays.asList(treeRitualRecipe.ingredients[i].getMatchingStacks()));
|
group.set(i + 2, Arrays.asList(treeRitualRecipe.ingredients[i].getItems()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class PatchouliCompat implements ICompat {
|
||||||
var r = ((info.color() >> 16) & 255) / 255F;
|
var r = ((info.color() >> 16) & 255) / 255F;
|
||||||
var g = ((info.color() >> 8) & 255) / 255F;
|
var g = ((info.color() >> 8) & 255) / 255F;
|
||||||
var b = (info.color() & 255) / 255F;
|
var b = (info.color() & 255) / 255F;
|
||||||
// TODO apply leaf color?
|
// TODO apply leaf color, we probably have to blit manually using the texture + color shader
|
||||||
//RenderSystem.color3f(r, g, b);
|
//RenderSystem.color3f(r, g, b);
|
||||||
Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256);
|
Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue