TileEntityChestRenderer .java

net.minecraft.client.renderer.tileentity.TileEntityChestRenderer (class, 200 lines): members: textureChristmasDouble, textureTrappedDouble, textureTrapped.

net.minecraft.client.renderer.tileentityclass200 linesclientextends TileEntitySpecialRenderer<TileEntityChest>6.7 KB

API Surface (1)

void renderTileEntityAt(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage)

Fields & Constants (9)

textureTrappedDouble
textureChristmasDouble
textureNormalDouble
textureTrapped
textureChristmas
textureNormal
simpleChest
largeChest
isChristmas

String literals (6)

"textures/entity/chest/trapped_double.png"
"textures/entity/chest/christmas_double.png"
"textures/entity/chest/normal_double.png"
"textures/entity/chest/trapped.png"
"textures/entity/chest/christmas.png"
"textures/entity/chest/normal.png"

Full Source

TileEntityChestRenderer.java200 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.renderer.tileentity;
2
3
import java.util.Calendar;
4
import net.minecraft.block.Block;
5
import net.minecraft.block.BlockChest;
6
import net.minecraft.client.model.ModelChest;
7
import net.minecraft.client.model.ModelLargeChest;
8
import net.minecraft.client.renderer.GlStateManager;
9
import net.minecraft.tileentity.TileEntityChest;
10
import net.minecraft.util.ResourceLocation;
11
12
public class TileEntityChestRenderer extends TileEntitySpecialRenderer<TileEntityChest>
13
{
14
    private static final ResourceLocation textureTrappedDouble = new ResourceLocation("textures/entity/chest/trapped_double.png");
15
    private static final ResourceLocation textureChristmasDouble = new ResourceLocation("textures/entity/chest/christmas_double.png");
16
    private static final ResourceLocation textureNormalDouble = new ResourceLocation("textures/entity/chest/normal_double.png");
17
    private static final ResourceLocation textureTrapped = new ResourceLocation("textures/entity/chest/trapped.png");
18
    private static final ResourceLocation textureChristmas = new ResourceLocation("textures/entity/chest/christmas.png");
19
    private static final ResourceLocation textureNormal = new ResourceLocation("textures/entity/chest/normal.png");
20
    private ModelChest simpleChest = new ModelChest();
21
    private ModelChest largeChest = new ModelLargeChest();
22
    private boolean isChristmas;
23
24
    public TileEntityChestRenderer()
25
    {
26
        Calendar calendar = Calendar.getInstance();
27
28
        if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26)
29
        {
30
            this.isChristmas = true;
31
        }
32
    }
33
34
    public void renderTileEntityAt(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage)
35
    {
36
        GlStateManager.enableDepth();
37
        GlStateManager.depthFunc(515);
38
        GlStateManager.depthMask(true);
39
        int i;
40
41
        if (!te.hasWorldObj())
42
        {
43
            i = 0;
44
        }
45
        else
46
        {
47
            Block block = te.getBlockType();
48
            i = te.getBlockMetadata();
49
50
            if (block instanceof BlockChest && i == 0)
51
            {
52
                ((BlockChest)block).checkForSurroundingChests(te.getWorld(), te.getPos(), te.getWorld().getBlockState(te.getPos()));
53
                i = te.getBlockMetadata();
54
            }
55
56
            te.checkForAdjacentChests();
57
        }
58
59
        if (te.adjacentChestZNeg == null && te.adjacentChestXNeg == null)
60
        {
61
            ModelChest modelchest;
62
63
            if (te.adjacentChestXPos == null && te.adjacentChestZPos == null)
64
            {
65
                modelchest = this.simpleChest;
66
67
                if (destroyStage >= 0)
68
                {
69
                    this.bindTexture(DESTROY_STAGES[destroyStage]);
70
                    GlStateManager.matrixMode(5890);
71
                    GlStateManager.pushMatrix();
72
                    GlStateManager.scale(4.0F, 4.0F, 1.0F);
73
                    GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
74
                    GlStateManager.matrixMode(5888);
75
                }
76
                else if (this.isChristmas)
77
                {
78
                    this.bindTexture(textureChristmas);
79
                }
80
                else if (te.getChestType() == 1)
81
                {
82
                    this.bindTexture(textureTrapped);
83
                }
84
                else
85
                {
86
                    this.bindTexture(textureNormal);
87
                }
88
            }
89
            else
90
            {
91
                modelchest = this.largeChest;
92
93
                if (destroyStage >= 0)
94
                {
95
                    this.bindTexture(DESTROY_STAGES[destroyStage]);
96
                    GlStateManager.matrixMode(5890);
97
                    GlStateManager.pushMatrix();
98
                    GlStateManager.scale(8.0F, 4.0F, 1.0F);
99
                    GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
100
                    GlStateManager.matrixMode(5888);
101
                }
102
                else if (this.isChristmas)
103
                {
104
                    this.bindTexture(textureChristmasDouble);
105
                }
106
                else if (te.getChestType() == 1)
107
                {
108
                    this.bindTexture(textureTrappedDouble);
109
                }
110
                else
111
                {
112
                    this.bindTexture(textureNormalDouble);
113
                }
114
            }
115
116
            GlStateManager.pushMatrix();
117
            GlStateManager.enableRescaleNormal();
118
119
            if (destroyStage < 0)
120
            {
121
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
122
            }
123
124
            GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F);
125
            GlStateManager.scale(1.0F, -1.0F, -1.0F);
126
            GlStateManager.translate(0.5F, 0.5F, 0.5F);
127
            int j = 0;
128
129
            if (i == 2)
130
            {
131
                j = 180;
132
            }
133
134
            if (i == 3)
135
            {
136
                j = 0;
137
            }
138
139
            if (i == 4)
140
            {
141
                j = 90;
142
            }
143
144
            if (i == 5)
145
            {
146
                j = -90;
147
            }
148
149
            if (i == 2 && te.adjacentChestXPos != null)
150
            {
151
                GlStateManager.translate(1.0F, 0.0F, 0.0F);
152
            }
153
154
            if (i == 5 && te.adjacentChestZPos != null)
155
            {
156
                GlStateManager.translate(0.0F, 0.0F, -1.0F);
157
            }
158
159
            GlStateManager.rotate((float)j, 0.0F, 1.0F, 0.0F);
160
            GlStateManager.translate(-0.5F, -0.5F, -0.5F);
161
            float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
162
163
            if (te.adjacentChestZNeg != null)
164
            {
165
                float f1 = te.adjacentChestZNeg.prevLidAngle + (te.adjacentChestZNeg.lidAngle - te.adjacentChestZNeg.prevLidAngle) * partialTicks;
166
167
                if (f1 > f)
168
                {
169
                    f = f1;
170
                }
171
            }
172
173
            if (te.adjacentChestXNeg != null)
174
            {
175
                float f2 = te.adjacentChestXNeg.prevLidAngle + (te.adjacentChestXNeg.lidAngle - te.adjacentChestXNeg.prevLidAngle) * partialTicks;
176
177
                if (f2 > f)
178
                {
179
                    f = f2;
180
                }
181
            }
182
183
            f = 1.0F - f;
184
            f = 1.0F - f * f * f;
185
            modelchest.chestLid.rotateAngleX = -(f * (float)Math.PI / 2.0F);
186
            modelchest.renderAll();
187
            GlStateManager.disableRescaleNormal();
188
            GlStateManager.popMatrix();
189
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
190
191
            if (destroyStage >= 0)
192
            {
193
                GlStateManager.matrixMode(5890);
194
                GlStateManager.popMatrix();
195
                GlStateManager.matrixMode(5888);
196
            }
197
        }
198
    }
199
}
200

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