From bf09d6922cb1894a395ea97c800bc4196e0f5df4 Mon Sep 17 00:00:00 2001 From: wea_ondara Date: Thu, 30 Jul 2020 14:19:04 +0200 Subject: [PATCH] fix //move -e --- .../beta/implementation/IChunkExtent.java | 35 +++++-------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IChunkExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IChunkExtent.java index f355cecea..a8a3621ca 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IChunkExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IChunkExtent.java @@ -1,11 +1,9 @@ package com.boydti.fawe.beta.implementation; import com.boydti.fawe.beta.IChunk; -import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.DoubleTag; import com.sk89q.jnbt.IntArrayTag; -import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.LongTag; import com.sk89q.jnbt.StringTag; @@ -111,39 +109,24 @@ public interface IChunkExtent extends Extent { @Override default Entity createEntity(Location location, BaseEntity entity) { final IChunk chunk = getOrCreateChunk(location.getBlockX() >> 4, location.getBlockZ() >> 4); - CompoundTag tag = entity.getNbtData(); - Map map = new HashMap<>(tag.getValue()); //do not modify original entity data + Map map = new HashMap<>(entity.getNbtData().getValue()); //do not modify original entity data map.put("Id", new StringTag(entity.getType().getName())); //Set pos - ListTag pos = (ListTag) map.get("Pos"); - List posList; - if (pos != null) { - posList = ReflectionUtils.getList(pos.getValue()); - } else { - 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())); + List posList = new ArrayList<>(); + posList.add(new DoubleTag(location.getX())); + posList.add(new DoubleTag(location.getY())); + posList.add(new DoubleTag(location.getZ())); + map.put("Pos", new ListTag(DoubleTag.class, posList)); //set new uuid UUID newuuid = UUID.randomUUID(); - IntArrayTag uuid = (IntArrayTag) map.get("UUID"); - int[] uuidArray; - if (uuid != null) { - uuidArray = uuid.getValue(); - } else { - uuidArray = new int[4]; - uuid = new IntArrayTag(uuidArray); - map.put("UUID", uuid); - } + int[] uuidArray = new int[4]; uuidArray[0] = (int) (newuuid.getMostSignificantBits() >> 32); uuidArray[1] = (int) newuuid.getMostSignificantBits(); uuidArray[2] = (int) (newuuid.getLeastSignificantBits() >> 32); uuidArray[3] = (int) newuuid.getLeastSignificantBits(); + map.put("UUID", new IntArrayTag(uuidArray)); map.put("UUIDMost", new LongTag(newuuid.getMostSignificantBits())); map.put("UUIDLeast", new LongTag(newuuid.getLeastSignificantBits())); @@ -151,7 +134,7 @@ public interface IChunkExtent extends Extent { map.put("PersistentIDMSB", new LongTag(newuuid.getMostSignificantBits())); map.put("PersistentIDLSB", new LongTag(newuuid.getLeastSignificantBits())); - chunk.setEntity(tag); + chunk.setEntity(new CompoundTag(map)); return new IChunkEntity(this, location, newuuid, entity); }