summaryrefslogtreecommitdiff
path: root/ihl/model/RenderBlocksExt.java
blob: b4b334a2f75218b78f8382cf6c86e01561dfaba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package ihl.model;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;

import java.util.HashSet;
import java.util.Set;

import cpw.mods.fml.relauncher.SideOnly;
import cpw.mods.fml.relauncher.Side;
import ihl.ClientProxy;
import ihl.IHLMod;
import ihl.enviroment.LightSource;

@SideOnly(value=Side.CLIENT)
public class RenderBlocksExt extends RenderBlocks {

	public static RenderBlocksExt instance;
	private final int[] YNEG = new int[] { 0, -1, 0 };
	private final int[] YPOS = new int[] { 0, 1, 0 };
	private final int[] XNEG = new int[] { -1, 0, 0 };
	private final int[] XPOS = new int[] { 1, 0, 0 };
	private final int[] ZNEG = new int[] { 0, 0, -1 };
	private final int[] ZPOS = new int[] { 0, 0, 1 };
	private final int BRIGHT = 0x0000FF;
	private final int DARK = 0x000000;

	public RenderBlocksExt(IBlockAccess blockAccess) {
		super(blockAccess);
		instance = this;
	}

	private void transformColour(int x, int y, int z, int[] normal) {
		/*		for (LightSource lightSource : ((ClientProxy)IHLMod.proxy).getLightHandler().lightSources) {
			if (lightSource.isBlockIlluminated(x, y, z)) {
				int[] lightValue = lightSource.getLightValue((int) x, (int) y, (int) z, normal);
				System.out.println("this.brightnessBottomRight="+this.brightnessBottomRight);
				this.brightnessTopLeft |= lightValue[0];
				this.brightnessBottomLeft |= lightValue[0];
				this.brightnessTopRight |= lightValue[0];
				this.brightnessBottomRight |= lightValue[0];
				this.colorRedTopLeft *= (255 - lightValue[0]) * lightValue[1] / 255 / 255f;
				this.colorRedBottomLeft *= (255 - lightValue[0]) * lightValue[1] / 255 / 255f;
				this.colorRedTopRight *= (255 - lightValue[0]) * lightValue[1] / 255 / 255f;
				this.colorRedBottomRight *= (255 - lightValue[0]) * lightValue[1] / 255 / 255f;
				this.colorBlueTopLeft *= (255 - lightValue[0]) * lightValue[2] / 255 / 255f;
				this.colorBlueBottomLeft *= (255 - lightValue[0]) * lightValue[2] / 255 / 255f;
				this.colorBlueTopRight *= (255 - lightValue[0]) * lightValue[2] / 255 / 255f;
				this.colorBlueBottomRight *= (255 - lightValue[0]) * lightValue[2] / 255 / 255f;
				this.colorGreenTopLeft *= (255 - lightValue[0]) * lightValue[3] / 255 / 255f;
				this.colorGreenBottomLeft *= (255 - lightValue[0]) * lightValue[3] / 255 / 255f;
				this.colorGreenTopRight *= (255 - lightValue[0]) * lightValue[3] / 255 / 255f;
				this.colorGreenBottomRight *= (255 - lightValue[0]) * lightValue[3] / 255 / 255f;
			}
		}*/
	}

	@Override
	public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
		this.transformColour((int) x, (int) y, (int) z, YNEG);
		super.renderFaceYNeg(block, x, y, z, icon);
	}

	@Override
	public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
		this.transformColour((int) x, (int) y, (int) z, YPOS);
		super.renderFaceYPos(block, x, y, z, icon);
	}

	@Override
	public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
		this.transformColour((int) x, (int) y, (int) z, ZNEG);
		super.renderFaceZNeg(block, x, y, z, icon);
	}

	@Override
	public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
		this.transformColour((int) x, (int) y, (int) z, ZPOS);
		super.renderFaceZPos(block, x, y, z, icon);
	}

	@Override
	public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
		this.transformColour((int) x, (int) y, (int) z, XNEG);
		super.renderFaceXNeg(block, x, y, z, icon);
	}

	@Override
	public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
		this.transformColour((int) x, (int) y, (int) z, XPOS);
		super.renderFaceXPos(block, x, y, z, icon);
	}
}