Merge pull request #2379 from kacpherek/fix/sculk-catalyst-nonplayer-kills
🤖 Agent: Proven in union R1 (branch union/cg19-r1, main + 83 of kacpherek's PRs): the 98 harnesses it can affect, clippy -D warnings, tests, lan_e2e in-frame and on the server thread.
This commit is contained in:
@@ -772,11 +772,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
|
||||
|
||||
@@ -510,13 +510,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);
|
||||
@@ -540,6 +534,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;
|
||||
|
||||
Reference in New Issue
Block a user