Make allays drop what they carry on death and use the default pickup delay when throwing

This commit is contained in:
Kacpherek
2026-10-26 15:11:01 +01:00
parent 8027cb4176
commit 3615c65d18
2 changed files with 24 additions and 1 deletions
+2 -1
View File
@@ -131,7 +131,8 @@ impl Game<'_> {
let m = &mut self.mobs[i];
m.extra.ints[1] -= 1;
m.extra.ints[3] = 60;
self.spawn_item(ItemStack::new(&item, 1), from, v, 40);
// ItemEntity.setDefaultPickUpDelay.
self.spawn_item(ItemStack::new(&item, 1), from, v, 10);
if self.world.game_time % 7 == 0 && self.world.random.next_double() < 0.9 {
const PITCHES: [f32; 16] = [
0.5625, 0.625, 0.75, 0.9375, 1.0, 1.0, 1.125, 1.25, 1.5, 1.875, 2.0, 2.25, 2.5,
+22
View File
@@ -399,6 +399,15 @@ pub fn die(m: &mut Mob, d: &Death, sequences: &mut RandomSequences) -> (Vec<Drop
out.push(Drop::Item(stack));
clear_slot(m, "mainhand");
}
// Allay: what it carries (`ints[1]` of the held item) is its inventory.
let allay_load = (s == Species::Allay)
.then(|| {
m.extra
.main_hand
.clone()
.map(|item| (item, m.extra.ints[1]))
})
.flatten();
let drops_loot = d.mob_drops && (is_monster(s) || !m.is_baby());
if drops_loot {
let table = format!(
@@ -455,6 +464,19 @@ pub fn die(m: &mut Mob, d: &Death, sequences: &mut RandomSequences) -> (Vec<Drop
out.push(Drop::Item(loot_stack("minecraft:nether_star", 1)));
}
}
// Allay.dropEquipment: its inventory, then the main-hand item unless it
// prevents equipment drops.
if let Some((item, carried)) = allay_load {
if carried > 0 {
out.push(Drop::Item(loot_stack(&item, carried)));
}
if let Some(stack) = slot_item(m, "mainhand")
&& !d.loot.prevents_equipment_drop(&stack)
{
out.push(Drop::Item(stack));
clear_slot(m, "mainhand");
}
}
// dropEquipment: AbstractHorse's inventory, then a chested horse's chest.
if equine::is_equine(s) {
for stack in m.extra.items.iter().flatten() {