Skip to content

Instantly share code, notes, and snippets.

@Keridos
Created November 28, 2014 15:36
Show Gist options
  • Save Keridos/787576e7b6beb15eba4e to your computer and use it in GitHub Desktop.
Save Keridos/787576e7b6beb15eba4e to your computer and use it in GitHub Desktop.
private void wideConeSource(int sourceX, int sourceY, int sourceZ, ForgeDirection direction, boolean remove) {
for (int i = 1; i <= configHandler.rangeConeFloodlight / 2; i++) {
for (int j = 1; j <= 8; j++) {
int a = i;
int b = 0;
int c = 0;
switch (j) {
case 0:
b += i;
case 1:
b -= i;
case 2:
c += i;
case 3:
c -= i;
case 4:
b += i;
c += i;
case 5:
b += i;
c -= i;
case 6:
b -= i;
c += i;
case 7:
b -= i;
c -= i;
}
int[] rotatedCoords = rotate(a, b, c, direction);
int x = sourceX + rotatedCoords[0];
int y = sourceY + rotatedCoords[1];
int z = sourceZ + rotatedCoords[2];
LightBlockHandle handler = getFloodlightHandler(x, y, z);
if (world.getBlock(x, y, z).isAir(world, x, y, z)) {
if (remove ) {
lightBlocks.get(lightBlocks.indexOf(handler)).removeSource(sourceX, sourceY, sourceZ);
} else {
lightBlocks.get(lightBlocks.indexOf(handler)).addSource(sourceX, sourceY, sourceZ);
}
} else if (world.getBlock(x, y, z).isOpaqueCube() && !remove) {
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment