From c757b0180316ca62fc3ce2298a4486e182a5c7b2 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 8 May 2020 16:16:08 +0100 Subject: [PATCH] By default only allow existing blocks to tick. - Revert back to default FAWE behaviour where placed blocks do not tick by default (until a restart, or another edit is done in the same chunksection without changing the block) --- .../fawe/bukkit/adapter/NMSAdapter.java | 47 ++++++++++++++----- .../java/com/boydti/fawe/config/Settings.java | 6 +++ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/NMSAdapter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/NMSAdapter.java index e15a8a9c5..e5b9073ee 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/NMSAdapter.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/NMSAdapter.java @@ -1,5 +1,6 @@ package com.boydti.fawe.bukkit.adapter; +import com.boydti.fawe.config.Settings; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockID; @@ -68,6 +69,24 @@ public class NMSAdapter { case BlockID.VOID_AIR: air++; break; + default: + if (!Settings.IMP.EXPERIMENTAL.ALLOW_TICK_PLACED) { + boolean ticking; + if (ordinal != lastOrdinal) { + ticking = BlockTypesCache.ticking[ordinal]; + lastOrdinal = ordinal; + lastticking = ticking; + } else { + ticking = lastticking; + } + if (ticking) { + BlockState state = BlockState.getFromOrdinal(ordinal); + ticking_blocks + .put(BlockVector3.at(i & 15, (i >> 8) & 15, (i >> 4) & 15), + WorldEditPlugin.getInstance().getBukkitImplAdapter() + .getInternalBlockStateId(state).orElse(0)); + } + } } set[i] = ordinal; break; @@ -78,19 +97,21 @@ public class NMSAdapter { air++; break; } - boolean ticking; - if (ordinal != lastOrdinal) { - ticking = BlockTypesCache.ticking[ordinal]; - lastOrdinal = ordinal; - lastticking = ticking; - } else { - ticking = lastticking; - } - if (ticking) { - BlockState state = BlockState.getFromOrdinal(ordinal); - ticking_blocks.put(BlockVector3.at(i & 15, (i >> 8) & 15, (i >> 4) & 15), - WorldEditPlugin.getInstance().getBukkitImplAdapter() - .getInternalBlockStateId(state).orElse(0)); + if (Settings.IMP.EXPERIMENTAL.ALLOW_TICK_PLACED) { + boolean ticking; + if (ordinal != lastOrdinal) { + ticking = BlockTypesCache.ticking[ordinal]; + lastOrdinal = ordinal; + lastticking = ticking; + } else { + ticking = lastticking; + } + if (ticking) { + BlockState state = BlockState.getFromOrdinal(ordinal); + ticking_blocks.put(BlockVector3.at(i & 15, (i >> 8) & 15, (i >> 4) & 15), + WorldEditPlugin.getInstance().getBukkitImplAdapter() + .getInternalBlockStateId(state).orElse(0)); + } } int palette = blockToPalette[ordinal]; if (palette == Integer.MAX_VALUE) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java index 561f2330d..989e8ef05 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java @@ -369,6 +369,12 @@ public class Settings extends Config { "Other experimental features" }) public boolean OTHER = false; + + @Comment({ + "Allow blocks placed by WorldEdit to tick. This could cause the big lags.", + "This has no effect on existing blocks one way or the other." + }) + public boolean ALLOW_TICK_PLACED = false; } public static class WEB {