mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
fix //move -e
This commit is contained in:
parent
3c70cdc9fd
commit
bf09d6922c
@ -1,11 +1,9 @@
|
|||||||
package com.boydti.fawe.beta.implementation;
|
package com.boydti.fawe.beta.implementation;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.IChunk;
|
import com.boydti.fawe.beta.IChunk;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.DoubleTag;
|
import com.sk89q.jnbt.DoubleTag;
|
||||||
import com.sk89q.jnbt.IntArrayTag;
|
import com.sk89q.jnbt.IntArrayTag;
|
||||||
import com.sk89q.jnbt.IntTag;
|
|
||||||
import com.sk89q.jnbt.ListTag;
|
import com.sk89q.jnbt.ListTag;
|
||||||
import com.sk89q.jnbt.LongTag;
|
import com.sk89q.jnbt.LongTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
@ -111,39 +109,24 @@ public interface IChunkExtent<T extends IChunk> extends Extent {
|
|||||||
@Override
|
@Override
|
||||||
default Entity createEntity(Location location, BaseEntity entity) {
|
default Entity createEntity(Location location, BaseEntity entity) {
|
||||||
final IChunk chunk = getOrCreateChunk(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
final IChunk chunk = getOrCreateChunk(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||||
CompoundTag tag = entity.getNbtData();
|
Map<String, Tag> map = new HashMap<>(entity.getNbtData().getValue()); //do not modify original entity data
|
||||||
Map<String, Tag> map = new HashMap<>(tag.getValue()); //do not modify original entity data
|
|
||||||
map.put("Id", new StringTag(entity.getType().getName()));
|
map.put("Id", new StringTag(entity.getType().getName()));
|
||||||
|
|
||||||
//Set pos
|
//Set pos
|
||||||
ListTag pos = (ListTag) map.get("Pos");
|
List<DoubleTag> posList = new ArrayList<>();
|
||||||
List<Tag> posList;
|
posList.add(new DoubleTag(location.getX()));
|
||||||
if (pos != null) {
|
posList.add(new DoubleTag(location.getY()));
|
||||||
posList = ReflectionUtils.getList(pos.getValue());
|
posList.add(new DoubleTag(location.getZ()));
|
||||||
} else {
|
map.put("Pos", new ListTag(DoubleTag.class, posList));
|
||||||
posList = new ArrayList<>();
|
|
||||||
pos = new ListTag(DoubleTag.class, posList);
|
|
||||||
map.put("Pos", pos);
|
|
||||||
}
|
|
||||||
posList.set(0, new DoubleTag(location.getX()));
|
|
||||||
posList.set(1, new DoubleTag(location.getY()));
|
|
||||||
posList.set(2, new DoubleTag(location.getZ()));
|
|
||||||
|
|
||||||
//set new uuid
|
//set new uuid
|
||||||
UUID newuuid = UUID.randomUUID();
|
UUID newuuid = UUID.randomUUID();
|
||||||
IntArrayTag uuid = (IntArrayTag) map.get("UUID");
|
int[] uuidArray = new int[4];
|
||||||
int[] uuidArray;
|
|
||||||
if (uuid != null) {
|
|
||||||
uuidArray = uuid.getValue();
|
|
||||||
} else {
|
|
||||||
uuidArray = new int[4];
|
|
||||||
uuid = new IntArrayTag(uuidArray);
|
|
||||||
map.put("UUID", uuid);
|
|
||||||
}
|
|
||||||
uuidArray[0] = (int) (newuuid.getMostSignificantBits() >> 32);
|
uuidArray[0] = (int) (newuuid.getMostSignificantBits() >> 32);
|
||||||
uuidArray[1] = (int) newuuid.getMostSignificantBits();
|
uuidArray[1] = (int) newuuid.getMostSignificantBits();
|
||||||
uuidArray[2] = (int) (newuuid.getLeastSignificantBits() >> 32);
|
uuidArray[2] = (int) (newuuid.getLeastSignificantBits() >> 32);
|
||||||
uuidArray[3] = (int) newuuid.getLeastSignificantBits();
|
uuidArray[3] = (int) newuuid.getLeastSignificantBits();
|
||||||
|
map.put("UUID", new IntArrayTag(uuidArray));
|
||||||
|
|
||||||
map.put("UUIDMost", new LongTag(newuuid.getMostSignificantBits()));
|
map.put("UUIDMost", new LongTag(newuuid.getMostSignificantBits()));
|
||||||
map.put("UUIDLeast", new LongTag(newuuid.getLeastSignificantBits()));
|
map.put("UUIDLeast", new LongTag(newuuid.getLeastSignificantBits()));
|
||||||
@ -151,7 +134,7 @@ public interface IChunkExtent<T extends IChunk> extends Extent {
|
|||||||
map.put("PersistentIDMSB", new LongTag(newuuid.getMostSignificantBits()));
|
map.put("PersistentIDMSB", new LongTag(newuuid.getMostSignificantBits()));
|
||||||
map.put("PersistentIDLSB", new LongTag(newuuid.getLeastSignificantBits()));
|
map.put("PersistentIDLSB", new LongTag(newuuid.getLeastSignificantBits()));
|
||||||
|
|
||||||
chunk.setEntity(tag);
|
chunk.setEntity(new CompoundTag(map));
|
||||||
return new IChunkEntity(this, location, newuuid, entity);
|
return new IChunkEntity(this, location, newuuid, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user