Let a sculk catalyst take the experience of mobs killed without a player

This commit is contained in:
Kacpherek
2026-10-26 19:33:09 +01:00
parent 68db8847e7
commit 849b5b663b
2 changed files with 14 additions and 9 deletions
+3 -2
View File
@@ -685,11 +685,12 @@ impl Game<'_> {
let by_player = killer.is_some() || m.ai.last_hurt_by_player > 0;
let mut dying = m.clone();
// LivingEntity.die: the death is heard, and a sculk catalyst nearby
// takes the experience (before the loot is dropped).
// takes the experience (before the loot is dropped). It takes what
// would drop, whoever killed the mob.
self.sculk_mob_died(m);
let consumed =
self.catalyst_takes_experience([m.position.x, m.position.y, m.position.z], |_| {
if by_player {
if horizon_client::mobs::drops::drops_experience(&dying) {
horizon_client::mobs::drops::base_experience(&mut dying).max(0) as u32
} else {
0
+11 -7
View File
@@ -471,13 +471,7 @@ pub fn die(m: &mut Mob, d: &Death, sequences: &mut RandomSequences) -> (Vec<Drop
}
}
// dropExperience.
let drops_experience = match s {
Species::Tadpole => false,
Species::Hoglin => true,
s if is_monster(s) => true,
_ => !m.is_baby(),
};
if killed_by_player && drops_experience && d.mob_drops {
if killed_by_player && drops_experience(m) && d.mob_drops {
let mut amount = base_experience(m);
while amount > 0 {
let value = orb_value(amount);
@@ -501,6 +495,16 @@ fn roll(
None => Vec::new(),
}
}
/// `LivingEntity.shouldDropExperience`: babies drop none, except monsters and
/// hoglins; tadpoles never do.
pub fn drops_experience(m: &Mob) -> bool {
match m.species() {
Species::Tadpole => false,
Species::Hoglin => true,
s if is_monster(s) => true,
_ => !m.is_baby(),
}
}
/// `getBaseExperienceReward` (no vanilla enchantment changes mob experience).
pub fn base_experience(m: &mut Mob) -> i32 {
use Species as S;