Skip to content

Minecraft: Java Edition 26.3 rewritten from scratch in Rust, checked against vanilla with 281 differential harnesses. Get it with the Horizon launcher.

Merge pull request #6534 from Detimes/feat-item-damaged-hook

Ludovic Marie9891e04d64e6
diff --cc crates/horizon-client/src/game/native_hooks.rs
index e0ad64674,3a3941d9c..eecfb999c
--- a/crates/horizon-client/src/game/native_hooks.rs
+++ b/crates/horizon-client/src/game/native_hooks.rs
@@@ -3524,8 -3483,29 +3524,29 @@@ impl Game<'_>
context: &NativeLootDrops<'_>,
drops: &mut Vec<ItemStack>,
) {
- let _ = (context, drops);
+ mod_api::dispatch_loot_drops(self, mod_api::mods(), context, drops);
}
+ /// The item `item` of a server player is about to lose `amount` points of
+ /// durability (`ItemStack.hurtAndBreak`; Bukkit's `PlayerItemDamageEvent`):
+ /// the tool that mines or hits, the armour that takes a hit, a shield, a
+ /// rod, an elytra. `amount` is what is left after Unbreaking; change it
+ /// (0 or less leaves the item whole) or set `cancel` for no wear at all. It
+ /// is not heard for a creative player's tools (they take no wear) nor when
+ /// Unbreaking already saved the item, nor for the wear of a mob's armour or
+ /// of a tool a dispenser uses, nor the host of a LAN world. The player's
+ /// state is swapped in, so `native_acting_player`, `native_tell` and the
+ /// item helpers reach them. Once for each wear, on a server.
+ /// @API:native_item_damaged@.
+ pub(super) fn native_item_damaged(
+ &mut self,
+ player: u128,
+ name: &str,
+ item: &str,
+ amount: &mut i32,
+ cancel: &mut bool,
+ ) {
+ let _ = (player, name, item, amount, cancel);
+ }
/// `player` threw `count` of `item` (`Player.drop`: the drop key, a
/// menu's throw...), not what scatters when they die. It only hears.
/// Server-side. API 40.