WIP: unfinished warden-sculk parity work, stopped by Ludovic
Uncommitted changes the agent had in progress when it was stopped on 2026-10-12; may not build or pass its harnesses yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -355,7 +355,9 @@ fn print(out: &mut String, t: i32, i: usize, m: &Mob) {
|
||||
u8::from(m.ai.jumping)
|
||||
);
|
||||
let _ = write!(out, "\trng {:x}", m.random.state());
|
||||
if let Some((acts, mem)) = horizon_client::mobs::villager_brain::describe(m) {
|
||||
if let Some((acts, mem)) = horizon_client::mobs::villager_brain::describe(m)
|
||||
.or_else(|| horizon_client::mobs::warden_brain::describe(m))
|
||||
{
|
||||
let _ = write!(out, "\tact {acts}\tmem {mem}");
|
||||
}
|
||||
out.push('\n');
|
||||
@@ -467,6 +469,12 @@ fn main() -> horizon_client::Result<()> {
|
||||
match flag.as_str() {
|
||||
"persistent" => m.persistent = true,
|
||||
"noai" => m.no_ai = true,
|
||||
// Warden.finalizeSpawn's own part.
|
||||
"digcooldown" | "emerge" => horizon_client::mobs::warden::finalize(
|
||||
&mut m,
|
||||
flag == "emerge",
|
||||
&mut Vec::new(),
|
||||
),
|
||||
other => panic!("unknown mob flag {other}"),
|
||||
}
|
||||
}
|
||||
@@ -481,6 +489,10 @@ fn main() -> horizon_client::Result<()> {
|
||||
spec.seed,
|
||||
);
|
||||
}
|
||||
if m.species() == Species::Warden {
|
||||
// As for villagers: the sensors delayed again, the RunOne seeded.
|
||||
horizon_client::mobs::warden::init_brain(&mut m, spec.seed);
|
||||
}
|
||||
mobs.push(m);
|
||||
}
|
||||
let player = s.player.map(|p| {
|
||||
|
||||
@@ -58,6 +58,7 @@ pub mod vex;
|
||||
pub mod villager;
|
||||
pub mod villager_brain;
|
||||
pub mod warden;
|
||||
pub mod warden_brain;
|
||||
pub mod witch;
|
||||
pub mod wither;
|
||||
mod world;
|
||||
|
||||
@@ -682,6 +682,10 @@ fn push_entities(m: &mut Mob, w: &MobWorld, events: &mut Vec<MobEvent>) {
|
||||
let _ = m.random.next_int_bound(4);
|
||||
}
|
||||
for (who, at) in targets {
|
||||
// Warden.doPush: touching it angers it, then the push itself.
|
||||
if m.species() == Species::Warden {
|
||||
super::warden::do_push(m, w, who, events);
|
||||
}
|
||||
// Entity.push(Entity) with `this` the other entity.
|
||||
let (mut xa, mut za) = (m.position.x - at.x, m.position.z - at.z);
|
||||
let mut dd = xa.abs().max(za.abs());
|
||||
@@ -758,6 +762,10 @@ fn server_ai_step(
|
||||
super::villager_brain::tick(m, w, level_random, events);
|
||||
let _ = m.random.next_int_bound(100);
|
||||
}
|
||||
if m.species() == Species::Warden {
|
||||
// Warden.customServerAiStep: the brain and its bookkeeping.
|
||||
super::warden::server_ai_step(m, w, level_random, events);
|
||||
}
|
||||
{
|
||||
let mut cx = Cx { w, events };
|
||||
custom_server_ai_step(m, &mut cx);
|
||||
@@ -782,7 +790,6 @@ fn custom_server_ai_step(m: &mut Mob, cx: &mut Cx) {
|
||||
Species::Enderman => super::enderman::custom_server_ai_step(m, cx),
|
||||
Species::Blaze => super::nether::blaze_server_ai_step(m, cx),
|
||||
Species::ElderGuardian => super::guardian::elder_server_ai_step(m, cx),
|
||||
Species::Warden => super::warden::server_ai_step(m, cx),
|
||||
Species::Wither if m.alive() => super::wither::custom_server_ai_step(m, cx.w, cx.events),
|
||||
// SpellcasterIllager.customServerAiStep.
|
||||
Species::Evoker if m.extra.counter > 0 => m.extra.counter -= 1,
|
||||
|
||||
@@ -36,7 +36,8 @@ impl<T> Default for Slot<T> {
|
||||
}
|
||||
}
|
||||
impl<T> Slot<T> {
|
||||
fn tick(&mut self) {
|
||||
/// `MemorySlot.tick` (`Brain.forgetOutdatedMemories`).
|
||||
pub(super) fn tick(&mut self) {
|
||||
if self.v.is_some() && self.ttl != NEVER {
|
||||
if self.ttl <= 0 {
|
||||
self.clear();
|
||||
@@ -66,9 +67,16 @@ impl<T> Slot<T> {
|
||||
pub fn get(&self) -> Option<&T> {
|
||||
self.v.as_ref()
|
||||
}
|
||||
pub(super) fn get_mut(&mut self) -> Option<&mut T> {
|
||||
self.v.as_mut()
|
||||
}
|
||||
pub fn present(&self) -> bool {
|
||||
self.v.is_some()
|
||||
}
|
||||
/// The time to live (`i64::MAX`: never expires).
|
||||
pub fn ttl(&self) -> i64 {
|
||||
self.ttl
|
||||
}
|
||||
}
|
||||
impl<T: Clone> Slot<T> {
|
||||
pub fn value(&self) -> Option<T> {
|
||||
@@ -77,7 +85,7 @@ impl<T: Clone> Slot<T> {
|
||||
}
|
||||
impl<T> Slot<Vec<T>> {
|
||||
/// `Brain.setMemory` of a collection: an empty one erases the memory.
|
||||
fn set_list(&mut self, v: Vec<T>) {
|
||||
pub(super) fn set_list(&mut self, v: Vec<T>) {
|
||||
if v.is_empty() {
|
||||
self.clear();
|
||||
} else {
|
||||
@@ -162,8 +170,8 @@ impl WalkTarget {
|
||||
/// cache of `Sensor.isEntityTargetable`.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Visible {
|
||||
list: Vec<Who>,
|
||||
cache: Vec<(Who, bool)>,
|
||||
pub(super) list: Vec<Who>,
|
||||
pub(super) cache: Vec<(Who, bool)>,
|
||||
}
|
||||
|
||||
/// The memories a villager's brain registers.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -467,6 +467,17 @@ public final class VanillaMobAiOracle {
|
||||
for (String flag : spec.flags) {
|
||||
if (flag.equals("persistent")) mob.setPersistenceRequired();
|
||||
else if (flag.equals("noai")) mob.setNoAi(true);
|
||||
// Warden.finalizeSpawn's own part (Mob.finalizeSpawn draws the level random,
|
||||
// which is not seeded yet): a minute before digging, or climbing out first.
|
||||
else if (flag.equals("digcooldown") || flag.equals("emerge")) {
|
||||
mob.getBrain().setMemoryWithExpiry(net.minecraft.world.entity.ai.memory.MemoryModuleType.DIG_COOLDOWN,
|
||||
net.minecraft.util.Unit.INSTANCE, 1200L);
|
||||
if (flag.equals("emerge")) {
|
||||
mob.setPose(net.minecraft.world.entity.Pose.EMERGING);
|
||||
mob.getBrain().setMemoryWithExpiry(net.minecraft.world.entity.ai.memory.MemoryModuleType.IS_EMERGING,
|
||||
net.minecraft.util.Unit.INSTANCE, net.minecraft.world.entity.monster.warden.WardenAi.EMERGE_DURATION);
|
||||
}
|
||||
}
|
||||
else throw new IllegalArgumentException(flag);
|
||||
}
|
||||
level.addFreshEntity(mob);
|
||||
|
||||
@@ -77,6 +77,16 @@ def scenarios():
|
||||
'player 12.5 -60 0.5',
|
||||
'mob minecraft:villager 0.5 -60 0.5 0 51 persistent',
|
||||
])
|
||||
# The warden: idle, sniffing out a player, roaring and fighting (WardenAi).
|
||||
# Without finalizeSpawn's dig cooldown a warden digs straight back down.
|
||||
add('warden_digs', 140, ['mob minecraft:warden 0.5 -60 0.5 0 60'])
|
||||
add('warden_alone', 400, ['mob minecraft:warden 0.5 -60 0.5 0 61 digcooldown'])
|
||||
add('warden_player', 600, ['player 5.5 -60 0.5', 'mob minecraft:warden 0.5 -60 0.5 0 62 digcooldown'])
|
||||
add('warden_player_far', 600, ['player 14.5 -60 3.5', 'mob minecraft:warden 0.5 -60 0.5 90 63 digcooldown'])
|
||||
add('warden_creative', 300, ['player 4.5 -60 0.5 creative', 'mob minecraft:warden 0.5 -60 0.5 0 64 digcooldown'])
|
||||
add('warden_persistent', 400, ['player 7.5 -60 0.5', 'mob minecraft:warden 0.5 -60 0.5 0 65 persistent digcooldown'])
|
||||
add('warden_emerging', 300, ['player 6.5 -60 0.5', 'mob minecraft:warden 0.5 -60 0.5 0 66 emerge'])
|
||||
add('warden_cow', 600, ['mob minecraft:warden 0.5 -60 0.5 0 67 digcooldown', 'mob minecraft:cow 4.5 -60 0.5 0 68 persistent'])
|
||||
return s
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user