PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.99k stars 2.31k forks source link

Crash ridding through a nether portal #11437

Open LucidAPs opened 1 month ago

LucidAPs commented 1 month ago

Stack trace

https://mclo.gs/sute7H7

Plugin and Datapack List

[12:43:31 INFO]: Server Plugins (15): [12:43:31 INFO]: Bukkit Plugins: [12:43:31 INFO]: - CMI, CMILib, CommandRestrictor, CustomEnchants, LuckPerms, PlaceholderAPI, ProtocolLib, SimpleClaims, SimpleCrates, SkySquidPlugin [12:43:31 INFO]: Vault, ViaBackwards, ViaVersion, WorldEdit, WorldGuard

Actions to reproduce (if known)

I am using a plugin that allows players when shooting with a special bow to ride the arrow and dismount it when it lands, I using the following events EntityShootBowEvent , EntityDismountEvent and ProjectileHitEvent

If a player shoots the arrow in overworld through a nether portal it will crash the server.

Paper version

[12:43:43 INFO]: This server is running Paper version 1.21.1-99-master@1bc02e6 (2024-09-25T02:41:02Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT) You are running the latest version Previous version: 1.21.1-2312-d7a7c91 (MC: 1.21.1)

Other

Is this something that needs to be fixed on paper's side or should I fix it on my plugin?

Machine-Maker commented 1 month ago

Have you 100% narrowed it down to the plugin you are working on (i.e. have you removed all other plugins and checked that it still happens)?

If so, can you provide more code or your plugin source for how you are doing this? I could not replicate this issue using the simple

@EventHandler
public void onEvent(EntityShootBowEvent event) {
    event.getProjectile().addPassenger(event.getEntity());
}

I shot a bow at a nether portal in the overworld, and was tp'd to the nether after riding the arrow (was in creative so it's an instant teleport).

LucidAPs commented 1 month ago

Have you 100% narrowed it down to the plugin you are working on (i.e. have you removed all other plugins and checked that it still happens)?

If so, can you provide more code or your plugin source for how you are doing this? I could not replicate this issue using the simple

@EventHandler
public void onEvent(EntityShootBowEvent event) {
    event.getProjectile().addPassenger(event.getEntity());
}

I shot a bow at a nether portal in the overworld, and was tp'd to the nether after riding the arrow.

Hi yes its my plugin, here is the code I am using for it. https://mclo.gs/IRA8k8l

Machine-Maker commented 1 month ago

Ok, I was able to replicate it, but it doesn't seem to happen all the time. Sometimes I just end up being dropped of on the block right before the portal. But sometimes I get the error + crash. For anyone else, I modified the code to make it easier to test.

https://pastes.dev/4VX1tNW9lm

Machine-Maker commented 1 month ago

After for research, this might not be a Paper issue, but rather a plugin just removing an entity in the wrong place. Basically non-player entities are destroyed and recreated when they change dimensions. As part of the changing dimensions process, before they are removed, all their passengers (in this case the player) are dismounted. This fires the EntityDismountEvent. If in the handler for the dismount event, you remove the entity, then the entity's scheduler is retired. But the entity isn't actually being completely removed, and the CraftEntity wrapper is transferred over to the new nms Entity (and that keeps the now retired scheduler) which then causes this exception/crash.