mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 08:28:35 +00:00
feat: implement removal of entities if they would be in a block after the edit (#2311)
- Includes some refactoring to EditSessionBuilder to prevent doubling-up of processors that are also extents - Better ordering of the EditSessionBuilder process/extent code to match where extents actually end up in the stack - Fixes #1941
This commit is contained in:
@ -32,6 +32,7 @@ import com.fastasyncworldedit.core.extent.NullExtent;
|
||||
import com.fastasyncworldedit.core.extent.SingleRegionExtent;
|
||||
import com.fastasyncworldedit.core.extent.SlowExtent;
|
||||
import com.fastasyncworldedit.core.extent.StripNBTExtent;
|
||||
import com.fastasyncworldedit.core.extent.processor.EntityInBlockRemovingProcessor;
|
||||
import com.fastasyncworldedit.core.extent.processor.heightmap.HeightmapProcessor;
|
||||
import com.fastasyncworldedit.core.extent.processor.lighting.NullRelighter;
|
||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode;
|
||||
@ -543,25 +544,6 @@ public final class EditSessionBuilder {
|
||||
}
|
||||
}
|
||||
}
|
||||
FaweRegionExtent regionExtent = null;
|
||||
if (disallowedRegions != null) { // Always use MultiRegionExtent if we have blacklist regions
|
||||
regionExtent = new MultiRegionExtent(this.extent, this.limit, allowedRegions, disallowedRegions);
|
||||
} else if (allowedRegions == null) {
|
||||
allowedRegions = new Region[]{RegionWrapper.GLOBAL()};
|
||||
} else {
|
||||
if (allowedRegions.length == 0) {
|
||||
regionExtent = new NullExtent(this.extent, FaweCache.NO_REGION);
|
||||
} else {
|
||||
if (allowedRegions.length == 1) {
|
||||
regionExtent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
|
||||
} else {
|
||||
regionExtent = new MultiRegionExtent(this.extent, this.limit, allowedRegions, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (placeChunks && regionExtent != null) {
|
||||
queue.addProcessor(regionExtent);
|
||||
}
|
||||
// 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))) {
|
||||
@ -571,6 +553,11 @@ public final class EditSessionBuilder {
|
||||
queue.addProcessor(new RelightProcessor(relighter));
|
||||
}
|
||||
queue.addProcessor(new HeightmapProcessor(world.getMinY(), world.getMaxY()));
|
||||
|
||||
if (!Settings.settings().EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) {
|
||||
queue.addProcessor(new EntityInBlockRemovingProcessor());
|
||||
}
|
||||
|
||||
IBatchProcessor platformProcessor = WorldEdit
|
||||
.getInstance()
|
||||
.getPlatformManager()
|
||||
@ -590,24 +577,13 @@ public final class EditSessionBuilder {
|
||||
} else {
|
||||
relighter = NullRelighter.INSTANCE;
|
||||
}
|
||||
Consumer<Component> onErrorMessage;
|
||||
if (getActor() != null) {
|
||||
onErrorMessage = c -> getActor().print(Caption.of("fawe.error.occurred-continuing", c));
|
||||
} else {
|
||||
onErrorMessage = c -> {
|
||||
};
|
||||
}
|
||||
if (limit != null && !limit.isUnlimited() && regionExtent != null) {
|
||||
this.extent = new LimitExtent(regionExtent, limit, onErrorMessage);
|
||||
} else if (limit != null && !limit.isUnlimited()) {
|
||||
this.extent = new LimitExtent(this.extent, limit, onErrorMessage);
|
||||
} else if (regionExtent != null) {
|
||||
this.extent = regionExtent;
|
||||
}
|
||||
if (this.limit != null && this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) {
|
||||
this.extent = new StripNBTExtent(this.extent, this.limit.STRIP_NBT);
|
||||
StripNBTExtent ext = new StripNBTExtent(this.extent, this.limit.STRIP_NBT);
|
||||
if (placeChunks) {
|
||||
queue.addProcessor((IBatchProcessor) this.extent);
|
||||
queue.addProcessor(ext);
|
||||
}
|
||||
if (!placeChunks || !combineStages) {
|
||||
this.extent = ext;
|
||||
}
|
||||
}
|
||||
if (this.limit != null && !this.limit.isUnlimited()) {
|
||||
@ -620,12 +596,50 @@ public final class EditSessionBuilder {
|
||||
}
|
||||
Set<PropertyRemap<?>> remaps = this.limit.REMAP_PROPERTIES;
|
||||
if (!limitBlocks.isEmpty() || (remaps != null && !remaps.isEmpty())) {
|
||||
this.extent = new DisallowedBlocksExtent(this.extent, limitBlocks, remaps);
|
||||
DisallowedBlocksExtent ext = new DisallowedBlocksExtent(this.extent, limitBlocks, remaps);
|
||||
if (placeChunks) {
|
||||
queue.addProcessor((IBatchProcessor) this.extent);
|
||||
queue.addProcessor(ext);
|
||||
}
|
||||
if (!placeChunks || !combineStages) {
|
||||
this.extent = ext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FaweRegionExtent regionExtent = null;
|
||||
if (disallowedRegions != null) { // Always use MultiRegionExtent if we have blacklist regions
|
||||
regionExtent = new MultiRegionExtent(this.extent, this.limit, allowedRegions, disallowedRegions);
|
||||
} else if (allowedRegions == null) {
|
||||
allowedRegions = new Region[]{RegionWrapper.GLOBAL()};
|
||||
} else {
|
||||
if (allowedRegions.length == 0) {
|
||||
regionExtent = new NullExtent(this.extent, FaweCache.NO_REGION);
|
||||
} else {
|
||||
if (allowedRegions.length == 1) {
|
||||
regionExtent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
|
||||
} else {
|
||||
regionExtent = new MultiRegionExtent(this.extent, this.limit, allowedRegions, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (regionExtent != null) {
|
||||
if (placeChunks) {
|
||||
queue.addProcessor(regionExtent);
|
||||
}
|
||||
if (!placeChunks || !combineStages) {
|
||||
this.extent = regionExtent;
|
||||
}
|
||||
}
|
||||
Consumer<Component> onErrorMessage;
|
||||
if (getActor() != null) {
|
||||
onErrorMessage = c -> getActor().print(Caption.of("fawe.error.occurred-continuing", c));
|
||||
} else {
|
||||
onErrorMessage = c -> {
|
||||
};
|
||||
}
|
||||
if (limit != null && !limit.isUnlimited()) {
|
||||
this.extent = new LimitExtent(this.extent, limit, onErrorMessage);
|
||||
}
|
||||
this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY);
|
||||
}
|
||||
return this;
|
||||
|
@ -160,17 +160,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
// Remove
|
||||
if (isRemoving() && success) {
|
||||
//FAWE start
|
||||
UUID uuid = null;
|
||||
if (tag.containsKey("UUID")) {
|
||||
int[] arr = tag.getIntArray("UUID");
|
||||
uuid = new UUID((long) arr[0] << 32 | (arr[1] & 0xFFFFFFFFL), (long) arr[2] << 32 | (arr[3] & 0xFFFFFFFFL));
|
||||
} else if (tag.containsKey("UUIDMost")) {
|
||||
uuid = new UUID(tag.getLong("UUIDMost"), tag.getLong("UUIDLeast"));
|
||||
} else if (tag.containsKey("WorldUUIDMost")) {
|
||||
uuid = new UUID(tag.getLong("WorldUUIDMost"), tag.getLong("WorldUUIDLeast"));
|
||||
} else if (tag.containsKey("PersistentIDMSB")) {
|
||||
uuid = new UUID(tag.getLong("PersistentIDMSB"), tag.getLong("PersistentIDLSB"));
|
||||
}
|
||||
UUID uuid = entity.getState().getNbtData().getUUID();
|
||||
if (uuid != null) {
|
||||
if (source != null) {
|
||||
source.removeEntity(
|
||||
|
Reference in New Issue
Block a user