mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 04:18:34 +00:00
fix //cut -e
This commit is contained in:
@ -20,6 +20,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -111,7 +112,7 @@ public interface IChunkExtent<T extends IChunk> extends Extent {
|
||||
default Entity createEntity(Location location, BaseEntity entity) {
|
||||
final IChunk chunk = getOrCreateChunk(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
CompoundTag tag = entity.getNbtData();
|
||||
Map<String, Tag> map = ReflectionUtils.getMap(tag.getValue());
|
||||
Map<String, Tag> map = new HashMap<>(tag.getValue()); //do not modify original entity data
|
||||
map.put("Id", new StringTag(entity.getType().getName()));
|
||||
|
||||
//Set pos
|
||||
@ -147,8 +148,11 @@ public interface IChunkExtent<T extends IChunk> extends Extent {
|
||||
map.put("UUIDMost", new LongTag(newuuid.getMostSignificantBits()));
|
||||
map.put("UUIDLeast", new LongTag(newuuid.getLeastSignificantBits()));
|
||||
|
||||
map.put("PersistentIDMSB", new LongTag(newuuid.getMostSignificantBits()));
|
||||
map.put("PersistentIDLSB", new LongTag(newuuid.getLeastSignificantBits()));
|
||||
|
||||
chunk.setEntity(tag);
|
||||
return null;
|
||||
return new IChunkEntity(this, location, newuuid, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -156,4 +160,50 @@ public interface IChunkExtent<T extends IChunk> extends Extent {
|
||||
final IChunk chunk = getOrCreateChunk(x >> 4, z >> 4);
|
||||
chunk.removeEntity(uuid);
|
||||
}
|
||||
|
||||
class IChunkEntity implements Entity {
|
||||
|
||||
private final Extent extent;
|
||||
private final Location location;
|
||||
private final UUID uuid;
|
||||
private final BaseEntity base;
|
||||
|
||||
public IChunkEntity(Extent extent, Location location, UUID uuid, BaseEntity base) {
|
||||
this.extent = extent;
|
||||
this.location = location;
|
||||
this.uuid = uuid;
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseEntity getState() {
|
||||
return base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove() {
|
||||
extent.removeEntity(location.getBlockX(), location.getBlockY(), location.getBlockZ(), uuid);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getFacet(Class<? extends T> cls) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setLocation(Location location) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,19 +90,6 @@ public class ReflectionUtils {
|
||||
}
|
||||
private static Class<?> UNMODIFIABLE_MAP = Collections.unmodifiableMap(Collections.EMPTY_MAP).getClass();
|
||||
|
||||
public static <T, V> Map<T, V> getMap(Map<T, V> map) {
|
||||
try {
|
||||
Class<? extends Map> clazz = map.getClass();
|
||||
if (clazz != UNMODIFIABLE_MAP) return map;
|
||||
Field m = clazz.getDeclaredField("m");
|
||||
m.setAccessible(true);
|
||||
return (Map<T, V>) m.get(map);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getHandle(Object wrapper) {
|
||||
final Method getHandle = makeMethod(wrapper.getClass(), "getHandle");
|
||||
return callMethod(getHandle, wrapper);
|
||||
|
Reference in New Issue
Block a user