Furnace Minecarts with Passengers [TMS 222 198]
Pheotis opened this issue ยท 7 comments
EDIT Updated 2022-06-20 @5:21 Toronto.
Running 1.19 paper, furnace minecarts cause problems if they teleport with passengers.
When teleporting intradimensionally, the furnace minecart and its passengers split, with the furnace minecart returning through the gate it just went through. Probably the cause of #196.
When teleporting interdimensionally, the furnace minecart and its passsengers persist, teleport, and print a stack trace to console. The teleportation is seemingly successful, except for the fact that it stack traces.
entity:
summon furnace_minecart ~ ~ ~ {Passengers:[{id:"minecraft:boat",Type:"oak"}]}
stack trace:
[17:17:34 ERROR]: Entity passenger world must match, cannot add EntityBoat['Boat'/329, uuid='76fd53e4-91d5-427b-907b-7dcd1c785f97', l='ServerLevel[world_nether]', x=-1.00, y=4.00, z=26.00, cpos=[-1, 1], tl=0, v=true] as passenger to EntityMinecartFurnace['Minecart with Furnace'/327, uuid='c1245664-84ce-407a-bcfc-ac29dcf61c00', l='ServerLevel[world]', x=42.50, y=-60.00, z=44.09, cpos=[2, 2], tl=75, v=true]
java.lang.Throwable: null
at net.minecraft.world.entity.Entity.addPassenger(Entity.java:2678) ~[paper-1.19.jar:git-Paper-31]
at net.minecraft.world.entity.Entity.startRiding(Entity.java:2630) ~[paper-1.19.jar:git-Paper-31]
at org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity.addPassenger(CraftEntity.java:756) ~[paper-1.19.jar:git-Paper-31]
at net.TheDgtl.Stargate.network.portal.Teleporter.lambda$teleportPassengers$2(Teleporter.java:214) ~[Stargate-1.0.0.9-ALPHA.jar:?]
at net.TheDgtl.Stargate.action.SupplierAction.run(SupplierAction.java:24) ~[Stargate-1.0.0.9-ALPHA.jar:?]
at net.TheDgtl.Stargate.thread.SynchronousPopulator.cycleQueue(SynchronousPopulator.java:106) ~[Stargate-1.0.0.9-ALPHA.jar:?]
at net.TheDgtl.Stargate.thread.SynchronousPopulator.cycleQueues(SynchronousPopulator.java:79) ~[Stargate-1.0.0.9-ALPHA.jar:?]
at net.TheDgtl.Stargate.thread.SynchronousPopulator.run(SynchronousPopulator.java:38) ~[Stargate-1.0.0.9-ALPHA.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.jar:git-Paper-31]
at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.jar:git-Paper-31]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1490) ~[paper-1.19.jar:git-Paper-31]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:446) ~[paper-1.19.jar:git-Paper-31]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1414) ~[paper-1.19.jar:git-Paper-31]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1187) ~[paper-1.19.jar:git-Paper-31]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:302) ~[paper-1.19.jar:git-Paper-31]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Update:
This all boils down to furnace minecarts riding boats.
When teleporting through an intradimensional portal, they go through, split from the boat, then go through backwards.
When going interdimensional, they go through and cause a stack trace. Going to try and repro this with a simplified command.
Consistently repros on paper 1.19 with
/summon furnace_minecart ~ ~ ~ {Passengers:[{id:"minecraft:boat",Type:"oak"}]}
Does it work to just move:
poweredMinecart.setVelocity(new Vector());
teleport(poweredMinecart, exit);
to before the sceduling, or does that break everything?
Good idea, I can try that. I also noticed that the minecart does not switch directions properly when entering portals in the x direction
The error basically says that the furnace minecart is not in the same dimension as the entity that it is going to become a passenger. This is a special case for furnace minecarts because they are teleported one tick later as in this script:
if (target instanceof PoweredMinecart) {
//A workaround for powered minecarts
PoweredMinecart poweredMinecart = (PoweredMinecart) target;
int fuel = poweredMinecart.getFuel();
poweredMinecart.setFuel(0);
Bukkit.getScheduler().runTaskLater(Stargate.getInstance(), () -> {
poweredMinecart.setVelocity(new Vector());
teleport(poweredMinecart, exit);
poweredMinecart.setFuel(fuel);
poweredMinecart.setVelocity(targetVelocity);
if (NonLegacyMethod.PUSH_X.isImplemented() && NonLegacyMethod.PUSH_Z.isImplemented()) {
NonLegacyMethod.PUSH_X.invoke(poweredMinecart, -location.getDirection().getBlockX());
NonLegacyMethod.PUSH_Z.invoke(poweredMinecart, -location.getDirection().getBlockZ());
} else {
logger.logMessage(Level.FINE, String.format("Unable to restore Furnace Minecart Momentum at %S --" +
" use Paper 1.18.2+ for this feature.", location));
}
}, 1);
}
By some reason passangers can not mount though. I have no clue why, and to a point I don't care if that works or not
For some context to the above resolution, this is definitely planned, but not practical for the 1.0.1.0 release
Namely, we need to:
- figure out why furnace minecarts randomly change directions
- find a way to deal with mounted entities
- find a way to resync teleported entities despite the delay
This is definitely needed, but would take too long to include in the current release.
Going to bump this to 1.1.0.0