Chair mechanic issues.
LadyCailinBot opened this issue · 64 comments
CRAFTBOOK-3213 - Reported by mibby
Paper (Spigot 1.10) dev 817
CraftBook dev 58
ProtocolLib dev 311
@me4502 Sitting in a chair idling for 60 seconds causes the player entity to dismount in certain locations. Chat window, if left opened, closes when the dismounting occurs.
Video example.
https://www.dropbox.com/s/dj1iz0q0yj9h1q9/2016-07-18%2004-51-56.mkv?dl=0
In addition, depending on location, you do not dismount but rather your chunk view goes blank until you fire off a move event (rotating camera). If you do not move, randomly it will load chunks again but then go blank a second after.
Video example.
https://www.dropbox.com/s/o9fjbctrwlalc3z/2016-07-18%2005-06-50.mkv?dl=0
And sometimes when you dismount, depending on location, you are not set above/behind the chair block. Rather, you are inside the chair.
Video example.
https://www.dropbox.com/s/qxzqsfin4qsmvdh/2016-07-18%2004-58-30.mkv?dl=0
Comment by mibby
@me4502 On build 60. Occurs when trying to sit.
[01:38:43] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to CraftBook v3.9-SNAPSHOT
org.bukkit.event.EventException
at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:46) ~[patched_1.10.2.jar:git-Paper-818]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:74) ~[patched_1.10.2.jar:git-Paper-818]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.10.2.jar:git-Paper-818]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517) [patched_1.10.2.jar:git-Paper-818]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:502) [patched_1.10.2.jar:git-Paper-818]
at org.bukkit.craftbukkit.v1_10_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:231) [patched_1.10.2.jar:git-Paper-818]
at net.minecraft.server.v1_10_R1.PlayerInteractManager.a(PlayerInteractManager.java:492) [patched_1.10.2.jar:git-Paper-818]
at net.minecraft.server.v1_10_R1.PlayerConnection.a(PlayerConnection.java:891) [patched_1.10.2.jar:git-Paper-818]
at net.minecraft.server.v1_10_R1.PacketPlayInUseItem.a(SourceFile:55) [patched_1.10.2.jar:git-Paper-818]
at net.minecraft.server.v1_10_R1.PacketPlayInUseItem.a(SourceFile:11) [patched_1.10.2.jar:git-Paper-818]
at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$1.run(SourceFile:13) [patched_1.10.2.jar:git-Paper-818]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_92]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_92]
at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45) [patched_1.10.2.jar:git-Paper-818]
at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:791) [patched_1.10.2.jar:git-Paper-818]
at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:404) [patched_1.10.2.jar:git-Paper-818]
at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:725) [patched_1.10.2.jar:git-Paper-818]
at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:624) [patched_1.10.2.jar:git-Paper-818]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_92]
Caused by: java.lang.NullPointerException
at com.sk89q.craftbook.mechanics.Chair$ChairData.access$000(Chair.java:272) ~[?:?]
at com.sk89q.craftbook.mechanics.Chair.removeChair(Chair.java:98) ~[?:?]
at com.sk89q.craftbook.mechanics.Chair.addChair(Chair.java:88) ~[?:?]
at com.sk89q.craftbook.mechanics.Chair.onRightClick(Chair.java:242) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor695.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:44) ~[patched_1.10.2.jar:git-Paper-818]
... 18 more
You sit, then immediately unsit. And of course, you are inside the block when kicked off the chair. Not restored to last location from where you clicked the chair.
Comment by mibby
@me4502 Apologies for the delayed testing.
No more exception and can sit down again. But the problem still occurs that after 60 seconds, your state attempts a dismount. --It doesn't kick you off the chair anymore, but-- it dismounts --and remounts,-- as well as closes chat window if you have it open. And depending on location, it won't force you off but will attempt a dismount/re-mount and make your chunk view disappear until you fire off a movement event.
You also still do not return to the location you were before when exiting the chair.
Essentially none of the problems are fixed --except that you aren't forcefully dismounted anymore. Just dismounted and then remounted.--
Edit: Nevermind. Got forcefully dismounted off the chair after 60 seconds again when testing. So that isn't fixed either.
Comment by me4502
The reason it dismounts, is that the arrow is being removed by the server. Every second CraftBook resets the age of the arrow, so for some reason it's being removed anyway.
Comment by mibby
The only thing I can think of is this Spigot setting in the spigot.yml.
arrow-despawn-rate: 1200
Assuming that is in ticks, that would equate to 60 seconds. Spigot could be overly aggressive in the removal.
If there is no way to prevent the arrow from despawning, is there perhaps a better way to mount players on a chair? Perhaps mounting a player on an invisible armor stand and detect the player as a passenger? If the armorstand doesn't detect a passenger, have it remove itself? Using armor stands may even help with performance a bit since you wouldn't have to tick the arrow to prevent it from despawning / keeping track of it.
Comment by mibby
@me4502 Any progress update? :(
Comment by me4502
I haven't had a chance to do it yet, but the armour stand would still require ticking.
Comment by mibby
@me4502 Can it be changed so that the armorstand is facing the same way as the stairs? Otherwise you end up with your head on backwards if the chair isn't facing south. Or better yet, possible to rotate the armorstand with the player direction when moving so you are always in a correct seated position?
Comment by me4502
What's wrong with the seated position when not facing the same direction as the armour stand?
Comment by mibby
@me4502 https://gyazo.com/0e0f48d6249193aa8345255c8539121c
This plugin doesn't seem to have the problem. Which is why I assume they rotate the armorstand with the player when sitting.
https://www.spigotmc.org/resources/better-chairs.18705/
Comment by me4502
Try it on the next build - it sets the yaw of the armorstand when they sit down. This makes the most sense as it means the armor stand is facing the correct direction for sitting straight on the chair. It's not updating every tick as that requires iterating over every chair every tick.
Comment by mibby
What if a player enters the chair from the front? Wouldn't the yaw face behind the block direction so when they try turning around, they have the head problems? Since the yaw would have been set / facing the direction they sat down?
Comment by me4502
It sets it based on the direction the chair is facing, not the direction the player is facing.
Comment by me4502
Oh, yes. In that case it does it based on the player's direction.
Comment by mibby
Right. So there is no way to prevent the head turning issue at all - being able to rotate in a full circle without your view snapping? This plugin works fine with full rotation, but not sure how they do it. https://www.spigotmc.org/resources/better-chairs.18705/ Might be using nms.
Comment by me4502
The first one I will look into.
With the second, when I first investigated it - it appeared to be an issue with the base game.
For the third issue, update to the latest version - that was fixed a week or so ago.
Comment by mibby
I am on the latest though. :(
CraftBook dev 58
For the 2nd issue, could it be related to the first? As in after the '60 seconds', the entity is being teleported but since it is not in a usable player state, chunks don't fire off loading requests? So if the entity did not forcefully move / dismount after that '60 second' time, both problems would be resolved?
Comment by me4502
When someone gets off a chair - it sends them back to the location they got on from. The only way to get off inside the block, is if they were there in the first place.
As for the other issue, I've just committed something that should hopefully fix it - if it doesn't, it's possibly an issue with the game or another plugin that removes arrows.
Comment by mibby
Interesting. I don't think it is working as intended then because I'm standing in front of a chair, right clicking it, then getting off. Puts me inside the chair block, not the location I came from.
https://www.dropbox.com/s/4n6c2lb75y97h1r/2016-07-19%2001-16-20.mkv?dl=0
As for the other issue, I'll update and test in a bit. Thanks. :) For testing, I didn't use any other plugins but CB, WE, WG, ProtocolLib, and PEX. So shouldn't be a plugin conflict.
Comment by me4502
It may be worth posting a bug report for the weird head when on an armour stand to the MC Bugtracker. If you make one of them, I could send it around to a few people see if I can get it fixed for 1.11
Comment by me4502
Okay, so I just tested the same concept in Sponge, and it works fine - it appears that rejecting armour stand position changes is actually an issue with Bukkit/Spigot, not the game.
Comment by mibby
This is still an issue with Paper/Spigot despite being fixed in this commit?
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/5245147d004f648afcddec6a689e60d451c027bf
Perhaps something you have to do in CraftBook to fix the issue?
Comment by mibby
@me4502 Bumping in case you didn't see my comment here. :) Still broken on CraftBook dev 105 and Paper (Spigot 1.11.2) dev 992.
PaperMC/Paper#473 (comment)
Comment by me4502
Sorry, hadn't looked at this as I haven't been home and the issue tracker was down for a bit.
Comment by me4502
It wasn't fixed in that commit, that sets the head rotation, which is not what is wanted.
In Sponge both rotationPitch and rotationYaw are manually set, which I believe is what fixes the issue.
Comment by mibby
Thanks for the info. I forwarded it to Zbob750 (PaperSpigot) on the git issue tracker to hopefully then be forwarded or pull request fixed upstream in Spigot. Hopefully one of the spigots will add a way to set rotationPitch and rotationYaw.
BetterChairs still does not have this problem, but I can only assume they are using NMS to update rotation directly themselves.
https://github.com/BlackScarx/BetterChairs
https://www.spigotmc.org/resources/better-chairs-come-contribute.18705/
Comment by mibby
See here for a slight update on the issue.
PaperMC/Paper#473 (comment)
Comment by mibby
Unfortunately a7f36bf does not fix the issue either. Still head snapping and odd rotation. :(
Comment by mibby
Quick follow-up. Still broken as of Paper dev 1052 / Spigot 1.11.2 (commit a1d3777d890) and CraftBook dev 120. Head snapping still occurs when rotating in a chair, the body doesn't face the same direction as the head.
Comment by mibby
Still broken as of
CraftBook dev 123
Paper dev 1059 (Spigot 1.11.2)
Comment by me4502
I haven't had a chance to look deep into paper and find out where the issue occurs.
Comment by mibby
It occurs in normal spigot too (being that Paper is a fork of Spigot with additional improvements). Broken spine trying to sit straight. :P http://i.imgur.com/2tj7ELB.jpg
Comment by me4502
I've forwarded this issue to Mojira - https://bugs.mojang.com/browse/MC-114169
Comment by mibby
Thanks. So is there no actual possible workaround without using NMS until mojang fixes it in a subsequent version update then?
Comment by me4502
Yeah, either that.. Or Spigot/Paper fixes setting entity rotation for the workaround. Basically either NMS, or Spigot fixing the issue, are required for the workaround. Issue with that is in my testing NMS by itself isn't actually enough - as it appears to override and sometimes snap back. It'd theoretically be possible with both NMS and ProtocolLib, but I don't really have time to quickly update CraftBook after each release that breaks NMS compatibility. Currently when something breaks it's a minor break, and I can fix it when I get a chance. If I use NMS it'll entirely break until updated.
Comment by me4502
I'll check what they do soon, but they probably just set the rotations of the armour stand. I can do that, it just means I need to iterate over every chair.
Comment by mibby
@me4502 Bump. Reminder that chairs are still partially broken. You sit facing south.
https://gyazo.com/4d19a645363b46fe5f9cd7bc87d1d3b2
Comment by me4502
Yeah, just changed it to update for the players yaw everytime the chair iterates.
Comment by me4502
Really? Hmm.. Is this using the latest version definitely? The armour stand is being set to the players rotation constantly, which based on prior checks is the issue...
I'll look into it a bit more.
Comment by me4502
Okay, looked it up for a bit, and the issue appears to be armour stands. The server won't allow them to be rotated whilst being ridden. Everyone who's posted about it solved it by just using another entity.
Comment by mibby
As in re-mount the player to a new entity on every yaw change and remove the old one? Wouldn't that cause de-mount/re-mount teleportation?
The source code of Better Chairs plugin was released (due to being abandoned). May have a solution there since it doesn't have the rotation issue. Though they might be using nms.
https://github.com/BlackScarx/BetterChairs
Comment by me4502
Yeah, had a look at that source. They don't exactly use an armour stand, they make their own custom entity.
Comment by me4502
I've been looking into it, there doesn't appear to be a solution to it being weird on rotation. The best way to solve is to use stairs, as they provide the initial direction
Comment by mibby
Really? That's extremely unfortunate, as stairs aren't exactly the best material used in designing fancy sitting lounges. It isn't possible to use a custom entity as well to solve the problem?
Comment by me4502
I've submitted the fix to the visual bug to the Mojang team, so hopefully, it makes its way into 1.12
Comment by mibby
@me4502 Unfortunately chairs are still partially broken in 1.12. Rotation breaks when you face north so if the chair stair or slab is designed for anything other than a south facing direction, you can't sit straight.
https://gyazo.com/6085f09b03d062de36433d6f1ed5c7e9
CraftBook dev 160
Paper dev 1124 (Spigot 1.12)
Comment by me4502
So issue there is that’s technically not a bug, so I can’t get that changed in the base game code. I could ask but I don’t want to be too pestery. There should be an option in the config, atleast for stairs, to have the armour stand face the direction of the chair which fixes it for them. However for slabs it’s a bit harder as they can’t be rotated on spigot.
Comment by mibby
So proper functioning chairs where you can rotate and face properly will never be a thing without being able to rotate the armorstand with nms? :( Bit silly that your character rotation breaks when rotating around the armorstand.
Comment by me4502
Basically, I'll make a bug on the MC issue tracker and see if I can get support to remove the animal riding behaviour from armour stands.
Comment by me4502
https://bugs.mojang.com/browse/MC-118885 <- MC Issue.