Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
LightAPI: format code
Browse files Browse the repository at this point in the history
Change-Id: I3f91a5dd3f3ab488509f63e8d50855fd4be00988
  • Loading branch information
BeYkeRYkt committed Jun 17, 2019
1 parent b36692f commit 3a1aacb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@
*/
public class NMS_v1_14_R1 extends NMSLightHandler {

private static Field cachedMailboxField;
private static Method cachedMailboxMethod;
private Field cachedMailboxField;
private Method cachedMailboxMethod;
private ReentrantLock locker = new ReentrantLock();

private static Field getMailboxField(Object lightEngine) throws NoSuchFieldException, SecurityException {
private Field getMailboxField(Object lightEngine) throws NoSuchFieldException, SecurityException {
if (cachedMailboxField == null) {
cachedMailboxField = lightEngine.getClass().getDeclaredField("b");
cachedMailboxField.setAccessible(true);
}
return cachedMailboxField;
}

private static Method getCheckMailboxMethod(Object lightEngine) throws NoSuchMethodException, SecurityException {
private Method getCheckMailboxMethod(Object lightEngine) throws NoSuchMethodException, SecurityException {
if (cachedMailboxMethod == null) {
cachedMailboxMethod = lightEngine.getClass().getDeclaredMethod("d");
cachedMailboxMethod.setAccessible(true);
Expand Down Expand Up @@ -192,12 +192,12 @@ public void setRawLightLevel(World world, LightType type, int blockX, int blockY

// no relight while ThreadMailbox is working
if (isThreadMailboxWorking(lightEngine)) {
try {
while (isThreadMailboxWorking(lightEngine)) {
while (isThreadMailboxWorking(lightEngine)) {
try {
Thread.sleep(50L); // TEMP FIX: wait a tick
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}

Expand Down Expand Up @@ -267,7 +267,6 @@ public void recalculateLighting(World world, LightType type, int blockX, int blo
try {
Thread.sleep(50L); // TEMP FIX: wait a tick
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Expand Down Expand Up @@ -333,24 +332,20 @@ public List<IChunkData> collectChunks(World world, int x, int y, int z, int ligh
}
int radiusBlocks = lightlevel;
List<IChunkData> list = new CopyOnWriteArrayList<IChunkData>();
try {
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
for (int dX = -radiusBlocks; dX <= radiusBlocks; dX += radiusBlocks) {
for (int dZ = -radiusBlocks; dZ <= radiusBlocks; dZ += radiusBlocks) {
int chunkX = (x + dX) >> 4;
int chunkZ = (z + dZ) >> 4;
if (nmsWorld.isChunkLoaded(chunkX, chunkZ)) {
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
IChunkData cCoord = new BukkitChunkData(world, chunk.getPos().x, y, chunk.getPos().z,
world.getPlayers());
if (chunk.isNeedsSaving() && !list.contains(cCoord)) {
list.add(cCoord);
}
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
for (int dX = -radiusBlocks; dX <= radiusBlocks; dX += radiusBlocks) {
for (int dZ = -radiusBlocks; dZ <= radiusBlocks; dZ += radiusBlocks) {
int chunkX = (x + dX) >> 4;
int chunkZ = (z + dZ) >> 4;
if (nmsWorld.isChunkLoaded(chunkX, chunkZ)) {
Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ);
IChunkData cCoord = new BukkitChunkData(world, chunk.getPos().x, y, chunk.getPos().z,
world.getPlayers());
if (chunk.isNeedsSaving() && !list.contains(cCoord)) {
list.add(cCoord);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public enum LReason {
* N/A
*/
THROW_EXCEPTION(3),

/**
* N/A
*/
Expand Down

0 comments on commit 3a1aacb

Please sign in to comment.