mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Fix king key weapon and item render
This commit is contained in:
1 parent
c5a5657810
commit
5293f811c8
3 files changed
+88
-2
No files matched your search
@@ -10,9 +10,13 @@
|
||||
*/
|
||||
package vazkii.botania.client.core.helper;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
|
||||
public final class IconHelper {
|
||||
@@ -25,4 +29,85 @@ public final class IconHelper {
|
||||
return ir.registerSprite(new ResourceLocation(LibResources.PREFIX_MOD + dir + "/" + name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a sprite from the spritesheet with depth, like a "builtin/generated" item model.
|
||||
* Adapted from ItemRenderer.renderItemIn2D, 1.7.10
|
||||
*/
|
||||
public static void renderIconIn3D(Tessellator tess, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int width, int height, float thickness) {
|
||||
WorldRenderer wr = tess.getWorldRenderer();
|
||||
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
|
||||
wr.pos(0.0D, 0.0D, 0.0D).tex(p_78439_1_, p_78439_4_).normal(0, 0, 1).endVertex();
|
||||
wr.pos(1.0D, 0.0D, 0.0D).tex(p_78439_3_, p_78439_4_).normal(0, 0, 1).endVertex();
|
||||
wr.pos(1.0D, 1.0D, 0.0D).tex(p_78439_3_, p_78439_2_).normal(0, 0, 1).endVertex();
|
||||
wr.pos(0.0D, 1.0D, 0.0D).tex(p_78439_1_, p_78439_2_).normal(0, 0, 1).endVertex();
|
||||
tess.draw();
|
||||
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
|
||||
wr.pos(0.0D, 1.0D, (0.0F - thickness)).tex(p_78439_1_, p_78439_2_).normal(0, 0, -1).endVertex();
|
||||
wr.pos(1.0D, 1.0D, (0.0F - thickness)).tex(p_78439_3_, p_78439_2_).normal(0, 0, -1).endVertex();
|
||||
wr.pos(1.0D, 0.0D, (0.0F - thickness)).tex(p_78439_3_, p_78439_4_).normal(0, 0, -1).endVertex();
|
||||
wr.pos(0.0D, 0.0D, (0.0F - thickness)).tex(p_78439_1_, p_78439_4_).normal(0, 0, -1).endVertex();
|
||||
tess.draw();
|
||||
float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)width;
|
||||
float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)height;
|
||||
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
|
||||
int k;
|
||||
float f7;
|
||||
float f8;
|
||||
|
||||
for (k = 0; k < width; ++k)
|
||||
{
|
||||
f7 = (float)k / (float)width;
|
||||
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
|
||||
wr.pos(f7, 0.0D, (0.0F - thickness)).tex(f8, p_78439_4_).normal(-1, 0, 0).endVertex();
|
||||
wr.pos(f7, 0.0D, 0.0D).tex(f8, p_78439_4_).normal(-1, 0, 0).endVertex();
|
||||
wr.pos(f7, 1.0D, 0.0D).tex(f8, p_78439_2_).normal(-1, 0, 0).endVertex();
|
||||
wr.pos(f7, 1.0D, (0.0F - thickness)).tex(f8, p_78439_2_).normal(-1, 0, 0).endVertex();
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
|
||||
float f9;
|
||||
|
||||
for (k = 0; k < width; ++k)
|
||||
{
|
||||
f7 = (float)k / (float)width;
|
||||
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
|
||||
f9 = f7 + 1.0F / (float)width;
|
||||
wr.pos(f9, 1.0D, (0.0F - thickness)).tex(f8, p_78439_2_).normal(1, 0, 0).endVertex();
|
||||
wr.pos(f9, 1.0D, 0.0D).tex(f8, p_78439_2_).normal(1, 0, 0).endVertex();
|
||||
wr.pos(f9, 0.0D, 0.0D).tex(f8, p_78439_4_).normal(1, 0, 0).endVertex();
|
||||
wr.pos(f9, 0.0D, (0.0F - thickness)).tex(f8, p_78439_4_).normal(1, 0, 0).endVertex();
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
|
||||
|
||||
for (k = 0; k < height; ++k)
|
||||
{
|
||||
f7 = (float)k / (float)height;
|
||||
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
|
||||
f9 = f7 + 1.0F / (float)height;
|
||||
wr.pos(0.0D, f9, 0.0D).tex(p_78439_1_, f8).normal(0, 1, 0).endVertex();
|
||||
wr.pos(1.0D, f9, 0.0D).tex(p_78439_3_, f8).normal(0, 1, 0).endVertex();
|
||||
wr.pos(1.0D, f9, (0.0F - thickness)).tex(p_78439_3_, f8).normal(0, 1, 0).endVertex();
|
||||
wr.pos(0.0D, f9, (0.0F - thickness)).tex(p_78439_1_, f8).normal(0, 1, 0).endVertex();
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
|
||||
|
||||
for (k = 0; k < height; ++k)
|
||||
{
|
||||
f7 = (float)k / (float)height;
|
||||
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
|
||||
wr.pos(1.0D, f7, 0.0D).tex(p_78439_3_, f8).normal(0, -1, 0).endVertex();
|
||||
wr.pos(0.0D, f7, 0.0D).tex(p_78439_1_, f8).normal(0, -1, 0).endVertex();
|
||||
wr.pos(0.0D, f7, (0.0F - thickness)).tex(p_78439_1_, f8).normal(0, -1, 0).endVertex();
|
||||
wr.pos(1.0D, f7, (0.0F - thickness)).tex(p_78439_3_, f8).normal(0, -1, 0).endVertex();
|
||||
}
|
||||
|
||||
tess.draw();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.client.core.handler.RenderEventHandler;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.entity.EntityBabylonWeapon;
|
||||
@@ -70,7 +71,7 @@ public class RenderBabylonWeapon extends Render<EntityBabylonWeapon> {
|
||||
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
GlStateManager.disableLighting();
|
||||
//ItemRenderer.renderItemIn2D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
GlStateManager.disableCull();
|
||||
|
||||
Reference in new issue
Block a user