Andrei Șugubete 7a63b766de feat: broadcast EntityStatus when equipment breaks (#1837)
* feat: broadcast EntityStatus when equipment breaks

Pumpkin did not play any sound or show break particles when a tool or
piece of armour reached zero durability. Vanilla sends a per-slot
EntityStatus packet (47-52, 65, 68) that every nearby client uses to
play the break sound and spawn break particles textured with the item
that just broke.

Changes
-------

player.rs – new damage_item_in_slot(slot, amount) method:
- Generalises the old damage_held_item to cover all EquipmentSlots:
  MainHand, OffHand, Head, Chest, Legs, Feet.
- Resolves the correct PlayerInventory slot index per slot (36-39 for
  armour, 40 for off-hand) consistent with build_equipment_slots().
- Sends the EntityStatus break packet BEFORE clearing the slot so
  clients can use the item texture for break particles.
- Bypasses sync_hand_slot (which only broadcast for hand slots) and
  instead calls enqueue_slot_set_packet + send_equipment_changes
  directly, ensuring armour equipment changes also propagate.
- damage_held_item is kept as a thin convenience wrapper.

apply_mending_from_xp – DRY refactor:
- Replaces three separate candidate-gathering blocks (main hand, off
  hand, armour loop) with a single unified slot_pairs list iterated
  once. Behaviour is identical.

living.rs – damage_armor_items:
- When a player takes hit damage, armour durability is reduced through
  LivingEntity::damage_armor_items, a separate code path from the
  player item-damage methods. This path now also broadcasts the
  EntityStatus break packet when an armour piece's durability hits zero.

entity/mod.rs – shared helper:
- Add equipment_break_status(slot) -> EntityStatus as a #[must_use]
  pub const fn. Eliminates the duplicated slot→status match that would
  otherwise exist in both call sites (player.rs and living.rs).

Tests (16 new)
--------------
- entity::tests::equipment_break_status_maps_all_slots – asserts every
  EquipmentSlot variant (including Body and Saddle) maps to its
  expected EntityStatus break variant.
- item::tests (15 tests) – first unit tests for ItemStack durability
  logic, covering damage_item_with_context (zero/negative amount,
  non-damageable item, unbreakable item, accumulation, stack break at
  max damage, over-damage) and repair_item (zero/negative amount,
  undamaged item, partial repair, cap at current damage, full repair
  clears the Damage component patch entry) and set_damage (negative
  value clamps to zero).

* refactor: use table-driven cases in damage_increases_damage_value test

* chore: make clippy happy

* refactor: the rest of damage and repair tests to use table-driven cases

* feat: broadcast EntityStatus when equipment breaks

- Implement strict packet ordering (EntityStatus before slot sync)
- Add break broadcast in play.rs use_on_block for all tools
- Generalize damage_item_in_slot to support all equipped slots
- Trim PR comments to 1-2 professional lines
- Convert equipment_break_status test to table-driven format
- Ensure vanilla parity per decompiled 1.21.11 EntityEvent mappings
2026-03-13 16:46:57 +01:00
2026-03-03 17:27:57 +01:00
2026-03-08 21:42:57 +01:00
2026-03-06 22:01:39 +01:00
2025-03-29 13:25:37 +01:00
2025-05-10 12:46:42 +02:00
2026-02-09 15:52:46 +01:00
2025-08-11 20:45:55 +02:00
2026-02-27 17:48:37 +01:00
2024-12-04 11:37:41 +01:00
2026-02-09 15:52:46 +01:00

Pumpkin

CI Discord License: GPL

Pumpkin is a Minecraft server built entirely in Rust, offering a fast, efficient, and customizable experience. It prioritizes performance and player enjoyment while adhering to the core mechanics of the game.

chunk loading

Goals

  • Performance: Leveraging multi-threading for maximum speed and efficiency.
  • Compatibility: Supports the latest Java & Bedrock Minecraft server version while adhering to Vanilla game mechanics.
  • Security: Prioritizes security by preventing known security exploits.
  • Flexibility: Highly configurable, with the ability to disable unnecessary features.
  • Extensibility: Provides a foundation for plugin development.

Important

Pumpkin is currently under heavy development.

See what needs to be done before the 1.0.0 Release

Features

  • Configuration (toml)
  • Tracking: Protocol
    • Server Status/Ping
    • Encryption
    • Packet Compression
    • Java/Bedrock
    • ...
  • Tracking: World
    • Player Tab-list
    • Scoreboard
    • World Loading
    • World Time
    • World Borders
    • World Saving
    • Lighting
    • Entity Spawning
    • Bossbar
    • Chunk Loading (Vanilla, Linear)
    • Chunk Generation
    • Chunk Saving (Vanilla, Linear)
    • Redstone
    • Liquid Physics
    • ...
  • Tracking: Player
    • Skins
    • Teleport
    • Movement
    • Animation
    • Inventory
    • Combat
    • Experience
    • Hunger
    • Off Hand
    • Advancements
    • Eating
    • ...
  • Entities
    • Non-Living (Minecart, Eggs...) (W.I.P)
    • Entity Effects
    • Players
    • Mobs (W.I.P)
    • Animals (W.I.P)
    • Entity AI
    • Boss
    • Villagers
    • Mobs Inventory
    • Entity Saving
  • Server
    • Plugins
    • Query
    • RCON
    • Inventories
    • Particles
    • Chat
    • Commands
    • Permissions
    • Translations
  • Proxy
    • Bungeecord
    • Velocity

How to run

See our Quick Start guide to get Pumpkin running.

Contributions

Contributions are welcome! See CONTRIBUTING.md

Docs

Pumpkin's documentation can be found at https://pumpkinmc.org/

Communication

Consider joining our Discord server to stay up-to-date on events, updates, and connect with other members.

Funding

If you want to fund me and help the project, check out my GitHub sponsors.

Description
Languages
Rust 100%