2015-08-18 20:40:55 -04:00
|
|
|
package team.chisel.client.render;
|
2014-12-15 00:11:48 +00:00
|
|
|
|
2015-08-18 20:40:55 -04:00
|
|
|
import team.chisel.Chisel;
|
|
|
|
|
import team.chisel.block.BlockRoadLine;
|
2015-08-25 22:06:38 -04:00
|
|
|
import team.chisel.ctmlib.Drawing;
|
2014-04-21 19:13:15 +01:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.client.renderer.EntityRenderer;
|
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
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
|
|
|
|
2015-04-23 17:31:25 -04:00
|
|
|
public class RendererRoadLine implements ISimpleBlockRenderingHandler {
|
2015-01-07 19:50:18 -05:00
|
|
|
|
2015-04-23 17:31:25 -04:00
|
|
|
public RendererRoadLine() {
|
2015-01-11 21:32:37 +00:00
|
|
|
Chisel.roadLineId = RenderingRegistry.getNextAvailableRenderId();
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
|
|
|
|
renderer.setRenderBoundsFromBlock(block);
|
|
|
|
|
Drawing.drawBlock(block, meta, renderer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void renderTopFace(double y, IIcon icon) {
|
|
|
|
|
Tessellator tessellator = Tessellator.instance;
|
|
|
|
|
|
|
|
|
|
tessellator.addVertexWithUV(1, y, 0, icon.getMaxU(), icon.getMinV());
|
|
|
|
|
tessellator.addVertexWithUV(0, y, 0, icon.getMinU(), icon.getMinV());
|
|
|
|
|
tessellator.addVertexWithUV(0, y, 1, icon.getMinU(), icon.getMaxV());
|
|
|
|
|
tessellator.addVertexWithUV(1, y, 1, icon.getMaxU(), icon.getMaxV());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks renderer) {
|
|
|
|
|
int meta = world.getBlockMetadata(x, y, z);
|
|
|
|
|
BlockRoadLine block = (BlockRoadLine) b;
|
|
|
|
|
Tessellator tessellator = Tessellator.instance;
|
|
|
|
|
|
|
|
|
|
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
|
|
|
|
|
|
|
|
|
float f = 1.0F;
|
|
|
|
|
int i1 = block.colorMultiplier(world, x, y, z);
|
|
|
|
|
float f1 = (i1 >> 16 & 255) / 255.0F;
|
|
|
|
|
float f2 = (i1 >> 8 & 255) / 255.0F;
|
|
|
|
|
float f3 = (i1 & 255) / 255.0F;
|
|
|
|
|
|
|
|
|
|
if (EntityRenderer.anaglyphEnable) {
|
|
|
|
|
float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
|
|
|
|
|
float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
|
|
|
|
|
float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
|
|
|
|
|
f1 = f4;
|
|
|
|
|
f2 = f5;
|
|
|
|
|
f3 = f6;
|
|
|
|
|
}
|
|
|
|
|
tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
|
|
|
|
|
|
2015-01-11 19:32:46 -05:00
|
|
|
boolean N = world.getBlock(x, y, z - 1).equals(block) && world.getBlockMetadata(x, y, z - 1) == meta;
|
|
|
|
|
boolean S = world.getBlock(x, y, z + 1).equals(block) && world.getBlockMetadata(x, y, z + 1) == meta;
|
|
|
|
|
boolean W = world.getBlock(x - 1, y, z).equals(block) && world.getBlockMetadata(x - 1, y, z) == meta;
|
|
|
|
|
boolean E = world.getBlock(x + 1, y, z).equals(block) && world.getBlockMetadata(x + 1, y, z) == meta;
|
2015-01-07 19:50:18 -05:00
|
|
|
|
|
|
|
|
if (!N && !S && !W && !E) {
|
|
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (N && S) {
|
|
|
|
|
renderer.uvRotateTop = 0;
|
2015-01-11 21:32:37 +00:00
|
|
|
renderer.overrideBlockTexture = block.fullLineIcon[meta];
|
2015-01-07 19:50:18 -05:00
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (N) {
|
|
|
|
|
renderer.uvRotateTop = 0;
|
2015-01-11 21:32:37 +00:00
|
|
|
renderer.overrideBlockTexture = block.halfLineIcon[meta];
|
2015-01-07 19:50:18 -05:00
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
if (S) {
|
|
|
|
|
renderer.uvRotateTop = 3;
|
2015-01-11 21:32:37 +00:00
|
|
|
renderer.overrideBlockTexture = block.halfLineIcon[meta];
|
2015-01-07 19:50:18 -05:00
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (E && W) {
|
|
|
|
|
renderer.uvRotateTop = 1;
|
2015-01-11 21:32:37 +00:00
|
|
|
renderer.overrideBlockTexture = block.fullLineIcon[meta];
|
2015-01-07 19:50:18 -05:00
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
|
} else {
|
|
|
|
|
if (E) {
|
|
|
|
|
renderer.uvRotateTop = 1;
|
2015-01-11 21:32:37 +00:00
|
|
|
renderer.overrideBlockTexture = block.halfLineIcon[meta];
|
2015-01-07 19:50:18 -05:00
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
if (W) {
|
|
|
|
|
renderer.uvRotateTop = 2;
|
2015-01-11 21:32:37 +00:00
|
|
|
renderer.overrideBlockTexture = block.halfLineIcon[meta];
|
2015-01-07 19:50:18 -05:00
|
|
|
renderer.renderStandardBlock(block, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderer.uvRotateTop = 0;
|
|
|
|
|
renderer.overrideBlockTexture = null;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean shouldRender3DInInventory(int renderId) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getRenderId() {
|
2015-01-11 21:32:37 +00:00
|
|
|
return Chisel.roadLineId;
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
2014-04-21 19:13:15 +01:00
|
|
|
}
|