mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
fix rotation of entities in clipboard
This commit is contained in:
parent
950f343339
commit
a38c82304a
@ -40,6 +40,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -436,6 +437,11 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
public List<? extends Entity> getEntities() {
|
||||
return new ArrayList<>(entities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
return new ArrayList<>(entities.stream().filter(e -> region.contains(e.getLocation().toBlockPoint())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntity(Entity entity) {
|
||||
|
@ -26,6 +26,7 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
@ -291,11 +292,15 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
return new ArrayList<>(entities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
return new ArrayList<>(entities.stream().filter(e -> region.contains(e.getLocation().toBlockPoint())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntity(Entity entity) {
|
||||
if (entity instanceof ClipboardEntity) {
|
||||
this.entities.remove(entity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ import java.util.UUID;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Stores block data as a multi-dimensional array of {@link BlockState}s and
|
||||
@ -197,18 +198,49 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
region = region.clone();
|
||||
region.shift(BlockVector3.ZERO.subtract(origin));
|
||||
return getParent().getEntities(region);
|
||||
return getParent().getEntities(region).stream().map(e ->
|
||||
{
|
||||
if (e instanceof ClipboardEntity) {
|
||||
ClipboardEntity ce = (ClipboardEntity) e;
|
||||
Location oldloc = ce.getLocation();
|
||||
Location loc = new Location(oldloc.getExtent(),
|
||||
oldloc.getX() + origin.getBlockX(),
|
||||
oldloc.getY() + origin.getBlockY(),
|
||||
oldloc.getZ() + origin.getBlockZ(),
|
||||
oldloc.getYaw(), oldloc.getPitch());
|
||||
return new ClipboardEntity(loc, ce.entity);
|
||||
}
|
||||
return e;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
return getParent().getEntities();
|
||||
return getParent().getEntities().stream().map(e ->
|
||||
{
|
||||
if (e instanceof ClipboardEntity) {
|
||||
ClipboardEntity ce = (ClipboardEntity) e;
|
||||
Location oldloc = ce.getLocation();
|
||||
Location loc = new Location(oldloc.getExtent(),
|
||||
oldloc.getX() + origin.getBlockX(),
|
||||
oldloc.getY() + origin.getBlockY(),
|
||||
oldloc.getZ() + origin.getBlockZ(),
|
||||
oldloc.getYaw(), oldloc.getPitch());
|
||||
return new ClipboardEntity(loc, ce.entity);
|
||||
}
|
||||
return e;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
return getParent().createEntity(location, entity);
|
||||
Location l = new Location(location.getExtent(),
|
||||
location.getX() - origin.getBlockX(),
|
||||
location.getY() - origin.getBlockY(),
|
||||
location.getZ() - origin.getBlockZ(),
|
||||
location.getYaw(), location.getPitch());
|
||||
return getParent().createEntity(l, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user