mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +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.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -437,6 +438,11 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
|||||||
return new ArrayList<>(entities);
|
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
|
@Override
|
||||||
public void removeEntity(Entity entity) {
|
public void removeEntity(Entity entity) {
|
||||||
this.entities.remove(entity);
|
this.entities.remove(entity);
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Collection;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class MemoryOptimizedClipboard extends LinearClipboard {
|
public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||||
@ -291,11 +292,15 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
|||||||
return new ArrayList<>(entities);
|
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
|
@Override
|
||||||
public void removeEntity(Entity entity) {
|
public void removeEntity(Entity entity) {
|
||||||
if (entity instanceof ClipboardEntity) {
|
if (entity instanceof ClipboardEntity) {
|
||||||
this.entities.remove(entity);
|
this.entities.remove(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import java.util.UUID;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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
|
* 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) {
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
region = region.clone();
|
region = region.clone();
|
||||||
region.shift(BlockVector3.ZERO.subtract(origin));
|
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
|
@Override
|
||||||
public List<? extends Entity> getEntities() {
|
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
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Entity createEntity(Location location, BaseEntity entity) {
|
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
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user