|
| 1 | +For anybody who wants to implement a similar fix, these are my experiences from developing Titanic: |
| 2 | + |
| 3 | +* When a boat is not ridden by a player, the server is in full control of its velocity and position. |
| 4 | + This makes it easy to prevent sinking by just applying an upward velocity. The movement ends up |
| 5 | + being smooth on the client-side. |
| 6 | +* Initially, I thought VehicleMoveEvent did not fire if ridden by player. Spigot used to handle it |
| 7 | + only via PlayerMoveEvent, [but since fixed that](https://hub.spigotmc.org/jira/browse/SPIGOT-2043). |
| 8 | +* VehicleMoveEvent is not cancellable, so cancelling sinking packets is not an option |
| 9 | +* When a boat is ridden by a player, the client is almost in full control: |
| 10 | + * It seems to ignore entity teleport packets for the ridden boat |
| 11 | + * Using Entity.teleport will force a dismount; re-attaching in the same event is too jerky |
| 12 | + * Server does not track velocity but does track position changes |
| 13 | + * Client only responds to Entity.setVelocity |
| 14 | + * Client will force a dismount if underwater too long; no way to tell if it's a manual dismount |
| 15 | + * Attempting to push up whilst boat is just in/on a slope makes the ride very jumpy |
| 16 | + |
| 17 | +# Release diary - 21st May 2016 |
| 18 | + |
| 19 | +I started work on this plugin three weeks ago. Titanic is actually based on [ToughBoats] |
| 20 | +(https://github.com/Gamealition/Titanic/tree/legacy) by [Cyclometh](https://github.com/Cyclometh/). |
| 21 | +We used ToughBoats for 1.8 to prevent boat breaking, player death on certain boat conditions and |
| 22 | +boat resync. I maintained a fork of ToughBoats to keep it updated and add some more fixes. |
| 23 | + |
| 24 | +Although virtually none of ToughBoats' original code is now in Titanic, I opted to keep attribution |
| 25 | +to Cyclometh. Without learning from and using ToughBoats' code, I would not have been able to do |
| 26 | +this project. |
| 27 | + |
| 28 | +Attempting to solve this issue by plugin was tough; when riding, boat movement is handled |
| 29 | +client-side in 1.9. The most accurate way of solving this would be a client-side plugin, but it's |
| 30 | +unreasonable to ask or expect players to install one for an SMP. |
| 31 | + |
| 32 | +At one point, I tried using [ProtocolLib](https://github.com/dmulloy2/ProtocolLib) to try to cancel |
| 33 | +or modify incoming boat packets, or send entity teleport/move ones. This didn't work, but turned out |
| 34 | +to be unnecessary; all I needed was a [VehicleMoveEvent](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/vehicle/VehicleMoveEvent.html) handler. |
| 35 | + |
| 36 | +The only way to move a boat whilst it's being ridden seems to be by setting a velocity. [The server |
| 37 | +does not track velocity of ridden boats](https://github.com/Gamealition/Titanic/blob/master/src/main/java/com/cyclometh/bukkit/plugins/toughboats/Titanic.java#L82), |
| 38 | +and setting any causes the boat to suddenly lose momentum client-side. I couldn't just set an upward |
| 39 | +velocity all the time; it made the boat jumpy and travel very slow. |
| 40 | + |
| 41 | +So I had to write a slightly complicated algorithm, to handle various situations a ridden boat may |
| 42 | +be in. It took a lot of trial and error; debug logging, breakpointing, live code changes, rowing |
| 43 | +back and forth and into waterfalls, etc. |
0 commit comments