mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 19:36:41 +00:00
Merge pull request #518 from aurorasmiles/fixEntities
start reimplementing entities
This commit is contained in:
@ -40,11 +40,15 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -153,6 +157,11 @@ public class AbstractDelegateExtent implements Extent {
|
||||
return extent.createEntity(location, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntity(int x, int y, int z, UUID uuid) {
|
||||
extent.removeEntity(x, y, z, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
return extent.getEntities();
|
||||
|
@ -37,11 +37,6 @@ public class PassthroughExtent extends AbstractDelegateExtent {
|
||||
super(extent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntity(int x, int y, int z, UUID uuid) {
|
||||
getExtent().removeEntity(x, y, z, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(int x, int z, @Nullable BiomeType type, @Nullable Long seed) {
|
||||
return getExtent().regenerateChunk(x, z, type, seed);
|
||||
|
@ -45,6 +45,7 @@ import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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,13 +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().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
|
||||
@ -286,7 +323,7 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
private final float yaw, pitch;
|
||||
|
||||
public ClipboardEntity(Location loc, BaseEntity entity) {
|
||||
this((Clipboard) loc.getExtent(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getYaw(), loc.getPitch(), entity);
|
||||
this((Clipboard) loc.getExtent(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), entity);
|
||||
}
|
||||
|
||||
public ClipboardEntity(Clipboard clipboard, double x, double y, double z, float yaw, float pitch, BaseEntity entity) {
|
||||
|
Reference in New Issue
Block a user