From 19a9db3abff40cff028c382e2df39a7128543cee Mon Sep 17 00:00:00 2001 From: Joey Date: Sun, 29 Apr 2018 17:40:48 +0200 Subject: [PATCH] Added a "Keep entities in non-air blocks" setting --- .../java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java | 2 +- .../java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java | 2 +- .../java/com/boydti/fawe/bukkit/v1_12/BukkitChunk_1_12.java | 3 ++- .../java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java | 2 +- .../java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java | 2 +- .../java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java | 2 +- core/src/main/java/com/boydti/fawe/config/Settings.java | 6 ++++++ .../java/com/boydti/fawe/forge/v110/ForgeChunk_All.java | 2 +- .../java/com/boydti/fawe/forge/v111/ForgeChunk_All.java | 2 +- .../java/com/boydti/fawe/forge/v112/ForgeChunk_All.java | 2 +- .../java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java | 2 +- .../java/com/boydti/fawe/forge/v189/ForgeChunk_All.java | 2 +- .../java/com/boydti/fawe/forge/v194/ForgeChunk_All.java | 2 +- .../boydti/fawe/nukkit/optimization/queue/NukkitChunk.java | 2 +- .../java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java | 2 +- .../java/com/boydti/fawe/sponge/v1_12/SpongeChunk_1_12.java | 2 +- 16 files changed, 22 insertions(+), 15 deletions(-) diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java index 7a555c7d..ae00740d 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java @@ -247,7 +247,7 @@ public class BukkitChunk_1_10 extends CharFaweChunk { ents.clear(); } } - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { Collection ents = entities[i]; if (!ents.isEmpty()) { char[] array = this.getIdArray(i); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java index a72cd028..f6ea93dc 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java @@ -268,7 +268,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk ents = entities[i]; if (!ents.isEmpty()) { char[] array = this.getIdArray(i); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_12/BukkitChunk_1_12.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_12/BukkitChunk_1_12.java index a8cf4d1c..c432a666 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_12/BukkitChunk_1_12.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_12/BukkitChunk_1_12.java @@ -3,6 +3,7 @@ package com.boydti.fawe.bukkit.v1_12; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.bukkit.v0.BukkitQueue_0; +import com.boydti.fawe.config.Settings; import com.boydti.fawe.example.CharFaweChunk; import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweQueue; @@ -246,7 +247,7 @@ public class BukkitChunk_1_12 extends CharFaweChunk { ents.clear(); } } - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { Collection ents = entities[i]; if (!ents.isEmpty()) { int layerYStart = i << 4; diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java index f3e69beb..f2c4eab2 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java @@ -163,7 +163,7 @@ public class BukkitChunk_1_7 extends CharFaweChunk { ents.clear(); } } - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { Collection ents = entities[i]; if (!ents.isEmpty()) { char[] array = this.getIdArray(i); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java index 02d2b246..2ac41bfa 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java @@ -93,7 +93,7 @@ public class BukkitChunk_1_8 extends CharFaweChunk { ents.clear(); } } - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { Collection ents = entities[i]; if (!ents.isEmpty()) { char[] array = this.getIdArray(i); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java index 71c8cccd..803f50cd 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java @@ -183,7 +183,7 @@ public class BukkitChunk_1_9 extends CharFaweChunk { ents.clear(); } } - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { Collection ents = entities[i]; if (!ents.isEmpty()) { char[] array = this.getIdArray(i); diff --git a/core/src/main/java/com/boydti/fawe/config/Settings.java b/core/src/main/java/com/boydti/fawe/config/Settings.java index fc6d3aae..ea263a6c 100644 --- a/core/src/main/java/com/boydti/fawe/config/Settings.java +++ b/core/src/main/java/com/boydti/fawe/config/Settings.java @@ -324,6 +324,12 @@ public class Settings extends Config { "Disable using native libraries", }) public boolean DISABLE_NATIVES = false; + + @Comment({ + "[SAFE] Keep entities that are positioned in non-air blocks when editing an area", + "Might cause client-side FPS lagg in some situations" + }) + public boolean KEEP_ENTITIES_IN_BLOCKS = false; } public static class WEB { diff --git a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java index 951af7d2..72eca90e 100644 --- a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java +++ b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java @@ -174,7 +174,7 @@ public class ForgeChunk_All extends CharFaweChunk { continue; } else if (count >= 4096) { entities[i] = new ClassInheritanceMultiMap<>(Entity.class); - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; Collection ents = new ArrayList<>(entities[i]); diff --git a/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeChunk_All.java b/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeChunk_All.java index c605bfff..68abb790 100644 --- a/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeChunk_All.java +++ b/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeChunk_All.java @@ -182,7 +182,7 @@ public class ForgeChunk_All extends CharFaweChunk { nmsWorld.removeEntity(ent); } } - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; Collection ents = new ArrayList<>(entities[i]); diff --git a/forge112/src/main/java/com/boydti/fawe/forge/v112/ForgeChunk_All.java b/forge112/src/main/java/com/boydti/fawe/forge/v112/ForgeChunk_All.java index 984897f7..d2aea383 100644 --- a/forge112/src/main/java/com/boydti/fawe/forge/v112/ForgeChunk_All.java +++ b/forge112/src/main/java/com/boydti/fawe/forge/v112/ForgeChunk_All.java @@ -182,7 +182,7 @@ public class ForgeChunk_All extends CharFaweChunk { nmsWorld.removeEntity(ent); } } - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; Collection ents = new ArrayList<>(entities[i]); diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java index 58d9e8da..4dd3d7c1 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java @@ -169,7 +169,7 @@ public class ForgeChunk_All extends CharFaweChunk { continue; } else if (count >= 4096) { entities[i].clear(); - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; Collection ents = new ArrayList<>(entities[i]); diff --git a/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeChunk_All.java b/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeChunk_All.java index b1e23f55..fc861060 100644 --- a/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeChunk_All.java +++ b/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeChunk_All.java @@ -92,7 +92,7 @@ public class ForgeChunk_All extends CharFaweChunk { continue; } else if (count >= 4096) { entities[i] = new ClassInheritanceMultiMap<>(Entity.class); - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; Collection ents = new ArrayList<>(entities[i]); diff --git a/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeChunk_All.java b/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeChunk_All.java index 413d20b6..bc70596b 100644 --- a/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeChunk_All.java +++ b/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeChunk_All.java @@ -173,7 +173,7 @@ public class ForgeChunk_All extends CharFaweChunk { continue; } else if (count >= 4096) { entities[i] = new ClassInheritanceMultiMap<>(Entity.class); - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; Collection ents = new ArrayList<>(entities[i]); diff --git a/nukkit/src/main/java/com/boydti/fawe/nukkit/optimization/queue/NukkitChunk.java b/nukkit/src/main/java/com/boydti/fawe/nukkit/optimization/queue/NukkitChunk.java index 547ea273..1bd9105d 100644 --- a/nukkit/src/main/java/com/boydti/fawe/nukkit/optimization/queue/NukkitChunk.java +++ b/nukkit/src/main/java/com/boydti/fawe/nukkit/optimization/queue/NukkitChunk.java @@ -96,7 +96,7 @@ public class NukkitChunk extends CharFaweChunk { } Map ents = chunk.getEntities(); - if (!ents.isEmpty()) { + if (!ents.isEmpty() && !getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { Iterator> iter = ents.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = iter.next(); diff --git a/sponge111/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java b/sponge111/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java index 0e55861b..519581f1 100644 --- a/sponge111/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java +++ b/sponge111/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java @@ -185,7 +185,7 @@ public class SpongeChunk_1_11 extends CharFaweChunk { entities[i] = new ClassInheritanceMultiMap<>(Entity.class); } } - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { char[] array = this.getIdArray(i); Collection ents = new ArrayList<>(entities[i]); synchronized (SpongeChunk_1_11.class) { diff --git a/sponge112/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeChunk_1_12.java b/sponge112/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeChunk_1_12.java index 3659c22c..956eb8d1 100644 --- a/sponge112/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeChunk_1_12.java +++ b/sponge112/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeChunk_1_12.java @@ -185,7 +185,7 @@ public class SpongeChunk_1_12 extends CharFaweChunk { entities[i] = new ClassInheritanceMultiMap<>(Entity.class); } } - } else { + } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { char[] array = this.getIdArray(i); Collection ents = new ArrayList<>(entities[i]); synchronized (SpongeChunk_1_12.class) {