_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:
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.
As a quick fix, you can disable drops-pre-merge in global.conf.
Fixed in https://github.com/SpongePowered/SpongeCommon/commit/7594478c8d86342e08bbf018e071a7689ee8d2e3.
Those Phases are really annoying sometimes.
Most helpful comment
Fixed in https://github.com/SpongePowered/SpongeCommon/commit/7594478c8d86342e08bbf018e071a7689ee8d2e3.
Those Phases are really annoying sometimes.