3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-10-02 03:40:06 +02:00

Add (untested) processing capability and second passes where appropriate

Dieser Commit ist enthalten in:
dordsor21 2024-05-27 17:54:36 +01:00
Ursprung 374e3baf16
Commit 6e4f8770b6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
33 geänderte Dateien mit 559 neuen und 160 gelöschten Zeilen

Datei anzeigen

@ -780,12 +780,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.NEIGHBORS,
//FAWE start - FAWE-supported side effects
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.VALIDATION,
SideEffect.ENTITY_AI,
SideEffect.EVENTS,
SideEffect.UPDATE
SideEffect.NEIGHBORS
//FAWE end
);
@Override

Datei anzeigen

@ -16,7 +16,11 @@ import javax.annotation.Nullable;
public class FaweMutableBlockPlaceContext extends BlockPlaceContext {
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(Vec3.ZERO, Direction.NORTH, BlockPos.ZERO, false);
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(new Vec3(
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE
), Direction.NORTH, BlockPos.ZERO, false);
private final ServerLevel level;
private BlockHitResult hitResult = null;
private Direction direction = null;

Datei anzeigen

@ -13,6 +13,7 @@ import com.fastasyncworldedit.core.util.NbtUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -283,9 +284,16 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
return state.toBaseBlock();
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.NEIGHBORS
);
@Override
public Set<SideEffect> getSupportedSideEffects() {
return SideEffectSet.defaults().getSideEffectsToApply();
return SUPPORTED_SIDE_EFFECTS;
}
@Override
@ -606,8 +614,13 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
@Override
public PlacementStateProcessor getPlatformPlacementProcessor(Extent extent, BlockTypeMask mask, boolean includeUnedited) {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
public PlacementStateProcessor getPlatformPlacementProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited
) {
return new PaperweightPlacementStateProcessor(extent, mask, secondPass, includeUnedited);
}
private boolean wasAccessibleSinceLastSave(ChunkHolder holder) {

Datei anzeigen

@ -1,6 +1,7 @@
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_19_R3;
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
import com.fastasyncworldedit.core.math.IntTriple;
import com.fastasyncworldedit.core.util.ExtentTraverser;
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
import com.sk89q.worldedit.EditSession;
@ -21,6 +22,7 @@ import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
import javax.annotation.Nullable;
import java.util.Queue;
public class PaperweightPlacementStateProcessor extends PlacementStateProcessor {
@ -28,13 +30,15 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
.getInstance()
.getBukkitImplAdapter());
private final FaweMutableBlockPlaceContext mutableBlockPlaceContext;
private final PaperweightLevelProxy proxyLevel;
public PaperweightPlacementStateProcessor(
final Extent extent,
final BlockTypeMask mask,
final boolean includeUnedited
boolean secondPass,
boolean includeUnedited
) {
super(extent, mask, includeUnedited);
super(extent, mask, secondPass, includeUnedited);
World world;
if (extent.isWorld()) {
world = (World) extent;
@ -53,8 +57,23 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
((CraftWorld) bukkitWorld.getWorld()).getHandle(),
extent
);
mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
proxyLevel.setEnabled(true);
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(),
extent
);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
private PaperweightPlacementStateProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited,
Queue<IntTriple> crossChunkSecondPasses,
PaperweightLevelProxy proxyLevel
) {
super(extent, mask, secondPass, includeUnedited, crossChunkSecondPasses);
this.proxyLevel = proxyLevel;
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
@Override
@ -85,12 +104,19 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
if (child == getExtent()) {
return this;
}
return new PaperweightPlacementStateProcessor(child, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(child, mask, secondPass, includeUnedited);
}
@Override
public PlacementStateProcessor fork() {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(
extent,
mask,
secondPass,
includeUnedited,
crossChunkSecondPasses,
proxyLevel
);
}
}

Datei anzeigen

@ -831,12 +831,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.NEIGHBORS,
//FAWE start - FAWE-supported side effects
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.VALIDATION,
SideEffect.ENTITY_AI,
SideEffect.EVENTS,
SideEffect.UPDATE
SideEffect.NEIGHBORS
//FAWE end
);
@Override

Datei anzeigen

@ -16,7 +16,11 @@ import javax.annotation.Nullable;
public class FaweMutableBlockPlaceContext extends BlockPlaceContext {
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(Vec3.ZERO, Direction.NORTH, BlockPos.ZERO, false);
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(new Vec3(
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE
), Direction.NORTH, BlockPos.ZERO, false);
private final ServerLevel level;
private BlockHitResult hitResult = null;
private Direction direction = null;

Datei anzeigen

@ -13,6 +13,7 @@ import com.fastasyncworldedit.core.util.NbtUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -283,9 +284,16 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
return state.toBaseBlock();
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.NEIGHBORS
);
@Override
public Set<SideEffect> getSupportedSideEffects() {
return SideEffectSet.defaults().getSideEffectsToApply();
return SUPPORTED_SIDE_EFFECTS;
}
@Override
@ -606,8 +614,13 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
@Override
public PlacementStateProcessor getPlatformPlacementProcessor(Extent extent, BlockTypeMask mask, boolean includeUnedited) {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
public PlacementStateProcessor getPlatformPlacementProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited
) {
return new PaperweightPlacementStateProcessor(extent, mask, secondPass, includeUnedited);
}
private boolean wasAccessibleSinceLastSave(ChunkHolder holder) {

Datei anzeigen

@ -1,6 +1,7 @@
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R1;
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
import com.fastasyncworldedit.core.math.IntTriple;
import com.fastasyncworldedit.core.util.ExtentTraverser;
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
import com.sk89q.worldedit.EditSession;
@ -21,6 +22,7 @@ import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
import javax.annotation.Nullable;
import java.util.Queue;
public class PaperweightPlacementStateProcessor extends PlacementStateProcessor {
@ -28,13 +30,15 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
.getInstance()
.getBukkitImplAdapter());
private final FaweMutableBlockPlaceContext mutableBlockPlaceContext;
private final PaperweightLevelProxy proxyLevel;
public PaperweightPlacementStateProcessor(
final Extent extent,
final BlockTypeMask mask,
final boolean includeUnedited
boolean secondPass,
boolean includeUnedited
) {
super(extent, mask, includeUnedited);
super(extent, mask, secondPass, includeUnedited);
World world;
if (extent.isWorld()) {
world = (World) extent;
@ -53,8 +57,23 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
((CraftWorld) bukkitWorld.getWorld()).getHandle(),
extent
);
mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
proxyLevel.setEnabled(true);
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(),
extent
);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
private PaperweightPlacementStateProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited,
Queue<IntTriple> crossChunkSecondPasses,
PaperweightLevelProxy proxyLevel
) {
super(extent, mask, secondPass, includeUnedited, crossChunkSecondPasses);
this.proxyLevel = proxyLevel;
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
@Override
@ -85,12 +104,19 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
if (child == getExtent()) {
return this;
}
return new PaperweightPlacementStateProcessor(child, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(child, mask, secondPass, includeUnedited);
}
@Override
public PlacementStateProcessor fork() {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(
extent,
mask,
secondPass,
includeUnedited,
crossChunkSecondPasses,
proxyLevel
);
}
}

Datei anzeigen

@ -780,12 +780,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.NEIGHBORS,
//FAWE start - FAWE-supported side effects
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.VALIDATION,
SideEffect.ENTITY_AI,
SideEffect.EVENTS,
SideEffect.UPDATE
SideEffect.NEIGHBORS
//FAWE end
);
@Override

Datei anzeigen

@ -16,7 +16,11 @@ import javax.annotation.Nullable;
public class FaweMutableBlockPlaceContext extends BlockPlaceContext {
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(Vec3.ZERO, Direction.NORTH, BlockPos.ZERO, false);
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(new Vec3(
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE
), Direction.NORTH, BlockPos.ZERO, false);
private final ServerLevel level;
private BlockHitResult hitResult = null;
private Direction direction = null;

Datei anzeigen

@ -13,6 +13,7 @@ import com.fastasyncworldedit.core.util.NbtUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -286,9 +287,16 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
return state.toBaseBlock();
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.NEIGHBORS
);
@Override
public Set<SideEffect> getSupportedSideEffects() {
return SideEffectSet.defaults().getSideEffectsToApply();
return SUPPORTED_SIDE_EFFECTS;
}
@Override
@ -609,8 +617,13 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
@Override
public PlacementStateProcessor getPlatformPlacementProcessor(Extent extent, BlockTypeMask mask, boolean includeUnedited) {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
public PlacementStateProcessor getPlatformPlacementProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited
) {
return new PaperweightPlacementStateProcessor(extent, mask, secondPass, includeUnedited);
}
private boolean wasAccessibleSinceLastSave(ChunkHolder holder) {

Datei anzeigen

@ -1,6 +1,7 @@
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2;
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
import com.fastasyncworldedit.core.math.IntTriple;
import com.fastasyncworldedit.core.util.ExtentTraverser;
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
import com.sk89q.worldedit.EditSession;
@ -21,6 +22,7 @@ import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
import javax.annotation.Nullable;
import java.util.Queue;
public class PaperweightPlacementStateProcessor extends PlacementStateProcessor {
@ -28,13 +30,15 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
.getInstance()
.getBukkitImplAdapter());
private final FaweMutableBlockPlaceContext mutableBlockPlaceContext;
private final PaperweightLevelProxy proxyLevel;
public PaperweightPlacementStateProcessor(
final Extent extent,
final BlockTypeMask mask,
final boolean includeUnedited
boolean secondPass,
boolean includeUnedited
) {
super(extent, mask, includeUnedited);
super(extent, mask, secondPass, includeUnedited);
World world;
if (extent.isWorld()) {
world = (World) extent;
@ -53,8 +57,23 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
((CraftWorld) bukkitWorld.getWorld()).getHandle(),
extent
);
mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
proxyLevel.setEnabled(true);
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(),
extent
);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
private PaperweightPlacementStateProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited,
Queue<IntTriple> crossChunkSecondPasses,
PaperweightLevelProxy proxyLevel
) {
super(extent, mask, secondPass, includeUnedited, crossChunkSecondPasses);
this.proxyLevel = proxyLevel;
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
@Override
@ -85,12 +104,19 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
if (child == getExtent()) {
return this;
}
return new PaperweightPlacementStateProcessor(child, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(child, mask, secondPass, includeUnedited);
}
@Override
public PlacementStateProcessor fork() {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(
extent,
mask,
secondPass,
includeUnedited,
crossChunkSecondPasses,
proxyLevel
);
}
}

Datei anzeigen

@ -780,12 +780,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.NEIGHBORS,
//FAWE start - FAWE-supported side effects
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.VALIDATION,
SideEffect.ENTITY_AI,
SideEffect.EVENTS,
SideEffect.UPDATE
SideEffect.NEIGHBORS
//FAWE end
);
@Override

Datei anzeigen

@ -16,7 +16,11 @@ import javax.annotation.Nullable;
public class FaweMutableBlockPlaceContext extends BlockPlaceContext {
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(Vec3.ZERO, Direction.NORTH, BlockPos.ZERO, false);
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(new Vec3(
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE
), Direction.NORTH, BlockPos.ZERO, false);
private final ServerLevel level;
private BlockHitResult hitResult = null;
private Direction direction = null;

Datei anzeigen

@ -13,6 +13,7 @@ import com.fastasyncworldedit.core.util.NbtUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -285,9 +286,16 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
return state.toBaseBlock();
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.NEIGHBORS
);
@Override
public Set<SideEffect> getSupportedSideEffects() {
return SideEffectSet.defaults().getSideEffectsToApply();
return SUPPORTED_SIDE_EFFECTS;
}
@Override
@ -607,8 +615,13 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
@Override
public PlacementStateProcessor getPlatformPlacementProcessor(Extent extent, BlockTypeMask mask, boolean includeUnedited) {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
public PlacementStateProcessor getPlatformPlacementProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited
) {
return new PaperweightPlacementStateProcessor(extent, mask, secondPass, includeUnedited);
}
private boolean wasAccessibleSinceLastSave(ChunkHolder holder) {

Datei anzeigen

@ -1,6 +1,7 @@
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3;
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
import com.fastasyncworldedit.core.math.IntTriple;
import com.fastasyncworldedit.core.util.ExtentTraverser;
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
import com.sk89q.worldedit.EditSession;
@ -21,6 +22,7 @@ import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import javax.annotation.Nullable;
import java.util.Queue;
public class PaperweightPlacementStateProcessor extends PlacementStateProcessor {
@ -28,13 +30,15 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
.getInstance()
.getBukkitImplAdapter());
private final FaweMutableBlockPlaceContext mutableBlockPlaceContext;
private final PaperweightLevelProxy proxyLevel;
public PaperweightPlacementStateProcessor(
final Extent extent,
final BlockTypeMask mask,
final boolean includeUnedited
boolean secondPass,
boolean includeUnedited
) {
super(extent, mask, includeUnedited);
super(extent, mask, secondPass, includeUnedited);
World world;
if (extent.isWorld()) {
world = (World) extent;
@ -53,8 +57,23 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
((CraftWorld) bukkitWorld.getWorld()).getHandle(),
extent
);
mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
proxyLevel.setEnabled(true);
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(),
extent
);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
private PaperweightPlacementStateProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited,
Queue<IntTriple> crossChunkSecondPasses,
PaperweightLevelProxy proxyLevel
) {
super(extent, mask, secondPass, includeUnedited, crossChunkSecondPasses);
this.proxyLevel = proxyLevel;
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
@Override
@ -85,12 +104,19 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
if (child == getExtent()) {
return this;
}
return new PaperweightPlacementStateProcessor(child, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(child, mask, secondPass, includeUnedited);
}
@Override
public PlacementStateProcessor fork() {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(
extent,
mask,
secondPass,
includeUnedited,
crossChunkSecondPasses,
proxyLevel
);
}
}

Datei anzeigen

@ -857,12 +857,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.NEIGHBORS,
//FAWE start - FAWE-supported side effects
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.VALIDATION,
SideEffect.ENTITY_AI,
SideEffect.EVENTS,
SideEffect.UPDATE
SideEffect.NEIGHBORS
//FAWE end
);
@Override

Datei anzeigen

@ -16,7 +16,11 @@ import javax.annotation.Nullable;
public class FaweMutableBlockPlaceContext extends BlockPlaceContext {
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(Vec3.ZERO, Direction.NORTH, BlockPos.ZERO, false);
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(new Vec3(
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE
), Direction.NORTH, BlockPos.ZERO, false);
private final ServerLevel level;
private BlockHitResult hitResult = null;
private Direction direction = null;

Datei anzeigen

@ -13,6 +13,7 @@ import com.fastasyncworldedit.core.util.NbtUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.mojang.serialization.Codec;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.blocks.BaseItemStack;
@ -35,7 +36,6 @@ import com.sk89q.worldedit.registry.state.IntegerProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.nbt.BinaryTag;
@ -295,9 +295,16 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
return state.toBaseBlock();
}
private static final Set<SideEffect> SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet(
SideEffect.HISTORY,
SideEffect.HEIGHTMAPS,
SideEffect.LIGHTING,
SideEffect.NEIGHBORS
);
@Override
public Set<SideEffect> getSupportedSideEffects() {
return SideEffectSet.defaults().getSideEffectsToApply();
return SUPPORTED_SIDE_EFFECTS;
}
@Override
@ -631,8 +638,13 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
@Override
public PlacementStateProcessor getPlatformPlacementProcessor(Extent extent, BlockTypeMask mask, boolean includeUnedited) {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
public PlacementStateProcessor getPlatformPlacementProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited
) {
return new PaperweightPlacementStateProcessor(extent, mask, secondPass, includeUnedited);
}
private boolean wasAccessibleSinceLastSave(ChunkHolder holder) {

Datei anzeigen

@ -22,7 +22,6 @@ public class PaperweightLevelProxy extends ServerLevel {
private PaperweightFaweAdapter adapter;
private Extent extent;
private ServerLevel serverLevel;
private boolean enabled = false;
@SuppressWarnings("DataFlowIssue")
public PaperweightLevelProxy() {
@ -47,14 +46,10 @@ public class PaperweightLevelProxy extends ServerLevel {
return newLevel;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@Nullable
@Override
public BlockEntity getBlockEntity(@Nonnull BlockPos blockPos) {
if (!enabled) {
if (blockPos.getX() == Integer.MAX_VALUE) {
return null;
}
BlockEntity tileEntity = this.serverLevel.getChunkAt(blockPos).getBlockEntity(blockPos);
@ -77,7 +72,7 @@ public class PaperweightLevelProxy extends ServerLevel {
@Override
@Nonnull
public BlockState getBlockState(@Nonnull BlockPos blockPos) {
if (!enabled) {
if (blockPos.getX() == Integer.MAX_VALUE) {
return Blocks.AIR.defaultBlockState();
}
com.sk89q.worldedit.world.block.BlockState state = this.extent.getBlock(
@ -92,7 +87,7 @@ public class PaperweightLevelProxy extends ServerLevel {
@Override
@Nonnull
public FluidState getFluidState(@Nonnull BlockPos pos) {
if (!enabled) {
if (pos.getX() == Integer.MAX_VALUE) {
return Fluids.EMPTY.defaultFluidState();
}
return getBlockState(pos).getFluidState();
@ -101,7 +96,7 @@ public class PaperweightLevelProxy extends ServerLevel {
@SuppressWarnings("unused")
@Override
public boolean isWaterAt(@Nonnull BlockPos pos) {
if (!enabled) {
if (pos.getX() == Integer.MAX_VALUE) {
return false;
}
return getBlockState(pos).getFluidState().is(FluidTags.WATER);

Datei anzeigen

@ -1,6 +1,7 @@
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4;
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
import com.fastasyncworldedit.core.math.IntTriple;
import com.fastasyncworldedit.core.util.ExtentTraverser;
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
import com.sk89q.worldedit.EditSession;
@ -21,20 +22,23 @@ import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.CraftWorld;
import javax.annotation.Nullable;
import java.util.Queue;
public class PaperweightPlacementStateProcessor extends PlacementStateProcessor {
private final PaperweightFaweAdapter adapter = ((PaperweightFaweAdapter) WorldEditPlugin
.getInstance()
.getBukkitImplAdapter());
private final PaperweightLevelProxy proxyLevel;
private final FaweMutableBlockPlaceContext mutableBlockPlaceContext;
public PaperweightPlacementStateProcessor(
final Extent extent,
final BlockTypeMask mask,
final boolean includeUnedited
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited
) {
super(extent, mask, includeUnedited);
super(extent, mask, secondPass, includeUnedited);
World world;
if (extent.isWorld()) {
world = (World) extent;
@ -49,34 +53,38 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
} else {
bukkitWorld = (BukkitWorld) world;
}
PaperweightLevelProxy proxyLevel = PaperweightLevelProxy.getInstance(
((CraftWorld) bukkitWorld.getWorld()).getHandle(),
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(),
extent
);
mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
proxyLevel.setEnabled(true);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
private PaperweightPlacementStateProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited,
Queue<IntTriple> crossChunkSecondPasses,
PaperweightLevelProxy proxyLevel
) {
super(extent, mask, secondPass, includeUnedited, crossChunkSecondPasses);
this.proxyLevel = proxyLevel;
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel);
}
@Override
protected char getStateAtFor(
int x,
int y,
int z,
BlockState state,
Vector3 clickPos,
Direction clickedFaceDirection,
BlockVector3 clickedBlock
int x, int y, int z, BlockState state, Vector3 clickPos, Direction clickedFaceDirection, BlockVector3 clickedBlock
) {
Block block = ((PaperweightBlockMaterial) state.getMaterial()).getBlock();
Vec3 pos = new Vec3(clickPos.x(), clickPos.y(), clickPos.z());
net.minecraft.core.Direction side = net.minecraft.core.Direction.valueOf(clickedFaceDirection.toString());
BlockPos blockPos = new BlockPos(clickedBlock.x(), clickedBlock.y(), clickedBlock.z());
net.minecraft.world.level.block.state.BlockState newState = block.getStateForPlacement(mutableBlockPlaceContext.withSetting(
new BlockHitResult(pos, side, blockPos, false),
net.minecraft.world.level.block.state.BlockState newState = block.getStateForPlacement(mutableBlockPlaceContext.withSetting(new BlockHitResult(pos, side, blockPos, false),
side.getOpposite()
));
return newState == null ? BlockTypesCache.ReservedIDs.AIR :
adapter.ibdIDToOrdinal(Block.BLOCK_STATE_REGISTRY.getId(newState));
return newState == null ? BlockTypesCache.ReservedIDs.AIR : adapter.ibdIDToOrdinal(Block.BLOCK_STATE_REGISTRY.getId(
newState));
}
@Override
@ -85,12 +93,19 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
if (child == getExtent()) {
return this;
}
return new PaperweightPlacementStateProcessor(child, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(child, mask, secondPass, includeUnedited);
}
@Override
public PlacementStateProcessor fork() {
return new PaperweightPlacementStateProcessor(extent, mask, includeUnedited);
return new PaperweightPlacementStateProcessor(
extent,
mask,
secondPass,
includeUnedited,
crossChunkSecondPasses,
proxyLevel
);
}
}

Datei anzeigen

@ -314,8 +314,13 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
}
@Override
public PlacementStateProcessor getPlatformPlacementProcessor(Extent extent, BlockTypeMask mask, boolean includeUnedited) {
return this.plugin.getBukkitImplAdapter().getPlatformPlacementProcessor(extent, mask, includeUnedited);
public PlacementStateProcessor getPlatformPlacementProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited
) {
return this.plugin.getBukkitImplAdapter().getPlatformPlacementProcessor(extent, mask, secondPass, includeUnedited);
}
//FAWE end
}

Datei anzeigen

@ -368,7 +368,12 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
* Returns an {@link PlacementStateProcessor} instance for processing placed blocks to "fix" them.
* @since TODO
*/
default PlacementStateProcessor getPlatformPlacementProcessor(Extent extent, BlockTypeMask mask, boolean includeUnedited) {
default PlacementStateProcessor getPlatformPlacementProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited
) {
return null;
}
//FAWE end

Datei anzeigen

@ -784,6 +784,11 @@ public class Settings extends Config {
})
public boolean UNSTUCK_ON_GENERATE = true;
@Comment({
"If edits that have a block update processor applied should also perform a second pass",
})
public boolean PERFORM_SECOND_UPDATE_PASS = true;
}
}

Datei anzeigen

@ -1,9 +1,10 @@
package com.fastasyncworldedit.core.extent.processor;
import com.fastasyncworldedit.core.extent.filter.block.FilterBlock;
import com.fastasyncworldedit.core.math.IntPair;
import com.fastasyncworldedit.core.math.IntTriple;
import com.fastasyncworldedit.core.math.MutableBlockVector3;
import com.fastasyncworldedit.core.math.MutableVector3;
import com.fastasyncworldedit.core.queue.Filter;
import com.fastasyncworldedit.core.queue.IBatchProcessor;
import com.fastasyncworldedit.core.queue.IChunk;
import com.fastasyncworldedit.core.queue.IChunkGet;
@ -27,23 +28,39 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import java.util.ArrayDeque;
import java.util.EnumSet;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.stream.Collectors;
public abstract class PlacementStateProcessor extends AbstractDelegateExtent implements IBatchProcessor, Filter, Pattern {
public abstract class PlacementStateProcessor extends AbstractDelegateExtent implements IBatchProcessor, Pattern {
private static final Direction[] NESW = new Direction[]{Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
private static volatile boolean SETUP = false;
private static BlockTypeMask DEFAULT_MASK = null;
private static BlockTypeMask SECOND_MASK = null;
private static BlockTypeMask REQUIRES_SECOND_PASS = null;
protected final Extent extent;
protected final BlockTypeMask mask;
protected final boolean includeUnedited;
protected final boolean secondPass;
protected final Queue<IntTriple> crossChunkSecondPasses;
private final MutableVector3 clickPos = new MutableVector3();
private final MutableBlockVector3 clickedBlock = new MutableBlockVector3();
public PlacementStateProcessor(Extent extent, BlockTypeMask mask, boolean includeUnedited) {
/**
* Process/extent/pattern for performing block updates, e.g. stair shape and glass pane connections
*
* @param extent Extent to use
* @param mask Mask of blocks to perform updates on
* @param secondPass Perform a second pass typically around stairs. May perform cross-chunk second passes too
* @param includeUnedited if unedited blocks should be processed as well
* @since TODO
*/
public PlacementStateProcessor(Extent extent, BlockTypeMask mask, boolean secondPass, boolean includeUnedited) {
super(extent);
// Required here as child classes are located within adapters and will therefore be statically accessed on startup,
// meaning we attempt to access BlockTypes class before it is correctly initialised.
@ -56,12 +73,29 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
}
this.extent = extent;
this.mask = mask == null ? DEFAULT_MASK : mask;
this.secondPass = secondPass;
this.includeUnedited = includeUnedited;
this.crossChunkSecondPasses = secondPass ? null : new ConcurrentLinkedQueue<>();
}
protected PlacementStateProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited,
Queue<IntTriple> crossChunkSecondPasses
) {
super(extent);
this.extent = extent;
this.mask = mask;
this.secondPass = secondPass;
this.includeUnedited = includeUnedited;
this.crossChunkSecondPasses = crossChunkSecondPasses;
}
private static void setup() {
DEFAULT_MASK = new BlockTypeMask(new NullExtent());
DEFAULT_MASK.add(
REQUIRES_SECOND_PASS = new BlockTypeMask(new NullExtent());
REQUIRES_SECOND_PASS.add(
BlockTypes.IRON_BARS,
BlockTypes.GLASS_PANE,
BlockTypes.BLACK_STAINED_GLASS_PANE,
@ -80,6 +114,27 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
BlockTypes.ORANGE_STAINED_GLASS_PANE,
BlockTypes.RED_STAINED_GLASS_PANE,
BlockTypes.WHITE_STAINED_GLASS_PANE,
BlockTypes.TRIPWIRE,
BlockTypes.TWISTING_VINES_PLANT,
BlockTypes.CAVE_VINES_PLANT,
BlockTypes.WEEPING_VINES_PLANT,
BlockTypes.VINE,
BlockTypes.REDSTONE_WIRE
);
BlockCategory[] categories = new BlockCategory[]{
BlockCategories.FENCES,
BlockCategories.FENCE_GATES,
BlockCategories.WALLS,
BlockCategories.CAVE_VINES
};
for (BlockCategory category : categories) {
if (category != null) {
REQUIRES_SECOND_PASS.add(category.getAll());
}
}
DEFAULT_MASK = REQUIRES_SECOND_PASS.copy();
DEFAULT_MASK.add(
BlockTypes.CHORUS_PLANT,
BlockTypes.DRIPSTONE_BLOCK,
BlockTypes.POINTED_DRIPSTONE,
@ -91,20 +146,20 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
BlockTypes.CRAFTER,
BlockTypes.MUSHROOM_STEM,
BlockTypes.BROWN_MUSHROOM_BLOCK,
BlockTypes.RED_MUSHROOM_BLOCK,
BlockTypes.TRIPWIRE,
BlockTypes.TWISTING_VINES_PLANT,
BlockTypes.CAVE_VINES_PLANT,
BlockTypes.WEEPING_VINES_PLANT,
BlockTypes.VINE,
BlockTypes.REDSTONE_WIRE
BlockTypes.RED_MUSHROOM_BLOCK
);
BlockCategory[] categories = new BlockCategory[]{BlockCategories.FENCES, BlockCategories.FENCE_GATES, BlockCategories.STAIRS, BlockCategories.WALLS, BlockCategories.BAMBOO_BLOCKS, BlockCategories.CAVE_VINES, BlockCategories.TALL_FLOWERS};
categories = new BlockCategory[]{
BlockCategories.STAIRS,
BlockCategories.BAMBOO_BLOCKS,
BlockCategories.TALL_FLOWERS
};
for (BlockCategory category : categories) {
if (category != null) {
DEFAULT_MASK.add(category.getAll());
}
}
SECOND_MASK = new BlockTypeMask(new NullExtent());
SECOND_MASK.add(BlockCategories.STAIRS.getAll());
SETUP = true;
}
@ -121,57 +176,128 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
continue;
}
}
Queue<IntPair> secondPasses = this.secondPass ? new ArrayDeque<>() : null;
for (int y = 0, i = 0; y < 16; y++) {
int blockY = layerY + y;
// Perform second pass to ensure changes to stairs are propagated to fences, walls, etc.
// Always perform if within chunk boundaries as this is not very costly.
// Only perform outside chunk boundaries if secondPass is not null
for (int z = 0; z < 16; z++) {
int blockZ = chunkZ + z;
for (int x = 0; x < 16; x++, i++) {
int blockX = chunkX + x;
char ordinal = set == null ? BlockTypesCache.ReservedIDs.__RESERVED__ : set[i];
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
if (!includeUnedited) {
checkAndPerformUpdate(iChunkGet, iChunkSet, get, set, layer, i, blockX, blockY, blockZ, x, z, secondPasses);
}
}
if (!secondPass || secondPasses.isEmpty()) {
continue;
}
if (get == null) {
get = iChunkGet.load(layer);
}
ordinal = get[i];
}
BlockState state = BlockTypesCache.states[ordinal];
if (!mask.test(state.getBlockType())) {
continue;
}
char newOrdinal = getBlockOrdinal(blockX, blockY, blockZ, state);
if (set == null) {
set = iChunkSet.load(layer);
}
set[i] = newOrdinal;
IntPair pair;
while ((pair = secondPasses.poll()) != null) {
int x = pair.x();
int z = pair.z();
int blockX = chunkX + x;
int blockZ = chunkZ + z;
if (x < 0 || x > 15 || z < 0 || z > 15) {
crossChunkSecondPasses.add(new IntTriple(blockX, blockY, blockZ));
}
int index = (y & 15) << 8 | z << 4 | x;
checkAndPerformUpdate(iChunkGet, iChunkSet, get, set, layer, index, blockX, blockY, blockZ, x, z, null);
}
}
}
return iChunkSet;
}
private void checkAndPerformUpdate(
IChunkGet iChunkGet,
IChunkSet iChunkSet,
char[] get,
char[] set,
int layer,
int index,
int blockX,
int blockY,
int blockZ,
int x,
int z,
Queue<IntPair> secondPasses
) {
char ordinal = set == null ? BlockTypesCache.ReservedIDs.__RESERVED__ : set[index];
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
if (!includeUnedited) {
return;
}
if (get == null) {
get = iChunkGet.load(layer);
}
ordinal = get[index];
}
BlockState state = BlockTypesCache.states[ordinal];
if (secondPasses == null && secondPass) {
if (!REQUIRES_SECOND_PASS.test(state.getBlockType())) {
return;
}
}
if (!mask.test(state.getBlockType())) {
return;
}
char newOrdinal = getBlockOrdinal(blockX, blockY, blockZ, state);
if (newOrdinal == ordinal) {
return;
}
if (secondPasses != null && (BlockCategories.STAIRS.contains(state) || secondPass && SECOND_MASK.test(state.getBlockType()))) {
secondPasses.add(new IntPair(x - 1, z));
secondPasses.add(new IntPair(x + 1, z));
secondPasses.add(new IntPair(x, z - 1));
secondPasses.add(new IntPair(x, z + 1));
}
if (set == null) {
set = iChunkSet.load(layer);
}
set[index] = newOrdinal;
}
@Override
public ProcessorScope getScope() {
return ProcessorScope.CHANGING_BLOCKS;
}
@Override
public void flush() {
IntTriple coords;
while ((coords = crossChunkSecondPasses.poll()) != null) {
BlockState state = extent.getBlock(coords.x(), coords.y(), coords.z());
char ordinal = state.getOrdinalChar();
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
continue;
}
if (!mask.test(state.getBlockType())) {
continue;
}
char newOrdinal = getBlockOrdinal(coords.x(), coords.y(), coords.z(), state);
if (newOrdinal == ordinal) {
continue;
}
extent.setBlock(coords.x(), coords.y(), coords.z(), BlockTypesCache.states[newOrdinal]);
}
}
@Override
public abstract PlacementStateProcessor fork();
// Require block type to avoid duplicate lookup
protected abstract char getStateAtFor(
int x, int y, int z, BlockState state, Vector3 clickPos, Direction clickedFaceDirection, BlockVector3 clickedBlock
int x,
int y,
int z,
BlockState state,
Vector3 clickPos,
Direction clickedFaceDirection,
BlockVector3 clickedBlock
);
private char getBlockOrdinal(
final int blockX,
final int blockY,
final int blockZ,
final BlockState state
) {
private char getBlockOrdinal(final int blockX, final int blockY, final int blockZ, final BlockState state) {
EnumSet<Direction> dirs = Direction.getDirections(state);
Direction clickedFaceDirection = null; // This should be always be set by the below.
Set<String> states = state.getStates().keySet().stream().map(Property::getName).collect(Collectors.toSet());

Datei anzeigen

@ -10,13 +10,14 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import javax.annotation.Nullable;
import java.io.Flushable;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.function.Function;
public interface IBatchProcessor {
public interface IBatchProcessor extends Flushable {
/**
* Process a chunk that has been set.

Datei anzeigen

@ -37,6 +37,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import org.apache.logging.log4j.Logger;
import java.io.Flushable;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -135,7 +136,7 @@ public class ParallelQueueExtent extends PassthroughExtent {
// if PQE is ever used with PARALLEL_THREADS = 1, or only one chunk is edited, just run sequentially
while (chunksIter.hasNext()) {
BlockVector2 pos = chunksIter.next();
getExtent().apply(null, filter, region, pos.getX(), pos.getZ(), full);
getExtent().apply(null, filter, region, pos.x(), pos.z(), full);
}
} else {
final ForkJoinTask[] tasks = IntStream.range(0, size).mapToObj(i -> handler.submit(() -> {
@ -159,11 +160,14 @@ public class ParallelQueueExtent extends PassthroughExtent {
break;
}
final BlockVector2 pos = chunksIter.next();
chunkX = pos.getX();
chunkZ = pos.getZ();
chunkX = pos.x();
chunkZ = pos.z();
}
block = queue.apply(block, newFilter, region, chunkX, chunkZ, full);
}
if (newFilter instanceof Flushable flushable) {
flushable.flush();
}
queue.flush();
} catch (Throwable t) {
if (t instanceof FaweException) {

Datei anzeigen

@ -65,6 +65,8 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
@ -104,6 +106,7 @@ public final class EditSessionBuilder {
private Extent extent;
private boolean compiled;
private boolean wrapped;
private SideEffectSet sideEffectSet = SideEffectSet.defaults();
private @Nullable
World world;
@ -415,6 +418,14 @@ public final class EditSessionBuilder {
return setDirty();
}
/**
* Set the side effects to be used with this edit
*/
public EditSessionBuilder setSideEffectSet(@Nullable SideEffectSet sideEffectSet) {
this.sideEffectSet = sideEffectSet;
return setDirty();
}
/**
* Compile the builder to the settings given. Prepares history, limits, lighting, etc.
*/
@ -445,6 +456,9 @@ public final class EditSessionBuilder {
fastMode = actor.getSession().hasFastMode();
}
}
if (fastMode) {
sideEffectSet = SideEffectSet.none();
}
if (checkMemory == null) {
checkMemory = actor != null && !this.fastMode;
}
@ -491,7 +505,7 @@ public final class EditSessionBuilder {
}
extent = this.bypassAll = wrapExtent(extent, eventBus, event, EditSession.Stage.BEFORE_CHANGE);
this.bypassHistory = this.extent = wrapExtent(bypassAll, eventBus, event, EditSession.Stage.BEFORE_REORDER);
if (!this.fastMode || changeSet != null) {
if (!this.fastMode || this.sideEffectSet.shouldApply(SideEffect.HISTORY) || changeSet != null) {
if (changeSet == null) {
if (Settings.settings().HISTORY.USE_DISK) {
UUID uuid = actor == null ? Identifiable.CONSOLE : actor.getUniqueId();
@ -546,13 +560,31 @@ public final class EditSessionBuilder {
}
// There's no need to do the below (and it'll also just be a pain to implement) if we're not placing chunks
if (placeChunks) {
if (((relightMode != null && relightMode != RelightMode.NONE) || (relightMode == null && Settings.settings().LIGHTING.MODE > 0))) {
relighter = WorldEdit.getInstance().getPlatformManager()
if (this.sideEffectSet.shouldApply(SideEffect.LIGHTING) &&
((relightMode != null && relightMode != RelightMode.NONE) || (relightMode == null && Settings.settings().LIGHTING.MODE > 0))) {
relighter = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.WORLD_EDITING)
.getRelighterFactory().createRelighter(relightMode, world, queue);
.getRelighterFactory()
.createRelighter(relightMode, world, queue);
queue.addProcessor(new RelightProcessor(relighter));
}
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)) {
queue.addProcessor(WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.WORLD_EDITING)
.getPlatformPlacementProcessor(
queue,
null,
Settings.settings().GENERAL.PERFORM_SECOND_UPDATE_PASS,
true
));
}
if (!Settings.settings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
queue.addProcessor(new EntityInBlockRemovingProcessor());
@ -710,6 +742,13 @@ public final class EditSessionBuilder {
return changeSet;
}
/**
* Get the SideEffectSet that will be used
*/
public SideEffectSet getSideEffectSet() {
return sideEffectSet;
}
/**
* Get the ultimate resultant extent
*/

Datei anzeigen

@ -1730,6 +1730,7 @@ public class LocalSession implements TextureHolder {
}
builder.command(command);
builder.fastMode(!this.sideEffectSet.doesApplyAny());
builder.setSideEffectSet(this.sideEffectSet);
editSession = builder.build();

Datei anzeigen

@ -41,6 +41,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.function.GroundFunction;
import com.sk89q.worldedit.function.generator.FloraGenerator;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection;
@ -903,7 +904,9 @@ public class RegionCommands {
@Confirm(Confirm.Processor.REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
public int fixblocks(
Actor actor, EditSession editSession, @Selection Region region
Actor actor, EditSession editSession, @Selection Region region,
@Switch(name = 'n', desc = "Do not perform a second pass ")
boolean noSecondPass
) {
int affected = editSession.setBlocks(
region,
@ -911,7 +914,7 @@ public class RegionCommands {
.getInstance()
.getPlatformManager()
.queryCapability(Capability.WORLD_EDITING)
.getPlatformPlacementProcessor(editSession, null, true)
.getPlatformPlacementProcessor(editSession, null, !noSecondPass, true)
);
if (affected != 0) {
actor.print(Caption.of("worldedit.set.done", TextComponent.of(affected)));

Datei anzeigen

@ -284,7 +284,12 @@ public interface Platform extends Keyed {
* Returns an {@link PlacementStateProcessor} instance for processing placed blocks to "fix" them.
* @since TODO
*/
default PlacementStateProcessor getPlatformPlacementProcessor(Extent extent, BlockTypeMask mask, boolean includeUnedited) {
default PlacementStateProcessor getPlatformPlacementProcessor(
Extent extent,
BlockTypeMask mask,
boolean secondPass,
boolean includeUnedited
) {
return null;
}
//FAWE end

Datei anzeigen

@ -149,7 +149,7 @@ public class BlockTypeMask extends AbstractExtentMask {
}
@Override
public Mask copy() {
public BlockTypeMask copy() {
return new BlockTypeMask(getExtent(), types.clone(), hasAir);
}

Datei anzeigen

@ -19,23 +19,30 @@
package com.sk89q.worldedit.util;
import com.fastasyncworldedit.core.configuration.Settings;
import java.util.Locale;
public enum SideEffect {
LIGHTING(State.ON, true),
NEIGHBORS(State.ON, true),
UPDATE(State.ON, true),
//FAWE start - adjust defaults, add history and heightmaps
HISTORY(State.ON, true),
HEIGHTMAPS(State.ON, true),
LIGHTING(State.OFF, true), // Off defaults to falling through to config
NEIGHBORS(State.OFF, true),
UPDATE(State.OFF, true),
//FAWE end
VALIDATION(State.OFF, true),
ENTITY_AI(State.OFF, true),
EVENTS(State.OFF, true),
/**
* Internal use only.
*/
POI_UPDATE(State.ON, false),
POI_UPDATE(State.OFF, false),
/**
* Internal use only.
*/
NETWORK(State.ON, false);
NETWORK(State.OFF, false);
//FAWE end
private final String displayName;
private final String description;