3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-17 08:30:04 +01:00

Add strings, changes to fastmode/side effect handling

Dieser Commit ist enthalten in:
dordsor21 2024-06-02 16:40:06 +01:00
Ursprung d1236313cf
Commit f23d430150
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
5 geänderte Dateien mit 65 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -361,7 +361,7 @@ public class FaweAPI {
Fawe.instance().getQueueHandler(), Fawe.instance().getQueueHandler(),
world, world,
true, true,
SideEffectSet.none().with(SideEffect.LIGHTING, SideEffect.State.ON) SideEffectSet.none().with(SideEffect.LIGHTING)
); );
queue = parallel.getExtent(); queue = parallel.getExtent();
} else { } else {

Datei anzeigen

@ -107,7 +107,7 @@ public final class EditSessionBuilder {
private Extent extent; private Extent extent;
private boolean compiled; private boolean compiled;
private boolean wrapped; private boolean wrapped;
private SideEffectSet sideEffectSet = SideEffectSet.defaults(); private SideEffectSet sideEffectSet = null;
private @Nullable private @Nullable
World world; World world;
@ -459,8 +459,9 @@ public final class EditSessionBuilder {
fastMode = actor.getSession().hasFastMode(); fastMode = actor.getSession().hasFastMode();
} }
} }
if (fastMode) { if (sideEffectSet == null) {
sideEffectSet = SideEffectSet.none(); // Keep heightmaps to maintain behaviour
sideEffectSet = fastMode ? SideEffectSet.none().with(SideEffect.HEIGHTMAPS) : SideEffectSet.defaults();
} }
if (checkMemory == null) { if (checkMemory == null) {
checkMemory = actor != null && !this.fastMode; checkMemory = actor != null && !this.fastMode;
@ -498,6 +499,7 @@ public final class EditSessionBuilder {
} else { } else {
extent = queue = Fawe.instance().getQueueHandler().getQueue(world); extent = queue = Fawe.instance().getQueueHandler().getQueue(world);
} }
queue.setSideEffectSet(sideEffectSet);
} else { } else {
wnaMode = true; wnaMode = true;
extent = world; extent = world;
@ -580,8 +582,7 @@ public final class EditSessionBuilder {
if (this.sideEffectSet.shouldApply(SideEffect.HEIGHTMAPS)) { if (this.sideEffectSet.shouldApply(SideEffect.HEIGHTMAPS)) {
queue.addProcessor(new HeightmapProcessor(world.getMinY(), world.getMaxY())); queue.addProcessor(new HeightmapProcessor(world.getMinY(), world.getMaxY()));
} }
if (this.sideEffectSet.shouldApply(SideEffect.UPDATE) || this.sideEffectSet.shouldApply(SideEffect.NEIGHBORS) || this.sideEffectSet.shouldApply( if (this.sideEffectSet.shouldApply(SideEffect.NEIGHBORS)) {
SideEffect.VALIDATION)) {
Region region = allowedRegions == null || allowedRegions.length == 0 Region region = allowedRegions == null || allowedRegions.length == 0
? null ? null
: allowedRegions.length == 1 ? allowedRegions[0] : new RegionIntersection(allowedRegions); : allowedRegions.length == 1 ? allowedRegions[0] : new RegionIntersection(allowedRegions);

Datei anzeigen

@ -154,6 +154,7 @@ public class LocalSession implements TextureHolder {
private transient TextureUtil texture; private transient TextureUtil texture;
private transient ResettableExtent transform = null; private transient ResettableExtent transform = null;
private transient World currentWorld; private transient World currentWorld;
private transient boolean fastMode = false;
//FAWE end //FAWE end
private transient ClipboardHolder clipboard; private transient ClipboardHolder clipboard;
private transient final Object clipboardLock = new Object(); private transient final Object clipboardLock = new Object();
@ -1725,11 +1726,12 @@ public class LocalSession implements TextureHolder {
* @return an edit session * @return an edit session
*/ */
public EditSession createEditSession(Actor actor) { public EditSession createEditSession(Actor actor) {
//FAWE start //FAWE start - save command used
return createEditSession(actor, null); return createEditSession(actor, null);
} }
public EditSession createEditSession(Actor actor, String command) { public EditSession createEditSession(Actor actor, String command) {
//FAWE end
checkNotNull(actor); checkNotNull(actor);
World world = null; World world = null;
@ -1740,18 +1742,18 @@ public class LocalSession implements TextureHolder {
} }
// Create an edit session // Create an edit session
EditSession editSession;
EditSessionBuilder builder = WorldEdit.getInstance().newEditSessionBuilder().world(world); EditSessionBuilder builder = WorldEdit.getInstance().newEditSessionBuilder().world(world);
if (actor.isPlayer() && actor instanceof Player) { if (actor.isPlayer() && actor instanceof Player) {
BlockBag blockBag = getBlockBag((Player) actor); BlockBag blockBag = getBlockBag((Player) actor);
builder.actor(actor); builder.actor(actor);
builder.blockBag(blockBag); builder.blockBag(blockBag);
} }
//FAWE start
builder.command(command); builder.command(command);
builder.fastMode(!this.sideEffectSet.doesApplyAny()); builder.fastMode(this.fastMode);
builder.setSideEffectSet(this.sideEffectSet); builder.setSideEffectSet(this.sideEffectSet);
editSession = builder.build(); EditSession editSession = builder.build();
if (mask != null) { if (mask != null) {
editSession.setMask(mask); editSession.setMask(mask);
@ -1763,7 +1765,7 @@ public class LocalSession implements TextureHolder {
editSession.addTransform(transform); editSession.addTransform(transform);
} }
editSession.setTickingWatchdog(tickingWatchdog); editSession.setTickingWatchdog(tickingWatchdog);
//FAWE end
return editSession; return editSession;
} }
//FAWE end //FAWE end
@ -1802,7 +1804,9 @@ public class LocalSession implements TextureHolder {
*/ */
@Deprecated @Deprecated
public boolean hasFastMode() { public boolean hasFastMode() {
return !this.sideEffectSet.doesApplyAny(); //FAWE start - use fastmode boolean not side effects
return this.fastMode;
//FAWE end
} }
/** /**
@ -1812,7 +1816,9 @@ public class LocalSession implements TextureHolder {
*/ */
@Deprecated @Deprecated
public void setFastMode(boolean fastMode) { 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
} }
/** /**

Datei anzeigen

@ -59,6 +59,27 @@ public class SideEffectSet {
//FAWE end //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) { public SideEffectSet with(SideEffect sideEffect, SideEffect.State state) {
Map<SideEffect, SideEffect.State> entries = this.sideEffects.isEmpty() Map<SideEffect, SideEffect.State> entries = this.sideEffects.isEmpty()
? Maps.newEnumMap(SideEffect.class) ? Maps.newEnumMap(SideEffect.class)
@ -101,4 +122,23 @@ public class SideEffectSet {
return NONE; 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
} }

Datei anzeigen

@ -626,10 +626,14 @@
"worldedit.selection.polygon2d.explain.secondary": "Added point #{0} at {1}.", "worldedit.selection.polygon2d.explain.secondary": "Added point #{0} at {1}.",
"worldedit.selection.sphere.explain.secondary": "Radius set to {0}.", "worldedit.selection.sphere.explain.secondary": "Radius set to {0}.",
"worldedit.selection.sphere.explain.secondary-defined": "Radius set to {0} ({1}).", "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": "Lighting",
"worldedit.sideeffect.lighting.description": "Updates block lighting", "worldedit.sideeffect.lighting.description": "Updates block lighting",
"worldedit.sideeffect.neighbors": "Neighbors", "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": "Update",
"worldedit.sideeffect.update.description": "Notifies the changed block", "worldedit.sideeffect.update.description": "Notifies the changed block",
"worldedit.sideeffect.validation": "Validation", "worldedit.sideeffect.validation": "Validation",