Vessel#getWaterLevel behaves unexpectedly for submerged submarines, causes movements to leave air underwater
notfoundry opened this issue ยท 1 comments
Describe the bug
The getWaterLevel
method in org.ships.vessel.common.types.Vessel
calculates the maximum heights at which each column of vessel blocks touch water (if at all), and returns the most frequently-appearing height among all of those columns, The ships5 and ships6 movement algorithms then seem like they use that height to decide which "old" vessel positions to fill with water/air as the vessel moves. This is pretty reasonable for waterships, where the most frequently-appearing height makes sense as the level where the vessel is "floating", but in the case of submergible vessels like submarines it causes vessel movements to leave air blocks behind underwater if the widest layer of the vessel is not also the highest layer.
I think it might be helpful for the movement algorithms to more carefully keep track of which blocks were previously water and which blocks were air (it might be slow, but it's correct), or for UnderWaterType
vessels to have some sort of special handling for how they calculate their water levels. I'm not sure what the best solution would be, but I think it's worth bringing this up.
To Reproduce
The submarine issue can be seen by creating a rectangular submarine with a pointed front/back and submerging it/moving it underwater. Blocks below the thickest layer of the vessel will be changed to water as the vessel moves, but blocks above the thickest layer will be changed to air. If the top level of the vessel is extended to be the thickest layer, then the movement seems to work well again.
Steps to reproduce the behavior:
- Minecraft version 1.16.5
- Platform: Paper (git-paper-418)
- Ships version: 6.0.0.0 beta10