Match finalizeSpawn for every case of the harness
A zombie villager's profession comes from its constructor's random, not the one finalizeSpawn draws from. Allays and withers are no longer marked persistent to escape despawning: they are kept as removeWhenFarAway and the wither's checkDespawn keep them, and canPickUpLoot follows the allay's and the sulfur cube's overrides. A sulfur cube's size sets its attribute bases, and strength and speed effects count in attribute values. The oracle's stand-in level gets the sound seed random Level.playSound draws from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -74,7 +74,10 @@ impl FinalizeLevel for Level<'_> {
|
||||
fn no_collision(&self, bounds: Aabb) -> bool {
|
||||
// A floor under the spawn point and an optional roof layer.
|
||||
self.roof.is_none_or(|y| {
|
||||
let (lo, hi) = (bounds.min(horizon_core::geometry::Axis::Y), bounds.max(horizon_core::geometry::Axis::Y));
|
||||
let (lo, hi) = (
|
||||
bounds.min(horizon_core::geometry::Axis::Y),
|
||||
bounds.max(horizon_core::geometry::Axis::Y),
|
||||
);
|
||||
!(lo < f64::from(y) + 1.0 && hi > f64::from(y))
|
||||
})
|
||||
}
|
||||
@@ -115,13 +118,29 @@ fn hex64(v: f64) -> String {
|
||||
fn hex32(v: f32) -> String {
|
||||
format!("{:x}", v.to_bits())
|
||||
}
|
||||
const HORSE: [&str; 7] = ["white", "creamy", "chestnut", "brown", "black", "gray", "dark_brown"];
|
||||
const HORSE: [&str; 7] = [
|
||||
"white",
|
||||
"creamy",
|
||||
"chestnut",
|
||||
"brown",
|
||||
"black",
|
||||
"gray",
|
||||
"dark_brown",
|
||||
];
|
||||
const MARKINGS: [&str; 5] = ["none", "white", "white_field", "white_dots", "black_dots"];
|
||||
const RABBITS: [&str; 6] = ["brown", "white", "black", "white_splotched", "gold", "salt"];
|
||||
const PARROTS: [&str; 5] = ["red_blue", "blue", "green", "yellow_blue", "gray"];
|
||||
const AXOLOTLS: [&str; 5] = ["lucy", "wild", "gold", "cyan", "blue"];
|
||||
const SALMON: [&str; 3] = ["small", "medium", "large"];
|
||||
const GENES: [&str; 7] = ["normal", "lazy", "worried", "playful", "brown", "weak", "aggressive"];
|
||||
const GENES: [&str; 7] = [
|
||||
"normal",
|
||||
"lazy",
|
||||
"worried",
|
||||
"playful",
|
||||
"brown",
|
||||
"weak",
|
||||
"aggressive",
|
||||
];
|
||||
const MEMORIES: [&str; 7] = [
|
||||
"long_jump_cooldown",
|
||||
"ram_cooldown",
|
||||
@@ -136,7 +155,10 @@ fn variant(m: &Mob, regs: &SpawnRegistries, v: &mut Vec<String>) {
|
||||
use Species as S;
|
||||
let s = m.species();
|
||||
let named = |reg: &finalize::VariantRegistry, i: u8| {
|
||||
format!("minecraft:{}", reg.names.get(i as usize).map_or("?", |n| n.as_str()))
|
||||
format!(
|
||||
"minecraft:{}",
|
||||
reg.names.get(i as usize).map_or("?", |n| n.as_str())
|
||||
)
|
||||
};
|
||||
let var = format!("minecraft:{}", finalize::variant_name(s, m.extra.variant));
|
||||
match s {
|
||||
@@ -212,7 +234,9 @@ fn variant(m: &Mob, regs: &SpawnRegistries, v: &mut Vec<String>) {
|
||||
S::Phantom => v.push(format!("size={}", m.extra.size)),
|
||||
S::Turtle => v.push(format!(
|
||||
"home={}",
|
||||
m.extra.home.map_or("-".into(), |h| format!("{},{},{}", h[0], h[1], h[2]))
|
||||
m.extra
|
||||
.home
|
||||
.map_or("-".into(), |h| format!("{},{},{}", h[0], h[1], h[2]))
|
||||
)),
|
||||
S::Dolphin => v.push(format!("air={}", m.air)),
|
||||
_ => {}
|
||||
@@ -252,7 +276,7 @@ fn describe(m: &Mob, all: &[Mob], regs: &SpawnRegistries) -> String {
|
||||
}
|
||||
t.push(format!("hp={}", hex32(m.health)));
|
||||
t.push(format!("lh={}", m.extra.left_handed));
|
||||
t.push(format!("loot={}", m.extra.pick_up_loot));
|
||||
t.push(format!("loot={}", m.can_pick_up_loot()));
|
||||
t.push(format!("persist={}", m.persistent));
|
||||
let mut eq = Vec::new();
|
||||
for (slot, name) in finalize::SLOT_NAMES.iter().enumerate() {
|
||||
@@ -284,7 +308,14 @@ fn describe(m: &Mob, all: &[Mob], regs: &SpawnRegistries) -> String {
|
||||
}
|
||||
eq.push(format!("{name}:{text}"));
|
||||
}
|
||||
t.push(format!("eq={}", if eq.is_empty() { "-".into() } else { eq.join(";") }));
|
||||
t.push(format!(
|
||||
"eq={}",
|
||||
if eq.is_empty() {
|
||||
"-".into()
|
||||
} else {
|
||||
eq.join(";")
|
||||
}
|
||||
));
|
||||
let drops: Vec<String> = finalize::SLOT_NAMES
|
||||
.iter()
|
||||
.enumerate()
|
||||
@@ -295,7 +326,11 @@ fn describe(m: &Mob, all: &[Mob], regs: &SpawnRegistries) -> String {
|
||||
.collect();
|
||||
t.push(format!(
|
||||
"drop={}",
|
||||
if drops.is_empty() { "-".into() } else { drops.join(";") }
|
||||
if drops.is_empty() {
|
||||
"-".into()
|
||||
} else {
|
||||
drops.join(";")
|
||||
}
|
||||
));
|
||||
let attrs: Vec<String> = [
|
||||
Attr::MaxHealth,
|
||||
@@ -318,7 +353,14 @@ fn describe(m: &Mob, all: &[Mob], regs: &SpawnRegistries) -> String {
|
||||
.map(|(e, d, a)| format!("{e}:{a}:{d}"))
|
||||
.collect();
|
||||
fx.sort();
|
||||
t.push(format!("fx={}", if fx.is_empty() { "-".into() } else { fx.join(",") }));
|
||||
t.push(format!(
|
||||
"fx={}",
|
||||
if fx.is_empty() {
|
||||
"-".into()
|
||||
} else {
|
||||
fx.join(",")
|
||||
}
|
||||
));
|
||||
let mem: Vec<String> = MEMORIES
|
||||
.iter()
|
||||
.filter_map(|name| {
|
||||
@@ -380,13 +422,18 @@ fn main() -> horizon_client::Result<()> {
|
||||
None => name = token,
|
||||
}
|
||||
}
|
||||
let get = |k: &str, d: &'static str| -> String { c.get(k).copied().unwrap_or(d).to_owned() };
|
||||
let get =
|
||||
|k: &str, d: &'static str| -> String { c.get(k).copied().unwrap_or(d).to_owned() };
|
||||
let p: Vec<f64> = get("pos", "0,0,0")
|
||||
.split(',')
|
||||
.map(|x| x.parse().unwrap_or(0.0))
|
||||
.collect();
|
||||
let pos = Vec3::new(p[0], p[1], p[2]);
|
||||
let block = [p[0].floor() as i32, p[1].floor() as i32, p[2].floor() as i32];
|
||||
let block = [
|
||||
p[0].floor() as i32,
|
||||
p[1].floor() as i32,
|
||||
p[2].floor() as i32,
|
||||
];
|
||||
let base = match get("difficulty", "normal").as_str() {
|
||||
"peaceful" => 0,
|
||||
"easy" => 1,
|
||||
|
||||
@@ -140,7 +140,7 @@ pub fn mob_to_nbt(m: &Mob, uuid: [i32; 4], raw: Option<&Tag>) -> Tag {
|
||||
for (key, value) in [
|
||||
("AbsorptionAmount", Tag::Float(0)),
|
||||
("FallFlying", Tag::Byte(0)),
|
||||
("CanPickUpLoot", Tag::Byte(i8::from(m.extra.pick_up_loot))),
|
||||
("CanPickUpLoot", Tag::Byte(i8::from(m.can_pick_up_loot()))),
|
||||
("LeftHanded", Tag::Byte(0)),
|
||||
(
|
||||
"Brain",
|
||||
|
||||
@@ -1215,14 +1215,14 @@ impl Mob {
|
||||
},
|
||||
kind,
|
||||
};
|
||||
// setCanPickUpLoot(true) in the Villager, AbstractPiglin, Allay,
|
||||
// Dolphin, Fox and Panda constructors.
|
||||
// setCanPickUpLoot(true) in the Villager, AbstractPiglin, Dolphin,
|
||||
// Fox and Panda constructors (an allay's is false until it holds
|
||||
// something: it overrides canPickUpLoot).
|
||||
mob.extra.pick_up_loot = matches!(
|
||||
mob.species(),
|
||||
Species::Villager
|
||||
| Species::Piglin
|
||||
| Species::PiglinBrute
|
||||
| Species::Allay
|
||||
| Species::Dolphin
|
||||
| Species::Fox
|
||||
| Species::Panda
|
||||
@@ -1230,6 +1230,15 @@ impl Mob {
|
||||
ai::register(&mut mob);
|
||||
mob
|
||||
}
|
||||
/// `Mob.canPickUpLoot`, with the overrides: an allay that holds
|
||||
/// something off its pickup cooldown, a sulfur cube with no block.
|
||||
pub fn can_pick_up_loot(&self) -> bool {
|
||||
match self.species() {
|
||||
Species::Allay => self.extra.main_hand.is_some() && self.extra.ints[3] <= 0,
|
||||
Species::SulfurCube => !sulfur_cube::has_body(self),
|
||||
_ => self.extra.pick_up_loot,
|
||||
}
|
||||
}
|
||||
pub fn bounds(&self) -> Aabb {
|
||||
let w = f64::from(self.width()) / 2.0;
|
||||
Aabb::new(
|
||||
|
||||
@@ -895,11 +895,14 @@ fn check_despawn(m: &mut Mob, w: &MobWorld) -> bool {
|
||||
|| super::nautilus::is_nautilus(m.species()) && m.extra.tame
|
||||
|| m.species() == Species::SulfurCube
|
||||
&& (super::sulfur_cube::has_body(m) || m.extra.scratch[3] != 0);
|
||||
// removeWhenFarAway: animals, wardens, patrols and raiders, zombie
|
||||
// villagers being cured and ridden mobs stay.
|
||||
// removeWhenFarAway: animals, wardens, allays, patrols and raiders,
|
||||
// zombie villagers being cured and ridden mobs stay; the wither's
|
||||
// checkDespawn never removes it for distance.
|
||||
let creature = m.kind.category == "creature";
|
||||
let removable = !(m.species() == Species::Warden
|
||||
|| creature && m.kind.flags.animal && !m.extra.jockey
|
||||
let removable = !(matches!(
|
||||
m.species(),
|
||||
Species::Warden | Species::Allay | Species::Wither
|
||||
) || creature && m.kind.flags.animal && !m.extra.jockey
|
||||
|| super::raider::keeps_alive(m, d)
|
||||
|| super::zombie_villager::keeps_alive(m)
|
||||
|| super::riders::keeps_alive(m));
|
||||
|
||||
@@ -27,7 +27,6 @@ pub fn register(m: &mut Mob) {
|
||||
m.ai.nav.kind = NavKind::Flying;
|
||||
// FlyingPathNavigation.setRequiredPathLength(48).
|
||||
m.ai.nav.required_path_length = 48.0;
|
||||
m.persistent = true;
|
||||
let g = &mut m.ai.goals;
|
||||
g.add(0, Panic::new(2.5));
|
||||
g.add(1, Fetch);
|
||||
|
||||
@@ -473,7 +473,10 @@ pub const COMMON_TROPICAL: [(u8, u8, u8); 22] = [
|
||||
pub fn finalize(m: &mut Mob) {
|
||||
if m.species() == Species::TropicalFish {
|
||||
let (p, b, c) = if m.random.next_float() < 0.9 {
|
||||
COMMON_TROPICAL[m.random.next_int_bound(COMMON_TROPICAL.len() as i32).unwrap_or(0) as usize]
|
||||
COMMON_TROPICAL[m
|
||||
.random
|
||||
.next_int_bound(COMMON_TROPICAL.len() as i32)
|
||||
.unwrap_or(0) as usize]
|
||||
} else {
|
||||
(
|
||||
m.random.next_int_bound(12).unwrap_or(0) as u8,
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
//! `sound_variant` the index in the species' sound variant registry.
|
||||
use super::{Mob, Species, farm::Climate, gear, spawning::LocalDifficulty};
|
||||
use crate::{enchant::Enchantments, items::Items};
|
||||
use horizon_core::{geometry::Aabb, random::RandomSource};
|
||||
use horizon_core::{
|
||||
geometry::Aabb,
|
||||
random::{LegacyRandom, RandomSource},
|
||||
};
|
||||
use serde_json::Value;
|
||||
use std::{fs, path::Path, sync::Arc};
|
||||
|
||||
@@ -490,6 +493,23 @@ fn transient(m: &Mob, a: Attr) -> Option<(f64, Op)> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
/// The attribute modifiers of the mob's effects (`MobEffect.addAttributeModifier`,
|
||||
/// scaled by the amplifier plus one): strength and speed.
|
||||
fn effect_modifiers(m: &Mob, a: Attr) -> impl Iterator<Item = (f64, Op)> + '_ {
|
||||
m.extra
|
||||
.effects
|
||||
.iter()
|
||||
.filter_map(move |&(effect, _, amplifier)| {
|
||||
let level = f64::from(amplifier + 1);
|
||||
match (effect.trim_start_matches("minecraft:"), a) {
|
||||
("strength", Attr::AttackDamage) => Some((3.0 * level, Op::AddValue)),
|
||||
("speed", Attr::MovementSpeed) => {
|
||||
Some((f64::from(0.2f32) * level, Op::AddMultipliedTotal))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
}
|
||||
/// `AttributeInstance.getValue`: the base, then the modifiers by operation.
|
||||
pub fn value(m: &Mob, a: Attr) -> f64 {
|
||||
compute(m, a, true)
|
||||
@@ -503,8 +523,9 @@ fn compute(m: &Mob, a: Attr, with_transient: bool) -> f64 {
|
||||
.filter(|x| x.attr == a)
|
||||
.map(|x| (x.amount, x.op))
|
||||
.collect();
|
||||
if with_transient && let Some(t) = transient(m, a) {
|
||||
ops.push(t);
|
||||
if with_transient {
|
||||
ops.extend(transient(m, a));
|
||||
ops.extend(effect_modifiers(m, a));
|
||||
}
|
||||
for (amount, op) in &ops {
|
||||
if *op == Op::AddValue {
|
||||
@@ -523,7 +544,11 @@ fn compute(m: &Mob, a: Attr, with_transient: bool) -> f64 {
|
||||
}
|
||||
}
|
||||
let (lo, hi) = a.range();
|
||||
if result.is_nan() { lo } else { result.clamp(lo, hi) }
|
||||
if result.is_nan() {
|
||||
lo
|
||||
} else {
|
||||
result.clamp(lo, hi)
|
||||
}
|
||||
}
|
||||
/// Copies the attribute values into the fields the game reads.
|
||||
fn refresh(m: &mut Mob, a: Attr) {
|
||||
@@ -719,7 +744,7 @@ fn age_boundary_reached(m: &mut Mob) {
|
||||
match m.species() {
|
||||
Species::Goat => set_base(m, Attr::AttackDamage, if baby { 1.0 } else { 2.0 }),
|
||||
Species::Hoglin => set_base(m, Attr::AttackDamage, if baby { 0.5 } else { 6.0 }),
|
||||
Species::SulfurCube if !baby => super::sulfur_cube::set_size(m, 2, true),
|
||||
Species::SulfurCube if !baby => sulfur_size(m, 2),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -875,7 +900,14 @@ impl<L: FinalizeLevel + ?Sized, R: RandomSource> Ctx<'_, L, R> {
|
||||
}
|
||||
}
|
||||
let partial = if self.difficulty.hard { 0.1 } else { 0.25 };
|
||||
const MATERIAL: [&str; 6] = ["leather", "copper", "golden", "chainmail", "iron", "diamond"];
|
||||
const MATERIAL: [&str; 6] = [
|
||||
"leather",
|
||||
"copper",
|
||||
"golden",
|
||||
"chainmail",
|
||||
"iron",
|
||||
"diamond",
|
||||
];
|
||||
let mut first = true;
|
||||
// EQUIPMENT_POPULATION_ORDER: head, chest, legs, feet.
|
||||
for (slot, piece) in [
|
||||
@@ -1095,7 +1127,8 @@ impl<L: FinalizeLevel + ?Sized, R: RandomSource> Ctx<'_, L, R> {
|
||||
m.extra.passenger = true;
|
||||
}
|
||||
} else if f64::from(self.float()) < 0.05
|
||||
&& let Some(mut chicken) = self.create("minecraft:chicken", Reason::Jockey, m)
|
||||
&& let Some(mut chicken) =
|
||||
self.create("minecraft:chicken", Reason::Jockey, m)
|
||||
{
|
||||
self.finalize(&mut chicken, Reason::Jockey, None);
|
||||
chicken.extra.jockey = true;
|
||||
@@ -1125,7 +1158,8 @@ impl<L: FinalizeLevel + ?Sized, R: RandomSource> Ctx<'_, L, R> {
|
||||
let knockback = r.next_double() * f64::from(0.05f32);
|
||||
let follow = r.next_double() * 1.5 * f64::from(special);
|
||||
let leader = r.next_float() < special * 0.05;
|
||||
let leader_rolls = leader.then(|| (r.next_double() * 0.25 + 0.5, r.next_double() * 3.0 + 1.0));
|
||||
let leader_rolls =
|
||||
leader.then(|| (r.next_double() * 0.25 + 0.5, r.next_double() * 3.0 + 1.0));
|
||||
set_base(m, Attr::SpawnReinforcements, reinforcements);
|
||||
add_modifier(
|
||||
m,
|
||||
@@ -1192,7 +1226,11 @@ impl<L: FinalizeLevel + ?Sized, R: RandomSource> Ctx<'_, L, R> {
|
||||
let (w, h) = self.data.camel_husk_size;
|
||||
let half = w / 2.0;
|
||||
let bounds = Aabb::new(
|
||||
horizon_core::geometry::Vec3::new(bx + 0.5 - f64::from(half), by, bz + 0.5 - f64::from(half)),
|
||||
horizon_core::geometry::Vec3::new(
|
||||
bx + 0.5 - f64::from(half),
|
||||
by,
|
||||
bz + 0.5 - f64::from(half),
|
||||
),
|
||||
horizon_core::geometry::Vec3::new(
|
||||
bx + 0.5 + f64::from(half),
|
||||
by + f64::from(h),
|
||||
@@ -1203,13 +1241,17 @@ impl<L: FinalizeLevel + ?Sized, R: RandomSource> Ctx<'_, L, R> {
|
||||
*tried = true;
|
||||
if self.float() < 0.1 {
|
||||
set_item(m, MAINHAND, "minecraft:iron_spear");
|
||||
if let Some(mut camel) = self.level.create("minecraft:camel_husk", Reason::Natural) {
|
||||
if let Some(mut camel) =
|
||||
self.level.create("minecraft:camel_husk", Reason::Natural)
|
||||
{
|
||||
// setPos: the husk's position, the camel's own rotation.
|
||||
camel.position = m.position;
|
||||
camel.previous = m.position;
|
||||
self.finalize(&mut camel, reason, None);
|
||||
self.ride(m, &mut camel);
|
||||
if let Some(mut parched) = self.create("minecraft:parched", Reason::Natural, m) {
|
||||
if let Some(mut parched) =
|
||||
self.create("minecraft:parched", Reason::Natural, m)
|
||||
{
|
||||
self.finalize(&mut parched, reason, None);
|
||||
self.ride(&mut parched, &mut camel);
|
||||
self.created.push(camel);
|
||||
@@ -1452,7 +1494,10 @@ impl<L: FinalizeLevel + ?Sized, R: RandomSource> Ctx<'_, L, R> {
|
||||
let s = m.species();
|
||||
match s {
|
||||
S::Pig | S::Cow | S::Chicken => {
|
||||
let (v, sound): (fn(&SpawnRegistries) -> &VariantRegistry, fn(&SpawnRegistries) -> &VariantRegistry) = match s {
|
||||
let (v, sound): (
|
||||
fn(&SpawnRegistries) -> &VariantRegistry,
|
||||
fn(&SpawnRegistries) -> &VariantRegistry,
|
||||
) = match s {
|
||||
S::Pig => (|r| &r.pig, |r| &r.pig_sound),
|
||||
S::Cow => (|r| &r.cow, |r| &r.cow_sound),
|
||||
_ => (|r| &r.chicken, |r| &r.chicken_sound),
|
||||
@@ -1725,7 +1770,7 @@ impl<L: FinalizeLevel + ?Sized, R: RandomSource> Ctx<'_, L, R> {
|
||||
let g = self.ageable(m, g);
|
||||
if s == S::SulfurCube {
|
||||
let size = if m.is_baby() { 1 } else { 2 };
|
||||
super::sulfur_cube::set_size(m, size, true);
|
||||
sulfur_size(m, size);
|
||||
} else {
|
||||
let mut scale = self.int(3);
|
||||
if scale < 2 && self.float() < 0.5 * self.special() {
|
||||
@@ -1784,7 +1829,13 @@ impl<L: FinalizeLevel + ?Sized, R: RandomSource> Ctx<'_, L, R> {
|
||||
S::Zombie | S::ZombifiedPiglin => self.zombie(m, g, reason),
|
||||
S::ZombieVillager => {
|
||||
self.villager_type(m);
|
||||
m.extra.variant2 = m.random.next_int_bound(15).unwrap_or(0) as u8;
|
||||
// ZombieVillager's constructor picks the profession from the
|
||||
// fresh entity's random, before anything seeds it: an
|
||||
// independent draw that leaves the mob's own random alone.
|
||||
let mut fresh = LegacyRandom::new(
|
||||
(m.random.state() as i64).wrapping_mul(0x5851_F42D_4C95_7F2D) ^ i64::from(m.id),
|
||||
);
|
||||
m.extra.variant2 = fresh.next_int_bound(15).unwrap_or(0) as u8;
|
||||
self.zombie(m, g, reason)
|
||||
}
|
||||
S::Husk => self.husk(m, g, reason),
|
||||
@@ -1826,7 +1877,12 @@ impl<L: FinalizeLevel + ?Sized, R: RandomSource> Ctx<'_, L, R> {
|
||||
super::warden::finalize(m, reason == Reason::Triggered, &mut Vec::new());
|
||||
set_memory(m, "dig_cooldown", 0, 1200);
|
||||
if reason == Reason::Triggered {
|
||||
set_memory(m, "is_emerging", 0, i64::from(super::warden::EMERGE_DURATION));
|
||||
set_memory(
|
||||
m,
|
||||
"is_emerging",
|
||||
0,
|
||||
i64::from(super::warden::EMERGE_DURATION),
|
||||
);
|
||||
}
|
||||
self.mob(m, g)
|
||||
}
|
||||
@@ -1893,11 +1949,27 @@ pub fn panda_variant(main: u8, hidden: u8) -> u8 {
|
||||
if recessive && main != hidden { 0 } else { main }
|
||||
}
|
||||
/// `AbstractCubeMob.setSize(size, true)` for slimes and magma cubes.
|
||||
/// `SulfurCube.setSize(size, true)`, with the attribute bases it sets.
|
||||
fn sulfur_size(m: &mut Mob, size: i32) {
|
||||
super::sulfur_cube::set_size(m, size, true);
|
||||
let size = m.extra.size;
|
||||
set_base(m, Attr::MaxHealth, f64::from(4 * size));
|
||||
set_base(
|
||||
m,
|
||||
Attr::MovementSpeed,
|
||||
f64::from(0.2f32 + 0.1f32 * size as f32),
|
||||
);
|
||||
m.health = max_health(m);
|
||||
}
|
||||
fn cube_size(m: &mut Mob, size: i32) {
|
||||
let size = size.clamp(1, 127);
|
||||
m.extra.size = size;
|
||||
set_base(m, Attr::MaxHealth, f64::from(size * size));
|
||||
set_base(m, Attr::MovementSpeed, f64::from(0.2f32 + 0.1f32 * size as f32));
|
||||
set_base(
|
||||
m,
|
||||
Attr::MovementSpeed,
|
||||
f64::from(0.2f32 + 0.1f32 * size as f32),
|
||||
);
|
||||
set_base(m, Attr::AttackDamage, f64::from(size));
|
||||
if m.species() == Species::MagmaCube {
|
||||
set_base(m, Attr::Armor, f64::from(size * 3));
|
||||
@@ -1911,7 +1983,9 @@ pub fn variant_index(s: Species, name: &str) -> u8 {
|
||||
Species::Cat => super::tame::CAT_VARIANTS.iter().position(|v| *v == name),
|
||||
Species::Wolf => super::tame::WOLF_VARIANTS.iter().position(|v| v.0 == name),
|
||||
Species::ZombieNautilus => super::nautilus::VARIANTS.iter().position(|v| *v == name),
|
||||
_ => ["temperate", "warm", "cold"].iter().position(|v| *v == name),
|
||||
_ => ["temperate", "warm", "cold"]
|
||||
.iter()
|
||||
.position(|v| *v == name),
|
||||
};
|
||||
i.unwrap_or(0) as u8
|
||||
}
|
||||
@@ -1921,8 +1995,14 @@ pub fn variant_name(s: Species, index: u8) -> &'static str {
|
||||
match s {
|
||||
Species::Cat => super::tame::CAT_VARIANTS.get(i).copied().unwrap_or("tabby"),
|
||||
Species::Wolf => super::tame::WOLF_VARIANTS.get(i).map_or("pale", |v| v.0),
|
||||
Species::ZombieNautilus => super::nautilus::VARIANTS.get(i).copied().unwrap_or("temperate"),
|
||||
_ => ["temperate", "warm", "cold"].get(i).copied().unwrap_or("temperate"),
|
||||
Species::ZombieNautilus => super::nautilus::VARIANTS
|
||||
.get(i)
|
||||
.copied()
|
||||
.unwrap_or("temperate"),
|
||||
_ => ["temperate", "warm", "cold"]
|
||||
.get(i)
|
||||
.copied()
|
||||
.unwrap_or("temperate"),
|
||||
}
|
||||
}
|
||||
/// `VillagerType.byBiome` (index into `render::VILLAGER_TYPES`: plains,
|
||||
@@ -1936,8 +2016,12 @@ pub fn villager_type(biome: &str) -> u8 {
|
||||
| "snowy_taiga" | "snowy_plains" | "grove" | "snowy_slopes" | "frozen_peaks"
|
||||
| "jagged_peaks" => 4,
|
||||
"swamp" | "mangrove_swamp" => 5,
|
||||
"old_growth_spruce_taiga" | "old_growth_pine_taiga" | "windswept_gravelly_hills"
|
||||
| "windswept_hills" | "taiga" | "windswept_forest" => 6,
|
||||
"old_growth_spruce_taiga"
|
||||
| "old_growth_pine_taiga"
|
||||
| "windswept_gravelly_hills"
|
||||
| "windswept_hills"
|
||||
| "taiga"
|
||||
| "windswept_forest" => 6,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ pub fn register(m: &mut Mob) {
|
||||
hovers: false,
|
||||
};
|
||||
m.ai.nav.kind = NavKind::Flying;
|
||||
m.persistent = true;
|
||||
let g = &mut m.ai.goals;
|
||||
g.add(0, DoNothing);
|
||||
g.add(
|
||||
|
||||
@@ -138,8 +138,8 @@ public final class VanillaFinalizeSpawnOracle {
|
||||
@Override public net.minecraft.world.level.StructureManager structureManager() { return structures; }
|
||||
@Override public BlockGetter getChunkForCollisions(int chunkX, int chunkZ) { return this; }
|
||||
@Override public boolean isSpawningMonsters() { return rules.get(GameRules.SPAWN_MOBS) && rules.get(GameRules.SPAWN_MONSTERS); }
|
||||
@Override public void playSeededSound(Entity except, double x, double y, double z, Holder<SoundEvent> sound, SoundSource source, float volume, float pitch, long seed) {}
|
||||
@Override public void playSeededSound(Entity except, Entity sourceEntity, Holder<SoundEvent> sound, SoundSource source, float volume, float pitch, long seed) {}
|
||||
@Override public void playSeededSound(net.minecraft.world.entity.Entity except, double x, double y, double z, Holder<SoundEvent> sound, SoundSource source, float volume, float pitch, long seed) {}
|
||||
@Override public void playSeededSound(net.minecraft.world.entity.Entity except, net.minecraft.world.entity.Entity sourceEntity, Holder<SoundEvent> sound, SoundSource source, float volume, float pitch, long seed) {}
|
||||
@Override public void gameEvent(Holder<net.minecraft.world.level.gameevent.GameEvent> gameEvent, Vec3 position, net.minecraft.world.level.gameevent.GameEvent.Context context) {}
|
||||
@Override public void broadcastEntityEvent(Entity entity, byte event) {}
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@@ -429,6 +429,8 @@ public final class VanillaFinalizeSpawnOracle {
|
||||
level.fake = server;
|
||||
put(level, ServerLevel.class, "server", server);
|
||||
level.registries = access;
|
||||
// Level.playSound draws a sound seed before the (ignored) seeded sound.
|
||||
put(level, net.minecraft.world.level.Level.class, "soundSeedGenerator", RandomSource.create(0L));
|
||||
level.entities = new ArrayList<>();
|
||||
level.scoreboard = new net.minecraft.server.ServerScoreboard(server);
|
||||
level.border = new WorldBorder();
|
||||
|
||||
Reference in New Issue
Block a user