Fixes fixlighting

Relates to #140
This commit is contained in:
Jesse Boyd 2016-06-06 17:04:16 +10:00
parent dbaa587530
commit ed08bf8a9c
3 changed files with 78 additions and 26 deletions

View File

@ -476,16 +476,49 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
return false;
}
ChunkSection[] sections = nmsChunk.getSections();
final boolean flag = craftChunk.getWorld().getEnvironment() == World.Environment.NORMAL;
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
section.a(new NibbleArray());
if (flag) {
section.b(new NibbleArray());
}
}
}
}
nmsChunk.initLighting();
if (flag) {
if (mode == RelightMode.ALL) {
nmsChunk.initLighting();
} else {
int i = nmsChunk.g();
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
int l = 15;
int y = i + 16 - 1;
do {
int opacity = nmsChunk.getTypeAbs(x, y, z).p();
if (opacity == 0 && l != 15) {
opacity = 1;
}
l -= opacity;
if (l > 0) {
ChunkSection section = sections[y >> 4];
if (section != null) {
section.a(x, y & 15, z, l);
}
}
--y;
} while (y > 0 && l > 0);
}
}
}
}
if (fc.getTotalRelight() == 0 && mode == RelightMode.MINIMAL) {
return true;
}
@ -503,6 +536,9 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
continue;
}
char[] array = section.getIdArray();
if (array == null) {
continue;
}
if (mode == RelightMode.ALL) {
for (int k = array.length - 1; k >= 0; k--) {
final int x = FaweCache.CACHE_X[j][k];

View File

@ -200,38 +200,43 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
chunk.load(false);
}
net.minecraft.server.v1_9_R2.Chunk c = ((CraftChunk) chunk).getHandle();
final boolean flag = chunk.getWorld().getEnvironment() == Environment.NORMAL;
ChunkSection[] sections = c.getSections();
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
section.a(new NibbleArray());
if (flag) {
section.b(new NibbleArray());
}
}
}
final boolean flag = chunk.getWorld().getEnvironment() == Environment.NORMAL;
if (flag)
{
}
if (flag) {
if (mode == RelightMode.ALL) {
c.initLighting();
} else {
int i = c.g();
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
int l = 15;
int i1 = i + 16 - 1;
int y = i + 16 - 1;
do {
int opacity = c.a(x, i1, z).c();
int opacity = c.a(x, y, z).c();
if (opacity == 0 && l != 15) {
opacity = 1;
}
l -= opacity;
if (l > 0) {
ChunkSection section = sections[i1 >> 4];
ChunkSection section = sections[y >> 4];
if (section != null) {
section.a(x, i1 & 15, z, l);
section.a(x, y & 15, z, l);
}
}
--i1;
} while (i1 > 0 && l > 0);
--y;
} while (y > 0 && l > 0);
}
}
}
}
@ -310,7 +315,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
}
}
return true;
} catch (final Throwable e) {
} catch (Throwable e) {
if (Thread.currentThread() == Fawe.get().getMainThread()) {
MainUtil.handleError(e);
}

View File

@ -7,6 +7,7 @@ import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager;
@ -402,7 +403,12 @@ public abstract class FawePlayer<T> {
try {
run.run();
} catch (Throwable e) {
e.printStackTrace();
FaweException faweException = FaweException.get(e);
if (faweException != null) {
BBC.WORLDEDIT_CANCEL_REASON.send(FawePlayer.this, faweException.getMessage());
} else {
MainUtil.handleError(e);
}
} finally {
deleteMeta("fawe_action");
}
@ -420,7 +426,12 @@ public abstract class FawePlayer<T> {
try {
run.run();
} catch (Throwable e) {
e.printStackTrace();
FaweException faweException = FaweException.get(e);
if (faweException != null) {
BBC.WORLDEDIT_CANCEL_REASON.send(FawePlayer.this, faweException.getMessage());
} else {
MainUtil.handleError(e);
}
} finally {
deleteMeta("fawe_action");
}