-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boat glitches when going off two block tall step on ice #1880
Comments
Can you create a code to replecate that more easy? |
Yes, but unfortunately no sooner than 7/15, I am currently without pc for some time. |
Thats fine |
Here I have the example code. I hope that it's okay that it is not a repository and is written in Kotlin 🙂 import net.minestom.server.MinecraftServer
import net.minestom.server.entity.*
import net.minestom.server.event.player.PlayerBlockInteractEvent
import net.minestom.server.event.player.PlayerLoginEvent
import net.minestom.server.event.player.PlayerPacketEvent
import net.minestom.server.instance.block.Block
import net.minestom.server.item.ItemStack
import net.minestom.server.item.Material
import net.minestom.server.network.packet.client.play.ClientSteerVehiclePacket
import kotlin.experimental.and
import kotlin.random.Random
fun main()
{
val minecraftServer = MinecraftServer.init()
val instanceManager = MinecraftServer.getInstanceManager()
val instance = instanceManager.createInstanceContainer()
instance.setGenerator { unit ->
val bottom = unit.absoluteStart().y().toInt()
if (Random.nextBoolean())
unit.modifier().fillHeight(bottom, bottom + 3, Block.PACKED_ICE)
else
unit.modifier().fillHeight(bottom, bottom + 1, Block.PACKED_ICE)
}
val globalEventHandler = MinecraftServer.getGlobalEventHandler()
globalEventHandler.addListener(PlayerLoginEvent::class.java) { event ->
event.setSpawningInstance(instance)
event.player.gameMode = GameMode.CREATIVE
event.player.inventory.setItemInHand(Player.Hand.MAIN, ItemStack.of(Material.OAK_BOAT))
}
globalEventHandler.addListener(PlayerBlockInteractEvent::class.java) { event ->
if (event.player.inventory.itemInMainHand.material() != Material.OAK_BOAT)
return@addListener
val boat = Entity(EntityType.BOAT)
boat.setInstance(instance, event.blockPosition.add(0.0, 1.0, 0.0))
boat.addPassenger(event.player)
}
globalEventHandler.addListener(PlayerPacketEvent::class.java) { event ->
val packet = event.packet
if (packet !is ClientSteerVehiclePacket)
return@addListener
if (packet.flags and 0x2 == 0.toByte())
return@addListener
val player = event.player
val vehicle = player.vehicle
vehicle?.removePassenger(player)
vehicle?.remove()
player.teleport(player.position.add(0.0, 1.0, 0.0))
}
minecraftServer.start("localhost", 25565)
}
|
Kotlin its fine. I work also all day with it. Thx |
Any update? |
Not yet i need still testing. Sorry for no update. I am on it 😅 |
Sure, I'll let you know tomorrow |
Thanks |
Still the same issue. javaw_NwRSjnE2UH.mp4 |
Vanilla behaviour: javaw_ZwwQ5MHe94.mp4 |
I have the vanilla behavior on my server. I tested yesterday |
Have you cloned the repo I provided? |
Only no modifications.
Yes |
Is anyone else here able to reproduce this bug? |
From looking at decompiled Fabric sources, it seems like boat physics are entirely handled by client prediction. When a boat is moving around horizontally on ice, the server thinks its velocity is 0 (at least on my Minestom server). Because of this, when it tries to apply gravity, it sends a velocity packet with the current horizontal velocity (which the server thinks is 0) and a modified vertical component based on the acceleration of gravity. This makes the boat stop moving horizontally on the client. Here's a simple fix: BlueDragonMC@04f0919 It's definitely not the best way to fix the issue, but it has worked for me so far. You could also make a custom Boat entity and prevent all velocity packets from being sent: // in a custom Entity subclass
override fun sendPacketToViewers(packet: SendablePacket) {
if (packet is EntityVelocityPacket) return
super.sendPacketToViewers(packet)
} However, this solution isn't localized to the entity's automatic velocity handling, so it could prevent you from sending velocity packets in scenarios where you'd want to. |
When you ride a baot on ice and go down over a ledge two or more blocks tall, you lose your forward momentum.
Illustration video in attachments. (there isn't directly two blocks tall ledge, but the boat goes two blocks down in total when it happens)
Recording.2023-06-14.094124.mp4
The text was updated successfully, but these errors were encountered: