diff options
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java')
| -rwxr-xr-x | src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java | 184 |
1 files changed, 109 insertions, 75 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java index a60c8cc..f8344b6 100755 --- a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java +++ b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java @@ -33,9 +33,12 @@ public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler { GL11.glDisable(GL11.GL_LIGHTING);
tessellator.startDrawingQuads();
if (metadata < 16)
- tessellator.setColorRGBA_I(BlockCrystal.colors[metadata], 100);
+ tessellator.setColorRGBA_I(
+ BlockCrystal.colors[metadata],
+ 100);
GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
- this.renderWorldBlock(null, 0, 0, 0, block, modelID, renderer);
+ this.renderWorldBlock(null, 0, 0, 0, block, modelID,
+ renderer);
tessellator.draw();
GL11.glTranslatef(0.5f, 0.5f, 0.5f);
GL11.glEnable(GL11.GL_LIGHTING);
@@ -44,7 +47,8 @@ public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler { @Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y,
- int z, Block block, int modelId, RenderBlocks renderer) {
+ int z, Block block, int modelId,
+ RenderBlocks renderer) {
int crystals = 5;
Random rnd = new Random();
Tessellator tessellator = Tessellator.instance;
@@ -56,8 +60,11 @@ public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler { tessellator.addTranslation(x, y, z);
if (world != null && world.getTileEntity(x, y, z) != null
&& ConfigHandler.CRYSTAL_GLOW)
- tessellator.setBrightness(((TileEntityCrystal) world
- .getTileEntity(x, y, z)).shine);
+ tessellator.setBrightness(
+ ((TileEntityCrystal) world
+ .getTileEntity(x,
+ y,
+ z)).shine);
else
tessellator.setBrightness(230);
// 37435, 76464
@@ -67,37 +74,47 @@ public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler { rnd.setSeed(76464);
if (world != null && world.getBlockMetadata(x, y, z) < 16)
tessellator.setColorRGBA_I(
- BlockCrystal.colors[world.getBlockMetadata(x, y, z)],
+ BlockCrystal.colors[world
+ .getBlockMetadata(
+ x,
+ y,
+ z)],
100);
- crystal(tessellator, umin, vmin, umax, vmax, 0.8D, 0.2D, 0D, 0D,
- 0D, 0.0D, 0.0D);
+ crystal(tessellator, umin, vmin, umax, vmax, 0.8D, 0.2D,
+ 0D, 0D, 0D, 0.0D, 0.0D);
for (int i = 0; i < crystals; i++) {
double rotation = Math.PI * 2.0f / crystals * i;
- double xp1 =
- Math.sin(rotation) * ((0.15F + rnd.nextFloat()) / 2f);
- double zp1 =
- Math.cos(rotation) * ((0.15F + rnd.nextFloat()) / 2f);
+ double xp1 = Math.sin(rotation)
+ * ((0.15F + rnd.nextFloat()) / 2f);
+ double zp1 = Math.cos(rotation)
+ * ((0.15F + rnd.nextFloat()) / 2f);
double height = 0.2f + rnd.nextFloat();
double topHeight = 0.1f + rnd.nextFloat() / 2f;
- crystal(tessellator, umin, vmin, umax, vmax, height, topHeight,
- -xp1, 0D, zp1, xp1, zp1);
+ crystal(tessellator, umin, vmin, umax, vmax,
+ height, topHeight, -xp1, 0D, zp1,
+ xp1, zp1);
}
if (world != null) {
crystals = 4;
for (int i = 0; i < crystals; i++) {
- double rotation = Math.PI * 2F / crystals * i;
- double xp1 = Math.sin(rotation)
- * ((0.15F + rnd.nextFloat()) / 2f);
- double zp1 = Math.cos(rotation)
- * ((0.15F + rnd.nextFloat()) / 2f);
+ double rotation = Math.PI * 2F / crystals
+ * i;
+ double xp1 = Math.sin(rotation) * ((0.15F
+ + rnd.nextFloat()) / 2f);
+ double zp1 = Math.cos(rotation) * ((0.15F
+ + rnd.nextFloat()) / 2f);
double height = 0.1f + rnd.nextFloat();
- double topHeight = 0.1f + rnd.nextFloat() / 2f;
- float xOff = (rnd.nextFloat() * 1.5f - 0.5f)
+ double topHeight = 0.1f
+ + rnd.nextFloat() / 2f;
+ float xOff = (rnd.nextFloat() * 1.5f
+ - 0.5f)
* (rnd.nextFloat() / 2f);
- float zOff = (rnd.nextFloat() * 1.5f - 0.5f)
+ float zOff = (rnd.nextFloat() * 1.5f
+ - 0.5f)
* (rnd.nextFloat() / 2f);
- crystal(tessellator, umin, vmin, umax, vmax, height,
- topHeight, xOff, 0D, zOff, xp1, zp1);
+ crystal(tessellator, umin, vmin, umax,
+ vmax, height, topHeight,
+ xOff, 0D, zOff, xp1, zp1);
}
}
tessellator.addTranslation(-x, -y, -z);
@@ -105,89 +122,106 @@ public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler { }
private static void crystal(Tessellator tessellator, double umin,
- double vmin, double umax, double vmax, double height,
- double topHeight, double posX, double posY, double posZ,
- double rotX, double rotZ) {
+ double vmin, double umax, double vmax,
+ double height, double topHeight, double posX,
+ double posY, double posZ, double rotX,
+ double rotZ) {
// Negative X
tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY,
0.6 - rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY,
- 0.6 + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY,
- 0.4 + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX,
+ height + posY, 0.6 + rotZ + posZ, umin,
+ vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX,
+ height + posY, 0.4 + rotZ + posZ, umax,
+ vmax);
tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY,
0.4 - rotZ + posZ, umax, vmin);
// Positive X
tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY,
0.4 - rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY,
- 0.4 + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY,
- 0.6 + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX,
+ height + posY, 0.4 + rotZ + posZ, umin,
+ vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX,
+ height + posY, 0.6 + rotZ + posZ, umax,
+ vmax);
tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY,
0.6 - rotZ + posZ, umax, vmin);
// Negative Z
tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY,
0.4 - rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY,
- 0.4 + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY,
- 0.4 + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX,
+ height + posY, 0.4 + rotZ + posZ, umin,
+ vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX,
+ height + posY, 0.4 + rotZ + posZ, umax,
+ vmax);
tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY,
0.4 - rotZ + posZ, umax, vmin);
// Positive Z
tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY,
0.6 - rotZ + posZ, umin, vmin);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY,
- 0.6 + rotZ + posZ, umin, vmax);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY,
- 0.6 + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX,
+ height + posY, 0.6 + rotZ + posZ, umin,
+ vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX,
+ height + posY, 0.6 + rotZ + posZ, umax,
+ vmax);
tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY,
0.6 - rotZ + posZ, umax, vmin);
// Top -X
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY,
- 0.6 + rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.4 - rotX + posX,
+ height + posY, 0.6 + rotZ + posZ, umin,
+ vmin);
tessellator.addVertexWithUV(0.5 - rotX - rotX + posX,
- height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin,
- vmax);
+ height + topHeight + posY,
+ 0.5 + rotZ + rotZ + posZ, umin, vmax);
tessellator.addVertexWithUV(0.5 - rotX - rotX + posX,
- height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax,
- vmax);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY,
- 0.4 + rotZ + posZ, umax, vmin);
+ height + topHeight + posY,
+ 0.5 + rotZ + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX,
+ height + posY, 0.4 + rotZ + posZ, umax,
+ vmin);
// Top +X
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY,
- 0.4 + rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.6 - rotX + posX,
+ height + posY, 0.4 + rotZ + posZ, umin,
+ vmin);
tessellator.addVertexWithUV(0.5 - rotX - rotX + posX,
- height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin,
- vmax);
+ height + topHeight + posY,
+ 0.5 + rotZ + rotZ + posZ, umin, vmax);
tessellator.addVertexWithUV(0.5 - rotX - rotX + posX,
- height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax,
- vmax);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY,
- 0.6 + rotZ + posZ, umax, vmin);
+ height + topHeight + posY,
+ 0.5 + rotZ + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX,
+ height + posY, 0.6 + rotZ + posZ, umax,
+ vmin);
// Top +Z
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY,
- 0.6 + rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.6 - rotX + posX,
+ height + posY, 0.6 + rotZ + posZ, umin,
+ vmin);
tessellator.addVertexWithUV(0.5 - rotX - rotX + posX,
- height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin,
- vmax);
+ height + topHeight + posY,
+ 0.5 + rotZ + rotZ + posZ, umin, vmax);
tessellator.addVertexWithUV(0.5 - rotX - rotX + posX,
- height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax,
- vmax);
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY,
- 0.6 + rotZ + posZ, umax, vmin);
+ height + topHeight + posY,
+ 0.5 + rotZ + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.4 - rotX + posX,
+ height + posY, 0.6 + rotZ + posZ, umax,
+ vmin);
// Top -Z
- tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY,
- 0.4 + rotZ + posZ, umin, vmin);
+ tessellator.addVertexWithUV(0.4 - rotX + posX,
+ height + posY, 0.4 + rotZ + posZ, umin,
+ vmin);
tessellator.addVertexWithUV(0.5 - rotX - rotX + posX,
- height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin,
- vmax);
+ height + topHeight + posY,
+ 0.5 + rotZ + rotZ + posZ, umin, vmax);
tessellator.addVertexWithUV(0.5 - rotX - rotX + posX,
- height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax,
- vmax);
- tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY,
- 0.4 + rotZ + posZ, umax, vmin);
+ height + topHeight + posY,
+ 0.5 + rotZ + rotZ + posZ, umax, vmax);
+ tessellator.addVertexWithUV(0.6 - rotX + posX,
+ height + posY, 0.4 + rotZ + posZ, umax,
+ vmin);
// Bottom
tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY,
0.6 - rotZ + posZ, umin, vmin);
|
