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 b957422f..3d951a48 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 @@ -231,21 +231,27 @@ public class BukkitChunk_1_10 extends CharFaweChunk { } for (int i = 0; i < entities.length; i++) { int count = this.getCount(i); - if (count == 0) { + if (count == 0 || getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { continue; } else if (count >= 4096) { Collection ents = entities[i]; if (!ents.isEmpty()) { - if (copy != null) { - for (net.minecraft.server.v1_10_R1.Entity entity : ents) { - copy.storeEntity(entity); + synchronized (BukkitQueue_0.class) { + Iterator iter = ents.iterator(); + while (iter.hasNext()) { + Entity entity = iter.next(); + if (entity instanceof EntityPlayer) { + continue; + } + iter.remove(); + if (copy != null) { + copy.storeEntity(entity); + } + removeEntity(entity); } } - synchronized (BukkitQueue_0.class) { - ents.clear(); - } } - } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { + } else { 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 c57229d4..b0e2ad38 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 @@ -3,6 +3,7 @@ package com.boydti.fawe.bukkit.v1_11; 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; @@ -218,6 +219,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk= 4096) { Collection ents = entities[i]; if (!ents.isEmpty()) { - if (copy != null) { - for (Entity entity : ents) { - copy.storeEntity(entity); + synchronized (BukkitQueue_0.class) { + Iterator iter = ents.iterator(); + while (iter.hasNext()) { + Entity entity = iter.next(); + if (entity instanceof EntityPlayer) { + continue; + } + iter.remove(); + if (copy != null) { + copy.storeEntity(entity); + } + removeEntity(entity); } } - synchronized (BukkitQueue_0.class) { - ents.clear(); - } } - } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { + } else { Collection 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 e90c46fb..8d710d2e 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; @@ -195,6 +196,7 @@ public class BukkitChunk_1_12 extends CharFaweChunk { BukkitChunk_1_12_Copy copy = getParent().getChangeTask() != null ? new BukkitChunk_1_12_Copy(getParent(), getX(), getZ()) : null; final Chunk chunk = this.getChunk(); final World world = chunk.getWorld(); + Settings settings = getParent().getSettings(); int bx = this.getX() << 4; int bz = this.getZ() << 4; final boolean flag = world.getEnvironment() == World.Environment.NORMAL; @@ -231,21 +233,27 @@ public class BukkitChunk_1_12 extends CharFaweChunk { } for (int i = 0; i < entities.length; i++) { int count = this.getCount(i); - if (count == 0) { + if (count == 0 || settings.EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { continue; } else if (count >= 4096) { Collection ents = entities[i]; if (!ents.isEmpty()) { - if (copy != null) { - for (Entity entity : ents) { - copy.storeEntity(entity); + synchronized (BukkitQueue_0.class) { + Iterator iter = ents.iterator(); + while (iter.hasNext()) { + Entity entity = iter.next(); + if (entity instanceof EntityPlayer) { + continue; + } + iter.remove(); + if (copy != null) { + copy.storeEntity(entity); + } + removeEntity(entity); } } - synchronized (BukkitQueue_0.class) { - ents.clear(); - } } - } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { + } else { 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 1cce1d55..18dc3b20 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 @@ -152,16 +152,24 @@ public class BukkitChunk_1_7 extends CharFaweChunk { // Remove entities for (int i = 0; i < 16; i++) { int count = this.getCount(i); - if (count == 0) { + if (count == 0 || getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { continue; } else if (count >= 4096) { Collection ents = entities[i]; if (!ents.isEmpty()) { synchronized (BukkitQueue_0.class) { - ents.clear(); + Iterator iter = ents.iterator(); + while (iter.hasNext()) { + Entity entity = iter.next(); + if (entity instanceof EntityPlayer) { + continue; + } + iter.remove(); + nmsWorld.removeEntity(entity); + } } } - } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { + } else { 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 1461b66f..955c441b 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 @@ -82,16 +82,24 @@ public class BukkitChunk_1_8 extends CharFaweChunk { // Remove entities for (int i = 0; i < 16; i++) { int count = this.getCount(i); - if (count == 0) { + if (count == 0 || getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { continue; } else if (count >= 4096) { Collection ents = entities[i]; if (!ents.isEmpty()) { synchronized (BukkitQueue_0.class) { - ents.clear(); + Iterator iter = ents.iterator(); + while (iter.hasNext()) { + Entity entity = iter.next(); + if (entity instanceof EntityPlayer) { + continue; + } + iter.remove(); + nmsWorld.removeEntity(entity); + } } } - } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { + } else { 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 040a8df0..9c093019 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 @@ -172,16 +172,24 @@ public class BukkitChunk_1_9 extends CharFaweChunk { // Remove entities for (int i = 0; i < entities.length; i++) { int count = this.getCount(i); - if (count == 0) { + if (count == 0 || getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { continue; } else if (count >= 4096) { Collection ents = entities[i]; if (!ents.isEmpty()) { synchronized (BukkitQueue_0.class) { - ents.clear(); + Iterator iter = ents.iterator(); + while (iter.hasNext()) { + Entity entity = iter.next(); + if (entity instanceof EntityPlayer) { + continue; + } + iter.remove(); + nmsWorld.removeEntity(entity); + } } } - } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { + } else { Collection ents = entities[i]; if (!ents.isEmpty()) { char[] array = this.getIdArray(i);