mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2025-02-17 21:11:26 +01:00
Optional async relighting
This commit is contained in:
parent
505e99b488
commit
33f3cb6ba5
@ -108,7 +108,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
bukkitWorld = Bukkit.getServer().getWorld(world);
|
bukkitWorld = Bukkit.getServer().getWorld(world);
|
||||||
}
|
}
|
||||||
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
|
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
|
||||||
bukkitWorld.loadChunk(loc.x, loc.z);
|
bukkitWorld.loadChunk(loc.x, loc.z, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadQueue.notifyAll();
|
loadQueue.notifyAll();
|
||||||
@ -177,29 +177,39 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendChunk(FaweChunk<Chunk> fc) {
|
public void sendChunk(final FaweChunk<Chunk> fc) {
|
||||||
fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
TaskManager.IMP.task(new Runnable() {
|
||||||
Chunk chunk = fc.getChunk();
|
@Override
|
||||||
World world = chunk.getWorld();
|
public void run() {
|
||||||
final int view = Bukkit.getServer().getViewDistance();
|
fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
||||||
int cx = chunk.getX();
|
TaskManager.IMP.task(new Runnable() {
|
||||||
int cz = chunk.getZ();
|
@Override
|
||||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
public void run() {
|
||||||
if (!player.getWorld().equals(world)) {
|
Chunk chunk = fc.getChunk();
|
||||||
continue;
|
World world = chunk.getWorld();
|
||||||
|
final int view = Bukkit.getServer().getViewDistance();
|
||||||
|
int cx = chunk.getX();
|
||||||
|
int cz = chunk.getZ();
|
||||||
|
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (!player.getWorld().equals(world)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final Location loc = player.getLocation();
|
||||||
|
final int px = loc.getBlockX() >> 4;
|
||||||
|
final int pz = loc.getBlockZ() >> 4;
|
||||||
|
if ((Math.abs(cx - px) > view) || (Math.abs(cz - pz) > view)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final Object entity = methodGetHandlePlayer.of(player).call();
|
||||||
|
final RefExecutor con = send.of(connection.of(entity).get());
|
||||||
|
final Object c = methodGetHandleChunk.of(fc.getChunk()).call();
|
||||||
|
Object packet = MapChunk.create(c, false, 65535);
|
||||||
|
con.call(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
}
|
}
|
||||||
final Location loc = player.getLocation();
|
}, Settings.ASYNC_LIGHTING);
|
||||||
final int px = loc.getBlockX() >> 4;
|
|
||||||
final int pz = loc.getBlockZ() >> 4;
|
|
||||||
if ((Math.abs(cx - px) > view) || (Math.abs(cz - pz) > view)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final Object entity = this.methodGetHandlePlayer.of(player).call();
|
|
||||||
final RefExecutor con = this.send.of(this.connection.of(entity).get());
|
|
||||||
final Object c = this.methodGetHandleChunk.of(fc.getChunk()).call();
|
|
||||||
Object packet = this.MapChunk.create(c, false, 65535);
|
|
||||||
con.call(packet);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -98,7 +98,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
bukkitWorld = Bukkit.getServer().getWorld(world);
|
bukkitWorld = Bukkit.getServer().getWorld(world);
|
||||||
}
|
}
|
||||||
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
|
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
|
||||||
bukkitWorld.loadChunk(loc.x, loc.z);
|
bukkitWorld.loadChunk(loc.x, loc.z, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadQueue.notifyAll();
|
loadQueue.notifyAll();
|
||||||
@ -166,10 +166,20 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendChunk(FaweChunk<Chunk> fc) {
|
public void sendChunk(final FaweChunk<Chunk> fc) {
|
||||||
fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
TaskManager.IMP.task(new Runnable() {
|
||||||
final Chunk chunk = fc.getChunk();
|
@Override
|
||||||
chunk.getWorld().refreshChunk(fc.getX(), fc.getZ());
|
public void run() {
|
||||||
|
fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
||||||
|
TaskManager.IMP.task(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final Chunk chunk = fc.getChunk();
|
||||||
|
chunk.getWorld().refreshChunk(fc.getX(), fc.getZ());
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
}, Settings.ASYNC_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,7 +60,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 {
|
|||||||
bukkitWorld = Bukkit.getServer().getWorld(world);
|
bukkitWorld = Bukkit.getServer().getWorld(world);
|
||||||
}
|
}
|
||||||
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
|
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
|
||||||
bukkitWorld.loadChunk(loc.x, loc.z);
|
bukkitWorld.loadChunk(loc.x, loc.z, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadQueue.notifyAll();
|
loadQueue.notifyAll();
|
||||||
@ -117,6 +117,9 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 {
|
|||||||
ChunkSection nibble = chunkSections[cy];
|
ChunkSection nibble = chunkSections[cy];
|
||||||
lastSection = nibble != null ? nibble.getBlocks() : null;
|
lastSection = nibble != null ? nibble.getBlocks() : null;
|
||||||
} else if (cy != lcy) {
|
} else if (cy != lcy) {
|
||||||
|
if (chunkSections == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
ChunkSection nibble = chunkSections[cy];
|
ChunkSection nibble = chunkSections[cy];
|
||||||
lastSection = nibble != null ? nibble.getBlocks() : null;
|
lastSection = nibble != null ? nibble.getBlocks() : null;
|
||||||
}
|
}
|
||||||
@ -146,10 +149,20 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendChunk(FaweChunk<Chunk> fc) {
|
public void sendChunk(final FaweChunk<Chunk> fc) {
|
||||||
fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
TaskManager.IMP.task(new Runnable() {
|
||||||
final Chunk chunk = fc.getChunk();
|
@Override
|
||||||
chunk.getWorld().refreshChunk(fc.getX(), fc.getZ());
|
public void run() {
|
||||||
|
fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
||||||
|
TaskManager.IMP.task(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final Chunk chunk = fc.getChunk();
|
||||||
|
chunk.getWorld().refreshChunk(fc.getX(), fc.getZ());
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
}, Settings.ASYNC_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -375,6 +388,8 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 {
|
|||||||
int data = lastId & 0xF;
|
int data = lastId & 0xF;
|
||||||
IBlockData ibd = Block.getById(id).fromLegacyData(data);
|
IBlockData ibd = Block.getById(id).fromLegacyData(data);
|
||||||
lastBit = palette.a(ibd);
|
lastBit = palette.a(ibd);
|
||||||
|
palette = (DataPalette) fieldPalette.get(nibble);
|
||||||
|
bits = (DataBits) fieldBits.get(nibble);
|
||||||
}
|
}
|
||||||
bits.a(i, lastBit);
|
bits.a(i, lastBit);
|
||||||
}
|
}
|
||||||
@ -390,20 +405,21 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 {
|
|||||||
case 0:
|
case 0:
|
||||||
int existingBit = bits.a(k);
|
int existingBit = bits.a(k);
|
||||||
if (existingBit != lastBit) {
|
if (existingBit != lastBit) {
|
||||||
|
palette = (DataPalette) fieldPalette.get(nibble);
|
||||||
|
bits = (DataBits) fieldBits.get(nibble);
|
||||||
lastBit = existingBit;
|
lastBit = existingBit;
|
||||||
IBlockData ibd = palette.a(existingBit);
|
IBlockData ibd = palette.a(existingBit);
|
||||||
if (ibd != null) {
|
if (ibd == null) {
|
||||||
Block block = ibd.getBlock();
|
|
||||||
int id = Block.getId(block);
|
|
||||||
if (FaweCache.hasData(id)) {
|
|
||||||
lastId = (id << 4) + block.toLegacyData(ibd);
|
|
||||||
} else {
|
|
||||||
lastId = id << 4;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fill = false;
|
fill = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Block block = ibd.getBlock();
|
||||||
|
int id = Block.getId(block);
|
||||||
|
if (FaweCache.hasData(id)) {
|
||||||
|
lastId = (id << 4) + block.toLegacyData(ibd);
|
||||||
|
} else {
|
||||||
|
lastId = id << 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (lastId != 0) {
|
if (lastId != 0) {
|
||||||
nonEmptyBlockCount++;
|
nonEmptyBlockCount++;
|
||||||
@ -420,6 +436,8 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 {
|
|||||||
int data = lastId & 0xF;
|
int data = lastId & 0xF;
|
||||||
IBlockData ibd = Block.getById(id).fromLegacyData(data);
|
IBlockData ibd = Block.getById(id).fromLegacyData(data);
|
||||||
lastBit = palette.a(ibd);
|
lastBit = palette.a(ibd);
|
||||||
|
palette = (DataPalette) fieldPalette.get(nibble);
|
||||||
|
bits = (DataBits) fieldBits.get(nibble);
|
||||||
}
|
}
|
||||||
bits.a(k, lastBit);
|
bits.a(k, lastBit);
|
||||||
continue;
|
continue;
|
||||||
@ -433,6 +451,8 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 {
|
|||||||
int data = lastId & 0xF;
|
int data = lastId & 0xF;
|
||||||
IBlockData ibd = Block.getById(id).fromLegacyData(data);
|
IBlockData ibd = Block.getById(id).fromLegacyData(data);
|
||||||
lastBit = palette.a(ibd);
|
lastBit = palette.a(ibd);
|
||||||
|
palette = (DataPalette) fieldPalette.get(nibble);
|
||||||
|
bits = (DataBits) fieldBits.get(nibble);
|
||||||
}
|
}
|
||||||
bits.a(k, lastBit);
|
bits.a(k, lastBit);
|
||||||
continue;
|
continue;
|
||||||
|
@ -16,7 +16,6 @@ import java.util.Map.Entry;
|
|||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
public static boolean REQUIRE_SELECTION = false;
|
public static boolean REQUIRE_SELECTION = false;
|
||||||
public static boolean FIX_ALL_LIGHTING = true;
|
|
||||||
public static boolean COMMAND_PROCESSOR = false;
|
public static boolean COMMAND_PROCESSOR = false;
|
||||||
public static List<String> WE_BLACKLIST = Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks");
|
public static List<String> WE_BLACKLIST = Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks");
|
||||||
public static long MEM_FREE = 95;
|
public static long MEM_FREE = 95;
|
||||||
@ -33,6 +32,9 @@ public class Settings {
|
|||||||
public static int QUEUE_DISCARD_AFTER = 60000;
|
public static int QUEUE_DISCARD_AFTER = 60000;
|
||||||
public static List<String> ALLOWED_3RDPARTY_EXTENTS;
|
public static List<String> ALLOWED_3RDPARTY_EXTENTS;
|
||||||
|
|
||||||
|
public static boolean FIX_ALL_LIGHTING = true;
|
||||||
|
public static boolean ASYNC_LIGHTING = true;
|
||||||
|
|
||||||
public static HashMap<String, FaweLimit> limits;
|
public static HashMap<String, FaweLimit> limits;
|
||||||
|
|
||||||
public static FaweLimit getLimit(FawePlayer player) {
|
public static FaweLimit getLimit(FawePlayer player) {
|
||||||
@ -71,7 +73,8 @@ public class Settings {
|
|||||||
options.put("command-processor", COMMAND_PROCESSOR);
|
options.put("command-processor", COMMAND_PROCESSOR);
|
||||||
options.put("max-memory-percent", MEM_FREE);
|
options.put("max-memory-percent", MEM_FREE);
|
||||||
options.put("crash-mitigation", ENABLE_HARD_LIMIT);
|
options.put("crash-mitigation", ENABLE_HARD_LIMIT);
|
||||||
options.put("fix-all-lighting", FIX_ALL_LIGHTING);
|
options.put("lighting.fix-all", FIX_ALL_LIGHTING);
|
||||||
|
options.put("lighting.async", ASYNC_LIGHTING);
|
||||||
options.put("history.use-disk", STORE_HISTORY_ON_DISK);
|
options.put("history.use-disk", STORE_HISTORY_ON_DISK);
|
||||||
options.put("history.compress", false);
|
options.put("history.compress", false);
|
||||||
options.put("history.chunk-wait-ms", CHUNK_WAIT);
|
options.put("history.chunk-wait-ms", CHUNK_WAIT);
|
||||||
@ -99,7 +102,8 @@ public class Settings {
|
|||||||
config.set(node.getKey(), node.getValue());
|
config.set(node.getKey(), node.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FIX_ALL_LIGHTING = config.getBoolean("fix-all-lighting");
|
FIX_ALL_LIGHTING = config.getBoolean("lighting.fix-all");
|
||||||
|
ASYNC_LIGHTING = config.getBoolean("lighting.async");
|
||||||
COMMAND_PROCESSOR = config.getBoolean("command-processor");
|
COMMAND_PROCESSOR = config.getBoolean("command-processor");
|
||||||
MEM_FREE = config.getInt("max-memory-percent");
|
MEM_FREE = config.getInt("max-memory-percent");
|
||||||
REQUIRE_SELECTION = config.getBoolean("require-selection-in-mask");
|
REQUIRE_SELECTION = config.getBoolean("require-selection-in-mask");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.util;
|
package com.boydti.fawe.util;
|
||||||
|
|
||||||
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -16,6 +17,20 @@ public abstract class TaskManager {
|
|||||||
|
|
||||||
public abstract void task(final Runnable r);
|
public abstract void task(final Runnable r);
|
||||||
|
|
||||||
|
public void task(final Runnable r, boolean async) {
|
||||||
|
if (async) {
|
||||||
|
async(r);
|
||||||
|
} else {
|
||||||
|
if (Fawe.get().getMainThread() == Thread.currentThread()) {
|
||||||
|
if (r != null) {
|
||||||
|
r.run();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
task(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void later(final Runnable r, final int delay);
|
public abstract void later(final Runnable r, final int delay);
|
||||||
|
|
||||||
public abstract void laterAsync(final Runnable r, final int delay);
|
public abstract void laterAsync(final Runnable r, final int delay);
|
||||||
|
Loading…
Reference in New Issue
Block a user