From cf96c478be334eaf147fd2ad8d286e379065ef5b Mon Sep 17 00:00:00 2001 From: SirYwell Date: Sat, 22 Dec 2018 00:46:05 +0100 Subject: [PATCH] change entity list to ignore player when pasting --- .../boydti/fawe/object/schematic/Schematic.java | 4 ++++ .../function/operation/ForwardExtentCopy.java | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java index 46268ff1b..a9f6bb9a2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java @@ -274,6 +274,10 @@ public class Schematic { final int entityOffsetZ = to.getBlockZ() - origin.getBlockZ(); // entities for (Entity entity : clipboard.getEntities()) { + // skip players on pasting schematic + if (entity.getState() != null && entity.getState().getType().getId().equals("minecraft:player")) { + continue; + } Location pos = entity.getLocation(); Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX, pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(), pos.getPitch()); extent.createEntity(newPos, entity.getState()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java index 2ebaacb39..30a978121 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java @@ -50,7 +50,7 @@ import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.Region; import java.util.ArrayList; import java.util.List; - +import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -347,7 +347,18 @@ public class ForwardExtentCopy implements Operation { blockCopy = new RegionVisitor(region, copy, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null); } - List entities = isCopyingEntities() ? source.getEntities(region) : new ArrayList<>(); + List entities; + if (isCopyingEntities()) { + // filter players since they can't be copied + entities = source.getEntities() + .stream() + .filter(entity -> entity.getState() != null && + entity.getState().getType().getId().equals("minecraft:player")) + .collect(Collectors.toList()); + } else { + entities = new ArrayList<>(); + } + for (int i = 0; i < repetitions; i++) { Operations.completeBlindly(blockCopy);