Sponge: Phase exception when teleporting a player having an item on their cursor a distance greater than 4 blocks

Created on 2 Feb 2018  路  2Comments  路  Source: SpongePowered/Sponge

_An oddly specific issue that was really annoying to get to reproduce outside of my plugin at first, haha._

If a player has an inventory open, an item on their cursor, and gets teleported any distance greater than 4 blocks, a phase exception is thrown.

Sample code to reproduce issue:

@Listener
public void onTest(MessageChannelEvent.Chat event, @Root Player player) {
    // When player writes "!test" in chat
    if (!event.getRawMessage().toPlain().equalsIgnoreCase("!test")) return;

    Inventory inventory = Inventory.builder()
            .of(InventoryArchetypes.CHEST)
            .build(plugin);

    inventory.offer(ItemStack.of(ItemTypes.DIAMOND, 1));

    player.openInventory(inventory);

    // Few seconds later, teleport the player
    Task.builder()
            .delayTicks(20 * 3)
            .execute(() -> {
                // If this is changed to 4 or less, no exception.
                // Any value above 4 seems to throw the exception.
                // 4.000000001 will throw exception, ex.
                double distance = 4.1;
                player.setLocation(player.getLocation().add(0, distance, 0));
            })
            .submit(plugin);
}

Reproduction instructions:
1) Write !test in chat
2) Quickly pick up the diamond in the inventory so it's on your cursor
3) After three seconds, you will get teleported more than 4 blocks into the air
4) Boom baam, phase exception

Log:
https://gist.github.com/VapidLinus/8635c1e8deee33404dac4744b0c3ca7c

Notes:

  • Happens for any distance greater than 4. Works the same for all axises.
  • The player must have an item on their cursor
  • Doesn't happen if the player opens their own inventory and picks up an item there

Version: _spongevanilla-1.12.2-8.0.0-BETA-394.jar_
Note that this still happens with the latest SpongeCommon changes.
I manually pulled and built latest as of 1e15970 and it still happens.

phase tracker bug 1.12

Most helpful comment

All 2 comments

As a quick fix, you can disable drops-pre-merge in global.conf.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TBlueF picture TBlueF  路  5Comments

therealmikz picture therealmikz  路  4Comments

XakepSDK picture XakepSDK  路  3Comments

Grinch picture Grinch  路  4Comments

randombyte-developer picture randombyte-developer  路  5Comments