use of blusunrize.immersiveengineering.common.blocks.BlockFakeLight.TileEntityFakeLight in project ImmersiveEngineering by BluSunrize.
the class TileEntityFloodlight method updateFakeLights.
public void updateFakeLights(boolean deleteOld, boolean genNew) {
Iterator<BlockPos> it = this.fakeLights.iterator();
ArrayList<BlockPos> tempRemove = new ArrayList<BlockPos>();
while (it.hasNext()) {
BlockPos cc = it.next();
TileEntity te = worldObj.getTileEntity(cc);
if (te instanceof TileEntityFakeLight) {
if (deleteOld)
tempRemove.add(cc);
} else
it.remove();
}
if (genNew) {
float angle = (float) (facing == EnumFacing.NORTH ? 180 : facing == EnumFacing.EAST ? 90 : facing == EnumFacing.WEST ? -90 : 0);
float yRotation = rotY;
double angleX = Math.toRadians(rotX);
Vec3d[] rays = { /*Straight*/
new Vec3d(0, 0, 1), /*U,D,L,R*/
new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), /*Intermediate*/
new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), /*Diagonal*/
new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1), new Vec3d(0, 0, 1) };
Matrix4 mat = new Matrix4();
if (side == EnumFacing.DOWN)
mat.scale(1, -1, 1);
else if (side != EnumFacing.UP) {
angle = facing == EnumFacing.DOWN ? 180 : facing == EnumFacing.NORTH ? -90 : facing == EnumFacing.SOUTH ? 90 : angle;
if (side.getAxis() == Axis.X) {
mat.rotate(Math.PI / 2, -1, 0, 0);
mat.rotate(Math.PI / 2, 0, 0, -side.getAxisDirection().getOffset());
} else {
mat.rotate(Math.PI / 2, -1, 0, 0);
if (//I dunno why south is giving me so much trouble, but this works, so who cares
side == EnumFacing.SOUTH) {
mat.rotate(Math.PI, 0, 0, 1);
if (facing.getAxis() == Axis.X)
angle = -angle;
}
}
}
double angleY = Math.toRadians(angle + yRotation);
mat.rotate(angleY, 0, 1, 0);
mat.rotate(-angleX, 1, 0, 0);
rays[0] = mat.apply(rays[0]);
mat.rotate(Math.PI / 8, 0, 1, 0);
rays[1] = mat.apply(rays[1]);
mat.rotate(-Math.PI / 16, 0, 1, 0);
rays[5] = mat.apply(rays[5]);
mat.rotate(-Math.PI / 8, 0, 1, 0);
rays[6] = mat.apply(rays[6]);
mat.rotate(-Math.PI / 16, 0, 1, 0);
rays[2] = mat.apply(rays[2]);
mat.rotate(Math.PI / 8, 0, 1, 0);
mat.rotate(Math.PI / 8, 1, 0, 0);
rays[3] = mat.apply(rays[3]);
mat.rotate(-Math.PI / 16, 1, 0, 0);
rays[7] = mat.apply(rays[7]);
mat.rotate(-Math.PI / 8, 1, 0, 0);
rays[8] = mat.apply(rays[8]);
mat.rotate(-Math.PI / 16, 1, 0, 0);
rays[4] = mat.apply(rays[4]);
mat.rotate(Math.PI / 8, 1, 0, 0);
mat.rotate(Math.PI / 16, 1, 0, 0);
mat.rotate(Math.PI / 16, 0, 1, 0);
rays[9] = mat.apply(rays[9]);
mat.rotate(-Math.PI / 8, 0, 1, 0);
rays[10] = mat.apply(rays[10]);
mat.rotate(-Math.PI / 8, 1, 0, 0);
rays[11] = mat.apply(rays[11]);
mat.rotate(Math.PI / 8, 0, 1, 0);
rays[12] = mat.apply(rays[12]);
for (int ray = 0; ray < rays.length; ray++) {
int offset = ray == 0 ? 0 : ray < 4 ? 3 : 1;
placeLightAlongVector(rays[ray], offset, tempRemove);
}
}
this.lightsToBeRemoved.addAll(tempRemove);
}
Aggregations