summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/renders/RendererSmelter.java
blob: ca5da8b4d374a0e9487538fd20b7b8e2035111df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package darkknight.jewelrycraft.renders;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

public class RendererSmelter implements ISimpleBlockRenderingHandler
{
    public static int renderID;
    
    public static Tessellator t;
    public static float minU, minV, maxU, maxV;
    
    public RendererSmelter(int id)
    {
        renderID = id;
    }
    
    @Override
    public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer)
    {
        
    }
    
    @Override
    public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
    {
        t = Tessellator.instance;
        
        t.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
        
        t.setColorOpaque_F(0.6F, 0.6F, 0.6F);
        
        bindTexture(Blocks.dirt.getIcon(1, 2));
        
        t.addVertexWithUV(x, y + 0.5F, z, minU, minV);
        t.addVertexWithUV(x, y, z, minU, maxV);
        t.addVertexWithUV(x, y, z + 1F, maxU, maxV);
        t.addVertexWithUV(x, y + 0.5F, z + 1F, maxU, minV);
        
        return true;
    }
    
    public void bindTexture(IIcon texture)
    {
        minU = texture.getMinU();
        minV = texture.getInterpolatedV(8);
        maxU = texture.getMaxU();
        maxV = texture.getMaxV();
    }
    
    @Override
    public boolean shouldRender3DInInventory(int modelId)
    {
        return false;
    }
    
    @Override
    public int getRenderId()
    {
        return renderID;
    }
}