diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java index 5ffc6b185..0158370c8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java @@ -358,7 +358,7 @@ public class FaweAPI { Fawe.instance().getQueueHandler(), world, true, - SideEffectSet.none().with(SideEffect.LIGHTING, SideEffect.State.ON) + SideEffectSet.none().with(SideEffect.LIGHTING) ); queue = parallel.getExtent(); } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java index a27a507f4..2fac0dee9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java @@ -107,7 +107,7 @@ public final class EditSessionBuilder { private Extent extent; private boolean compiled; private boolean wrapped; - private SideEffectSet sideEffectSet = SideEffectSet.defaults(); + private SideEffectSet sideEffectSet = null; private @Nullable World world; @@ -459,8 +459,9 @@ public final class EditSessionBuilder { fastMode = actor.getSession().hasFastMode(); } } - if (fastMode) { - sideEffectSet = SideEffectSet.none(); + if (sideEffectSet == null) { + // Keep heightmaps to maintain behaviour + sideEffectSet = fastMode ? SideEffectSet.none().with(SideEffect.HEIGHTMAPS) : SideEffectSet.defaults(); } if (checkMemory == null) { checkMemory = actor != null && !this.fastMode; @@ -498,6 +499,7 @@ public final class EditSessionBuilder { } else { extent = queue = Fawe.instance().getQueueHandler().getQueue(world); } + queue.setSideEffectSet(sideEffectSet); } else { wnaMode = true; extent = world; @@ -580,8 +582,7 @@ public final class EditSessionBuilder { if (this.sideEffectSet.shouldApply(SideEffect.HEIGHTMAPS)) { queue.addProcessor(new HeightmapProcessor(world.getMinY(), world.getMaxY())); } - if (this.sideEffectSet.shouldApply(SideEffect.UPDATE) || this.sideEffectSet.shouldApply(SideEffect.NEIGHBORS) || this.sideEffectSet.shouldApply( - SideEffect.VALIDATION)) { + if (this.sideEffectSet.shouldApply(SideEffect.NEIGHBORS)) { Region region = allowedRegions == null || allowedRegions.length == 0 ? null : allowedRegions.length == 1 ? allowedRegions[0] : new RegionIntersection(allowedRegions); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 6f678ed49..e0b8e8840 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -153,6 +153,7 @@ public class LocalSession implements TextureHolder { private transient TextureUtil texture; private transient ResettableExtent transform = null; private transient World currentWorld; + private transient boolean fastMode = false; //FAWE end private transient ClipboardHolder clipboard; private transient final Object clipboardLock = new Object(); @@ -1706,10 +1707,12 @@ public class LocalSession implements TextureHolder { * @return an edit session */ public EditSession createEditSession(Actor actor) { + //FAWE start - save command used return createEditSession(actor, null); } public EditSession createEditSession(Actor actor, String command) { + //FAWE end checkNotNull(actor); World world = null; @@ -1720,19 +1723,18 @@ public class LocalSession implements TextureHolder { } // Create an edit session - //FAWE start - we don't use the edit session builder yet - EditSession editSession; EditSessionBuilder builder = WorldEdit.getInstance().newEditSessionBuilder().world(world); if (actor.isPlayer() && actor instanceof Player) { BlockBag blockBag = getBlockBag((Player) actor); builder.actor(actor); builder.blockBag(blockBag); } + //FAWE start builder.command(command); - builder.fastMode(!this.sideEffectSet.doesApplyAny()); + builder.fastMode(this.fastMode); builder.setSideEffectSet(this.sideEffectSet); - editSession = builder.build(); + EditSession editSession = builder.build(); if (mask != null) { editSession.setMask(mask); @@ -1744,7 +1746,7 @@ public class LocalSession implements TextureHolder { editSession.addTransform(transform); } editSession.setTickingWatchdog(tickingWatchdog); - + //FAWE end return editSession; } //FAWE end @@ -1783,7 +1785,9 @@ public class LocalSession implements TextureHolder { */ @Deprecated public boolean hasFastMode() { - return !this.sideEffectSet.doesApplyAny(); + //FAWE start - use fastmode boolean not side effects + return this.fastMode; + //FAWE end } /** @@ -1793,7 +1797,9 @@ public class LocalSession implements TextureHolder { */ @Deprecated public void setFastMode(boolean fastMode) { - this.sideEffectSet = fastMode ? SideEffectSet.none() : SideEffectSet.defaults(); + //FAWE start - use fastmode boolean not side effects + this.fastMode = fastMode; + //FAWE end } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/SideEffectSet.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/SideEffectSet.java index 8e7a707bc..73e3805eb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/SideEffectSet.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/SideEffectSet.java @@ -59,6 +59,27 @@ public class SideEffectSet { //FAWE end } + //FAWE start - simple overload method for setting side effects + + /** + * Create a new {@link SideEffectSet} with the given side effect set to "on" + * + * @since TODO + */ + public SideEffectSet with(SideEffect sideEffect) { + return with(sideEffect, SideEffect.State.ON); + } + + /** + * Create a new {@link SideEffectSet} with the given side effect set to "off" + * + * @since TODO + */ + public SideEffectSet without(SideEffect sideEffect) { + return with(sideEffect, SideEffect.State.OFF); + } + //FAWE end + public SideEffectSet with(SideEffect sideEffect, SideEffect.State state) { Map entries = this.sideEffects.isEmpty() ? Maps.newEnumMap(SideEffect.class) @@ -101,4 +122,23 @@ public class SideEffectSet { return NONE; } + //FAWE start + + /** + * API-friendly side effect set. + * Sets: + * - Heightmaps + * - Lighting (if set to mode 1 or 2 in config) + * Does not set: + * - History + * - Neighbours + * - Lighting (if set to mode 0 in config + * + * @since TODO + */ + public static SideEffectSet api() { + return defaults().without(SideEffect.HISTORY); + } + //FAWE end + } diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index c343dd623..ee8ef19e4 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -615,10 +615,14 @@ "worldedit.selection.polygon2d.explain.secondary": "Added point #{0} at {1}.", "worldedit.selection.sphere.explain.secondary": "Radius set to {0}.", "worldedit.selection.sphere.explain.secondary-defined": "Radius set to {0} ({1}).", + "worldedit.sideeffect.history": "History", + "worldedit.sideeffect.history.description": "Writes history of the change", + "worldedit.sideeffect.heightmaps": "Heightmaps", + "worldedit.sideeffect.heightmaps.description": "Updates heightmaps", "worldedit.sideeffect.lighting": "Lighting", "worldedit.sideeffect.lighting.description": "Updates block lighting", "worldedit.sideeffect.neighbors": "Neighbors", - "worldedit.sideeffect.neighbors.description": "Notifies nearby blocks of changes", + "worldedit.sideeffect.neighbors.description": "Updates shapes of blocks in the edit", "worldedit.sideeffect.update": "Update", "worldedit.sideeffect.update.description": "Notifies the changed block", "worldedit.sideeffect.validation": "Validation",