RenderPainting .java

net.minecraft.client.renderer.entity.RenderPainting (class): members: KRISTOFFER_PAINTING_TEXTURE, doRender, getEntityTexture. imports: EntityPainting.

net.minecraft.client.renderer.entityclass147 linesclientextends Render<EntityPainting>8.0 KB

API Surface (2)

void doRender(EntityPainting entity, double x, double y, double z, float entityYaw, float partialTicks)
ResourceLocation getEntityTexture(EntityPainting entity)

Fields & Constants (1)

KRISTOFFER_PAINTING_TEXTURE

Full Source

RenderPainting.java147 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.renderer.entity;
2
3
import net.minecraft.client.renderer.GlStateManager;
4
import net.minecraft.client.renderer.OpenGlHelper;
5
import net.minecraft.client.renderer.Tessellator;
6
import net.minecraft.client.renderer.WorldRenderer;
7
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
8
import net.minecraft.entity.item.EntityPainting;
9
import net.minecraft.util.BlockPos;
10
import net.minecraft.util.EnumFacing;
11
import net.minecraft.util.MathHelper;
12
import net.minecraft.util.ResourceLocation;
13
14
public class RenderPainting extends Render<EntityPainting>
15
{
16
    private static final ResourceLocation KRISTOFFER_PAINTING_TEXTURE = new ResourceLocation("textures/painting/paintings_kristoffer_zetterstrand.png");
17
18
    public RenderPainting(RenderManager renderManagerIn)
19
    {
20
        super(renderManagerIn);
21
    }
22
23
    /**
24
     * Renders the desired {@code T} type Entity.
25
     */
26
    public void doRender(EntityPainting entity, double x, double y, double z, float entityYaw, float partialTicks)
27
    {
28
        GlStateManager.pushMatrix();
29
        GlStateManager.translate(x, y, z);
30
        GlStateManager.rotate(180.0F - entityYaw, 0.0F, 1.0F, 0.0F);
31
        GlStateManager.enableRescaleNormal();
32
        this.bindEntityTexture(entity);
33
        EntityPainting.EnumArt entitypainting$enumart = entity.art;
34
        float f = 0.0625F;
35
        GlStateManager.scale(f, f, f);
36
        this.renderPainting(entity, entitypainting$enumart.sizeX, entitypainting$enumart.sizeY, entitypainting$enumart.offsetX, entitypainting$enumart.offsetY);
37
        GlStateManager.disableRescaleNormal();
38
        GlStateManager.popMatrix();
39
        super.doRender(entity, x, y, z, entityYaw, partialTicks);
40
    }
41
42
    /**
43
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
44
     */
45
    protected ResourceLocation getEntityTexture(EntityPainting entity)
46
    {
47
        return KRISTOFFER_PAINTING_TEXTURE;
48
    }
49
50
    private void renderPainting(EntityPainting painting, int width, int height, int textureU, int textureV)
51
    {
52
        float f = (float)(-width) / 2.0F;
53
        float f1 = (float)(-height) / 2.0F;
54
        float f2 = 0.5F;
55
        float f3 = 0.75F;
56
        float f4 = 0.8125F;
57
        float f5 = 0.0F;
58
        float f6 = 0.0625F;
59
        float f7 = 0.75F;
60
        float f8 = 0.8125F;
61
        float f9 = 0.001953125F;
62
        float f10 = 0.001953125F;
63
        float f11 = 0.7519531F;
64
        float f12 = 0.7519531F;
65
        float f13 = 0.0F;
66
        float f14 = 0.0625F;
67
68
        for (int i = 0; i < width / 16; ++i)
69
        {
70
            for (int j = 0; j < height / 16; ++j)
71
            {
72
                float f15 = f + (float)((i + 1) * 16);
73
                float f16 = f + (float)(i * 16);
74
                float f17 = f1 + (float)((j + 1) * 16);
75
                float f18 = f1 + (float)(j * 16);
76
                this.setLightmap(painting, (f15 + f16) / 2.0F, (f17 + f18) / 2.0F);
77
                float f19 = (float)(textureU + width - i * 16) / 256.0F;
78
                float f20 = (float)(textureU + width - (i + 1) * 16) / 256.0F;
79
                float f21 = (float)(textureV + height - j * 16) / 256.0F;
80
                float f22 = (float)(textureV + height - (j + 1) * 16) / 256.0F;
81
                Tessellator tessellator = Tessellator.getInstance();
82
                WorldRenderer worldrenderer = tessellator.getWorldRenderer();
83
                worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
84
                worldrenderer.pos((double)f15, (double)f18, (double)(-f2)).tex((double)f20, (double)f21).normal(0.0F, 0.0F, -1.0F).endVertex();
85
                worldrenderer.pos((double)f16, (double)f18, (double)(-f2)).tex((double)f19, (double)f21).normal(0.0F, 0.0F, -1.0F).endVertex();
86
                worldrenderer.pos((double)f16, (double)f17, (double)(-f2)).tex((double)f19, (double)f22).normal(0.0F, 0.0F, -1.0F).endVertex();
87
                worldrenderer.pos((double)f15, (double)f17, (double)(-f2)).tex((double)f20, (double)f22).normal(0.0F, 0.0F, -1.0F).endVertex();
88
                worldrenderer.pos((double)f15, (double)f17, (double)f2).tex((double)f3, (double)f5).normal(0.0F, 0.0F, 1.0F).endVertex();
89
                worldrenderer.pos((double)f16, (double)f17, (double)f2).tex((double)f4, (double)f5).normal(0.0F, 0.0F, 1.0F).endVertex();
90
                worldrenderer.pos((double)f16, (double)f18, (double)f2).tex((double)f4, (double)f6).normal(0.0F, 0.0F, 1.0F).endVertex();
91
                worldrenderer.pos((double)f15, (double)f18, (double)f2).tex((double)f3, (double)f6).normal(0.0F, 0.0F, 1.0F).endVertex();
92
                worldrenderer.pos((double)f15, (double)f17, (double)(-f2)).tex((double)f7, (double)f9).normal(0.0F, 1.0F, 0.0F).endVertex();
93
                worldrenderer.pos((double)f16, (double)f17, (double)(-f2)).tex((double)f8, (double)f9).normal(0.0F, 1.0F, 0.0F).endVertex();
94
                worldrenderer.pos((double)f16, (double)f17, (double)f2).tex((double)f8, (double)f10).normal(0.0F, 1.0F, 0.0F).endVertex();
95
                worldrenderer.pos((double)f15, (double)f17, (double)f2).tex((double)f7, (double)f10).normal(0.0F, 1.0F, 0.0F).endVertex();
96
                worldrenderer.pos((double)f15, (double)f18, (double)f2).tex((double)f7, (double)f9).normal(0.0F, -1.0F, 0.0F).endVertex();
97
                worldrenderer.pos((double)f16, (double)f18, (double)f2).tex((double)f8, (double)f9).normal(0.0F, -1.0F, 0.0F).endVertex();
98
                worldrenderer.pos((double)f16, (double)f18, (double)(-f2)).tex((double)f8, (double)f10).normal(0.0F, -1.0F, 0.0F).endVertex();
99
                worldrenderer.pos((double)f15, (double)f18, (double)(-f2)).tex((double)f7, (double)f10).normal(0.0F, -1.0F, 0.0F).endVertex();
100
                worldrenderer.pos((double)f15, (double)f17, (double)f2).tex((double)f12, (double)f13).normal(-1.0F, 0.0F, 0.0F).endVertex();
101
                worldrenderer.pos((double)f15, (double)f18, (double)f2).tex((double)f12, (double)f14).normal(-1.0F, 0.0F, 0.0F).endVertex();
102
                worldrenderer.pos((double)f15, (double)f18, (double)(-f2)).tex((double)f11, (double)f14).normal(-1.0F, 0.0F, 0.0F).endVertex();
103
                worldrenderer.pos((double)f15, (double)f17, (double)(-f2)).tex((double)f11, (double)f13).normal(-1.0F, 0.0F, 0.0F).endVertex();
104
                worldrenderer.pos((double)f16, (double)f17, (double)(-f2)).tex((double)f12, (double)f13).normal(1.0F, 0.0F, 0.0F).endVertex();
105
                worldrenderer.pos((double)f16, (double)f18, (double)(-f2)).tex((double)f12, (double)f14).normal(1.0F, 0.0F, 0.0F).endVertex();
106
                worldrenderer.pos((double)f16, (double)f18, (double)f2).tex((double)f11, (double)f14).normal(1.0F, 0.0F, 0.0F).endVertex();
107
                worldrenderer.pos((double)f16, (double)f17, (double)f2).tex((double)f11, (double)f13).normal(1.0F, 0.0F, 0.0F).endVertex();
108
                tessellator.draw();
109
            }
110
        }
111
    }
112
113
    private void setLightmap(EntityPainting painting, float p_77008_2_, float p_77008_3_)
114
    {
115
        int i = MathHelper.floor_double(painting.posX);
116
        int j = MathHelper.floor_double(painting.posY + (double)(p_77008_3_ / 16.0F));
117
        int k = MathHelper.floor_double(painting.posZ);
118
        EnumFacing enumfacing = painting.facingDirection;
119
120
        if (enumfacing == EnumFacing.NORTH)
121
        {
122
            i = MathHelper.floor_double(painting.posX + (double)(p_77008_2_ / 16.0F));
123
        }
124
125
        if (enumfacing == EnumFacing.WEST)
126
        {
127
            k = MathHelper.floor_double(painting.posZ - (double)(p_77008_2_ / 16.0F));
128
        }
129
130
        if (enumfacing == EnumFacing.SOUTH)
131
        {
132
            i = MathHelper.floor_double(painting.posX - (double)(p_77008_2_ / 16.0F));
133
        }
134
135
        if (enumfacing == EnumFacing.EAST)
136
        {
137
            k = MathHelper.floor_double(painting.posZ + (double)(p_77008_2_ / 16.0F));
138
        }
139
140
        int l = this.renderManager.worldObj.getCombinedLight(new BlockPos(i, j, k), 0);
141
        int i1 = l % 65536;
142
        int j1 = l / 65536;
143
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)i1, (float)j1);
144
        GlStateManager.color(1.0F, 1.0F, 1.0F);
145
    }
146
}
147

Deobfuscated MCP 1.8.9 source of RenderPainting from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/renderer/entity/RenderPainting.java), stored verbatim.