Added a "Keep entities in non-air blocks" setting

This commit is contained in:
Joey 2018-04-29 17:40:48 +02:00
parent 7519f735bc
commit 19a9db3abf
16 changed files with 22 additions and 15 deletions

View File

@ -247,7 +247,7 @@ public class BukkitChunk_1_10 extends CharFaweChunk<Chunk, BukkitQueue_1_10> {
ents.clear(); ents.clear();
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
Collection<net.minecraft.server.v1_10_R1.Entity> ents = entities[i]; Collection<net.minecraft.server.v1_10_R1.Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);

View File

@ -268,7 +268,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk<Chunk, com.boydti.fawe.bukki
ents.clear(); ents.clear();
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);

View File

@ -3,6 +3,7 @@ package com.boydti.fawe.bukkit.v1_12;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.v0.BukkitQueue_0; import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.CharFaweChunk; import com.boydti.fawe.example.CharFaweChunk;
import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
@ -246,7 +247,7 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
ents.clear(); ents.clear();
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
int layerYStart = i << 4; int layerYStart = i << 4;

View File

@ -163,7 +163,7 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
ents.clear(); ents.clear();
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);

View File

@ -93,7 +93,7 @@ public class BukkitChunk_1_8 extends CharFaweChunk<Chunk, BukkitQueue18R3> {
ents.clear(); ents.clear();
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);

View File

@ -183,7 +183,7 @@ public class BukkitChunk_1_9 extends CharFaweChunk<Chunk, BukkitQueue_1_9_R1> {
ents.clear(); ents.clear();
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
Collection<Entity> ents = entities[i]; Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);

View File

@ -324,6 +324,12 @@ public class Settings extends Config {
"Disable using native libraries", "Disable using native libraries",
}) })
public boolean DISABLE_NATIVES = false; 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 { public static class WEB {

View File

@ -174,7 +174,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
continue; continue;
} else if (count >= 4096) { } else if (count >= 4096) {
entities[i] = new ClassInheritanceMultiMap<>(Entity.class); entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue; if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);

View File

@ -182,7 +182,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
nmsWorld.removeEntity(ent); nmsWorld.removeEntity(ent);
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue; if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);

View File

@ -182,7 +182,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
nmsWorld.removeEntity(ent); nmsWorld.removeEntity(ent);
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue; if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);

View File

@ -169,7 +169,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
continue; continue;
} else if (count >= 4096) { } else if (count >= 4096) {
entities[i].clear(); entities[i].clear();
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue; if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);

View File

@ -92,7 +92,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
continue; continue;
} else if (count >= 4096) { } else if (count >= 4096) {
entities[i] = new ClassInheritanceMultiMap<>(Entity.class); entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue; if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);

View File

@ -173,7 +173,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
continue; continue;
} else if (count >= 4096) { } else if (count >= 4096) {
entities[i] = new ClassInheritanceMultiMap<>(Entity.class); entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
if (array == null || entities[i] == null || entities[i].isEmpty()) continue; if (array == null || entities[i] == null || entities[i].isEmpty()) continue;
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);

View File

@ -96,7 +96,7 @@ public class NukkitChunk extends CharFaweChunk<BaseFullChunk, NukkitQueue> {
} }
Map<Long, Entity> ents = chunk.getEntities(); Map<Long, Entity> ents = chunk.getEntities();
if (!ents.isEmpty()) { if (!ents.isEmpty() && !getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
Iterator<Map.Entry<Long, Entity>> iter = ents.entrySet().iterator(); Iterator<Map.Entry<Long, Entity>> iter = ents.entrySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Map.Entry<Long, Entity> entry = iter.next(); Map.Entry<Long, Entity> entry = iter.next();

View File

@ -185,7 +185,7 @@ public class SpongeChunk_1_11 extends CharFaweChunk<Chunk, SpongeQueue_1_11> {
entities[i] = new ClassInheritanceMultiMap<>(Entity.class); entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);
synchronized (SpongeChunk_1_11.class) { synchronized (SpongeChunk_1_11.class) {

View File

@ -185,7 +185,7 @@ public class SpongeChunk_1_12 extends CharFaweChunk<Chunk, SpongeQueue_1_12> {
entities[i] = new ClassInheritanceMultiMap<>(Entity.class); entities[i] = new ClassInheritanceMultiMap<>(Entity.class);
} }
} }
} else { } else if (!getParent().getSettings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
char[] array = this.getIdArray(i); char[] array = this.getIdArray(i);
Collection<Entity> ents = new ArrayList<>(entities[i]); Collection<Entity> ents = new ArrayList<>(entities[i]);
synchronized (SpongeChunk_1_12.class) { synchronized (SpongeChunk_1_12.class) {