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
|
package ihl.enviroment;
import java.util.BitSet;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ihl.ClientProxy;
import ihl.IHLMod;
@SideOnly(value=Side.CLIENT)
public class LightSource {
private final int centerX;
private final int centerY;
private final int centerZ;
public int fromX;
public int fromY;
public int fromZ;
public int toX;
public int toY;
public int toZ;
private final int red;
private final int green;
private final int blue;
private final int power;
public final BitSet illuminatedBlocks = new BitSet();
public LightSource(int centerX1, int centerY1, int centerZ1,
int red1, int green1, int blue1, int power1) {
centerX = centerX1;
centerY = centerY1;
centerZ = centerZ1;
red = red1;
green = green1;
blue = blue1;
power = power1;
}
public void setBorders(int fromX1, int fromY1, int fromZ1,
int toX1, int toY1, int toZ1)
{
fromX=fromX1;
fromY=fromY1;
fromZ=fromZ1;
toX=toX1;
toY=toY1;
toZ=toZ1;
}
public boolean isBlockIlluminated(int x, int y, int z) {
if(x<fromX || x>toX || y<fromY || y>toY || z<fromZ || z>toZ)
{
return false;
}
else
{
int rx = x - centerX;
int ry = y - centerY;
int rz = z - centerZ;
int l = ((ClientProxy)IHLMod.proxy).getLightHandler().encodeXYZ(rx, ry, rz);
return illuminatedBlocks.get(l);
}
}
public int[] getLightValue(int x, int y, int z, int[] normal) {
int dx = centerX-x;
int dy = centerY-y;
int dz = centerZ-z;
int d = dx*dx+dy*dy+dz*dz;
dx=normal[0]*dx;
dy=normal[1]*dy;
dz=normal[2]*dz;
dx=dx>0?(dx<<16)/d:0;
dy=dy>0?(dy<<16)/d:0;
dz=dz>0?(dz<<16)/d:0;
int brightness = Math.min(power*(dx+dy+dz)>>16,255);
return new int[]{brightness, this.red, this.blue, this.green};
}
}
|