feat: complete boat implementation (#1440)

* feat: implement boat placement

- add boat item handler for all boat/raft types
- raycast with fluid handling to place on water or blocks
- filter entities with can_hit predicate (vanilla parity)
- check space is empty before spawning
- decrement item unless creative mode

* feat: add boat entity with damage handling

- create BoatEntity struct implementing EntityBase
- implement can_hit() and is_collidable() for boats
- implement damage handling that drops boat item on destroy
- update boat item to spawn BoatEntity instead of generic Entity

* fix: boat damage wobble and attack sounds match vanilla

Boats now accumulate damage with wobble animation that decays over time.
Attack sounds play for all hittable entities, not just living entities.

* feat: add boat riding and vehicle movement packets

* feat: complete boat implementation matching vanilla

- add underwater check (60 ticks) and max 2 passengers limit
- add paddle animation metadata and handler
- implement proper land dismount with offset calculation
- add riding_cooldown field to entity

* fix: clippy warnings for boat implementation

* refactor: use loot tables for boat item drops

* fix: collapse nested if to satisfy clippy

* style: fix cargo fmt formatting for collapsible if

* fix: boat dismount places player correctly beside vehicle

- implement vanilla's dismount position calculation with
  getDismountHeight, canDismountInBlock, and pose fallback
  (standing → crouching → swimming)
- fix packet ordering race: use enqueue_packet for teleport so it
  arrives after CSetPassengers (send_packet_now bypassed the queue)
- pre-set awaiting_teleport before CSetPassengers to block stale
  movement packets during async dismount calculation
- send CSetPassengers directly to dismounting player, broadcast to
  others (matching vanilla's targeted packet behavior)
- use DELTA|ROT position flags for teleport (vanilla preserves
  current look direction with relative rotation)
- add riding cooldown (60 ticks) to prevent immediate re-mount
- reset sneaking state after player dismount
- fix water detection to check specifically for water/flowing_water
  fluids (Fluid::from_state_id returns EMPTY for air blocks)
- revert broken loot table refactor for boat item drops (boats use
  hardcoded entity-to-item mapping, not loot tables)
- add get_dismount_height helper on World matching vanilla's
  BlockView.getDismountHeight()
- ignore movement packets while awaiting teleport confirmation in
  handle_position and handle_position_rotation

* style: fix cargo fmt formatting

* refactor: use loot tables for boat item drops

add loot table entries to entities.json for all 20 boat/raft types
and use the existing loot table system instead of hardcoded mapping.

* fix: resolve rebase conflicts and clippy warnings

* fix: regenerate codegen to include boat loot tables
This commit is contained in:
Richard Marshall
2026-02-17 19:47:49 +00:00
committed by GitHub
parent 1c4ea3a1d5
commit b77d9c1b4d
18 changed files with 1487 additions and 84 deletions

View File

@@ -17,6 +17,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:acacia_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"acacia_chest_boat": {
@@ -37,6 +52,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:acacia_chest_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"allay": {
@@ -197,6 +227,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:bamboo_chest_raft"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"bamboo_raft": {
@@ -217,6 +262,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:bamboo_raft"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"bat": {
@@ -287,6 +347,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:birch_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"birch_chest_boat": {
@@ -307,6 +382,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:birch_chest_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"blaze": {
@@ -840,6 +930,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:cherry_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"cherry_chest_boat": {
@@ -860,6 +965,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:cherry_chest_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"chest_minecart": {
@@ -1407,6 +1527,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:dark_oak_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"dark_oak_chest_boat": {
@@ -1427,6 +1562,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:dark_oak_chest_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"dolphin": {
@@ -3389,6 +3539,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:jungle_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"jungle_chest_boat": {
@@ -3409,6 +3574,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:jungle_chest_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"leash_knot": {
@@ -3700,6 +3880,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:mangrove_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"mangrove_chest_boat": {
@@ -3720,6 +3915,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:mangrove_chest_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"mannequin": {
@@ -4037,6 +4247,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:oak_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"oak_chest_boat": {
@@ -4057,6 +4282,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:oak_chest_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"ocelot": {
@@ -4142,6 +4382,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:pale_oak_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"pale_oak_chest_boat": {
@@ -4162,6 +4417,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:pale_oak_chest_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"panda": {
@@ -6206,6 +6476,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:spruce_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"spruce_chest_boat": {
@@ -6226,6 +6511,21 @@
"spawn_restriction": {
"location": "UNRESTRICTED",
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
},
"loot_table": {
"type": "minecraft:entity",
"pools": [
{
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:spruce_chest_boat"
}
],
"rolls": 1.0,
"bonus_rolls": 0.0
}
]
}
},
"squid": {
@@ -8013,4 +8313,4 @@
"heightmap": "MOTION_BLOCKING_NO_LEAVES"
}
}
}
}