Minecraft: Java Edition 26.3 rewritten from scratch in Rust, checked against vanilla with 281 differential harnesses. Get it with the Horizon launcher.
Rust differential-testinggame-enginegamedevlinuxminecraftminecraft-javareimplementationrustvoxelvulkanwgpu
Merge remote-tracking branch 'upstream/main' into HEAD
arismoko3370efe35e60
diff --cc crates/horizon-client-render/src/block_entities.rsindex 5fb1ea4ed,0e0a14479..48ea57c3f--- a/crates/horizon-client-render/src/block_entities.rs+++ b/crates/horizon-client-render/src/block_entities.rs@@@ -277,18 -274,9 +303,19 @@@ impl BlockEntities}/// `LevelChunk.setBlockEntity` (+ `addAndRegisterBlockEntity`): a new/// block entity may get a slot; one replacing another keeps its slot.+ /// One of the same type rewrites it in place (a jukebox taking a disc,+ /// `/data merge block`), where vanilla keeps the object, so its+ /// attachments stay; any other replacement starts them over.pub fn insert(&mut self, pos: Pos, entity: BlockEntity) -> Option<BlockEntity> {let new_is_mod = matches!(entity, BlockEntity::Mod(_));+ let same_type = |old: &BlockEntity| match (old, &entity) {+ (BlockEntity::Mod(old), BlockEntity::Mod(new)) => old.id == new.id,+ (old, new) => std::mem::discriminant(old) == std::mem::discriminant(new),+ };+ if !self.map.get(&pos).is_some_and(same_type) {+ self.attachments.remove(&pos);+ }+ let new_box = shows_box(&entity);let old = self.map.insert(pos, entity);if old.is_none() {self.add(pos);@@@ -351,13 -348,8 +388,13 @@@/// Removes the block entities `keep` refuses, and their slots/// (`clearAllBlockEntities` of unloaded chunks).pub fn retain(&mut self, mut keep: impl FnMut(&Pos, &mut BlockEntity) -> bool) {- let (live, pending, freed) = (&mut self.live, &mut self.pending, &mut self.freed);+ let (live, pending, freed, attachments) = (+ &mut self.live,+ &mut self.pending,+ &mut self.freed,+ &mut self.attachments,+ );- let mods = &mut self.mods;+ let (mods, boxes) = (&mut self.mods, &mut self.boxes);self.map.retain(|p, e| {let kept = keep(p, e);if !kept {@@@ -370,9 -362,9 +408,10 @@@});}pub fn clear(&mut self) {+ self.attachments.clear();self.map.clear();self.mods.clear();+ self.boxes.clear();self.tickers = Arc::default();self.live.clear();self.added.clear();@@@ -389,8 -381,8 +428,9 @@@pub fn load_chunk(&mut self, entities: Vec<(Pos, BlockEntity)>) {let order = chunk_map_order(entities.iter().map(|(p, _)| *p));for (p, e) in entities {+ self.attachments.remove(&p);let new_is_mod = matches!(e, BlockEntity::Mod(_));+ self.note_box(p, Some(&e));let old = self.map.insert(p, e);if old.is_some() {self.replaced.insert(p);diff --cc crates/horizon-client/src/entry.rsindex 502f4115c,dc4e03a1e..c022dfa2e--- a/crates/horizon-client/src/entry.rs+++ b/crates/horizon-client/src/entry.rs@@@ -3,17 -3,9 +3,18 @@@ use crate::{crash, game, logging, ram_l/// Start the game. The executable supplies the allocator and retains the mod API marker.pub fn main() {+ main_with(Default::default());+}++/// Start the game with trait mods in dispatch order.+pub fn main_with(mods: crate::mod_api::Mods) {+ // First: a trait injection into anything below (logging, the crash handler) calls its mod.+ if crate::mod_api::MODS.set(mods).is_err() {+ log::warn!("Trait mods already installed; ignoring the second list");+ }horizon_threads::configure_allocator();horizon_client::telemetry::mark_start();+ horizon_client::spans::startup::init(std::time::Instant::now());let args: Vec<String> = std::env::args().skip(1).collect();let game_args = args.iter().take_while(|a| *a != "--dedicated");let help = game_argsdiff --cc crates/horizon-client/src/game/lan_actions.rsindex d184f4f38,2851ef545..069eb70a2--- a/crates/horizon-client/src/game/lan_actions.rs+++ b/crates/horizon-client/src/game/lan_actions.rs@@@ -829,11 -825,15 +829,19 @@@ impl Game<'_>// inventory key while riding).let guest_mount = std::mem::replace(&mut self.mount_menu, host_mount_menu).opened_mob();self.keys = host_keys;+ // `Entity.addPassenger`: a rider that gets in now sits behind the+ // players already in the vehicle, which is what tells its+ // `getControllingPassenger` apart from this one's.+ let seat_order = (guest_vehicle.is_some() && host.hub.guests[i].vehicle != guest_vehicle)+ .then(|| {+ host.hub.seat_order += 1;+ host.hub.seat_order+ });let g = &mut host.hub.guests[i];+ std::mem::swap(+ &mut self.player_attachments,+ self.guest_attachments.entry(g.uuid).or_default(),+ );let left_vehicle = g.vehicle.filter(|_| guest_vehicle.is_none());if guest_vehicle.is_none() {g.vehicle_good = None;diff --cc crates/horizon-client/src/game/persist.rsindex 46f095e32,4e65cac10..92a9cefbf--- a/crates/horizon-client/src/game/persist.rs+++ b/crates/horizon-client/src/game/persist.rs@@@ -1517,12 -1503,12 +1557,17 @@@ impl Game<'_>.chain(self.item_frames.iter().map(|e| e.id)).chain(self.paintings.iter().map(|e| e.id)).chain(self.others.iter().map(|e| e.id))+ .chain(self.orbs.iter().map(|e| e.id))+ .chain(self.creatures.projectiles.iter().map(|e| e.id))+ .chain(self.crystals.iter().map(|e| e.id))+ .chain(self.dragon.iter().map(|e| e.id))+ .chain(self.tnts.iter().map(|e| e.id)).collect();+ for (id, uuid) in &self.persist.uuids {+ if !alive.contains(id) {+ self.entity_attachments.remove(uuid);+ }+ }self.persist.uuids.retain(|id, _| alive.contains(id));self.persist.raw.retain(|id, _| alive.contains(id));}