mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
fixed JEI being broken
This commit is contained in:
parent
1104a10397
commit
3c2da1fb92
3 changed files with 44 additions and 43 deletions
|
@ -31,6 +31,8 @@ public class AnimalSpawnerRecipe {
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return null;
|
return null;
|
||||||
Entity entity = entry.newInstance(world);
|
Entity entity = entry.newInstance(world);
|
||||||
|
if (x == 0 && y == 0 && z == 0)
|
||||||
|
return entity;
|
||||||
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360F), 0F);
|
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360F), 0F);
|
||||||
if (entity instanceof EntityLiving) {
|
if (entity instanceof EntityLiving) {
|
||||||
EntityLiving living = (EntityLiving) entity;
|
EntityLiving living = (EntityLiving) entity;
|
||||||
|
|
|
@ -9,12 +9,7 @@ import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||||
import mezz.jei.api.gui.IRecipeLayout;
|
import mezz.jei.api.gui.IRecipeLayout;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.IRecipeCategory;
|
import mezz.jei.api.recipe.IRecipeCategory;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -22,8 +17,6 @@ import java.util.Arrays;
|
||||||
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerWrapper> {
|
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerWrapper> {
|
||||||
|
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
private AnimalSpawnerRecipe recipe;
|
|
||||||
private Entity entity;
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -52,43 +45,10 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerWrapp
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(IRecipeLayout recipeLayout, AnimalSpawnerWrapper recipeWrapper, IIngredients ingredients) {
|
public void setRecipe(IRecipeLayout recipeLayout, AnimalSpawnerWrapper recipeWrapper, IIngredients ingredients) {
|
||||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
||||||
this.recipe = recipeWrapper.recipe;
|
AnimalSpawnerRecipe recipe = recipeWrapper.recipe;
|
||||||
this.entity = null;
|
for (int i = 0; i < recipe.ingredients.length; i++) {
|
||||||
for (int i = 0; i < this.recipe.ingredients.length; i++) {
|
|
||||||
group.init(i, true, i * 18, 68);
|
group.init(i, true, i * 18, 68);
|
||||||
group.set(i, Arrays.asList(this.recipe.ingredients[i].getMatchingStacks()));
|
group.set(i, Arrays.asList(recipe.ingredients[i].getMatchingStacks()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawExtras(Minecraft minecraft) {
|
|
||||||
if (this.entity == null)
|
|
||||||
this.entity = this.recipe.makeEntity(minecraft.world, 0, 0, 0);
|
|
||||||
|
|
||||||
float size = Math.max(1F, Math.max(this.entity.width, this.entity.height));
|
|
||||||
renderEntity(this.entity, 35, 28, 35F, 100F / size * 0.4F, size * 0.5F);
|
|
||||||
|
|
||||||
String name = this.entity.getDisplayName().getFormattedText();
|
|
||||||
minecraft.fontRenderer.drawString(name, 36 - minecraft.fontRenderer.getStringWidth(name) / 2F, 55, 0xFFFFFF, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void renderEntity(Entity entity, float x, float y, float rotation, float renderScale, float offset) {
|
|
||||||
GlStateManager.enableColorMaterial();
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.color(1F, 1F, 1F);
|
|
||||||
GlStateManager.translate(x, y, 50.0F);
|
|
||||||
GlStateManager.scale(-renderScale, renderScale, renderScale);
|
|
||||||
GlStateManager.translate(0F, offset, 0F);
|
|
||||||
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
|
||||||
GlStateManager.rotate(rotation, 0.0F, 1.0F, 0.0F);
|
|
||||||
RenderHelper.enableStandardItemLighting();
|
|
||||||
Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;
|
|
||||||
Minecraft.getMinecraft().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
RenderHelper.disableStandardItemLighting();
|
|
||||||
GlStateManager.disableRescaleNormal();
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
|
||||||
GlStateManager.disableTexture2D();
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,11 @@ import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.ingredients.VanillaTypes;
|
import mezz.jei.api.ingredients.VanillaTypes;
|
||||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemMonsterPlacer;
|
import net.minecraft.item.ItemMonsterPlacer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -13,6 +18,7 @@ import net.minecraft.item.crafting.Ingredient;
|
||||||
public class AnimalSpawnerWrapper implements IRecipeWrapper {
|
public class AnimalSpawnerWrapper implements IRecipeWrapper {
|
||||||
|
|
||||||
public final AnimalSpawnerRecipe recipe;
|
public final AnimalSpawnerRecipe recipe;
|
||||||
|
private Entity entity;
|
||||||
|
|
||||||
public AnimalSpawnerWrapper(AnimalSpawnerRecipe recipe) {
|
public AnimalSpawnerWrapper(AnimalSpawnerRecipe recipe) {
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
|
@ -29,4 +35,37 @@ public class AnimalSpawnerWrapper implements IRecipeWrapper {
|
||||||
ItemMonsterPlacer.applyEntityIdToItemStack(egg, this.recipe.entity);
|
ItemMonsterPlacer.applyEntityIdToItemStack(egg, this.recipe.entity);
|
||||||
ingredients.setOutput(VanillaTypes.ITEM, egg);
|
ingredients.setOutput(VanillaTypes.ITEM, egg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||||
|
if (this.entity == null)
|
||||||
|
this.entity = this.recipe.makeEntity(minecraft.world, 0, 0, 0);
|
||||||
|
|
||||||
|
float size = Math.max(1F, Math.max(this.entity.width, this.entity.height));
|
||||||
|
float rot = (minecraft.world.getTotalWorldTime() + minecraft.getRenderPartialTicks()) % 360F;
|
||||||
|
renderEntity(this.entity, 35, 28, rot, 100F / size * 0.4F, size * 0.5F);
|
||||||
|
|
||||||
|
String name = this.entity.getDisplayName().getFormattedText();
|
||||||
|
minecraft.fontRenderer.drawString(name, 36 - minecraft.fontRenderer.getStringWidth(name) / 2F, 55, 0xFFFFFF, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void renderEntity(Entity entity, float x, float y, float rotation, float renderScale, float offset) {
|
||||||
|
GlStateManager.enableColorMaterial();
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.color(1F, 1F, 1F);
|
||||||
|
GlStateManager.translate(x, y, 50.0F);
|
||||||
|
GlStateManager.scale(-renderScale, renderScale, renderScale);
|
||||||
|
GlStateManager.translate(0F, offset, 0F);
|
||||||
|
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
||||||
|
GlStateManager.rotate(rotation, 0.0F, 1.0F, 0.0F);
|
||||||
|
RenderHelper.enableStandardItemLighting();
|
||||||
|
Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;
|
||||||
|
Minecraft.getMinecraft().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
RenderHelper.disableStandardItemLighting();
|
||||||
|
GlStateManager.disableRescaleNormal();
|
||||||
|
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||||
|
GlStateManager.disableTexture2D();
|
||||||
|
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue