2014-10-28 21:10:08 -04:00
|
|
|
package info.jbcs.minecraft.chisel.utils;
|
2014-03-16 22:26:43 +01:00
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
2014-12-14 20:05:39 +00:00
|
|
|
|
2014-03-16 22:26:43 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
2014-12-14 20:05:39 +00:00
|
|
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
|
|
|
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
|
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
public class BlockTexturedOreRenderer implements ISimpleBlockRenderingHandler
|
|
|
|
|
{
|
|
|
|
|
float bot = -0.001f, top = 1.0f - bot;
|
|
|
|
|
static int id;
|
2014-03-16 22:26:43 +01:00
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
public BlockTexturedOreRenderer()
|
|
|
|
|
{
|
|
|
|
|
id = RenderingRegistry.getNextAvailableRenderId();
|
|
|
|
|
}
|
2014-03-16 22:26:43 +01:00
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
@Override
|
|
|
|
|
public void renderInventoryBlock(Block blck, int meta, int modelID, RenderBlocks renderer)
|
|
|
|
|
{
|
|
|
|
|
if(blck == null || !(blck instanceof BlockTexturedOre))
|
|
|
|
|
return;
|
2014-03-16 22:26:43 +01:00
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
BlockTexturedOre block = (BlockTexturedOre) blck;
|
2014-03-16 22:26:43 +01:00
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
if(block.icon != null)
|
|
|
|
|
{
|
|
|
|
|
renderer.overrideBlockTexture = block.icon;
|
|
|
|
|
renderer.renderBlockAsItem(Blocks.stone, meta, 1.0f);
|
|
|
|
|
renderer.overrideBlockTexture = null;
|
|
|
|
|
} else if(block.base != null)
|
|
|
|
|
{
|
|
|
|
|
renderer.renderBlockAsItem(block.base, meta, 1.0f);
|
|
|
|
|
}
|
2014-03-16 22:26:43 +01:00
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
GL11.glEnable(3042);
|
|
|
|
|
GL11.glBlendFunc(770, 771);
|
|
|
|
|
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
|
|
|
|
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
|
|
|
|
Drawing.drawBlock(block, meta, renderer);
|
|
|
|
|
GL11.glDisable(3042);
|
|
|
|
|
}
|
2014-03-16 22:26:43 +01:00
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
@Override
|
|
|
|
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer)
|
|
|
|
|
{
|
|
|
|
|
if(blck == null || !(blck instanceof BlockTexturedOre))
|
|
|
|
|
return false;
|
|
|
|
|
BlockTexturedOre block = (BlockTexturedOre) blck;
|
|
|
|
|
|
|
|
|
|
if(block.currentPass == 0)
|
|
|
|
|
{
|
|
|
|
|
if(block.icon != null)
|
|
|
|
|
{
|
|
|
|
|
renderer.overrideBlockTexture = block.icon;
|
|
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
|
renderer.overrideBlockTexture = null;
|
|
|
|
|
} else if(block.base != null)
|
|
|
|
|
{
|
|
|
|
|
renderer.renderBlockByRenderType(block.base, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
renderer.setRenderBounds(bot, bot, bot, top, top, top);
|
|
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean shouldRender3DInInventory(int modelId)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getRenderId()
|
|
|
|
|
{
|
|
|
|
|
return id;
|
|
|
|
|
}
|
2014-03-16 22:26:43 +01:00
|
|
|
}
|