259 lines
16 KiB
Java
259 lines
16 KiB
Java
package mods.tinker.tconstruct.client.block;
|
|
|
|
import mods.tinker.tconstruct.blocks.RedstoneBallRepeater;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
import net.minecraft.util.Icon;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
|
|
|
public class BallRepeaterRender implements ISimpleBlockRenderingHandler
|
|
{
|
|
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
|
@Override
|
|
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
|
{
|
|
//Inventory should be an item. This is not here!
|
|
}
|
|
|
|
@Override
|
|
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
|
{
|
|
return renderRedstoneBallRepeater(block, x, y, z, world);
|
|
}
|
|
|
|
@Override
|
|
public boolean shouldRender3DInInventory ()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int getRenderId ()
|
|
{
|
|
return model;
|
|
}
|
|
|
|
public boolean renderRedstoneBallRepeater(Block par1Block, int par2, int par3, int par4, IBlockAccess world)
|
|
{
|
|
Tessellator tessellator = Tessellator.instance;
|
|
int l = world.getBlockMetadata(par2, par3, par4);
|
|
Icon icon = RedstoneBallRepeater.func_94409_b("repeaterDust_cross");
|
|
Icon icon1 = RedstoneBallRepeater.func_94409_b("repeaterDust_line");
|
|
Icon icon2 = RedstoneBallRepeater.func_94409_b("repeaterDust_cross_overlay");
|
|
Icon icon3 = RedstoneBallRepeater.func_94409_b("repeaterDust_line_overlay");
|
|
tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(world, par2, par3, par4));
|
|
float f = 1.0F;
|
|
float f1 = (float)l / 15.0F;
|
|
float f2 = f1 * 0.6F + 0.4F;
|
|
|
|
if (l == 0)
|
|
{
|
|
f2 = 0.3F;
|
|
}
|
|
|
|
float f3 = f1 * f1 * 0.7F - 0.5F;
|
|
float f4 = f1 * f1 * 0.6F - 0.7F;
|
|
|
|
if (f3 < 0.0F)
|
|
{
|
|
f3 = 0.0F;
|
|
}
|
|
|
|
if (f4 < 0.0F)
|
|
{
|
|
f4 = 0.0F;
|
|
}
|
|
|
|
tessellator.setColorOpaque_F(f2, f3, f4);
|
|
boolean flag = RedstoneBallRepeater.isPowerProviderOrWire(world, par2 - 1, par3, par4, 1) || !world.isBlockNormalCube(par2 - 1, par3, par4) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 - 1, par3 - 1, par4, -1);
|
|
boolean flag1 = RedstoneBallRepeater.isPowerProviderOrWire(world, par2 + 1, par3, par4, 3) || !world.isBlockNormalCube(par2 + 1, par3, par4) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 + 1, par3 - 1, par4, -1);
|
|
boolean flag2 = RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3, par4 - 1, 2) || !world.isBlockNormalCube(par2, par3, par4 - 1) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 - 1, par4 - 1, -1);
|
|
boolean flag3 = RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3, par4 + 1, 0) || !world.isBlockNormalCube(par2, par3, par4 + 1) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 - 1, par4 + 1, -1);
|
|
|
|
if (!world.isBlockNormalCube(par2, par3 + 1, par4))
|
|
{
|
|
if (world.isBlockNormalCube(par2 - 1, par3, par4) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 - 1, par3 + 1, par4, -1))
|
|
{
|
|
flag = true;
|
|
}
|
|
|
|
if (world.isBlockNormalCube(par2 + 1, par3, par4) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 + 1, par3 + 1, par4, -1))
|
|
{
|
|
flag1 = true;
|
|
}
|
|
|
|
if (world.isBlockNormalCube(par2, par3, par4 - 1) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 + 1, par4 - 1, -1))
|
|
{
|
|
flag2 = true;
|
|
}
|
|
|
|
if (world.isBlockNormalCube(par2, par3, par4 + 1) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 + 1, par4 + 1, -1))
|
|
{
|
|
flag3 = true;
|
|
}
|
|
}
|
|
|
|
float f5 = (float)(par2 + 0);
|
|
float f6 = (float)(par2 + 1);
|
|
float f7 = (float)(par4 + 0);
|
|
float f8 = (float)(par4 + 1);
|
|
int i1 = 0;
|
|
|
|
if ((flag || flag1) && !flag2 && !flag3)
|
|
{
|
|
i1 = 1;
|
|
}
|
|
|
|
if ((flag2 || flag3) && !flag1 && !flag)
|
|
{
|
|
i1 = 2;
|
|
}
|
|
|
|
if (i1 == 0)
|
|
{
|
|
int j1 = 0;
|
|
int k1 = 0;
|
|
int l1 = 16;
|
|
int i2 = 16;
|
|
|
|
if (!flag)
|
|
{
|
|
f5 += 0.3125F;
|
|
}
|
|
|
|
if (!flag)
|
|
{
|
|
j1 += 5;
|
|
}
|
|
|
|
if (!flag1)
|
|
{
|
|
f6 -= 0.3125F;
|
|
}
|
|
|
|
if (!flag1)
|
|
{
|
|
l1 -= 5;
|
|
}
|
|
|
|
if (!flag2)
|
|
{
|
|
f7 += 0.3125F;
|
|
}
|
|
|
|
if (!flag2)
|
|
{
|
|
k1 += 5;
|
|
}
|
|
|
|
if (!flag3)
|
|
{
|
|
f8 -= 0.3125F;
|
|
}
|
|
|
|
if (!flag3)
|
|
{
|
|
i2 -= 5;
|
|
}
|
|
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f8, (double)icon.getInterpolatedU((double)l1), (double)icon.getInterpolatedV((double)i2));
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f7, (double)icon.getInterpolatedU((double)l1), (double)icon.getInterpolatedV((double)k1));
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f7, (double)icon.getInterpolatedU((double)j1), (double)icon.getInterpolatedV((double)k1));
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f8, (double)icon.getInterpolatedU((double)j1), (double)icon.getInterpolatedV((double)i2));
|
|
tessellator.setColorOpaque_F(f, f, f);
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f8, (double)icon2.getInterpolatedU((double)l1), (double)icon2.getInterpolatedV((double)i2));
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f7, (double)icon2.getInterpolatedU((double)l1), (double)icon2.getInterpolatedV((double)k1));
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f7, (double)icon2.getInterpolatedU((double)j1), (double)icon2.getInterpolatedV((double)k1));
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f8, (double)icon2.getInterpolatedU((double)j1), (double)icon2.getInterpolatedV((double)i2));
|
|
}
|
|
else if (i1 == 1)
|
|
{
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f8, (double)icon1.getMaxU(), (double)icon1.getMaxV());
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f7, (double)icon1.getMaxU(), (double)icon1.getMinV());
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f7, (double)icon1.getMinU(), (double)icon1.getMinV());
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f8, (double)icon1.getMinU(), (double)icon1.getMaxV());
|
|
tessellator.setColorOpaque_F(f, f, f);
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f8, (double)icon3.getMaxU(), (double)icon3.getMaxV());
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f7, (double)icon3.getMaxU(), (double)icon3.getMinV());
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f7, (double)icon3.getMinU(), (double)icon3.getMinV());
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f8, (double)icon3.getMinU(), (double)icon3.getMaxV());
|
|
}
|
|
else
|
|
{
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f8, (double)icon1.getMaxU(), (double)icon1.getMaxV());
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f7, (double)icon1.getMinU(), (double)icon1.getMaxV());
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f7, (double)icon1.getMinU(), (double)icon1.getMinV());
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f8, (double)icon1.getMaxU(), (double)icon1.getMinV());
|
|
tessellator.setColorOpaque_F(f, f, f);
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f8, (double)icon3.getMaxU(), (double)icon3.getMaxV());
|
|
tessellator.addVertexWithUV((double)f6, (double)par3 + 0.015625D, (double)f7, (double)icon3.getMinU(), (double)icon3.getMaxV());
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f7, (double)icon3.getMinU(), (double)icon3.getMinV());
|
|
tessellator.addVertexWithUV((double)f5, (double)par3 + 0.015625D, (double)f8, (double)icon3.getMaxU(), (double)icon3.getMinV());
|
|
}
|
|
|
|
if (!world.isBlockNormalCube(par2, par3 + 1, par4))
|
|
{
|
|
if (world.isBlockNormalCube(par2 - 1, par3, par4) && world.getBlockId(par2 - 1, par3 + 1, par4) == Block.redstoneWire.blockID)
|
|
{
|
|
tessellator.setColorOpaque_F(f * f2, f * f3, f * f4);
|
|
tessellator.addVertexWithUV((double)par2 + 0.015625D, (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 1), (double)icon1.getMaxU(), (double)icon1.getMinV());
|
|
tessellator.addVertexWithUV((double)par2 + 0.015625D, (double)(par3 + 0), (double)(par4 + 1), (double)icon1.getMinU(), (double)icon1.getMinV());
|
|
tessellator.addVertexWithUV((double)par2 + 0.015625D, (double)(par3 + 0), (double)(par4 + 0), (double)icon1.getMinU(), (double)icon1.getMaxV());
|
|
tessellator.addVertexWithUV((double)par2 + 0.015625D, (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 0), (double)icon1.getMaxU(), (double)icon1.getMaxV());
|
|
tessellator.setColorOpaque_F(f, f, f);
|
|
tessellator.addVertexWithUV((double)par2 + 0.015625D, (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 1), (double)icon3.getMaxU(), (double)icon3.getMinV());
|
|
tessellator.addVertexWithUV((double)par2 + 0.015625D, (double)(par3 + 0), (double)(par4 + 1), (double)icon3.getMinU(), (double)icon3.getMinV());
|
|
tessellator.addVertexWithUV((double)par2 + 0.015625D, (double)(par3 + 0), (double)(par4 + 0), (double)icon3.getMinU(), (double)icon3.getMaxV());
|
|
tessellator.addVertexWithUV((double)par2 + 0.015625D, (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 0), (double)icon3.getMaxU(), (double)icon3.getMaxV());
|
|
}
|
|
|
|
if (world.isBlockNormalCube(par2 + 1, par3, par4) && world.getBlockId(par2 + 1, par3 + 1, par4) == Block.redstoneWire.blockID)
|
|
{
|
|
tessellator.setColorOpaque_F(f * f2, f * f3, f * f4);
|
|
tessellator.addVertexWithUV((double)(par2 + 1) - 0.015625D, (double)(par3 + 0), (double)(par4 + 1), (double)icon1.getMinU(), (double)icon1.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1) - 0.015625D, (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 1), (double)icon1.getMaxU(), (double)icon1.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1) - 0.015625D, (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 0), (double)icon1.getMaxU(), (double)icon1.getMinV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1) - 0.015625D, (double)(par3 + 0), (double)(par4 + 0), (double)icon1.getMinU(), (double)icon1.getMinV());
|
|
tessellator.setColorOpaque_F(f, f, f);
|
|
tessellator.addVertexWithUV((double)(par2 + 1) - 0.015625D, (double)(par3 + 0), (double)(par4 + 1), (double)icon3.getMinU(), (double)icon3.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1) - 0.015625D, (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 1), (double)icon3.getMaxU(), (double)icon3.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1) - 0.015625D, (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 0), (double)icon3.getMaxU(), (double)icon3.getMinV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1) - 0.015625D, (double)(par3 + 0), (double)(par4 + 0), (double)icon3.getMinU(), (double)icon3.getMinV());
|
|
}
|
|
|
|
if (world.isBlockNormalCube(par2, par3, par4 - 1) && world.getBlockId(par2, par3 + 1, par4 - 1) == Block.redstoneWire.blockID)
|
|
{
|
|
tessellator.setColorOpaque_F(f * f2, f * f3, f * f4);
|
|
tessellator.addVertexWithUV((double)(par2 + 1), (double)(par3 + 0), (double)par4 + 0.015625D, (double)icon1.getMinU(), (double)icon1.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1), (double)((float)(par3 + 1) + 0.021875F), (double)par4 + 0.015625D, (double)icon1.getMaxU(), (double)icon1.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 0), (double)((float)(par3 + 1) + 0.021875F), (double)par4 + 0.015625D, (double)icon1.getMaxU(), (double)icon1.getMinV());
|
|
tessellator.addVertexWithUV((double)(par2 + 0), (double)(par3 + 0), (double)par4 + 0.015625D, (double)icon1.getMinU(), (double)icon1.getMinV());
|
|
tessellator.setColorOpaque_F(f, f, f);
|
|
tessellator.addVertexWithUV((double)(par2 + 1), (double)(par3 + 0), (double)par4 + 0.015625D, (double)icon3.getMinU(), (double)icon3.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1), (double)((float)(par3 + 1) + 0.021875F), (double)par4 + 0.015625D, (double)icon3.getMaxU(), (double)icon3.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 0), (double)((float)(par3 + 1) + 0.021875F), (double)par4 + 0.015625D, (double)icon3.getMaxU(), (double)icon3.getMinV());
|
|
tessellator.addVertexWithUV((double)(par2 + 0), (double)(par3 + 0), (double)par4 + 0.015625D, (double)icon3.getMinU(), (double)icon3.getMinV());
|
|
}
|
|
|
|
if (world.isBlockNormalCube(par2, par3, par4 + 1) && world.getBlockId(par2, par3 + 1, par4 + 1) == Block.redstoneWire.blockID)
|
|
{
|
|
tessellator.setColorOpaque_F(f * f2, f * f3, f * f4);
|
|
tessellator.addVertexWithUV((double)(par2 + 1), (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 1) - 0.015625D, (double)icon1.getMaxU(), (double)icon1.getMinV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1), (double)(par3 + 0), (double)(par4 + 1) - 0.015625D, (double)icon1.getMinU(), (double)icon1.getMinV());
|
|
tessellator.addVertexWithUV((double)(par2 + 0), (double)(par3 + 0), (double)(par4 + 1) - 0.015625D, (double)icon1.getMinU(), (double)icon1.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 0), (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 1) - 0.015625D, (double)icon1.getMaxU(), (double)icon1.getMaxV());
|
|
tessellator.setColorOpaque_F(f, f, f);
|
|
tessellator.addVertexWithUV((double)(par2 + 1), (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 1) - 0.015625D, (double)icon3.getMaxU(), (double)icon3.getMinV());
|
|
tessellator.addVertexWithUV((double)(par2 + 1), (double)(par3 + 0), (double)(par4 + 1) - 0.015625D, (double)icon3.getMinU(), (double)icon3.getMinV());
|
|
tessellator.addVertexWithUV((double)(par2 + 0), (double)(par3 + 0), (double)(par4 + 1) - 0.015625D, (double)icon3.getMinU(), (double)icon3.getMaxV());
|
|
tessellator.addVertexWithUV((double)(par2 + 0), (double)((float)(par3 + 1) + 0.021875F), (double)(par4 + 1) - 0.015625D, (double)icon3.getMaxU(), (double)icon3.getMaxV());
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|