Files
Chisel/src/main/java/com/cricketcraft/chisel/utils/BlockTexturedOreRenderer.java
T

78 lines
2.1 KiB
Java
Raw Normal View History

2014-12-15 00:11:48 +00:00
package com.cricketcraft.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;
2015-06-03 17:43:03 -04:00
import com.cricketcraft.ctmlib.Drawing;
2014-12-14 20:05:39 +00:00
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class BlockTexturedOreRenderer implements ISimpleBlockRenderingHandler {
2014-03-16 22:26:43 +01:00
float bot = -0.001f, top = 1.0f - bot;
static int id;
2014-03-16 22:26:43 +01:00
public BlockTexturedOreRenderer() {
id = RenderingRegistry.getNextAvailableRenderId();
}
2014-03-16 22:26:43 +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
BlockTexturedOre block = (BlockTexturedOre) blck;
2014-03-16 22:26:43 +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
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);
}
@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
}