3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 11:00:04 +01:00

fix rotation of entities in clipboard

Dieser Commit ist enthalten in:
wea_ondara 2020-07-26 18:26:21 +02:00
Ursprung 950f343339
Commit a38c82304a
3 geänderte Dateien mit 47 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -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);

Datei anzeigen

@ -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);
} }
} }
} }

Datei anzeigen

@ -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