FastAsyncWorldEdit

FastAsyncWorldEdit

152k Downloads

NullPointerException when pasting entities from a clipboard using API

opl- opened this issue ยท 0 comments

commented

Server Implementation

Paper

Server Version

1.20.2

Describe the bug

ExtentEntityCopy assumes source extent from which entities get copied is never null, but it can be null if the first constructor is used (the only one available with original WorldEdit). This triggers a NullPointerException when an entity has Rotation in its NBT, which is true for most if not all living entities.

Vector3 orgDirection = new Location(source, 0, 0, 0, orgrot.getFloat(0), orgrot.getFloat(1)).getDirection();

To Reproduce

  1. Spawn a pig.
  2. Select the region around the pig.
  3. //copy -e
  4. Run the following code:
public void test() throws WorldEditException {
    org.bukkit.entity.Player player = null; // replace this with the player holding the clipboard
    Player actor = BukkitAdapter.adapt(player);
    SessionManager manager = WorldEdit.getInstance().getSessionManager();
    LocalSession localSession = manager.get(actor);
    Clipboard clipboard = localSession.getClipboard().getClipboard();

    ExtentEntityCopy entityCopy = new ExtentEntityCopy(
            clipboard.getOrigin().toVector3(),
            BukkitAdapter.adapt(player.getWorld()),
            clipboard.getOrigin().toVector3(),
            new Identity()
    );

    for (Entity entity : clipboard.getEntities()) {
        entityCopy.apply(entity);
    }
}
  1. Get following stack trace:
java.lang.NullPointerException: null
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:903) ~[guava-32.1.2-jre.jar:?]
        at com.sk89q.worldedit.util.Location.<init>(Location.java:135) ~[FastAsyncWorldEdit-Bukkit-2.8.0.jar:?]
        at com.sk89q.worldedit.util.Location.<init>(Location.java:107) ~[FastAsyncWorldEdit-Bukkit-2.8.0.jar:?]
        at com.sk89q.worldedit.function.entity.ExtentEntityCopy.transformNbtData(ExtentEntityCopy.java:279) ~[FastAsyncWorldEdit-Bukkit-2.8.0.jar:?]
        at com.sk89q.worldedit.function.entity.ExtentEntityCopy.apply(ExtentEntityCopy.java:156) ~[FastAsyncWorldEdit-Bukkit-2.8.0.jar:?]
        ...

Expected behaviour

Y'know, no crashes.

Screenshots / Videos

No response

Error log (if applicable)

No response

Fawe Debugpaste

https://athion.net/ISPaster/paste/view/f05eca59ab7a4e188ced658f1f9ffa4c

Fawe Version

FastAsyncWorldEdit version 2.8.0

Checklist

Anything else?

No response