Merge pull request #5 from SirYwell/master

change entity list to ignore player when pasting
This commit is contained in:
NotMyFault 2018-12-22 09:04:45 +01:00 committed by GitHub
commit 8d5a655a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -274,6 +274,10 @@ public class Schematic {
final int entityOffsetZ = to.getBlockZ() - origin.getBlockZ(); final int entityOffsetZ = to.getBlockZ() - origin.getBlockZ();
// entities // entities
for (Entity entity : clipboard.getEntities()) { 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 pos = entity.getLocation();
Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX, pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(), pos.getPitch()); Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX, pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(), pos.getPitch());
extent.createEntity(newPos, entity.getState()); extent.createEntity(newPos, entity.getState());

View File

@ -50,7 +50,7 @@ import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; 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); blockCopy = new RegionVisitor(region, copy, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null);
} }
List<? extends Entity> entities = isCopyingEntities() ? source.getEntities(region) : new ArrayList<>(); List<? extends Entity> 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++) { for (int i = 0; i < repetitions; i++) {
Operations.completeBlindly(blockCopy); Operations.completeBlindly(blockCopy);