Compare commits

..
Author SHA1 Message Date
Ludovic Marie 11102a5651 Merge pull request #12516 from RINNECODER/up5/port-armor-tags
🤖 Agent: The declaration passes horizon-mods' item check: max_stack_size 1 is the field (1..=99), and minecraft:equippable with only slot is a valid 26.3 Equippable. The #tag walk stops at 8 levels and reads only the carried jar's tags, so the oracle path and untagged items are unchanged.
2026-11-08 14:28:04 +01:00
Ludovic Marie 0cf6116d8d Merge pull request #12505 from sluisr/sec/protocol-recursion-and-threads-soundness
🤖 Agent: Same diff as #12490, which I reviewed before its author closed it (its verify failure was a linker crash on a full-disk runner). A server's registry ids can no longer walk out of the resources folder (no ., .., empty or upper-case segments), predicate components get the same nesting guard as potions, and banner layer counts are bounded by the bytes left (2 per layer).
2026-11-08 14:28:00 +01:00
Ludovic Marie bf53e59fae Merge pull request #12511 from MSedgeMC/port_map/debug-profile
🤖 Agent: DebugEntries has load, set_status, toggle_status, enabled and save, and the F3+F6 editor is game/debug_options.rs, so the 'no editor' skip note was out of date.
2026-11-08 14:27:57 +01:00
Ludovic Marie affb4cbc98 Merge pull request #12510 from MSedgeMC/port_map/multiplayer-allowed
🤖 Agent: AccountStatus::allows_multiplayer in ban_notice.rs is the account check the title screen reads; a skip:service with no note was stale.
2026-11-08 14:27:52 +01:00
Ludovic Marie ab6fe1802d Merge pull request #12509 from MSedgeMC/port_map/world-dimensions-stable
🤖 Agent: dimension_is_vanilla_like in save.rs holds the three stable arms, so the isStable* rows are inline there and isVanillaLike is the port.
2026-11-08 14:27:47 +01:00
Ludovic Marie c23c62df76 Merge pull request #12508 from MSedgeMC/port_map/equipment-is-armor
🤖 Agent: Slot::is_armor exists in mobs/equip.rs (head, chest, legs, feet, not the hands), so the stale skip:other becomes the port.
2026-11-08 14:27:42 +01:00
Ludovic Marie 67093685db Merge pull request #12458 from glitchsnake/fix/11807-summon-duplicate-uuid
🤖 Agent: PersistentEntitySectionManager refuses a UUID already in the level, so a duplicate inside a summoned tree stays a saved passenger under Passengers. Cost to watch: target_with_uuid scans every known UUID, now once per loaded entity with a UUID. I pushed #[ignore] on its second test, which unwraps HORIZON_TEST_RESOURCES like its ignored sibling (verify failed on it).
2026-11-08 14:27:39 +01:00
Ludovic Marie 012391f4aa Merge pull request #12405 from TaquitoSuabe/perf/cheap-in-order-chunks
🤖 Agent: Columns decode on up to 4 workers and are delivered strictly in arrival order (seq). I pushed a fix: the attachments retain runs after the column's block entities load again, so a resent column keeps its block entities' attachments.
2026-11-08 14:23:38 +01:00
Ludovic Marie 4757e2ddca Merge pull request #12507 from MSedgeMC/port_map/weather-layers
🤖 Agent: Builder::weather_layers and weather_layer are in horizon-world's environment_system.rs on main; environment.rs no longer has apply_weather, so the two rows point at the code that runs.
2026-11-08 14:23:35 +01:00
Ludovic Marie c1e8fc5d4b Merge pull request #12495 from MSedgeMC/fix/non-tame-prey-recheck
🤖 Agent: NonTameRandomTargetGoal: canUse needs an untamed mob, and the target keeps matching the selector (Turtle.BABY_ON_LAND_SELECTOR now checks !isInWater), so a baby turtle that reaches water is let go.
2026-11-08 14:22:01 +01:00
Ludovic Marie aa3d35ebc7 Merge pull request #12492 from sluisr/perf/entity-pool-and-meshing-allocs
🤖 Agent: pack_lighting reuses one stack array (every row below h is fully written, the rows above refilled), the server's object states reuse the pooled States, and the guest turn skips the 5-stack clone when the gear is unchanged.
2026-11-08 14:21:58 +01:00
Ludovic Marie d178e80ea5 Merge pull request #12484 from TheMrZZ/fix/h182-trader-llama-discard
🤖 Agent: TraderLlama.maybeDespawn discards in aiStep, so a removed trader llama leaves the mob list in that tick (tick returns false); tame or persistent ones stay.
2026-11-08 14:21:54 +01:00
Ludovic Marie 7f117f484e Merge pull request #12465 from TheMrZZ/fix/armor-stand-lodestone-inventory-tick
🤖 Agent: EntityEquipment.tick runs each equipped item's inventoryTick, so a stand's lodestone compass loses its target when the lodestone goes; only compass stacks pay the lookup.
2026-11-08 14:21:50 +01:00
Ludovic Marie d3910293e0 Merge pull request #12457 from Joansitoh/fix/11886-trident-falls
🤖 Agent: AbstractArrow.tick: a stuck trident falls when the block at its position differs from lastState (the hit block) and nothing is within 0.06; startFalling's three nextFloat()*0.2F draws scale x, y, z in that order.
2026-11-08 14:21:47 +01:00
Ludovic Marie c3d6c640ac Merge pull request #12383 from TheMrZZ/fix/h259-unused-feature-startup
🤖 Agent: An unused invalid fill_layer in a selected pack now fails world preparation through the existing leaf codec, as vanilla's registry load does, instead of the dedicated server falling back to a flat generator; its capture harness (--kind/--output) runs by name only (pushed).
2026-11-08 14:21:44 +01:00
Ludovic Marie 37e9e82dfd Merge pull request #12501 from MSedgeMC/fix/spider-vehicle-attack
🤖 Agent: SpiderAttackGoal.canUse is super.canUse() && !isVehicle(): Mob.rider (a player on its back, set by mounts.rs and the remote/LAN vehicle paths) now counts beside extra.rider (a mob jockey).
2026-11-08 14:21:40 +01:00
Ludovic Marie f4eebc417e Merge pull request #12500 from MSedgeMC/fix/hurt-by-universal-anger
🤖 Agent: HurtByTargetGoal.canUse returns false for a player's hit when universal_anger is on (checked after the timestamp, before the ignore classes, as vanilla); Who has only Player/Mob, so guests' hits take the same path.
2026-11-08 14:21:36 +01:00
Ludovic Marie 0e83631f9d Merge pull request #12499 from TheMrZZ/fix/entity-predicate-movement
🤖 Agent: MovementPredicate.matches as vanilla: per-tick velocity × 20, speed and horizontal_speed against squared bounds (a negative bound squares, as MinMaxBounds.Doubles does), vertical_speed on |y|, exact bounds with no tolerance; only an unmounted, unridden mob gets the snapshot, so other subjects keep today's false.
2026-11-08 14:21:33 +01:00
Ludovic Marie a2140a9ef6 Merge pull request #12502 from TheMrZZ/fix/golem-defense-reputation
🤖 Agent: DefendVillage reads the villager's gossips by the selected player's own UUID instead of level.player_uuid, so a hated guest on a server is attacked and a hated host no longer turns the golem on a guest. I pushed a commit dropping a doc paragraph and a constant copied from another test file.
2026-11-08 14:21:30 +01:00
Ludovic Marie 35b2938c47 Merge pull request #12503 from vnsmoreira/packs/polytone-particle-runtime
🤖 Agent: Merged main in (game.rs frame block and the add/add on horizon-polytone particles.rs, which matches main plus tick_source); the merged diff equals the last commit. Without a Polytone pack, polytone_animate/polytone_entity/make return at the first `let Some(registry)`, so the animate tick and spawn paths pay nothing.
2026-11-08 14:21:26 +01:00
Ludovic Marie 236b13f290 Merge pull request #12389 from Vaspyyy/armor-stand-entity-collisions
🤖 Agent: Stands collide with shulkers, boats and a still adult happy ghast through Entity.collide's getEntityCollisions, with an obstacle grid built only when a stand moves, and Shulker.makeBoundingBox's lid lifts what rests on it.
2026-11-08 14:21:22 +01:00
Ludovic Marie 838ae17615 Merge pull request #12504 from horizon-rust/cg72/grindstone-default-max-damage
🤖 Agent: Grindstone max_damage fix for main's menu_click 7998/8000 (#11434): writes the merged MAX_DAMAGE only when it differs from the item's own, as PatchedDataComponentMap.set does; unit test with the failing case
2026-11-08 14:21:18 +01:00
RINNECODERandClaude Opus 5.5 bdc8a23f21 Port pack: without the oracle, armour the vanilla armour tags name is worn in its slot
A carry without the oracle's facts declared every item that has no block as
a stick, so a mod's helmets and chestplates could not be worn. Items the
carried minecraft:{head,chest,leg,foot}_armor tags name (directly or through
the mod's own tags) now get minecraft:equippable with that slot and a stack
size of 1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 07:11:06 -06:00
Horizon agentandClaude Opus 5.5 087ce1708b Merge origin/main into armor-stand-entity-collisions
ObstacleGrid keeps main's reused scratch list (near takes &mut self) with
this branch's roots, near_except and huge-area path; the shulker keeps one
progress_aabb with a scale and bullet_origin is the centre of bounds_at;
the shulker shell tick and main's trader llama tick both run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 14:03:16 +01:00
MSedgeMC 61b7fa5b26 port_map: the three stable-dimension helpers are arms of dimension_is_vanilla_like 2026-11-08 13:01:34 +00:00
MSedgeMC 1df93f9739 port_map: the rest of the debug profile editor rows are ports 2026-11-08 13:00:39 +00:00
MSedgeMC 17e2982614 port_map: the debug profile load and save rows are ports
Both methods are implemented in debug_entries.rs and used by the F3+F6
DebugOptionsScreen; the rows' "no editor" note is stale.
2026-11-08 12:59:18 +00:00
Horizon agentandClaude Opus 5.5 eb74ad2a63 Merge origin/main into packs/polytone-particle-runtime
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 13:59:14 +01:00
MSedgeMC 34aa927de4 port_map: Minecraft.allowsMultiplayer is allows_multiplayer
The row skipped the account check as a service. AccountStatus::allows_multiplayer
is documented as the method and the title screen enables its Multiplayer and
Realms buttons from it.
2026-11-08 12:58:48 +00:00
MSedgeMC 491403897f port_map: WorldDimensions.isVanillaLike is dimension_is_vanilla_like
The row skipped the predicate, but save::dimension_is_vanilla_like is
documented as the method and its caller world_gen_unstable drives the
experimental-settings warning the note mentions.
2026-11-08 12:58:14 +00:00
MSedgeMC 3f7e6970ae port_map: EquipmentSlot.isArmor is Slot::is_armor
The row skipped the predicate as a plain constant, but Slot::is_armor is
documented as EquipmentSlot.isArmor and read by slot_for and mob loot
replacement.
2026-11-08 12:57:49 +00:00
Horizon agentandClaude Opus 5.5 d609f56d42 golem_defense_tests: drop a doc paragraph and a constant copied from another test
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 13:57:20 +01:00
MSedgeMC 37ed06402d port_map: the weather layer rows name environment_system
apply_weather is gone; the weather layers live in horizon-world's
environment_system: Builder::weather_layers adds one per attribute rain or
thunder changes, and Builder::weather_layer registers the entries weather
runs.
2026-11-08 12:57:19 +00:00
sluisr e5043bb090 fix(security): bound item predicate recursion, validate registry paths, and fix threads UB
- Guard recursive `Component::read` calls in `skip::component_matchers`,
  `gameplay::block_predicate`, and `v1_20_3::from_tag` with `Nested::enter()`
  to prevent stack overflow DoS via deeply nested `CAN_PLACE_ON` / `CAN_BREAK`
  exact component matchers, and tighten `banner_layers` pre-allocation cap.
- Validate registry and entry resource location segments in
  `net::fill_known_entries` before joining paths and reading local files on
  `Clientbound::RegistryData`.
- Fix data race UB in `horizon_threads::heap_census` (`slot` / `slot_name`)
  by publishing `NAME_PTR` with `Release` and loading with `Acquire`, and
  guard `CensusAllocator::alloc` / `realloc` against size addition overflow.
- Fix provenance UB in `horizon_threads::boot_paint` where an immutable
  reference `&count` was passed as Win32 `AddFontMemResourceEx`'s mutable
  `pNumFonts` out-pointer, and require `'static` font byte slices.
2026-11-08 13:55:29 +01:00
Horizon agentandClaude Opus 5.5 d035060e66 Grindstone: a merged max damage equal to the item's own writes no component
GrindstoneMenu.mergeItems sets MAX_DAMAGE to the larger of the two, and
PatchedDataComponentMap.set drops a value equal to the prototype's. Since
#11434 Horizon always wrote it, so merging two plain diamond pickaxes gave
one carrying max_damage:1561 (menu_click 7998/8000 on main).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 13:50:25 +01:00
MSedgeMC afb2ce0f1e A spider carrying a player does not start its attack
`SpiderAttackGoal.canUse` is `super.canUse() && !isVehicle()`, and
`isVehicle()` is true for any rider. Horizon's `SpiderAttack` checked only
mob riders (`extra.rider`), so a spider with a player on its back began
the melee goal.
2026-11-08 12:48:48 +00:00
MSedgeMC 2ffc8b5f56 Universal anger leaves a player's hit to the anger goals
`HurtByTargetGoal.canUse` refuses a player's hit when the
`universal_anger` game rule is on, leaving that hit to the anger target
goals. Horizon's `HurtByTarget` always retaliated against the player, so
the rule changed the anger bookkeeping but not the direct retaliation.
2026-11-08 12:48:16 +00:00
Ludovic Marie 447e9d277d Merge pull request #12477 from vnsmoreira/packs/polytone-particles
🤖 Agent: Includes #12475 and #12476. Particle and emitter files are parsed with every expression compiled at load (a typo fails the load); nothing spawns them yet, so no runtime cost.
2026-11-08 13:42:09 +01:00
TheMrZZandCodex d0d9e050d3 Evaluate movement predicates for supported Mob query snapshots
Preserve global ranges and unsupported provider contexts.

Co-Authored-By: Codex <[email protected]>
2026-11-08 13:41:10 +01:00
MSedgeMC 678dfde14b A non-tame predator stops hunting prey its selector no longer matches
`NonTameRandomTargetGoal.canContinueToUse` re-tests the goal's
`targetConditions` while hunting, so the `Turtle.BABY_ON_LAND_SELECTOR`
(a baby turtle out of water) drops out as soon as the turtle enters
water. Horizon's `NearestTarget` only ran the base continue rules, and its
turtle filter never checked the water, so a wolf or cat kept hunting the
turtle.
2026-11-08 12:37:25 +00:00
Ludovic Marie 1597853de7 Merge pull request #12486 from echo-ilovech3ss/fix/12287-windows-save-roundtrip-paths
🤖 Agent: Tooling only: save_roundtrip compares relative .dat paths as POSIX on every OS, so Windows' backslashes no longer make every file look renamed.
2026-11-08 13:36:22 +01:00
Ludovic Marie 7d0f866a47 Merge pull request #12481 from RINNECODER/up4/upgrade-surface-rule-biomes
🤖 Agent: A surface rule's biome_is keeps vanilla's biomes and the pack's own; others (a "comment" entry, another mod's biome) are dropped and reported as lossy, since 26.3 refuses the pack over them.
2026-11-08 13:36:18 +01:00
Vinícius MoreiraandClaude Opus 5.5 600fd5f04a Polytone: run custom particles and block and entity particle emitters
Resource packs' custom particle types now run in the particle engine: the
initializer sets the particle up, the ticker moves, recolours and removes it,
its emitters spawn more, emitter values seed the particles they spawn, and
`limit` caps how many live at once. Block modifiers' emitters run from the
block animate tick, the way torches spawn flames; entity modifiers' emitters
run on the player each client tick (fog, dust and weather around them).
Expressions see the particle, the blocks and biome around it, the player,
the camera, the time and weather.

Model and GPU particles aren't drawn yet (model ones still tick and emit);
additive blending and rotation modes fall back to the plain translucent
billboard; entity emitters ignore bones.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:33:09 -03:00
Vinícius MoreiraandClaude Opus 5.5 2145f26929 Polytone: read custom particles and particle emitters
Reads what a pack's particles do (wiki "Custom Particle Types", "Block
Properties Modifiers", "Entity Modifiers"): a custom particle type's kind
(custom, semi custom copying a vanilla one, GPU), render type, liquid
affinity, physics and despawn flags, limit, tick interval, exclusion
radius, light level and rotation mode; its initializer and ticker
expressions with their named variables; and the particle emitters that
particles, blocks and entity bones carry (the particle by id or with its
options, chance, count, position, motion, colour, size and customs, the
state predicate, biomes, spawn location, bone, max distance). Every
expression is compiled when the pack loads, so a typo is a load error.
Nothing spawns them yet.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:33:09 -03:00
Vinícius MoreiraandClaude Opus 5.5 36e962a58c Polytone: colormap values in attribute layers
An attribute value or argument can name a Polytone colormap (wiki
"Colormaps"): an image read at the column and row two expressions pick,
each 0 to 1 with 1 the top-left corner, rounded to the nearest pixel by
default, the row scaled by the column when triangular. Without a .json
the axes are the biome's temperature and downfall, which the frame now
passes along. The colour is the modifier's argument whenever the layer
applies; a transparent pixel falls back to the value before the pack (the
entry the modifier replaced), as fallback_colormap's default "original".

Colormaps load once per pack reload, shared by the three dimensions'
stacks, and only those a modifier names, decoded to RGBA ints as on
Java. The biome_id axis isn't supported yet.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:33:09 -03:00
Vinícius MoreiraandClaude Opus 5.5 3ce27e636b Polytone: an expression value out of range is clamped, not dropped
A number an expression gives outside its attribute's range goes through the range as the sampled
value does (AttributeRange.sanitize) instead of failing validation and leaving the value as it
was. A pack whose fog end goes below zero deep underground (14 * view distance - 128 under the
surface) now gets its thickest fog there, as on the real mod, where the cave was left with no fog.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:33:09 -03:00
Ludovic Marie db2b5ff76b Merge pull request #12479 from NikitaMGrimm/hdr-resolve-gone
🤖 Agent: HDR output now takes its gain from Hdr::draw_params instead of the removed mark-resolve lane; the change stays behind HDR, which is off by default, and frame_identity's test covers the no-pack path.
2026-11-08 13:29:59 +01:00
Florian ErnstandClaude Opus 5.5 06fe2cc687 An iron golem reads the reputation of the player it selects
DefendVillageTargetGoal asks the villagers in the golem's box for the
reputation of the player (Villager.getPlayerReputation: the gossips
about that player's UUID). Horizon read one reputation per villager,
keyed by the level's own player, while each golem's goal looks at the
player it selects, often a nearby guest: on a server, a hated guest was
never attacked, and a hated host could turn the golem on a guest it
did not hate. The goal now reads the villager's gossips about the
selected player's UUID.

Fixes #12487

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 13:27:39 +01:00
Ludovic Marie a9033e8c41 Merge pull request #12483 from RINNECODER/up4/upgrade-biome-effects
🤖 Agent: 1.21.1 biome effects move to 26.3's visual/audio attributes (colours as #rrggbb), carvers become the air list, and liquid carvers are reported as lossy.
2026-11-08 13:26:43 +01:00
Ludovic Marie c3a1e1293f Merge pull request #12478 from glitchsnake/fix/command-components-expected-equal
🤖 Agent: A bare component in an item argument ([custom_data]) now fails with expected '=' as ItemParser's reader.expect does, instead of being ignored; !removals are unchanged.
2026-11-08 13:26:40 +01:00
Ludovic Marie 1e3e77270d Merge pull request #12470 from oloion/perf/client-culling-and-chunk-streaming
🤖 Agent: Frustum select picks the same corner as the branches did (-0.0 >= 0 both ways) and the resident bounds are origin()'s arithmetic inline. I pushed a fix: upload order measured the camera section as floor(y/16) while keys count from the world's bottom, four sections off in the overworld.
2026-11-08 13:26:36 +01:00
Ludovic Marie 138616afdb Merge pull request #12475 from vnsmoreira/packs/polytone-expression-values
🤖 Agent: Pack expressions are compiled at load and evaluated against the frame only when a pack's environment stack is loaded (pack.environments), so the vanilla path sets no frame and keeps folding constant layers.
2026-11-08 13:23:43 +01:00
Florian ErnstandClaude Opus 5.5 1863a04353 Measure a golem's defence against the player it selects (test checkpoint)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 13:22:56 +01:00
Shreyas 8634b05990 save_roundtrip: normalize relative dat paths to POSIX slashes on Windows (#12287) 2026-11-08 17:51:06 +05:30
Ludovic Marie bf928658ef Merge pull request #12474 from horizon-rust/cg72/loot-mine-named-only
🤖 Agent: Tooling only: loot_mine_location_block asserts its .local/h079/capture is new, so it fails at startup on the Mac runner after one run (#12405); it joins the other capture harnesses in named_only.
2026-11-08 13:20:28 +01:00
Ludovic Marie 8c58505b3c Merge pull request #12456 from martipops/ui/hud-room
🤖 Agent: The room is rebuilt each frame from the boss bars (BossHealthOverlay: y 12, step 19); with 0-1 bar the notice stays at y 18, and HudBatch::new there allocates nothing. I merged main (client_lib re-export list: hud_kit beside main's social).
2026-11-08 13:18:14 +01:00
Ludovic Marie d3151e0cc2 Merge pull request #12418 from RINNECODER/up4/port-item-place-block
🤖 Agent: A block item whose block has another name (seeds) is carried with place_block; one whose block is left out stays in items_unknown. I merged main (both branches added a test at the same spot; both kept).
2026-11-08 13:18:10 +01:00
Vinícius MoreiraandClaude Opus 5.5 2017a3b977 Polytone: read custom particles and particle emitters
Reads what a pack's particles do (wiki "Custom Particle Types", "Block
Properties Modifiers", "Entity Modifiers"): a custom particle type's kind
(custom, semi custom copying a vanilla one, GPU), render type, liquid
affinity, physics and despawn flags, limit, tick interval, exclusion
radius, light level and rotation mode; its initializer and ticker
expressions with their named variables; and the particle emitters that
particles, blocks and entity bones carry (the particle by id or with its
options, chance, count, position, motion, colour, size and customs, the
state predicate, biomes, spawn location, bone, max distance). Every
expression is compiled when the pack loads, so a typo is a load error.
Nothing spawns them yet.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:16:21 -03:00
Vinícius MoreiraandClaude Opus 5.5 a3b56d6218 Polytone: colormap values in attribute layers
An attribute value or argument can name a Polytone colormap (wiki
"Colormaps"): an image read at the column and row two expressions pick,
each 0 to 1 with 1 the top-left corner, rounded to the nearest pixel by
default, the row scaled by the column when triangular. Without a .json
the axes are the biome's temperature and downfall, which the frame now
passes along. The colour is the modifier's argument whenever the layer
applies; a transparent pixel falls back to the value before the pack (the
entry the modifier replaced), as fallback_colormap's default "original".

Colormaps load once per pack reload, shared by the three dimensions'
stacks, and only those a modifier names, decoded to RGBA ints as on
Java. The biome_id axis isn't supported yet.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:16:21 -03:00
Vinícius MoreiraandClaude Opus 5.5 30aee13f1d Polytone: an expression value out of range is clamped, not dropped
A number an expression gives outside its attribute's range goes through the range as the sampled
value does (AttributeRange.sanitize) instead of failing validation and leaving the value as it
was. A pack whose fog end goes below zero deep underground (14 * view distance - 128 under the
surface) now gets its thickest fog there, as on the real mod, where the cave was left with no fog.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:16:20 -03:00
sluisr fec26a0044 perf: reuse server States tracking pool and reduce meshing/lighting allocations
- Reuse the pooled EntityState entries in States (`out.add`) across all 21
  object and projectile loops in `lan_entities.rs`, and push vehicle, armor
  stand pose, and arrow metadata directly into `e.meta`.
- Look up vehicle driver mobs via `self.mob_index` in `lan_riding` instead
  of a linear scan over `self.mobs`.
- Compare `play.equipped` by reference before cloning 5 `ItemStack`s on
  every `enter_guest` turn, and reuse `play.craft_grid` via `std::mem::swap`.
- Eliminate per-fluid-cell `Vec::new()` allocations in `mesher/fluid.rs` and
  deduplicate animated fluid layers directly into `out.sprite_layers`.
- Reuse `SectionMesh::packed` capacity and a thread-local scratch buffer in
  `mesher/packed.rs` during `sort_solid`.
- Pack uniform/single-channel lighting from a stack buffer in `chunk.rs`
  (`Light::from_slice`) instead of allocating and dropping a 4 KiB `Box`.
- Check `!self.saves_beside_final` and neighbor readiness before cloning
  `Chunk` in `Streaming::update`.
2026-11-08 13:15:43 +01:00
LokiandAntigravity 9fd2c8c339 items: require '=' for non-removal command components
Java 26.3 `ItemParser.State.readComponents` expects '=' after a component
type unless it begins with '!'. Return an error for bare components rather
than silently ignoring them.

Co-Authored-By: Antigravity <[email protected]>
2026-11-08 21:08:01 +09:00
Ludovic Marie 3f58a9511b Merge pull request #12461 from MSedgeMC/port_map/creative-screen
🤖 Agent: draw_creative, click_creative and creative_tooltip_tabs moved to game/creative_screen.rs on main; the rows follow them.
2026-11-08 13:06:07 +01:00
Ludovic Marie 2d087e4826 Merge pull request #12460 from MSedgeMC/port_map/shear-saddle
🤖 Agent: Game::shear_saddle exists on main and takes a saddle off any saddleable mob, so attemptToShearEquipment is a port row now.
2026-11-08 13:06:03 +01:00
Horizon agentandClaude Opus 5.5 d426f98ae2 parity: run loot_mine_location_block by name only
It writes .local/h079/capture and asserts the capture is new, so every automatic
run on a checkout that ran it once fails at startup (the Mac mini runner).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 13:04:57 +01:00
RINNECODERandClaude Opus 5.5 48f02115ed Port pack: 1.21.1 biomes upgrade their effects to 26.3 attributes and their carvers to a list
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:02:45 -06:00
RINNECODERandClaude Opus 5.5 06b5147e56 Port pack: surface rules drop the biomes nothing defines, as 1.21.1 never matched them
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:02:32 -06:00
Ludovic Marie 9fc6abb08b Merge pull request #12468 from kacpherek/fix/server-sword-blocking
🤖 Agent: A consumable or blocks_attacks the server's patch adds (components 24 and 37) now starts a use like the item's own (getUseDuration reads the stack); items with their own consumable are unchanged.
2026-11-08 13:01:32 +01:00
Horizon agentandClaude Opus 5.5 1a9663f21a uploads: measure the camera's section from the world's bottom
Pending upload keys count sections from min_y, so floor(y / 16) put the camera
four sections low in the overworld.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 12:58:30 +01:00
Ludovic Marie eaca6fe37a Merge pull request #12467 from masa-masa-0314/fix/realms-terms
🤖 Agent: Realms answers 6002 for a new account: RealmsTermsScreen shows (Agree posts /mco/tos/agreed, then the join resumes; Disagree goes back), with vanilla aka.ms/MinecraftRealmsTerms and mco.terms.* keys.
2026-11-08 12:53:12 +01:00
Vinícius MoreiraandClaude Opus 5.5 c52446638a Polytone: expression values in attribute layers
A pack's attribute value or argument can be a scripting expression
(wiki "Environment Attributes"): fog that closes in with the rain and
with depth, a cloud height scaled from the value the layers before gave.
Each one is compiled when the pack loads and evaluated whenever its layer
applies, against what the frame sets: g (rain, time, day time, sky type,
dimension, render distance, moon phase), p (position, in water), c
(position, view distance in blocks), o (the camera's position, sky and
block light), r (random), v (the value so far, colours packed ARGB) and
the pack's config(id). Its result is the modifier's argument; one that
fails leaves the value as it was. A dynamic entry is never folded into
the base value, since it changes every frame.

Expressions are compiled with Arc instead of Rc so a pack's stacks can be
built on the loading worker.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 08:51:58 -03:00
Ludovic Marie e8acedb5c2 Merge pull request #12401 from Web-mc1/studio-screen-bridge
🤖 Agent: Screen::Studio is opened only by `studio screen open` and draws nothing itself (no chat behind it); Escape closes it. I pushed the rustfmt fix verify failed on.
2026-11-08 12:50:37 +01:00
Horizon agentandClaude Opus 5.5 a0d1a9f0e3 Merge origin/main into up4/port-item-place-block
Both branches added a test before the Windows-separator one: both kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 12:48:19 +01:00
Ludovic Marie 4b2cba530a Merge pull request #12451 from apeirs/fix/fxc-entity-written-color
🤖 Agent: FXC (DX12) failed on discards one call below the entry point; fs_entity now computes entity_color itself and hands it on, same colour on every backend.
2026-11-08 12:48:16 +01:00
Ludovic Marie 4b99e9a701 Merge pull request #12441 from RINNECODER/up3/far-tile-walk
🤖 Agent: Boxing the far tile meshes shrinks Tile for the per-frame walk; release paths unbox each mesh once, nothing double-released.
2026-11-08 12:48:12 +01:00
Horizon agentandClaude Opus 5.5 4497f18b31 Merge origin/main into ui/hud-room
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 12:47:26 +01:00
Ludovic Marie e761e6394a Merge pull request #12463 from MSedgeMC/port_map/edge-walk
🤖 Agent: VoxelShape::edges exists in horizon-core's shape.rs, so forAllEdges is a port now rather than skip:data.
2026-11-08 12:45:18 +01:00
Ludovic Marie bced9e4ecd Merge pull request #12462 from MSedgeMC/port_map/watcher-home
🤖 Agent: PackSelectionScreen.Watcher spans datapack.rs::folder_stamp and options_ui.rs's watch, so a home row fits better than a single port target.
2026-11-08 12:43:01 +01:00
Ludovic Marie 4dd22ecd6a Merge pull request #12459 from MSedgeMC/port_map/infested-silverfish
🤖 Agent: spawn_infested, player_infested and mobs.rs::infested_silverfish all exist on main; the rows now name where the roll and the spawn happen.
2026-11-08 12:38:53 +01:00
Ludovic Marie ba041dc3bb Merge pull request #12439 from RINNECODER/up3/pack-halflives
🤖 Agent: Pack half-lives replace OptiFine's defaults in the same units (600/200/10/1). I pushed a scripted-clock version of its test: backdating u.last was the wall-clock flake #12354 removed.
2026-11-08 12:34:49 +01:00
Ludovic Marie 706aad56c0 Merge pull request #12455 from Evan-lhm/fix/release-sums-windows-test
🤖 Agent: Git Bash's sha256sum writes `*name` (binary mode); the test strips the star, nothing else changes.
2026-11-08 12:29:15 +01:00
Ludovic Marie 564f031294 Merge pull request #12445 from RINNECODER/up3/lod-dispatch-incremental
🤖 Agent: Mesh jobs' samples are kept per 8x8 shard and synced at every active/ready change; debug builds assert the copy matches active ∩ ready.
2026-11-08 12:29:12 +01:00
Ludovic Marie f18c761edc Merge pull request #12443 from RINNECODER/up3/mod-content-copy
🤖 Agent: Plain files are copied with the same size and path checks read() made; tags, atlases, declarations, biome modifiers, worldgen and structures are still read and parsed.
2026-11-08 12:29:08 +01:00
Ludovic Marie c2661a333d Merge pull request #12410 from masa-masa-0314/feat/friends-service
🤖 Agent: The friends worker never holds the lock across HTTP (reads the etag, unlocks, fetches, relocks), and nothing starts unless the account's FRIENDS_ENABLED flag is set.
2026-11-08 12:29:05 +01:00
Ludovic Marie c09321478d Merge pull request #12408 from m-uvex/pluto/add-flake
🤖 Agent: The flake builds the launcher from the repo itself, so it follows main, unlike #11200's pinned tarball; both outputs evaluate on NixOS (horizon-launcher-0.2.0.drv, nix-shell.drv); CI does not build it.
2026-11-08 12:29:01 +01:00
Horizon agentandClaude Opus 5.5 519d9b6d97 persist: ignore the second summon UUID test without prepared resources
It unwraps HORIZON_TEST_RESOURCES like its sibling, which is already #[ignore]d.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 12:27:29 +01:00
TheMrZZandCodex gpt-6.1-sol fe3ebc3b8d Tick lodestone compasses equipped by armor stands
Reuse the existing loaded-target predicate for actual stand equipment inside
the entity-ticking guard. Preserve player behavior and bounded tracker rules.

Fixes #12395

Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-08 12:26:24 +01:00
MSedgeMC 98e37bbb84 port_map: the edge-walk rows name VoxelShape::edges
forAllEdges and forAllAxisEdges were skipped as data, but the walk is in
crates/horizon-core/src/geometry/shape.rs: VoxelShape::edges is documented
as forAllEdges, and its inner axis scan is forAllAxisEdges.
2026-11-08 11:24:22 +00:00
Kacper 7965bc432e Merge pull request #12447 from RINNECODER/up3/mount-tick-order
Riding: the driven mount ticks before its rider, on the input the rider's last tick applied
2026-11-08 12:24:13 +01:00
Kacper 50f53a5a2b Merge pull request #12437 from RINNECODER/up3/mount-air-speed
Mounts: a player-steered mount moves through the air at a tenth of its speed (LivingEntity.getFlyingSpeed)
2026-11-08 12:24:06 +01:00
Kacper 113ac28e79 Merge pull request #12426 from RINNECODER/up4/port-food
Port pack: food items carry over, as 26.3's food, consumable and use_remainder
2026-11-08 12:23:59 +01:00
Kacper 509deae34e Merge pull request #12424 from RINNECODER/up4/upgrade-weird-scaled-sampler
upgrade-datapack: weird_scaled_sampler becomes 26.3's interval_select of scaled noises
2026-11-08 12:23:52 +01:00
Kacper 156f335169 Merge pull request #12422 from RINNECODER/up4/upgrade-nether-vegetation
upgrade-datapack: nether_forest_vegetation becomes 26.3's spread simple_block
2026-11-08 12:23:45 +01:00
Kacper f4cbc6311e Merge pull request #12416 from RINNECODER/up4/port-farmland-template
Port pack: carried models on 1.21.1's farmland template use 26.3's indented cube
2026-11-08 12:23:38 +01:00
MSedgeMC 7a4012d00f port_map: PackSelectionScreen.Watcher is a home row
The class row was written with a `port` verdict and the function that
represents it. Class rows take `home` with the files that represent the
class; list datapack.rs (folder_stamp) and options_ui.rs (watch_data_packs).
2026-11-08 11:23:32 +00:00
Kacper dca8dbddd1 Merge pull request #12414 from RINNECODER/up4/port-recipe-conditions
Port pack: recipes with NeoForge conditions are upgraded when NeoForge loaded them
2026-11-08 12:23:31 +01:00
Kacper 6410d3f446 Merge pull request #12412 from RINNECODER/up4/port-tag-namespaces
Port pack: tags alone claim no namespace
2026-11-08 12:23:24 +01:00
Kacper 059eb482c4 Merge pull request #12400 from Solenopsisbot/perf/obstacle-grid-scratch
perf: reuse obstacle grid query scratch
2026-11-08 12:23:13 +01:00
MSedgeMC 3835921949 port_map: the creative screen rows name game/creative_screen.rs
The creative inventory screen moved out of game.rs into its own module.
draw_creative, creative_tooltip_tabs and click_creative are unchanged; only
the module path in the six rows that name them was left behind.
2026-11-08 11:23:10 +00:00
Kacper f8be508301 Merge pull request #12397 from Solenopsisbot/perf/creature-path-writes
perf: move creature path writes without copying
2026-11-08 12:23:06 +01:00
Kacper 8b06e4ba1e Merge pull request #12386 from TheMrZZ/fix/stand-command-hurt
/damage breaks, lights or burns an armor stand as its hurt does
2026-11-08 12:22:59 +01:00
Kacper 197a6ef7dc Merge pull request #12381 from svetch/discovery-texture-uris
parity: take valid texture URIs from the services discovery document
2026-11-08 12:22:52 +01:00
Kacper ba54ecff05 Merge pull request #12375 from TheMrZZ/fix/test-run-cross-dimension-coordinate-feedback
fix: send completed test coordinate feedback to its command source
2026-11-08 12:22:45 +01:00
MSedgeMC 44a27421ca port_map: the equipment shearing rows name shear_saddle
`Game::shear_pig_saddle` was renamed and generalized to `Game::shear_saddle`
when shears began taking the saddle off any saddleable mob. Its doc names
`Mob.attemptToShearEquipment` and `Mob.shearItem`; re-point the two rows.
2026-11-08 11:22:40 +00:00
Kacper eb8f8e38b5 Merge pull request #12374 from TheMrZZ/fix/h064-vibration-source-uuid
Save the source and projectile owner UUIDs of a vibration
2026-11-08 12:22:38 +01:00
Kacper d276c60075 Merge pull request #12371 from glitchsnake/fix/11382-vehicle-entity-random
game: use entity random for boat, minecart and item frame operations (fixes #11382)
2026-11-08 12:22:31 +01:00
Kacper ee91d5907a Merge pull request #12366 from vnsmoreira/packs/polytone-environment
Polytone: biome and dimension modifiers as attribute layers
2026-11-08 12:22:24 +01:00
Kacper 1cec3b3751 Merge pull request #12365 from vnsmoreira/packs/polytone-overlays
Polytone: pack configs and conditional overlays
2026-11-08 12:22:17 +01:00
MSedgeMC 04ead01cb4 port_map: the infested hurt rows name spawn_infested and player_infested
`Game::infested_hurt` was split. `Game::spawn_infested` spawns a silverfish
per drawn velocity at half the bearer's height with the hurt sound, and
`Game::player_infested` is the player's roll and spawn. Re-point the two
rows that still name the old function.
2026-11-08 11:22:13 +00:00
Kacper 447341b6a4 Merge pull request #12364 from vnsmoreira/attributes/integration
Environment: sample the sky through the vanilla attribute stack
2026-11-08 12:22:10 +01:00
Kacper 2bb7df1bf9 Merge pull request #12352 from k3yh/potion-contents-names
A potion or tipped arrow is named by its contents
2026-11-08 12:22:02 +01:00
Kacper 13c56dd065 Merge pull request #12345 from Vaspyyy/title-icon-tooltips
Show the title screen icon buttons' tooltips while hovered like vanilla
2026-11-08 12:21:55 +01:00
Kacper cceab3b2b5 Merge pull request #12344 from Vaspyyy/shulker-bullet-parity
Fire shulker bullets from the box centre and turn them at standable blocks
2026-11-08 12:21:48 +01:00
Kacper 6e00e1bbf1 Merge pull request #12341 from Vaspyyy/vehicle-container-scatter
A destroyed chest boat or container minecart scatters its contents like vanilla
2026-11-08 12:21:40 +01:00
Kacper fc14c6fc28 Merge pull request #12336 from k3yh/loot-give-full-inventory
/loot give to a full inventory throws nothing out
2026-11-08 12:21:33 +01:00
Kacper d03fbd593a Merge pull request #12260 from Akirabane/fix/9335-passengers
Riders turn like vanilla's: vehicle body only where vanilla copies it
2026-11-08 12:21:26 +01:00
Kacper 0335218910 Merge pull request #11682 from TheMrZZ/fix/loot-mine-location-block-state
Evaluate loaded block-state offsets in loot-mine location checks
2026-11-08 12:21:19 +01:00
Kacper 3b76fcb951 Merge pull request #11642 from TheMrZZ/fix/inline-armor-trim-holders
Preserve fully inline armor-trim holders in item stacks
2026-11-08 12:21:11 +01:00
masa-masa-0314andZCode a7f89f1c62 Realms: the terms screen before a new account's first join
A new account's first join gets error 6002; GetServerDetailsTask shows
RealmsTermsScreen instead of the generic error. Port it:

- The title, the first sentence and the underlined terms link at
  row(5), with the hover colours and the link's measured hit box
  (extractRenderState's onLink). A click opens
  CommonLinks.REALMS_TERMS (https://aka.ms/MinecraftRealmsTerms).
- Agree (width/4) and Disagree (width/2 + 4), each width/4 - 2 wide at
  row(12). Agree posts mco/tos/agreed (RealmsClient.agreeToTos) on a
  worker, then runs GetServerDetailsTask again from the same screen;
  a failure logs and stays. Disagree and Escape return to the screen
  that started the join (GetServerDetailsTask.lastScreen, now carried
  by Connecting).

Co-Authored-By: ZCode <[email protected]>
2026-11-08 19:21:06 +08:00
Kacper 73b2d7434f Merge pull request #11588 from TheMrZZ/fix/named-predicate-context
Resolve named predicate references through the Game context
2026-11-08 12:21:04 +01:00
Kacper e19018da1c Merge pull request #11564 from TheMrZZ/fix/h157-player-save-projection
fix: project live player motion fields into saved data
2026-11-08 12:20:57 +01:00
Kacper 5a94e4c188 Merge pull request #11488 from TheMrZZ/fix/h181-noai-trader-llama-delay
Advance eligible TraderLlama despawn delay with NoAI
2026-11-08 12:20:51 +01:00
Kacper 6db9351111 Merge pull request #11301 from TheMrZZ/fix/h052-vehicle-container-save
Respect class-owned container fields in vehicle saves
2026-11-08 12:20:43 +01:00
Horizon agentandClaude Opus 5.5 7d2f225c85 pack uniforms: drive the half-life test with a scripted clock
Backdating u.last measured the gap with the wall clock; a few ms of runner delay
moved wetness past the 1e-3 tolerance (the flake #12354 fixed in the Iris test).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 12:12:58 +01:00
Horizon agentandClaude Opus 5.5 f15f153836 remote chunks: drop block-entity attachments after the column's block entities load
Moving the retain before the block entities loaded dropped every attachment of a
resent column, and skipping it for new columns kept those of forgotten ones.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 12:12:19 +01:00
JoansitohandClaude Sonnet 5.5 c9f62a1572 Trident: a stuck trident falls when its block is destroyed
AbstractArrow.tick: if lastState != blockState && shouldFall() startFalling().

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-08 12:11:48 +01:00
LokiandAntigravity 067a6a1db1 game: skip in-tree duplicate UUIDs in summoned passenger trees (fixes #11807)
Co-Authored-By: Antigravity <[email protected]>
2026-11-08 20:11:37 +09:00
Horizon agentandClaude Opus 5.5 7ba6ef0912 studio screen: rustfmt the control replies
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 12:11:35 +01:00
Kacpherek 34c91f0c34 Hold a server-patched consumable or blocks_attacks use on a server
A server that adds blocks_attacks and a long consumable to a sword (1.8
style sword blocking, #11817) sends both components in the stack patch,
which the client reads past. The client never started the use itself and
remote_tick_using dropped the use the server's living flags started on
the next tick, so the right click kept restarting the use and the input
slowdown flickered (GrimAC NoSlow).

Read the added components from the wire patch, as Item.use does from the
stack's components: Consumable.startConsuming / startUsingItem start the
use, Item.getUseDuration takes the consumable's consumeTicks (else 72000
for blocks_attacks), and the use is held until the button lets go or the
server stops it, as LivingEntity.updateUsingItem never completes a use on
the client (LocalPlayer.onSyncedDataUpdated keeps it running).
2026-11-08 12:10:32 +01:00
Evan-lhmandClaude Opus 5.5 0f36e33ccf Tests: read SHA256SUMS names with Git Bash's binary-mode * (#12454)
On Windows, Git Bash's sha256sum writes `<digest> *<name>`, so the
optional release assets test kept the `*` in every name and failed for
all four masks. Both forms are valid sha256sum output; accept them.

Fixes #12454

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 11:59:54 +01:00
apeirs 94e2918668 DX12: keep entity_color's discards one call below fs_entity, so FXC compiles it
Since #12282, fs_entity called entity_written_color, which called entity_color.
FXC (every DX12 game: Horizon ships no dxcompiler.dll) fails on that with
"internal error: argument pulled into unrelated predicate" while creating the
first entity pipeline, and the game crashes at start. entity_written_color now
takes entity_color's result instead of calling it.
2026-11-08 11:46:09 +01:00
m_uvexandPluto ecc9a21e18 packaging: build Horizon launcher from source in flake
Addresses review feedback from #11200:
- Builds horizon-launcher from repository source via rustPlatform.buildRustPackage
  instead of fetching a pinned binary tarball by hash.
- Native build support for both x86_64-linux and aarch64-linux.
- Added essential POSIX tools to devShells.default for pr_ready test suite.

Co-Authored-By: Pluto <[email protected]>
2026-11-08 13:41:26 +03:00
TaquitoSuabe 00127a51c7 remote_chunks: decode chunk packets concurrently with strict in-order retirement
- Parallelize chunk decompression across a bounded worker pool while enforcing sequential retirement (FIFO arrival order) via monotonic sequence ordering.
- Filter resident neighbors and batch section dirtying with column masks.
- Skip attachment and block entity cleanup scans for fresh (non-resident) chunks.
- Enable TCP_QUICKACK on Linux streams and reset empty reader buffers to prevent drift.
- Elevate network worker thread QoS on supported platforms.
2026-11-08 03:40:59 -07:00
Ludovic Marie 92fd45976d Merge pull request #12393 from Solenopsisbot/perf/worldgen-decoration-biomes
🤖 Agent: Same fixed [u64; 128] bitset with spill as the generator's (#12346): spilled words keep index 128 + offset, so the decorated chunk's biomes stay ascending, and the exact reserve avoids regrowth.
2026-11-08 11:39:18 +01:00
SolenopsisbotandCodex 3bf71f9926 perf: reuse obstacle grid query scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 21:33:40 +11:00
Web-mc1 df92a7cbc5 Open and close Screen::Studio from horizon via studio screen, with test 2026-11-08 23:29:06 +13:00
Web-mc1 b7215560ba Add Screen::Studio so Studio windows don't borrow the chat slot 2026-11-08 23:28:48 +13:00
Ludovic Marie 79bd301973 Merge pull request #12388 from kacpherek/fix/remote-push-tick-order
🤖 Agent: ClientLevel.tickEntities ticks in add order: after login (and after a respawn re-adds the player last) a mob added later pushes from where both ended the tick, so the push reaches the player's next move, which is what GrimAC's Simulation check expects.
2026-11-08 11:27:31 +01:00
SolenopsisbotandCodex ec73a1af84 perf: move creature path writes without copying
Co-Authored-By: Codex <[email protected]>
2026-11-08 21:24:37 +11:00
Horizon agentandClaude Opus 5.5 bbbbfa6dd2 Parity: unused_feature_startup runs by name only
It needs --kind, --output and --binary, which an automatic parity run
doesn't pass (#12372).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 11:23:29 +01:00
Ludovic Marie 33facd006a Merge pull request #12361 from adiraj66132/security/audit-hardening
🤖 Agent: client_mod_command is the chat-side mod hook; the SMP and other server mods use native_perform_command, so gating guests (lan_acting) out of it removes a level-0 path without touching server commands. The 4 GiB zip budget is per opened archive, and every Zip lives for one load.
2026-11-08 11:22:13 +01:00
Ludovic Marie 0ad6f93762 Merge pull request #12280 from NikitaMGrimm/portal-ticket-persistence
🤖 Agent: PORTAL tickets are saved in chunk_tickets.dat with level and ticks left, reload on restart (prepareLevels), and do not expire while their chunk is still loading (canTicketExpire). I fixed the main merge: #12232's ticket fast path compared (chunk, level) pairs with this PR's PortalTicket (LAND-STOP: E0308); it compares (ticket.chunk, ticket.level) now.
2026-11-08 11:22:09 +01:00
SolenopsisbotandCodex 1467568676 perf: reuse decorated biome discovery scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 21:18:11 +11:00
masa-masa-0314andZCode da428abd4d Friends: use ? for the presence request's missing session and endpoint
Co-Authored-By: ZCode <[email protected]>
2026-11-08 18:15:47 +08:00
Ludovic Marie 02deae8774 Merge pull request #12377 from Solenopsisbot/perf/station-defaults-reuse
🤖 Agent: Smithing results and banner defaults now share the shared() snapshot StationData loads once; the standalone loaders keep reading their own.
2026-11-08 11:14:56 +01:00
Ludovic Marie 90267f9863 Merge pull request #12359 from Solenopsisbot/perf/items-enchant-defaults
🤖 Agent: item_defaults::shared is the cached item_defaults::read, so the enchantment properties read the same snapshot Items already decoded; the standalone loader still reads its own.
2026-11-08 11:12:04 +01:00
martipopsandClaude Opus 5.5 88dd9e8d1e Document the HUD kit's Room and Plate
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:09:02 -05:00
martipopsandClaude Opus 5.5 8ce5ba0e52 Keep the controller notice and the splitscreen join strip off the boss bars (#12342)
Game::hud_room gathers the boss bars the HUD shows each frame; hud empties the room every
frame first. The notice and the join strip go below the bars when they would cover them,
and stay at y 18 otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:09:02 -05:00
martipopsandClaude Opus 5.5 9fb2965c3a HUD kit: Room keeps Horizon's overlays below the boss bars, and Plate
hud_kit::room holds a view's keep-outs, today the boss bars, and tells a centred overlay
where it goes: where it wanted unless the bars reach past it. boss_bars_bottom follows
BossHealthOverlay's layout. hud_kit::plate draws the notice's box.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:09:01 -05:00
Kacpherek 5c616363b1 Push the local player by mobs in ClientLevel's tick order
Vanilla's ClientLevel ticks entities in the order they were added: after
login the player comes first, so a mob added later pushes it from where
both ended the tick, and the push reaches the player's next move. After a
respawn the new player is added after what the level holds, so those
entities tick before it. Horizon applied every mob's push before the
player's move, from where the mobs had just moved: walking into a mob
the server is pushing away tripped anticheats (GrimAC Simulation 0.02-0.04
on every push).
2026-11-08 11:01:33 +01:00
SolenopsisbotandCodex 58140be02b fix: satisfy station defaults lint
Co-Authored-By: Codex <[email protected]>
2026-11-08 21:00:32 +11:00
SolenopsisbotandCodex 4fab87e3ce perf: reuse station item defaults
Co-Authored-By: Codex <[email protected]>
2026-11-08 21:00:32 +11:00
Ludovic Marie d61235cb39 Merge pull request #12370 from Solenopsisbot/perf/stream-decoration-scratch
🤖 Agent: The 9-key array and Box<[Proto; 9]> build the same region in the same order; the removed try_into fallback could never fail (always 9 keys).
2026-11-08 10:59:28 +01:00
Ludovic Marie 38d670c0ac Merge pull request #12379 from Solenopsisbot/perf/block-tick-scratch
🤖 Agent: The spawner and trial-spawner lists keep their tick order and are taken around the client effects, so a client tick can't see a half-filled list.
2026-11-08 10:59:24 +01:00
Horizon agentandClaude Opus 5.5 e5cad94537 Zip budget test: pass the budget by shared reference
clippy (-D warnings): read_within takes &AtomicU64, so &mut was needless.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:56:41 +01:00
Ludovic Marie 1c17df10b4 Merge pull request #12367 from Solenopsisbot/perf/remote-tick-scratch
🤖 Agent: Indexing the retained buffers by mob index is safe: nothing between the fluid loop and the rain loop adds or removes remote mobs, and an early return only loses the warm capacity.
2026-11-08 10:55:57 +01:00
Ludovic Marie d1b5000930 Merge pull request #12360 from Solenopsisbot/perf/outline-scratch
🤖 Agent: The outline strokes keep their order (black then bright) and the custom PvP colour; both scratch vectors are bounded by MAX_OUTLINE_EDGES, so the retained capacity stays small.
2026-11-08 10:55:53 +01:00
Florian ErnstandClaude Opus 5.5 83d9347f4b Merge origin/main into fix/h259-unused-feature-startup
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:55:15 +01:00
SolenopsisbotandCodex 0dab8b30f5 perf: reuse item defaults for enchantments
Co-Authored-By: Codex <[email protected]>
2026-11-08 20:53:56 +11:00
masa-masa-0314andZCode 5740311a36 Friends: the service's empty answer reads as three empty lists
The live getFriends answer an account with no friends gets is
{"empty":true,"friends":[],"incomingRequests":[],"outgoingRequests":[]};
the parser reads the three lists and ignores the flag. Recorded as a
regression case beside the populated answer.

Co-Authored-By: ZCode <[email protected]>
2026-11-08 17:53:30 +08:00
Florian ErnstandClaude Opus 5.5 17f3a0ff81 /damage breaks, lights or burns an armor stand as its hurt does
ArmorStand.hurtServer returns false for an explosion, fire that ignites
armor stands and burning, after it has acted on the stand: a blast breaks
it (its equipment pops, then it is killed), in_fire lights a stand that
is not burning for 5 seconds, and on_fire burns 4 health off one with
more than 0.5. The command route had no armor stand arm, so /damage left
the stand as it was. It now runs those sources with the stand's guards
and still fails as vanilla's command does.

Part of #12380

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:53:20 +01:00
Horizon agentandClaude Opus 5.5 c0f9600544 Parity: run_coordinate_feedback runs by name only
It needs --binary, --work-dir and --reference-dir, which an automatic
parity run doesn't pass (#12372).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:50:57 +01:00
VaspyyyandClaude Opus 5.5 f1be49b7df Lid pushes follow vanilla's tick order, and boats reach an open lid
- BoxReach (the boats' and carts' mob pre-filter) is worked out from each
  mob's real box, so a shulker whose open lid grows its box sideways or
  below its position is still found: a boat runs into the lid and picks
  the shulker up, as in vanilla.
- ArmorStand::shove makes up for Horizon ticking stands before mobs: a
  stand that joined after its shulker gets vanilla's push-then-travel
  ground and speed, one that joined before gets Entity.move's own.
- /data merge keeps a mob's and a stand's join order (Entity.load changes
  the entity in place).
- A shulker a boat or a minecart picks up turns to AttachFace DOWN
  (Shulker.startRiding).
- The stand's box uses the float height 1.975F, canStayAt the shulker's
  scale.
- The harness adds wall, ceiling and squeezed lids, with the stand joined
  after and before its shulker, and the boat that runs into an open lid.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:47:00 +01:00
VaspyyyandClaude Opus 5.5 a1ecb7f6de An opening shulker lid lifts the armor stand on it
Shulker.onPeekAmountChange moves every entity with physics in the lid's
path with Entity.move(MoverType.SHULKER), armor stands included, and
Shulker.makeBoundingBox grows the shell's box by the lid's physical peek.
Horizon pushed only the player and mobs and sized the box from the
dimensions, so a stand resting on a normal shulker sank into it the first
time the lid opened.

- The lid sends MobEvent::LidPush; ArmorStand::shove moves each stand with
  physics through the collision resolver. Mob::bounds_at gives a shulker
  its makeBoundingBox, scaled and grown by getPhysicalPeek in float.
- Shulker.tick's own part (keep a face, ease the lid) runs without AI
  too, and not for a shell that rides something (isPassenger).
- /data merge keeps a shulker's eased currentPeekAmount: Entity.load reads
  only the raw Peek.
- A stand leaves out the boxes of mobs riding it
  (isPassengerOfSameVehicle), so a stand carrying a /ride shulker rises.
- ObstacleGrid::near tests each box once when the query spans more cells
  than there are boxes, and a stand's loaded Motion drops a component past
  10 (Entity.load), so a huge Motion no longer stalls the server.
- A rider sits on a stand's float passenger point (1.975F widened).
- The harness adds a stand carrying a riding shulker and the lid opening
  and shutting under the first stand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:47:00 +01:00
VaspyyyandClaude Opus 5.5 6880103394 Armor stands land on and stop at shulkers and boats like vanilla
ArmorStand.travel moves with Entity.move, whose Entity.collide adds
EntityGetter.getEntityCollisions: the entities that canBeCollidedWith the
stand (a living shulker, a boat, a happy ghast held still) stop it as
blocks do. Horizon resolved a stand's move against blocks and the world
border only, so a stand dropped onto a shulker sank into it, one dropped
onto a boat fell through to the ground, and one pushed into a shulker
went through it (#11877).

The stand tick now gathers those boxes once, when the first stand
travels (the same set that stops a dropped item, primed TNT or a falling
block), and passes the ones meeting each stand's box stretched by its
movement into the move. It runs in the server's tick, so single player,
LAN hosts and dedicated servers all get it.

The new stand_entity_collision harness drops stands onto a NoAI shulker,
a boat and the stone, slides one into a shulker's side, and compares
their Pos, Motion, OnGround and fall_distance with vanilla's tick by
tick. Without the fix 27 of its 198 records differ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:47:00 +01:00
RINNECODERandClaude Opus 5.5 4d5de18e40 Riding: the driven mount ticks before its rider (ClientLevel.tickNonPassenger) on the input the rider's last tick applied (xxa/zza through modifyInput); it moved a tick ahead of the server's view (GrimAC Simulation on a horse, 27 flags)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:41 -06:00
RINNECODERandClaude Opus 5.5 340d4d8b22 Mounts: LivingEntity.getFlyingSpeed, a player-steered mount moves through the air at a tenth of its speed, not 0.02 (a horse's jump)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:41 -06:00
RINNECODERandClaude Opus 5.5 d3c183549e shader packs: honour wetnessHalflife, drynessHalflife, eyeBrightnessHalflife, centerDepthHalflife
Packs set these const directives (ShaderDoc, OptiFine's shaders.txt);
Horizon always used the defaults (600/200/10/1 ticks). IterationT sets
wetnessHalflife 200 and drynessHalflife 50, so under Horizon its sky
stayed sunny for a minute after rain started (wetness rose 3x too
slowly) and stayed wet 4x too long after it stopped. The pack log now
names the half-lives a pack sets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:41 -06:00
RINNECODERandClaude Opus 5.5 f711009645 Far tiles: an FxHashMap, not SipHash, for the renderer's tiles
draw_frame looks every visible tile up 3-4 times a frame and upload_lods walks them all; with
lodDistance 256 (~8.5k tiles) std's SipHash was 8-10% of the main thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:40 -06:00
RINNECODERandClaude Opus 5.5 9cde3d1f9a Far tiles: keep mesh jobs' samples as tiles change, not gathered per batch
`Lod::dispatch_meshes` collected every active tile's ready samples into a new
map for each batch of mesh jobs (thousands of entries, rehashed as it grew):
5-10% of the main thread in flight. The map is now kept up to date where a
tile turns active or inactive and where its samples change
(`Lod::sync_sample`), in shards of 8 by 8 tiles behind `Arc`s: a batch copies
the shards' handles, and a change copies only its shard while a job still
reads it. Debug builds check it against the full gather on every dispatch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:40 -06:00
RINNECODERandClaude Opus 5.5 c7c143cbf1 Mod content: copy plain files into the overlay instead of reading and rewriting them
Building a mod set's resource root read every content file and wrote it back out; with the
14 Popular Mods (Chipped's 10k textures) that was about two thirds of a 37 s first start
(sample: open/read/write on the main thread). Files the build does not parse are now copied
with fs::copy (a clone on APFS), checked as reading them was (name, 16 MiB limit).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:40 -06:00
RINNECODERandClaude Opus 5.5 cd313d031f Far tiles: box a tile's meshes so the per-frame tile walk stays small
draw_frame tests every far tile against the frustum each frame. A Tile held two SectionGpu
inline (~0.5 KB), so with lodDistance 256 (~8.5k tiles) the walk read ~9 MB a frame and was
the main thread's top cost (17-23% in sample). Boxed, a tile is ~90 bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:40 -06:00
TheMrZZandCodex 9bf65b95b4 Validate unused fill-layer entries before world readiness
Partial H259; retain other registry validation as open scope.

Co-Authored-By: Codex <[email protected]>
2026-11-08 10:46:38 +01:00
RINNECODERandClaude Opus 5.5 4efbd5ea91 Port pack: 1.21.1 weird_scaled_sampler densities upgrade to 26.3's interval_select of scaled noises
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:56 -06:00
RINNECODERandClaude Opus 5.5 09d0f6eb7c Port pack: 1.21.1 nether_forest_vegetation upgrades to 26.3's spread simple_block
As 26.3 wrote crimson and warped forest vegetation: a simple block on nylium,
tried spread_width² times at a trapezoid offset, where there is air. Terralith's
last feature left as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:56 -06:00
RINNECODERandClaude Opus 5.5 ebec6fdd1c Port pack: 1.21.1 random_patch and flower features upgrade to 26.3's counted, offset placement
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:56 -06:00
RINNECODERandClaude Opus 5.5 dabd3c04cc Port pack: an item that places a block of another name (seeds) binds that block
A BlockItem whose block has another name (Farmer's Delight's cabbage seeds
place `cabbages`, Supplementaries' way signs `way_sign_wall`) was left out
as "a block item without a block": 35 items over the 8 mods. It is now
carried with `place_block` naming its block when that block is carried
(vanilla's or one of the mod's declared ones), and left out as "its block
is left out" otherwise. That check looked the item's own name up in the
left-out blocks instead of its block's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:55 -06:00
RINNECODERandClaude Opus 5.5 cec040fef1 Port pack: food items carry over, as 26.3's food, consumable and use_remainder
Food was left out ("no food template yet"): 82 items over the eight mods tried, most of Farmer's
Delight. 1.21.1's minecraft:food held what 26.3 splits into food (numbers), consumable (eating
time, on_consume_effects: one apply_effects per effect with its own chance) and use_remainder
(the bowl), as 26.3's golden apple and mushroom stew have them. NeoForge's cures are dropped, and an
effect of the mod's own is left out and reported (the game would refuse the item).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:55 -06:00
RINNECODERandClaude Opus 5.5 a2d300a03f Port pack: carried models on 1.21.1's farmland template use 26.3's indented cube
26.3 has no `block/template_farmland`: its farmland model is
`template_cube_bottom_top_indented` with `bottom`, `side` and `top`, where
1.21.1's template read `dirt` for the bottom and sides. A carried model on
the old template (Supplementaries' raked gravel) now names the new one with
its dirt as side and bottom, instead of drawing the missing model.

`minecraft:block/rope` (Supplementaries' bunting particle) is in neither
1.21.1 nor 26.3: not a rename, left as is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:55 -06:00
RINNECODERandClaude Opus 5.5 b2e0010655 Port pack: recipes with NeoForge conditions are upgraded when NeoForge loaded them
A vanilla-type recipe with neoforge:conditions was kept as 1.21.1 wrote it, and 26.3 refused its
old ingredients: Quark's 1,466, most of Supplementaries'. The oracle's recipes are the ones whose
conditions passed (a mod's own conditions, such as config flags, are only known there): those
lose the conditions and are upgraded; the others go outside, as NeoForge left them out. Without
the oracle, NeoForge's own conditions are read against the mods ported along.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:55 -06:00
RINNECODERandClaude Opus 5.5 d0815a9d0b Port pack: tags alone claim no namespace (Farmer's Delight and Supplementaries both added to create's tags and clashed)
A mod's tag additions under another mod's namespace (data/create/tags/...) made it claim that namespace
when its own files named it; two such mods in one pack then refused to load together (Popular Mods:
Supplementaries off). Tags alone now stay outside the carry, as other compat files do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:55 -06:00
Florian Ernst 217affdc9e Merge origin/main into fix/h064-vibration-source-uuid
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/game.rs
#	crates/horizon-client/src/game/sculk.rs
2026-11-08 10:44:34 +01:00
Florian ErnstandClaude Opus 5.5 5674b63b57 Measure /damage side effects on armor stands (test checkpoint)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:42:38 +01:00
Florian Ernst 255d45aa56 Merge origin/main into fix/test-run-cross-dimension-coordinate-feedback
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/game/commands/test_runs.rs
#	crates/horizon-client/src/game/game_tests.rs
2026-11-08 10:42:37 +01:00
SolenopsisbotandCodex 5f599617e6 perf: reuse block entity tick scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 20:37:03 +11:00
Ludovic Marie 668555dd33 Merge pull request #12376 from horizon-rust/ci/command-exec-dead-flag
🤖 Agent: Main fix: three lines a union merge brought back read a flag #12242 removed, so every command_exec-driven harness stopped with AttributeError (80 of 173 on #12344's run). Nothing else in the driver uses an undefined args attribute; the corpus builds its 161 groups.
2026-11-08 10:36:50 +01:00
Horizon agentandClaude Opus 5.5 db09adeca9 command_exec harness: drop the seed-sync gaps block a merge brought back
#12242 removed --seed-sync-gaps-diagnostic and the block that read it.
The union merge that landed TheMrZZ's series (#12160) kept the block from
an older base without the flag, so every command_exec run (and every
harness that drives it) stopped at
AttributeError: 'Namespace' object has no attribute 'seed_sync_gaps_diagnostic'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:35:08 +01:00
Román Benjámin e46c586cec parity: take valid texture URIs from the services discovery document 2026-11-08 10:34:11 +01:00
Ludovic Marie 1bc5012f4f Merge pull request #12372 from horizon-rust/ci/named-only-capture-harnesses
🤖 Agent: Tooling only: 17 capture-preserving harnesses that fail at startup under parity.py (no --work-dir / a capture folder that must be new) move to named_only; they still run by name and in the nightly --all audit.
2026-11-08 10:33:02 +01:00
Ludovic Marie 7976203343 Merge pull request #12241 from MSedgeMC/fix/tame-panic-damage
🤖 Agent: A cat or parrot panics from any #panic_causes damage and only a wolf keeps #panic_environmental_causes, as TamableAnimalPanicGoal is built per species; the old fire_ticks gate is gone. I made its test return early without extracted mob data (CI compared None with Some(true)).
2026-11-08 10:27:28 +01:00
TheMrZZandCodex gpt-6.1-sol aaf53aa0bd fix: retain test-run source for completion coordinate feedback
Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-08 10:21:52 +01:00
AkirabaneandClaude Opus 5.5 6ff8c950e4 Merge origin/main into fix/9335-passengers
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:19:33 +01:00
Ludovic Marie f8f7d2574b Merge pull request #12231 from NikitaMGrimm/tnt-size-eye
🤖 Agent: Primed TNT's box is 0.98F and its eye height 0.15F, widened from float as EntityType.TNT's sized() gives them; the command_exec case reads them back. Merged main (command_exec corpus group order).
2026-11-08 10:16:27 +01:00
Horizon agentandClaude Opus 5.5 0d27a2a38f Parity: keep the capture-preserving harnesses out of automatic runs
Seventeen harnesses need --work-dir (a fresh capture folder) and
--reference-dir, or assert that their fixed capture folder is new.
parity.py passes neither, so whenever --changed selects them they fail
at startup, whatever the pull request changed: 14 of the 18 failures on
#12336's parity run were these. List them under named_only: they still
run when named and in the nightly --all audit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:16:25 +01:00
SolenopsisbotandCodex 728141ad4f fix: retain remote tick vectors after iteration
Co-Authored-By: Codex <[email protected]>
2026-11-08 20:13:42 +11:00
Loki 329aae2ae3 Merge remote-tracking branch 'origin/main' into fix/11382-vehicle-entity-random 2026-11-08 18:09:56 +09:00
LokiandAntigravity db270fecca game: use entity random for boat, minecart and item frame operations (fixes #11382)
Co-Authored-By: Antigravity <[email protected]>
2026-11-08 18:09:48 +09:00
SolenopsisbotandCodex 4bf7247bcb perf: reuse decoration scheduling scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 20:07:21 +11:00
adiraj66132 92fc757a73 security: harden guest commands, the JSON parser and zip totals
- A LAN/dedicated guest's command no longer runs the host's client-side
  native mod commands (they ran before any permission check; client mod
  commands belong to the local player only).
- The server-files JSON parser refuses documents nested past 128 levels
  instead of recursing unbounded.
- The zip reader caps the total inflated bytes across entries (4 GiB per
  archive), not just per entry.

Co-Authored-By: Mercury <[email protected]>

# Conflicts:
#	crates/horizon-client-render/src/zip.rs
2026-11-08 14:37:10 +05:30
Florian ErnstandClaude Opus 5.5 8a964bbb79 Drop a discarded trader llama from the mob list in the same tick
TraderLlama.maybeDespawn discards an eligible llama in its aiStep when its
DespawnDelay runs out, so it leaves the level's entity list in that tick.
Horizon's countdown set m.removed, but ai::tick still returned true, so
the creature tick kept the llama in game.mobs until the next tick. During
that extra tick the next mob snapshot and the native leave bookkeeping
still saw it. Commands, the tracker and collisions already skip removed
mobs, so commands showed no difference.

The final return of ai::tick now reports a trader llama that its own tick
removed, and the creature tick drops it in that tick, as it does for a
despawned mob. The rest of the llama's tick still runs, and other species
are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:06:51 +01:00
masa-masa-0314andZCode 8a84813b69 Friends: the account's friends service and its worker
Port the service behind vanilla 26.3's friends list, without its screens:

- authlib's FriendsService over the discovery document: getFriends,
  updateFriends, updateAttributes and updatePresence with the account's
  bearer token, If-None-Match/ETag caches, Retry-After poll intervals and
  the ten-second read cooldown (MinecraftServicesFriendsService).
- RemoteFriendListUpdateHandler's worker and state: one read a minute
  (five in the background), a forced read after a successful action, the
  result-code-to-state mapping and the cached lists.
- PlayerSocialManager's flags and accessors, with no screen using them.
- PresenceHandler: the sharePresence option picks the public status, the
  client supplies getPresenceStatus each tick, and closing posts OFFLINE.

Minecraft's constructor decides whether the worker starts from the
account's friendsPreferences (UserFlag.FRIENDS_ENABLED /
ACCEPT_FRIEND_INVITES); title.poll_account now does the same after its
getAttributes answer. The overlay, the Online options switches and the
title/pause icon changes stay for later parts, so no player-visible UI
changes here. A joined Realm is carried to the presence status through
ServerData.isRealm's equivalent (Action::Connect.realm).

No new harness: the list and presence parsers, the state mapping, the
sharePresence levels and Retry-After are unit-tested.

Co-Authored-By: ZCode <[email protected]>
2026-11-08 17:01:47 +08:00
Florian ErnstandClaude Opus 5.5 6fefa6ec54 Save the source and projectile owner UUIDs of a vibration
VibrationInfo keeps the UUIDs of its source entity and of a projectile's
owner, and VibrationInfo.CODEC saves them as source and projectile_owner.
The sculk listener now takes them from the save layer's UUID of the
mob the event names, writes them, and reads them back. Loaded vibrations
keep no live entity; a player source stays unnamed.

Fixes #12186

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:01:27 +01:00
Florian Ernst 362e77ba6c Merge origin/main into fix/loot-mine-location-block-state
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/game/commands/terrain_cmds.rs
#	crates/horizon-items/src/items.rs
2026-11-08 09:59:18 +01:00
SolenopsisbotandCodex 65f1235daf perf: reuse remote entity tick scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 19:56:39 +11:00
Florian Ernst cdfe986e8c Merge origin/main into fix/h052-vehicle-container-save
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/game/commands/data.rs
#	tools/command_exec_corpus.py
#	tools/test_command_exec_parity.py
2026-11-08 09:56:29 +01:00
Florian Ernst b56f598a71 Merge origin/main into fix/h181-noai-trader-llama-delay
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/mobs/ai.rs
#	tools/command_exec_corpus.py
2026-11-08 09:56:20 +01:00
Florian Ernst b778599d5f Merge origin/main into fix/h157-player-save-projection
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 09:56:11 +01:00
Florian Ernst 1699b82741 Merge origin/main into fix/named-predicate-context
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/advancements.rs
#	crates/horizon-client/src/game/functions.rs
2026-11-08 09:55:53 +01:00
Florian Ernst 79723cb13e Merge origin/main into fix/inline-armor-trim-holders
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/item_sync.rs
#	crates/horizon-client/src/lan/guest.rs
#	crates/horizon-protocol/src/item.rs
2026-11-08 09:55:26 +01:00
Horizon agent ee61f0ea71 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 09:55:20 +01:00
Florian ErnstandClaude Opus 5.5 84e22207fb Measure saved vibration source UUIDs (H064 test checkpoint)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:48:41 +01:00
SolenopsisbotandCodex 83de5c24d6 perf: reuse selection outline scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 19:48:00 +11:00
Ludovic Marie 2d22e6a7e3 Merge pull request #12311 from voidsipp/fix/round6-12063
🤖 Agent: Server configuration dialogs keep the panorama behind them (DialogScreen inherits Screen.extractBackground) instead of the flat 20/20/20 fill.
2026-11-08 09:43:43 +01:00
Ludovic Marie e1315b7e55 Merge pull request #12357 from umbx-dot/launcher/mod-version-picker
🤖 Agent: Includes #12355. A version picked in the Versions tab is kept (chosen-versions.json) until the player installs the recommended one, so the pre-build swap and the automatic updates no longer undo a deliberate pick.
2026-11-08 09:43:38 +01:00
dd8daeb619 HDR float frame: remove the mark resolve and lane state
Float writers already store colour and coverage. Remove the unused mark
resolve pipeline and shader, and keep the world scratch and parameters for
the tone curve and HUD composite that still use them.

Choose no-pack HDR gain explicitly without storing a frame lane. Keep the
uniform ABI and existing light arithmetic. TAA tracks baked gain and its
settings, preserves compatibility history when gain is off, and rejects
history when it resumes after a shader pack.

Use a non-float legacy oracle for writer tests and restore exact float,
OIT and visibility-buffer sessions in the identity harness. Preserve the
compatibility mark paths and the non-layered hand brightness sentinel.

Co-Authored-By: GPT 6.1 Sol <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:37:53 +01:00
Ludovic Marie 6f856b2c0a Merge pull request #12343 from Solenopsisbot/perf/lz4-decode-scratch-v2
🤖 Agent: Each stream now starts from 21 zeroed bytes (clear + resize, pushed): a bare resize left the previous stream's bytes past a short block, which the decompressor may read, so corrupt-stream checks could differ from a fresh buffer.
2026-11-08 09:37:00 +01:00
Ludovic Marie b0ad9abd0c Merge pull request #12333 from Solenopsisbot/perf/pack-page-scratch
🤖 Agent: The retained page list is cleared after the shader pack's post passes (pushed): it keeps its capacity, but no longer holds clones of arena page buffers until the next pack frame, which would keep freed pages alive on the GPU once the pack is off.
2026-11-08 09:36:57 +01:00
Ludovic Marie c5c53d4c6c Merge pull request #12354 from horizon-rust/ci/pack-uniforms-scripted-clock
🤖 Agent: Test-only: the smoothed-uniforms test steps PackInputs::frame_timing instead of backdating the wall clock, so a slow runner can no longer push centerDepthSmooth past its 1e-3 tolerance (failed verify on #12241 and #12311).
2026-11-08 09:33:49 +01:00
Ludovic Marie 3bca17f46a Merge pull request #12160 from TheMrZZ/fix/h248-hurt-cooldown-incoming
🤖 Agent: This head holds all 13 layers of TheMrZZ's series (12010 already merged; 11732 … 12133 below it), so landing it merges the rest. The top layer's own point: inside the hurt cooldown a hit is compared with `lastHurt` by its incoming amount, before armor and Resistance, and only the difference goes on to `actuallyHurt`, as `LivingEntity.hurtServer` does.
2026-11-08 09:26:53 +01:00
Ludovic Marie 7e306e4b25 Merge pull request #12337 from NikitaMGrimm/hdr-marks-b
🤖 Agent: Stacked on #12330: landing it lands the chain. Only the float frame (HORIZON_HDR_FRAME=float) changes its alpha; 8- and 16-bit frames keep their pipelines and marks.
2026-11-08 09:26:49 +01:00
Ludovic Marie 26d73e3f28 Merge pull request #12346 from Solenopsisbot/perf/worldgen-biome-bitset
🤖 Agent: A spilled word keeps its index (128 + spill offset) in the chained iteration, so the ids stay ascending as with the Vec bitset; 1 KB on the stack per generated chunk.
2026-11-08 09:26:46 +01:00
Ludovic Marie 929cb85c85 Merge pull request #12340 from Solenopsisbot/perf/worldgen-empty-blender
🤖 Agent: Blender has no interior mutability (two OpenMaps and an Option, read only), so one shared empty Arc is safe for every chunk without old-world data, and non-empty blenders stay per chunk.
2026-11-08 09:26:42 +01:00
Ludovic Marie e3966b586a Merge pull request #12338 from Solenopsisbot/perf/game-cpu-fanout
🤖 Agent: The ten handoff loaders share only the resource root and the parsed entity document, both immutable; a panic in a worker is resumed on the caller and Creative's error keeps its message, so startup fails the same way. No wall-clock number yet: the gain is the slowest loader instead of the sum.
2026-11-08 09:26:39 +01:00
umbx-dotandClaude Opus 5.5 7a1fe7f702 launcher: a native mod's Versions tab says which version fits, and picks one
A registry native mod's Versions tab lists each version's date and how it
fits the Horizon played (the fit line the trust text already uses), marks
the one the launcher would pick Recommended, and has Install on every
version but the installed one.

A version the player picks there stays as it is: no automatic update, no
offered update and no swap before a build, until the player installs the
mod again or picks its recommended version (mod-browser/chosen-versions.json).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:23:15 +01:00
Ludovic Marie 443f9b0642 Merge pull request #12330 from NikitaMGrimm/hdr-marks-a
🤖 Agent: On the float frame the renderer is rebuilt when the HUD layering changes, not only the format; still behind HORIZON_HDR_FRAME=float.
2026-11-08 09:19:46 +01:00
Horizon agentandClaude Opus 5.5 79738505fb LZ4 scratch: zero the header bytes for each stream, as a new buffer had them
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:19:36 +01:00
Horizon agentandClaude Opus 5.5 851bda5b5e Shader pack pages: drop the buffer clones after the frame, keep the capacity
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:19:04 +01:00
Horizon agent ce322efe53 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 09:17:08 +01:00
umbx-dotandClaude Opus 5.5 238bf31f77 launcher: automatic updates keep a native mod on a version that builds
The start's automatic update moved native mods to their newest version, which the build then swapped back when it doesn't build on the Horizon played. It now updates them only to the newest version that builds there, when that is known.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:16:44 +01:00
Horizon agentandClaude Opus 5.5 aa1f9c5dc9 Shader pack test: drive the smoothed uniforms with a scripted clock
smoothed_uniforms_take_iris_half_lives backdated the wall clock and let
update() measure the gap, so any delay between the two calls moved
centerDepthSmooth (0.1 s half-life) past its 1e-3 tolerance. It failed
verify on busy runners for unrelated PRs (#12241, #12311). Use
PackInputs::frame_timing, which update() already takes as the frame's
delta, so every step is exact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:15:28 +01:00
k3yhandClaude Opus 5.5 b4ed614faa A potion or tipped arrow is named by its contents
PotionItem.getName and TippedArrowItem.getName name these items by
their contents (PotionContents.getName: the contents' custom_name, the
potion, else empty), over item_name. brewing::contents_name_key gives
that key, and the five functions that name a stack take it after the
custom_name component and before item_name.

New command corpus group: potion contents names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:13:32 -05:00
SolenopsisbotandCodex e3082a0281 fix: satisfy LZ4 clippy
Co-Authored-By: Codex <[email protected]>
2026-11-08 19:13:15 +11:00
Horizon agent 013fb324e6 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 09:08:18 +01:00
Horizon agentandClaude Opus 5.5 0a871808fa Ticket fast path: compare the portal tickets with their level, as the sources store them
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:08:18 +01:00
Vinícius MoreiraandClaude Opus 5.5 0e6d23f59b Polytone: biome and dimension modifiers as attribute layers
Resource packs' Polytone biome and dimension modifiers now change the
environment attribute stack the frame draws (wiki "Environment
Attributes"): a dimension modifier's base group changes the dimension's
own entries, rain and thunder change the weather's, post_process adds a
layer after all others; a biome modifier's base group changes its target
biomes' entries (ids, #tags through the biome tags, patterns) and
post_process adds a biome layer after the weather. REMOVE drops an
entry; modifiers apply lowest priority first. Values that are scripting
expressions or colormaps are left for the next steps.

The stacks are built when packs load, only when a pack has modifiers, and
only the frame reads them: gameplay (sky darkening, the server's sun
angle) keeps vanilla's. Without such a pack nothing changes.

With such a pack on, its biome and dimension modifiers load and apply;
the environment_render and environment_system harnesses still match
vanilla.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:08:03 -03:00
Ludovic Marie 170cfb468c Merge pull request #12321 from voidsipp/fix/round6-12128
🤖 Agent: LAN join and respawn packets carry the world spawn and its rotation, not the acting player's personal spawn, and /setworldspawn now updates connected players in every dimension (SetWorldSpawnCommand.setSpawn, PlayerList.sendLevelInfo).
2026-11-08 09:07:49 +01:00
Vinícius MoreiraandClaude Opus 5.5 0d0b58a960 Polytone: pack configs and conditional overlays
Polytone packs keep most of their effects in pack overlays that a
polytone_condition turns on: a scripting expression over the pack's own
config entries (config('pack:fog') == 'ON', modOn('minecraft', range)),
or an object with require_config, require_mods and override. A pack's
config entries (assets/<namespace>/polytone/config_entries/*.json) are
now read at their default values, and an overlay with a condition is
active when it holds: an expression decides alone (packs pair it with
formats no version matches), an object only alongside the formats unless
it overrides them. Overlays without one work as before.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:07:42 -03:00
Vinícius MoreiraandClaude Opus 5.5 92e3012389 Environment: sample the sky through the vanilla attribute stack
Environment now builds the dimension's EnvironmentAttributeSystem as
addDefaultLayers does: the dimension type's attributes, a biome layer for
every attribute some biome sets, the timelines its tag lists (in order),
and the rain and thunder layers where Level.canHaveWeather. The frame
samples it with the camera's Gaussian biome mix (the probe's order) and
the biome at the camera, so every attribute blends and changes with the
weather the vanilla way, not only the sky and fog colours, and the
hand-written timeline sampling, biome colour blending and apply_weather
are gone. Biomes keep their attribute maps for the biome layer.

environment_render now passes with no tolerance except one rounding in
Sky's light level fraction (was 218 inexact cases), and covers cloud
height.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:07:42 -03:00
SolenopsisbotandCodex 0427c41bde perf: keep biome id bitsets on the stack
Co-Authored-By: Codex <[email protected]>
2026-11-08 19:05:34 +11:00
umbx-dotandClaude Opus 5.5 54bedee730 launcher: use the native mod version that builds on your Horizon
Installing a registry native mod took its newest version, and a build
left out any mod made for another Horizon, though the registry often has
an older version made for the Horizon the player picked.

native_fit::best picks the newest version that builds on the Horizon
played, else the newest that moves the build to its own commit without
clashing. Installs and updates use it, and before each build every mod
turned on whose installed version doesn't build is swapped for that
version, with a line saying which version is used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 09:04:54 +01:00
Kacper 23bd1b7627 Merge pull request #12318 from TheApple05/codex/parity-12181
Keep resource-pack parity paths intact with JSON headers
2026-11-08 09:00:21 +01:00
Kacper 920346fb43 Merge pull request #12010 from TheMrZZ/fix/h236-clone-dimensions
Resolve /clone's source and target dimensions
2026-11-08 09:00:13 +01:00
Kacper 632d6cd4f4 Merge pull request #11654 from MSedgeMC/fix/set-custom-model-data
A loot table's set_custom_model_data writes the item's model data
2026-11-08 09:00:01 +01:00
Kacper 98342f1bd0 Merge pull request #11476 from baytyone/xp-orbs-riding-merge-water
Experience orbs: pickup over the vehicle, a kept following player, merges before the move, eye-level water
2026-11-08 08:59:50 +01:00
Kacper d2cadb1c39 Merge pull request #11473 from MSedgeMC/fix/vindicator-johnny
A vindicator that was named Johnny stays Johnny
2026-11-08 08:59:39 +01:00
Kacper cab807c9d7 Merge pull request #11463 from MSedgeMC/fix/palette-pack
Chunk storage: pack a section's palette as vanilla's PalettedContainer.pack does
2026-11-08 08:59:32 +01:00
SolenopsisbotandCodex 70e0a37264 fix: satisfy pack page lint
Co-Authored-By: Codex <[email protected]>
2026-11-08 18:56:55 +11:00
SolenopsisbotandCodex 58b2eaa55e fix: preserve LZ4 scratch stream length
Co-Authored-By: Codex <[email protected]>
2026-11-08 18:51:32 +11:00
SolenopsisbotandCodex 104fe56b30 perf: reuse LZ4 decode scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 18:51:32 +11:00
SolenopsisbotandCodex 98d9f172bd perf: share empty worldgen blenders
Co-Authored-By: Codex <[email protected]>
2026-11-08 18:43:32 +11:00
Ludovic Marie b49f32e4ab Merge pull request #12332 from martipops/settings/shell-choice-step
🤖 Agent: Left and Right step a focused choice back and on in the settings shell, as Shift-press and press do; other rows keep their keys.
2026-11-08 08:41:32 +01:00
Ludovic Marie 32613f5637 Merge pull request #12331 from Vaspyyy/biome-id-past-table
🤖 Agent: A biome id past the table after a proxy's server switch names plains instead of panicking (#12148: "the len is 67 but the index is 67"), and the reconfiguring client plays menu music as ServerReconfigScreen lets it.
2026-11-08 08:41:29 +01:00
Ludovic Marie 3f604c3028 Merge pull request #12329 from Solenopsisbot/perf/vegetation-scratch
🤖 Agent: Vegetation patches iterate their position sets directly instead of copying them, and multiface growth shuffles fixed arrays; the shuffle draws the same number of randoms in the same order.
2026-11-08 08:41:25 +01:00
Ludovic Marie ed4077ec1d Merge pull request #12328 from Solenopsisbot/perf/creature-vegetation-scratch
🤖 Agent: The creature tick's MobEvent buffer is kept between ticks and drained, returning its capacity even when a handler errors.
2026-11-08 08:41:22 +01:00
Ludovic Marie f9b605a934 Merge pull request #12327 from Solenopsisbot/perf/pack-resource-fanout
🤖 Agent: Pack names, clouds, the forcefield and custom sky load on four scoped threads; panics still propagate (resume_unwind) and the values are the same.
2026-11-08 08:41:18 +01:00
Ludovic Marie fbd34a0343 Merge pull request #12326 from J5Casey/braid/fishing-medium
🤖 Agent: The fishing_medium native hook lets a mod make a bobber float and fish in another block, with its own loot table and lure range; in water the vanilla path is untouched.
2026-11-08 08:41:14 +01:00
Ludovic Marie e9208d8d86 Merge pull request #12325 from Solenopsisbot/perf/displacement-frame-scratch
🤖 Agent: The displacement pass collects its nearby sections into a SmallVec sized to its 64-section cap and reuses its section table, removing the per-frame heap allocations; the GPU writes are unchanged.
2026-11-08 08:41:10 +01:00
Ludovic Marie e0081cb2ae Merge pull request #12324 from k3yh/loot-components-modelled
🤖 Agent: A loot set_components patch for a component Horizon models (potion_contents and the rest) is read into its field as a saved stack's is, so a rolled potion gives its effect; damage and custom_name keep their own paths.
2026-11-08 08:41:06 +01:00
Ludovic Marie 9990881f3a Merge pull request #12291 from masa-masa-0314/feat/realms-account-uuid
🤖 Agent: The single-player owner is the signed-in account's UUID and older worlds move their owner to it on open; I made the migration keep the offline player files as .dat_offline backups instead of deleting them.
2026-11-08 08:41:01 +01:00
k3yhandClaude Opus 5.5 24a3e509bd /loot give to a full inventory throws nothing out
The give branch of cmd_loot spawned what give couldn't fit at the
command's position and counted every drop. LootCommand.playerGive puts
each drop in with Inventory.add: what fits stays, the rest is lost, and
the drop counts only when add returns true, which it does when all of
it went in or for a creative player.

New command corpus group: loot give full inventory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:39:11 -05:00
SolenopsisbotandCodex 7dda0df3c0 perf: fan out game CPU resource loads
Co-Authored-By: Codex <[email protected]>
2026-11-08 18:38:23 +11:00
Ludovic Marie 6539a95ef6 Merge pull request #12322 from masa-masa-0314/feat/realms-create-world
🤖 Agent: Generate New World opens Create World and uploads the temporary world it writes, as RealmsCreateWorldFlow.createWorld does.
2026-11-08 08:37:45 +01:00
Ludovic Marie 4a1adf44fd Merge pull request #12295 from glitchsnake/fix/11854-mob-health-boost
🤖 Agent: A mob's max_health is refreshed whenever Health Boost's amplifier changes or it ends (load, conversion, milk, death protection), and health is clamped to the new maximum, as refreshDirtyAttributes does. I merged main: #12255 already refreshes Health Boost in apply_death_effect and the trader's drink, so this PR's copies of those blocks were dropped and its test kept.
2026-11-08 08:37:41 +01:00
Ludovic Marie 4cf8cd0957 Merge pull request #12257 from voidsipp/fix/round6-12230
🤖 Agent: Piston block events and sculk charge cursors check the block-ticking ticket range (ServerLevel.shouldTickBlocksAt), not chunk ticking readiness, so they run in a freshly ticketed chunk; moving pistons still wait for readiness, as the oracle shows. Merged main (isPositionTickingWithEntitiesLoaded's doc now names the entities).
2026-11-08 08:33:21 +01:00
Nikita Maximilian GrimmandGPT 6.1 Sol eb835292f5 HDR float frame: store colour and coverage without light marks
Choose float alpha storage independently of the no-pack HDR gain. Plain
draws and the mirror keep their RGB; opaque finishes write alpha 1 and
blended draws keep coverage. Keep the existing written-light arithmetic.

Run light-mark redraws and hand unmark/remark only on compatibility
frames. Preserve the non-layered 0.2 hand's UI-brightness sentinel. Stop
resolving float alpha into light, while retaining the resolve oracle and
lane state for the next cleanup.

Check real shader outputs on the GPU and preserve the existing pictures
with differential HDR, pack, OIT, visibility-buffer and hand captures.

Co-Authored-By: GPT 6.1 Sol <[email protected]>
2026-11-08 08:32:06 +01:00
SolenopsisbotandCodex ddaada5bb9 perf: reuse shader pack page scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 18:31:27 +11:00
VaspyyyandClaude Opus 5.5 6b33c13380 Divide MenuTooltipPositioner's widget offset as floats like vanilla
getOffset divides the pointer's distance from the widget edge by the
widget height as floats: 26.3's bytecode is iload_3, i2f, iload_2, i2f,
fdiv before Mth.lerp and Math.round(float). The decompiled text without
the casts made widget_offset an int division, so a hovered widget's
tooltip stayed height - 3 below its edge until the pointer was a whole
height away, then jumped. On a 20 px button it sat up to 10 px lower than
vanilla's. The offset now follows the pointer as vanilla's does, rounded
with jmath::round_f32, and the test expectations are the values the real
26.3 MenuTooltipPositioner returns for the same inputs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 08:28:21 +01:00
VaspyyyandClaude Opus 5.5 b03828a569 Show the title screen icon buttons' tooltips while hovered like vanilla
The title screen's icon row (Friends, Language, Accessibility) drew its
sprites but no tooltip: the tooltip pass after the button loop only knew
Create World, Select World and Multiplayer. Vanilla gives these buttons a
Tooltip (CommonButtons.language and accessibility, FriendsButton while
friends are available), which WidgetTooltipHolder draws while the button
is hovered, placed by MenuTooltipPositioner and split at 170 px. The
accessibility onboarding screen builds its Accessibility Settings... and
Language... buttons with the same CommonButtons, so they lacked the same
tooltips.

Title::button_tooltip now names each screen's button tooltips, and both
the narration hints and the draw loop read it. The draw loop remembers
the hovered button's tooltip and draws it after the widgets (and after
the onboarding fade, which vanilla applies to widgets only) with the same
positioner (ui::tooltip_menu), before the toast so the toast stays on top.
Fixes #12067.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 08:28:21 +01:00
VaspyyyandClaude Opus 5.5 99bd306532 Scatter a destroyed chest boat's or container minecart's contents like vanilla
AbstractChestBoat.remove and AbstractMinecartContainer.remove spill the
container through Containers.dropContents for every removal reason that
destroys the vehicle: the kill of VehicleEntity.destroy and a creative
hit's discard alike. That spill has no entity_drops gate; only the hull
item and chestVehicleDestroyed's second, empty spill follow the rule.

Horizon's damage path got both vehicles wrong. A chest boat dropped each
stack whole at its position with an item's own motion and a pickup
delay of 10, and never drew chestVehicleDestroyed's per-slot spots. A
container minecart scattered its contents only with entity_drops on, so
with the rule off (or from a creative hit with it off) the contents
vanished.

Both now share one Containers.dropContents helper (the /kill path used a
second copy): the contents scatter from a spot in the vehicle's block in
pieces of 10 to 30 with no pickup delay, before the ENTITY_DIE event and
before a boat's lead, as Entity.kill and AbstractBoat.remove order them.
The hull item and the empty spill still need entity_drops and a
non-creative hit. Every damage source (players, LAN guests, explosions,
lightning, /damage) goes through these two functions, so single player,
LAN and dedicated servers all get it.

The vehicle_command_damage harness now breaks a chest boat with /damage,
and a chest minecart with entity_drops off both by /damage and by a
creative player's hit, against the real 26.3 server. Each break must
leave the 5 diamonds inside the vehicle's block with no pickup delay,
and the 40 dirt as piles in that block whose counts add up to 40. A
gameplay test seeds the level random, breaks a chest boat and a chest
minecart, and checks that the random ends where vanilla's two
Containers.dropContents calls leave it (the empty second spill's draws
included).

The port map rows for AbstractChestBoat.remove and
AbstractMinecartContainer.remove point at the shared helper instead of
the removed /kill copy. The chestVehicleDestroyed row now says what is
left there: a player's hit on a container minecart angers no piglins yet.

Fixes #12121

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 08:27:26 +01:00
Horizon-agent 2fae2a9101 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 08:21:34 +01:00
Ludovic Marie aedfd10c93 Merge pull request #12220 from NikitaMGrimm/hdr-frame-rebuild
🤖 Agent: The HDR float frame follows HDR, Smooth Gradients and the picked pack at once by rebuilding the renderer; all of it is behind HORIZON_HDR_FRAME=float, so the default path only pays one bool check per frame.
2026-11-08 08:19:20 +01:00
VaspyyyandClaude Opus 5.5 6d72b0375e Fire shulker bullets from the box centre and turn them at standable blocks
A shulker's bullet started at the centre of the shulker's block cell.
Vanilla's ShulkerBullet constructor starts it at
owner.getBoundingBox().getCenter(), and Shulker.makeBoundingBox grows
that box toward the open side by the lid's physical peek (times the
scale), so an open floor shulker fires from the top of its block
(#11974). shulker::bullet_origin now builds that box with
getProgressDeltaAabb at the shulker's scale, from the peek the goal
sees (the attack goal runs before Shulker.tick eases the peek, in both
games).

In flight, a bullet turned only before a full collision cube. Vanilla
asks Level.loadedAndEntityCanStandOn(next, bullet): the top face of the
block's collision shape, in the bullet's collision context, is full
(Block.isFaceFull). Top slabs, upside-down stairs, closed top trapdoors
and the like now turn it too, instead of the bullet flying into them
(#11970). collisions::projectile_can_stand_on implements the test, and
ProjectileWorld::solid becomes can_stand_on(pos, entity_y), since
scaffolding reads the bullet's height.

New harness shulker_bullet: the real ShulkerBullet constructor for all
six attach faces, every peek of an opening lid and four scales, and
loadedAndEntityCanStandOn over forty block states at four bullet
heights, compared bit for bit with the Rust probe.

Fixes #11974
Fixes #11970

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 08:17:17 +01:00
Horizon agentandClaude Opus 5.5 4f71890226 Ticket fast path: compare the portal tickets' chunks after the main merge
#12232's portal_matches read self.portal as (chunk, level) pairs; here it holds
PortalTicket, so it compares ticket.chunk.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 08:16:49 +01:00
Ludovic Marie f64f181d1d Merge pull request #12319 from glitchsnake/fix/11651-spawn-finalize
🤖 Agent: EntityType.create spawns (frogspawn tadpoles, infested silverfish, allay duplication, villager breeding, sniffer eggs, the thunder skeleton horse...) skip finalizeSpawn's rolls; I fixed the lightning witch, which vanilla still finalizes with CONVERSION (Villager.java:748).
2026-11-08 07:57:06 +01:00
martipops 47a832db72 Merge remote-tracking branch 'upstream/main' into settings/shell-choice-step 2026-11-08 01:56:53 -05:00
Horizon agentandClaude Opus 5.5 3627361d25 Merge main into #12295
#12255 already refreshes Health Boost and clamps absorption in apply_death_effect
and the wandering trader's drink; main's blocks are kept, this PR's copies of them
dropped, and its clear-all-effects test kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 07:55:18 +01:00
Horizon agent db1e3398ce Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 07:54:46 +01:00
SolenopsisbotandCodex 5288273f01 perf: reuse vegetation placement scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 17:50:24 +11:00
SolenopsisbotandCodex e55b51a4b0 perf: reuse creature event scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 17:47:51 +11:00
Ludovic Marie fe020bb113 Merge pull request #12314 from NikitaMGrimm/warden-digging-test
🤖 Agent: The warden digging test ticks the warden at age 1, since the client moves tickCount on before it ticks; it had failed on main since #12110 wherever the vanilla data is prepared.
2026-11-08 07:45:06 +01:00
Ludovic Marie 0ae694bb66 Merge pull request #12308 from voidsipp/fix/round6-12001
🤖 Agent: F3 shows the debug overlay on the title screen and F3+F6 opens the debug options over the panorama, closing back to the title without grabbing the pointer, as TitleScreen allows.
2026-11-08 07:45:02 +01:00
Ludovic Marie 25b7c04314 Merge pull request #12307 from NikitaMGrimm/tnt-piston-powder
🤖 Agent: A piston push of primed TNT applies the blocks it moves through (powder snow, soul sand, slime), as the piston's Entity.move does. Stacked on #12290.
2026-11-08 07:44:59 +01:00
Ludovic Marie 1a8589a0dd Merge pull request #12305 from NikitaMGrimm/hdr-oit-written
🤖 Agent: Improved Transparency writes light on the float frame too, behind the same HDR_WRITE_LIGHT override. Stacked on #12302.
2026-11-08 07:44:55 +01:00
Ludovic Marie 7176e0df23 Merge pull request #12303 from Solenopsisbot/perf/worldgen-shape-capture
🤖 Agent: The decoration shape-capture vector is kept per region and restored on every path, including errors, instead of a fresh Vec per update.
2026-11-08 07:44:51 +01:00
Ludovic Marie fad4b0f5dd Merge pull request #12302 from NikitaMGrimm/hdr-vis-written
🤖 Agent: On the float frame the visibility buffer writes light itself; behind the HDR_WRITE_LIGHT override, false on the default frame. Stacked on #12282.
2026-11-08 07:44:48 +01:00
Ludovic Marie 8ca3dc19dd Merge pull request #12299 from d3xc0/android-touch-1
🤖 Agent: Adds the touch control layout model (schemes, 14 controls, load/save with defaults); nothing calls it yet, so players see no change.
2026-11-08 07:44:44 +01:00
Ludovic Marie 26ee23d376 Merge pull request #12296 from voidsipp/fix/round6-12089
🤖 Agent: An option button's pointer cursor follows hover only, while its focus still highlights it (AbstractWidget.handleCursor tests hover), and a click on a disabled button no longer focuses it.
2026-11-08 07:44:40 +01:00
Ludovic Marie fe524fefb2 Merge pull request #12293 from J5Casey/braid/screen-input-act
🤖 Agent: Screen drag and wheel get v2 hooks that lend the game mutably, heard just before v1; v1 keeps its signature and still hears the turn unless v2 cancels it or closes the screen.
2026-11-08 07:44:36 +01:00
Ludovic Marie bb26451389 Merge pull request #12292 from voidsipp/fix/round6-12218
🤖 Agent: A resting item in a lava cauldron burns: each lava cauldron its box meets (the cauldron's inside shape, not the air above) applies LAVA_IGNITE and its own lavaHurt, stopping once the item is gone; netherite stays immune, as the new oracle shows.
2026-11-08 07:44:33 +01:00
SolenopsisbotandCodex b7468c0196 perf: fan out independent pack resource loads
Co-Authored-By: Codex <[email protected]>
2026-11-08 17:43:18 +11:00
Horizon agent 282b7b3085 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 07:42:55 +01:00
Horizon agent 7d269ccea1 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/realms.rs
2026-11-08 07:42:42 +01:00
Horizon agent c072d21438 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 07:42:38 +01:00
SolenopsisbotandCodex 94bd299a9a perf: reuse displacement frame scratch
Co-Authored-By: Codex <[email protected]>
2026-11-08 17:39:59 +11:00
bf6a7d910c HDR float frame: rebuild when the HUD layering changes
Choose the frame format and HUD layering together. No-pack float HDR needs
the HUD layer, so devices without it keep the compatibility frame. A 0.2
pack still gets its float frame in SDR and HDR.

Rebuild when picking or dropping a pack changes the layering even if the
format stays float, so the renderer always has the layering a fresh start
would give it.

Co-Authored-By: GPT 6.1 Sol <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 07:39:39 +01:00
Horizon agentandClaude Opus 5.5 944a3e1c80 Keep the offline player files as backups when the owner moves
The migration renamed nothing back if it went wrong: it deleted the offline
.dat and .dat_old after writing the account's file. They now stay beside it as
.dat_offline and .dat_old_offline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 07:36:14 +01:00
Horizon agent f57866e72f Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 07:35:55 +01:00
k3yhandClaude Opus 5.5 8c8615875e A potion a loot table rolls with set_components gives its effect
StackData::set_loot_component kept every component but trim in other,
its saved form, so a potion a chest or a mob's loot rolled with a
set_components potion_contents gave no effect: brewing::contents_effects
reads potion and potion_extra. A modelled component is now read into
its field the way a saved stack's is (decode_components). Damage stays
in other, as the stack holds it, and custom_name keeps its own reading.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:34:11 -05:00
Horizon agentandClaude Opus 5.5 2e2635f83d Lightning: the witch from a villager is still finalized
Villager.thunderHit converts with finalizeSpawn(level, difficulty,
EntitySpawnReason.CONVERSION, null); only Pig.thunderHit skips it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 07:33:26 +01:00
VaspyyyandClaude Opus 5.5 dde2b2abff Start the menu music while reconfiguring and test the #12148 path
Vanilla's ServerReconfigScreen is a plain Screen, not a
LevelLoadingScreen, so MusicManager.tick starts the MENU music that
getSituationalMusic picks once the player is gone. Horizon treated the
reconfiguration as loading (no player, no title, no credits) and stayed
silent until the next world; a reconfiguring connection no longer
counts as loading.

A Game test (prepared resources, ignored by default) puts a column
holding a biome id one past the table at the origin, reads it through
biome_at and biome_name_at (plains), then checks that a reconfiguring
client picks and starts the menu music and that the level probe after
it reads plains' music without a panic.

Biomes::name's doc now says that Biomes::get clamps such an id to the
last entry instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 07:31:01 +01:00
VaspyyyandClaude Opus 5.5 85b61b6f6e Stop the client crashing on a biome id past its table after a server switch
A proxy that moves the player to another server reconfigures the
connection. Horizon keeps the last server's columns until the next
Login clears them, but Reconfigured already swaps in the next server's
biome table. When the last server had a biome the game lacks (added to
the table as id 67) and the next one does not, those columns hold an id
past the 67-entry table. situational_music still probed the level at
the origin during the reconfiguration, and biome_at indexed the table
with that id: "index out of bounds: the len is 67 but the index is 67".

Vanilla never reads that level: handleConfigurationStart calls
clearClientLevel, which nulls the player, so getSituationalMusic
returns the menu music. The music probe now asks Remote::has_level
(Login seen, no reconfiguration since) instead of logged_in.

The three places that indexed the biome table directly (biome_at for
music, ambience and custom skies, biome_name_at for random textures and
fishing, and /fillbiome's filter) now go through Biomes::name, which
names plains for an id past the table, as biome_at already did for a
missing column and Biomes::id does for an unknown name.

Fixes #12148

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 07:30:57 +01:00
Horizon agent aee2c83c2f Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 07:29:43 +01:00
Horizon-agent 24c3cabed3 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/test_command_exec_parity.py
2026-11-08 07:20:51 +01:00
Horizon agentandClaude Opus 5.5 61d43cf005 Skip the tamable panic test without extracted mob data
with_built_test_world runs nothing where the data is missing (CI), and the
test then compared None with Some(true); it now returns early there, as the
other with_built_test_world tests do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 07:16:00 +01:00
Horizon agent b62553197b Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 07:15:37 +01:00
Ludovic Marie 6ef71901bf Merge pull request #12316 from horizon-rust/fix/test-batch-starting-feedback
🤖 Agent: the batch-starting line now goes to the /test command's own source inside the command (TestBatchSummaryDisplayer); the test-instance block still uses the server source. Lifecycle stays 95/99: its 4 if-loaded records are an oracle artifact.
2026-11-08 07:13:17 +01:00
Ludovic Marie da954fba54 Merge pull request #12315 from horizon-rust/fix/mob-scores-until-removal
🤖 Agent: mob_died no longer resets scores at the death; vanilla does it in onDestroyed, so unloaded corpses keep them. The #12185 shulkers get fixed UUIDs so /scoreboard players list can match at all.
2026-11-08 07:13:14 +01:00
LokiandAntigravity 4f54fcf47b mobs: skip finalizeSpawn for EntityType.create spawns (fixes #11651)
Co-Authored-By: Antigravity <[email protected]>
2026-11-08 15:13:09 +09:00
TheApple05andCodex GPT-6 911bab7e0f Preserve resource-pack parity paths with JSON headers
Co-Authored-By: Codex GPT-6 <[email protected]>
2026-11-08 06:11:54 +00:00
Ludovic Marie 22e6e5c8a4 Merge pull request #12242 from NikitaMGrimm/entity-own-random
🤖 Agent: A new item's own random now makes its UUID (Mth.createInsecureUUID, the first two draws), then bobOffs, yaw and motion in that order, instead of a process-wide clock-seeded UUID; I merged main (the seed-sync gaps diagnostic this PR retires stays out).
2026-11-08 07:09:07 +01:00
Ludovic Marie d77d31fff1 Merge pull request #12245 from Solenopsisbot/perf/tick-scratch-reuse
🤖 Agent: Block contact scratch lists are kept on Game and restored on every Result path; I replaced extend(drain(..)) with append, the clippy error that failed verify (clippy -D warnings passes now).
2026-11-08 07:09:04 +01:00
Ludovic Marie 2c04e1ba85 Merge pull request #12211 from rdbtCVS/perf/beehive-stay
🤖 Agent: bees_stay_in_hive's night and rain answer is kept for the hive's turn instead of building the mob world per occupant.
2026-11-08 07:09:00 +01:00
Nikita Maximilian Grimm edddce4485 Merge remote-tracking branch 'origin/main' into warden-digging-test 2026-11-08 07:08:38 +01:00
Horizon-agent 030e7e6ff6 Merge commit '02ff63cf4bc4f243391974eb957afa247f4c5a01' into HEAD 2026-11-08 07:05:41 +01:00
masa-masa-0314andZCode 32cc9c56e0 Realms: Generate New World opens Create World and uploads what it makes
`RealmsResetWorldScreen`'s Generate New World tile is enabled: it opens the Create
New World screen (`RealmsCreateWorldFlow.createWorld`), and its Create builds the
temporary world the upload packs instead of entering a local one.

- The tile returns the Realm, slot and reset kind to the title, which shows Create New
  World with the default options. Create (`create_or_upload`) builds a `Level` from
  those options (name, seed, game type, difficulty, cheats, game rules, feature flags
  and data packs) and hands it back to the Realms screen; Back/Escape returns to the
  configuration screen (or the list for a new Realm).
- `realms::create_temporary_world` mirrors `createTemporaryWorldFolder`: a temporary
  folder with level.dat from `WorldData.createTag(null)` (no `singleplayer_uuid`), the
  world generation and game rules, and the Create World screen's data packs moved into
  `datapacks/`. No chunks: the Realm generates them.
- The upload runs the same `RealmCreationTask` → `SwitchSlotTask` → `packAndUpload`
  chain as a local-world upload, with `RealmsWorldOptions.createFromSettings` (slot
  name, game mode, difficulty, the game's version) and the hardcore setting. While it
  runs `AlertScreen` (`mco.create.world.reset.title`) shows a Cancel; success returns
  to the configuration screen, or plays the Realm just created
  (`RealmsMainScreen.play`); cancel returns to the reset screen; a failure shows
  `mco.create.world.failed`.
- `Level::write_upload` writes only the upload's files (no player file, weather or
  clocks), with `singleplayer_uuid` omitted as `createTag(null)` writes it.

Co-Authored-By: ZCode <[email protected]>
2026-11-08 14:05:35 +08:00
Horizon-agent 02ff63cf4b Merge commit '1cccd4167d8525b125ac6cc74f0dcc235683e767' into HEAD 2026-11-08 07:04:51 +01:00
Ludovic Marie 6ebe4a33c3 Merge pull request #11867 from MrCloudy2/fix/passengers-players
🤖 Agent: `execute on passengers` finds the players riding a vehicle on a server (the player in place, then the hub guests by their vehicle); I merged main, whose new mob-children arm now follows this PR's player_passengers, so both players and mob riders are found.
2026-11-08 07:04:32 +01:00
Horizon-agent 1cccd4167d Merge commit '849c2915611feced73975c8310f5d5f603f747af' into HEAD 2026-11-08 07:03:58 +01:00
Horizon-agent 849c291561 Merge commit 'ca441c3ea06bbff7c2cae41cd4b3f0cf3ea88813' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 07:03:46 +01:00
Horizon-agent ca441c3ea0 Merge commit '5ee77de8c82449a4830f716a1be8d7553fdd65d4' into HEAD 2026-11-08 07:02:48 +01:00
martipopsandClaude Opus 5.5 dba8453681 Settings: Left and Right step a focused choice back and on
On the settings shell (Extras, Graphics), a value between `<` `>` could
only be stepped back with Shift-click or, with an Extras setting on, the
wheel: a pad or keyboard player could only go forward. Left and Right on a
focused choice now step it back and on, as its arrows show, from the D-pad
and the arrow keys alike. They are a Shift press and a press, the same path
as a click, so Undo and saving follow.

They step at once rather than after A arms the row, as sliders do: A keeps
its step forward and there is no mode to find, and up and down passing over
a choice never change it. Up and down leave the row, and LB and RB reach the
page list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:02:15 -05:00
Horizon-agent 5ee77de8c8 Merge commit '35ab3f27b058be561260e09d9676d289cde52565' into HEAD 2026-11-08 07:01:55 +01:00
voidsip ba5f08c10c Keep respawn fallback and spawn rotations consistent with world data 2026-11-08 00:01:37 -06:00
Horizon-agent 35ab3f27b0 Merge commit 'ed1d96c9117c54ea7a6d74556f34fa08d05aeb8a' into HEAD 2026-11-08 07:00:52 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 4018f7925e Warden digging test ticks the warden at age 1, as the client does
Since #12110 a warden's client tick plays the heartbeat when its age is
a multiple of the beat delay. The test ticked a new warden at age 0, so
it heard a heartbeat. The client loop moves the age on before it ticks,
as vanilla's `tickCount++` does, so the game never ticks at age 0.

Fixes #12312

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 07:00:07 +01:00
Horizon-agent ed1d96c911 Merge commit 'd7c560ec78d66a2c022a494be7c084f5aa7dfad9' into HEAD 2026-11-08 06:59:58 +01:00
Horizon-agent d7c560ec78 Merge commit 'dc41d4bc93996ede221a19266f924b30f683e39b' into HEAD 2026-11-08 06:59:13 +01:00
Ludovic Marie cbb2b99022 Merge pull request #12285 from voidsipp/fix/round6-12201
🤖 Agent: An export that fails on a missing lib/tzdb.dat now names the Java to repair, matched only on the FileNotFound/NoSuchFile line for that exact path; other failures keep their message.
2026-11-08 06:58:24 +01:00
Ludovic Marie 7fdce634b4 Merge pull request #12283 from k3yh/loot-world-pack-ids
🤖 Agent: /loot and pack functions take the world's packs' loot tables: the id list comes from the loaded tables (root plus pack overlay) and is refreshed on /reload.
2026-11-08 06:58:20 +01:00
Horizon-agent dc41d4bc93 Merge commit '826fdf6306a88ad931520b0a9f34801675b76660' into HEAD 2026-11-08 06:57:09 +01:00
Horizon-agent 826fdf6306 Merge commit '1c878671de71a6827708ed1eb51141b32da22d2a' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 06:56:51 +01:00
Horizon-agent 1c878671de Merge commit '414fcee500187355e0a27c64819b2d9823a93a3f' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
#	tools/test_command_exec_parity.py
2026-11-08 06:56:24 +01:00
Ludovic Marie 7d084fc8aa Merge pull request #12282 from NikitaMGrimm/hdr-write-light
🤖 Agent: On the float frame every shader writes its own light; all of it sits behind the HDR_WRITE_LIGHT pipeline override, false on the default frame, so the SDR path compiles it out. Stacked on #12220 and #12247.
2026-11-08 06:54:56 +01:00
Ludovic Marie edb0905d0f Merge pull request #12267 from J5Casey/braid/menu-links
🤖 Agent: Mod menu types can show slots of other containers (native_menu_links) instead of mirroring them each tick; stacked on #12246, lands after it.
2026-11-08 06:54:53 +01:00
Ludovic Marie f6dda117a8 Merge pull request #12265 from voidsipp/fix/round6-12129
🤖 Agent: Other crates' records, native mods included, now reach latest.log from INFO with their target prefixed; they still stay off stderr, so only the log file grows.
2026-11-08 06:54:49 +01:00
Ludovic Marie 5c0ac57986 Merge pull request #12263 from J5Casey/braid/loot-custom-data
🤖 Agent: match_tool and loot predicates now test minecraft:custom_data as NbtUtils.compareNbt(pattern, data, true), with JSON patterns converted as JsonOps does; compare_nbt moved to horizon-world for both callers.
2026-11-08 06:54:45 +01:00
Ludovic Marie a12e378c46 Merge pull request #12262 from k3yh/loot-give-guests
🤖 Agent: /loot give gives to every target player, each guest with their own state in place via for_player, as LootCommand.playerGive does.
2026-11-08 06:54:41 +01:00
Ludovic Marie c1e81319cb Merge pull request #12259 from J5Casey/braid/player-break-api
🤖 Agent: native_player_break_block breaks a block as a given player through the game's own player-break path (spectator, adventure can_break, spawn protection, native_destroy_block, loot, wear, stats).
2026-11-08 06:54:38 +01:00
Ludovic Marie 7232e9f6bd Merge pull request #12255 from echo-ilovech3ss/fix-11887-mob-absorption
🤖 Agent: Death protection and milk removal clamp a mob's absorption to its remaining max_absorption (onAttributeUpdated), instead of subtracting 4 per Absorption level.
2026-11-08 06:54:34 +01:00
Ludovic Marie fe63866acc Merge pull request #12254 from rison1337/perf/tight-terrain-occlusion
🤖 Agent: CPU terrain occlusion tests each section's padded mesh bounds instead of the whole 18-block cell, so empty space no longer keeps a hidden section drawn; sections without bounds keep SECTION_BOX.
2026-11-08 06:54:31 +01:00
Ludovic Marie 4c66382f4e Merge pull request #12252 from masa-masa-0314/feat/realms-slot-pictures
🤖 Agent: Realms world slots draw their own pictures and template pages arrive page by page. Cost to note: the four 1024-tall slot pictures now live in the HUD atlas for every player, about one 1024-tall shelf of GPU memory; a follow-up should load them only while Realms screens are open.
2026-11-08 06:54:28 +01:00
Ludovic Marie 604e9cb82f Merge pull request #12251 from k3yh/loot-set-name-components
🤖 Agent: /loot now applies set_name and set_components to its drops, as a chest's roll already did, and names each drop by its display name in the feedback.
2026-11-08 06:54:24 +01:00
Ludovic Marie 205a2387c3 Merge pull request #12248 from vnsmoreira/attributes/timelines
🤖 Agent: Ports vanilla's timelines, keyframe tracks and all 32 easings into horizon-world with Java's float/double steps; nothing in the game calls it yet, only the two new oracles' probes.
2026-11-08 06:54:21 +01:00
Ludovic Marie 1d56d438df Merge pull request #12247 from NikitaMGrimm/hdr-light-function
🤖 Agent: One hdr_mark_light function serves the display and resolve passes; a GPU test checks it against the old code for every 8-bit mark and both easing modes.
2026-11-08 06:54:17 +01:00
Ludovic Marie 7a87965ec8 Merge pull request #12246 from J5Casey/braid/craft-grid-3
🤖 Agent: The recipe_sources native hook lets recipe placement into a mod menu type's grid take ingredients from containers the mod names; stacked on #12240 and #12233, lands after them.
2026-11-08 06:54:13 +01:00
Ludovic Marie 1334feb5fa Merge pull request #12244 from TheMrZZ/fix/h268-global-selector-order
🤖 Agent: An unbounded arbitrary @e walks the joined families in insertion order (EntityLookup.getEntities), falling back to the old order if the walk fails; it builds one count map per such query, other selectors keep their path.
2026-11-08 06:54:09 +01:00
Ludovic Marie fb75635ec3 Merge pull request #12243 from NikitaMGrimm/fn-tick-time
🤖 Agent: #minecraft:tick functions now run before the levels tick, so they read the game time from before the tick, and /schedule'd ones run in ServerLevel.tickTime once the clock has moved, as MinecraftServer.tickChildren orders them.
2026-11-08 06:54:06 +01:00
J5CaseyandClaude Opus 5.5 b1a75237d0 Native hook: fishing_medium, a bobber that floats and fishes outside water
A mod answers `native_fishing_medium(dimension, hook, position, owner, medium)`
for a bobber that is flying or floating, not in water and not hooked to an
entity. `Some(NativeFishingMedium)` makes the spot a medium: in the block of
its `surface` or below, the bobber floats, waits, bites and is reeled in as
in still water; the catch rolls its `loot_table` (vanilla's
`minecraft:gameplay/fishing` when None) and `lure_ticks` replaces vanilla's
100 to 600 tick wait when set. It is asked on the server and on the clients
that draw the bobber, so both move it alike. No answer keeps vanilla, and
water is never asked about, so vanilla fishing is unchanged.

`horizon-ctl status` shows the hook's loot table. Fixes #12300.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KtNXhvTSpY15Rjzwuqh8Nf
2026-11-07 23:53:12 -06:00
Horizon-agent 414fcee500 Merge commit '2d29c7f8e954fad2e3eafa4c18c35b4a1147c807' into HEAD 2026-11-08 06:53:10 +01:00
Horizon agent af4a313bc7 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/test_command_exec_parity.py
2026-11-08 06:51:10 +01:00
Horizon agentandClaude Opus 5.5 9b0c6f48ea Drop the second passengers arm left by the main merge
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:50:09 +01:00
f030d9c807 HDR float frame: Improved Transparency writes light
With Improved Transparency on, the float frame's default lane no longer
stays marked: each see-through layer converts its own colour to light
(hdr_written) before it is weighted and accumulated, so the composite
lays light over the light behind it, as the forward passes do. Text,
shadows, weather and the border keep their source gain, as they do in
the forward passes; cracks keep their multiply blend outside the
accumulation, since it scales the light under them. Only a shader pack
keeps the frame marked now. The identity harness's float OIT session is
no longer an identity case; Improved Transparency with HDR off and on
the 16-bit frame are, and fail unless the option changed the picture.

Co-Authored-By: GPT 6.1 Sol <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:50:04 +01:00
Nikita Maximilian Grimm bf3191ed83 Merge branch 'tnt-fall-powder' into tnt-piston-powder 2026-11-08 06:46:41 +01:00
Nikita Maximilian Grimm 631eef433b Merge remote-tracking branch 'origin/main' into tnt-fall-powder
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 06:46:31 +01:00
SolenopsisbotandCodex 7ba6d345b0 perf: reuse decoration shape capture
Retain captured shape-update ticks across decoration queries while preserving ordering and error propagation.

Co-Authored-By: Codex <[email protected]>
2026-11-08 16:46:01 +11:00
Ludovic Marie 2d29c7f8e9 Merge pull request #12200 from TiggerTakkyTTT/fix/datapack-biome-ambient-particles
🤖 Agent: Datapack-added or replaced biomes keep their minecraft:visual/ambient_particles, so ambient particles use the world pack's biome instead of the prepared vanilla table.
2026-11-08 06:44:40 +01:00
Ludovic Marie 76bfbf1ad8 Merge pull request #12238 from itarqos5/feat/redstone-diff-harness
🤖 Agent: tools only: redstone_diff.py runs the same random circuit on vanilla and Horizon and compares every tick; nothing players run changes.
2026-11-08 06:44:36 +01:00
Horizon agent f62c4b546e Merge commit 'ff0ca9ba176d9a12a9d2d0fbf540446942315988' into HEAD 2026-11-08 06:41:09 +01:00
Horizon agent ff0ca9ba17 Merge commit 'c60ed93aff' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 06:40:57 +01:00
Horizon agentandClaude Opus 5.5 c60ed93aff Drop the duplicated orb_data_tests module line from the stack merge
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:37:45 +01:00
Arthur BlackandClaude Opus 5.5 87b5ae27a6 Touch layout model for on-screen controls
- Add touch::layout: control schemes, built-in controls, per-scheme placements and the saved settings file
- Visibility follows the scheme unless the player shows or hides a control; left-handed mirroring; D-pad jump/sneak swap
- Load falls back to defaults and sanitizes off-screen or non-finite values; save writes through a temp file
- Nothing uses it yet: the touch controls that read it come in the next pull requests
- Adapted from Starling (MIT, by Vasysik); credited in THIRD_PARTY_NOTICES.md

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-11-07 21:33:35 -08:00
voidsip 28acf8303c Exercise the title submenu control through debug keys 2026-11-07 23:32:55 -06:00
LokiandAntigravity 0538f95dd8 lan: clamp mob health and refresh max_health on effect changes (fixes #11854)
Co-Authored-By: Antigravity <[email protected]>
2026-11-08 14:32:01 +09:00
Horizon agentandClaude Opus 5.5 8f6ef43b0d Sort the test modules (rustfmt)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:32:00 +01:00
Horizon agent 8ee2a1ab6a Merge commit '13217d3b4c0bbaf153871a85477b4010e83ad1f5' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 06:30:06 +01:00
Horizon agentandClaude Opus 5.5 13217d3b4c Sort the test modules after the main merge (rustfmt)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:29:53 +01:00
Ludovic Marie 2a66276bcc Merge pull request #12232 from Solenopsisbot/perf/defaults-ticket-fastpath
🤖 Agent: perf: unchanged ticket sources skip renormalisation, and item defaults load once per root; I fixed the fast path to compare the dragon arena too (it broke the watched-dragon-arena test).
2026-11-08 06:29:15 +01:00
Horizon agent 82ed0f3ac8 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
#	tools/test_command_exec_parity.py
2026-11-08 06:29:14 +01:00
Ludovic Marie 38f9ce31e7 Merge pull request #12210 from rdbtCVS/perf/streaming-cover
🤖 Agent: update records that the cover was refreshed at its start, so each waiting chunk no longer compares the ~200-entry extra areas list every tick.
2026-11-08 06:29:11 +01:00
Horizon agentandClaude Opus 5.5 67f84002d3 redstone_diff: start the game through lab.game_env
tests/test_game_home.py requires every script that starts the game to use it
(scratch folders, no audio) instead of setting HORIZON_NO_AUDIO by hand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:28:25 +01:00
Horizon agentandClaude Opus 5.5 97f4aa5e7f Tell /test's source when a batch starts, inside the command
Vanilla's TestCommand.trackAndStartRunner adds a TestBatchSummaryDisplayer
holding the command's source; GameTestRunner.start runs the first batch
inside the command, and testBatchStarting sends
"Starting environment <env> batch <n>" with sendSuccess(.., true). Horizon
queued the line as a server console broadcast for the next tick, so `/test
run` answered only "Running 1 test(s)..." (world_test_def 94/96,
world_test_def_lifecycle 6 of its 10 differing records, as #11992 noted).

A runner a command starts now sends the line through that command's source
while the command runs (`feedback`). A test instance block's runner keeps the
server's source (TestInstanceBlockEntity.runTest), as do later batches, which
start from the tick.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:28:23 +01:00
Horizon agentandClaude Opus 5.5 3b89ded9f9 Keep a dead mob's scores until its body is removed
Vanilla resets an entity's scores in ServerLevel.EntityCallbacks.onDestroyed
(Scoreboard.entityRemoved), when the entity is removed for good: a mob's body
twenty ticks after LivingEntity.die, never when it is unloaded. Horizon reset
them in mob_died, at the death. A mob killed in a frozen world and then
unloaded kept its scores in vanilla and lost them here, so a later
`/scoreboard players list` named 32 fewer holders (command_exec, after
#12185's shulker command damage case).

mob_died no longer resets them; score_destroyed_entities already resets every
removed entity's scores once a tick, and keeps an unloaded one's.

#12185's 32 shulkers had random UUIDs, which that list then named: Java and
Horizon could never print the same list. The case now gives them fixed
UUIDs, so the record is exact again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:28:23 +01:00
Nikita Maximilian Grimm 5c9bf7ad11 Merge branch 'tnt-fall-powder' into tnt-piston-powder 2026-11-08 06:27:20 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 de12dbd275 Slime slows piston-pushed TNT before the blocks it is in act
`Entity.applyEffectsFromBlocks` runs the supporting block's `stepOn`
before the blocks the entity is inside, so slime slows TNT before a
bubble column beside it lifts it. TNT's own tick had them the other
way round, and the piston push shares the same steps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:27:20 +01:00
J5CaseyandClaude Opus 5.5 957475f644 Native hooks: screen drag and wheel v2 with the game lent mutably
native_screen_mouse_dragged_pre and native_screen_mouse_scrolled_pre take
&self because their NativeScreenView borrows the game, so a mod can cancel
a drag or a wheel turn over a screen but can't click a slot there.
Mouse Tweaks-style mods (Mouse Tricks) inject into the private
inventory_drag_move and tweak_scroll instead and pin one Horizon commit.

Add native_screen_mouse_dragged_pre_v2 and
native_screen_mouse_scrolled_pre_v2 with &mut Game: the view's id and
pointer come by value, the rest as v1's. Each fires at v1's point, just
before v1, which hears the screen as v2 left it and nothing of an input
v2 canceled. Cancelling does what cancelling v1 does. v1 is unchanged.

Fragment tools/native-hook-fragments/screen_mouse_input_v2.json; native
bodies filled by `cargo run -p xtask -- mod-api`.

Fixes #12286

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KtNXhvTSpY15Rjzwuqh8Nf
2026-11-07 23:26:15 -06:00
Horizon agentandClaude Opus 5.5 33e0bf2aec Use append for the later cells (clippy::extend_with_drain)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:26:10 +01:00
Horizon agent dca25b7662 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 06:26:10 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 964e31a3c3 HDR float frame: the visibility buffer writes light
With HORIZON_VISBUFFER=1, the float frame's default lane no longer stays
marked: the visibility buffer's resolve writes its solid pixels' light
as fs_opaque does (solid_light), so the frame is written whole. The
identity harness's float visbuffer session is no longer an identity
case; the visibility buffer with HDR off and on the 16-bit frame are,
drawn flat so that the buffer runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:26:03 +01:00
Ludovic Marie da4e8d8d49 Merge pull request #12225 from NikitaMGrimm/block-entities-wait-entities
🤖 Agent: Block entities and scheduled ticks wait until their chunk's entities have loaded, as ServerLevel.isPositionTickingWithEntitiesLoaded gates them; the entities_pending set is cloned once per call.
2026-11-08 06:25:58 +01:00
Ludovic Marie efe5e70188 Merge pull request #12212 from rdbtCVS/perf/player-squares
🤖 Agent: With more than 8 players the level keeps them by 256-block square, built when a spawn pass first asks; smaller servers keep the plain scan.
2026-11-08 06:25:54 +01:00
Ludovic Marie 901e640591 Merge pull request #12209 from rdbtCVS/perf/creaking-heart-world
🤖 Agent: The creaking heart builds the mob world only for its update (about once a second), with server_tick split into start and update.
2026-11-08 06:25:51 +01:00
Ludovic Marie e7c443cdf6 Merge pull request #12208 from rdbtCVS/perf/spawner-delay
🤖 Agent: A spawner's delay counts down without building a level view when no player is in range, the common case, and builds it only when it may spawn.
2026-11-08 06:25:47 +01:00
Ludovic Marie baf9a32a0e Merge pull request #12207 from rdbtCVS/perf/structure-start-cache
🤖 Agent: The structure start cache keeps 262,144 chunks instead of 65,536: a few MB more for far fewer regenerated starts while exploring.
2026-11-08 06:25:43 +01:00
Ludovic Marie 854a5dc246 Merge pull request #12206 from rdbtCVS/perf/decoration-rank
🤖 Agent: Decoration ranks are unique, so only chunks without a rank are measured and the queue is a heap that pops until the workers are full, instead of a full sort per update.
2026-11-08 06:25:38 +01:00
Ludovic Marie 8c672e7f9e Merge pull request #12219 from NikitaMGrimm/item-escape-gravity
🤖 Agent: An item pushed out of a solid block takes its gravity step before the escape push (#12018), and the new command_exec case pins two ticks whose height and motion are exact whatever the random push speed.
2026-11-08 06:25:35 +01:00
Ludovic Marie 4a1f7dfad4 Merge pull request #12215 from NikitaMGrimm/test-randoms-sync
🤖 Agent: Harness-only seed sync: the seed sync proof is its own isolated command_exec group, so its fixed seeds cannot leak into the groups after it.
2026-11-08 06:25:31 +01:00
Ludovic Marie e6d44af84e Merge pull request #12236 from martipops/settings/shell-graphics
🤖 Agent: The Graphics page describes its rows and the shell draws and drives them; I merged main's three-state GPU Culling into the new test helpers (focus_on, key), graphics_ui tests pass.
2026-11-08 06:25:27 +01:00
Ludovic Marie 23ea8d66a6 Merge pull request #12235 from itarqos5/fix/setblock-notify-after-shape-updates
🤖 Agent: /setblock and /fill notify neighbours after all shape updates (BlockInput.place, ServerLevel.updateNeighboursOnBlockSet), so a wire beside a block that pops off ends as a cross; I merged main (fill's note-block normalisation kept) and marked the two resource-backed tests #[ignore], as the other HORIZON_TEST_RESOURCES tests are, since CI has no resources.
2026-11-08 06:25:24 +01:00
Nikita Maximilian Grimm 8abbc6b9e4 Merge remote-tracking branch 'origin/main' into tnt-fall-powder 2026-11-08 06:23:27 +01:00
voidsip f2fe9c1dfe Keep title submenu debug-options handling unchanged 2026-11-07 23:22:01 -06:00
Nikita Maximilian GrimmandClaude Opus 5.5 6a11db7ef7 Frame identity harness: the float visibility buffer session draws flat
The visibility buffer draws only frames drawn flat, which frames without
a pack are by default only on Metal and some Intel drivers, so elsewhere
float_visbuffer compared the forward passes. It now sets
HORIZON_FLAT_DRAWS=1 and fails unless the game built the buffer. The
module docs list the sessions added on this branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:19:47 +01:00
voidsip 7a5d306949 Show title-screen debug information and options 2026-11-07 23:19:38 -06:00
Nikita Maximilian GrimmandClaude Opus 5.5 66d06e23f7 A spent piston push still applies TNT's block effects
Once `limitPistonMovement` has used the tick's 0.51, `Entity.move`
returns at once, but `moveEntityByPiston` still runs
`applyEffectsFromBlocks`, so a second piston's push still lets slime
under the TNT slow it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 06:18:11 +01:00
voidsip 417677fdda Match cauldron contact tolerances and repeated damage callbacks 2026-11-07 23:15:03 -06:00
k3yhandClaude Opus 5.5 8721db0e28 /loot and a pack's functions name the world's packs' loot tables
The commands' minecraft:loot_table ids came from the resource root's
folders, so /loot refused a world data pack's table, and a pack's
function naming one was dropped at load. ResourceOrIdArgument looks the
id up in the server's registries, which hold the world's packs. The ids
are now the world's loot table map (Items::loot_table_ids): set when the
world opens and again before admit_store parses the packs' functions.

New command corpus group: loot world pack tables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:09:20 -05:00
masa-masa-0314andZCode 96f8110001 Worlds: the single-player owner is the account's UUID, old worlds migrate
`IntegratedServer`'s constructor sets `setSingleplayerProfile(minecraft.getGameProfile())`,
and `ServerLoginPacketListenerImpl.handleHello` gives a login whose name matches that
profile the profile itself; the local memory hello names the account's profile id
(`Minecraft.handleClientLogin`'s `ServerboundHelloPacket(getUser().getName(),
getUser().getProfileId())`). The integrated server's owner, its gate/op entry and its
login are now the account's UUID; an offline start keeps the offline profile.

`MinecraftServer.saveAllChunks` saves with `saveDataTag(worldData,
getSingleplayerProfile().id())`: level.dat's `singleplayer_uuid` follows the owner on
every save. A world without one (a Realms download; `FileDownload.untarGzipArchive`
drops it) then loads the owner's `players/data/<account uuid>.dat` instead of starting
a new player.

Worlds older Horizon builds made name their player by the offline UUID everywhere:
level.dat's `singleplayer_uuid`, the player file and its `UUID`, and entity references
(`TamableAnimal`/`AbstractHorse`/`Projectile`/`AreaEffectCloud`/`EvokerFangs` `Owner`,
`ItemEntity`'s `Owner`/`Thrower`, `Fox`'s `Trusted`, `NeutralMob`'s `angry_at`,
`Leashable`'s `leash.UUID`). The first open under the account moves the player file to
the account's UUID (the newer of the two when both exist), rewrites level.dat before the
first session save, and rewrites each entity as its chunk loads, so the next save keeps
the account's UUID. A world renamed since it was made stays as it is: the old name its
offline UUID came from is not stored, so it cannot be identified.

Co-Authored-By: ZCode <[email protected]>
2026-11-08 13:06:42 +08:00
Nikita Maximilian Grimm 89d7b8e65b Merge remote-tracking branch 'origin/main' into portal-ticket-persistence 2026-11-08 06:03:18 +01:00
Nikita Maximilian Grimm 190c17fc7a Merge branch 'tnt-fall-powder' into tnt-piston-powder 2026-11-08 06:01:36 +01:00
Ludovic Marie 9e1abc64d1 Merge pull request #12169 from abit-foggy/codex/studio-c1-c2-topbar-timeline
🤖 Agent: Studio's top bar and timeline are Horizon-only and off unless Studio is opened; the only gameplay touch is the fov/play_input hooks, which read the new state only while Studio is open.
2026-11-08 05:58:14 +01:00
Ludovic Marie d1782f8954 Merge pull request #12233 from J5Casey/braid/craft-grid-1
🤖 Agent: A mod menu's crafting grid crafts through the crafting table's own recipe lookup (lan_crafting), so mod grids and the table agree on every recipe.
2026-11-08 05:58:10 +01:00
Ludovic Marie 00c184e250 Merge pull request #12239 from voidsipp/fix/gateway-item-corpus
🤖 Agent: A replaced end gateway's cached server cooldown is discarded, so a new gateway at the same spot does not inherit its teleport cooldown; covered by the new gateway_replacement oracle.
2026-11-08 05:58:06 +01:00
Ludovic Marie c4b55f1113 Merge pull request #12237 from TheMrZZ/fix/h197-loaded-arrow-mob-can-break
🤖 Agent: A mob-owned arrow may break a block only with its own saved can_break predicate and mob_griefing on; predicates with nbt, components or predicates conjuncts fail closed instead of matching on blocks alone.
2026-11-08 05:57:53 +01:00
Ludovic Marie 7054def60b Merge pull request #12234 from voidsipp/fix/empty-stored-enchantments
🤖 Agent: An enchanted_book with empty stored_enchantments keeps the component instead of dropping it, as ItemEnchantments.EMPTY still saves.
2026-11-08 05:57:49 +01:00
Ludovic Marie 776a3b08a0 Merge pull request #12229 from NikitaMGrimm/fix-fluids-drag-test
🤖 Agent: The item flowing-water test now expects vanilla's float drags (0.98F/0.8F widened to double), the values Entity.handleFluid really produces.
2026-11-08 05:57:45 +01:00
Horizon agent f79643821e Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 05:57:41 +01:00
Ludovic Marie 3b52978005 Merge pull request #12224 from Solenopsisbot/perf/hotpath-microalloc
🤖 Agent: Rebased onto main: the hot-path buffers (command args, protocol buf, redstone, json folder) are reused instead of reallocated, with the args tests covering the reused path.
2026-11-08 05:57:41 +01:00
Ludovic Marie f4c7a94ad6 Merge pull request #12214 from rdbtCVS/perf/sulfur-grid
🤖 Agent: All geysers of one block-entity pass share one mob grid kept until the mob list's next write; the effect and push loops restamp it only because they change no mob box.
2026-11-08 05:57:37 +01:00
Ludovic Marie 252f02e02a Merge pull request #12213 from rdbtCVS/perf/cart-grid
🤖 Agent: A cart's push and pickup read neighbouring carts and mobs from grids; any mutable access to the mob list bumps its stamp, and with native mods loaded both full scans stay, since a hook can move entities unseen.
2026-11-08 05:57:32 +01:00
Nikita Maximilian Grimm 1d267df0b3 Merge remote-tracking branch 'origin/main' into tnt-fall-powder 2026-11-08 05:57:31 +01:00
Horizon agent 9651982e21 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 05:57:28 +01:00
Ludovic Marie 3e3a0ffa10 Merge pull request #12216 from rdbtCVS/fix/guest-hit-mob
🤖 Agent: A guest's effect and sting hits now credit the mob that swung, matching LivingEntity.hurtServer's attacker; stacked on #12204, lands after it.
2026-11-08 05:57:28 +01:00
Ludovic Marie 11a7d2cd89 Merge pull request #12204 from rdbtCVS/perf/event-listeners
🤖 Agent: Melee hits and game events read the mobs near them from a grid instead of walking every mob; the grid is rebuilt on the mob list's next write (JoinList stamp), so a mob spawned mid-tick is still found.
2026-11-08 05:57:25 +01:00
Horizon agent 2415fb9e91 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/commands/execute.rs
#	tools/lan_e2e.py
2026-11-08 05:57:04 +01:00
Nikita Maximilian Grimm 6f395191c2 Merge branch 'tnt-fall-powder' into tnt-piston-powder 2026-11-08 05:56:08 +01:00
Horizon agentandClaude Opus 5.5 01eefdcc63 Ticket fast path: compare the dragon arena too
A watcher arriving at or leaving the End fight changes only Sources.dragon;
the unchanged-sources skip ignored it, so the arena never got (or lost) its
TicketType.DRAGON levels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:56:02 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 0f69036171 Stream restored portal tickets' chunks during the startup wait
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:56:00 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 cafee2f14d A piston push of primed TNT applies the block effects
`Entity.move(MoverType.PISTON)` uses up TNT's pending stuck multiplier
(without scaling the push), reads its fall for powder snow's top, adds
to that fall and resets it on landing, and applies the block speed
factor. `moveEntityByPiston` then runs `applyEffectsFromBlocks`, so
powder snow it is pushed into makes it stuck, and slime under it slows
it. Horizon did none of this, so in a chunk that does not tick
entities pushed TNT kept its motion in powder snow and on soul sand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:55:41 +01:00
voidsip 2ed136b137 Keep LAN default-spawn packets tied to the world spawn 2026-11-07 22:55:02 -06:00
Horizon agent e299e931f5 Merge commit '4cbca5702609168ee27fff1645b29b5fa196a974' into HEAD
# Conflicts:
#	tools/test_command_exec_parity.py
2026-11-08 05:54:38 +01:00
Horizon agent 4cbca57026 Merge commit '183513311337bd8c4d95f9f915f03084b58534c5' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 05:54:33 +01:00
Horizon agent 1835133113 Merge commit '1d533463ca8f620c87474a32d1f817e4c4f5489c' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 05:54:25 +01:00
Horizon agent 1d533463ca Merge commit '87dfb297ef73a16d1967e981f4732fda1c5cc0e2' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 05:54:15 +01:00
Horizon agentandClaude Opus 5.5 87dfb297ef Sort the test modules (rustfmt)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:54:04 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 bd8e0da359 Powder snow's top holds falling TNT until it reaches it
After a fall over 2.5, `PowderSnowBlock.getEntityInsideCollisionShape`
is the 0.9-high top, so the snow only makes the TNT stuck once a step
reaches that top. A TNT passing 2.5 just above the snow used to be made
stuck early, lose its fall and sink through.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:53:44 +01:00
J5CaseyandClaude Opus 5.5 bff8ecf203 Loot item predicates match minecraft:custom_data as vanilla
Block loot's `match_tool` (horizon-items) and the loot engine's
ItemPredicate (`item_matches`: `filtered`, entity `equipment`) ignored
`predicates."minecraft:custom_data"`, so any stack passed. They now test
it as `CustomDataPredicate` does (NbtPredicate.matches ->
CustomData.matchedBy -> NbtUtils.compareNbt(pattern, data, true)): a typed
NBT subset, lists matched element by element, absent custom data read as
`{}`, the pattern SNBT or a JSON object converted as DataFixerUpper does.

`compare_nbt` moves down to horizon-world (re-exported from nbt_path) so
the loot engine can use it, and a killer's equipment keeps its custom data
for entity loot predicates.

New harness loot_custom_data: a data pack's dirt table with a pool per
pattern behind match_tool, `loot give @s mine` with sticks carrying
different custom data, 66/66 records equal to vanilla. The loot engine's
`filtered` path gets the same vanilla matrix as a horizon-world test.

Fixes #12196

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KtNXhvTSpY15Rjzwuqh8Nf
2026-11-07 22:47:46 -06:00
k3yhandClaude Opus 5.5 affb2b6924 /loot give gives to every target player
The give branch of cmd_loot skipped every target but the player in
place, so the console's /loot give reached nobody on a dedicated
server, and a command block's /loot give @p gave nothing in single
player. Each target now goes through for_player, as cmd_give does
(LootCommand.playerGive gives to every target ServerPlayer).

New lan_e2e check: loot_give_guest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:45:11 -05:00
J5CaseyandClaude Opus 5.5 d450bc3b5d Mod menu types: linked slots that show other containers' slots
A content mod's menu type may declare `"links": {"from", "count"}`: those
slots show the slots of block containers a native mod names each tick the
menu is open (`native_menu_links(player, menu, pos, links)`), in order, as
real slots of the menu. Clicks, shift-clicks and drags run on the server's
menu engine and move the containers' own items, a changed container is
saved and its comparators update, and the block entity never holds the
linked slots. Linked slots with nothing behind them hold nothing and are
left out of clicks, as a hidden slot is.

This is what a crafting station's side panel needs (Tinkers' Construct's
shows the chest beside it); a tab per neighbour is a menu button that
changes what the mod links for that player.

Part of #12198.

Claude-Session: https://claude.ai/code/session_01KtNXhvTSpY15Rjzwuqh8Nf
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 22:44:11 -06:00
voidsip 45d46d46f4 Keep the panorama behind server configuration dialogs 2026-11-07 22:37:41 -06:00
voidsip 3ac68d69d3 Keep option button cursors tied to pointer hover 2026-11-07 22:34:17 -06:00
Shreyas 22c6c667a2 Clamp a mob's absorption to maximum on death protection and milk removal 2026-11-08 10:00:00 +05:30
Horizon agent 4635eed508 Merge commit '01c1e661687793318d5487918b18ae4dfc5b05c7' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 05:29:11 +01:00
Horizon agent 01c1e66168 Merge commit 'c7fc1c994f9569dc99674cdc40522f2b25826697' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
#	tools/test_command_exec_parity.py
2026-11-08 05:29:07 +01:00
Horizon agent c7fc1c994f Merge commit '4eba8a6991243314c98098e99f32ea0a929e387c' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
#	tools/test_command_exec_parity.py
2026-11-08 05:29:04 +01:00
Horizon agent 4eba8a6991 Merge commit '01fcfc484950ac5a1417be5b5f82488184a7785e' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
#	tools/test_command_exec_parity.py
2026-11-08 05:29:01 +01:00
Horizon agent 01fcfc4849 Merge commit '13dc865c9a591265d0a2d12bbd2845f813a6642a' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
#	tools/test_command_exec_parity.py
2026-11-08 05:28:51 +01:00
AkirabaneandClaude Opus 5.5 391da75bf3 Riders turn like vanilla's: vehicle body only where vanilla copies it
position_riders gave every mob rider of a mob its vehicle's body yaw each
tick. 26.3 does so only in AbstractHorse.positionRider and
Chicken.positionRider, and in AbstractSkeleton.rideTick and Drowned.rideTick
for a rider steering a PathfinderMob; any other rider's body turns on its
own. A rider of a living vehicle is drawn by LivingEntityRenderer.solveBodyRot
from the vehicle's body, which only the window's player model did: mobs now
go through the same function.

Fixes #9335.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:28:25 +01:00
Horizon agent 13dc865c9a Merge commit '80d929f7d64a7fd92ede64042392f676df4387b7' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
2026-11-08 05:28:07 +01:00
Horizon agent 80d929f7d6 Merge commit '75cd96be536365ec99573e48e08411832ab01701' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
#	tools/test_command_exec_parity.py
2026-11-08 05:27:48 +01:00
Horizon agent 75cd96be53 Merge commit '5bf7ce508d86204c6fb42a528a2ee05ce85da43a' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/commands.rs
#	tools/command_exec_corpus.py
#	tools/test_command_exec_parity.py
2026-11-08 05:27:34 +01:00
Horizon agent 5bf7ce508d Merge commit '4dbb00502ff162b4ac3472a3e7c85c5d8d88883e' into HEAD 2026-11-08 05:27:16 +01:00
SolenopsisbotandCodex d91706378e perf: reuse block tick scratch buffers
Retain per-tick block contact, random tick, and entity-inside vectors on Game while restoring scratch across result exits and preserving vanilla ordering.

Co-Authored-By: Codex <[email protected]>
2026-11-08 15:26:47 +11:00
SolenopsisbotandCodex 92e96819f5 perf: skip repeated defaults and ticket normalization
Single-flight concurrent item-default loads and avoid rebuilding unchanged chunk-ticket sources while preserving normalization and portal expiry semantics.

Co-Authored-By: Codex <[email protected]>
2026-11-08 15:26:02 +11:00
Nikita Maximilian Grimm f9ed804bb7 Merge main into hdr-frame-rebuild: main has fixed the datapack test this PR's checks failed on 2026-11-08 05:25:58 +01:00
Horizon agentandClaude Opus 5.5 2394ee861d Mark the setblock order tests as needing prepared resources
CI has no HORIZON_TEST_RESOURCES, so they panicked there; like the other
resource-backed game tests they now run with --ignored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:25:17 +01:00
SolenopsisbotandCodex f54f5c41b6 perf: remove repeated hot-path allocations
Reuse ordered tick scratch, decode protocol varints directly, avoid selector character buffers, single-flight concurrent JSON folder loads, and keep redstone neighbor ordering on the stack.

Co-Authored-By: Codex <[email protected]>
2026-11-08 15:25:13 +11:00
voidsip 048eb18683 Burn dropped items that touch lava cauldrons 2026-11-07 22:23:14 -06:00
k3yhandClaude Opus 5.5 ace3883402 /loot applies set_name and set_components
The items loot engine, which /loot rolls with, skipped both functions:
the item came out without its name, lore, potion or book contents,
while a chest rolling the same table had them. set_name sets the
component its target names, as a chest's roll does. set_components
applies the patch as ItemStack.applyComponents does and reads the
stack back as saved components are read, so a potion's contents make
it a potion. The feedback names each drop by getDisplayName.

New command corpus group: loot set name and components.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:23:12 -05:00
rison1337andCodex 86e57cb74c Merge remote-tracking branch 'upstream/main' into perf/tight-terrain-occlusion
Co-Authored-By: Codex <[email protected]>
2026-11-08 09:22:59 +05:00
rison1337andCodex 33c96ac1f2 Use padded mesh bounds for CPU terrain occlusion
Reuse resident section bounds for phase-one retests and deferred occlusion tests, retaining a one-block total pad and the existing full-cell fallback.

Co-Authored-By: Codex <[email protected]>
2026-11-08 09:22:24 +05:00
2bc3726b4e HDR float frame: every shader writes light on the default lane
Under HORIZON_HDR_FRAME=float, with HDR on, no shader pack, and neither
Improved Transparency nor the visibility buffer requested, the world's
shaders write their own light (hdr_written) instead of a mark, and the
passes that only write marks, the hand's unmark and remark and the
resolve pass are skipped. A frame is all written or all marked. TAA's
history is dropped when that or the HDR parameters it holds change.

Co-Authored-By: GPT 6.1 Sol <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:22:16 +01:00
Horizon agent 3a05ee18c6 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	docs/README.md
2026-11-08 05:22:03 +01:00
Horizon agent e1f9a8c096 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client-render/src/graphics_ui.rs
2026-11-08 05:22:03 +01:00
Horizon agent 0b2270dd45 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/commands.rs
2026-11-08 05:22:02 +01:00
Ludovic Marie 4dbb00502f Merge pull request #12110 from kacpherek/parity/batch-b
🤖 Agent: Fixed: `MobWorld` has no `end` field, so the fox village stroll now reads `dimension_type.has_fixed_time`, as `Level.isBrightOutside` does; it builds with main merged (lib and tests).
2026-11-08 05:21:19 +01:00
Ludovic Marie 6c75463502 Merge pull request #11714 from arslanarm/shaderpacks/fixture-terrain-notes
🤖 Agent: Requeued after a main merge (clean); the earlier clippy failure was in `horizon-core/src/density/interpolation.rs`, which this PR doesn't touch.
2026-11-08 05:21:15 +01:00
Horizon agent a869493ff4 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 05:21:14 +01:00
Horizon agent c471036d29 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
#	tools/test_command_exec_parity.py
2026-11-08 05:21:11 +01:00
Ludovic Marie 41de65db6e Merge pull request #11764 from rdbtCVS/fix/far-ring-brake-thresholds
🤖 Agent: Requeued after a main merge (clean); the earlier failure was main's native mod API stamp (`native_level_play_sound`) at that moment, not the brake thresholds.
2026-11-08 05:21:11 +01:00
Horizon agent 1c15d2b68c Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 05:21:03 +01:00
voidsip ed656ba6cf Run block events on ticketed chunks before they start ticking 2026-11-07 22:21:02 -06:00
Horizon agent 0eb8b8ec26 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 05:21:01 +01:00
Horizon agent 1d0621ac38 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 05:20:50 +01:00
Horizon agent 1ebc813852 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 05:20:47 +01:00
Horizon agent 59994ad2a2 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 05:20:45 +01:00
Horizon agent 9a62e99376 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 05:20:42 +01:00
Horizon agent 0b10ddd665 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 05:20:39 +01:00
Horizon agent 406ac72d0a Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 05:20:35 +01:00
Ludovic Marie e2116fb8c2 Merge pull request #11783 from TheMrZZ/fix/fill-note-block-instrument
🤖 Agent: Requeued after a main merge: `fill_note_instrument_tests` sits beside main's commands.rs tests.
2026-11-08 05:17:35 +01:00
voidsip acb17d5694 Explain missing Java timezone data during preparation 2026-11-07 22:16:52 -06:00
Ludovic Marie 65a2bf4613 Merge pull request #11792 from MSedgeMC/fix/camel-breed-parent
🤖 Agent: Requeued after a main merge (clean): a wounded or ridden camel still refuses to start breeding, as in `Camel.canFallInLove`.
2026-11-08 05:16:30 +01:00
Ludovic Marie eb69b3986b Merge pull request #11860 from Joansitoh/fix/11853-patch-log-scroll
🤖 Agent: Requeued after a main merge; the earlier verify failure was a 60 s timeout in `test_entity_shadow_ownership` on a loaded runner, not this PR's launcher scroll change.
2026-11-08 05:16:26 +01:00
Ludovic Marie 389224abec Merge pull request #11879 from TheMrZZ/fix/h155-fork-function-feedback
🤖 Agent: Requeued after a main merge: the fork-feedback corpus case and its flag are kept beside main's new command corpus cases.
2026-11-08 05:16:22 +01:00
Ludovic Marie 3bea613053 Merge pull request #11890 from MrCloudy2/fix/rider-vehicle-teleport
🤖 Agent: Requeued after a main merge: `lan_e2e.py` keeps both sides' checks; the codec base still isn't reset by `handleTeleportEntity`.
2026-11-08 05:16:18 +01:00
Ludovic Marie a9d293cb18 Merge pull request #12012 from TheMrZZ/fix/h262-enderman-absolute-anger
🤖 Agent: Requeued after a main merge: only persist.rs's test modules conflicted; the absolute anger time read is unchanged.
2026-11-08 05:16:15 +01:00
Ludovic Marie cd8ebdff23 Merge pull request #12032 from MSedgeMC/fix/melee-home-chase
🤖 Agent: Requeued after a main merge: `melee_continue_tests` sits beside main's new goals.rs tests; the home check in `canContinueToUse` is unchanged.
2026-11-08 05:16:11 +01:00
Ludovic Marie 6edc5de20f Merge pull request #12162 from KBroneZ/claude/carry-1-20-folders
🤖 Agent: Requeued after a main merge: in report.rs, main's installed-data-pack branch comes before the carried-mod branch, which still marks 1.20 layouts Partial; port-pack checks clean.
2026-11-08 05:16:08 +01:00
Ludovic Marie 314edb02fc Merge pull request #12166 from KBroneZ/claude/datapack-support-text
🤖 Agent: Requeued after a main merge: all 86 lang files were merged key by key with main, keeping main's new strings and this PR's data pack text.
2026-11-08 05:16:04 +01:00
Ludovic Marie 5e2b6c675f Merge pull request #12177 from TheMrZZ/fix/h171-inline-feature-parse
🤖 Agent: Requeued after a main merge: only game.rs's test-module list conflicted (`inline_feature_parse_tests` beside main's new ones).
2026-11-08 05:16:00 +01:00
Ludovic Marie 01c53f23d2 Merge pull request #12193 from UnQuis/feat/opaque-ice-clean
🤖 Agent: Requeued after a main merge: the `graphics_ui.rs` conflict kept Opaque Ice's switch, and main's tri-state GPU culling no longer has a plain on/off arm there.
2026-11-08 05:15:57 +01:00
voidsip 40aed431b6 Keep native mod diagnostics in the game log 2026-11-07 22:13:47 -06:00
Nikita Maximilian Grimm 4c3cb9a51b Merge hdr-light-function-main (one mark-to-light function, on main) into the written lane 2026-11-08 05:10:32 +01:00
Nikita Maximilian Grimm 2052b918ec Merge remote-tracking branch 'origin/main' into tnt-fall-powder
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 05:09:46 +01:00
Horizon agentandClaude Opus 5.5 c23236bceb Fox village stroll: isBrightOutside reads the dimension's fixed time
MobWorld has no end field. Level.isBrightOutside is false in every
dimension with a fixed time (the Nether and the End).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:09:46 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 4ca78266a5 Primed TNT keeps a fall distance and powder snow holds it
Primed TNT is an Entity in vanilla, so `checkFallDamage` adds each step
down, narrowed to a float, to its double fall_distance, which resets on
landing or in water and is saved and read and written by /data. Powder
snow uses that distance: over 2.5 it holds TNT on a 0.9-high top, and
otherwise TNT goes in and is stuck (0.9/1.5/0.9) like in a cobweb. The
stuck multiplier is used on the next move, which then zeroes motion.

Double and float lists in saved entity data now store -0.0 as 0.0, as
`DoubleTag.valueOf` does, so TNT resting on a block reads Motion 0.0d.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 05:09:14 +01:00
Ludovic Marie cf9569747b Merge pull request #12191 from TheMrZZ/fix/h260-level-world-border
🤖 Agent: queued. The level in place reads its own saved `world_border` when the world opens, before any command, so a first `/worldborder set` is no longer overwritten later.
2026-11-08 05:06:47 +01:00
Ludovic Marie 423abdd863 Merge pull request #10280 from MSedgeMC/fix/jukebox-stop-vibration
🤖 Agent: jukebox stop now captures was_playing before clearing j.playing, so the stop vibration fires once. On main merge 904b3036a, sculk, server_player_sculk, server_wool_vibration and mob_command_damage_vibration pass on playhorizon. command_exec's only 2 mismatches are main's gateway_item case (same 16819/16821 on bare main b13dbf068).
2026-11-08 05:06:42 +01:00
Horizon agent 8f0a7f4494 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	launcher/lang/af.json
#	launcher/lang/ar.json
#	launcher/lang/az.json
#	launcher/lang/ba.json
#	launcher/lang/be.json
#	launcher/lang/bg.json
#	launcher/lang/br.json
#	launcher/lang/bs.json
#	launcher/lang/ca.json
#	launcher/lang/cs.json
#	launcher/lang/cv.json
#	launcher/lang/cy.json
#	launcher/lang/da.json
#	launcher/lang/de.json
#	launcher/lang/el.json
#	launcher/lang/eo.json
#	launcher/lang/es.json
#	launcher/lang/et.json
#	launcher/lang/eu.json
#	launcher/lang/fa.json
#	launcher/lang/fi.json
#	launcher/lang/fil.json
#	launcher/lang/fo.json
#	launcher/lang/fr.json
#	launcher/lang/fur.json
#	launcher/lang/fy.json
#	launcher/lang/ga.json
#	launcher/lang/gd.json
#	launcher/lang/gl.json
#	launcher/lang/haw.json
#	launcher/lang/he.json
#	launcher/lang/hi.json
#	launcher/lang/hr.json
#	launcher/lang/hu.json
#	launcher/lang/hy.json
#	launcher/lang/id.json
#	launcher/lang/ig.json
#	launcher/lang/is.json
#	launcher/lang/it.json
#	launcher/lang/ja.json
#	launcher/lang/ka.json
#	launcher/lang/kk.json
#	launcher/lang/kn.json
#	launcher/lang/ko.json
#	launcher/lang/ky.json
#	launcher/lang/la.json
#	launcher/lang/lb.json
#	launcher/lang/li.json
#	launcher/lang/lmo.json
#	launcher/lang/lo.json
#	launcher/lang/lt.json
#	launcher/lang/lv.json
#	launcher/lang/mk.json
#	launcher/lang/mn.json
#	launcher/lang/ms.json
#	launcher/lang/mt.json
#	launcher/lang/nl.json
#	launcher/lang/no.json
#	launcher/lang/oc.json
#	launcher/lang/pl.json
#	launcher/lang/pt-br.json
#	launcher/lang/pt.json
#	launcher/lang/ro.json
#	launcher/lang/ru.json
#	launcher/lang/sah.json
#	launcher/lang/se.json
#	launcher/lang/sk.json
#	launcher/lang/sl.json
#	launcher/lang/so.json
#	launcher/lang/sq.json
#	launcher/lang/sr.json
#	launcher/lang/sv.json
#	launcher/lang/szl.json
#	launcher/lang/ta.json
#	launcher/lang/th.json
#	launcher/lang/tr.json
#	launcher/lang/tt.json
#	launcher/lang/uk.json
#	launcher/lang/ur.json
#	launcher/lang/uz.json
#	launcher/lang/vec.json
#	launcher/lang/vi.json
#	launcher/lang/yi.json
#	launcher/lang/yo.json
#	launcher/lang/zh.json
#	launcher/lang/zu.json
2026-11-08 05:05:11 +01:00
Horizon agent 4b38881802 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-port-pack/src/report.rs
2026-11-08 05:04:10 +01:00
Horizon agent 7daecbbce2 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client-render/src/graphics_ui.rs
2026-11-08 05:03:21 +01:00
TheMrZZandCodex 1f5cd1e43b Preserve joined-family order in unbounded arbitrary entity selectors
Use the existing insertion traversal only at the qualified global selector branch.

Co-Authored-By: Codex <[email protected]>
2026-11-08 05:02:34 +01:00
Horizon agent d6be40bbf7 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:59:35 +01:00
Horizon agent 1e743c812e Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/commands.rs
#	tools/command_exec_corpus.py
#	tools/test_command_exec_parity.py
2026-11-08 04:59:32 +01:00
Horizon agent e020e1d440 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:59:17 +01:00
Vinícius MoreiraandClaude Opus 5.5 01edf84d9f Environment attributes: timelines, keyframe tracks and easings
Ports net.minecraft.world.timeline and the keyframe machinery under it:
Timeline (clock, period, tracks, time markers, validateInternal),
AttributeTrack's codec (a modifier, override by default, and keyframes of
its argument), KeyframeTrack.validateKeyframes and validatePeriod,
KeyframeTrackSampler's looping segments and sampling,
argumentKeyframeLerp for every modifier, EasingType (cubic Bézier with
its Newton-Raphson and bisection solve) and all 32 Ease curves, with
Java's float and double steps (jmath, Mth's sine table). The layer stack
takes timelines as time-based layers that read their clock's ticks.

The new harness environment_timeline compares 3,464 cases with the pinned
client (every easing, the vanilla day, moon and early game tracks, and
synthetic and invalid tracks); environment_system now stacks the real
timelines between the biome and weather layers (36,000 lines).

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:59:14 -03:00
Horizon agent 8540619240 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/commands.rs
2026-11-08 04:59:13 +01:00
Horizon agent 97020c6abe Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:58:47 +01:00
Horizon agent 7cec42ea0b Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
#	tools/test_command_exec_parity.py
2026-11-08 04:58:44 +01:00
Horizon agent 75a2643501 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
#	tools/test_command_exec_parity.py
2026-11-08 04:58:37 +01:00
Horizon agent 0a9ce82a0b Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:58:19 +01:00
Horizon agent 9dda4ce381 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
#	tools/test_command_exec_parity.py
2026-11-08 04:58:17 +01:00
Horizon agent 4d91ddc86c Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/lan_e2e.py
2026-11-08 04:58:02 +01:00
Horizon agent 6e4c79f33b Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
#	tools/test_command_exec_parity.py
2026-11-08 04:57:46 +01:00
Horizon agent e1ae4fb750 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
2026-11-08 04:57:35 +01:00
Horizon agent d0dc8f1ad6 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/mobs/goals.rs
2026-11-08 04:57:24 +01:00
Horizon agent 65b2833bb9 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 04:57:14 +01:00
Nikita Maximilian Grimm 0972bbea7b Merge remote-tracking branch 'origin/main' into portal-ticket-persistence
# Conflicts:
#	crates/horizon-client/src/game/levels.rs
2026-11-08 04:57:09 +01:00
Horizon agent 8ac6fa92a1 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:57:04 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 b1ebe3d6e0 Merge origin/main into fn-tick-time
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 04:56:57 +01:00
Horizon agent 5452da616f Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 04:56:54 +01:00
Horizon agent c5b9f07b5d Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
#	crates/horizon-client/src/game/commands.rs
#	crates/horizon-client/src/game/commands/data.rs
#	crates/horizon-client/src/game/persist.rs
2026-11-08 04:56:48 +01:00
masa-masa-0314andZCode 8485f4c0ef Realms: the slot pictures, the template pages and the minigame list
- The world slots' pictures follow RealmsWorldSlotButton.State: the
  minigame image (or presets/isles.png when it has none), the empty
  frame, a slot's own template image, then the slot's panorama. The
  atlas now keeps the four slot pictures (the three 1024-tall faces and
  isles.png) at their own size: they were excluded as title/background
  and presets, and even once let through were dropped by the 512-tall
  GUI texture cap.
- WorldTemplate/WorldTemplateList read like JsonUtils' getStringOr,
  getIntOr and getUriNullable: numbers read as their JSON text (some ids
  and player counts are numbers, some counters are strings), and an
  empty link is no link — the row icons are not drawn and no empty URL
  can be opened.
- The template list fetches one page per job and appends it as it
  arrives, chaining the next page until isLastPage or an empty page,
  instead of waiting for every page before drawing the first row.
- The minigame list (RealmsWorldsTab.switchToMinigame) returns to the
  Worlds tab on Back and Escape, not to a reset screen.

Tests: 2250 lib tests pass (71 realms), scoped clippy clean.

Co-Authored-By: ZCode <[email protected]>
2026-11-08 11:56:47 +08:00
Horizon agent 64821ce0bb Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/mobs.rs
2026-11-08 04:56:42 +01:00
Horizon agent f38098f921 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 04:56:27 +01:00
MSedgeMC eaceaeda73 A cat hit by a player panics, and a wolf freezes into one
`TamableAnimal.TamableAnimalPanicGoal` passes a damage tag to `PanicGoal`:
`Wolf` gives it `#panic_environmental_causes`, while `Cat` and `Parrot`
keep the default `#panic_causes`. Horizon's `TamePanic` gated all three on
`fire_ticks > 0`, so only a burning pet panicked: a cat hit by a player or
a wolf freezing stood still where vanilla flees.

`TamePanic` now delegates to the `Panic` it wraps. The wolf's panic is
marked environmental (fire, freezing, cactus, lightning, lava); the cat's
and parrot's take any panic-causing damage.
2026-11-08 03:56:11 +00:00
J5CaseyandClaude Opus 5.5 87bb072d77 Native hook: recipe_sources, extra containers recipe placement takes from
`native_recipe_sources(player, menu, pos, sources)` lets a mod name
block containers (chests and the like, mod containers) that recipe
placement into a mod menu type's crafting grid may also take
ingredients from, after the player's inventory, as a crafting station
takes them from the chests beside it. No answer keeps vanilla's
placement.

Part of #12198.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:53:47 -06:00
Nikita Maximilian GrimmandClaude Opus 5.5 c7389334f1 A new item's own random makes its UUID, bob offset, yaw and motion
Vanilla's Entity takes its UUID from the first two draws of its own random
(Mth.createInsecureUUID); ItemEntity then draws bobOffs and the yaw from it,
and the constructor without a given motion draws the motion last. Horizon gave
every entity a clock-seeded UUID when first asked, drew a new item's motion
from a fresh random's first draws, its bobOffs from the particle random and a
loaded item's from the level's, and left the yaw at 0.

spawn_item_own makes all four from one own random in that order and replaces
dispenser::new_item_motion at its callers. A loaded or summoned item makes its
UUID (unless the tag has one) and bobOffs from its own random, so summoning no
longer shifts the level's random. Primed TNT from a block takes its UUID from
its own random too.

The seed sync proof now reads those UUIDs, the drop's rotation and motion, and
a TNT kick after a summoned item: 8/15 before, 15/15 after.

Fixes #12217

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 04:53:17 +01:00
itarqos5andClaude Sonnet 5.5 733d34582d tools: redstone_diff.py, whole redstone machines against vanilla one tick at a time
Runs hand-built circuits and random "soups" of redstone components through the real
tick loop in vanilla 26.3 (the bench mod's client, no server, no EULA) and in Horizon
(horizon-ctl), in a frozen world stepped with `tick step 1`, and prints the first tick
where the blocks differ and which ones. Narrowing: --near/--drop reduce a difference
to a few commands.

- RedstoneDiff + ServerLevelTickMixin in the bench mod snapshot the box before the
  first stepped tick and after each.
- `simulation blocks X1 Y1 Z1 X2 Y2 Z2` (horizon-ctl) reads the server's blocks, not
  the window's replica, which lags the server by design.
- agent.rs: `blocks_json`, shared by `blocks` and `simulation blocks`.

Only blocks are compared; entities are recorded, not diffed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011paghWkrnyQRBhJRodZpG2
2026-11-08 03:49:01 +00:00
Nikita Maximilian GrimmandGPT 6.1 Sol aac6bc2c2a HDR: one mark-to-light function for the display pass and the resolve pass
Co-Authored-By: GPT 6.1 Sol <[email protected]>
2026-11-08 04:48:49 +01:00
itarqos5andClaude Sonnet 5.5 af6fc73a51 /setblock and /fill notify neighbours after the shape updates, as vanilla does
Vanilla places a command's block with UPDATE_CLIENTS | UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS
(2|256), so Level.setBlock notifies no neighbour. The shape updates run inside
setBlock; ServerLevel.updateNeighboursOnBlockSet follows afterwards (for /fill,
after every block is in). Horizon placed with UPDATE_ALL (3), so the neighbours
heard of the block before its shape updates ran.

That is visible when the notice makes a block pop off: a comparator with nothing
under it breaks at its first notice and takes an attached wall torch with it. In
vanilla the wire between them had already connected to the torch, so it ends as a
cross; in Horizon the torch was gone first and the wire ended as a dot.

Found by tools/redstone_diff.py (two of 48 random circuits differed on vanilla
26.3 vs Horizon, reduced to four commands); after the change 144 random circuits
over three seeds match vanilla tick for tick.

- Behaviours::update_neighbours_on_block_set ports ServerLevel.updateNeighboursOnBlockSet.
- place_state takes `command`: setblock and fill use the vanilla flags; clone keeps
  its own flow. The strict variants are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011paghWkrnyQRBhJRodZpG2
2026-11-08 03:44:52 +00:00
Ludovic Marie 8bf4597a57 Merge pull request #12167 from J1zeee/fix/12022-piston-push-velocity-restitution
🤖 Agent: queued. Piston restitution bounces the entity's own velocity and runs for server entities only; the ground flag comes from #12168 (queued first).
2026-11-08 04:44:37 +01:00
TheMrZZandCodex gpt-6.1-sol cc3d62a7cd Preserve loaded arrow can_break for Mob block permissions
Carry the actual top-level projectile predicate through ArrowState load/save
and consult the existing matcher only for resolved Mob arrows under both
rules. Refuse unsupported conjuncts and preserve other projectile/drop paths.

Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-08 04:43:07 +01:00
J5CaseyandClaude Opus 5.5 3042d4068b Recipe placement fills a mod menu type's crafting grid
The recipe book's place packet and Horizon's viewer transfer channel go
to an open mod crafting menu (`lan_mod_craft_apply`) over its block
entity's grid, as a click does, with a ghost recipe when the items are
missing; the client's `native_place_recipe` and `native_transfer_recipe`
accept such a screen, so JEI ports and the Recipes mod fill it as they
fill a crafting table.

Part of #12198.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:41:25 -06:00
Ludovic Marie e1f01aff0b Merge pull request #12161 from TheMrZZ/fix/h141-mannequin-save
🤖 Agent: queued. A mannequin saves `profile`, `hidden_layers`, `main_hand` and `pose` always, and no `Mob` fields, since `Mannequin` is an `Avatar`, not a `Mob`.
2026-11-08 04:40:29 +01:00
Ludovic Marie 9c24961df0 Merge pull request #11830 from TheMrZZ/fix/h122-named-predicate-random
🤖 Agent: queued. Literal `random_chance` predicates in commands now draw from the world's random, as `LootContext` gets `level.getRandom()`; main merged in.
2026-11-08 04:40:25 +01:00
Ludovic Marie bbabaf720b Merge pull request #12000 from masa-masa-0314/feat/realms-ui-batch
🤖 Agent: queued. Realms screens follow vanilla's layout, state and input; the owner-UUID change was reverted (it would orphan tamed pets in Horizon-made worlds), and `under_world` skips parts with ':', with a test.
2026-11-08 04:40:21 +01:00
Ludovic Marie 1e1c77126d Merge pull request #12112 from kacpherek/parity/batch-d
🤖 Agent: queued. Equippable assets for armor, wings, capes and camera overlays; the End flash now uses `random_source::create()` after main dropped `SoundEngine::unseeded`, with a skybox gate in `tick_end_flash`.
2026-11-08 04:40:18 +01:00
Ludovic Marie 933ab57aa1 Merge pull request #12172 from NikitaMGrimm/t3/scheduled-item-tick-pass
🤖 Agent: queued. An item a scheduled block tick drops ticks in that tick's entity pass, as `EntityTickList.forEach` runs after the block ticks; a boat's lily pad drop still waits.
2026-11-08 04:38:14 +01:00
Ludovic Marie c5067a988b Merge pull request #11934 from TheMrZZ/fix/h203-mob-absorption-max
🤖 Agent: queued. Health Boost and Absorption hooks run for every accepted effect and `add_effect` returns its result after them; after #11883, #11959 and #12108.
2026-11-08 04:37:54 +01:00
Ludovic Marie 3936cafd12 Merge pull request #12194 from Solenopsisbot/perf/measurement-tools
🤖 Agent: queued. Startup trace step stats (count, median, p95, RSS) with a test; the compression bench was taken out, since the zlib reuse it measures is not on main.
2026-11-08 04:37:20 +01:00
Ludovic Marie 3b6d2fc635 Merge pull request #11802 from itarqos5/feat/far-tile-packed-quads-clean
🤖 Agent: queued. Far tiles' quads take a quarter of the arena; the decode helpers only tests use are now `#[cfg(test)]`, so clippy is clean.
2026-11-08 04:37:15 +01:00
Ludovic Marie bd6025952f Merge pull request #12138 from itarqos5/feat/auto-gpu-culling
🤖 Agent: queued. GPU culling Auto turns it on where the CPU limits the frame and keeps it only if frame time improves; the client_lib.rs conflict kept both `autotune` and main's `random_source`.
2026-11-08 04:36:42 +01:00
martipops 98abaa9217 Merge remote-tracking branch 'upstream/main' into settings/shell-graphics 2026-11-07 22:36:12 -05:00
Ludovic Marie c6eef4b0b7 Merge pull request #12139 from TheMrZZ/fix/h210-container-name-components
🤖 Agent: queued. Styled container names stay as the `CustomName` tag in the live block model, so a styled chest name survives a break; main's spill test now compares tags.
2026-11-08 04:36:09 +01:00
Ludovic Marie 1fb469a969 Merge pull request #12115 from TheMrZZ/fix/h274-test-guest-view
🤖 Agent: queued. `/test pos` picks the block from a connected source player's view, as `TestCommand` reads `source.getPlayer()`; rustfmt fixed after the main merge.
2026-11-08 04:35:36 +01:00
Ludovic Marie 7adf3992a5 Merge pull request #12197 from martipops/settings/shell-graphics-features
🤖 Agent: queued. Undo, a row's cost and the greyed-row reason are generic shell features with tests; Extras gets no Undo, and Graphics moves onto them in the next PR.
2026-11-08 04:35:15 +01:00
Ludovic Marie 8629067aa4 Merge pull request #11811 from TheMrZZ/fix/chorus-projectile-drops
🤖 Agent: queued. Arrows and snowballs breaking a chorus flower now drop it via `ChorusFlowerBlock.onProjectileHit` (`destroyBlock` with drops); main merged in.
2026-11-08 04:34:42 +01:00
voidsip 9f6d28e257 Discard a removed gateway's server cooldown state 2026-11-07 21:32:07 -06:00
Ludovic Marie ec2c0c8d1f Merge pull request #12011 from NikitaMGrimm/hdr-tone-curve
🤖 Agent: queued. The HDR float frame's tone curve eases highlights into the peak instead of clipping; it is HDR-only, so the SDR path doesn't change.
2026-11-08 04:29:50 +01:00
Ludovic Marie 358c4e0c01 Merge pull request #12150 from RINNECODER/up2/glsl-exact-overload
🤖 Agent: queued. GLSL overload resolution now prefers an exact argument match over a conversion, as the GLSL spec ranks them, so packs that overload on int/float pick the right function.
2026-11-08 04:29:46 +01:00
Ludovic Marie 90b4e7d794 Merge pull request #11821 from vnsmoreira/attributes/layer-stack
🤖 Agent: queued. Environment attributes now come from the layer stack (dimension, then biome with blending, then weather) in `EnvironmentAttributeSystem`'s order; main merged in since the review.
2026-11-08 04:27:14 +01:00
Ludovic Marie 989afe1c00 Merge pull request #11870 from IwantHappiness/translate-ru-lang
🤖 Agent: queued. The remaining Russian strings in the launcher and the game are translated, and the keys match en_us, so no string falls back to English.
2026-11-08 04:27:10 +01:00
Horizon agent 0dc90c1d29 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:26:07 +01:00
Horizon agent e67b56eec6 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:25:27 +01:00
Horizon agent 3e4f2a7305 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:25:21 +01:00
Horizon agent f9b2840d07 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:24:42 +01:00
Horizon agent 1c9380fa56 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:24:12 +01:00
voidsip 6e5cd517d7 Elide default stored enchantments when saving enchanted books 2026-11-07 21:23:25 -06:00
Ludovic Marie 5a0906f5f4 Merge pull request #12051 from ilguerro/perf/11126-structure-starts-templates
🤖 Agent: queued. A template start is read back only when every child decodes; one unreadable child sends the whole start to #11652's regeneration, so old saves get nothing worse. I couldn't rerun the ignored `saved_starts_match_generated_layouts` here (no prepared resources on this host); your 7/7 run and the parity run decide.
2026-11-08 04:22:28 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 b9404f32c3 Tick functions run before the game time moves on, and before that tick's scheduled functions
MinecraftServer.tickChildren runs the #minecraft:load and #minecraft:tick
functions before the world clocks and the levels tick; the Overworld's
ServerLevel.tickTime then raises the game time and runs the scheduled
functions due at the new time. Horizon raised the game time, the weather and
the day clock first, then ran the scheduled functions and the tick functions
after them, so a tick function read both clocks one tick ahead and a
`schedule ... 1t` from it waited a tick more.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 04:19:23 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 951fe53102 Seed sync: run the proof group as a harness of its own
A script that syncs runs on fixed seeds to its end, so in the full command-exec
corpus every group after the proof drew from them, at seeds fixed by whatever
came before. With one more proof case (#12217), "experience orb stuck", whose
orb rarely ends otherwise on random seeds, landed on such a seed and failed on
every run. The group is isolated now and runs as tools/test_seed_sync_parity.py;
the main corpus runs without the agent, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 04:16:28 +01:00
Nikita Maximilian Grimm 0b30eba4e0 Merge remote-tracking branch 'origin/main' into tnt-size-eye 2026-11-08 04:14:43 +01:00
Nikita Maximilian Grimm 7abea17aa3 Merge remote-tracking branch 'origin/main' into fix-fluids-drag-test 2026-11-08 04:06:21 +01:00
Ludovic Marie 0f56e3165a Merge pull request #12227 from horizon-rust/fix/keyring-timeout-12179
🤖 Agent: keyring calls now give up after 20 s on a thread of their own; a call still stuck makes later ones fail at once, so the account lock is never held forever (tested with a keyring that never answers).
2026-11-08 04:05:55 +01:00
Horizon agent 3943b0e8a7 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:05:32 +01:00
Horizon agent f7a3c0f2e4 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:05:24 +01:00
Horizon agent 92b1ae1132 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:05:20 +01:00
Horizon agent 316752b706 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:05:16 +01:00
Horizon agent aa3919d3ae Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:05:15 +01:00
Horizon agent a1afb474a5 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:05:03 +01:00
Horizon agent fdb6ad8b8f Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:04:55 +01:00
Horizon agent 7f505e07dd Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:04:36 +01:00
Horizon agentandClaude Opus 5.5 98b4d049fa launcher: give up on a keyring that never answers (#12179)
A Secret Service daemon that never answers (two keyrings racing for the
D-Bus name, a locked collection with no working prompter) held the
account lock forever: Play stayed on "Starting…" and printed nothing.

Every keychain call now runs on a thread and gives up after 20 s
(Bounded): on Linux the secrets file takes writes as before, and a
sign-in that can't be read says so instead of "no owner". While a
given-up call is still stuck, later calls fail at once. Play prints one
stderr line per step, and `account list` prints why a check failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 04:04:29 +01:00
Horizon agent 32faed9621 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 04:04:03 +01:00
Horizon agent 0270b0133d Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 04:03:56 +01:00
Horizon agent 1b7cec46d9 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
#	tools/test_command_exec_parity.py
2026-11-08 04:03:52 +01:00
Horizon agent 6922878d94 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
#	tools/test_command_exec_parity.py
2026-11-08 04:03:51 +01:00
Horizon agent 9a442e5382 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
#	tools/test_command_exec_parity.py
2026-11-08 04:03:42 +01:00
Horizon agent af61f6751e Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
2026-11-08 04:03:35 +01:00
abit-foggyandCodex a4df995446 fix(studio): localize timeline marker labels
Co-Authored-By: Codex <[email protected]>
2026-11-07 17:03:20 -10:00
Ludovic Marie 6c2498236d Merge pull request #12222 from horizon-rust/fix/new-world-packs-test-meta
🤖 Agent: queued first. Main's correctness job fails on this test since #12086 met the folder metadata gate (84f695992), and every PR that merges main fails on it; verify is green here.
2026-11-08 04:02:16 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 2294609404 TNT's rider seat test expects the float height
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:59:15 +01:00
Ludovic Marie 7ddbb41f86 Merge pull request #12141 from RINNECODER/up2/compute-workgroups-limit
🤖 Agent: queued. A dispatch over 65,535 workgroups per dimension (the wgpu limit) is now split into several dispatches with the base passed along, so packs whose compute pass sizes from the screen still run at 4K and up.
2026-11-08 03:58:06 +01:00
Ludovic Marie 4b38e08b7f Merge pull request #11950 from senjinthedragon/item-entity-material-maps
🤖 Agent: queued. LabPBR `_n`/`_s` maps now reach entities, items, block entities and the hand; `set_shared_material_maps` now runs after `set_custom_sky` in loading_window.rs, so a pack reload binds both.
2026-11-08 03:58:03 +01:00
abit-foggy 5c00a74d4e Merge remote-tracking branch 'upstream/main' into codex/studio-c1-c2-topbar-timeline
# Conflicts:
#	crates/horizon-client/src/game/play_keys.rs
2026-11-07 16:50:47 -10:00
abit-foggyandCodex 858f248202 fix(studio): align C1+C2 replay controls
Co-Authored-By: Codex <[email protected]>
2026-11-07 16:50:04 -10:00
Nikita Maximilian GrimmandClaude Opus 5.5 290560bc52 Expect the float drags in the item flowing-water test
#11794 made the item's water and air drag floats (0.99F, 0.98F), as
vanilla's are; the test still expected the f64 constants, so it fails
wherever the vanilla data is prepared.

Fixes #12221

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:25 +01:00
Horizon agentandClaude Opus 5.5 092ae508ba rustfmt game.rs (verify failed on it)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:45:11 +01:00
Horizon agentandClaude Opus 5.5 30c20a7a54 datapack test: give the new-world packs a pack section
folder_metadata_present (Pack.readPackMetadata) now requires a pack section
with a description, so the {} metadata in #12086's test hid both packs and
seed_create_world returned None. This failed every PR's verify on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:43:49 +01:00
Ludovic Marie f96d9e89b5 Merge pull request #10283 from MSedgeMC/fix/cloud-save
🤖 Agent: removing an entity's chunk now drops its area-effect clouds too (breath_clouds.retain), and saves keep entity_base_tag's Entity fields. On main merge 8b583a15e, save_roundtrip, entity_nbt_boolean, orb_saved_uuid, stand_fall_save, conversion_water_save, mob_pickup_save and potion_effect_icon pass. command_exec's only 2 mismatches are main's gateway_item case (same on bare main b13dbf068).
2026-11-08 03:41:29 +01:00
Nikita Maximilian Grimm a45b450e56 Merge remote-tracking branch 'origin/main' into block-entities-wait-entities 2026-11-08 03:40:46 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 e6281842d8 Block entities and scheduled ticks wait for their chunk's entities to load
LevelChunk.isTicking and ServerLevel.isPositionTickingWithEntitiesLoaded
also need the chunk's entity section loaded (areEntitiesLoaded). It loads at
the end of a level tick, frozen or not (PersistentEntitySectionManager
.processPendingLoads), empty sections too. A chunk that loads now waits for
the end of the level's next pass before its block entities (bells, conduits,
gateways and sculk blocks included), moving pistons and scheduled ticks run.
The command harness's readiness waits mark their chunks loaded, as the
vanilla oracle's do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:35:18 +01:00
bulkandClaude Opus 5.5 842c094de7 Potent sulfur: find the mobs near a geyser from a grid
Every gassing geyser scanned every mob every 10 ticks, all on the same tick,
and every erupting one every tick. One grid of mob boxes is kept for the block
entity pass, until the mob list's next write; a geyser's own effects and
pushes move no mob, so the grid holds after them.

The mobs still get their effect and push in list order, and the gas reads
blocks only, so finding the reached mobs before any gets its effect changes
nothing.

(cherry picked from commit 2bad442a93, ported to the fields on Game)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:32:06 +00:00
bulkandClaude Opus 5.5 fc55599794 Credit the mob that swung for a guest's effect and sting hits
A cave spider's poison bite or a bee's sting on a guest named the mob
nearest to where the hit came from in X and Z, ignoring height, so a zombie
standing under the spider took the credit (the kill message, the hurt-by
advancement, the guest's revenge target). The event names the mob that
swung, as a plain melee hit does since the previous commit.

(cherry picked from commit 3ab80dc9d0, without its deletion of tools/bench_*.rs)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:32:06 +00:00
bulkandClaude Opus 5.5 12af27a781 Carts: read the carts and mobs near a cart from a grid
Each ticked cart compared its box with every cart, and a moving rideable cart
with every mob twice (and built the mob teams for each). A grid kept for the
tick answers in slot order, as the scans did. The cart grid follows each
ticked cart, is rebuilt when a cart is gone or added, and dropped after a
cart's command; the mob grid holds until the mob list's next write. With
native mods loaded, whose hooks can move either, the scans stay.

(cherry picked from commit 3613b40c6b, ported to the fields on Game)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:32:01 +00:00
Ludovic Marie bca5833f8d Merge pull request #12185 from Ragbie/fix/shulker-hurt-teleport-now
🤖 Agent: queued. A shulker's hurt teleport now runs inside the hurt, before the bullet's levitation, and riders get off where it stood (`unRide`); NoAI shulkers never teleport, as `teleportSomewhere` requires.
2026-11-08 03:31:45 +01:00
bulkandClaude Opus 5.5 ca0da4d9bb JoinList: count the writes, so a cache of the list can tell it is stale
A ListStamp names the list and how many times it was written through
`DerefMut` (every push, insert, retain or slot write). A cache built from
the list keeps the stamp and is rebuilt when the stamp differs; a swapped-in
list (another level's) has another name.

(part of commit 6b826d204a)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:31:42 +00:00
Ludovic Marie 4a8a101391 Merge pull request #12182 from TheMrZZ/fix/h283-built-in-component-delivery
🤖 Agent: queued. Four components (`provides_trim_material`, `provides_banner_patterns`, `can_place_on`, `can_break`) are now encoded in outgoing stacks with the synced registry IDs; anything unsupported drops the whole buffer, as before.
2026-11-08 03:31:41 +01:00
Ludovic Marie 07aab11e71 Merge pull request #12181 from TheApple05/codex/older-server-mapping-generation
🤖 Agent: queued. Every mapping value stays the same; the IDs the translators read come from generated pinned constants, and `--check` catches drift.
2026-11-08 03:31:37 +01:00
bulkandClaude Opus 5.5 fdd3d1e59c Stop walking every mob for each game event and melee hit
A game event posted outside the mob pass (a block placed, a door opened, an
explosion) looked through every mob of the level for the wardens and allays
that can hear it. The listener slots are now kept until the mob list is
written again (the previous commit's stamp), or another level's list is in
place.

Mob id lookups for game events, thorns and a hit's source go through the
mob index instead of a scan. A guest's melee event names the mob that
swung, so the hit credits that mob rather than the one nearest in x and z
to the player.

(cherry picked from commit 6b826d204a without its join_seq part, ported to the fields on Game)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:31:34 +00:00
Ludovic Marie bc21da03bc Merge pull request #12174 from NikitaMGrimm/saved-ticks-startup
🤖 Agent: queued. The server now waits for the saved tickets' chunks before the first tick (`prepareLevels`), so their saved ticks unpack at the time they were saved at; the wait gives up after 600 s.
2026-11-08 03:31:33 +01:00
Ludovic Marie 93fc4b2ba9 Merge pull request #12159 from itarqos5/tools/world-compare
🤖 Agent: queued. Tools only: `world_compare.py` and `perf_bench.py --seed`, no generator change; the seed report it answers is documented with the two seeds compared.
2026-11-08 03:31:30 +01:00
Ludovic Marie f3cc9257df Merge pull request #12080 from KBroneZ/claude/instances-folder
🤖 Agent: queued. `--folder` on the CurseForge `Instances` folder now finds its instances, and a Prism `instances` folder (same name where case is ignored) is not mistaken for it.
2026-11-08 03:31:26 +01:00
bulkandClaude Opus 5.5 8c1f6115d5 JoinList: count the writes, so a cache of the list can tell it is stale
A ListStamp names the list and how many times it was written through
`DerefMut` (every push, insert, retain or slot write). A cache built from
the list keeps the stamp and is rebuilt when the stamp differs; a swapped-in
list (another level's) has another name.

(part of commit 6b826d204a)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:31:25 +00:00
bulkandClaude Opus 5.5 069cc39f05 Carts: find the ticked cart at its slot and move it instead of cloning
push_from_ticked_cart searched the cart list for the ticked cart twice and
copied it in and out whole. The caller knows its slot: the ticked copy is
swapped into the slot for the push, and only the pushed cart is copied back,
over the copy it replaced (clone_from reuses its buffers). Lava hurting a cart
looks there first too.

Without mods a push changes velocities and riders, never the list, so the
cart is still in its slot after it (a debug assertion checks). With native
mods loaded a mount hook can change the list: the copies and the search by id
stay. The loot roll stays with the ticked copy, as #11526 made it: it comes
off before the swap and goes back after.

(cherry picked from commit 206905a2d5, without
the loot roll part of fb69aba537)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:31:22 +00:00
Ludovic Marie 0a407714e0 Merge pull request #12184 from sergue212fbright/fix/lod-slab-visibility
🤖 Agent: queued. Far terrain treats slabs as full cells like stairs, so a waterlogged slab keeps its own material instead of becoming water; the test walks every real slab state.
2026-11-08 03:31:22 +01:00
Ludovic Marie 3bb4e7827c Merge pull request #12164 from KBroneZ/claude/es-empty-shaderpacks
🤖 Agent: queued. An empty `shaderpacks/` (CurseForge and Sodium create it) no longer counts as a shader pack, for folders and archives alike; tests cover both.
2026-11-08 03:31:19 +01:00
Ludovic Marie 546eab04b7 Merge pull request #12168 from NikitaMGrimm/orb-piston-ground
🤖 Agent: queued. After every server push the ground flag is set to `verticalCollisionBelow` (`Entity.move` → `setOnGroundWithMovement`, which runs when `isLocalInstanceAuthoritative`), so a sideways push off a block clears it; #12167 builds on this.
2026-11-08 03:31:15 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 44caa43238 Primed TNT's box and eye height are vanilla's floats
EntityTypes.TNT is sized 0.98F with an explicit eyeHeight(0.15F). The box
now widens the float size, so TNT stopped by a wall or ceiling ends where
Java's does, and the fluid eye height is the type's 0.15F instead of the
default 0.85 of the height.

Fixes #12020

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:30:52 +01:00
Horizon agentandClaude Opus 5.5 a9fba955bd Leave the compression bench to the zlib reuse change
main still makes a new ZlibEncoder per record, so the bench would compare
two fresh encoders. It belongs with the change that adds the reuse (#12189).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:30:23 +01:00
Horizon agent e74f789659 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 03:28:10 +01:00
Horizon agent e02c201c97 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game.rs
2026-11-08 03:28:04 +01:00
Horizon agent 325c627cdb Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/game/persist.rs
2026-11-08 03:27:59 +01:00
Horizon agentandClaude Opus 5.5 139e83fff8 Opaque Ice: own flag; IceBlock keeps frosted ice for fluids
Fluids read Info::ice through is_ice_class (instanceof IceBlock, frosted
ice included), so excluding frosted ice there changed fluid meshing with
the option off. Regular ice now gets its own opaque_ice flag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:25:30 +01:00
Horizon agentandClaude Opus 5.5 1d6e5d01b5 Piston restitution: the entity's own velocity, server entities only, ground flag from #12168
Restitution bounces the entity's velocity (getDeltaMovement), not the push.
It runs for server entities only, since a player's client moves the player.
It runs even when the step is too small to apply, as Entity.move does.
The ground flag is left to set_pushed_on_ground (#12168), which follows
setOnGroundWithMovement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:22:00 +01:00
Horizon agent 2adedf5570 Merge commit 'refs/cg72/pr-12168' into HEAD 2026-11-08 03:20:30 +01:00
Ludovic Marie 4e6920a319 Merge pull request #11829 from senjinthedragon/entity-motion-objects
🤖 Agent: queued. `at_velocity` now covers boats, minecarts, armor stands, frames, paintings, TNT, falling blocks, block entities and moving pistons; the `falling_block_visible` doc comment is back on its function.
2026-11-08 03:19:38 +01:00
Ludovic Marie c214f59711 Merge pull request #12076 from TheMrZZ/fix/h246-storage-alias
🤖 Agent: queued. A wildcard `data modify storage` that fails part way keeps the edits made so far, as vanilla's in-place NbtPath edit does; main merged in.
2026-11-08 03:19:34 +01:00
Nikita Maximilian Grimm 5e7e654901 Merge remote-tracking branch 'origin/main' into item-escape-gravity
# Conflicts:
#	tools/command_exec_corpus.py
2026-11-08 03:18:38 +01:00
J5CaseyandClaude Opus 5.5 7e4e421224 Native mods: break a block as a player (native_player_break_block)
A helper-only fragment adds `native_player_break_block(uuid, pos,
into_inventory)` (`Host::player_break_block`), so a vein-mining mod can
break blocks as its player without injecting into the private
`Game::break_block`. It runs the game's own player break
(ServerPlayerGameMode.destroyBlock): the player's checks, the
`destroy_block` hook, loot for the held tool and its enchantments, tool
wear, stats, exhaustion and experience. With `into_inventory` the block's
drops go to the player's inventory, the rest dropped from them.

The break now reports whether it removed the block, and a break nested in
another's hook keeps the outer break's own-event position. The acting
guest's spawn protection is kept for their turn so the helper can check
it while the hub is out of reach.

Fixes #12195

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:18:20 -06:00
Horizon agentandClaude Opus 5.5 719fa5e2bd rustfmt game.rs (verify failed on it)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:17:03 +01:00
Horizon agentandClaude Opus 5.5 485323aaaf add_effect: keep the accepted result past the absorption and health boost hooks
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:16:51 +01:00
Ludovic Marie 4a374440f4 Merge pull request #11883 from TheMrZZ/fix/h205-mob-health-boost
🤖 Agent: queued. Health Boost raises the max health modifier and clamps health down when it ends, as `HealthBoostMobEffect` does; #11934 builds on it.
2026-11-08 03:15:58 +01:00
Ludovic Marie b99e2087d3 Merge pull request #11848 from TheMrZZ/fix/h174-bell-block-entity
🤖 Agent: queued. Command reads keep the real bell block entity (and copper golem statue) instead of a synthesized one, so `data get block` matches vanilla's NBT; main merged in.
2026-11-08 03:15:55 +01:00
Ludovic Marie b84c97088f Merge pull request #11766 from TheMrZZ/fix/mob-effect-amplifier-codec
🤖 Agent: queued. Effect amplifiers decode as unsigned bytes (`Byte.toUnsignedInt`), so an amplifier of 200 no longer reads as -56; main merged in.
2026-11-08 03:15:51 +01:00
Ludovic Marie 57da7aecbc Merge pull request #11729 from TheMrZZ/fix/h195-command-damage-range
🤖 Agent: queued. `damage` predicate ranges compare the item's damage as `ItemDamagePredicate` does (range on damage, not durability); main merged in.
2026-11-08 03:15:47 +01:00
Ludovic Marie e93afc5ade Merge pull request #11728 from TheMrZZ/fix/summoned-leash-knot-lifecycle
🤖 Agent: queued. A summoned leash knot snaps to the block centre and dies without a fence, as `LeashFenceKnotEntity.survives` checks; main merged in.
2026-11-08 03:15:44 +01:00
Ludovic Marie a7296b75e0 Merge pull request #11708 from TheMrZZ/fix/h032-jukebox-saved-clock
🤖 Agent: queued. A jukebox without a song now saves no `ticks_since_song_started`, as `JukeboxSongPlayer` writes it only while playing; main merged in.
2026-11-08 03:15:40 +01:00
J5CaseyandClaude Opus 5.5 9d25e30101 Mod menu types: a crafting grid that crafts as the crafting table
A content mod's menu type may declare `"crafting": {"grid", "size",
"result"}`: those slots run vanilla's CraftingMenu logic on the menu
engine (live result, consumption and remainders on take, shift-click
crafting, recipe placement), over a grid the block entity keeps. The
result is the menu's own: the block entity never holds it, so hoppers,
comparators and a broken block can't dupe it, and the hub shows guests
the result the game made, again each tick the grid changed.

Part of #12198.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:15:16 -06:00
UnQuis 4543e2f454 Add an Opaque Ice performance option
A Horizon-only option, off by default, that draws regular ice opaque in the solid pass and culls faces between adjacent ice blocks. It follows the public description of Luxium's Opaque Ice and the design note in #11563; no Luxium source was read or copied.

Fixes #12192
2026-11-08 10:14:00 +08:00
Ludovic Marie 36584650ea Merge pull request #12152 from RINNECODER/up2/glsl-atomic-struct-copy
🤖 Agent: queued. Patch in vendored naga: copies of structs or arrays holding atomics go member by member, up to 64 scalars; larger ones stay whole copies, as noted.
2026-11-08 03:12:06 +01:00
Ludovic Marie aee2c63c3b Merge pull request #12143 from RINNECODER/up2/pack-image-formats
🤖 Agent: queued. The added formats (RGB10_A2, RGB10_A2UI, 16-bit SNORM) map to the wgpu formats `image_format` already binds; formats a GPU can't store into are still left out with a note.
2026-11-08 03:12:01 +01:00
Ludovic Marie ef23545cef Merge pull request #12126 from hunixcode/fix/translatable-fallback-literal
🤖 Agent: queued. A translatable with a fallback keeps the fallback as a literal, as `TranslatableContents` does, instead of looking it up as another key.
2026-11-08 03:11:58 +01:00
Ludovic Marie 92c708b3fe Merge pull request #12125 from hunixcode/fix/panel-unspecified-host
🤖 Agent: queued. The panel accepts LAN browsers when bound to 0.0.0.0 or :: only; a loopback bind still refuses them, so nothing new faces the network.
2026-11-08 03:11:55 +01:00
Ludovic Marie c6f935414d Merge pull request #12124 from itarqos5/perf/terrain-interpolant-packing
🤖 Agent: queued. Passing terrain's interpolants in 5 locations instead of 12; visbuffer reads `TerrainOut` only internally, so packs see no difference.
2026-11-08 03:11:51 +01:00
Ludovic Marie 73231e735d Merge pull request #12114 from p-stzhuk/fix/legacy-intel-metal
🤖 Agent: queued. The wgpu-hal change is in `third_party/`, gated to legacy Intel Metal; other GPUs take the same path as before.
2026-11-08 03:11:47 +01:00
Ludovic Marie a71408736f Merge pull request #12093 from vnsmoreira/packs/core-sky
🤖 Agent: queued. Pack `core/sky` and `core/stars` shaders apply only when a resource pack ships them; without one the sky pipeline is unchanged.
2026-11-08 03:11:44 +01:00
TiggerTakkyTTTandCodex fb4805072f Fix ambient particles for datapack biomes
Co-Authored-By: Codex <[email protected]>
2026-11-08 09:11:04 +07:00
Nikita Maximilian Grimm 111c22dd5e Merge remote-tracking branch 'origin/main' into test-randoms-sync 2026-11-08 03:09:04 +01:00
SolenopsisbotandCodex ce08c38337 perf: add opt-in startup and compression benchmarks
Measure startup step distributions and RSS, and compare reused versus fresh zlib streams with deterministic checksums.

Co-Authored-By: Codex <[email protected]>
2026-11-08 13:08:58 +11:00
Ludovic Marie 8d2900e6ce Merge pull request #12113 from kacpherek/parity/batch-e
🤖 Agent: queued. One cost: the stepped tracker paths add a Vec per tracked entity on the tracker tick; small, but it is the hot path, worth a look if MSPT moves.
2026-11-08 03:05:56 +01:00
Ludovic Marie cd1318bf02 Merge pull request #12111 from kacpherek/parity/batch-c
🤖 Agent: queued. Batch: sculk now hears bottles, golems, endermen and frames; portals dismount per vehicle tick as vanilla's `Entity.handlePortal` does.
2026-11-08 03:05:53 +01:00
Ludovic Marie 2f661c08ed Merge pull request #12109 from kacpherek/parity/batch-a
🤖 Agent: queued. Batch of server click answers; each case matches `Mob.interact`/`InteractionResult` and is in the batch's harnesses, which run in parity.
2026-11-08 03:05:49 +01:00
Ludovic Marie 1bf8766c1d Merge pull request #12103 from martipops/controller/direct-craft
🤖 Agent: queued. LT + A crafting a recipe repeatedly is new controller input; servers see the same clicks a mouse would send, so nothing server-side changes.
2026-11-08 03:05:46 +01:00
martipops 9f92bb23b4 Merge remote-tracking branch 'upstream/main' into settings/shell-graphics-features 2026-11-07 21:03:09 -05:00
Ludovic Marie 3e06612e08 Merge pull request #11826 from iseaprojects/i18n/es-es-remaining
🤖 Agent: queued. es.json was merged key by key with main (91 translations kept, main's new keys too), so no Spanish string main added is lost.
2026-11-08 03:02:29 +01:00
Ludovic Marie 15c0246614 Merge pull request #12147 from RINNECODER/up2/port-occludes
🤖 Agent: queued after #12145 (its base, queued). Main merged in and the stack rebuilt on #12145's head; verify is green at this head.
2026-11-08 03:02:25 +01:00
Ludovic Marie face534db3 Merge pull request #12132 from Evan-lhm/fix/launcher-blur-zero-sharp
🤖 Agent: queued. A 0 px blur skips the blur pass, so the plates are sharp and the GPU does no work for it.
2026-11-08 03:02:22 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 64f4bab6f3 Parity harnesses: unseeded randoms and entity ids can be synced between vanilla and Horizon
A test-only Java agent makes vanilla's RandomSupport.generateUniqueSeed step a
uniquifier of the calling thread's own, without the clock; HORIZON_TEST_SEEDS=1
does the same in Horizon's unique_seed. A command script's sync_randoms step sets
that uniquifier, the entity-id counter and the level's random in both engines,
and the "seed sync proof" group compares a drop's position, primed TNT's kick, a
dispensed item and the resting phase of four items exactly. The oracle cache
counts the agent jar as an input.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:01:17 +01:00
Horizon agentandClaude Opus 5.5 52d1a0b475 lod/packed: from_bits and from_words are test-only
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:00:41 +01:00
Horizon agentandClaude Opus 5.5 c0fe9adca6 End flash sound: random_source::create (SoundEngine::unseeded left main)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:00:37 +01:00
Horizon agent 992ea05825 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 03:00:37 +01:00
Horizon agentandClaude Opus 5.5 2e11de8943 Compare spill test names as Tags (block_names holds the CustomName tag now)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:00:32 +01:00
Horizon agent 7351ad6d91 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/horizon-client/src/client_lib.rs
2026-11-08 03:00:31 +01:00
Ludovic Marie 0a6eca805d Merge pull request #12154 from RINNECODER/up2/pack-comment-settings
🤖 Agent: queued. Comment settings end at their line, as the Iris probes in `read_stage` show it reads them line by line; live code still reads to the `;`.
2026-11-08 02:59:34 +01:00
Horizon agent e949fd4cc1 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 02:58:50 +01:00
Ludovic Marie ed0be44325 Merge pull request #12117 from sergue212fbright/fix/sign-text-formatting
🤖 Agent: queued. Bold is drawn as the shifted second pass and italic as the skew vanilla's `BakedGlyph` uses, and after the #11863 merge styled glyphs keep the HDR emission tier; the 102 sign cases pass.
2026-11-08 02:58:24 +01:00
Ludovic Marie 97e46ce1d5 Merge pull request #12050 from TheMrZZ/fix/h140-nautilus-cooldown-memory
🤖 Agent: queued. The Nautilus cooldown memory now exists only while it counts down and is erased at 0, as `Brain.setMemoryWithExpiry` does; its harness runs in parity.
2026-11-08 02:58:20 +01:00
Ludovic Marie 5669d66de3 Merge pull request #11990 from TheMrZZ/fix/h285-adventure-predicate-saved-forms
🤖 Agent: queued. A one-block predicate now saves as the bare id and partial `custom_data` keeps only the keys given, which is how `BlockPredicate`'s codec writes them; the residual corpus documents what is left.
2026-11-08 02:58:17 +01:00
Ludovic Marie f54fba8726 Merge pull request #12123 from NikitaMGrimm/tnt-piston-ground
🤖 Agent: queued. A sideways push leaves `onGround` false, as `PistonMovingBlockEntity.moveCollidedEntities` only sets it for upward pushes; main merged in since my review, no other change.
2026-11-08 02:58:13 +01:00
Ludovic Marie f86b98b203 Merge pull request #12118 from NikitaMGrimm/minecart-drop-motion
🤖 Agent: queued. A destroyed minecart drops its item and contents with `Containers.dropContents`' motions; same items, now in vanilla's spread.
2026-11-08 02:58:10 +01:00
Ludovic Marie 9842e75046 Merge pull request #12107 from martipops/settings/shell-fixes
🤖 Agent: queued. Building the settings rows once removes the per-frame rebuild, and Down from the search field lands in the list.
2026-11-08 02:58:07 +01:00
Ludovic Marie 99956fff22 Merge pull request #12106 from martipops/controller/nintendo-buttons
🤖 Agent: queued. The Nintendo row picks by position or by letter only in the glyph table; the bindings themselves don't move.
2026-11-08 02:58:03 +01:00
Ludovic Marie b23ad347d1 Merge pull request #12105 from NikitaMGrimm/execute-block-nbt
🤖 Agent: queued. `execute if block`, `fill` and `clone` now compare the block entity's NBT part of the predicate, as `BlockPredicateArgument` does.
2026-11-08 02:58:00 +01:00
Ludovic Marie 350e156a34 Merge pull request #12088 from KBroneZ/claude/datapack-jars-launcher
🤖 Agent: queued. Last of the series, after #12087: a profile with only data packs now plays instead of reporting nothing to install.
2026-11-08 02:57:55 +01:00
Ludovic Marie 502c15aba6 Merge pull request #12086 from KBroneZ/claude/new-world-datapacks
🤖 Agent: queued. First of the 12086 → 12087 → 12088 series (each includes the one before): new worlds get the game folder's `new-world-datapacks`, copied at creation only.
2026-11-08 02:55:14 +01:00
Ludovic Marie 147980da63 Merge pull request #12082 from KBroneZ/claude/found-on-this-computer
🤖 Agent: queued. Only reads other launchers' folders (no writes), and the 86 lang files carry the new strings.
2026-11-08 02:55:09 +01:00
Ludovic Marie 97e99a45b4 Merge pull request #12073 from KyttuXD/fix/metal-cutout-leaves-derivatives
🤖 Agent: queued. Metal now always draws vanilla terrain flat, whatever the section count, which is the path that was already used under the threshold.
2026-11-08 02:55:05 +01:00
Ludovic Marie 37cda82c81 Merge pull request #12060 from ZiQu-dev/fix/oit-cull-depth-metal
🤖 Agent: queued. The 4-ulp depth tolerance fixes the speckles on Metal where the OIT pass's depths differ by a few ulps from the opaque pass's.
2026-11-08 02:55:01 +01:00
Ludovic Marie c76ed64570 Merge pull request #12058 from Mik00000/perf/dimension-tick
🤖 Agent: queued. Ending the tick on the first level skips the dimension swap that did nothing, and the ray chunk cache is per raycast, so no stale chunk outlives one ray.
2026-11-08 02:54:58 +01:00
Ludovic Marie f63ad014e1 Merge pull request #12048 from ilguerro/perf/9996-load-palres
🤖 Agent: queued. One cost to know: the registry-wide cache has 8192 slots that are never reclaimed; past that it falls back to decoding, so it only stops helping, it doesn't grow.
2026-11-08 02:54:54 +01:00
Ludovic Marie 7b33d702f5 Merge pull request #12047 from ilguerro/perf/9996-load-packed
🤖 Agent: queued. The SWAR check tests 8 palette indices per word and has an exhaustive test against the scalar loop, so a bad index is still caught at the same position.
2026-11-08 02:54:50 +01:00
Ludovic Marie dfae932fec Merge pull request #12016 from MSedgeMC/fix/drowned-trident-continue
🤖 Agent: queued. The trident attack continues while `alive && (holding a trident || !nav.done)`, which is vanilla's condition rewritten; a drowned that drops its trident now switches to melee.
2026-11-08 02:54:47 +01:00
Ludovic Marie bf3a5f162f Merge pull request #12008 from MSedgeMC/fix/cat-tempt-tamed
🤖 Agent: queued. A tamed cat no longer starts the tempt goal, as `Cat.TemptGoal`'s `canUse` returns false once tamed.
2026-11-08 02:54:43 +01:00
Ludovic Marie 14fc6d55e0 Merge pull request #11985 from TheMrZZ/ci/overlap-note-faster
🤖 Agent: queued. Tools only: one `git cat-file --batch-check` for the heads instead of a process per PR, and the diffs fetched in parallel; same notes out.
2026-11-08 02:54:39 +01:00
Ludovic Marie 4e6a8131c2 Merge pull request #11980 from MSedgeMC/fix/trade-start-conditions
🤖 Agent: queued. `TradeWithPlayerGoal.canUse` also stops on hurt and on distance > 16; it reads `cx.w.player` like the existing LookAtTradingPlayer goal does, so guests on a server share that approximation.
2026-11-08 02:54:36 +01:00
Ludovic Marie 01451da341 Merge pull request #11977 from MSedgeMC/fix/ghast-still-float
🤖 Agent: queued. The happy ghast's still timeout now ends the float goal as in vanilla, so a parked ghast stays put instead of drifting.
2026-11-08 02:54:32 +01:00
Ludovic Marie 179ebb840a Merge pull request #11965 from MSedgeMC/fix/cube-jump-passenger
🤖 Agent: queued. A ridden cube mob now skips its jump-move as vanilla's `SlimeMoveControl` does while it is a passenger, so a slime on a boat no longer hops off its seat.
2026-11-08 02:54:28 +01:00
Ludovic Marie fca63b5eb8 Merge pull request #11868 from MrCloudy2/fix/rider-teleport-look
🤖 Agent: queued. Matches `ClientPacketListener.handleMovePlayer`: a passenger keeps its seat when the server's position packet comes, instead of snapping out of the vehicle for a tick.
2026-11-08 02:54:25 +01:00
Horizon agentandClaude Opus 5.5 c1cdeb19d4 rustfmt client_lib.rs (verify failed on it)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:50:17 +01:00
J1zeee b03127ab97 Merge fork/fix/12022-piston-push-velocity-restitution 2026-11-08 04:44:47 +03:00
Horizon agentandClaude Opus 5.5 1f9493c4fc Keep falling_block_visible's doc comment on it
The motion helpers went in between the comment and the function it describes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:44:31 +01:00
Nemotron 9524516752 Fix piston push not zeroing entity velocity in lazy chunks (#12022)
move_pushed applied the resolved movement to position only, leaving the
entity's velocity untouched. In a ticking chunk the entity's own tick
masks this (PrimedTnt::tick_among restitutes), but in a lazy chunk the
velocity survives: a primed TNT pushed by a piston into a wall, ceiling
or slime keeps 0.4 / -0.8 / -0.8 instead of vanilla's 0 / 0 / 0.64.

Add restitute_piston after apply_push: compare the post-piston-limit
movement (limited) with the post-collision result (resolved) and, as
Entity.move(MoverType.PISTON, …) does, zero blocked horizontal axes,
zero or slime-bounce the vertical axis, and update on_ground. Covers
Player, Guest and every Entity kind including PrimedTnt.

Add unit test a_pushed_tnt_loses_velocity_into_a_wall (needs prepared
resources) asserting the TNT's vx is zeroed by a wall.

Co-Authored-By: Nemotron <[email protected]>
2026-11-08 04:36:37 +03:00
Horizon agentandClaude Opus 5.5 a465c3efae rustfmt (verify failed on it)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:30:39 +01:00
Horizon agent 904b3036ab Merge remote-tracking branch 'origin/main' into m10280 2026-11-08 02:29:41 +01:00
Horizon agentandClaude Opus 5.5 85d56215e6 Merge main into #11826
es.json: main's file with this PR's 91 translations applied key by key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:28:45 +01:00
Horizon agentandClaude Opus 5.5 ebf06768f1 Merge main into #11950
Main moved build_renderer to game/loading_window.rs; the shared material maps
are set there now, after the custom sky as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:28:17 +01:00
Horizon agentandClaude Opus 5.5 fd03679d85 Merge main into #11829
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:27:35 +01:00
Horizon agentandClaude Opus 5.5 27ed9c66f7 Merge main into #11821
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:27:34 +01:00
Horizon agent 738861aae2 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 02:26:57 +01:00
Horizon agentandClaude Opus 5.5 c7ff85fdf4 Realms: keep the single-player owner UUID; skip drive and stream parts in downloads
- Merge main.
- The owner switch from the offline UUID to the account UUID (integrated.rs,
  lan/conn.rs, lan/playerdata.rs, net.rs, remote.rs) is left out: every world
  Horizon made names its player by the offline UUID, so tamed pets and other
  owner references would no longer know their player. It needs its own PR
  with a migration.
- A tar entry part with a colon (a drive prefix or an alternate data stream)
  would leave the world folder on Windows: skip it, with a test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:26:29 +01:00
Horizon agent 175c2d453a Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 02:25:49 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 673d5cff49 Read the escape case exactly now that the float drags have landed
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:24:42 +01:00
Evrim CicekandClaude Opus 5.5 ca896819d7 rustfmt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 04:24:28 +03:00
GlockSmithandOpenAI Codex GPT-6 0a8df72a16 Keep slab materials in distant terrain
Retain top and bottom slab states in LOD chunk summaries instead of
discarding dry slabs or replacing waterlogged slabs with water. Use the
same full-cell approximation as the existing partial-block filter.

Check real summaries, coarse reduction and emitted faces for every
prepared slab state. All 72 LOD tests pass, including resource-backed
coverage of 606 slab states across 101 materials.

Refs horizon-rust/horizon#12180.

Co-Authored-By: OpenAI Codex GPT-6 <[email protected]>
2026-11-07 20:23:37 -05:00
Ludovic Marie b13dbf0687 Merge pull request #11837 from yahya-nusseibeh/fix/control-socket-path
🤖 Agent: queued. When `/tmp` is shared the socket goes into a private `horizon-<uid>` folder, so another user on the machine can't connect to or squat on the control socket.
2026-11-08 02:20:33 +01:00
Ludovic Marie 0cdb230b54 Merge pull request #11815 from ilguerro/fix/thorns-rest
🤖 Agent: queued at a3fd3597f (main merged in; the draw now uses `random_source::entity()`). Thorns rolls in EquipmentSlot order from the wearer's own random, as `EnchantmentHelper.doPostAttackEffects` does.
2026-11-08 02:20:29 +01:00
Ludovic Marie 6e919e4356 Merge pull request #11806 from MrCloudy2/fix/shield-disable-cooldown
🤖 Agent: queued. The defender now gets the Cooldown packet the server sets on the shield (`Player.disableShield`), so its client greys the shield out for the 100 ticks instead of letting it block client-side.
2026-11-08 02:20:26 +01:00
Ludovic Marie 92cf9ac888 Merge pull request #11799 from Detimes/fix-old-attribute-names
🤖 Agent: queued at 14bfb672f (main and #11750 merged in). UPDATE/REMOVE_MOB_EFFECT ids are renumbered for older clients; effects they don't know are dropped instead of showing as another effect.
2026-11-08 02:20:22 +01:00
Ludovic Marie 0961939b71 Merge pull request #11791 from MrCloudy2/fix/spear-stab-players
🤖 Agent: queued. One cost to keep in mind: `stab_players_for` builds a Vec for every guest using any item each tick (shields, food too); small, but a follow-up could return early when the item is not a spear.
2026-11-08 02:19:16 +01:00
Ludovic Marie 2cd05e462e Merge pull request #11789 from MSedgeMC/fix/camel-sit-room
🤖 Agent: queued. Same check as `Camel.canCamelChangePose` (the standing box against the blocks above), and the test uses a block at y+2 that blocks only the 2.375-tall standing pose.
2026-11-08 02:19:11 +01:00
Ludovic Marie 541f331f1e Merge pull request #11762 from Mayonesu0/perf/launcher-write-data-file
🤖 Agent: queued. The data file is written off the UI thread after `complete_assets`, and a stale one is dropped when the assets change, so a repaired install doesn't read an old index.
2026-11-08 02:19:07 +01:00
Ludovic Marie 973287971d Merge pull request #11759 from doodlyyousuf/251107-fix-guest-left-mob-xp
🤖 Agent: queued. Matches `LivingEntity.dropExperience`/`dropCustomDeathLoot`: experience and equipment follow `lastHurtByPlayerMemoryTime > 0`, while LAST_DAMAGE_PLAYER still needs the player to be resolvable, and the new test checks both sides.
2026-11-08 02:19:04 +01:00
Ludovic Marie 7648d874b9 Merge pull request #11750 from Detimes/fix-11722-old-pick-item
🤖 Agent: queued at fee1085be (main merged in). A 1.21.3 pick_item now becomes the same container swap a 1.21.4+ client sends, so older clients keep middle-click in survival.
2026-11-08 02:19:00 +01:00
Ludovic Marie b91f5f5892 Merge pull request #11741 from yahya-nusseibeh/fix/server-undrained-packets
🤖 Agent: queued. The count goes up at the one `NetEvent::Packet` send in `conn.rs` and down at the hub's drain, so the 2× inbox cap bounds what a flooding client can queue between ticks without touching the hot path otherwise.
2026-11-08 02:18:57 +01:00
Ludovic Marie f159a106a8 Merge pull request #11713 from Akirabane/feat/transfer-stop-wait
🤖 Agent: queued. The stop waits only with `[transfer]` on, and its 90 s bound stays under the supervisor's 120 s kill, so a proxy that never answers can't hang a stop. Built with 14 other PRs on main (pr_ready --quick green apart from known NixOS-only tests).
2026-11-08 02:18:54 +01:00
Ludovic Marie c805ee70c5 Merge pull request #11782 from Teiwazik/render/native-section-fade
🤖 Agent: I moved the distance blend per pixel (it was per triangle through the flat hdr_code). Before/after screenshots and frame time are in my comment: the pack's GPU frame is 121.1 vs 122.0 ms on lavapipe, same within noise.
2026-11-08 02:18:50 +01:00
TheMrZZandCodex 074aa1124f Encode four built-in item components for outgoing inventory stacks
Preserve typed holder and adventure-predicate payloads at the inventory bridge.

Co-Authored-By: Codex <[email protected]>
2026-11-08 02:15:11 +01:00
Horizon agent 14bfb672f8 Merge #11750 into #11799 (both add the last tests of client_session.rs)
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-protocol/src/adapter/client_session.rs
2026-11-08 02:14:29 +01:00
Horizon agent bf321a8425 Merge #11789 into #11792 (both add the last tests of camel.rs)
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/mobs/camel.rs
2026-11-08 02:14:01 +01:00
Horizon agent 2fdc1509ae Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 02:13:52 +01:00
TheApple05andCodex GPT-6 703c0ea18b Generate pinned adapter IDs and record regeneration recipes
Co-Authored-By: Codex GPT-6 <[email protected]>
2026-11-08 01:13:25 +00:00
Nikita Maximilian Grimm 5bea37b4be Merge remote-tracking branch 'origin/main' into portal-ticket-persistence
# Conflicts:
#	crates/horizon-client/src/game/levels.rs
2026-11-08 02:10:48 +01:00
abit-foggyandCodex GPT-6 d15f455027 fix(studio): show replay UI and release cursor
Co-Authored-By: Codex GPT-6 <[email protected]>
2026-11-07 15:08:30 -10:00
Nikita Maximilian Grimm 23f0fd6675 Merge remote-tracking branch 'origin/main' into item-escape-gravity 2026-11-08 02:06:55 +01:00
Horizon agent 8b583a15e1 Merge remote-tracking branch 'origin/main' into m10283
# Conflicts:
#	crates/horizon-client/src/entity_nbt.rs
2026-11-08 02:06:02 +01:00
Florian ErnstandClaude Opus 5.5 48782a8231 Refuse a malformed inline /place feature while the command is parsed
ResourceOrIdArgument decodes an inline value with the registry's codec
while the command is parsed, so a feature the ConfiguredFeature codec
refuses fails the parse: the command never runs, and an execute store
around it keeps its value. Horizon's parse accepted any compound for
minecraft:worldgen/feature and ran the codec only when the command
executed, which then failed and stored 0.

Where the server has its live features, the command registries now carry
a check that runs the same inline decode placement uses (the live
features' catalog and block bindings, through LiveFeatures::decode_inline),
without placing anything. A value it refuses fails the parse with
argument.resource_or_id.failed_to_parse. Without live features (a client,
or a server without the worldgen bundle) the parse is unchanged. The loot
table and every other registry keep their decode.

The message is the native codec's own (for example "invalid world
generation field: to_place"), not DataFixerUpper's text.

Fixes #12171.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:02:45 +01:00
Horizon agentandClaude Opus 5.5 43832ec794 Merge #12145 into #12147 (both change the map_color line)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:58:49 +01:00
Horizon agentandClaude Opus 5.5 d2d9dd7ae1 Merge main into #12112
The End flash moved to tick_end_flash here, while main (0b23212f4) switched
the flash and the dragon fight to the dimension type: keep main's
has_ender_dragon_fight check, and gate tick_end_flash on the End skybox as
main did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:58:14 +01:00
Evrim CicekandClaude Opus 5.5 c0a3af67b0 A teleporting shulker throws off whoever rides it where it stood (Entity.unRide)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:57:52 +03:00
Horizon agentandClaude Opus 5.5 acf0cabce9 Merge main into #12110
main (3443abbde) kept NoAI Nautilus out of the needs_water branch; this PR
gives every Nautilus its own handler, which already refills NoAI ones.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:57:46 +01:00
Ludovic Marie bc6016d19d Merge pull request #12157 from horizon-rust/agent/older-servers-8718
🤖 Agent: Follow-up to #8718. On main, lan_bot's older_clients_of_each_release_join_and_are_sent_chunks fails at 1.21.1 (the reverse step never adds 1.21.2's particle status to ClientInformation); CI misses it because the test returns early without prepared resources. With this it passes, as do all 440 horizon-protocol tests and, on the union, the particle harnesses block/emitter/entity/marker/native_client_particles, particle_providers, player_effect_amplifier and spell_ticks (8/8).
2026-11-08 01:55:30 +01:00
Horizon agent 72e6ef91db Merge #12108 into #11934 (same effect and attribute code)
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/game/commands/world_cmds.rs
#	tools/test_command_exec_parity.py
2026-11-08 01:53:30 +01:00
Horizon agent ab069b576c Merge #11959 into #11934 (same effect and attribute code)
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/mobs.rs
2026-11-08 01:53:27 +01:00
Horizon agent f521237d6c Merge #11883 into #11934 (same effect and attribute code)
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/game/commands/effects.rs
#	crates/horizon-client/src/game/potions.rs
#	crates/horizon-client/src/mobs.rs
#	crates/horizon-client/src/mobs/ai.rs
#	tools/test_command_exec_parity.py
2026-11-08 01:53:24 +01:00
Nikita Maximilian Grimm 18bbc46240 Merge remote-tracking branch 'origin/main' into item-escape-gravity 2026-11-08 01:53:09 +01:00
Horizon agentandClaude Opus 5.5 4f56dfc42b Merge #11813 into #11831 (both change take_mob_passengers)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:52:32 +01:00
Florian ErnstandClaude Opus 5.5 a75a57bd18 Load the world border of the level in place when the world opens
Each level reads its world_border SavedData when it is made
(ServerLevel.getWorldBorder), so a restarted server has the saved border
in place before its first command. #11016 gave each level its own
border. But world open reset the border of the level in place to the
default, and the saved file was read only later, in load_scoreboard (the
first tick's functions, or the first scoreboard use). A first
/worldborder get after a restart read the default, and a first
/worldborder set was put back to the saved size soon after.

World open now reads the in-place level's border with load_border, as
open_level does for the other levels, and load_scoreboard no longer
touches the border.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:51:14 +01:00
Horizon agentandClaude Opus 5.5 f1af021d5c Merge main into #11732
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:49:11 +01:00
Nikita Maximilian Grimm aed804a26d Merge remote-tracking branch 'origin/main' into saved-ticks-startup 2026-11-08 01:49:01 +01:00
Horizon agentandClaude Opus 5.5 fcd33abc9e Merge main into #12133
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:48:46 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 8ce0848a31 Harness: stop a server that never finishes starting
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:48:34 +01:00
Nikita Maximilian Grimm 48c080e387 Merge remote-tracking branch 'origin/main' into t3/scheduled-item-tick-pass 2026-11-08 01:48:27 +01:00
Horizon agentandClaude Opus 5.5 8a218ed405 Merge main into #12127
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:47:55 +01:00
Horizon agentandClaude Opus 5.5 02e546660a Merge main into #12115
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:46:54 +01:00
Horizon agentandClaude Opus 5.5 46e77b05a8 Merge main into #12108
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:46:51 +01:00
Horizon agentandClaude Opus 5.5 9b6074a363 Merge main into #12094
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:46:44 +01:00
Horizon agentandClaude Opus 5.5 3c73be2517 Merge main into #12076
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:46:42 +01:00
Evrim CicekandClaude Opus 5.5 917ce67f0d Test: a shulker bullet's hit teleports an open shulker before it returns
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:37 +03:00
Evrim CicekandClaude Opus 5.5 b11fe1da84 A shulker's hurt teleports it inside the hurt, as vanilla's does
Shulker.hurtServer calls teleportSomewhere() and hitByShulkerBullet() inside
the hurt. Mob::damage has no world, so the flags it leaves now run right
after the hurt: in the mob's own tick (hurt_teleports, also without AI) and
in the game layer (settle_hurt_teleports: /damage, explosions, projectile
hits, the creature outbox), before a bullet's levitation. teleportSomewhere
also refuses a NoAI shulker, keeps inside the world border and unRides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:36 +03:00
Evrim CicekandClaude Opus 5.5 fdb23b8ac6 Harness: a shulker's low-health teleport inside the hurt (/damage while frozen, poison past tick 281, NoAI)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 03:46:36 +03:00
Horizon agentandClaude Opus 5.5 8fd45d810e Merge main into #12041
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:46:31 +01:00
Horizon agentandClaude Opus 5.5 2183972c00 Merge main into #12031
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:45:32 +01:00
Horizon agentandClaude Opus 5.5 ac85e523c7 Merge main into #12012
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:44:51 +01:00
Horizon agentandClaude Opus 5.5 03df68c41d Merge main into #11991
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:44:45 +01:00
Horizon agentandClaude Opus 5.5 a77d401f53 Merge main into #12010
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:44:45 +01:00
Horizon agentandClaude Opus 5.5 1769fff834 Merge main into #11964
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:44:42 +01:00
Horizon agentandClaude Opus 5.5 386ab14035 Merge main into #11959
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:44:40 +01:00
Horizon agentandClaude Opus 5.5 ca82b37eb0 Merge main into #11934
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:44:15 +01:00
Horizon agentandClaude Opus 5.5 a505caa32a Merge main into #11883
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:43:50 +01:00
Horizon agentandClaude Opus 5.5 9aa5c9fe4a Merge main into #11879
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:43:47 +01:00
Horizon agentandClaude Opus 5.5 c7a2daa593 Merge main into #11848
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:43:43 +01:00
Horizon agentandClaude Opus 5.5 e5d8856821 Merge main into #11831
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:43:42 +01:00
Horizon agentandClaude Opus 5.5 3584268d11 Merge main into #11830
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:43:26 +01:00
Horizon agentandClaude Opus 5.5 93bb7f3230 Merge main into #11813
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:43:24 +01:00
Horizon agentandClaude Opus 5.5 bf1070413f Merge main into #11811
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:43:18 +01:00
Horizon agentandClaude Opus 5.5 816d917134 Merge main into #11797
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:43:08 +01:00
Horizon agentandClaude Opus 5.5 2573d1c76a Merge main into #11783
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:43:07 +01:00
Horizon agentandClaude Opus 5.5 3a967d8838 Merge main into #11766
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:42:56 +01:00
abit-foggyandCodex GPT-6 000e13fbe6 test(studio): isolate mouse drag hook fixture
Co-Authored-By: Codex GPT-6 <[email protected]>
2026-11-07 14:42:49 -10:00
Ludovic Marie 40e3f368da Merge pull request #11720 from Teiwazik/seat/follow-plugin-seat-chains
🤖 Agent: I pushed 9bc110bae. The new second position_riders() call after the player moves rebuilt the whole mob index on every tick for every client; it now runs only when the riding graph has something on this player. I also added the missing passenger_vehicles field to main's studio Remote initializer (it did not compile on main) and drop passengers whose vehicle is removed. Both ignored tests pass with prepared resources, and so do the riding harnesses on a union with current main: boat_authority, boat_rider, boat_paddle_reset, mob_rider_navigation, mount_submerged, server_entities, vehicle_command_damage, dedicated_server (8/8).
2026-11-08 01:42:48 +01:00
Horizon agentandClaude Opus 5.5 bd967852e5 Merge main into #11729
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:39:31 +01:00
Horizon agentandClaude Opus 5.5 ecdecc8fd2 Merge main into #11728
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:38:55 +01:00
Horizon agentandClaude Opus 5.5 c4c084be94 Merge main into #11708
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:38:51 +01:00
abit-foggyandCodex GPT-6 6c5d89ffac fix(studio): own marker archive entry names
Co-Authored-By: Codex GPT-6 <[email protected]>
2026-11-07 14:34:05 -10:00
Nikita Maximilian Grimm 6e72e2de7d Merge branch 'tnt-piston-ground' into orb-piston-ground 2026-11-08 01:29:33 +01:00
Nikita Maximilian Grimm 8b0028bbeb Merge remote-tracking branch 'origin/main' into t3/scheduled-item-tick-pass 2026-11-08 01:28:12 +01:00
abit-foggyandCodex GPT-6 e69f6a5050 feat(studio): add replay top bar and timeline
Co-Authored-By: Codex GPT-6 <[email protected]>
2026-11-07 14:25:03 -10:00
itarqos5andClaude Sonnet 5.5 7c34cfa6b2 tools: world_compare.py compares a vanilla and a Horizon world of one seed
Reads the seed, spawn, biomes, structure starts and blocks two saved 26.x worlds
share, with a run-to-run floor from a second world of one game. Run on seed 12345
and a large negative seed: the spawn, every biome and every structure start match,
terrain blocks match to 99.3 to 99.9%, and decoration sits at vanilla's own floor
except trees, a few points under it. perf_bench.py gets --seed to make the worlds.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011paghWkrnyQRBhJRodZpG2
2026-11-08 00:21:56 +00:00
Ludovic Marie b399f0ddc5 Merge pull request #11775 from Teiwazik/older-servers/sign-update-order
🤖 Agent: Checked against the 26.3 client jar: ServerboundSignUpdatePacket's codec is pos, fixedSizeList(4) of stringUtf8(384), then SignTextSlot as an idMapper VarInt (BACK=0, FRONT=1), so reading the side last and writing it as the old boolean after the position is right. It only runs in the older-server adapter, so 26.3 servers are untouched. I merged main (the #8718 conflict in translate.rs: kept #8718's arms plus this one); 440 horizon-protocol tests and clippy pass.
2026-11-08 01:18:50 +01:00
Horizon agentandClaude Opus 5.5 a3fd3597f4 Thorns: draw from random_source::entity(), which replaced dispenser::entity_random on main
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:16:10 +01:00
Horizon agent 1d9f455dac Merge remote-tracking branch 'origin/main' into HEAD 2026-11-08 01:15:53 +01:00
Horizon agent f97dffe988 Merge remote-tracking branch 'origin/main' into pr-11775
# Conflicts:
#	crates/horizon-protocol/src/adapter/translate.rs
2026-11-08 00:15:30 +00:00
KBroneZandClaude Opus 5.5 c6f52257e2 fix: count 1.20 recipe results in the reason only when there are some
The partial reason of a carried 1.20 mod leaves out the recipe clause
when no result names `item`, and says "1 recipe result names" for one.
docs/modpacks.md says how the game treats each 1.20-shaped file, as an
offscreen run of a carried synthetic 1.20 jar showed: one file at a
time, never the whole start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 02:12:22 +02:00
Florian ErnstandClaude Opus 5.5 07d0cfc344 Format the mannequin main-hand writer
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:11:37 +01:00
Horizon agentandClaude Opus 5.5 949eef6772 Russian launcher strings: fix the JSON and a placeholder
A missing comma after the horizon-server line made ru.json unreadable, so
the whole launcher fell back to English (the i18n tests failed on it).
The {mods} placeholder had been translated, so the count would never be
filled in. Also "подключиться" for two "Couldn't connect" lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:08:05 +01:00
KBroneZandClaude Sonnet 5.5 ecce33154e Launcher: installing a data pack counts what the game reads today
datapacks::READ named four kinds, so a pack of only recipes, loot tables, advancements or
worldgen was refused as changing nothing, and the install note listed them as not read. READ
now lists the kinds the game loads (worldgen by folder, so world presets still count as not
read), the refusal goes through trf(), and docs/datapack-upgrade.md no longer says worldgen is
not applied.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-08 02:07:21 +02:00
itarqos5andClaude Sonnet 5.5 d6f88d2483 feat(render): GPU Culling gets an Auto mode that tries it where the CPU limits the frame
GPU Culling pays where the CPU is the slower of CPU and GPU and costs where the
GPU is, and a machine's parts don't say which. Auto watches the frames' median CPU
and GPU times, tries it where the CPU is clearly the slower one, and keeps it only
if the frame's busier side dropped under 97%; a trial that didn't help is undone and
waits 5 minutes, then 20, then for good.

gpuCulling in horizon-graphics.txt is now false|true|auto (older files read as before);
Settings > Performance steps Off/On/Auto; horizon-ctl gpu-culling takes auto. Off stays
the default and no preset sets it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011paghWkrnyQRBhJRodZpG2
2026-11-08 00:04:36 +00:00
TheMrZZandCodex gpt-6.1-sol 0cdc4a49da Preserve styled container names in the live block model
Carry admitted Component tags through name state, saves and drops; let modeled name removal override stale source names.

Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-08 01:02:29 +01:00
Horizon agentandClaude Opus 5.5 fee1085bec Merge main into fix-11722-old-pick-item
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:02:24 +01:00
Horizon agentandClaude Opus 5.5 272518c1f2 Merge main into fix-old-attribute-names
Main already carries the 1.21.1 and 1.20.6 attribute tables (consolidated in
d79a36101); kept main's generated tables and this branch's mob effect renumbering.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:02:00 +01:00
abit-foggyandCodex GPT-6 68459f0442 feat(studio): persist timeline markers
Co-Authored-By: Codex GPT-6 <[email protected]>
2026-11-07 14:02:00 -10:00
Nikita Maximilian Grimm 2877c7fbfa Merge remote-tracking branch 'origin/main' into saved-ticks-startup 2026-11-08 01:01:52 +01:00
KBroneZandClaude Sonnet 5.5 5be2aba2ae style(port-pack): rustfmt the shaderpacks test
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-08 02:01:09 +02:00
Nikita Maximilian GrimmandClaude Opus 5.5 6b371cdc48 HDR float frame: the frame follows HDR and the pack picked at once
Under HORIZON_HDR_FRAME=float, when HDR, Smooth Gradients or the pack picked call for another
frame than the renderer's, the renderer is made again on the same device before the next frame
draws, and the world is meshed again, as after a lost device. Without the switch nothing changes:
the frame stays until the next start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:00:38 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 1b63e0abc2 Startup waits for the forced chunks before the first tick, so saved ticks there fire on time
MinecraftServer.prepareLevels waits for the chunks the restored tickets hold
(ChunkLoadCounter) before the first tick, and the first tick unpacks their
saved block and fluid ticks at the game time they were saved at. Horizon's
dedicated and integrated servers started ticking while the forced chunks were
still streaming in, and the saved ticks were unpacked from the tick the chunk
arrived, one tick or more late.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:58:28 +01:00
Nikita Maximilian Grimm 9ab82c59cd Merge main into hdr-tone-curve: #11987 is on main now 2026-11-08 00:56:51 +01:00
Nemotron e0cbbdb50a Fix piston push not zeroing entity velocity in lazy chunks (#12022)
move_pushed applied the resolved movement to position only, leaving the
entity's velocity untouched. In a ticking chunk the entity's own tick
masks this (PrimedTnt::tick_among restitutes), but in a lazy chunk the
velocity survives: a primed TNT pushed by a piston into a wall, ceiling
or slime keeps 0.4 / -0.8 / -0.8 instead of vanilla's 0 / 0 / 0.64.

Add restitute_piston after apply_push: compare the post-piston-limit
movement (limited) with the post-collision result (resolved) and, as
Entity.move(MoverType.PISTON, …) does, zero blocked horizontal axes,
zero or slime-bounce the vertical axis, and update on_ground. Covers
Player, Guest and every Entity kind including PrimedTnt.

Add unit test a_pushed_tnt_loses_velocity_into_a_wall (needs prepared
resources) asserting the TNT's vx is zeroed by a wall.

Co-Authored-By: Nemotron <[email protected]>
2026-11-08 02:56:20 +03:00
KBroneZandClaude Sonnet 5.5 56ec50a875 fix(port-pack): an empty shaderpacks folder is not a shader pack to convert
The CurseForge app, and mods such as Sodium, create `shaderpacks/` in an instance
even when the player never installed a shader pack. Import counted the folder
itself as one "shader pack, conversion pending" file and listed it under "not yet",
so a client-only instance such as one with Sodium, Lithium, Jade, malilib and
Litematica reported 4 "not yet" rows for 3 mods. A folder instance now reports
shaderpacks/ only when it holds something, and a zip only when it has a file
under its shaderpacks/ (a bare directory entry no longer counts).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-08 01:54:47 +02:00
Florian ErnstandClaude Opus 5.5 066b6e9cef Save a mannequin's own fields and none of a Mob's
Mannequin extends Avatar extends LivingEntity; it is not a Mob.
Mannequin.addAdditionalSaveData always writes profile, hidden_layers,
main_hand and pose after LivingEntity's fields, and none of
Mob.addAdditionalSaveData's. Horizon left out the four unless they were
loaded, and wrote PersistenceRequired, CanPickUpLoot, LeftHanded and NoAI.

A mannequin now reads main_hand and hidden_layers into the main-arm and
hidden-layer state it already had (a list with an entry that is not a part
hides nothing, as the codec's failed read), and writes all four from its
live state: the empty profile when it has none, the hidden layers in
PlayerModelPart order, its arm and its pose. It neither reads nor saves
Mob.readAdditionalSaveData's flags, and its save drops the Mob-owned keys
over a stale loaded compound. Every other kind is unchanged.

Fixes #12135.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:53:14 +01:00
KBroneZandClaude Opus 5.5 172d7c51e6 fix: keep the 1.20 partial reason on one line of words
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:51:33 +02:00
Nikita Maximilian Grimm 5cf4a1dec8 Merge remote-tracking branch 'origin/main' into t3/scheduled-item-tick-pass 2026-11-08 00:49:17 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 4bf9b604f7 Keep the contact drop range half-open
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:49:15 +01:00
Nikita Maximilian Grimm b95e34a990 Merge remote-tracking branch 'origin/main' into tnt-piston-ground
# Conflicts:
#	crates/horizon-client/src/game/piston_push.rs
2026-11-08 00:46:47 +01:00
GlockSmithandOpenAI Codex GPT-6 e86ce41888 Merge main and retain HDR emission on styled sign text
Resolve the overlap with #11863 in the styled span and glyph loops. Keep its emission tier on glyphs, outlines and decoration quads, with regression coverage.

Co-Authored-By: OpenAI Codex GPT-6 <[email protected]>
2026-11-07 18:42:38 -05:00
Horizon agentandClaude Opus 5.5 458f0e4134 Native shader packs: blend the section fade by distance per pixel
The fade-in's 16-to-32-block distance blend was computed per vertex and
carried in the flat hdr_code, so it was one value per triangle (the
provoking vertex's) and near faces faded in steps. The flat bits now hold
only the section's own visibility (the same for the whole section), and
horizon_material_faded blends it by the interpolated spherical distance,
as terrain.wgsl's interpolated visibility does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:40:34 +00:00
Kacper 29b3374b5d Merge pull request #12098 from NikitaMGrimm/boat-drop-motion
A destroyed boat drops its item with vanilla's drop motion
2026-11-08 00:40:24 +01:00
Kacper 02042bf6b4 Merge pull request #12097 from NikitaMGrimm/boat-fire-timer
A boat burns: its fire timer counts down, fire hurts it and water puts it out, as in vanilla
2026-11-08 00:40:18 +01:00
Kacper 79e277451b Merge pull request #12095 from Web-mc1/fix/telemetry-scrub-word-boundaries
telemetry: match the user name exactly when lowercasing moves boundaries
2026-11-08 00:40:10 +01:00
Kacper e5c1ea0612 Merge pull request #12092 from Web-mc1/fix/java-properties-save-convert
java_properties: write a NUL and a non-BMP character as Java does
2026-11-08 00:40:03 +01:00
Kacper 2f39e246fe Merge pull request #12084 from KBroneZ/claude/windows-unused-mut
Fix Windows-only unused_mut on the TCP keepalive builders
2026-11-08 00:39:56 +01:00
Kacper 2cd9e12ecd Merge pull request #12078 from KBroneZ/claude/oracle-windows
Run tools/neoforge_oracle.py on Windows
2026-11-08 00:39:43 +01:00
Kacper 6d32a88a50 Merge pull request #12069 from senjinthedragon/horizon-uniforms-lights-tier
Shader packs: Horizon's dynamic lights as uniforms, horizonTier for terrain and entities
2026-11-08 00:39:37 +01:00
Kacper 124e88e731 Merge pull request #12068 from NikitaMGrimm/fix/diode-moving-piston-support
A repeater or comparator on a retracting piston stays, as in vanilla
2026-11-08 00:39:30 +01:00
Kacper 1a004614f8 Merge pull request #12056 from TheMrZZ/fix/h255-mob-piston-ground
Project ground after unoccupied server NoAI Mob piston movement
2026-11-08 00:39:23 +01:00
Kacper 1edf540479 Merge pull request #12054 from TheMrZZ/fix/h234-machine-recipe-placement
Route recipe-book placement into actual furnace menus
2026-11-08 00:39:16 +01:00
Kacper 9bccc1056f Merge pull request #12053 from TheMrZZ/fix/h245-sulfur-bucket
Pick up a sulfur cube with an empty bucket
2026-11-08 00:39:09 +01:00
Kacper d144af4a11 Merge pull request #12049 from ilguerro/perf/9996-load-loadlight
Load saved light directly from its layers instead of expanding and repacking
2026-11-08 00:39:03 +01:00
Kacper 616707f3d7 Merge pull request #12033 from Vaspyyy/feat/native-muffle-sounds
Native mod API: muffle the game's sounds for a while, as ears ringing after a blast (native_muffle_sounds)
2026-11-08 00:38:56 +01:00
Kacper 1c5744ac24 Merge pull request #12014 from Vaspyyy/fix/native-mod-image-slot
Native mods: a game built with horizon-mixins gets the mod image slot, native-mods.json or not
2026-11-08 00:38:49 +01:00
Kacper c124718cbc Merge pull request #12002 from MrCloudy2/fix/sprint-hit-slowdown
lan_e2e: sprint-hit-slowdown runs up instead of teleporting, and catches a missing slowdown
2026-11-08 00:38:43 +01:00
Kacper 0b8f18dd40 Merge pull request #11992 from TheMrZZ/fix/h275-test-defs-world-packs
Load a world's test instances from its data packs when it opens
2026-11-08 00:38:36 +01:00
Kacper e51c277db7 Merge pull request #11987 from NikitaMGrimm/hdr-hud-composite
HDR float frame: the HUD and menus lay over the world's light
2026-11-08 00:38:29 +01:00
Kacper fc61e4e9ff Merge pull request #11986 from NikitaMGrimm/hdr-entity-marks
HDR: mobs get HDR lighting and held light sources shine again
2026-11-08 00:38:23 +01:00
Kacper 2c300290d5 Merge pull request #11983 from TheMrZZ/fix/h207-effective-equippable
Honor supported pumpkin Equippable overrides on item use
2026-11-08 00:38:10 +01:00
Kacper 16260920c3 Merge pull request #11969 from Mik00000/perf/mob-ai-stress-bench
mobs: reuse pathfinding allocation buffers and add stress_mob_ai benchmark
2026-11-08 00:38:03 +01:00
Kacper d84428c781 Merge pull request #11968 from TheMrZZ/fix/h237-clone-block-ticks
Copy a clone's pending block ticks to its destination
2026-11-08 00:37:57 +01:00
Kacper e5f23f8b40 Merge pull request #11958 from TheMrZZ/fix/h095-allay-liked-player-ttl
Keep an Allay's liked_player memory time to live and expire it
2026-11-08 00:37:50 +01:00
Kacper 17e4124d04 Merge pull request #11956 from Stink-O/native/hold-world
Native mod API: hold the terrain's picture while the world changes (`native_world_hold`)
2026-11-08 00:37:43 +01:00
Horizon agentandClaude Opus 5.5 37eafb6c1b Older clients: a 1.21.1 client's information gains 1.21.2's particle status
The reverse step for 1.21.1 clients passed ClientInformation through, so a
host read past its end. The older-server adapter now writes 1.21.1's real
layout (no particle status), which made lan_bot's
older_clients_of_each_release_join_and_are_sent_chunks fail at 1.21.1;
real 1.21.1 clients were refused the same way. The step appends
ParticleStatus.ALL in configuration and play.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:37:41 +00:00
Florian ErnstandClaude Opus 5.5 aee1b8b81c Adopt /data edits on a live interaction entity
EntityDataAccessor.setData loads the edited compound into the same entity,
and Interaction.readAdditionalSaveData reads its width, height, response
and the attack and interaction records. Horizon kept an interaction only
as a generic entity with its loaded compound, and its live data write
took markers alone, so every /data edit answered "Nothing changed".

A server interaction now holds its settings (InteractionState: width,
height, response and the two PlayerAction records) next to its position.
It reads them when it loads or is summoned, saves from them
(addAdditionalSaveData, a record only when set), and a /data edit decodes
the edited compound into the same entity, which keeps its id and UUID.
Every other kind is unchanged.

Fixes #12131.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:29:55 +01:00
RINNECODERandClaude Opus 5.5 c56e9312ee Port pack: a mod's own rarity or map colour stays the template's, not a refused mod
NeoForge lets mods add item rarities (Immersive Engineering's masterwork) and some blocks carry a
map colour id past 26.3's 61 (Mekanism's gas blocks: 63). The game refuses the whole content
root for either, so one such file left every block of the mod out. They now keep the template's
and the report names them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:28:23 -06:00
RINNECODERandClaude Opus 5.5 9f52bf9a83 Port pack: a block that can't occlude (noOcclusion) carries occludes=false
The oracle reports can_occlude per state, but the carry ignored it: a
full-cube block made with noOcclusion() (one its block entity draws) took
its template's occlusion and hid the faces behind it, leaving a hole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:26:03 -06:00
Nikita Maximilian GrimmandClaude Opus 5.5 a9612bdabc Apply an item's gravity before pushing it out of a block
ItemEntity.tick applies gravity (or the fluid movement) first and then
moveTowardsClosestSpace, whose 0.75 scales the already-fallen vertical
speed. The push ran before tick_move_before_block_effects, so gravity
came after it. Pass the escape speed into the move and apply it right
after gravity; the native block-contact pipeline is unchanged.

Fixes #12018

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:25:22 +01:00
Oloion 2a33c013d7 perf: branchless frustum culling, zero-copy Arc meshing regions and 3D upload priority 2026-11-08 02:24:31 +03:00
Nikita Maximilian GrimmandClaude Opus 5.5 b58576b523 Reload saved portal tickets and pause their expiry while their chunk loads
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:24:26 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 a20d3296b4 A sideways piston push no longer leaves an experience orb marked on ground
The orb kept its own vertical-only on-ground rule for a piston push. It
now takes the server's end-of-move rule that items, primed TNT and armor
stands use: on ground only when the push's downward part was blocked.

Fixes #12100

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:23:06 +01:00
RINNECODERandClaude Opus 5.5 eadbb41095 Shader packs: run a workGroups over 65535 per dimension
wgpu caps a dispatch at 65535 work groups per dimension and panics past it;
GLSL packs may ask for more (131072). A larger workGroups now runs as the
same number of groups in a shape within the limit, and main works out each
group's place in the declared dispatch, so gl_WorkGroupID,
gl_GlobalInvocationID and gl_NumWorkGroups read what they would there. The
shape uses every group exactly, so no group leaves before a barrier. A
count no shape holds skips the program with a note; an oversized
workGroupsRender dispatch is not run instead of panicking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:22:07 -06:00
RINNECODERandClaude Opus 5.5 bc59734a29 Shader packs: copy a struct or array holding atomics as its declared type
naga's GLSL frontend turns a uint/int that an atomic*() call touches into
an atomic type after parsing. A load or store of a whole struct or array
holding such a member then had the upgraded type: `Cell c = buf.cells[i];`
and `uint copy[4] = shared_counts;` failed validation. A whole struct or
fixed-size array of integers in a buffer or shared memory is now loaded
and stored member by member, so each copy keeps its declared type.

Vendored-naga patch: third_party/naga/src/front/glsl/context.rs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:20:58 -06:00
RINNECODERandClaude Opus 5.5 626c60740d Shader packs: make an image in its layout qualifier's format
An image declared RGB10_A2, RGB10_A2UI or a 16-bit SNORM format was made
as an RGBA8, RGBA8UI or 8-bit SNORM texture, so a shader binding it as
layout(rgb10_a2) etc. was refused ("is rgb10_a2 but its texture is
Rgba8Unorm"). Each now gets the wgpu format of its GLSL qualifier; one the
GPU can't store into is left out with a note, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:20:58 -06:00
RINNECODERandClaude Opus 5.5 0bd5a4f201 Shader packs: an exact argument beats a conversion in GLSL overloads
naga's GLSL frontend never compared an exactly matching argument with the
previous best overload's conversion there, so greaterThanEqual(ivec3, uvec3)
found the uvec3 overload no better than the vec3 one and reported
"Ambiguous best function". GLSL 4.60 §6.1 ranks an exact match above any
implicit conversion: the uvec3 overload wins. Zephyr Starlight's
shadowcomp1-4 failed on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:20:49 -06:00
RINNECODERandClaude Opus 5.5 cf0b0d02c8 Shader packs: a setting in a comment may end at its line
Packs list their const settings in a block comment one per line with no
';' (`const vec4 colortex6ClearColor = vec4(0.0, 0.0, 0.0, 1.0)`). The
reader looked for the next ';' and took every following line as the value,
so each such setting was refused as 'not a vec4' (Zephyr Starlight logged
85 multi-line notes) and its clear colour was lost. In a comment a
declaration now ends at the first ';' or line end; live code still reads to
the ';'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:20:49 -06:00
Nikita Maximilian GrimmandClaude Opus 5.5 60fff3987f Keep the drops of entities' block contacts on the next tick
tick_blocks applies the entities' block contacts (a boat breaking a lily
pad) before the scheduled ticks; vanilla runs them inside each entity's
own tick, so their drops still wait for the next tick.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:19:02 +01:00
Evan-lhmandClaude Opus 5.5 1b93764780 Launcher: a 0 px blur leaves the glass plates sharp (#12062)
With the blur at 0 the plates still read their backdrop bilinearly between
texel centres, and a texel is 3 to 6 logical pixels of pixel art, so the
scene behind the glass stayed slightly soft. With no blur, read the texel
under the point instead.

Fixes #12062

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:18:19 +01:00
Horizon agentandClaude Opus 5.5 52aad2205d Older servers: keep the particle markers inside the adapter's connections
The render crate read a trail duration of -1 as the pre-1.21.4 marker, and
the client read particle ids -2/-3 as the old entity-effect providers, for
any server: a 26.3 server sending those values got the legacy behaviour.
The client now decides from the connection's release (received_particle)
and passes an explicit legacy_trail_lifetime option; a current server's
-1 stays a lifetime of -1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:18:13 +00:00
KBroneZandClaude Opus 5.5 da4d26b00d feat: carry 1.20 jars' data under 1.21's folder names
A content mod jar whose data files are mostly in the folders 1.21
renamed (recipes/, loot_tables/, structures/, advancements/,
predicates/, item_modifiers/, functions/ and tags/blocks, items,
entity_types, fluids, game_events, functions) was refused by `carry`.
Now the carry moves each such file to the singular name 26.3 reads.
A file the jar also ships under the new name keeps that copy, and a
1.21 jar's stale plural folder is left as it was.

The JSON stays 1.20's: a recipe whose result names its item as `item`
(before 1.20.5), which 26.3 skips, is kept as it is instead of counted
as upgraded, and NBT in loot functions, ingredients and predicates is
not upgraded yet. The report therefore marks such a mod partial
whatever its harness says, and says why. `check` still refuses 1.20
jars until the JSON steps of #10262 land.

Part of #10262.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 01:14:06 +02:00
KBroneZandClaude Sonnet 5.5 342315073f Launcher: the data pack support text says what the game reads today
The browser's data pack note still said recipes, loot tables, advancements, other tags and
worldgen were not read. The game reads them now. The note goes through tr() and is in all
86 language tables (translated in 14, English elsewhere).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-08 01:13:03 +02:00
martipopsandClaude Opus 5.5 de0132b638 Controllers: the craft prompt says Quick Craft, and its setting's description is shorter
Two words, like the guide's other rows, and the same name as Quick Craft on
Servers. The exact rule (single player, LAN worlds from the server list) stays
in docs/controllers.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:12:25 -05:00
Florian ErnstandClaude Opus 5.5 31d39aec80 Count /loot kill under execute as a connected player as that player's kill
LootCommand.dropKillLoot takes the command source's entity as the killer:
a player is the last damage player, so killed_by_player holds, and its
own weapon counts for looting. Under `execute as <connected player>` from
another player, Horizon counted no player kill and used the issuer's
held stack.

For a connected player as the source, /loot kill now reads that player's
selected stack with it in place (for_player); an empty hand stays empty.
The loot roll, the output, the feedback and the result run as before,
after the issuer is back. Other sources keep their current rule.

Fixes #12122.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:11:21 +01:00
Nikita Maximilian Grimm 30f1fc145d Merge remote-tracking branch 'origin/main' into t3/scheduled-item-tick-pass 2026-11-08 00:10:09 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 f509e284bf Tick an item a scheduled block tick drops in that tick's entity pass
ServerLevel.tick runs the block ticks and block events before
entityTickList.forEach, so a dropper's item ticks on the tick it is
dispensed. The item cutoff was taken right after the tick functions;
take it just before the entity pass instead. Primed TNT and falling
blocks keep their own packet cutoff (#10063).

Fixes #12017

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:10:05 +01:00
itarqos5andClaude Sonnet 5.5 3d5216e717 perf(render): pass terrain's interpolants in 5 locations, not 12
Terrain's vertex stage exported 20 scalars in 12 interpolant locations. A GPU's
vertex stage pays per location (AMD gives each a parameter slot): on an RX 580 the
12 cost 3.2 ns per quad and the same values in 5 cost 1.6. TerrainOut stays the type
the shader code uses; TerrainWire crosses the stage boundary, each component
interpolated on its own and the integers flat, so a pixel gets the same values.

RX 580, Vulkan, 1080p, render distance 16: village 523.7 -> 590.8 FPS (+12.8%),
forest 267.6 -> 323.7 (+21.0%).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011paghWkrnyQRBhJRodZpG2
2026-11-07 23:09:46 +00:00
Horizon agentandClaude Opus 5.5 9bc110bae6 Riding: skip the extra rider pass when nothing rides the player
The second position_riders() call after the player moves rebuilt the mob
index every tick for every client; run it only when the riding graph has
something on this player. Also forget passengers whose vehicle is removed,
and add the new field to main's second (studio) Remote initializer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:08:57 +00:00
Florian ErnstandClaude Opus 5.5 8f9e984d63 Compare a mob's hurt cooldown on the incoming damage
LivingEntity.hurtServer compares a hit inside the hurt cooldown
(invulnerableTime > 10) with lastHurt by its incoming amount, before
armor and Resistance, and keeps that amount as lastHurt. actuallyHurt then
reduces only the difference. Horizon reduced the hit first, then compared
and stored the reduced amount. Under full Resistance every hit reduced to 0,
so a stronger hit inside the cooldown was refused. With armor, a second
hit dealt reduced(8) - reduced(4), not reduced(8 - 4).

The comparison now uses the amount after the helmet, freeze and infinity
changes. The existing armor, Resistance, protection, witch and wolf armor
steps get the accepted difference, and last_hurt keeps the incoming amount.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 00:07:47 +01:00
hunix 14ba691e53 Components: keep a translatable fallback literal instead of looking it up as a key
The component parser translated a missing key's fallback as if it were another key, so a fallback that named a
real key showed that key's translation. It now builds the text through Text::translate_with_fallback, as
TranslatableContents.decompose does (Language.getOrDefault(key, fallback)), which also keeps the fallback in the
component's JSON. Fixes #12042.
2026-11-07 13:02:44 -10:00
hunix 877cb37978 Web panel: accept LAN browsers when bound to 0.0.0.0 or ::
Bound to every interface, the panel's Host check accepts any IP address with the bind's port (and localhost),
which a rebound DNS name can never be, and the login link names this computer's network address instead of
0.0.0.0. Fixes #12039.
2026-11-07 13:02:44 -10:00
Nikita Maximilian Grimm 83535ddcc1 Merge remote-tracking branch 'origin/main' into minecart-drop-motion 2026-11-07 23:58:46 +01:00
Nikita Maximilian Grimm 2c672eae2d Merge remote-tracking branch 'origin/main' into tnt-piston-ground 2026-11-07 23:58:26 +01:00
bulkandClaude Opus 5.5 12273a4e8e Natural spawning: find the players near a spawn start by square
Every spawn start measured its distance to every player to keep those
within reach of its attempts. With more than 8 players, the level keeps them
by the 256-block square they stand in, built once a pass first asks, and a
start reads the 3×3 squares around it: every player within reach is in
them, and the nearest one is the same in any order. The spawn draws are
untouched.

(the player-square part of commit e3b70aace7; its region spawning is left
out)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 22:56:49 +00:00
sergue212fbrightandOpenAI Codex GPT-6 796047f1e8 Render styled sign text and animate obfuscated glyphs
Follow vanilla 26.3 sign layout and baked glyph geometry, preserving styles through clipping and rebuilding animated sign meshes. Extend the block-entity oracle with styled components and glyph vertices.

Co-Authored-By: OpenAI Codex GPT-6 <[email protected]>
2026-11-07 17:53:48 -05:00
Kacpherek 34194ab7ec test: give the remote mining fixture's remote_break_restricted the position it now takes 2026-11-07 23:47:06 +01:00
Florian ErnstandClaude Opus 5.5 7803f1351e Cite AttributeMap.pack for the sulfur cube attribute save
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:46:38 +01:00
Florian ErnstandClaude Opus 5.5 c9b07b1ffb Pick /test pos's block with a connected source player's view
TestCommand.showPos takes the source player (getPlayerOrException) and
that player's own pick: its eyes and view, not the execute position. So
`execute as <connected player> run test pos` from another player answers
with the block that player looks at, and the issuer is told. Horizon
only accepted the player in place, so the command did nothing.

For a connected player as the source, /test pos now picks the block with
that player in place (for_player) and only the pick runs there; the test
is looked up in the command's level and the issuer told afterwards. Every
other source keeps its current rule, and the highlight packet is
unchanged.

Fixes #12102.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:45:41 +01:00
Kacpherek ec77214342 Send a bounce in the tick it happens: move the update clock to its next interval (ServerEntity.sendChanges) 2026-11-07 23:42:53 +01:00
PetroandOpenAI GPT-6 Luna bec6ac6448 Fix legacy Intel Metal startup and terrain rendering
Use compatible compute shaders and direct terrain draws on older Intel Metal.

Co-Authored-By: OpenAI GPT-6 Luna <[email protected]>
2026-11-07 23:42:25 +01:00
Kacpherek a2b3f669ef Swing at a wandering trader only for a named name tag, not a lead or an unnamed tag (NameTagItem, Entity.interact) 2026-11-07 23:42:05 +01:00
Kacpherek 7bfecd3fd1 Time the End flash by the End's own clock (ClientLevel.tick: getDefaultClockTime) 2026-11-07 23:41:38 +01:00
Kacpherek 43ef30f98c Draw wings and move the cape only for a chest-slot equippable (HumanoidArmorLayer.shouldRender) 2026-11-07 23:41:25 +01:00
Nikita Maximilian Grimm 2dbcb75cfa Merge remote-tracking branch 'origin/main' into execute-block-nbt 2026-11-07 23:41:15 +01:00
Kacpherek ce4f0d7074 Let shears in hand still take a camel's back seat or open a ridden mount's inventory (Entity.interact falls through to mobInteract) 2026-11-07 23:41:12 +01:00
Kacpherek 4ba236928d Run no heartbeat sound or random draw for the warden on the server thread (Warden.tick's client branch only) 2026-11-07 23:41:04 +01:00
Kacpherek GIT_COMMITTER_NAME=Kacpherek [email protected] [email protected] 34c5bb84e6 Keep a silent breeze's whirl and idle sounds quiet (EntityBoundSoundInstance.canPlaySound) 2026-11-07 23:40:45 +01:00
Kacpherek GIT_COMMITTER_NAME=Kacpherek [email protected] [email protected] e809bed768 Play the warden's heartbeat once in single player: the server thread's copy is a local sound too 2026-11-07 23:40:45 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 34f528ffcb Drop a destroyed minecart's item and contents with vanilla's motions
VehicleEntity.destroy spawns the cart item through spawnAtLocation, with an
ItemEntity's own motion (0.2 up, random sideways). A container cart's contents
go through Containers.dropContents: a spot in the cart's block, pieces of 10 to
30 with the level random's scatter and no pickup delay, every slot drawing its
spot, and chestVehicleDestroyed drops the emptied container again. Fixes #12099.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:40:28 +01:00
Kacpherek 031037cee5 Send stepped move paths only for living entities, as vanilla's SteppedInterpolationTracker does 2026-11-07 23:39:00 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 7f6f26a33a A shulker lid's push sets the pushed entity's on-ground flag the same way
ShulkerBoxBlockEntity.moveCollidedEntities pushes through Entity.move too,
so it ends in the same setOnGroundWithMovement as a piston's push.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:30:46 +01:00
Kacpherek 70342ed68b Show your own crit particles on critical hits against other players on servers (Player.attackVisualEffects, LocalPlayer.crit) 2026-11-07 23:30:01 +01:00
Kacpherek 98d7553124 Unlock used_ender_eye advancements when throwing an eye of ender (UsedEnderEyeTrigger.trigger)
EnderEyeItem.use now fires the minecraft:used_ender_eye criterion with the squared horizontal distance to the located structure, matched against the distance bounds squared as MinMaxBounds.Doubles.matchesSqr does.
2026-11-07 23:29:23 +01:00
Kacpherek ef6fc399f5 List the blocks an item can break or be placed on in its tooltip (AdventureModePredicate.addToTooltip) 2026-11-07 23:29:04 +01:00
Kacpherek 94aeeac20d Flash the End sky on servers and pan its rumble toward the flash (ClientLevel.tick, DirectionalSoundInstance)
The End flash state now ticks on every client, so servers, LAN guests and single player show the sky flash and its light. Its weather.end_flash sound plays 30 ticks later ten blocks from the camera toward the flash, follows the camera, and is skipped under the credits.
2026-11-07 23:28:35 +01:00
Kacpherek 7f51885a85 Show mobs bouncing on slime blocks and beds to other players without cutting the bounce short (SteppedInterpolationTracker) 2026-11-07 23:28:17 +01:00
Kacpherek 5ecd155b76 Stop cracking blocks a can_break tool may not break in adventure mode on servers (Player.blockActionRestricted) 2026-11-07 23:27:33 +01:00
Kacpherek 5fe374444f Keep riders in the portal when they get off a vehicle standing in one (LivingEntity.dismountVehicle)
Getting off a boat, minecart or mount whose block is in #minecraft:portals now takes the free-position branch straight up from the rider, as for a removed vehicle, instead of the vehicle's side dismount spot.
2026-11-07 23:27:14 +01:00
Kacpherek c3f7e94775 Let foxes stroll into villages at night (Fox.FoxStrollThroughVillageGoal) 2026-11-07 23:26:35 +01:00
Kacpherek ff50de2553 Shear saddles off horses, striders, camels and nautili with a sound (Mob.attemptToShearEquipment)
Shears now take the saddle off any #can_equip_saddle mob, not only pigs, and play the saddle's shearing sound item.saddle.unequip unless the mob is silent. A mount wearing horse or nautilus armor is left alone, since vanilla shears that body armor first.
2026-11-07 23:26:20 +01:00
Kacpherek d4ea299fdd Let adventure-mode can_break and can_place_on predicates with nbt or components match their blocks (BlockPredicate.matches(BlockInWorld)) 2026-11-07 23:25:54 +01:00
Kacpherek 5383881562 Mark worlds with experimental features as Experimental in the world list (LevelSummary.createInfo) 2026-11-07 23:25:20 +01:00
Kacpherek 1c402c47a7 Anger piglins that see a player break a chest boat (ContainerEntity.chestVehicleDestroyed)
A survival player's hit that breaks a chest boat with entity_drops on angers the piglins that see it, as AbstractChestBoat.destroy does through chestVehicleDestroyed.
2026-11-07 23:25:04 +01:00
Kacpherek 6e5f7e88f7 Hold a lead at the right point while gliding, riptiding or swimming in third person (Player.getRopeHoldPosition)
The lead now hangs from the body's yaw, not the head's, follows the eased position, and uses vanilla's gliding/riptide and swimming hold points.
2026-11-07 23:24:48 +01:00
Kacpherek 75dd0dde7d Save and load a mob's hurt immunity as invulnerable_time (Entity.load / saveWithoutId)
A mob writes invulnerable_time while it has hurt immunity left and reads it back with a default of 0, so /data get shows it, /data merge sets it, and the immunity survives a save and reload.
2026-11-07 23:24:42 +01:00
Kacpherek 8c4e3bb507 Pour a water bottle onto dirt to make mud at once on servers instead of drinking it (PotionItem.useOn) 2026-11-07 23:24:38 +01:00
Kacpherek dabae908cd Keep hidden server list entries, so Direct Connection servers remember pack and Code of Conduct answers (ServerList.save, ServerList.add) 2026-11-07 23:24:26 +01:00
Kacpherek 211b53f598 Let a ravager's roar knock armor stands away when mob griefing is on (Ravager.roar) 2026-11-07 23:24:19 +01:00
Kacpherek 2d94afaa61 Keep counting time since last rest on the death screen (ServerPlayer.doTick)
time_since_rest now counts every tick the player is not sleeping, dead or alive, as ServerPlayer.doTick does; time_since_death still counts only while alive.
2026-11-07 23:23:39 +01:00
Kacpherek 14a5193b41 Use up a knowledge book and swing the arm at once on servers (KnowledgeBookItem.use) 2026-11-07 23:23:35 +01:00
Kacpherek 00d050bb8f Show each worn item's own camera overlay (Hud.extractCameraOverlays)
Items a server or datapack gives a camera_overlay now draw it in first person when worn in their equippable slot, and a carved pumpkin whose equippable was removed no longer blurs the screen.
2026-11-07 23:23:29 +01:00
Kacpherek 7225a84b10 Count thrown snowballs, eggs, pearls, potions and xp bottles as used (throwable Item.use)
Throwing a snowball, egg, ender pearl, splash or lingering potion or bottle o' enchanting awards the used statistic, as SnowballItem, EggItem, EnderpearlItem, ThrowablePotionItem and ExperienceBottleItem.use do.
2026-11-07 23:23:21 +01:00
Kacpherek 40afd73cd8 Draw wings and hide the cape by the chest stack's own equippable (WingsLayer.submit, CapeLayer.hasLayer)
A chestplate a server gives elytra wings now shows them and hides the cape, and an elytra whose equippable was changed or removed no longer shows elytra wings.
2026-11-07 23:23:03 +01:00
Kacpherek c54c8c0f42 Let a beached nautilus dry out instead of drowning, and spare NoAI ones (Nautilus.handleAirSupply) 2026-11-07 23:23:02 +01:00
Kacpherek 939d492535 Let sculk hear item frames break as a block change too (ItemFrame.dropItem)
A frame broken by a player, an explosion or losing its support posts block_change after its drops, as ItemFrame.dropItem(level, causedBy) does, on top of the entity_die it already posted.
2026-11-07 23:22:57 +01:00
Kacpherek 41934f3d93 Let sculk hear items knocked out of item frames (ItemFrame.hurtServer)
Punching the item out of a frame posts block_change with the attacker as source after the item drops.
2026-11-07 23:22:45 +01:00
Kacpherek 85a6a8b9dc Let sculk hear items put into or turned in item frames (ItemFrame.interact)
Putting an item in a frame or rotating it posts block_change with the player as source, after the item or rotation changes.
2026-11-07 23:22:36 +01:00
Kacpherek 4ca3d55e78 Draw worn armour from the stack's own equippable asset (HumanoidArmorLayer.renderArmorPiece)
Armour a server or a command gives a different or removed equippable now renders with that asset, or not at all, and only in its own slot, on players, mobs and armour stands. The head layer draws a helmet item when its equippable has no asset.
2026-11-07 23:22:27 +01:00
Kacpherek b97f0f61d7 Let sculk hear endermen pick up and put down blocks (EnderMan block goals)
EndermanTakeBlockGoal.tick posts block_destroy and EndermanLeaveBlockGoal.tick posts block_place, each with the enderman and the block state as context.
2026-11-07 23:22:05 +01:00
Kacpherek 0c40da1a82 Let an opening shulker lift and push you on servers too (Shulker.onPeekAmountChange on the client) 2026-11-07 23:22:04 +01:00
Kacpherek e01adc67e3 Let Thorns hurt a player who sweeps its wearer in PvP (Player.doSweepAttack's doPostAttackEffects) 2026-11-07 23:21:48 +01:00
Kacpherek 32137ae44f Answer pandas' clicks on servers as vanilla does: scared ones pass, ones on their back swing, adults leave bamboo to the off hand (Panda.mobInteract) 2026-11-07 23:21:39 +01:00
Kacpherek 9503a3cc7d Let sculk hear copper golems open and close chests (ContainerOpenersCounter)
The first golem to open a chest half posts container_open with the golem as source, the last to close it posts container_close (incrementOpeners / decrementOpeners), and the openers recheck posts a sourceless container_close when the golems have walked off (recheckOpeners).
2026-11-07 23:21:26 +01:00
Kacpherek 7c4a6d1ea6 Use the held item on a pig or strider someone already rides on servers (Pig/Strider.mobInteract) 2026-11-07 23:21:14 +01:00
Kacpherek 3c4d936707 Say "formerly known as" when a renamed player joins a server (PlayerList.placeNewPlayer) 2026-11-07 23:21:11 +01:00
Kacpherek 44f5a37e64 Open a wandering trader's trades on servers without swinging the arm (WanderingTrader.mobInteract) 2026-11-07 23:21:01 +01:00
Kacpherek 5ffd5c6515 Use the held item on a sleeping villager on servers instead of swallowing the click (Villager.mobInteract) 2026-11-07 23:20:45 +01:00
Kacpherek 8cd7616054 Let breezes whirl and idle on servers too (Breeze.tick and Breeze.playAmbientSound on the client) 2026-11-07 23:20:44 +01:00
Kacpherek ea99e6572c Let sculk hear glass bottles filling and count their uses (BottleItem.use)
Filling a bottle from water now plays the fill sound at the player and posts fluid_pickup at the water block; both the water and the dragon's breath branch award the used statistic (BottleItem.turnBottleIntoItem), and collecting dragon's breath fires player_interacted_with_entity on the cloud.
2026-11-07 23:20:32 +01:00
Kacpherek c5dbb620c2 Let sneak-clicks and clicks on occupied cushions reach the held item on servers, without an arm swing (Cushion.interact) 2026-11-07 23:20:24 +01:00
Kacpherek 642ac0d489 Play the warden's heartbeat on servers too (Warden.tick's client branch) 2026-11-07 23:19:51 +01:00
Kacpherek 92bedb26d0 Show team colours and prefixes in /list on LAN worlds (ListPlayersCommand.listPlayers uses Player.getDisplayName) 2026-11-07 23:19:40 +01:00
Nikita Maximilian Grimm 3d8924dcc8 Merge remote-tracking branch 'origin/main' into tnt-piston-ground 2026-11-07 23:15:42 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 8ad82f9ac0 A piston push sets an item's or primed TNT's on-ground flag as vanilla does
Entity.move(MoverType.PISTON) ends in setOnGroundWithMovement on a server,
for every push: a sideways push clears the flag, and so does a free push
down. The ArmorStand-only repair in move_pushed becomes a trait method that
items, primed TNT and armor stands share.

Fixes #12029

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:15:41 +01:00
Web-mc1 77290ac3c1 telemetry: match the user name exactly when lowercasing moves boundaries
`replace_word` lowercased the text to find the user's name in any case, and
used that copy whenever it had the same byte length as the text. Equal
lengths don't imply equal boundaries: `İ` (U+0130) grows from 2 bytes to 3
and `K` (U+212A) shrinks from 3 to 1, so a text holding both keeps its
length while its offsets move. A match then sliced the original text
mid-character and panicked.

Use the lowercased copy only when the two share their character boundaries.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
2026-11-08 11:12:29 +13:00
Nikita Maximilian Grimm daa43de927 Merge remote-tracking branch 'origin/main' into boat-drop-motion 2026-11-07 23:10:52 +01:00
Nikita Maximilian Grimm 3fb98b187f Merge remote-tracking branch 'origin/main' into boat-fire-timer 2026-11-07 23:10:51 +01:00
martipopsandClaude Opus 5.5 76db917ded Controller settings: a Nintendo Buttons row (By Position / By Letter)
The Device page gets a row beside Button Glyphs that toggles
PadSettings::nintendo_letters, so players no longer edit
horizon-controller.txt to make A confirm and jump on a Nintendo pad.
Its description says what A and B do in each mode. Always shown, like
the DualSense rows. docs/controllers.md points at the row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:09:01 -05:00
Florian ErnstandClaude Opus 5.5 39701a9334 Adopt /data edits on a live experience orb
EntityDataAccessor.setData keeps the entity's UUID around Entity.load of
the edited compound, and ExperienceOrb.readAdditionalSaveData reads its
Age, Health, Value and Count into the same orb. Horizon had no experience
orb case, so `data merge entity <orb> {Age:42s}` answered "Nothing
changed" and the orb kept its age.

The orb case decodes the edited compound with the existing orbs_from_nbt
and copies its saved fields into the resident orb, which keeps its
runtime id, join order, tick count and UUID. As Entity.load does, the
saved PortalCooldown is read while a live portal process stays. The
edited compound is kept like the other cases', so Tags follow it.

A falling block's Time is handled separately (#11424).

Fixes #12090.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:04:52 +01:00
Vinícius MoreiraandClaude Opus 5.5 721d4cfa44 Resource packs: a pack's core/sky and core/stars shaders
A resource pack's core/sky now draws the overworld's sky disc and its
core/stars the stars, as vanilla's SkyRenderer does with the SKY and
STARS pipelines: the disc of buildSkyDisc(16) with the sky colour in
ColorModulator and the sky's fog, the stars with their brightness, both
turned with the camera only. Without such a pack the sky draws natively.

Packs use this to tint the night sky or add a haze to the horizon. With
Visual Effects+'s sky shaders alone, Horizon's sky now reads within a few
units of the Java client's at noon, sunset and night.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:47:59 -03:00
martipopsandClaude Opus 5.5 78b21e4afb Graphics moves onto the settings shell
Part of #11487. The graphics screen now describes its pages and rows
(`GraphicsScreen`), and the shell draws them, takes the clicks, the wheel,
the stick, the keys and the pad's focus, as it does for Extras. What each
setting does, its saved value, its cost and its description stay in
graphics_ui as they were; Undo puts back the same settings.

What changes beyond what the shell gives every page: the HDR shortcut row
shows its key on a key button, as Extras' Sort key does, instead of between
arrows. The screen's own keyboard, scrolling and drawing code goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 16:47:11 -05:00
martipopsandClaude Opus 5.5 26496db7c3 Merge upstream/main into controller/direct-craft
Main moved key_pressed to game/play_keys.rs and inventory_press to
game/inventory_input.rs; the craft's stop on a key or mouse press moves
with them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 16:46:48 -05:00
Web-mc1 37b79d1b63 java_properties: write a NUL and a non-BMP character as Java does
saveConvert pushed one UTF-16 unit at a time and marked a surrogate half with
a NUL sentinel, then ran fix_surrogates over the whole value, which split every
NUL in the result. A \u0000 that is part of a value (legal in a .properties
file) was therefore taken for a marker: "k=\u0000\uD83D\uDE00x" came back from
store with the NUL and both halves of the pair replaced, and since
server.properties is rewritten on every start the value could not survive a
round trip. Walk chars() instead: a Rust str's UTF-16 units always pair up, so
Java's per-char loop needs no marker, and a character past U+FFFF is still
escaped as the two units Java escapes it as.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
2026-11-08 10:44:43 +13:00
martipopsandClaude Opus 5.5 d5f931ca64 Controllers: LT + A on a recipe crafts it, held to keep crafting
LT + A on a crafting book recipe crafts it into the inventory: a tap makes
one, each further LT + A while one is in flight makes one more, and held past
the repeat delay it keeps going until a button comes up, the items run out
or the inventory is full. One request at a time, each waiting for the
server's answer; a result moves only with room for all of it as the client
last saw the inventory. A result that isn't the recipe's stops the craft with
nothing moved, and two seconds with no answer stops it with nothing more
sent. A refused LT + A (a carried stack, another recipe still finishing, not
allowed here) is plain A.

It's free in single player and on LAN worlds joined from the server list's
LAN entries; everywhere else, joins by address included, it waits for Quick
Craft on Servers. On any server but single player's own, placements keep
250 ms apart, under Paper's default limit on recipe placements (5 a second
over 4 seconds); on servers that need the option, every request also keeps
a tick apart.

On the crafting book LT changes the category as it comes up unless A was
pressed meanwhile; RT, and both triggers on the furnace books, change it as
they go down, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 16:41:47 -05:00
KyttuXDandClaude Haiku 5.5 702b0895bd Draw vanilla terrain flat on Metal at any section count
On Metal, vanilla terrain drew flat only past 1600 listed sections. Cave
culling can drop the listed count below that on a normal view, and the
per-section path then drops cutout leaves on Intel Metal: the canopy above
trunks vanished. Flat draws keep them, so Metal now always draws flat.

Co-Authored-By: Claude Haiku 5.5 <[email protected]>
2026-11-07 16:41:30 -05:00
martipopsandClaude Opus 5.5 a08827d6d5 Settings shell: Undo, a row's cost and why it is greyed
Part of #11487. What the graphics screen has that the shell couldn't say
yet, for any screen that wants it:

- Undo over Done once a row changed something, putting back what the
  screen says it changes (`Screen::undoes`, `Screen::undo`), from the
  settings as the screen found them. Tab and the arrows reach it.
- A row's cost, a square and the cost in its colour after its name in the
  strip.
- Why a greyed row can't be used, in the strip, muted, instead of what it
  does.
- `Shell::show` opens a screen at one of its pages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 16:37:34 -05:00
martipopsandClaude Opus 5.5 4465238c9c Settings shell: build rows once, Down from search to the list, reveal clipped rows
Part of #11487.

- The shell keeps the rows it built and builds them again only when what
  they read changes: the screen's stamp of its settings, a press or slide,
  the search, the page, the size or the language. On Extras, a pad session
  of 727 frames built them twice instead of 751 times.
- On a screen with no page list, Down from the search field goes to the
  first row instead of Done, for the shell's keys and, through a declared
  focus link, for the pad and the keyboard's focus.
- A row the list hides part of scrolls fully into view when the pad or the
  keyboard focuses or presses it (AbstractSelectionList.setSelected), so A
  presses it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 16:35:56 -05:00
Nikita Maximilian Grimm 43943df1ef Merge remote-tracking branch 'origin/main' into boat-drop-motion 2026-11-07 22:29:00 +01:00
KBroneZandClaude Opus 5.5 8906102eb9 chore(launcher): add the found list's string before each table's last entry
Inserting "Found on this computer" before the last entry of each language
table, instead of after it, adds one line per file and leaves the last line
alone, so other pull requests that append strings don't conflict with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:23:19 +02:00
KBroneZandClaude Sonnet 5.5 0a51d6dc5c fix: shadow the TCP keepalive instead of mutating it, so Windows builds are lint-clean
`let mut keepalive` was only assigned under
`#[cfg(not(any(target_os = "windows", target_os = "openbsd")))]`, so on
Windows and OpenBSD clippy reported `unused_mut` and `-D warnings` failed.
Shadow the binding under the same cfg instead; behaviour is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 23:22:22 +02:00
KBroneZandClaude Opus 5.5 21ca2fdd1d refactor(launcher): drop the found list's caption; check slugs against import
The "Found on this computer" heading says enough on its own, and the caption
cost a string in every language table. The test now checks that each found
instance's slug is the one importing it gives, so the Open button keeps
pointing at the pack an import made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:15:51 +02:00
Nikita Maximilian Grimm 89a515a8d7 Merge remote-tracking branch 'origin/main' into boat-fire-timer 2026-11-07 22:14:37 +01:00
KBroneZandClaude Sonnet 5.5 a0f9368edf feat: the launcher plays a profile that only has data packs
Imported.datapacks counts the packs in a profile's home/new-world-datapacks,
`can_play` and `apply_profile` accept a profile with only data packs, and
`outcome` and `modpack list` count them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 23:13:52 +02:00
KBroneZandClaude Sonnet 5.5 1f86e14b9a feat: port data-only mod jars as data packs for a modpack's new worlds
A mod jar with no classes, a pack.mcmeta and a data/ folder is a data pack.
For a 26.2 or 26.3 modpack, `port` now upgrades such jars to 26.3 (the
upgrade-datapack code; 26.3 ones are copied) into the profile's
home/new-world-datapacks/ instead of carrying them as content mods, which
dropped their data/minecraft overrides. The game copies that folder into
each new world it creates.

Before its jar is read, a mod whose Modrinth project also ships as a data
pack counts as data tier, so `fetch` gets the jar; the jar then decides.
The coverage report lists such a jar as partial.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 23:13:51 +02:00
SenjinandClaude Opus 5.5 5ec521bb7b Shader packs: Horizon's dynamic lights as uniforms, horizonTier for terrain and entities
horizonDynamicLightCount and horizonDynamicLight0..15 give a pack Horizon
Extras' dynamic lights, nearest first (camera-relative position, light
level). horizonTier gives terrain, entity and hand programs a face's HDR
tier: 0 none, 1 to 4 low to very bright, plus 4 on terrain when the whole
face shines. Opt-in: a pack that declares none of them sees no change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 22:13:03 +01:00
Nikita Maximilian Grimm 80bbced3fc Merge remote-tracking branch 'origin/main' into fix/diode-moving-piston-support 2026-11-07 22:12:23 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 c30b863128 Let water a boat drops into along its move put its fire out
Entity.collidedWithFluid sweeps the box along the whole move, so water reaches
the boat down to the lower of its start and end bottoms in every step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 22:12:17 +01:00
KBroneZandClaude Opus 5.5 690d434afa feat(launcher): list other launchers' modpacks on the Modpacks page
The Modpacks page now opens with "Found on this computer": the modpack
instances the CurseForge app, Prism Launcher, MultiMC, the Modrinth App,
ATLauncher and the official launcher keep in their usual folders, read with
`other_launchers::scan` on a thread. Each row shows the app, Minecraft
version and loader, and imports the instance with one click through the
same path as "Import an instance folder…" (a Prism instance from its own
folder, so its `mmc-pack.json` still names the version). A pack already
imported opens instead.

Only instances with a `mods` folder of their own are listed: the official
launcher's profiles that play in its own folder are the player's everyday
game, not a pack. The two new strings are in every language table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:10:54 +02:00
Florian ErnstandClaude Opus 5.5 c0806b9ee3 Keep a failed wildcard set's edit in command storage
StorageDataAccessor.getData returns the stored compound itself, and
DataCommands.manipulateData edits it in place. A wildcard set on a
non-empty byte, int or long array clears the array before it rejects a
string, so the command fails with nothing counted and the storage keeps
the cleared array. Horizon edited a copy and dropped it on the failure.

On that failure, a /data modify on storage now puts the edited compound
back with CommandStorage::set_unsaved: only an id that is stored is
replaced, and the storage is not marked for saving, as vanilla calls no
setData. The error, the result, the success path and the entity and
block copies are unchanged.

Fixes #12057.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 22:08:42 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 f57811dd0d Drop a destroyed boat's item with an item entity's own motion
VehicleEntity.destroy spawns the boat item through spawnAtLocation, so it
leaves with ItemEntity's default motion (0.2 up, random sideways), not
straight up at 0.1. Chest contents keep their own scatter. Fixes #12026.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 22:05:45 +01:00
KBroneZandClaude Opus 5.5 70bc17720c fix(launcher): keep a Prism root's instances folder from reading as CurseForge's
Where folder names ignore case (Windows, macOS), a Prism or MultiMC root's
`instances` folder is also `Instances`, so `in_folder` took it for the
CurseForge app's modding folder and found nothing. It now reads that folder
as CurseForge's only when none of its instances has an `mmc-pack.json`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 23:03:37 +02:00
Nikita Maximilian GrimmandClaude Opus 5.5 73e054f827 Apply a boat's fire block effects in the order its move meets the blocks
Entity.checkInsideBlocks meets the blocks of the box a move starts in before
the ones it reaches, each once, and each step lights before it puts out: a
boat that leaves water for fire in one move ends up burning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 22:01:24 +01:00
Mik00000 e1434f2ee4 perf(game): reduce dimension swap overhead and cache raycast chunk lookups 2026-11-07 22:58:20 +02:00
bulkandClaude Opus 5.5 25ea320338 Streaming: rank decoration by rank alone
Decoration scheduling measured, sorted and ranked every proto chunk each update.
Ranks are unique, so only chunks without one need their distance; the rest
pop from a heap until the workers are busy. A server with 200 players spread
over the map held ~57,000 protos and spent a fifth of its tick here.

The heap pops in the order the full sort gave; unranked chunks at the same
distance now go by position instead of where the unstable sort left them.

(cherry picked from commit d20e7bf74e)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:57:34 +00:00
KBroneZandClaude Opus 5.5 6fa7f8896a feat(launcher): find instances in the CurseForge app's Instances folder
`instance others --folder` and `copy-from --folder` now accept a folder whose
children are CurseForge instances, the `Instances` folder the app shows the
player, as well as the modding folder above it. Before, that folder found
nothing.

When nothing is found, the message says where it looked (the folder named, or
every default folder the scan reads) and which folders it expects. The
CurseForge folder is joined one component at a time, so its path no longer
shows mixed separators on Windows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 22:57:04 +02:00
Florian ERNSTandCodex 67a39ecaac Project ground after unoccupied server NoAI Mob piston movement
Co-Authored-By: Codex <[email protected]>
2026-11-07 21:56:55 +01:00
KBroneZandClaude Sonnet 5.5 199d9d74f8 fix: run tools/neoforge_oracle.py on Windows
Windows users cannot create symlinks without a privilege (WinError 1314), and NeoForge's
unix_args.txt gives "Illegal char <:>" there. Link the server's libraries folder with a
junction and the mod jars with a hard link, copying when that fails; use win_args.txt on
Windows. Linux and macOS keep the symlinks and unix_args.txt. Adds tests/test_neoforge_oracle.py.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 22:55:49 +02:00
TheMrZZandCodex 1005076a59 Route recipe-book placement through actual furnace menus
Reuse the existing machine menu cache, shared placement and authoritative
slot writeback for ordinary PlaceRecipe packets. Preserve inventory/table
placement and the separate Horizon recipe-transfer route.

Fixes #12009

Co-Authored-By: Codex (gpt-6.1-sol) <[email protected]>
2026-11-07 21:49:12 +01:00
bulkandClaude Opus 5.5 94ed2f4cc8 Beehives: ask once per hive turn whether bees stay in
bees_stay_in_hive built the mob world (every mob and player) for each occupant
whose time was up. The night and rain it reads hold for the hive's turn.

(cherry picked from commit 3430283af0)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:48:44 +00:00
bulkandClaude Opus 5.5 517f54d076 Streaming: know the extra cover is current instead of comparing it
Every in-range check compared the cover's copy of the extra list (about 200
entries on a spread server) with the live one, for each waiting chunk each
tick. The cover is refreshed at the start of update; update now says so and
the checks trust it, with a debug assertion that they still match.

(cherry picked from commit f61e6ed98d)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:48:44 +00:00
bulkandClaude Opus 5.5 9626c7446e Creaking hearts: build the mob world only for the heart's update
A heart built the mob world (every player, the teams, the weather) each tick,
but reads it only in the update about once a second. server_tick is split at
that point; the game builds the world for the update only. The heart's
creaking, asked for a few times a tick, is found through the mob index
instead of a scan.

(cherry picked from commit a1cf6491dd, with the mob index
in place of its own slot map)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:48:44 +00:00
bulkandClaude Opus 5.5 da2b437f49 Spawners: count the delay down without building a level
BaseSpawner.serverTick only decrements a running delay. The level (every
player, the mob world) was built for each spawner near a player every tick
first.

(cherry picked from commit 1f06b720c9)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:48:44 +00:00
bulkandClaude Opus 5.5 6e0f482e83 Structure starts: keep four times as many chunks cached
Players spread far apart read more start chunks than the cache held, so
outposts' and trial chambers' jigsaws were built again on the server thread
whenever natural spawning asked about them.

(cherry picked from commit da2c8d2d48)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:48:44 +00:00
Nikita Maximilian Grimm 8189734106 Merge remote-tracking branch 'origin/main' into fix/diode-moving-piston-support 2026-11-07 21:46:30 +01:00
KBroneZandClaude Sonnet 5.5 1f29c88a49 feat: copy a game folder's new-world-datapacks into every new world
A game folder can hold a `new-world-datapacks` folder. Create New World now
seeds its temporary data pack folder from it and selects those packs, and a
world opened without the Create screen (`--world`, the control socket) gets
a copy when it has no level.dat yet. Each world keeps its own copy. Without
the folder nothing changes.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 22:46:25 +02:00
Nikita Maximilian GrimmandClaude Opus 5.5 bf0f0dd811 Wear off a driven boat's damage before it burns, and let water it left put it out
AbstractBoat.tick decays the damage before Entity.baseTick burns the boat, also
for a boat its rider's client moves, and the block effects follow the whole
move, so water the boat started in still puts it out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:44:44 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 007458a627 A repeater or comparator on a retracting piston stays, as in vanilla
DiodeBlock.canSurviveOn asks isFaceSturdy(level, pos, UP, RIGID) of the
block below, in canSurvive and in updateShape with the neighbour's new
state. A retracting piston base is a moving_piston whose block entity
shape holds the extended base, so its top face is rigid. The diode checks
read the raw state's exported facts instead, saw no support, and broke the
repeater or comparator. Both paths now go through the contextual rigid
support, which takes the state a shape update hands over.

The redstone catalog harness gains fixed lever/piston/diode contraptions
for both piston and both diode kinds (#12019).

Fixes #12019

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:29:19 +01:00
Nikita Maximilian Grimm 9c30028167 Merge remote-tracking branch 'origin/main' into execute-block-nbt 2026-11-07 21:28:43 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 0d49b282c0 Read a block predicate's NBT with the argument's own SNBT grammar
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:28:40 +01:00
Florian ErnstandClaude Opus 5.5 099fb70e6a Pick up a sulfur cube with an empty bucket
SulfurCube.mobInteract ends with Bucketable.bucketMobPickup, and a sulfur
cube is picked up with an empty bucket (canBePickedUpWithBucket), not a
water bucket. Horizon's bucket pickup only knew the water bucket's mobs,
so a click with a bucket left the cube where it was.

After the cube's own baby, primed, shears and swallow branches, an empty
bucket now plays the sulfur fill sound, fills a sulfur_cube_bucket, fires
filled_bucket and player_interacted_with_entity, drops the leash, discards
the cube and gives the bucket through ItemUtils.createFilledResult, as the
other bucketable mobs do. The native bucket hook hears it.

The filled bucket carries SulfurCube.saveToBucketTag: the cube's age and
age_locked in bucket_entity_data, and its body block as
sulfur_cube_content when it has one. Other species keep their bucket data.

The command harness gets a mob_interact op: the connected player's real
Interact packet on a mob, on both sides.

Fixes #12044.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:26:20 +01:00
Florian ErnstandClaude Opus 5.5 38a1babc5a Use the archetype data's float for the knockback modifier amount
The archetype table keeps knockback resistance as a decimal double for
the physics code. The data's modifier amount is the float widened
(0.4000000059604645 for slow_bouncy), so /attribute read 0.4 and 0.7
where vanilla reads 0.4000000059604645 and 0.699999988079071.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:26:16 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 c7aef39dd5 Burn boats: live fire timer, fire damage and both block-effect passes
A boat now keeps Entity.remainingFireTicks: Entity.baseTick burns it down a
tick at a time and hurts it every 20 ticks, and the two applyEffectsFromBlocks
of AbstractBoat.tick light it on fire blocks, hurt it once per fire block,
let water, powder snow and rain put it out and clear the cooldown. Saves,
/data, portals and the root vehicle write the live Fire; loads and /data
merge read it. Fixes #12025.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:24:20 +01:00
TheMrZZandCodex gpt-6.1-sol d7c3fefcfa Preserve Nautilus cooldown memory presence and lifetime
Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-07 21:23:19 +01:00
Florian ERNSTandCodex 8b48b0d74e test: checkpoint H255 piston ground regression before claim-cap decision
Qualified old-source failure only; no production repair or fixed-pass claim.

Co-Authored-By: Codex <[email protected]>
2026-11-07 21:19:53 +01:00
Florian ErnstandClaude Opus 5.5 3e5e8c4841 Give a sulfur cube its body archetype attribute modifiers
SulfurCube.collectEquipmentChanges runs in LivingEntity.tick
(detectEquipmentUpdates) when the body item changed. It removes the
previous body's archetype modifiers and adds the new body's as transient
modifiers: knockback_resistance, explosion_knockback_resistance and
bounciness (add_value), friction_modifier and air_drag_modifier
(add_multiplied_total). /attribute read the defaults for these five on a
cube with a body.

A sulfur cube now has its own attribute map from its type's defaults.
The five attributes go to that map, and the tick adopts the body's
modifiers there with the existing AttributeInstance operations. A
transient modifier shadows a permanent one with the same id, and the
removal takes both, as in vanilla. The archetype table also gets its
explosion knockback resistance, from the 26.3 data.

The save writes the base and the permanent modifiers of these instances,
not the transient ones. A command change of the knockback base or of a
permanent modifier also goes to the store that the bodiless physics
reads, so that effect stays as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:18:07 +01:00
Nikita Maximilian Grimm 5664a950e8 Merge remote-tracking branch 'origin/main' into execute-block-nbt 2026-11-07 21:17:10 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 538422f3c7 Match the NBT part of a block predicate against the block entity
execute if|unless block, fill ... replace and clone ... filtered tested only
the block state; BlockPredicateArgument also compares the {...} part with the
block entity's full saved data (NbtUtils.compareNbt), and a block without a
block entity fails it.

Fixes #12030

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:17:09 +01:00
Florian ErnstandClaude Opus 5.5 7339c9057a Run a /kill-ed mob's death during the command
LivingEntity.kill is a generic_kill hit that calls LivingEntity.die before
the command returns. Horizon set the mob's health to 0 and left the death
to the next tick's creature phase, so its entity_die vibration reached a
sculk sensor one tick late.

The /kill mob arm now runs the existing death routine (mob_died) at once
for a mob that this kill takes from alive to dead, behind the existing
`died` guard, as a frog's bite already does. The native living_death veto,
the vibration, the catalyst, loot, experience and kill credit now happen
during /kill instead of in the next creature phase. A second kill and the
next tick do not run it again. The body's removal timer is unchanged.

Fixes #12037.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 21:04:50 +01:00
Florian ErnstandClaude Opus 5.5 b528247824 Merge origin/main into fix/h275-test-defs-world-packs
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:59:27 +01:00
Florian ErnstandClaude Opus 5.5 ed1ce7495e Merge origin/main into fix/chorus-projectile-drops
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:59:09 +01:00
MSedgeMC d1f8cccb7c A mob stops chasing a target outside its home
`MeleeAttackGoal.canContinueToUse`'s follow branch returns
`isWithinHome(target.blockPosition()) && !(target is a spectator or
creative player)`. Horizon's `MeleeAttack::can_continue` only refused a
creative player: a mob with a home kept chasing past its radius, and a
player who became a spectator was still chased.
2026-11-07 19:46:00 +00:00
MSedgeMC e8da3a8e21 A drowned stops the trident attack when it loses the trident
`DrownedTridentAttackGoal` overrides `canUse` with the trident test and
inherits `RangedAttackGoal.canContinueToUse`, which calls `canUse()` again
(and falls back to a target it is still walking towards). Horizon's
`DrownedTridentAttack::can_continue` asked only the base ranged goal, so a
drowned whose trident was gone kept the trident attack running once its
path was finished.
2026-11-07 19:42:47 +00:00
Mateusz KorniakandClaude Opus 5.5 3004b64927 Fix speckled players with Improved Transparency on Metal
fs_oit_cull writes the nearest opaque see-through depth into the depth
buffer, and the later OIT stages test GreaterEqual against it, so an opaque
fragment is compared with its own depth. On Metal, position.z can differ from
the rasterizer's depth by an ulp, which dropped random pixels of players and
mannequins (horizontal dashes, text behind showing through). Write the depth
4 ulps farther: the fragment still passes, anything visibly behind is culled.

Checked on macOS (Metal, Apple M1) with a mannequin and a text display; not
yet on Linux (Vulkan).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:38:40 +01:00
Florian ERNSTandCodex 60a2c3f164 Preserve loaded NoAI Enderman absolute anger timestamps
Co-Authored-By: Codex <[email protected]>
2026-11-07 20:36:12 +01:00
VaspyyyandClaude Opus 5.5 abdf311e3b Native mod API: muffle the game's sounds for a while (native_muffle_sounds)
After a close blast a mod can now dull and quieten the world's sounds while
its own ringing plays clearly: native_muffle_sounds(amount, lowpass, ticks,
exempt) turns every sound down by `amount` and low-passes it by `lowpass`
(down to 300 Hz), both fading back over `ticks` client ticks and held while
the game is paused. The sound events in `exempt` play through untouched,
those already playing too.

The mixer mixes the muffled sounds into a bus of their own, runs two
one-pole low-pass stages and the duck over it, and adds it to the exempt
ones. The level glides over 20 ms so tick-sized steps don't click. While no
muffle is set or once it has faded, sounds mix straight into the output as
before. The sound engine marks a channel exempt as it starts, and marks the
playing ones again when the list changes.

Helper-only fragment muffle_sounds. Fixes #12006

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:34:54 +01:00
Florian ErnstandClaude Opus 5.5 2979cf024d Resolve /clone's source and target dimensions
/clone from <sourceDimension> ... to <targetDimension> ignored both
arguments: an unknown name cloned in the current level, and a valid
other dimension wrote into the current level instead of its own world.

As CloneCommands does, sourceDimension is resolved as begin is read and
targetDimension as destination is read, each position checked loaded in
its own level; an unknown name fails with argument.dimension.invalid
(the built-in dimensions, as execute in checks them), the source first.
The overlap check applies within one level only. The blocks are read in
the source level and placed in the target level through the existing
level swap (enter_command_level), each entry checked; the coordinates
are resolved in the command's own context first. The command's own
level is put back on every path, before the command reports.

Fixes #11997

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:34:36 +01:00
MSedgeMC f96e0fba0f A tamed cat stops being tempted
`CatTemptGoal` overrides `canUse` with `!cat.isTame()` but does not
override `canContinueToUse`; `TemptGoal.canContinueToUse` ends with
`return this.canUse()`, so taming a cat mid-tempt ends the goal. Horizon's
`CatTempt::can_continue` ran only the base `Tempt` continue, which never
asked whether the cat was tamed, so a cat tamed while following a fish
kept following it.
2026-11-07 19:32:24 +00:00
VaspyyyandClaude Opus 5.5 653a4a99fe Native mods: a game horizon-mixins built has the mod image slot
The HUD atlas reserved `horizon/modimage` (native_mod_image, API 355) only
when the launcher's native-mods.json listed mods, so a bundle applied with
horizon-mixins by hand or by a mod's own script built a game whose
native_mod_image always returned false.

horizon-mixins leaves .horizon-mixins-stage.json at the root of every
workspace it changes, naming each injection's and module's mod. The build
script turns a record that names mods into HORIZON_MIXIN_MODS, and
built_with_native_mods counts it and installed trait mods as well as
native-mods.json. A release or Nightly has none of them and keeps no slot.

Fixes #12005

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:26:53 +01:00
Mik00000 65c35da0dc mobs: reuse pathfinding allocation buffers across queries 2026-11-07 21:21:07 +02:00
Florian ErnstandClaude Opus 5.5 46c6bdc8ac Let /attribute add and remove see a baby zombie's minecraft:baby modifier
Zombie and Piglin.setBaby put a transient minecraft:baby speed modifier
on a baby. AttributeInstance refuses to add an id it already holds and
removes a modifier whatever its kind; the next setBaby removes
minecraft:baby again and, for a baby, adds the transient one back. The
transient modifier was computed from the baby state, so /attribute
modifier add stacked a permanent one on it and modifier remove found
nothing to remove.

The add now counts the transient modifier, and the remove takes it away
until the next setBaby (a flag on the mob's attributes, not saved: a
load runs setBaby again). setBaby clears that flag and removes a
permanent minecraft:baby, as vanilla's does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:15:12 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 4fa237a12e HDR layered frame: a tone curve eases the light into the peak
After the post effects and before the camera overlays, ITU-R BT.2390's EETF in PQ rolls the
light off into the peak, on its brightest channel so it keeps its hue. It takes over the HDR
lighting's easing and the light sources' cap at the peak, which the resolve pass no longer
applies. The knee stays where the lighting's was, 60% of the peak.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:14:01 +01:00
MrCloudy2andClaude Opus 5.5 772088790c lan_e2e: sprint-hit-slowdown builds its sprint with a run-up
An absolute /tp zeroes the player's speed, as vanilla's does
(TeleportCommand's relatives carry no DELTA), so the check's teleport
right before the hit left the guest at walking speed and the check
failed on main. The guest now runs 19 ticks from 8 blocks out and
clicks in reach. The slowdown assertion is tightened: the first
post-hit sample must be under 0.75 of the sprint speed and then climb,
which fails with the client's 0.6 cut removed (the old 0.9 bound did not).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 20:14:01 +01:00
masa-masa-0314andZCode aaa674f54b Realms: the screens follow vanilla's layout, state and input
The parity work after the per-screen PRs (#9714, #9836, #9909, #9926,
#9968, #9982, #10032, #10391, #10448, #11640), as verified in the local
playtest builds:

- Main list: RealmsMainScreen's header and footer geometry, row content
  and status light, scrolling, notices, selection narration, and the
  60 s/10 s/300 s data-fetcher periods.
- Configuration screen: the four tabs (MenuTabBar), GridLayout columns,
  slot options, region preference, invite codes and their edit screen,
  the players tab (invites, operators, removal), the subscription tab
  and the tab keyboard.
- World screens: RealmsResetWorldScreen's tiles, the template list, the
  upload selection and upload screen, and the PDP rows and keyboard.
- Backups: RealmsBackupScreen/RealmsBackupInfoScreen on the current wire
  (lastModifiedDate, metadata as strings, a local changeList), restore
  as RestoreTask (retries, abort), and the complete Download Latest flow:
  DownloadTask, RealmsDownloadLatestWorldScreen's size check, bar, speed
  and cancel, and FileDownload's tar.gz unpack (name cleanup, world/
  entries only, level.dat renamed, resource pack SHA-1 checked).
- Settings: RealmsSettingsTab's GridLayout/ScrollableLayout, the
  distance sliders, the name validation, and tooltips drawn after every
  widget.
- Service: the ops/invites endpoints, the invite answer's players, the
  backup age on the wall clock, null gameMode, and news persistence.
- Integrated server: the owner and the memory connection's login use the
  account profile (IntegratedServer.setSingleplayerProfile,
  ServerboundHelloPacket), so a world without singleplayer_uuid (a Realms
  download) loads the owner's players/data file; saveAllChunks'
  saveDataTag(profile.id()) is mirrored by save_owner.

Tests: 2166 lib tests pass (65 realms), scoped clippy clean.

Co-Authored-By: ZCode <[email protected]>
2026-11-08 03:00:28 +08:00
Florian ErnstandClaude Opus 5.5 ad475b0573 Load a world's test instances from its data packs when it opens
/test only knew the test instances of the game's own data: read_test_def
read options.resources, and the selector ids were the exported built-in
ones, so a test a world's data pack defined was "No matches for
selector". Vanilla 26.3 loads Registries.TEST_INSTANCE from the packs the
world enables when it loads: later packs override earlier ones and the
built-in data, and /reload or /datapack do not change it.

When a world opens (the end of load_world_state), the built-in pack's and
the initially enabled packs' test_instance files are read once, in pack
order, through the existing test instance decoder. They become the
world's test definitions (test_defs) and its minecraft:test_instance ids,
replacing the previous world's. /reload and /datapack leave them as they
are. A game with no world opened reads the game's own data as before.

Fixes #11976

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:59:12 +01:00
Florian ERNSTandCodex aa019cfaa4 Canonicalize two saved adventure predicate forms
Co-Authored-By: Codex <[email protected]>
2026-11-07 19:58:10 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 9e962f6350 HDR layered frame docs: say what a screenshot shows without promising the tone curve changes it
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:55:14 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 78ea4b6d02 HDR layered frame: drop the coverage debug flag the display pass no longer reads
The coverage view is chosen once, when the shader is wrapped; nothing reads the field after.
Also lets a test fill the coverage with its own f64.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:51:26 +01:00
Florian ErnstandClaude Opus 5.5 e2367a4b6a Skip the full Mob tick tests without the vanilla data
CI has no prepared resources, so the assert on the test world failed
there. Do what the other test-world tests do: check nothing when the
data is missing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:49:30 +01:00
Florian ErnstandClaude Opus 5.5 596fda5618 Overlap note: check heads in one git call, diff in parallel
The workflow's clone is blobless, so `git cat-file -e` on a head it
does not hold fetches it from the server, one round trip per check.
On busy days the job ran into its 10-minute timeout. Check every head
in one `cat-file --batch-check` with lazy fetching off, and run the
diffs on 8 threads so their blob fetches overlap. A note for #11723
now takes 13 s instead of 170 s; `show` over every open pull request
29 s instead of 785 s, with the same notes.

Closes #11984

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:42:34 +01:00
TheMrZZandCodex gpt-6.1-sol 46b257b1d5 fix: honor supported Equippable overrides on item use
Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-07 19:38:39 +01:00
Florian ErnstandClaude Opus 5.5 9f0b1d99c1 Save a mob's movement_speed instance only once it has ticked
AttributeMap.pack saves the attribute instances that exist. A fresh
living entity has none (attributes:[]); its first tick creates
movement_speed (LivingEntity.aiStep -> removeFrost -> getAttribute).
The mob writer added movement_speed to every save, so a mob that had
not ticked yet already saved it.

The writer's invented movement_speed entry now waits for the mob's first
tick (its tick count). The instances the load itself makes stay:
Zombie and Piglin setBaby the speed, Rabbit setVariant the attack damage.
Instances the mob was loaded with are kept as before, and the list is
written even when empty.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:34:14 +01:00
MSedgeMC 8b0c8e40a6 A trader stops trading when hurt or out of reach
`TradeWithPlayerGoal.canUse` refuses a trader that `wasHurtRecently` or
whose trading player is more than four blocks away, but Horizon's
`TradeWithPlayer::can_use` checked neither. A wandering trader that took a
hit, or whose customer walked off, stayed in the stand-still trade goal
where vanilla ends the trade.
2026-11-07 18:34:07 +00:00
MSedgeMC d980cd810d A happy ghast on a still timeout stops floating
`HappyGhast.HappyGhastFloatGoal` overrides `canUse` with
`!isOnStillTimeout() && super.canUse()`. `FloatGoal` does not override
`canContinueToUse`, so `Goal.canContinueToUse` asks that same overridden
`canUse` on every tick: a player standing on the ghast makes it stop
floating. Horizon's `HappyGhastFloat::can_continue` re-ran only
`Float.can_use`, so the goal kept hopping in water under a player who was
holding it still.
2026-11-07 18:31:37 +00:00
Nikita Maximilian GrimmandClaude Opus 5.5 196bea6f1a HDR marks: entities, the hand and translucent particles mark at the entity pipeline's depth bias
#7820 gave the entity pipeline a constant depth bias of 128 so entities win the tie with
coplanar terrain. HDR output marks what it draws by drawing the same quads again, alpha only,
GreaterEqual against the depth it left, but without the bias: every mark tested a hair behind
that depth and failed. Mobs lost their HDR lighting, light sources in the hand stopped shining,
and the empty hand only looked right by reading the ground's mark behind it.

The marks after entities, the hand (unmark and mark) and translucent particles now draw at the
same bias. Translucent items, additive draws and the OIT stage follow unbiased pipelines and
keep the unbiased mark.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:27:20 +01:00
Nikita Maximilian GrimmandClaude Opus 5.5 cdabdddb6b HDR float frame: the HUD and menus lay over the world's light
On the float HDR frame the last pass guessed which pixels still showed the world
(`shows_world`) and clipped everything else at white, so the world's light dropped to
SDR under the chat's see-through background, a menu's backdrop and the coloured camera
overlays. Where the device records HUD coverage (#11896) the frame is now drawn in
layers, as the HDR note's step 3 specifies:

- After the world and the hand, `Hdr::resolve` turns the frame's marks into light once.
  The camera overlays, post effects and entity outlines draw on light after it.
- `keep_world` becomes a pass: the world clipped to white, alpha 0, into a HUD target in
  the frame's format, which the HUD and menus draw on with their unchanged blends.
- The last pass lays the HUD over the world's light by its coverage, in gamma as the HUD
  blends (H = P - (1 - c) B, then H ui^(1/2.2) + (1 - c) W). UI Brightness scales the
  HUD's own part.
- The menu blur blurs that composite, light included, and makes it the world the menu
  draws over.

Until the tone curve, a screenshot is the HUD target and the world icon the world, both
clipped at white; the -hdr.png is the full picture. The legacy path, the 16-bit frame and
HDR off are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:27:07 +01:00
Florian ErnstandClaude Opus 5.5 78efabcfa7 Copy a clone's pending block ticks to its destination
/clone placed the blocks but not the block ticks pending in its source
box, so a strict clone of fresh sand never fell, while vanilla 26.3's
CloneCommands.clone ends with LevelTicks.copyAreaFrom over the whole
source box.

cmd_clone now calls the existing LevelTicks::copy_area with the source
box and the destination offset, after the placements and block
entities and before the empty-count failure, as vanilla does. The core
copy (the box filter, trigger times, priorities, sub-tick reordering
and dedup) is unchanged. Block ticks only, in the same level.

Fixes #11963

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:16:16 +01:00
MSedgeMC 8d783c0ff0 A cube mob keeps still while it is a passenger
`AbstractCubeMob.CubeMobKeepOnJumpingGoal.canUse` is
`!this.cubeMob.isPassenger()`, but Horizon's `CubeKeepJumping::can_use`
returned true unconditionally. A slime or magma cube riding a boat, a
minecart or another mob therefore kept hopping and steering its vehicle
every tick, where vanilla leaves the vehicle alone.
2026-11-07 18:14:53 +00:00
Nikita Maximilian GrimmandClaude Opus 5.5 cbe9ddfa3f HDR marks: entities, the hand and translucent particles mark at the entity pipeline's depth bias
#7820 gave the entity pipeline a constant depth bias of 128 so entities win the tie with
coplanar terrain. HDR output marks what it draws by drawing the same quads again, alpha only,
GreaterEqual against the depth it left, but without the bias: every mark tested a hair behind
that depth and failed. Mobs lost their HDR lighting, light sources in the hand stopped shining,
and the empty hand only looked right by reading the ground's mark behind it.

The marks after entities, the hand (unmark and mark) and translucent particles now draw at the
same bias. Translucent items, additive draws and the OIT stage follow unbiased pipelines and
keep the unbiased mark.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:14:43 +01:00
Stink-OandClaude Opus 5.5 749c5405f6 World hold: its import on a line of its own, apart from the shared mod_api list
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:13:53 +00:00
Florian ErnstandClaude Opus 5.5 08ce93b6f1 Keep the shared inventory helpers crate-private and test the delegation
add_to_container and load_container are only used inside the crate. Two
unit tests pin VillagerState::add_item as add_to_container with eight
slots, and a later same-kind stack merging while eight kinds fill the
slots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:06:20 +01:00
Mik00000 bc8912c13f bench: add stress_mob_ai scene for active mob AI and pathfinding 2026-11-07 20:02:57 +02:00
Florian ERNSTandCodex 408e2606d8 Preserve weaker Mob effects through countdown and promotion
Keep active tuples authoritative and carry only fallback EffectInstance subtrees through Mob load/save and the audited mutation boundaries. Reuse the existing pure duration operation after server work.

Co-Authored-By: Codex <[email protected]>
2026-11-07 18:59:12 +01:00
Florian ErnstandClaude Opus 5.5 40ad3a91c9 Keep an Allay's liked_player memory time to live and expire it
An Allay loaded with a finite minecraft:liked_player memory kept it
forever and saved it without its ttl: the loader read only the memory's
presence and value, the save wrote the value, and nothing counted the
memory down.

- The memory's time to live is kept next to the existing liked-player
  state (None for a memory that never expires), read on load and
  written on save as MemorySlot.visit does.
- The Allay's AI step, which NoAI skips like customServerAiStep, ticks
  it as MemorySlot.tick does: it counts down, and is cleared on the
  tick after it reaches 0.
- Giving an item sets the memory without a time to live
  (Brain.setMemory), taking it back erases it, and the /data path that
  keeps the memory keeps its time to live too.

Fixes #11936

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:42:50 +01:00
SenjinandClaude Opus 5.5 fb3f1bce90 Shader packs: LabPBR maps for entities, items and the hand
The shared atlas's textures (items, entities, block entities) now bring
their _n and _s maps to shader packs as paged maps: 16x16 pages of the
atlas, only those holding a mapped texture stored, found through a page
table at the map's start. The programs drawing that geometry read
normals and specular through hz_pagedTexture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:39:19 +01:00
Florian ErnstandClaude Opus 5.5 181ca3d833 Merge origin/main into fix/h052-vehicle-container-save
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:35:40 +01:00
Florian ErnstandClaude Opus 5.5 b2d87410fc Merge a Piglin's and a Villager's saved inventory stacks on load
InventoryCarrier.readInventoryFromTag loads the saved stacks with
SimpleContainer.fromItemList: clear, then addItem each one, which fills
earlier stacks of the same item and components up to the limit before it
takes an empty slot, and drops what does not fit in the eight. Piglins
and villagers took the first eight saved stacks as they were, so 2 + 3
stone stayed two stacks and 40 + 40 did not become 64 + 16.

The villager's existing SimpleContainer.addItem port becomes a free
add_to_container, unchanged; both loads add each decoded stack through it
at the type's stack limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:33:30 +01:00
Florian ErnstandClaude Opus 5.5 833bb5cab4 Merge origin/main into fix/h155-fork-function-feedback
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:23:43 +01:00
IwantHappiness 5d9d9fb3ab Merge branch 'main' into translate-ru-lang 2026-11-07 20:18:57 +03:00
Florian ErnstandClaude Opus 5.5 65e2abae80 Count Absorption in a mob's max_absorption and clamp its amount to it
Absorption adds 4 per level to max_absorption (an ADD_VALUE modifier),
and LivingEntity clamps the absorption amount to getMaxAbsorption: when
the effect starts (setAbsorptionAmount) and when it goes
(onAttributeUpdated). A mob's max_absorption lived only in the command's
per-target attribute map, without the effect's modifier; /effect clear
left the amount, and expiry subtracted 4 per level, so a mob with a
raised base lost absorption it keeps in vanilla.

The mob's max_absorption now uses the attribute map it already has for
armor; its effective value counts the effect in the ADD_VALUE phase. The
add clamps the amount to it, /effect clear and expiry clamp to what is
left. The command-set base and modifiers stay unsaved, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:17:00 +01:00
SenjinandClaude Opus 5.5 dddf351a05 Shader packs: at_velocity for the player's own model
Its vertices fell in the unmarked run that closes the mobs', so in third
person (and in a pack's shadow pass) its at_velocity read zero.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 18:03:19 +01:00
MrCloudy2andClaude Opus 5.5 570d53a780 A move packet counts from the position the server last reported
ClientPacketListener.handleMoveEntity decodes a move's delta from the
entity's position codec base, which AddEntity, a move and a position sync
set and a TeleportEntity leaves alone. Horizon counted it from the
tracked position, which the teleport had moved: when a command teleported
a vehicle, its rider was told the teleport and then the tracker's delta,
and saw the vehicle (and themselves) as far again past where it was.

lan_e2e gains `vehicle-teleport`: a strider the guest rides, teleported
3 blocks, is where the server has it in the guest's game.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:51:29 +01:00
TheMrZZandCodex gpt-6.1-sol 8db7c3ddc0 fix: preserve plain forked function feedback order
Prepare starts for eligible actual sources before executing their owned function calls. Keep the existing body, callback, store and fallback paths, and consume or clear invocation slots around leaf execution.

Add frozen Java/Game command parity and causal store, return, error and fallback controls.

Fixes #11824

Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-07 17:33:05 +01:00
IwantHappinessandNemotron 4cc2a04c25 Translate remaining Russian launcher and game strings
Translate still-English UI strings in launcher/lang/ru.json and the game's
crates/horizon-client/assets/horizon/lang/ru_ru.json (particle culling
settings). Keep proper nouns, acronyms, key names, paths and env vars in
English.

Co-Authored-By: Nemotron <[email protected]>
2026-11-07 19:20:43 +03:00
MrCloudy2andClaude Opus 5.5 a61825404a A vehicle's teleports leave its rider's look alone
ClientPacketListener.handleMovePlayer applies a position packet only when
the player is no passenger, and still accepts the teleport. Horizon's
client applied it to a rider too, look included: a map whose datapack
teleports the vehicle every tick (`tp @s ~ ~ ~ 0 0` on a strider) snapped
the rider's view back 20 times a second. A rider now keeps its own
position and look and answers the teleport with them.

lan_e2e gains `rider-look`: a tick function teleports the strider the
guest rides, and the guest's view stays where they turned it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:18:26 +01:00
Florian ErnstandClaude Opus 5.5 ce25d100ef Merge origin/main into fix/mob-effect-amplifier-codec
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:15:10 +01:00
Florian ErnstandClaude Opus 5.5 a191dcd2b2 Merge origin/main into fix/h052-vehicle-container-save
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:14:59 +01:00
Florian ErnstandClaude Opus 5.5 8b577fc24c Merge origin/main into fix/h032-jukebox-saved-clock
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:14:51 +01:00
Florian ErnstandClaude Opus 5.5 974305151d Merge origin/main into fix/summoned-leash-knot-lifecycle
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:14:50 +01:00
Florian ErnstandClaude Opus 5.5 e6941baa5a Merge origin/main into fix/h195-command-damage-range
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:14:49 +01:00
Florian ErnstandClaude Opus 5.5 1bf526ca7f Merge origin/main into fix/h193-effective-component-presence
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:14:48 +01:00
Florian ErnstandClaude Opus 5.5 635f14ea0e Merge origin/main into fix/h151-boat-passenger-command
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:14:47 +01:00
MrCloudy2andClaude Opus 5.5 d72b2a555b execute on passengers finds the players riding a vehicle on a server
Entity.getPassengers holds players as well as mobs. Horizon's `on
passengers` named the player in place when a mob had a rider flag, and no
server player: a map's datapack, running with no player in place, never
found the player riding its strider, and a command the host ran named the
host instead of the guest riding. It now gives the player in place when
they ride the entity, and each other player of the level riding it.

Mob and boat passengers are left to #11810.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:10:47 +01:00
Florian ErnstandClaude Opus 5.5 7cd9dbc7a2 Let Health Boost raise a mob's healing maximum and clamp when it goes
Health Boost is a max_health attribute modifier. The attribute getter
already counted it, but Mob::heal clamps to the cached attrs.max_health,
which the effect paths never refreshed, and nothing lowered Health when
the effect went (LivingEntity.onAttributeUpdated). Adding the effect,
/effect clear and its expiry now refresh the cache and lower Health above
the new maximum; the add still heals nothing.

Sulfur cubes and wolves write their maximum straight into the cache
(sulfur_cube::set_size, tame::set_tame), outside the attribute model,
and keep their current behavior. Other effect removal paths are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 17:10:03 +01:00
JoansitohandClaude Sonnet 5.5 6d1746d729 launcher: the Home patch log and console logs keep the wheel to themselves
Their overflow_y_scroll lists lacked the on_scroll stop_propagation every other
inner scroller has, so a wheel turn the list could not use (up at the top, or
down at the end) scrolled the whole page behind it.

Fixes #11853

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 17:04:07 +01:00
Florian ERNSTandCodex 2dd6879bc4 Keep actual bell block entities for command reads
Co-Authored-By: Codex <[email protected]>
2026-11-07 16:55:24 +01:00
Stink-OandClaude Opus 5.5 aa2220fcf6 Native mod API: hold the terrain's picture while the world changes (native_world_hold)
A client mod asks once a frame (`hold.hold()`, or `hold.hold_within(x, z, radius)` for circles):
sections already on screen that are meshed again are uploaded as ever but wait beside the meshes
drawn, and letting go swaps them all in on one frame with nothing left to upload. Smaller circles
let go of what they leave. In single player, far terrain waits too for the columns the server
changes beyond the view inside the hold, and takes them in when it lets go of them. Bounded: 30 s,
1 GiB of waiting meshes, the arena running out; ended so, it stays off until no mod asks for a
frame. Clearing the sections (another world or dimension) and unloading columns drop what waits;
arena compaction moves waiting meshes too. Renderer::upload keeps its order on the normal path
(before_mesh / upload_mesh / after_mesh). Tests in gfx/hold.rs; docs in native-mods.md; fragment
world_hold.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 15:34:09 +00:00
8cd009e149 Read saved template structure starts before regenerating them
Part of #11126. Builds on #11652.

Decode shipwreck, ocean ruin, igloo, ruined portal, woodland mansion,
nether fossil and end city pieces from saved starts. Rebuild template
boxes and placement settings like vanilla's tag constructors, retaining
the whole-start regeneration fallback for unsupported or broken pieces.

Cover every new type with resource-free round trips and extend the
prepared-resource generation/read comparison across all three dimensions.

Piece ids go through #11652's saved_piece_id first; any other id is
matched with or without the minecraft: namespace, not lowercased, as
Identifier.parse reads it.

Co-Authored-By: Codex (gpt-6.1-sol) <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 16:33:44 +01:00
SenjinandClaude Opus 5.5 ebfcad98f6 Shader packs: at_velocity for blocks a piston moves
A moving block (and an extending or retracting head) is drawn with the entities while it
moves, and read zero at_velocity: flying machines and piston contraptions smeared under a
pack's TAA. Each marks its own run, (6 << 32) | the cell it moves to, which stays the same
while it moves; a finished one keeps that key until the chunk mesh shows the block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 16:25:09 +01:00
yahya-nusseibehandClaude Opus 5.5 d94fdae0b9 Agent control: no shared /tmp socket path, and bench refuses bad numbers
Without XDG_RUNTIME_DIR (containers, some WSL and minimal setups) the
control socket was /tmp/horizon-control.sock, a fixed name in a folder
every user shares. Another user who bound it first made --control fail
to start, and horizon-ctl then talked to their socket.

When the temporary directory is shared (world-writable, as /tmp), the
default endpoint is now horizon-<uid>/horizon-control.sock in it. The
game makes that folder 0700, and both the game and horizon-ctl refuse
it unless it is a real folder, owned by this user, that no one else may
enter. A temporary directory of the user's own (macOS's $TMPDIR) is
used as before, so nothing moves there. The launcher's copy of the
default endpoint (game_tools.rs) follows the same rule.

Separately, `bench -1` or `bench nan` panicked the game in
Duration::from_secs_f64; bench now takes 0 to 86400 seconds and refuses
anything else.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SJ3stK8iXVDXqoi7midcqd
2026-11-07 17:20:50 +02:00
Florian ERNSTandCodex e16378accd Use world RNG for literal command predicate chances
Co-Authored-By: Codex <[email protected]>
2026-11-07 16:19:02 +01:00
Florian ErnstandClaude Opus 5.5 4adf2afffb Drop passenger entries that load nothing, keep riders through /data merge
EntityType.loadPassengersRecursive mounts only the Passengers entries that
load, and Entity.saveWithoutId saves the riders the entity has.
take_mob_passengers kept every non-mob entry raw, so an unknown or missing
id, or a non-compound value, stayed in the saved Passengers. It now drops
an entry that is not a compound or has no registered type (entity-types,
EntityType.by), and keeps valid non-mob entries raw as before.

Entity.load does not read Passengers either. apply_entity_nbt stored the
whole merged compound as raw, so a mob, boat, minecart or TNT saved copies
of its live riders and any merged entries after /data merge. It now keeps
the Passengers the load kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 16:09:01 +01:00
iseaprojectsandDeepSeek V4.1 Flash d1dd934be2 Spanish: finish the launcher and es_es strings
The launcher's es.json still held 91 English values: the mod-port status sentences, release notices, look-and-feel settings, the SSH hosting panel and several install/update results. Translate them, and fix Back from the body part (Espalda) to Atrás.

es_es.json was 20 keys short of en_us.json: every /studio replay message, Play in Background and the controller-focus note. Add them so Spanish screens no longer fall back to English.

Closes #11814.

Co-Authored-By: DeepSeek V4.1 Flash <[email protected]>
2026-11-07 11:08:01 -04:00
MrCloudy2andClaude Opus 5.5 a95c0e022d lan_e2e shield: each player's own game shows the disabled shield's cooldown
The shield check now also asks each player's window what its hotbar
draws over the shield (a new `shield_cooldown_shown` in the control
state: ItemCooldowns' percent for minecraft:shield). Right after the
vindicator's axe disables it the cooldown shows, and after the 100 ticks
it is gone. On main both players' games showed none (#11805).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 15:41:24 +01:00
Florian ERNSTandCodex 282a7005c8 Fix chorus-flower drops from arrow and snowball impacts
Co-Authored-By: Codex <[email protected]>
2026-11-07 15:40:50 +01:00
Florian ErnstandClaude Opus 5.5 5440872e93 Refuse /summon trees that hold a live entity's UUID
ServerLevel.tryAddFreshEntityWithPassengers checks every UUID of the
summoned tree against the loaded entities before anything joins, and
fails with commands.summon.failed.uuid. summon_with_nbt now walks the
same tree the loaders admit (the root, then the mob riders that
take_mob_passengers takes under mob, boat, minecart and TNT roots) and
refuses it when an entity in the level holds one of its UUIDs.

Duplicate UUIDs inside the new tree are still admitted (vanilla skips
the later one but keeps it under its vehicle's Passengers); the
command harness keeps them as --summon-uuid-internal-diagnostic and
the Game test as a known-unfixed ignored test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 15:39:15 +01:00
MrCloudy2andClaude Opus 5.5 2f3743d282 An axe disabling a shield sends the defender the shield's cooldown
BlocksAttacks.disable adds the item cooldown (ItemCooldowns.addCooldown
on the shield's group), which ServerItemCooldowns sends a player as
Cooldown(minecraft:shield, 100) and ends with 0. Horizon only set its own
shield counter, so a guest's client never heard of it: no cooldown on the
hotbar, and a held right click could show the shield raised while the
server had it down. The disable now also goes through the item cooldowns.

Fixes #11805

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 15:25:58 +01:00
SenjinandClaude Opus 5.5 381c5a1e62 Shader packs: at_velocity for boats, minecarts, armor stands, frames, paintings, TNT, falling blocks and block entities
They were drawn in runs marked only by type, so a pack's at_velocity read zero on them even
while they or the camera moved (TAA smeared them). Each now marks its own motion run:
(3 << 32) | entity id, (4 << 32) | id for an item frame's held item, (5 << 32) | position for a
block entity, with a closing mark after each group; maps stay unmarked (keyed by map id).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 15:25:24 +01:00
itarqos5andClaude Opus 5 6a634e49e2 feat(render): a compact layout for far tiles' quads, a quarter of the arena
Chunk sections already put their solid quads in the arena as one 24-byte
record each instead of four 24-byte vertices (`mesher::packed`). Far tiles
never could: that record's coordinates are a block grid of 16, and a far
tile's quads are merged rectangles of a voxel column's exposed side,
hundreds of blocks wide. So they stayed at four vertices a quad, and at
`lodDistance` 256 they were by far the largest thing the renderer held.

A far quad is much more regular than a chunk's, though -- a rectangle in an
axis-aligned plane, one colour, one light and one layer across all four
corners, with UVs `lod::mesh::emit_quad` derives from the positions -- so a
record of its own holds it in the same 24 bytes, and terrain.wgsl's
`far_corner` does what that function did. The two layouts share the arena
and the pipeline; a draw's base vertex says which it is (`FAR_BASE`).

Measured on a settled LodTest at `lodDistance` 256, render distance 16, the
same binary with `HORIZON_FAR_PACK=0` and without, each run settled on the
same 4424 tiles and the same quad count to within four:

                      far vertices   arena pages   GPU allocated
    four vertices        492.5 MiB       960.0        1241.7 MiB
    a record a quad      127.4 MiB       640.0         921.8 MiB

365 MiB less vertex data, and 320 MiB less video memory actually allocated
rather than merely accounted for. 24.8 bytes a quad: a record each, and the
few quads that spill. Both figures repeated exactly over two pairs of runs.

Frame time is unchanged. Over the same flight, the mean of two pairs:

                      avg FPS   1% low   GPU avg
    four vertices       171.0     95.8    5.390 ms
    a record a quad     170.3     94.9    5.420 ms

The pairs disagree on the sign -- the compact layout was 1.5% slower in one
and 0.7% faster in the other -- so the difference is run variance, not the
cost of expanding a record. Worth stating because one pair alone read as a
regression.

Nothing here reasons about which record is right for a quad: `pack` builds
one, rebuilds the four vertices from it, and keeps it only if they come back
bit for bit. A quad no record reproduces is kept as its four vertices, as
`mesher::packed` keeps one; in practice that is the fluid faces, whose
surface sits at 8/9 of a block, and about 1% of quads.

`lod::mesh`'s `every_quad_the_mesher_emits_packs_and_comes_back` holds the
layout and the mesher to each other over real terrain, which the layout's
own tests cannot: they check its records against its own copy of what
`emit_quad` does, and would pass just as well if the two had drifted.

A same-build control says the picture does not change: two launches of the
identical build differ in 50.7% of pixels (16.0% above the animation noise
floor, worst channel delta 76), because far-tile refinement does not settle
identically between launches. Packed against unpacked differs in 40.5%
(12.8% above the floor, worst 77) -- less than the control.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011paghWkrnyQRBhJRodZpG2
2026-11-07 14:13:34 +00:00
Teiwazik 1eb3b7f6c3 Merge remote-tracking branch 'origin/main' into tmp-seat/follow-plugin-seat-chains 2026-11-07 15:12:38 +01:00
TheMrZZandCodex gpt-6.1-sol ce3a7a7587 Project live boat passengers in command NBT
Reuse the existing runtime tree projection before the live leash writer. Preserve the original full-body diagnostic and add an independently admitted typed-tree command gate.

Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-07 15:07:30 +01:00
MSedgeMC 2f7a46dfd3 port_map: the Camel.canMate row no longer records the canParent gap 2026-11-07 13:48:54 +00:00
MSedgeMC dfe4c2cb51 Test that a wounded or ridden camel cannot breed
Two camels in love in a built world: the breed goal starts, then one loses a
point of health and is refused, and a rider also refuses it. Without the
canParent guard the wounded camel still starts the goal.
2026-11-07 13:48:54 +00:00
MSedgeMC 3ed00f4071 A wounded or ridden camel no longer starts breeding
`Camel.canMate` is `partner instanceof Camel && this.canParent() &&
camel.canParent()`, and `AbstractHorse.canParent` requires no vehicle or
passenger and full health (a camel's `isTamed` is always true). The shared
`Breed` goal applied those checks only to horses, donkeys and llamas, so a
camel stayed free to breed while hurt or carried.

Camels still pair only with camels: the `camel` flag feeds the canParent
guard only, not the partner species rule.
2026-11-07 13:48:54 +00:00
MrCloudy2andClaude Opus 5.5 36add718c0 Spears stab other players: the charge and the jab reach players on a server
KineticWeapon.damageEntities and PiercingWeapon.attack hit every entity
along the view, players included (PiercingWeapon.canHitEntity:
canHarmPlayer, not the same vehicle). Horizon's stab targets were the
mobs only. A guest's spear now also reaches the other players of its
level; each stab is worked out as the attacker in their turn and lands
through the PvP path once the hub is back, with the spear's damage type,
the 0.4 push and the weapon's Knockback, the dismount, thorns and the
kill score, then the attacker's wear, stats, exhaustion and hit feedback.

The kill score and thorns of pvp_land move into pvp_aftermath, shared by
both. lan_e2e gains a `spear` check: a jab and a sprinting charge hurt
the host, and with the pvp game rule off neither does.

Fixes #11790

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 14:42:20 +01:00
MSedgeMC 077164ff2f port_map: the camel RandomSitting row no longer records the pose gap 2026-11-07 13:39:44 +00:00
MSedgeMC c953fe79cb Test that a sitting camel cannot stand under a two-block ceiling
The test builds a world with a stone ceiling cell inside the standing box
but above the sitting box, then asks RandomSitting, the arm the goal
selector calls: 200 asks must all be refused. A second camel with open sky
fires within the same 200, so the refusal is the pose check and not the
state setup. Dropping the can_change_pose conjunct fails the first loop.
2026-11-07 13:39:44 +00:00
MSedgeMC 92282c7476 A sitting camel stands up only when its standing box fits
`CamelAi.RandomSitting.checkExtraStartConditions` ends with
`body.canCamelChangePose()`, which is
`wouldNotSuffocateAtTargetPose(isCamelSitting() ? STANDING : SITTING)`.
RandomSitting did not ask, so a camel sitting under a ceiling that blocks
its 2.375 tall standing box (its sitting pose is 0.945 tall) stood up into
it. The `can_change_pose` helper already existed for the elastic leash pull.
2026-11-07 13:39:43 +00:00
TeiwazikandClaude Sonnet 5.5 052c2eb962 Native shader packs: sections fade in toward the fog colour like vanilla terrain
The fade-in rides the high 16 bits of the flat hdr_code varying (no new
location); solid and translucent colours mix toward the fog colour after
the pack's material, alpha kept.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 14:35:56 +01:00
Florian ERNSTandCodex 1066efbafb Normalize note-block instruments during fill
Co-Authored-By: Codex <[email protected]>
2026-11-07 14:35:22 +01:00
TeiwazikandClaude Sonnet 5.5 fdc056c8ac Older servers: send sign_update with the side before the lines
26.3 ends sign_update with the side as a VarInt; 26.2 and older read it as a
boolean right after the position. Forwarding the packet unchanged made the
server misread it and kick the player on Done.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 14:23:33 +01:00
Horizon agent 9f6aa5f2f6 Merge origin/main into PR #11682
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/horizon-client/src/game/commands/terrain_cmds.rs
#	crates/horizon-items/src/items.rs
2026-11-07 14:19:54 +01:00
e8a5564059 Cache decoded saved palette entries in the block registry
A saved area resolves the same dozen block states in every section of every column, but decode_column built a format!-ed String key and parsed each entry through BlockState::from_nbt into a per-column HashMap. The registry now memoizes palette entries by their NBT in an FxHashMap keyed by the tag itself, so a repeated entry costs one hash and one comparison and allocates nothing; the per-entry resolution rules move with it unchanged. Loading the 529-column saved area drops Persistent::load from 1,467.8M to 1,284.3M instructions.

Part of #9996.

A first draft by DeepSeek V4.1 Flash, via pi, reviewed and reworked.

Co-Authored-By: DeepSeek V4.1 Flash <[email protected]>
Co-Authored-By: Codex (gpt-6.1-terra) <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 14:15:22 +01:00
70a0a29eec Check packed palette indices one word at a time
Loading a generated area spends 16% of Persistent::load (the worker's
chunk load) in PalettedContainer::from_packed, and nearly all of it is
check_indices: a scalar bounds check of every entry of every section
(~10.6 instructions per entry, 22M entries per 529-column area).

check_indices now rejects a whole word at once. Adding 2^bits - palette
to a word lifts every field by that much, so a field carries out of its
own bits exactly when its index is past the palette; the carry out of
each bit is computed for the whole word with (a & b) | ((a | b) & !sum).
A field can only appear bad where a genuinely bad field precedes it in
the same word (a carry adds one to it), which never turns an accepted
input into a rejected one, and the offending word is rescanned entry by
entry on the error path so the reported index is the same first
offending entry as before. The last word's padding fields are biased by
zero, so they cannot look bad, as the entry-by-entry scan ignored them.
The same set of inputs is accepted: the early return when the palette
holds exactly 2^bits entries was already there and stays.

Part of #9996.

A first draft by DeepSeek V4.1 Flash, via pi, reviewed and reworked.

Co-Authored-By: DeepSeek V4.1 Flash <[email protected]>
Co-Authored-By: Codex (gpt-6.1-terra) <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 14:15:22 +01:00
5cffcf1370 Load saved light directly from its layers instead of expanding and repacking
The saved sky and block nibble layers are already the resident Light::Sky and Light::Block layout. Choose the resident variant from the layers and copy the stored layer when only one kind of light varies, so only sections where both vary still expand their light into a full array. Missing layers still inherit the bottom row above and dimensions without sky light still ignore saved sky layers.

Part of #9996.

A first draft by DeepSeek V4.1 Flash, via pi, reviewed and reworked.

Co-Authored-By: DeepSeek V4.1 Flash <[email protected]>
Co-Authored-By: Codex (gpt-6.1-terra) <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 14:15:22 +01:00
Horizon agentandClaude Opus 5.5 c3f5770bb9 Merge origin/main into #11301 (main builds again after #11767)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 14:10:28 +01:00
Horizon agentandClaude Opus 5.5 5a07a7edfe Merge origin/main into #11301 (keep both data.rs test modules and command_exec groups)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 13:59:39 +01:00
Florian ERNSTandCodex 2688eb16d6 Decode Mob effect amplifiers as unsigned bytes
Co-Authored-By: Codex <[email protected]>
2026-11-07 13:52:45 +01:00
TeiwazikandClaude Sonnet 5.5 ff28824d42 Riding: boat riders keep their own seat
position_riders re-seated every mob whose vehicle is not a mob through
passenger_riding_position, which puts every boat rider in seat 0 from
the boat's position. seat_boat_mobs had already placed them, so remote
players on a moving boat jumped between the two seats each pass.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 13:44:21 +01:00
bulkandClaude Sonnet 5.5 a0c5f26cc2 Far ring brake: pull in over 50 ms, grow back under 45 ms
The ring got stuck at its smallest on servers whose normal tick sits
between 25 and 40 ms, since it only grew back under 25 ms.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 12:43:37 +00:00
TeiwazikandClaude Sonnet 5.5 45978aaf67 Seat test: import Vec3 and play packets
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 13:43:19 +01:00
24fa04d753 fix: drop mob XP after the guest who hurt it has left
Vanilla LivingEntity.dropExperience and Mob.dropCustomDeathLoot key on
lastHurtByPlayerMemoryTime, not whether that player is still in the
world. Horizon folded both into Death.player, so a guest who left
within the 100-tick memory made drops::die skip experience and
equipment.

Give die a player_killed flag from the timer. LAST_DAMAGE_PLAYER stays
None when killer_uuid cannot resolve them.

Fixes #11674

Co-Authored-By: OpenCode <[email protected]>
Co-authored-by: monkeycode-ai <[email protected]>
2026-11-07 12:29:23 +00:00
Mayonesu0 1429b27098 Merge remote-tracking branch 'origin/main' into perf/launcher-write-data-file 2026-11-07 13:20:05 +01:00
DetimesandClaude Opus 5.5 c78882c7da Older clients: attributes and effects in the client's numbering
1.21.2 dropped the generic./player./zombie. attribute prefixes, so the id tables of 1.21.1 and 1.20.6 (matched by
name) had no attribute runs and every update_attributes value was left out for those clients. They are regenerated
with the renames. Mob effect ids were never renumbered: update_mob_effect and remove_mob_effect now go through the
client's table, and an effect added after its release is not sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 12:16:51 +00:00
Horizon agentandClaude Opus 5.5 3cbe777d44 Merge origin/main into fix/set-custom-model-data
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 13:08:36 +01:00
Horizon agentandClaude Opus 5.5 28299018c7 Merge origin/main into fix/vindicator-johnny
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 13:02:07 +01:00
Detimes bb22bf6570 Merge remote-tracking branch 'upstream/main' into fix-11722-old-pick-item 2026-11-07 11:58:27 +00:00
DetimesandClaude Opus 5.5 c7f54b7461 Older clients: a 1.21.3 client's pick-item swaps the slot into its hand
1.21.3 and older clients send pick_item with the inventory slot that holds the picked block's item; 26.3 has no
such packet and the adapter dropped it. It now becomes a container_click swap of that slot with the held hotbar
slot (tracked from set_carried_item and set_held_slot), state id 0 so the server resends the inventory.

Fixes #11722

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:58:27 +00:00
TheMrZZandCodex gpt-6.1-sol 7e8c7a27c1 Use effective stack prototypes for component presence
Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-07 12:38:41 +01:00
Mayonesu0andClaude Opus 5.5 199e8193fd Launcher: write a prepared version's data file after installing it
A version's first start read its thousands of small files one by one, about
100 s under Windows Defender here, because only the game wrote
horizon-data.bin, and only after that slow start. The launcher now writes it
in the background once an install or import has its resources, reading on up
to 8 threads (43 s against 281 s on one, on a fresh copy); the start then
loads in 1.2 s. The game stays the fallback, on its one idle thread.

A reused version no longer copies the data file, which names its own root.
complete_assets removes the file when it adds something, as the file answers
missing for what it lacks. A write removes what a stopped writer left.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 12:38:08 +01:00
TheMrZZandCodex gpt-6.1-sol ac4859eab4 fix: match command damage-only item predicate ranges
Evaluate the supported damage-only subpredicate against modeled damage and
existing effective component presence. Preserve removal precedence and leave
unsupported conjunctions on their existing path.

Fixes #11715

Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-07 12:23:52 +01:00
Florian ERNSTandCodex 087c763432 Normalize summoned leash knots and check their fence support
Co-Authored-By: Codex <[email protected]>
2026-11-07 12:23:27 +01:00
Horizon agentandClaude Opus 5.5 08f2880b2a Merge main (clippy as_chunks lint fix)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:52:14 +01:00
Horizon agentandClaude Opus 5.5 03d1f86f4a Merge main (clippy as_chunks lint fix)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:50:56 +01:00
Horizon agentandClaude Opus 5.5 65d3e70f5d Merge main (clippy as_chunks lint fix)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:47:54 +01:00
Horizon agentandClaude Opus 5.5 14428f3233 Merge main (clippy as_chunks lint fix)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:46:07 +01:00
TeiwazikandClaude Sonnet 5.5 55a54edebe Riding: follow plugin seat chains through invisible vehicles
Plugins seat players on text displays, interactions, armor stands or area
effect clouds that ride another player. Resolve the seat through the whole
chain of vehicles, keep the packet riding graph, move the local rider with a
moving seat, and use the Avatar attachment height for player vehicles.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 11:44:41 +01:00
Horizon agentandClaude Opus 5.5 4a697d3689 Merge main (clippy as_chunks lint fix)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:44:19 +01:00
Horizon agentandClaude Opus 5.5 baab15d42d Fail location_check on unloaded counterparts
Vanilla's LocationPredicate checks Level.isLoaded before the block predicate, so an offset into an unloaded chunk fails instead of holding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:35:59 +01:00
Horizon agentandClaude Opus 5.5 71c7dfaf97 Merge main; fail location_check on unloaded counterparts
Vanilla's LocationPredicate checks Level.isLoaded before the block predicate, so an offset into an unloaded chunk fails instead of holding. Drops the docs/parity run logs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:35:26 +01:00
Riccardo GuerrieroandClaude Opus 5.5 c9f2efa210 A player's Thorns hurts the mob as the player's thorns hit
Thorns on the player answered a mob's hit with generic damage that had no
attacker, so the mob was not knocked back, did not turn on the player and
dropped no experience when it died of it. It now hurts the mob by
`minecraft:thorns` damage the player caused (`DamageEntity` with the
wearer as owner), rolled from the mob's own random, and the held weapon's
Breach applies as on any hit by the player.

The whole equipment counts, in `EquipmentSlot` order: the main hand, the
off hand, then feet up to head (Thorns' slots are `any`), so a Thorns
piece held in a hand answers too. Each piece rolls its chance, hurts the
attacker and wears in that order, also when the attacker is already dead.
A piece that takes no wear, or a creative player's, is left alone.

A mob hit by thorns damage plays `enchant.thorns.hit` where it stands
when the hit lands whole, silent or not (`playSecondaryHurtSound`).

Part of #9954.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:34:28 +01:00
Horizon agentandClaude Opus 5.5 d12d6262bb Drop the docs/parity run logs and their one-off capture script
Run logs are not docs; the PR body keeps the numbers. tools/inline_trim_packet_capture.py only produced the dropped packet log and nothing calls it; the protocol test keeps the captured payload.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:25:02 +01:00
Horizon agentandClaude Opus 5.5 c36df3986f Merge origin/main into fix/inline-armor-trim-holders
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:25:01 +01:00
Horizon agentandClaude Opus 5.5 38f887eab2 Merge #11655 (with #11643) into #11654
The three loot functions add arms and tests at the same spots in loot.rs; all kept. Land #11643, then #11655, then this.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:15:02 +01:00
Horizon agentandClaude Opus 5.5 71c1240617 Drop the docs/parity run logs
Run logs are not docs; the PR body keeps the numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:14:40 +01:00
Horizon agentandClaude Opus 5.5 14100456d1 Merge origin/main into fix/named-predicate-context
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:14:40 +01:00
Horizon agentandClaude Opus 5.5 32109b87b6 Merge #11643 (set_book_cover) into #11655
Both add a set_loot_component arm, a loot.rs function arm and a loot test at the same spots; both kept. Land #11643 first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:14:10 +01:00
Horizon agentandClaude Opus 5.5 66ecf65d4e Merge origin/main into fix/h157-player-save-projection
Keep main's vibration_tests module beside the new test module; the test's Joined literal gains main's new configured field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:08:46 +01:00
Horizon agentandClaude Opus 5.5 1315c0e4db Vindicator: write Johnny only while the flag is set
Vindicator.addAdditionalSaveData writes Johnny: 1b only when isJohnny is true; a vindicator that is not Johnny saves no key (and drops a stale Johnny: 0b from its raw compound).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:07:23 +01:00
Arslan ArmanulyandClaude Opus 5.5 d3e7858cda Shader packs: GPU example fixtures give their packs terrain programs
Since a pack with no program for terrain or translucent terrain gets the
notes "no program for terrain; nothing draws it" and "no program for
translucent terrain; nothing draws it", standard_pack_gpu_entities and
entity_shadow_ownership failed their no-notes assertions: their packs had
entity programs only. Both packs now also have gbuffers_terrain and
gbuffers_water. The fixtures draw no terrain, and every other assertion is
unchanged.

Fixes #11710

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 15:06:18 +05:00
Horizon agentandClaude Opus 5.5 4169af3fa6 Merge origin/main into fix/h181-noai-trader-llama-delay
Keep main's craft_map_take import beside the trader llama corpus import.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:01:55 +01:00
Horizon agentandClaude Opus 5.5 306f9425e8 Merge origin/main into xp-orbs-riding-merge-water
ordered_tick: main's obstacle grid for the orb move kept after the
merge scan and the followed-player pick. A kept followingPlayer now
stays at exactly 8 blocks: ExperienceOrb.followNearbyPlayer re-picks
only past distanceToSqr > 64. Orb merge fixture keeps merge_new_orb.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 11:01:54 +01:00
TheMrZZandCodex gpt-6.1-sol 6d5c7c51a6 Preserve modeled jukebox saved-song clock presence
Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-07 11:01:17 +01:00
AkirabaneandClaude Opus 5.5 8e0b157254 dedicated: a stop waits for a proxy to move the players out first
With [transfer] on and players on, a stop (/stop, a stop signal, the
supervisor's stop or restart) now waits stop_wait_seconds (10 by default,
0 to 60, 0 stops at once as before) so a proxy told server/stopping can
move the players out first. The log says "Stopping in 10 s: a proxy may
move the players out first", which horizon-server takes as the start of
the stop. Every login is refused as server_shutdown, and the server ticks
on and answers the proxy's requests.

The wait ends as soon as no player is placed, at its time when no
hand-over is frozen, and at the latest a freeze's longest time later, so a
hand-over started in time finishes; the whole wait is cut at 90 s, within
the supervisor's 120 s for a stop, so stop_wait_seconds and
max_freeze_seconds may add up to 90 at most when the stop waits. No freeze
starts that this limit would cut: a player its source saved after the
target placed it would be on both servers. A freeze lasts ticks, so its
length is reckoned at the tick length of the moment (the rate's, or longer
on a server slower than its rate). A second stop ends the wait. Then the
stop goes on as vanilla's.

Refs #7484

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 10:51:02 +01:00
Horizon agentandClaude Opus 5.5 b0047b5518 Merge origin/main into #11301
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 09:51:22 +01:00
Horizon agentandClaude Opus 5.5 1990e4aecc Merge origin/main into #11301
Keep main's non_mob_tag base with the PR's class-owned container fields,
and both new test modules and corpus groups.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 09:35:57 +01:00
Florian ERNSTandCodex 16d77f41d4 Bind loaded block locations in loot-mine conditions
Co-Authored-By: Codex <[email protected]>
2026-11-07 09:17:11 +01:00
Florian ERNSTandCodex 7f21b95989 Adapt new equipment wear test to named trim holders
Co-Authored-By: Codex <[email protected]>
2026-11-07 08:15:48 +01:00
Florian ERNSTandCodex 76123f5638 Preserve inline armor-trim holders through item state and sync
Co-Authored-By: Codex <[email protected]>
2026-11-07 08:13:34 +01:00
MSedgeMC 3b8ac89d2c port_map: SetBannerPatternFunction.run is ported
The row said layers from loot are not set and no vanilla table uses the
function; a datapack table does, and the row now names the arm and the item-side
parse that puts the layers on the banner.
2026-11-07 06:49:34 +00:00
MSedgeMC f8aa8e0e0d test: the loot arm appends or replaces, and the item wears the layers
The loot table test fills a chest with a white banner through set_components
(a red stripe at the bottom) and then set_banner_pattern with append: the
component carries both layers, in that order; with append false it carries only
the function's blue border. Without the arm the append case keeps the single
red layer.

The item test hands set_loot_component a banner_patterns list and reads
`banner_patterns` back as two BannerLayers (pattern and dye), and a null
component empties them again. Without the arm the list is empty - the banner
wears nothing.
2026-11-07 06:49:34 +00:00
MSedgeMC 6ec1865ac1 fix: a looted banner_patterns component dresses the banner
set_loot_component only knew the trim, so a rolled banner_patterns list landed
in `other` as a raw tag: the renderer and the tooltip read
`StackData::banner_patterns`, which stayed empty, and the banner from a
datapack table (or a set_components function) came out undyed. The arm parses
the component with the same `layers_from_nbt` the item's own component uses, so
the layers - pattern and dye - reach the fields the game reads.
2026-11-07 06:49:12 +00:00
MSedgeMC 18cb5eb6d0 fix: set_banner_pattern writes a banner's layers
SetBannerPatternFunction sets the stack's banner_patterns to the function's
layers, or with append adds them to the end of the component's own list
(BannerPatternLayers.Builder.addAll twice). A layer is a pattern id and a dye
name, so the list the table wrote is the component's list as it stands. The arm
was missing, so a datapack's banner pattern changed nothing: the banner came out
bare, or with only the layers an earlier function wrote.
2026-11-07 06:49:12 +00:00
MSedgeMC 66931c6958 port_map: the two set_custom_model_data rows are ported
apply names the ListOperation helper its four lists go through, and run names
the arm that draws the floats and colours and keeps the component the stack
already had. The rows said "no vanilla loot table uses it", which was true but
not a reason for a table that does to change nothing.
2026-11-07 06:46:00 +00:00
MSedgeMC 0ba45ef93e test: the four model-data lists each follow their own operation
A table writes custom_model_data through set_components (floats [1.0], strings
["old"]) and then set_custom_model_data: floats appended from a constant
provider, flags and strings replaced, a colour inserted first. The rolled stack
carries 1.0 and 2.0, [true], ["new"] and [16711680] - without the arm the
component keeps the first function's lists and has no colours at all.

The helper's own test covers what a table rarely reaches: a replace_section of
one element, one with no size (the new values' length), an insert past the end
that changes nothing, and a mode the codec would refuse reading as a
replacement.
2026-11-07 06:46:00 +00:00
MSedgeMC 68e1549ebd fix: set_custom_model_data writes the item's four model-data lists
SetCustomModelDataFunction reads the stack's custom_model_data (EMPTY when it
has none) and replaces each of its four lists the function names - floats and
colors from number providers drawn with the loot random, flags and strings as
written - by that list's ListOperation over what was there: replace_all,
replace_section (offset and an optional size), insert at an offset, or append.
The arm was missing, so a datapack's model data changed nothing at all.

ListOperation itself is a small helper beside the number readers; an offset
past the end leaves the list as it was, as vanilla logs and ignores it there.
The component then reaches the item through set_loot_component's generic arm,
which keeps it in `other` where the model selection, the CIT rules and the LAN
sync already read it - that half needed nothing new.
2026-11-07 06:46:00 +00:00
MSedgeMC b2c9470eb7 port_map: SetBookCoverFunction.apply is ported
The row said no vanilla loot table uses set_book_cover, so nothing was missing;
a datapack's table does reach it, and it now names the arm that applies the
cover and the item-side parse that reads the component back.
2026-11-07 06:22:12 +00:00
MSedgeMC dc8f47b2e8 test: a loot table's cover titles the book, and the item reads it
The loot table test fills a chest with a written book through two modifiers: one
set_components with a title, author and page, then set_book_cover with another
title, an author and generation 2. The cover replaces the title, author and
generation, and the page the other function wrote is still the book's. Without
the arm the component keeps the first title.

The item test hands set_loot_component a written_book_content as the loot engine
builds it and reads the book back: title, author, generation and both pages, and
a null component leaves none. Without the arm the book has no content at all.
2026-11-07 06:22:12 +00:00
MSedgeMC 02dc69348d fix: a looted written_book_content reaches the book's fields
A component a loot function writes goes through StackData::set_loot_component
when the rolled stack becomes an item, and only the trim had an arm: a written
book's content landed in `other` as a raw tag nobody reads, so set_book_cover
(or set_components) titled a book whose tooltip and reading screen still showed
nothing. The content is now parsed the way the item's own component is - the
parse moves out of from_nbt into written_book_from_tag, shared by both - so the
title, author, generation and pages come out of a rolled book.
2026-11-07 06:22:11 +00:00
MSedgeMC 65e6b5ce95 fix: set_book_cover writes a written book's title, author and generation
SetBookCoverFunction updates the stack's written_book_content, over the
component it already carries: the title as a Filterable (the raw text, and the
filtered text when a server filtered it), the author, and the generation, while
the pages and the resolved flag stay as the earlier functions left them. A loot
table's written book got none of that: the modifier ran and changed nothing, so
a datapack book came out with no cover at all.
2026-11-07 06:22:11 +00:00
yahya-nusseibehandClaude Opus 5.5 d689881e68 Cap the packets a connection queues for the hub between ticks
A connection's network thread hands every play packet to the hub over
an unbounded channel. The hub's inbox caps (INBOX_LIMIT packets,
INBOX_BYTES bytes) apply only as it drains that channel at the start of
a tick, so while one tick runs long (an autosave, chunk generation) a
client can queue tiny packets without bound, each a boxed Serverbound
many times its size on the wire.

Each connection now counts what it handed the hub and the hub hasn't
taken yet (Undrained, shared between the network thread and the
guest's PlayerSender). Past twice the inbox caps the network thread
disconnects the client with the same message as the packet-rate kick
(disconnect.exceeded_packet_rate) and logs a warning; the hub
uncounts each packet as it takes it. A client within the inbox caps
never comes near.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SJ3stK8iXVDXqoi7midcqd
2026-11-07 08:06:12 +02:00
Florian ERNSTandCodex 3db0da6dd2 fix: resolve named predicates through the Game context
Bind loaded predicate references without changing source identity or origin. Defensively reject invalid reference graphs before boolean evaluation while keeping registry admission separate.

Co-Authored-By: Codex <[email protected]>
2026-11-07 04:24:58 +01:00
Vinícius MoreiraandClaude Opus 5.5 dd4528f4e4 Environment attributes: the layer stack, biome blending and weather
Ports EnvironmentAttributeSystem: every attribute is its default run
through layers in the order they are added, leading constant layers folded
into the base (bakeLayerSampler) and the result sanitized. The dimension
type's attributes are constant layers; the biome layer reads the biome at
the position, or for spatially interpolated attributes the
SpatialAttributeInterpolator mix that GaussianSampler accumulates; the
weather layers (WeatherAttributes.RAIN and THUNDER) blend by the rain and
thunder levels with each type's state-change lerp. Timelines plug in as
time layers and come next; nothing in the game uses the stack yet.

Entries of types not ported yet (append, overlay) are kept as no-ops so a
biome's other attributes still load.

The new harness environment_system compares 900 stacks with the pinned
client (36,000 lines), with the vanilla biome and dimension type data.

Part of #11486

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 23:38:15 -03:00
TheMrZZandCodex gpt-6.1-sol bca4a22e08 fix: project live player motion fields into saved data
Carry the active Player grace time and fall-particle flag through the existing
save context, restore owner snapshots after guest calls, and write the official
empty player Brain schema. Keep tracker projection outside this change.

Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-07 02:51:56 +01:00
Horizon agent ab6900b4c9 Merge main into #10283
# Conflicts:
#	crates/horizon-client/src/entity_nbt.rs
2026-11-07 01:57:18 +01:00
Horizon agent 58e32ea813 Merge main into #10280 2026-11-07 01:53:40 +01:00
TheMrZZandCodex gpt-6.1-sol 8bb5a572ec Advance eligible TraderLlama despawn delay with NoAI
Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-07 00:42:42 +01:00
baytyoneandZCode 91b3a7410e Experience orbs: pickup over the vehicle, a kept following player, merges before the move, eye-level water
Vanilla's Player.aiStep widens the pickup area to the union with the vehicle's box while riding; ExperienceOrb.tick keeps its followingPlayer until they leave 8 blocks, runs scanForMerges in its own turn before the move, and floats by the eye's fluid rather than the feet's block. Fixes #11389.

Co-Authored-By: ZCode (GLM) <[email protected]>
2026-11-07 04:12:29 +05:00
MSedgeMC b918309242 port_map: a vindicator's Johnny flag is latched, saved and read
`tools/port_map/game2-004.tsv` recorded
`Vindicator.addAdditionalSaveData` as `missing` and `Vindicator.setCustomName`'s
gap as "the Johnny goal reads the current custom name each tick; vanilla latches
the flag once a name is Johnny". Both rows now name what the port does, with a
row for `readAdditionalSaveData` beside them.
2026-11-06 23:04:15 +00:00
MSedgeMC 68f5909ef6 test: a vindicator's Johnny latch through a rename and a save
`vindicator_server_ai_step` is the AI step, and `mob_to_nbt`/`mob_from_nbt` are
the pair `Game::mob_tree_nbt` and `Game::load_mob` go through. A vindicator
named Bob is not Johnny; named Johnny it is; renamed to Bob it stays Johnny.
The save writes `Johnny: 1b`, the reloaded vindicator is still Johnny with the
name Bob, and a compound with no `Johnny` (its `CustomName` reading Johnny)
loads false and saves `Johnny: 0b`.

Without the latch the test stops at the first name: `left: false`, `right:
true`.
2026-11-06 23:04:15 +00:00
MSedgeMC 995a99b984 fix: a vindicator that was named Johnny stays Johnny
`Vindicator.setCustomName` latches a flag the first time the name it is given is
`Johnny`, and nothing ever clears it:

    public void setCustomName(@Nullable Component name) {
       super.setCustomName(name);
       if (!this.isJohnny && name != null && name.getString().equals("Johnny")) {
          this.isJohnny = true;
       }
    }

`VindicatorJohnnyAttackGoal` starts for `isJohnny` (`addAdditionalSaveData`
writes it, `readAdditionalSaveData` reads it back with `getBooleanOr("Johnny",
false)`), so a vindicator renamed from Johnny to Bob keeps attacking every
living entity, and one whose save says `Johnny: 1b` does so after a reload.

Horizon read the live custom name in the goal's `when` each tick and saved no
flag, so a renamed vindicator stopped attacking everything, and a reloaded
vindicator that had been named Johnny but is now Bob never started.

`extra.johnny` is the latch, taken from the live name in
`vindicator_server_ai_step` (the AI step is where a name set since the last step
is seen, and it never clears), read by the goal, written as `Johnny` and read
back from it. A save with no `Johnny` loads false, whatever the name in the
compound, as `getBooleanOr` does.
2026-11-06 23:04:14 +00:00
MSedgeMC 6a5fc04295 test: a re-saved section writes only the states a cell holds
Both cases read the emitted tag, so they fail on the live palette: 342 longs
of `data` where vanilla's `SimpleBitStorage(4, 4096)` is 256, a palette of
`[0, 1, … 16]` where first use is `[1, … 15, 0]`, and `(2, Some(256))` where a
section edited back to one state is `(1, None)`.
2026-11-06 22:49:30 +00:00
MSedgeMC 5dc59396d6 fix: save a chunk section's palette as vanilla packs it
`PalettedContainer.pack` re-encodes the cells into a fresh palette before a
section is written: a state no cell holds any more is dropped, the entries are
in first-use order, and the bit count is `getConfigurationForPaletteSize` of
the states that remain. `PalettedContainer::to_nbt` wrote the live palette
instead, which keeps the slot of every state a block edit replaced (the `free`
list needs it) and packs at that wider count: a section whose 17th state was
edited away saved 342 longs where vanilla writes 256, and a section edited back
to a single state saved a 2-entry palette with a 256-long `data` where vanilla
writes one entry and no `data`.
2026-11-06 22:47:00 +00:00
TheMrZZandCodex gpt-6.1-sol fec7a5f9e6 Respect class-owned container fields in vehicle saves
Keep plain vehicles free of container fields and save pending boat tables
instead of Items. Normalize recognized pending keys while preserving the
existing cart loot restoration path.

Co-Authored-By: Codex gpt-6.1-sol <[email protected]>
2026-11-06 20:28:32 +01:00
m_uvexandPluto 41d699a458 packaging: include native mod build dependencies in launcher FHS
Adds gcc, glibc.dev, pkg-config, alsa-lib.dev, and udev.dev to the FHS
environment so native mod compilation works on NixOS without external shell.

Co-Authored-By: Pluto <[email protected]>
2026-11-06 22:10:15 +03:00
m_uvexandPluto 160e997e4a packaging: add flake.nix for Horizon launcher and devShell
Provides a Nix flake packaging the Horizon launcher in an FHS environment
along with a development shell containing dependencies for building the project.

Co-Authored-By: Pluto <[email protected]>
2026-11-06 18:21:05 +03:00
MSedgeMC 4304cc44b5 Merge remote-tracking branch 'upstream/main' into HEAD 2026-11-06 13:39:30 +00:00
Horizon agentandClaude Opus 5.5 96c7d68d0d Unloading a chunk takes its lingering clouds with it
entity_chunks(remove = true) is the unload path: every other kind it
writes is also taken out of the level, and the potion clouds were not,
so a chunk loaded again got a second cloud on the same spot. The new
test unloads and reloads a cloud and expects one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 13:11:04 +01:00
Horizon agentandClaude Opus 5.5 5988321440 Jukebox: post jukebox_stop_play only while a song plays
JukeboxSongPlayer.stop posts the event inside `if (this.song != null)`:
taking a disc out (by hand or by a hopper) after its song ended is silent.
The test takes the finished disc out and expects only the end's event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 13:11:02 +01:00
Horizon agent 47dc19fa20 Merge main into #10283 2026-11-06 12:54:39 +01:00
Horizon agent 9141f1d538 Merge main into #10280 2026-11-06 12:54:33 +01:00
MSedgeMC a33e5b574a The ledger knows a cloud's save is ported
AreaEffectCloud.addAdditionalSaveData was listed missing, which was right: only
the reader existed. game/potions.rs::potion_cloud_to_nbt writes it now, from
entity_chunks.
2026-11-05 22:12:59 +00:00
MSedgeMC 78cf6e36a0 Test that a lingering cloud survives a save
A cloud with a poison and a slowness effect, one of them hidden and one ambient,
written with potion_cloud_to_nbt and read back with potion_cloud_from_nbt: the
position, age, duration, radius, the four use settings, the duration scale,
RadiusPerTick, the effect list and the colour all come back. The test also
checks that the compound carries the field names vanilla's
readAdditionalSaveData looks for, and that it is saved as
minecraft:area_effect_cloud.
2026-11-05 22:12:59 +00:00
MSedgeMC bd991e7917 A lingering potion's cloud survives a save
AreaEffectCloud.addAdditionalSaveData writes the cloud's age, duration, radius,
the four use settings, RadiusPerTick, potion_duration_scale and its
potion_contents, and the client already read every one of them back
(game/potions.rs::load_potion_cloud): a cloud that was loaded from a save came
back whole. Nothing ever wrote one, though. entity_chunks writes the dragon, the
crystals, the item frames, the fangs and the rest kind by kind, and the
lingering clouds -- which live in breath_clouds, not in entity_lists! -- were in
none of those, so every replacement pass dropped the cloud a thrown potion or a
creeper left behind.

The save side now writes them: game/potions.rs::potion_cloud_to_nbt builds the
compound on the entity fields entity_nbt::entity_base_tag gives it, and
entity_chunks adds one tag per potion-bearing cloud of the chunk. A dragon's own
breath carries no potion and is not written.

The reader moved out of the Game method into potion_cloud_from_nbt, so the pair
can be tested against itself. The client keeps no potion id, so the effects are
written as custom_effects with the colour the cloud was drawn in, and the custom
particle and owner reference the vanilla cloud also saves have no counterpart
here.
2026-11-05 22:12:58 +00:00
MSedgeMC 18f1a16d12 test: a jukebox that stops posts jukebox_stop_play
A windowless game with a jukebox at (0, 64, 0): a disc put in and popped back
out posts one G 0,64,0 minecraft:jukebox_stop_play, a song ticked to its end
posts one, a broken jukebox posts none from this path (the world's spill posts
it) and a jukebox that never held a disc posts nothing.
2026-11-05 22:04:17 +00:00
MSedgeMC c7fc74cb26 fix: a jukebox that stops playing tells the listeners
JukeboxSongPlayer.stop posts GameEvent.JUKEBOX_STOP_PLAY at the block (and level
event 1011), and both ways a song ends reach it: popOutTheItem, when the disc is
taken out or a hopper pulls it, and tick's own hasFinished branch.

Horizon posted that event only from the world's removal path, so a broken
jukebox was heard but a jukebox whose disc was pulled out by hand, or whose song
ran out, was silent to a sculk sensor beside it. The paths that keep the block
now go through stop_song_heard; jukebox_removed keeps the plain stop_song,
because the world's spill already posts the same event once for it.
2026-11-05 22:04:17 +00:00
894 changed files with 88741 additions and 8017 deletions

No files matched your search

+2 -2
View File
@@ -162,13 +162,13 @@ state stays separate from the library tests. This compiles gameplay twice for ex
| Player actions | game.rs (`fn use_hand`, `fn tick_mining`, `fn break_block`); G: `item_actions.rs` (`fn use_item`), `melee.rs` (`fn attack`), `hand.rs`, `combat.rs`, `consume.rs`, `using_item.rs` (an item in use, tick by tick), `potions.rs`, `shield.rs`, `crossbow.rs`, `trident.rs`, `fishing.rs`; L: `motion.rs` + `motion/` (movement), `collisions.rs`; crate `horizon-items`: `items.rs`, `item_data.rs`, `enchant.rs`, `blocks.rs` |
| Inventory and containers | L: `menu.rs` (`AbstractContainerMenu.clicked`), `container_screen.rs`, `containers.rs`, `creative.rs`, `crafting.rs`, `recipe_book*.rs`, `stations.rs`, `merchant.rs`; game.rs `fn menu_ops`, `fn click_inventory`; G: `stations.rs`, `trading.rs`, `recipe_book.rs`, `machines.rs`, `inventory_input.rs` (keys and clicks over a container), `inventory_slots.rs` (slot layout and drawing) |
| Commands | parse: crate `horizon-command` (`args.rs`, `selector.rs`, `tree_*.rs`, `vanilla.rs`); run: G: `commands.rs` (dispatch) + `commands/*.rs` (`admin`, `execute`, `items`, `players`, `world_cmds`...); L: `scoreboard_cmd.rs`, `data_cmd.rs`; `horizon-client-core`: `nbt_path.rs`, `scoreboard.rs`; G: `functions.rs`, `command_blocks.rs` |
| UI screens | `Screen` enum in game.rs; L: `title.rs` + `title/`, `options_ui.rs`, `multiplayer.rs`, `pack_screen.rs`, `graphics_ui.rs`, `screen_draw.rs`, `ui.rs` (widgets), `hud.rs`, `hud_layout.rs`, `hud_overlays.rs`, `chat.rs`, `tab_list.rs`; G: `startup_menu.rs`, `loading_screen.rs` (the loading screen, the pre-game `App`), `screens.rs` (pause, death), `options.rs`, `lan_screen.rs`, `chat.rs`, `sign_edit.rs`, `books.rs`, `creative_screen.rs` |
| UI screens | `Screen` enum in game.rs; L: `title.rs` + `title/`, `options_ui.rs`, `multiplayer.rs`, `pack_screen.rs`, `graphics_ui.rs`, `screen_draw.rs`, `ui.rs` (widgets), `hud.rs`, `hud_layout.rs`, `hud_overlays.rs`, `hud_kit/` (Horizon overlays' `Room` and `Plate`, [docs/ui-kit.md](docs/ui-kit.md)), `chat.rs`, `tab_list.rs`; G: `startup_menu.rs`, `loading_screen.rs` (the loading screen, the pre-game `App`), `screens.rs` (pause, death), `options.rs`, `lan_screen.rs`, `chat.rs`, `sign_edit.rs`, `books.rs`, `creative_screen.rs` |
| Multiplayer client | L: `net.rs` (network thread); G: `remote.rs` (`fn handle_packet`, `fn tick_remote`), `remote_*.rs` (mob data, objects, projectiles, vehicles, stations) |
| LAN host / server side | L: `lan/` (`conn.rs` handshake + login threads, `hub.rs` + `hub/` play state, `chunks.rs`, `entity.rs`, `tracking.rs`, `guest.rs`, `playerdata.rs`); G: `lan.rs` (`LanHost`), `lan_actions.rs` (`fn as_guest`, `fn tick_guests`), `lan_*.rs` per feature, `lan_entities.rs` (tracked entities) |
| Integrated server | G: `integrated.rs` (the server thread), `levels.rs` (one level per dimension, `fn tick_server`), `server_travel.rs` |
| Dedicated server | G: `dedicated.rs`, `dedicated/status.rs`; crates `horizon-server-files`, `horizon-server`, `horizon-anticheat` (L: `lan/anticheat.rs`) |
| Save and load | L: `save.rs` (level.dat, regions, playerdata), `entity_nbt.rs`, `options_file.rs`; `horizon-client-core/src/block_entity_nbt.rs`; G: `saving.rs`, `persist.rs` (entities), `world_session.rs` (opening and closing a world); `crates/horizon-world/src/{region.rs,nbt.rs,datafix/}` |
| Input | game.rs `fn window_event`; G: `play_keys.rs` (`fn key_pressed`), `play_input.rs` (`fn play_mouse`, toggled keys, the hotbar wheel); crate `horizon-client-input` (`keybinds.rs`, `keymapping.rs`, `key_names.rs`, `mouse.rs`, `input.rs`, `interaction_input.rs`, `gamepad.rs`, `clipboard.rs`); L: `osk.rs`; G: `pad.rs`, `pad_menu.rs`, `pointer_capture.rs` (mouse look, pointer grab) |
| Input | game.rs `fn window_event`; G: `play_keys.rs` (`fn key_pressed`), `play_input.rs` (`fn play_mouse`, toggled keys, the hotbar wheel); crate `horizon-client-input` (`keybinds.rs`, `keymapping.rs`, `key_names.rs`, `mouse.rs`, `input.rs`, `interaction_input.rs`, `gamepad.rs`, `clipboard.rs`); L: `osk.rs`; G: `pad.rs`, `pad_menu.rs`, `pad_craft.rs`, `pointer_capture.rs` (mouse look, pointer grab) |
| Audio | L: `audio.rs` (mixer), `sound_engine.rs`, `sound_events.rs`, `music.rs`, `ambience.rs`; G: `music.rs`, `subtitle_hud.rs` |
| Resource packs | L: `packs.rs` + `packs/`, `pack_screen.rs`, `atlas_sources.rs`, `sprites.rs`, `mipmap.rs`, `model_library.rs`, `font.rs`, `mobs/cem.rs` + `mobs/cem_anim.rs` (OptiFine/EMF entity models and their animations); `horizon-client-core/src/lang.rs`; crates `horizon-assets`, `horizon-optifine`; G: `packs.rs` |
| Agent control | L: `control.rs` (socket), `bin/horizon-ctl/`; G: `control.rs`, `agent.rs`, `events.rs`, `ui_control.rs` ([docs/agent-control.md](docs/agent-control.md)) |
Generated
+2
View File
@@ -1588,6 +1588,7 @@ dependencies = [
"horizon-mod-api-gen",
"horizon-narrator",
"horizon-optifine",
"horizon-polytone",
"horizon-protocol",
"horizon-shader-api",
"horizon-shaders",
@@ -1775,6 +1776,7 @@ dependencies = [
name = "horizon-polytone"
version = "0.1.0"
dependencies = [
"log",
"regex",
"serde_json",
]
+8
View File
@@ -309,3 +309,11 @@ Permission to use, copy, modify, and distribute this
software is freely granted, provided that this notice
is preserved.
```
## Starling
`crates/horizon-client-render/src/touch/layout.rs` is adapted from the touch layout of
[Starling](https://github.com/starling-client/starling), an Android port of Horizon, at commit
[150a414b09a1](https://github.com/starling-client/starling/tree/150a414b09a18c900489d9462a7fc035dae744b7)
(`android` branch), written mostly by Vasysik. Starling is licensed under the same MIT license as
Horizon (Copyright (c) 2026 Ludovic Marie and the Horizon contributors).
+41 -3
View File
@@ -412,10 +412,11 @@ pub fn to_text_with(
.collect()
})
.unwrap_or_default();
let translated = Text::translate(key, &args);
// TranslatableContents.decompose: Language.getOrDefault(key, fallback), so the
// fallback is the template itself, never looked up as another key.
match o.get("fallback").and_then(Value::as_str) {
Some(fallback) if translated.plain() == key => Text::translate(fallback, &args),
_ => translated,
Some(fallback) => Text::translate_with_fallback(key, fallback, &args),
None => Text::translate(key, &args),
}
} else if let Some(sel) = o.get("selector").and_then(Value::as_str) {
resolve(sel)
@@ -513,6 +514,43 @@ pub fn name_text(tag: &Tag) -> Text {
#[cfg(test)]
mod tests {
use super::*;
use crate::lang::{self, Language, ResourceSource};
struct Mem(std::collections::HashMap<String, Vec<u8>>);
impl ResourceSource for Mem {
fn read(&self, path: &str) -> Option<Vec<u8>> {
self.0.get(path).cloned()
}
}
/// TranslatableContents.decompose: Language.getOrDefault(key, fallback). A missing key
/// shows the fallback as written, even when the fallback is another key the language has.
#[test]
fn a_translatable_fallback_stays_literal() {
let pack = Mem([(
"assets/minecraft/lang/en_us.json".to_owned(),
br#"{"real.key": "Translated", "greet": "Hello %s"}"#.to_vec(),
)]
.into());
let ((), _) = lang::scoped(Language::load(&[&pack], "en_us"), || {
let parse = |v: Value| to_text(&v, &mut |_| Text::empty()).plain();
let missing = serde_json::json!({"translate": "missing.key", "fallback": "real.key"});
assert_eq!(parse(missing), "real.key");
// The fallback is a template: its arguments are filled in.
let args = serde_json::json!({"translate": "missing.key", "fallback": "Hi %s", "with": ["Steve"]});
assert_eq!(parse(args), "Hi Steve");
// A key the language has wins over its fallback.
let found =
serde_json::json!({"translate": "greet", "fallback": "real.key", "with": ["Alex"]});
assert_eq!(parse(found), "Hello Alex");
// A component built with the constructor keeps its meaning through its JSON.
let built = Text::translate_with_fallback("missing.key", "real.key", &[]);
let again = to_text(&built.component(), &mut |_| Text::empty());
assert_eq!(again.plain(), built.plain());
assert_eq!(again.component(), built.component());
});
}
/// SnbtGrammar: a compound or list may end with one comma; two in a row
/// stay an error.
#[test]
+18
View File
@@ -46,6 +46,21 @@ thread_local! {
}
/// The current language's `bidirectional`, read for every drawn string.
static BIDIRECTIONAL: AtomicBool = AtomicBool::new(false);
/// Counts the languages set (`set`): another count is another language, so text looked up
/// before it may read otherwise.
static GENERATION: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
thread_local! {
/// Counts the scopes this thread entered and left (`scoped`), which no other thread sees.
static SCOPE_GENERATION: std::cell::Cell<u64> = const { std::cell::Cell::new(0) };
}
/// Which language text looks up in now, on this thread, as a count that changes whenever that
/// can: both counts only grow, so their sum changes when either does.
pub fn generation() -> u64 {
GENERATION.load(Ordering::Relaxed) + SCOPE_GENERATION.get()
}
fn scope_changed() {
SCOPE_GENERATION.set(SCOPE_GENERATION.get() + 1);
}
/// A source of resource files: the prepared root plus packs, highest priority last.
pub trait ResourceSource {
@@ -524,6 +539,7 @@ pub fn available(sources: &[&dyn ResourceSource]) -> Vec<LanguageInfo> {
pub fn set(language: Language) {
BIDIRECTIONAL.store(language.bidirectional, Ordering::Relaxed);
*CURRENT.write().unwrap_or_else(|e| e.into_inner()) = Some(Arc::new(language));
GENERATION.fetch_add(1, Ordering::Relaxed);
}
pub fn current() -> Option<Arc<Language>> {
if let Some(language) = SCOPE.with(|s| s.borrow().as_ref().map(|s| s.language.clone())) {
@@ -543,6 +559,7 @@ pub fn scoped<R>(language: Language, f: impl FnOnce() -> R) -> (R, Vec<String>)
impl Drop for Restore {
fn drop(&mut self) {
SCOPE.with(|s| *s.borrow_mut() = self.0.take());
scope_changed();
}
}
let outer = SCOPE.with(|s| {
@@ -552,6 +569,7 @@ pub fn scoped<R>(language: Language, f: impl FnOnce() -> R) -> (R, Vec<String>)
})
});
let _restore = Restore(outer);
scope_changed();
let result = f();
let missed = SCOPE.with(|s| {
s.borrow_mut()
+1 -20
View File
@@ -1,6 +1,7 @@
//! NBT paths (`NbtPathArgument`): `foo.bar[0]`, `[]`, `list[{id:1}]`,
//! `{root:match}`, with get, set, insert and remove on a tag tree, and the
//! partial NBT comparison (`NbtUtils.compareNbt`) selectors and conditions use.
pub use horizon_world::nbt::compare_nbt;
use horizon_world::nbt::{Compound, JavaString, Tag, parse_snbt};
/// An error carrying the translation key and its arguments.
@@ -47,26 +48,6 @@ fn get_child<'a>(c: &'a Compound, name: &str) -> Option<&'a Tag> {
c.get(&key(name))
}
/// `NbtUtils.compareNbt(expected, actual, true)`.
pub fn compare_nbt(expected: &Tag, actual: Option<&Tag>) -> bool {
let Some(actual) = actual else { return false };
if std::mem::discriminant(expected) != std::mem::discriminant(actual) {
return false;
}
match (expected, actual) {
(Tag::Compound(e), Tag::Compound(a)) => {
a.len() >= e.len() && e.iter().all(|(k, v)| compare_nbt(v, a.get(k)))
}
(Tag::List(e), Tag::List(a)) => {
if e.is_empty() {
return a.is_empty();
}
a.len() >= e.len() && e.iter().all(|x| a.iter().any(|y| compare_nbt(x, Some(y))))
}
_ => expected == actual,
}
}
// ---- list-like tags ----------------------------------------------------------
/// The elements of a list or array tag.
@@ -89,6 +89,31 @@ pub struct Registries {
pub trigger_objectives: Vec<String>,
/// Objectives with the `trigger` criterion -> holder -> whether its score is locked.
pub trigger_scores: BTreeMap<String, BTreeMap<String, bool>>,
/// The `ConfiguredFeature` codec for an inline `minecraft:worldgen/feature`
/// value (`ResourceOrIdArgument`), where the source has the server's live
/// features; None leaves the decode to when the command runs.
pub inline_feature: Option<InlineFeatureCheck>,
}
/// A codec check of an inline value: its error message when it does not decode.
#[derive(Clone)]
pub struct InlineFeatureCheck(
std::sync::Arc<dyn Fn(&horizon_world::nbt::Tag) -> Result<(), String> + Send + Sync>,
);
impl InlineFeatureCheck {
pub fn new(
check: impl Fn(&horizon_world::nbt::Tag) -> Result<(), String> + Send + Sync + 'static,
) -> Self {
Self(std::sync::Arc::new(check))
}
pub fn check(&self, value: &horizon_world::nbt::Tag) -> Result<(), String> {
(self.0)(value)
}
}
impl std::fmt::Debug for InlineFeatureCheck {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("InlineFeatureCheck(..)")
}
}
/// The ids and tag ids of one registry.
#[derive(Clone, Debug, Default)]
+8 -1
View File
@@ -583,6 +583,10 @@ pub struct PadSettings {
/// The sneak button flips sneaking (Bedrock's default) instead of
/// holding it, unless vanilla's toggle crouch is on already.
pub toggle_sneak: bool,
/// LT + A on a recipe crafts on every server, not only in single player and on LAN worlds
/// found in the server list. Off by default: a server's rules may count a repeated craft as a
/// macro.
pub craft_on_servers: bool,
pub glyphs: GlyphStyle,
/// A Nintendo pad's face buttons go by their letters (A confirms and jumps, as on the
/// Switch's own menus and keyboard) instead of their places (B, at the bottom, does): on
@@ -614,6 +618,7 @@ impl Default for PadSettings {
look_deadzone: 0.12,
trigger_threshold: 0.4,
toggle_sneak: true,
craft_on_servers: false,
glyphs: GlyphStyle::Auto,
nintendo_letters: cfg!(target_os = "horizon"),
keyboard: TextKeyboard::Auto,
@@ -684,6 +689,7 @@ impl PadSettings {
s.trigger_threshold = unit(s.trigger_threshold).clamp(0.1, 0.9)
}
"toggleSneak" => s.toggle_sneak = flag(s.toggle_sneak),
"craftOnServers" => s.craft_on_servers = flag(s.craft_on_servers),
"glyphs" => s.glyphs = GlyphStyle::parse(value),
"nintendoLetters" => s.nintendo_letters = flag(s.nintendo_letters),
"keyboard" => s.keyboard = TextKeyboard::parse(value),
@@ -745,7 +751,8 @@ impl PadSettings {
self.keyboard.name(),
);
text.push_str(&format!(
"gameplayGuide:{}\npointerSpeed:{}\nscrollSpeed:{}\nrepeatDelay:{}\nrepeatInterval:{}\n",
"craftOnServers:{}\ngameplayGuide:{}\npointerSpeed:{}\nscrollSpeed:{}\nrepeatDelay:{}\nrepeatInterval:{}\n",
bool_text(self.craft_on_servers),
self.guide_detail.name(),
self.pointer_speed, self.scroll_speed, self.repeat_delay, self.repeat_interval,
));
+1
View File
@@ -23,6 +23,7 @@ horizon-narrator = { path = "../horizon-narrator" }
# OptiFine-format pack files: random entity textures (hud.rs), connected textures
# (connected.rs) and custom item texture rules (cit.rs).
horizon-optifine = { path = "../horizon-optifine" }
horizon-polytone = { path = "../horizon-polytone" }
horizon-protocol = { path = "../horizon-protocol" }
horizon-shader-api = { path = "../horizon-shader-api" }
horizon-shaders = { path = "../horizon-shaders" }
@@ -32,6 +32,11 @@ fn pack(properties: &str, shadow: Option<&str>, reads_shadow: bool) -> horizon_s
write("final.fsh", if reads_shadow { SHADOW_READ } else { COLOUR });
write("gbuffers_entities.vsh", VERTEX);
write("gbuffers_entities.fsh", COLOUR);
// Terrain programs keep the load free of "nothing draws it" notes; no terrain is drawn.
for terrain in ["gbuffers_terrain", "gbuffers_water"] {
write(&format!("{terrain}.vsh"), VERTEX);
write(&format!("{terrain}.fsh"), COLOUR);
}
if let Some(shadow) = shadow {
write("shadow.vsh", VERTEX);
write("shadow.fsh", shadow);
@@ -661,6 +661,7 @@ fn remesh(
blend_radius,
smooth_lighting,
cutout_leaves,
opaque_ice: false,
translucent_layers: &[],
leaf_culling,
};
@@ -50,10 +50,14 @@ fn pack(renderer: &mut Renderer, folder: &Path, valid: bool) {
std::fs::create_dir_all(&shaders).unwrap();
let vertex = "#version 120\nvarying vec2 uv; void main(){gl_Position=ftransform();uv=gl_MultiTexCoord0.xy;}\n";
let fragment = "#version 120\nuniform int entityId; uniform int blockEntityId; uniform vec4 entityColor; void main(){gl_FragData[0]=vec4(float(entityId)/255.0,entityColor.a,float(blockEntityId)/255.0,1.0);}\n";
// The terrain programs keep the load free of "nothing draws it" notes; this
// fixture draws no terrain.
for program in [
"gbuffers_entities",
"gbuffers_block",
"gbuffers_entities_translucent",
"gbuffers_terrain",
"gbuffers_water",
] {
std::fs::write(shaders.join(format!("{program}.vsh")), vertex).unwrap();
std::fs::write(
+263 -1
View File
@@ -47,6 +47,53 @@ struct Channel {
world: u32,
/// The sound file it started and when, to tell another player's copy of it.
started: Option<(String, std::time::Instant)>,
/// Its sound event plays clearly through a mod's muffle (`Audio::muffle`).
unmuffled: bool,
}
/// The cutoff of the muffle's low-pass at full strength: the world heard through ringing ears.
const MUFFLED_CUTOFF: f32 = 300.0;
/// The cutoff it sweeps down from as its strength rises.
const OPEN_CUTOFF: f32 = 20_000.0;
/// How long the muffle takes to glide to a new level: a game tick's step (50 ms) would click.
const MUFFLE_GLIDE: f32 = 0.02;
/// A mod's muffle (`Audio::muffle`) in the mixer: the other sounds are mixed apart, low-passed by
/// two one-pole stages and turned down, then added to the sounds it leaves clear. While it is off
/// (never set, or faded out) the sounds mix straight into the output, as without it.
#[derive(Default)]
struct Muffle {
/// `[amount, lowpass]`, each 0 to 1, as the game's tick last set them.
target: [f32; 2],
/// Where the output is now, gliding to `target`.
current: [f32; 2],
/// The low-pass stages' state for the left and right output channels.
stages: [[f32; 2]; 2],
/// The muffled sounds of one buffer, reused.
bus: Vec<f32>,
}
impl Muffle {
fn active(&self) -> bool {
self.target != [0.0; 2] || self.current.iter().any(|v| *v > 1e-4)
}
/// Adds `bus` (the muffled sounds) to `data`, low-passed and turned down.
fn apply(&mut self, bus: &[f32], data: &mut [f32], channels: usize, rate: u32) {
let rate = rate as f32;
let glide = 1.0 - (-1.0 / (MUFFLE_GLIDE * rate)).exp();
for (frame, muffled) in data.chunks_mut(channels).zip(bus.chunks(channels)) {
for (current, target) in self.current.iter_mut().zip(self.target) {
*current += (target - *current) * glide;
}
let [amount, lowpass] = self.current;
let gain = 1.0 - amount;
let cutoff = OPEN_CUTOFF * (MUFFLED_CUTOFF / OPEN_CUTOFF).powf(lowpass);
let a = 1.0 - (-std::f32::consts::TAU * cutoff / rate).exp();
for ((out, s), stage) in frame.iter_mut().zip(muffled).zip(&mut self.stages) {
stage[0] += (s - stage[0]) * a;
stage[1] += (stage[0] - stage[1]) * a;
// Dry at no strength, so a muffle that only turns sounds down leaves them as they were.
*out += (s + (stage[1] - s) * lowpass) * gain;
}
}
}
}
#[derive(Default)]
struct Mixer {
@@ -65,6 +112,8 @@ struct Mixer {
cameras: Vec<([f64; 3], Basis, u32)>,
/// Per-source gain/pan/step cache for one buffer, reused across callbacks.
voices: Vec<(ChannelId, [f32; 3], f64)>,
/// A mod's muffle of the sounds it does not exempt.
muffle: Muffle,
limiter_peak: f32,
/// The output device the stream was opened on (`Library.currentDeviceName`).
#[cfg(feature = "audio")]
@@ -100,6 +149,21 @@ pub struct Heard {
pub range: f32,
pub looping: bool,
}
/// A mod's muffle (`Audio::muffle`): its full strength, and the ticks it fades over and has left.
#[derive(Clone, Copy, Debug, PartialEq)]
struct MuffleFade {
amount: f32,
lowpass: f32,
ticks: u32,
left: u32,
}
impl MuffleFade {
/// `[amount, lowpass]` now: full when set, falling in a straight line to none.
fn level(&self) -> [f32; 2] {
let left = self.left as f32 / self.ticks as f32;
[self.amount * left, self.lowpass * left]
}
}
/// The mixer side of the engine (`Backend`).
pub struct MixerBackend {
mixer: Arc<Mutex<Mixer>>,
@@ -247,6 +311,8 @@ pub struct Audio {
pub stopped: std::collections::BTreeMap<String, u32>,
/// The volume sliders' `SoundPreviewHandler`.
preview: crate::sound_preview::SoundPreview,
/// A mod's muffle fading out (`muffle`), advanced by `tick`.
muffle: Option<MuffleFade>,
/// `SoundEngine.lastSeenDevices`: the system default output last seen.
#[cfg(feature = "audio")]
default_seen: Option<String>,
@@ -439,6 +505,7 @@ impl Backend for MixerBackend {
owner: self.owner,
world: self.world,
started: None,
unmuffled: false,
},
);
Some(id)
@@ -466,6 +533,9 @@ impl Backend for MixerBackend {
fn set_relative(&mut self, channel: ChannelId, relative: bool) {
self.with(channel, |c| c.relative = relative);
}
fn set_unmuffled(&mut self, channel: ChannelId, unmuffled: bool) {
self.with(channel, |c| c.unmuffled = unmuffled);
}
/// `getCompleteBuffer` (cached, else decoded on the decoder thread) or
/// `getStream` (decoded on a thread of its own), then attach and
/// `alSourcePlay`. A sound that cannot load leaves its source initial,
@@ -702,6 +772,13 @@ fn mix(mixer: &mut Mixer, data: &mut [f32], channels: usize, rate: u32) {
let step = f64::from(*source_rate) / f64::from(rate) * f64::from(c.pitch.max(0.0));
voices.push((*id, [left, right, gain], step));
}
// A mod's muffle: the sounds it doesn't exempt mix into a bus of their own first.
let muffling = mixer.muffle.active();
let mut bus = std::mem::take(&mut mixer.muffle.bus);
if muffling {
bus.clear();
bus.resize(data.len(), 0.0);
}
for (id, [left, right, gain], step) in voices.iter().copied() {
let Some(c) = mixer.channels.get_mut(&id) else {
continue;
@@ -711,7 +788,12 @@ fn mix(mixer: &mut Mixer, data: &mut [f32], channels: usize, rate: u32) {
};
let source_channels = source_channels as usize;
let frames = samples.len() / source_channels;
for frame in data.chunks_mut(channels) {
let out: &mut [f32] = if muffling && !c.unmuffled {
&mut bus
} else {
&mut *data
};
for frame in out.chunks_mut(channels) {
let mut i = c.position as usize;
if i + 1 >= frames {
if c.looping && frames > 1 {
@@ -746,6 +828,14 @@ fn mix(mixer: &mut Mixer, data: &mut [f32], channels: usize, rate: u32) {
}
}
mixer.voices = voices;
if muffling {
mixer.muffle.apply(&bus, data, channels, rate);
} else {
// Off: the next muffle starts from silence, not from the last one's filter.
mixer.muffle.current = [0.0; 2];
mixer.muffle.stages = [[0.0; 2]; 2];
}
mixer.muffle.bus = bus;
// Limit the whole buffer together, preserving waveform and stereo balance
// instead of flattening each overloaded sample; release over 200 ms
// (OpenAL Soft's output limiter, `ALC_OUTPUT_LIMITER_SOFT`, releases
@@ -1077,6 +1167,7 @@ impl Audio {
heard: Default::default(),
stopped: Default::default(),
preview: Default::default(),
muffle: None,
#[cfg(feature = "audio")]
default_seen: if live { default_output_name() } else { None },
#[cfg(feature = "audio")]
@@ -1238,6 +1329,7 @@ impl Audio {
heard: Default::default(),
stopped: Default::default(),
preview: Default::default(),
muffle: None,
// The device belongs to the first player's output, which looks after it.
#[cfg(feature = "audio")]
default_seen: self.default_seen.clone(),
@@ -1370,6 +1462,50 @@ impl Audio {
}
self.sync_volumes();
self.engine.tick(paused, ctx, &mut self.backend);
// A paused game holds a mod's muffle where it is, as it holds the sounds.
if !paused && let Some(fade) = &mut self.muffle {
fade.left = fade.left.saturating_sub(1);
let level = fade.level();
if fade.left == 0 {
self.muffle = None;
self.engine.set_unmuffled(Vec::new(), &mut self.backend);
}
self.set_muffle_level(level);
}
}
/// A mod's muffle (`native_muffle_sounds`): `amount` (0 to 1) of every sound's volume taken
/// away and `lowpass` (0 to 1) dulling it, from untouched to a 300 Hz low-pass, fading in a
/// straight line to none over `ticks` client ticks; the sound events in `exempt` (namespaced,
/// `mymod:ear.ringing`) play clearly through it, those already playing too. It replaces any
/// muffle in place; `ticks` 0 or no strength ends it. The output's, so in splitscreen every
/// player hears it. False for an amount or strength outside 0 to 1.
pub fn muffle(&mut self, amount: f32, lowpass: f32, ticks: u32, exempt: &[&str]) -> bool {
if !(0.0..=1.0).contains(&amount) || !(0.0..=1.0).contains(&lowpass) {
return false;
}
let on = ticks > 0 && (amount > 0.0 || lowpass > 0.0);
let exempt = if on {
exempt
.iter()
.map(|e| crate::sound_events::normalize(e))
.collect()
} else {
Vec::new()
};
self.engine.set_unmuffled(exempt, &mut self.backend);
self.muffle = on.then_some(MuffleFade {
amount,
lowpass,
ticks,
left: ticks,
});
self.set_muffle_level(self.muffle.map_or([0.0; 2], |fade| fade.level()));
true
}
fn set_muffle_level(&mut self, level: [f32; 2]) {
if let Ok(mut m) = self.backend.mixer.lock() {
m.muffle.target = level;
}
}
/// The `uiSoundReserve` extra: positional sounds leave
/// `sound_engine::HEARD_RESERVE` static channels free (off: vanilla's pool).
@@ -1468,6 +1604,14 @@ impl Audio {
let id = self.engine.add(instance, false);
self.engine.play_delayed(id, ticks);
}
/// `SoundManager.playDelayed` of an instance the caller made: it starts
/// `ticks` sound-engine ticks from now.
pub fn play_instance_after(&mut self, instance: SoundInstance, ticks: i32) {
*self.heard.entry(instance.identifier.clone()).or_default() += 1;
self.sync_volumes();
let id = self.engine.add(instance, false);
self.engine.play_delayed(id, ticks);
}
/// `play` for this client only: a sound a packet's handler plays
/// (`playLocalSound`), which the guests play from that packet themselves.
pub fn play_unshared(&mut self, event: &str, at: Option<[f64; 3]>, volume: f32, pitch: f32) {
@@ -1835,6 +1979,7 @@ mod tests {
owner: 0,
world: 0,
started: None,
unmuffled: false,
}
}
@@ -2255,6 +2400,123 @@ mod tests {
assert_eq!(data, [0.5; 2]);
}
/// One second of a `hz` sine at 48 kHz, amplitude 0.3 (looped, it repeats seamlessly).
fn sine(hz: f32) -> Vec<f32> {
(0..48_000)
.map(|i| 0.3 * (std::f32::consts::TAU * hz * i as f32 / 48_000.0).sin())
.collect()
}
fn rms(data: &[f32]) -> f32 {
(data.iter().map(|s| s * s).sum::<f32>() / data.len() as f32).sqrt()
}
/// `seconds` of the mixer's stereo output, in the 10 ms buffers an output stream asks for.
fn listen(m: &mut Mixer, seconds: f32) -> Vec<f32> {
let mut out = Vec::new();
let mut buffer = [0.0; 960];
for _ in 0..(seconds * 100.0).round() as usize {
mix(m, &mut buffer, 2, 48_000);
out.extend_from_slice(&buffer);
}
out
}
#[test]
fn a_muffle_dulls_and_quietens_every_sound_but_the_exempt_ones() {
// A looping tone heard through a muffle of `[amount, lowpass]`, once it has settled.
let heard = |hz: f32, muffle: [f32; 2], unmuffled: bool| {
let mut m = Mixer::default();
let mut c = channel(sine(hz), None, [0.0, 0.0, 2.0], true);
c.unmuffled = unmuffled;
m.channels.insert(1, c);
m.muffle.target = muffle;
listen(&mut m, 0.2);
listen(&mut m, 0.2)
};
let plain = |hz: f32| rms(&heard(hz, [0.0; 2], false));
// Fully low-passed, a 6 kHz whine all but goes and a 100 Hz hum keeps most of its level.
assert!(rms(&heard(6000.0, [0.0, 1.0], false)) < plain(6000.0) * 0.05);
assert!(rms(&heard(100.0, [0.0, 1.0], false)) > plain(100.0) * 0.8);
// Half the volume taken and no low-pass: half the level, the tone itself untouched.
let ducked = rms(&heard(6000.0, [0.5, 0.0], false)) / plain(6000.0);
assert!((ducked - 0.5).abs() < 1e-3, "{ducked}");
// An exempt sound plays through as if there were no muffle, sample for sample.
assert_eq!(
heard(6000.0, [0.5, 1.0], true),
heard(6000.0, [0.0; 2], false)
);
}
#[test]
fn a_faded_muffle_leaves_the_sound_as_it_was() {
let mixer = || {
let mut m = Mixer::default();
m.channels
.insert(1, channel(sine(3000.0), None, [2.0, 0.0, 1.0], true));
m
};
let (mut muffled, mut plain) = (mixer(), mixer());
muffled.muffle.target = [0.7, 1.0];
assert_ne!(listen(&mut muffled, 0.1), listen(&mut plain, 0.1));
muffled.muffle.target = [0.0; 2];
listen(&mut muffled, 0.5);
listen(&mut plain, 0.5);
assert_eq!(listen(&mut muffled, 0.1), listen(&mut plain, 0.1));
}
#[test]
fn a_mods_muffle_fades_with_the_game_ticks_and_spares_its_exempt_sounds() {
let mut audio = Audio::silent(Path::new("/nonexistent/horizon-test-assets"));
audio.engine.registry.add_file(
"minecraft",
br#"{"ambient.cave":{"sounds":["ambient/cave/cave1"]}}"#,
&|_, _| true,
);
audio.engine.registry.add_file(
"hztest",
br#"{"ear.ringing":{"sounds":["ear/ringing"]}}"#,
&|_, _| true,
);
// The engine makes its channels; with no output, none loads a file.
audio.engine.loaded = true;
let marks = |audio: &Audio| {
let m = audio.backend.mixer.lock().unwrap();
let mut marks: Vec<_> = m
.channels
.iter()
.map(|(&id, c)| (id, c.unmuffled))
.collect();
marks.sort();
marks
};
let level = |audio: &Audio| audio.backend.mixer.lock().unwrap().muffle.target;
let close =
|a: [f32; 2], b: [f32; 2]| (a[0] - b[0]).abs() < 1e-6 && (a[1] - b[1]).abs() < 1e-6;
// Two sounds already playing, and one exempt sound started under the muffle.
audio.play("ambient.cave", None, 1.0, 1.0);
audio.play("hztest:ear.ringing", None, 1.0, 1.0);
assert!(audio.muffle(0.8, 1.0, 4, &["hztest:ear.ringing"]));
audio.play("hztest:ear.ringing", None, 1.0, 1.0);
assert_eq!(marks(&audio), [(1, false), (2, true), (3, true)]);
assert!(close(level(&audio), [0.8, 1.0]));
let ticks = TickContext::default();
audio.tick(false, &ticks);
assert!(close(level(&audio), [0.6, 0.75]), "{:?}", level(&audio));
// A paused game holds it.
audio.tick(true, &ticks);
assert!(close(level(&audio), [0.6, 0.75]), "{:?}", level(&audio));
for _ in 0..3 {
audio.tick(false, &ticks);
}
assert_eq!(level(&audio), [0.0; 2]);
// Over: its exemptions go with it.
assert_eq!(marks(&audio), [(1, false), (2, false), (3, false)]);
// Out of range changes nothing.
assert!(!audio.muffle(1.5, 0.0, 10, &[]));
assert_eq!(level(&audio), [0.0; 2]);
}
#[test]
fn output_devices_are_looked_at_again_only_when_the_cards_change() {
// No fingerprint (not Linux, or the cards could not be read): the list
+6 -1
View File
@@ -191,13 +191,18 @@ pub fn discovery_url() -> String {
.unwrap_or_else(|| DEFAULT_DISCOVERY.to_owned())
}
fn agent() -> ureq::Agent {
pub(crate) fn agent() -> ureq::Agent {
ureq::AgentBuilder::new()
.timeout(Duration::from_secs(15))
.user_agent(&format!("Horizon/{}", horizon_core::release::VERSION))
.build()
}
/// Whether `HORIZON_API_DISCOVERY` names another services environment.
pub fn discovery_overridden() -> bool {
discovery_url() != DEFAULT_DISCOVERY
}
/// The discovery document, fetched once per game (a failure is retried next time).
pub(crate) fn discovery() -> Result<Arc<serde_json::Value>, JoinError> {
static CACHE: Mutex<Option<Arc<serde_json::Value>>> = Mutex::new(None);
@@ -0,0 +1,314 @@
//! GPU Culling's Auto mode: the setting switched by what limits the frame, measured here.
//!
//! GPU Culling moves the walk over the near sections and the listing of their draws from the
//! render thread to the GPU. That pays where the CPU is the slower of the two and costs where
//! the GPU is, and which a machine is can't be told from its parts: a fast CPU with a modest
//! GPU, a slow one with a strong GPU and every mix between depend on the scene, the render
//! distance and the resolution. So Auto watches the frames' own CPU and GPU times, and only
//! where the CPU is clearly the slower one it tries GPU Culling, measures the frame again, and
//! keeps it if the frame got faster. A trial that didn't help is undone and not repeated for
//! minutes of play, then for longer, then not until the next start, so a machine or a scene it
//! doesn't suit loses a few frames' time a few times, not every half minute.
//!
//! A verdict is the medians of a window of frames (`WINDOW`), which a few slow frames (a chunk
//! load, say) don't move. Nothing here reads the GPU or draws anything: the caller feeds it the
//! frames and applies what it answers.
/// Frames in one verdict.
pub const WINDOW: usize = 240;
/// The CPU's time must be this many times the GPU's for a window to count as CPU-bound.
const CPU_BOUND: f32 = 1.3;
/// Below this CPU time, in milliseconds, a frame is fast enough that neither matters.
const WORTH_TRYING_MS: f32 = 1.5;
/// A trial is kept when the frame's busier side dropped under this share of what it was.
const KEEP_BELOW: f32 = 0.97;
/// Windows of CPU-bound frames in a row before a trial.
const STREAK: u8 = 2;
/// Windows left out after a switch, while its effects settle.
const SETTLE: u8 = 1;
/// How long, in milliseconds of frames watched, after the first and the second trial that didn't
/// help before another; after a third there is none.
const RETRY_AFTER_MS: [f64; 2] = [5.0 * 60_000.0, 20.0 * 60_000.0];
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum State {
/// Off, looking for a CPU-bound frame.
Watching,
/// On for a trial: left out `SETTLE` windows, then measured against the frame before.
Trial,
/// The trial made the frame faster: on from here.
Kept,
}
/// What Auto has decided and why, a step at a time.
#[derive(Clone, Debug)]
pub struct GpuCullingAuto {
cpu: Vec<f32>,
gpu: Vec<f32>,
on: bool,
state: State,
/// CPU-bound windows in a row.
streak: u8,
/// The frame's busier side before the trial, in milliseconds.
before: f32,
/// Windows still left out after a switch.
settling: u8,
/// The frames watched so far, in milliseconds of their own time.
clock_ms: f64,
/// When the next trial may start, on that clock.
retry_at_ms: f64,
/// Trials that didn't help.
rejected: usize,
}
impl Default for GpuCullingAuto {
fn default() -> Self {
Self::new()
}
}
impl GpuCullingAuto {
pub fn new() -> Self {
Self {
cpu: Vec::with_capacity(WINDOW),
gpu: Vec::with_capacity(WINDOW),
on: false,
state: State::Watching,
streak: 0,
before: 0.0,
settling: 0,
clock_ms: 0.0,
retry_at_ms: 0.0,
rejected: 0,
}
}
/// Whether Auto has GPU Culling on now.
pub fn on(&self) -> bool {
self.on
}
/// Where Auto is, for the status: `watching`, `trial` or `kept`.
pub fn state(&self) -> &'static str {
match self.state {
State::Watching => "watching",
State::Trial => "trial",
State::Kept => "kept",
}
}
/// Back to the start: off, with nothing measured (the mode changed, or the world did).
pub fn reset(&mut self) {
*self = Self::new();
}
/// One frame's CPU time, a GPU time where its timestamps have arrived, and its whole time,
/// in milliseconds. Answers the new state when this frame completed a window that changed it.
pub fn observe(&mut self, cpu_ms: f32, gpu_ms: Option<f32>, frame_ms: f32) -> Option<bool> {
self.clock_ms += f64::from(frame_ms);
self.cpu.push(cpu_ms);
if let Some(gpu) = gpu_ms {
self.gpu.push(gpu);
}
if self.cpu.len() < WINDOW {
return None;
}
let cpu = median(&mut self.cpu);
// A GPU that can't be timed leaves nothing to compare with: Auto stays as it is.
let gpu = (self.gpu.len() >= WINDOW / 4).then(|| median(&mut self.gpu));
self.cpu.clear();
self.gpu.clear();
self.verdict(cpu, gpu?)
}
fn verdict(&mut self, cpu: f32, gpu: f32) -> Option<bool> {
if self.settling > 0 {
self.settling -= 1;
return None;
}
match self.state {
State::Kept => None,
State::Watching => {
if self.clock_ms < self.retry_at_ms {
return None;
}
let bound = cpu >= WORTH_TRYING_MS && cpu > gpu * CPU_BOUND;
self.streak = if bound { self.streak + 1 } else { 0 };
if self.streak < STREAK {
return None;
}
self.streak = 0;
self.before = cpu.max(gpu);
self.state = State::Trial;
self.settling = SETTLE;
self.on = true;
Some(true)
}
State::Trial => {
if cpu.max(gpu) < self.before * KEEP_BELOW {
self.state = State::Kept;
return None;
}
self.state = State::Watching;
self.retry_at_ms = RETRY_AFTER_MS
.get(self.rejected)
.map_or(f64::INFINITY, |wait| self.clock_ms + wait);
self.rejected += 1;
self.on = false;
Some(false)
}
}
}
}
fn median(values: &mut [f32]) -> f32 {
values.sort_by(f32::total_cmp);
values[values.len() / 2]
}
#[cfg(test)]
mod tests {
use super::*;
/// A window of frames at constant times, each as long as its busier side; the last answer.
fn window(auto: &mut GpuCullingAuto, cpu: f32, gpu: f32) -> Option<bool> {
(0..WINDOW)
.filter_map(|_| auto.observe(cpu, Some(gpu), cpu.max(gpu)))
.last()
}
/// A machine whose CPU limits the frame is tried, and keeps GPU Culling when the frame
/// gets faster.
#[test]
fn a_cpu_bound_frame_tries_it_and_keeps_it_when_it_helps() {
let mut auto = GpuCullingAuto::new();
assert!(!auto.on());
// One CPU-bound window is not yet a verdict.
assert_eq!(window(&mut auto, 5.0, 2.0), None);
assert_eq!(window(&mut auto, 5.0, 2.0), Some(true));
assert!(auto.on());
assert_eq!(auto.state(), "trial");
// The window after the switch is left out, whatever it shows.
assert_eq!(window(&mut auto, 9.0, 9.0), None);
// The frame's busier side went from 5.0 to 3.0 ms.
assert_eq!(window(&mut auto, 3.0, 2.6), None);
assert_eq!(auto.state(), "kept");
assert!(auto.on());
// Kept stays kept, even if a later scene is GPU-bound.
assert_eq!(window(&mut auto, 1.0, 8.0), None);
assert!(auto.on());
}
/// Where it didn't help, it is undone, and not tried again for 5 minutes, then 20, then
/// not at all: a scene it doesn't suit is not tried every half minute.
#[test]
fn a_trial_that_does_not_help_is_undone_and_waits_longer_each_time() {
let mut auto = GpuCullingAuto::new();
// One window is 240 frames of 5 ms: 1.2 s. A trial, and its rejection:
let reject = |auto: &mut GpuCullingAuto| {
window(auto, 5.0, 2.0);
assert_eq!(window(auto, 5.0, 2.0), Some(true));
window(auto, 5.0, 2.0);
// The GPU took over the frame: 5.0 ms before, 5.4 after.
assert_eq!(window(auto, 2.5, 5.4), Some(false));
assert!(!auto.on());
assert_eq!(auto.state(), "watching");
};
reject(&mut auto);
// CPU-bound as ever, and left alone for 5 minutes of frames: 250 windows.
let mut waited = 0;
while window(&mut auto, 5.0, 2.0).is_none() {
waited += 1;
}
assert!((248..=252).contains(&waited), "{waited}");
// That window started the second trial; it is rejected too.
window(&mut auto, 5.0, 2.0);
assert_eq!(window(&mut auto, 2.5, 5.4), Some(false));
// Now 20 minutes: 1000 windows.
let mut waited = 0;
while window(&mut auto, 5.0, 2.0).is_none() {
waited += 1;
}
assert!((998..=1002).contains(&waited), "{waited}");
window(&mut auto, 5.0, 2.0);
assert_eq!(window(&mut auto, 2.5, 5.4), Some(false));
// A third rejection is for good.
for _ in 0..5000 {
assert_eq!(window(&mut auto, 5.0, 2.0), None);
}
assert!(!auto.on());
}
/// A GPU-bound machine is never switched: its frame is the GPU's.
#[test]
fn a_gpu_bound_frame_is_left_alone() {
let mut auto = GpuCullingAuto::new();
for _ in 0..20 {
assert_eq!(window(&mut auto, 0.5, 3.6), None);
}
assert!(!auto.on());
}
/// Within the margin neither side limits the frame, and a single CPU-bound window among
/// others breaks no streak into a trial.
#[test]
fn neither_a_balanced_nor_an_occasional_cpu_bound_frame_is_tried() {
let mut auto = GpuCullingAuto::new();
for _ in 0..10 {
assert_eq!(window(&mut auto, 3.0, 2.6), None);
}
for _ in 0..10 {
assert_eq!(window(&mut auto, 5.0, 2.0), None);
assert_eq!(window(&mut auto, 2.0, 2.0), None);
}
assert!(!auto.on());
}
/// Fast frames aren't worth a trial, bound or not.
#[test]
fn a_frame_under_the_floor_is_not_tried() {
let mut auto = GpuCullingAuto::new();
for _ in 0..10 {
assert_eq!(window(&mut auto, 1.2, 0.2), None);
}
assert!(!auto.on());
}
/// Without GPU times (a GPU that can't be timed) there is nothing to compare.
#[test]
fn frames_without_gpu_times_decide_nothing() {
let mut auto = GpuCullingAuto::new();
for _ in 0..WINDOW * 10 {
assert_eq!(auto.observe(8.0, None, 8.0), None);
}
assert!(!auto.on());
}
/// A spike in a window doesn't move its verdict: the median ignores it.
#[test]
fn a_few_slow_frames_do_not_make_a_window_cpu_bound() {
let mut auto = GpuCullingAuto::new();
for _ in 0..4 {
let mut answer = None;
for i in 0..WINDOW {
// One frame in ten is a 30 ms chunk load, the rest are GPU-bound.
let cpu = if i % 10 == 0 { 30.0 } else { 0.8 };
answer = answer.or(auto.observe(cpu, Some(3.0), 3.0));
}
assert_eq!(answer, None);
}
assert!(!auto.on());
}
#[test]
fn reset_starts_over() {
let mut auto = GpuCullingAuto::new();
window(&mut auto, 5.0, 2.0);
window(&mut auto, 5.0, 2.0);
assert!(auto.on());
auto.reset();
assert!(!auto.on());
assert_eq!(auto.state(), "watching");
assert_eq!(window(&mut auto, 5.0, 2.0), None);
}
}
+36 -2
View File
@@ -17,11 +17,15 @@ pub struct BanDetails {
pub reason_message: Option<String>,
}
/// authlib's `UserProperties`, as far as the title screen reads it.
/// authlib's `UserProperties`, as far as the title screen and the friends service read it.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UserProperties {
/// `UserFlag.SERVERS_ALLOWED` (`privileges.multiplayerServer.enabled`).
pub servers_allowed: bool,
/// `UserFlag.FRIENDS_ENABLED` (`friendsPreferences.friends`).
pub friends_enabled: bool,
/// `UserFlag.ACCEPT_FRIEND_INVITES` (`friendsPreferences.acceptInvites`).
pub accept_friend_invites: bool,
/// `bannedScopes.get("MULTIPLAYER")`.
pub multiplayer_ban: Option<BanDetails>,
}
@@ -30,6 +34,8 @@ impl Default for UserProperties {
fn default() -> Self {
Self {
servers_allowed: true,
friends_enabled: false,
accept_friend_invites: false,
multiplayer_ban: None,
}
}
@@ -209,6 +215,13 @@ pub fn parse_properties(body: &str) -> Option<UserProperties> {
.pointer("/privileges/multiplayerServer/enabled")
.and_then(|e| e.as_bool())
.unwrap_or(false);
let toggle = |name: &str| {
v.pointer(&format!("/friendsPreferences/{name}"))
.and_then(|f| f.as_str())
.is_some_and(|f| f.eq_ignore_ascii_case("ENABLED"))
};
let friends_enabled = toggle("friends");
let accept_friend_invites = toggle("acceptInvites");
let multiplayer_ban = v
.pointer("/banStatus/bannedScopes/MULTIPLAYER")
.filter(|b| b.is_object())
@@ -222,6 +235,8 @@ pub fn parse_properties(body: &str) -> Option<UserProperties> {
});
Some(UserProperties {
servers_allowed,
friends_enabled,
accept_friend_invites,
multiplayer_ban,
})
}
@@ -275,6 +290,24 @@ mod tests {
assert!(clean.servers_allowed && clean.multiplayer_ban.is_none());
}
#[test]
fn friends_preferences_read_their_two_flags() {
let body = r#"{"privileges":{"multiplayerServer":{"enabled":true}},
"friendsPreferences":{"friends":"ENABLED","acceptInvites":"DISABLED"}}"#;
let p = parse_properties(body).unwrap();
assert!(p.friends_enabled);
assert!(!p.accept_friend_invites);
let other = parse_properties(
r#"{"friendsPreferences":{"friends":"DISABLED","acceptInvites":"ENABLED"}}"#,
)
.unwrap();
assert!(!other.friends_enabled);
assert!(other.accept_friend_invites);
// The offline fallback has neither flag, as `OFFLINE_PROPERTIES` does.
assert!(!UserProperties::default().friends_enabled);
assert!(!UserProperties::default().accept_friend_invites);
}
#[test]
fn parses_profile_actions() {
let a = parse_profile_actions(
@@ -297,6 +330,7 @@ mod tests {
properties: UserProperties {
servers_allowed: true,
multiplayer_ban: Some(ban.clone()),
..Default::default()
},
actions: ProfileActions {
forced_name_change: true,
@@ -317,7 +351,7 @@ mod tests {
let no_servers = AccountStatus {
properties: UserProperties {
servers_allowed: false,
multiplayer_ban: None,
..Default::default()
},
..Default::default()
};
+59 -1
View File
@@ -1,6 +1,7 @@
//! Biome colours from the pinned biome definitions and colormaps
//! (`Biome.getGrassColor`/`getFoliageColor`/..., `BlockTintSources`).
use crate::Result;
use horizon_client_core::particle_type::ParticleType;
use horizon_core::{noise::SimplexNoise, position::BlockPos, random::LegacyRandom};
use serde_json::Value;
use std::{
@@ -106,11 +107,31 @@ pub struct BiomeInfo {
/// The biome's own fog colour attribute; otherwise the dimension's applies.
pub fog: Option<u32>,
pub water_fog: u32,
/// `minecraft:visual/ambient_particles` entries and their probabilities.
pub ambient_particles: Vec<(ParticleType, f32)>,
/// `BiomeGenerationSettings.features`: the placed feature ids of each
/// `GenerationStep.Decoration` step, in order.
pub features: Vec<Vec<String>>,
/// The biome's environment attributes (`Biome.getAttributes`): its layer in the
/// environment attribute stack.
pub attributes: horizon_world::environment_attributes::AttributeMap,
}
impl BiomeInfo {
fn ambient_particles(v: &Value) -> Vec<(ParticleType, f32)> {
let list = &v["attributes"]["minecraft:visual/ambient_particles"];
let entries = list["argument"].as_array().or_else(|| list.as_array());
entries
.into_iter()
.flatten()
.filter_map(|entry| {
Some((
ParticleType::from_name(entry["particle"]["type"].as_str()?)?,
entry["probability"].as_f64().unwrap_or(0.0) as f32,
))
})
.collect()
}
/// `Biome.getHeightAdjustedTemperature`: the frozen modifier, then cooler
/// with height above `sea_level + 17`.
pub fn temperature_at(&self, pos: BlockPos, sea_level: i32) -> f32 {
@@ -245,6 +266,7 @@ impl BiomeInfo {
sky: color(&attributes["minecraft:visual/sky_color"]),
fog: color(&attributes["minecraft:visual/fog_color"]),
water_fog: color(&attributes["minecraft:visual/water_fog_color"]).unwrap_or(0x050533),
ambient_particles: Self::ambient_particles(v),
features: v["features"]
.as_array()
.into_iter()
@@ -258,6 +280,11 @@ impl BiomeInfo {
.collect()
})
.collect(),
attributes: horizon_world::environment_attributes::AttributeMap::parse(attributes)
.unwrap_or_else(|e| {
log::warn!("biome attributes: {e}");
Default::default()
}),
name,
}
}
@@ -374,6 +401,17 @@ impl Biomes {
pub fn get(&self, id: u16) -> &BiomeInfo {
&self.list[usize::from(id).min(self.list.len() - 1)]
}
/// The name of biome `id`, plains (as for an unknown name) when the id is
/// past this table: a column a server sent under its earlier, longer
/// registry (a proxy's previous server) keeps its ids until the next
/// login replaces it. `get` clamps such an id to the last entry instead,
/// so for that stale column the colours and this name can come from
/// different biomes until the login.
pub fn name(&self, id: u16) -> &str {
self.list
.get(usize::from(id))
.map_or("minecraft:plains", |b| b.name.as_str())
}
pub fn grass(&self, id: u16, x: f64, z: f64) -> u32 {
let b = self.get(id);
match b.modifier {
@@ -563,7 +601,9 @@ mod pack_tests {
#[test]
fn packs_replace_in_place_and_add_after_the_builtin_biomes() {
let base = builtin(&["minecraft:meadow", "minecraft:plains", "minecraft:river"]);
let red = json!({"temperature": 2.0, "effects": {"water_color": "#ff0000"}});
let red = json!({"temperature": 2.0, "effects": {"water_color": "#ff0000"},
"attributes": {"minecraft:visual/ambient_particles": {
"argument": [{"particle": {"type": "minecraft:ash"}, "probability": 0.25}]}}});
let hot = json!({"effects": {"grass_color": 0x123456}});
let files = [
("pack:zeta", &hot),
@@ -576,6 +616,9 @@ mod pack_tests {
assert_eq!(world.id("minecraft:river"), 2);
assert_eq!(world.get(2).water, 0xFF0000);
assert_eq!(world.get(2).temperature, 2.0);
assert_eq!(world.get(2).ambient_particles.len(), 1);
assert_eq!(world.get(2).ambient_particles[0].0.name(), "ash");
assert_eq!(world.get(2).ambient_particles[0].1, 0.25);
// New biomes follow, in registry order.
assert_eq!(world.id("minecraft:molten_peaks"), 3);
assert_eq!(world.id("pack:zeta"), 4);
@@ -600,6 +643,21 @@ mod pack_tests {
assert_eq!(other.get(2).water, 0x3F76E4);
assert!(!other.has_packs());
}
/// A column keeps the ids of the table it was decoded with. When a
/// proxy's next server lacks a biome the last one added, that id is past
/// the next table, and it names plains instead of indexing past the end
/// (#12148: "the len is 67 but the index is 67").
#[test]
fn an_id_past_the_table_names_plains() {
let next = builtin(&["minecraft:meadow", "minecraft:plains", "minecraft:river"]);
let last = next.with_packs([("limbo:void", &json!({}))]);
let stale = last.id("limbo:void");
assert_eq!((stale, last.name(stale)), (3, "limbo:void"));
assert_eq!(next.name(stale), "minecraft:plains");
assert_eq!(next.name(u16::MAX), "minecraft:plains");
assert_eq!(next.name(2), "minecraft:river");
}
}
#[cfg(test)]
@@ -12,12 +12,13 @@ use crate::{
block_entity_anim::{self, EnchantingBook},
breaking::entity_geometry,
fast_hash::FxHashMap,
font::Glyph,
font::{Font, Glyph},
gfx::mark_oit,
hud::Rect,
mesher::{CULL_BACK, Vertex},
models::load_visibility,
signs::{self, SignData, SignText},
text::{Style, Text},
world::World,
};
use glam::{DVec3, Mat4, Quat, Vec3};
@@ -620,30 +621,26 @@ fn frac(x: f32) -> f32 {
x - x.floor()
}
/// `StringSplitter.splitLines(...).get(0)` for plain text: the first line,
/// wrapped at the last space that fits or mid-word when none does.
fn first_line(line: &str, max_width: f32, advance: &dyn Fn(char) -> f32) -> String {
/// `StringSplitter.findLineBreak`: first line, with styled advances.
fn first_line(line: &Text, max_width: f32, advance: &dyn Fn(char, &Style) -> f32) -> Text {
let mut width = 0.0;
let mut visible = false;
let mut last_space = None;
for (i, c) in line.char_indices() {
for (i, (c, style)) in line.chars().enumerate() {
if c == '\n' {
return line[..i].to_owned();
return line.slice(0, i);
}
if c == ' ' {
last_space = Some(i);
}
width += advance(c);
if width > max_width {
let end = match last_space {
Some(s) if s > 0 => s,
_ if i > 0 => i,
// The first char alone is too wide: take that one char.
_ => c.len_utf8(),
};
return line[..end].to_owned();
let step = advance(c, style);
width += step;
if visible && width > max_width.max(1.0) {
return line.slice(0, last_space.unwrap_or(i));
}
visible |= step != 0.0;
}
line.to_owned()
line.clone()
}
/// `AbstractSignRenderer.isOutlineVisible`: the camera within 16 blocks of
@@ -661,7 +658,7 @@ fn sign_text_near(pos: [i32; 3], camera: DVec3) -> bool {
/// `AbstractSignRenderer.submitSignText`: four centred lines, glowing text
/// full-bright with an 8x outline in the dark colour. The font colours each
/// glyph by its style (`Font.StringRenderOutput`): a line's own colour wins,
/// else the sign's. A line is one call per run of one colour.
/// else the sign's. Keep style boundaries for glyphs and decoration effects.
fn sign_text_calls(
scene: &Scene,
data: &SignData,
@@ -684,17 +681,32 @@ fn sign_text_calls(
} else {
(dark, 0, vertex_light(packed), 0)
};
let advance = |c: char| (scene.glyph)(c).advance;
let advance = |c: char, style: &Style| {
let g = scene
.font
.map_or_else(|| (scene.glyph)(c), |f| f.glyph_styled(c, style));
g.advance + if style.is_bold() { g.offset } else { 0.0 }
};
let mut calls: Vec<TextCall> = Vec::with_capacity(text.lines.len());
for i in 0..text.lines.len() {
// The line that fits, in the order it is drawn (getVisualOrder).
let line = text.line_text(i);
let line = line.resolved();
let flat: String = line.chars().map(|(c, _)| c).collect();
let fits = first_line(&flat, data.max_line_width(), &advance);
let shown = line.slice(0, fits.chars().count());
let shown = if let Some(font) = scene.font {
font.split_formatted(&line, data.max_line_width())
.into_iter()
.next()
.unwrap_or_default()
.resolved()
.into_owned()
} else {
first_line(&line.resolved(), data.max_line_width(), &advance)
};
let shown = visual(&shown);
let width = shown.chars().map(|(c, _)| advance(c)).sum::<f32>().ceil();
let width = shown
.chars()
.map(|(c, s)| advance(c, s))
.sum::<f32>()
.ceil();
let x = -((width as i32) / 2) as f32;
let y = i as f32 * line_height - midpoint;
let first = calls.len();
@@ -704,20 +716,22 @@ fn sign_text_calls(
.style
.color
.map_or(color, |rgb| 0xFF00_0000 | (rgb & 0xFF_FFFF));
match calls[first..].last_mut() {
Some(last) if last.color == run => last.text.push_str(&span.text),
_ => calls.push(TextCall {
matrix: m,
x: x + pen,
y,
text: span.text.clone(),
color: run,
outline,
light,
tier,
}),
}
pen += span.text.chars().map(advance).sum::<f32>();
calls.push(TextCall {
matrix: m,
x: x + pen,
y,
text: span.text.clone(),
style: span.style.clone(),
color: run,
outline,
light,
tier,
});
pen += span
.text
.chars()
.map(|c| advance(c, &span.style))
.sum::<f32>();
}
if calls.len() == first {
// A line with no text is still a call, of no glyphs.
@@ -726,6 +740,7 @@ fn sign_text_calls(
x,
y,
text: String::new(),
style: Style::default(),
color,
outline,
light,
@@ -736,6 +751,17 @@ fn sign_text_calls(
calls
}
fn sign_text_animated(data: &SignData) -> bool {
[&data.front, &data.back].into_iter().any(|side| {
(0..side.lines.len()).any(|i| {
side.line_text(i)
.resolved()
.chars()
.any(|(c, s)| c != ' ' && s.obfuscated == Some(true))
})
})
}
/// How far the text of an outlined call sits in front of its outline, in
/// text units (`Font.DisplayMode.POLYGON_OFFSET`, see `draw_text`).
const TEXT_OVER_OUTLINE: f32 = 0.05;
@@ -749,72 +775,131 @@ const TEXT_OVER_OUTLINE: f32 = 0.05;
/// reader instead (a twentieth of a font pixel, invisible) rather than
/// z-fighting with the outline under it.
fn draw_text(scene: &Scene, call: &TextCall, out: &mut Vec<Vertex>) {
text_vertices(scene.glyph, call, out);
let glyph = |c| {
let Some(font) = scene.font else {
return (scene.glyph)(c);
};
let g = font.glyph_styled(c, &call.style);
if call.style.obfuscated == Some(true) && c != ' ' {
font.random_glyph(&call.style, g.advance)
} else {
g
}
};
text_vertices(&glyph, scene.font.map(Font::white), call, out);
}
/// `draw_text` with the font's glyph cells and advances from `glyph`: the
/// `BakedSheetGlyph.renderChar` / `Font.PreparedTextBuilder.accept`: the
/// text of `call` as glyph quads in its matrix's plane, 1 unit a font pixel,
/// y down as the font's, with its outline when it has one. A native mod's
/// block entity draws its text this way (`native_draw_text`).
pub fn text_vertices(glyph: &dyn Fn(char) -> Glyph, call: &TextCall, out: &mut Vec<Vertex>) {
let mut emit = |dx: f32, dy: f32, z: f32, argb: u32| {
let mut x = call.x + dx;
let y0 = call.y + dy;
for ch in call.text.chars() {
pub fn text_vertices(
glyph: &dyn Fn(char) -> Glyph,
white: Option<Rect>,
call: &TextCall,
out: &mut Vec<Vertex>,
) {
let bold = call.style.is_bold();
let mut quad = |corners: [(f32, f32); 4], cell: Rect, z: f32, argb: u32| {
let uvs = [
[cell.u0, cell.v1],
[cell.u1, cell.v1],
[cell.u1, cell.v0],
[cell.u0, cell.v0],
];
let color = 0xFF00_0000 | (argb & 255) << 16 | (argb >> 8 & 255) << 8 | (argb >> 16 & 255);
for ((x, y), uv) in corners.into_iter().zip(uvs) {
out.push(Vertex {
normal: [0; 4],
pos: call.matrix.transform_point3(Vec3::new(x, y, z)).to_array(),
uv,
layer: u32::from(call.tier) << 16,
color,
light: call.light,
glint_uv: [0.0; 2],
});
}
};
let mut emit = |dx: f32, dy: f32, z: f32, argb: u32, outline: bool| {
let mut pen = call.x;
for (i, ch) in call.text.chars().enumerate() {
let g = glyph(ch);
let x = pen + dx * g.offset;
let y = call.y + dy * g.offset;
let advance = g.advance + if bold { g.offset } else { 0.0 };
if let Some(cell) = g.rect {
// BakedSheetGlyph: the glyph's own box from the pen, not a
// fixed 8x8 cell (a Unifont glyph is 0.5 units per texel).
let (x0, x1) = (x + g.left, x + g.right);
let (top, bottom) = (y0 + g.top, y0 + g.bottom);
let corners = [(x0, bottom), (x1, bottom), (x1, top), (x0, top)];
let uvs = [
[cell.u0, cell.v1],
[cell.u1, cell.v1],
[cell.u1, cell.v0],
[cell.u0, cell.v0],
];
let c =
0xFF00_0000 | (argb & 255) << 16 | (argb >> 8 & 255) << 8 | (argb >> 16 & 255);
for ((cx, cy), uv) in corners.into_iter().zip(uvs) {
out.push(Vertex {
normal: [0; 4],
pos: call
.matrix
.transform_point3(Vec3::new(cx, cy, z))
.to_array(),
uv,
layer: u32::from(call.tier) << 16,
color: c,
light: call.light,
glint_uv: [0.0, 0.0],
});
let thick = if bold { 0.1 } else { 0.0 };
let shear = |v| {
if call.style.is_italic() {
1.0 - 0.25 * v
} else {
0.0
}
};
for copy in 0..=usize::from(bold) {
let x0 = x + copy as f32 * g.offset + g.left - thick;
let x1 = x + copy as f32 * g.offset + g.right + thick;
let top = y + g.top - thick;
let bottom = y + g.bottom + thick;
quad(
[
(x0 + shear(g.bottom), bottom),
(x1 + shear(g.bottom), bottom),
(x1 + shear(g.top), top),
(x0 + shear(g.top), top),
],
cell,
z + copy as f32 * 0.001,
argb,
);
}
}
x += g.advance;
// `Font.prepare8xTextOutline` discards effects: only the front
// text gets underline/strikethrough, including over spaces.
if !outline && let Some(white) = white {
let x0 = if i == 0 { x - 1.0 } else { x };
for (enabled, top) in [
(call.style.strikethrough, 3.5),
(call.style.underlined, 8.0),
] {
if enabled == Some(true) {
quad(
[
(x0, y + top + 1.0),
(x + advance, y + top + 1.0),
(x + advance, y + top),
(x0, y + top),
],
white,
z + 0.01,
argb,
);
}
}
}
pen += advance;
}
};
if call.outline != 0 {
for (dx, dy) in [
(-1.0, -1.0),
(0.0, -1.0),
(1.0, -1.0),
(-1.0, 0.0),
(1.0, 0.0),
(-1.0, 1.0),
(0.0, 1.0),
(1.0, 1.0),
] {
emit(dx, dy, 0.0, call.outline);
for dx in -1..=1 {
for dy in -1..=1 {
if dx != 0 || dy != 0 {
emit(dx as f32, dy as f32, 0.0, call.outline, true);
}
}
}
}
let z = if call.outline != 0 {
TEXT_OVER_OUTLINE
} else {
0.0
};
emit(0.0, 0.0, z, call.color);
emit(
0.0,
0.0,
if call.outline != 0 {
TEXT_OVER_OUTLINE
} else {
0.0
},
call.color,
false,
);
}
/// Block-entity fields the level ticks, at one position (vanilla's own field
@@ -847,6 +932,7 @@ pub struct TextCall {
pub x: f32,
pub y: f32,
pub text: String,
pub style: Style,
/// ARGB.
pub color: u32,
/// ARGB outline colour, 0 for none.
@@ -894,6 +980,8 @@ pub struct Scene<'a> {
pub skull: &'a dyn Fn([i32; 3]) -> Option<String>,
/// Font glyph: atlas cell (none for blank glyphs such as the space), box and advance.
pub glyph: &'a dyn Fn(char) -> Glyph,
/// Font providers, effects and random glyphs for styled sign text.
pub font: Option<&'a Font>,
/// Changes whenever `glyph` may answer differently (`Font::epoch`): sign
/// text laid out under another value is laid out again.
pub glyphs: u64,
@@ -1055,6 +1143,7 @@ struct SignTextEntry {
/// Game time it was last drawn.
used: i64,
vertices: Vec<Vertex>,
animated: bool,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct StaticKey {
@@ -2361,9 +2450,11 @@ impl BlockEntityRenderer {
let entry = match signs.entry(pos) {
std::collections::hash_map::Entry::Occupied(mut occupied) => {
let entry = occupied.get_mut();
let changed = entry.data != *data;
if (entry.state, entry.packed, entry.near, entry.glyphs)
!= (state, packed, near, glyphs)
|| entry.data != *data
|| changed
|| entry.animated
{
entry.vertices.clear();
self.render_one(
@@ -2378,7 +2469,10 @@ impl BlockEntityRenderer {
&mut entry.vertices,
);
entry.state = state;
entry.data.clone_from(data);
if changed {
entry.animated = sign_text_animated(data);
entry.data.clone_from(data);
}
entry.packed = packed;
entry.near = near;
entry.glyphs = glyphs;
@@ -2399,6 +2493,7 @@ impl BlockEntityRenderer {
&mut vertices,
);
vacant.insert(SignTextEntry {
animated: sign_text_animated(data),
state,
data: data.clone(),
packed,
@@ -3638,6 +3733,7 @@ mod tests {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
// Compare the cached world path with the original model renderer,
@@ -4032,6 +4128,7 @@ mod tests {
skull: &|_| None,
glyph: &glyph,
glyphs: 0,
font: None,
dynamic_visible: None,
};
let mut call = TextCall {
@@ -4039,6 +4136,7 @@ mod tests {
x: 0.0,
y: 0.0,
text: "Hi".into(),
style: Style::default(),
color: 0xFFFF_FF00,
outline: 0xFF33_3300,
light: 240 | 240 << 8,
@@ -4106,6 +4204,7 @@ mod tests {
skull: &|_| None,
glyph: &glyph,
glyphs: 0,
font: None,
dynamic_visible: None,
};
let call = TextCall {
@@ -4113,6 +4212,7 @@ mod tests {
x: 10.0,
y: 2.0,
text: "ab".into(),
style: Style::default(),
color: 0xFF00_0000,
outline: 0,
light: 240 | 240 << 8,
@@ -4136,6 +4236,83 @@ mod tests {
assert_eq!(boxes, [[10.0, 14.0, 2.0, 10.0], [15.0, 19.0, 2.0, 10.0]]);
}
#[test]
fn styled_sign_quads_follow_vanilla_glyph_and_effect_bounds() {
let white = Rect {
u0: 0.0,
v0: 0.0,
u1: 0.1,
v1: 0.1,
w: 1,
h: 1,
};
let glyph = |c| Glyph {
rect: (c != ' ').then_some(white),
left: 0.0,
right: 4.0,
top: 0.0,
bottom: 8.0,
advance: 5.0,
offset: 0.5,
};
let mut call = TextCall {
matrix: Mat4::IDENTITY,
x: 0.0,
y: 0.0,
text: "A ".into(),
color: 0xff123456,
outline: 0,
light: 240,
tier: crate::mesher::LOW,
style: Style {
bold: Some(true),
italic: Some(true),
underlined: Some(true),
strikethrough: Some(true),
..Default::default()
},
};
let mut out = Vec::new();
text_vertices(&glyph, Some(white), &call, &mut out);
// BakedSheetGlyph: bold expands by 0.1, italic shears by 1 - y/4,
// the second bold glyph is 0.5 along and 0.001 in front (Unihex).
assert_eq!(out.len(), 24);
for (got, expected) in out[0].pos.iter().zip([-1.1, 8.1, 0.0]) {
assert!((got - expected).abs() < 1e-6);
}
assert!((out[4].pos[0] - out[0].pos[0] - 0.5).abs() < 1e-6);
assert_eq!(out[4].pos[2], 0.001);
assert_eq!(out[8].pos, [-1.0, 4.5, 0.01]);
assert_eq!(out[12].pos, [-1.0, 9.0, 0.01]);
assert_eq!(out[21].pos, [11.0, 9.0, 0.01]); // underline crosses the space
assert!(out.iter().all(|v| v.color == 0xff563412 && v.light == 240));
call.outline = 0xff010203;
out.clear();
text_vertices(&glyph, Some(white), &call, &mut out);
// Eight outlines contain glyphs only; effects appear once, in front.
assert_eq!(out.len(), 8 * 8 + 24);
assert!((out[0].pos[0] - -1.6).abs() < 1e-6);
assert!(out[64..].iter().all(|v| v.pos[2] >= TEXT_OVER_OUTLINE));
// The glow tier reaches bold copies, outlines and decoration quads.
assert!(out.iter().all(|v| v.layer >> 16 == 1));
call.tier = 0;
out.clear();
text_vertices(&glyph, Some(white), &call, &mut out);
assert!(out.iter().all(|v| v.layer >> 16 == 0));
}
#[test]
fn styled_sign_clipping_counts_bold_width_and_preserves_resets() {
let line = Text::legacy("§lAB§r東Z");
let advance = |_: char, s: &Style| 5.0 + if s.is_bold() { 0.5 } else { 0.0 };
let shown = first_line(&line, 16.0, &advance);
assert_eq!(shown.plain(), "AB東");
assert_eq!(
shown.chars().map(|(_, s)| s.is_bold()).collect::<Vec<_>>(),
[true, true, false]
);
}
/// The front text calls of a sign whose every glyph advances 6.
fn front_calls(data: &SignData, near: bool) -> Vec<(String, f32, f32, u32, u32)> {
let world = World::new(BlockStateId(0), 1);
@@ -4164,6 +4341,7 @@ mod tests {
skull: &|_| None,
glyph: &glyph,
glyphs: 0,
font: None,
dynamic_visible: None,
};
sign_text_calls(&scene, data, &data.front, Mat4::IDENTITY, 0, near)
@@ -4303,7 +4481,9 @@ mod tests {
..changed.clone()
};
let wide = std::cell::Cell::new(6.0);
let glyph_reads = std::cell::Cell::new(0);
let glyph = |c: char| {
glyph_reads.set(glyph_reads.get() + 1);
let u = f32::from(c as u8 % 16) / 16.0;
let rect = Rect {
u0: u,
@@ -4346,6 +4526,7 @@ mod tests {
skull: &|_| None,
glyph: &glyph,
glyphs: 0,
font: None,
dynamic_visible: None,
};
let check = |scene: &Scene, pos: [i32; 3], state: u32| {
@@ -4389,6 +4570,23 @@ mod tests {
wide.set(5.0);
scene.glyphs = 1;
check(&scene, pos, 1);
// With the same game time and data, plain text reuses its vertices,
// but obfuscated text must ask the font for fresh glyphs each frame.
let mut vertices = Vec::new();
let reads = glyph_reads.get();
renderer.render(&scene, [(pos, 1)].iter(), &mut vertices);
assert_eq!(glyph_reads.get(), reads);
let animated = SignData {
front: text("§kSecret", false),
..Default::default()
};
let animated_sign = |_| Some(&animated);
scene.sign = &animated_sign;
renderer.render(&scene, [(pos, 0)].iter(), &mut vertices);
let reads = glyph_reads.get();
renderer.render(&scene, [(pos, 0)].iter(), &mut vertices);
assert!(glyph_reads.get() > reads);
scene.sign = &first_sign;
// Signs out of view for a while are dropped.
scene.game_time = 2 * SIGN_TEXT_KEEP;
check(&scene, pos, 0);
@@ -4396,11 +4594,23 @@ mod tests {
}
#[test]
fn first_line_wraps_on_bytes_without_splitting_a_char() {
let advance = |c: char| if c == ' ' { 4.0 } else { 6.0 };
assert_eq!(first_line("ab cd ef", 13.0, &advance), "ab");
assert_eq!(first_line("abcdef", 13.0, &advance), "ab");
assert_eq!(first_line("\u{6771}", 3.0, &advance), "\u{6771}");
assert_eq!(first_line("ab\ncd", 100.0, &advance), "ab");
let advance = |c: char, _: &Style| if c == ' ' { 4.0 } else { 6.0 };
assert_eq!(
first_line(&Text::literal("ab cd ef"), 13.0, &advance).plain(),
"ab"
);
assert_eq!(
first_line(&Text::literal("abcdef"), 13.0, &advance).plain(),
"ab"
);
assert_eq!(
first_line(&Text::literal("\u{6771}"), 3.0, &advance).plain(),
"\u{6771}"
);
assert_eq!(
first_line(&Text::literal("ab\ncd"), 100.0, &advance).plain(),
"ab"
);
}
/// `rendertype_end_portal` culls back faces, and `AbstractEndPortalRenderer`
/// submits the unit cube's two Y faces. Both are wound outward, so of each
@@ -4504,6 +4714,7 @@ mod tests {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let mut verts = Vec::new();
@@ -4590,6 +4801,7 @@ mod tests {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
// A closed single chest of `block` drawn by `renderer`: positions and UVs.
@@ -358,6 +358,7 @@ fn batched_callbacks_preserve_entity_ranges_and_allow_immediate_culling() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
// Reverse local-position order to check that cache indexing does not
@@ -447,6 +448,7 @@ fn static_cache_qualifies_local_positions_by_section_and_drops_old_entries() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let options = CacheOptions {
@@ -502,6 +504,7 @@ fn gpu_static_cache_uses_section_local_chests_and_keeps_visibility_separate() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let blocks = [([100, 70, -32], 0)];
@@ -689,6 +692,7 @@ fn sign_text_cache_can_be_disabled_and_reenabled_without_changing_output() {
skull: &|_| None,
glyph: &glyph,
glyphs: 0,
font: None,
dynamic_visible: None,
};
let blocks = [([0, 64, 0], 0)];
@@ -743,6 +747,7 @@ fn shulker_cache_tracks_settled_poses_and_does_not_freeze_opening_animation() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let blocks = [([0, 64, 0], 0)];
@@ -845,6 +850,7 @@ fn shulker_cache_covers_all_colors_and_facing_directions() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let options = CacheOptions {
@@ -900,6 +906,7 @@ fn cached_bells_keep_shaking_until_the_animation_ends() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let blocks = [([0, 64, 0], 0)];
@@ -962,6 +969,7 @@ fn cached_closed_chests_match_the_direct_model_and_rebuild_when_opening() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let blocks = [([0, 64, 0], 0)];
@@ -1060,6 +1068,7 @@ fn closed_chest_cache_covers_all_materials_and_atlas_reloads() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let pos = [0, 64, 0];
@@ -1149,6 +1158,7 @@ fn double_chest_cache_bypasses_both_halves_while_either_lid_is_open() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let pair = [([0, 64, 0], 0), ([1, 64, 0], 1)];
@@ -1225,6 +1235,7 @@ fn decorated_pot_cache_tracks_sherds_and_bypasses_wobble_animation() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let blocks = [([0, 64, 0], 0)];
@@ -1304,6 +1315,7 @@ fn banner_cache_keeps_the_pole_static_while_the_flag_and_patterns_update() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let blocks = [([0, 64, 0], 0)];
@@ -1371,6 +1383,7 @@ fn cached_wall_banner_poles_use_the_wall_model() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let pos = [0, 64, 0];
@@ -1419,6 +1432,7 @@ fn copper_statue_cache_rebuilds_when_its_pose_state_changes() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let options = CacheOptions {
@@ -1525,6 +1539,7 @@ fn copper_statue_cache_covers_weathering_waxing_and_all_poses() {
skull: &|_| None,
glyph: &|_| Glyph::default(),
glyphs: 0,
font: None,
dynamic_visible: None,
};
let options = CacheOptions {
@@ -37,6 +37,37 @@ pub fn potion_name_key(item: &str, potion: Option<&str>) -> String {
let suffix = potion.and_then(self::potion).map_or("empty", |p| p.name);
format!("item.minecraft.{prefix}.effect.{suffix}")
}
/// `PotionItem.getName` and `TippedArrowItem.getName`: a potion or a tipped
/// arrow is named by its contents (`PotionContents.getName`: their own
/// `custom_name`, else the potion's name, else `empty`), whatever its
/// `item_name`. None for other items, and for a stack whose contents were
/// taken off (`!minecraft:potion_contents`), which takes the item's name.
pub fn contents_name_key(stack: &ItemStack) -> Option<String> {
use horizon_world::nbt::Tag;
let item = &*stack.item;
let named = matches!(
item,
"minecraft:potion"
| "minecraft:splash_potion"
| "minecraft:lingering_potion"
| "minecraft:tipped_arrow"
);
let data = stack.data();
if !named || data.is_some_and(|d| d.other("!minecraft:potion_contents").is_some()) {
return None;
}
let prefix = item.trim_start_matches("minecraft:");
let own = data
.and_then(|d| d.potion_extra.iter().find(|(k, _)| k == "custom_name"))
.and_then(|(_, name)| match name {
Tag::String(s) => Some(s.to_string_lossy()),
_ => None,
});
Some(match own {
Some(suffix) => format!("item.minecraft.{prefix}.effect.{suffix}"),
None => potion_name_key(item, stack.potion()),
})
}
/// `PotionContents.getAllEffects`: the potion's effects, then the stack's
/// `custom_effects` (id, duration, amplifier). Unknown effect ids are dropped.
pub fn contents_effects(stack: &ItemStack) -> Vec<(&'static str, i32, i32)> {
@@ -469,6 +500,40 @@ mod tests {
potion_name_key("minecraft:splash_potion", Some("minecraft:long_swiftness")),
"item.minecraft.splash_potion.effect.swiftness"
);
// A potion or a tipped arrow is named by its contents, over its
// item_name; one whose contents were taken off is not.
use horizon_world::nbt::Tag;
let mut swift =
ItemStack::new("minecraft:potion", 1).with_potion("minecraft:long_swiftness");
swift
.data_mut()
.set_other("minecraft:item_name", Some(Tag::String("Bottle".into())));
assert_eq!(
contents_name_key(&swift).as_deref(),
Some("item.minecraft.potion.effect.swiftness")
);
assert_eq!(
contents_name_key(&ItemStack::new("minecraft:splash_potion", 1)).as_deref(),
Some("item.minecraft.splash_potion.effect.empty")
);
let mut own = ItemStack::new("minecraft:tipped_arrow", 1).with_potion("minecraft:poison");
own.data_mut()
.potion_extra
.push(("custom_name".into(), Tag::String("luck".into())));
assert_eq!(
contents_name_key(&own).as_deref(),
Some("item.minecraft.tipped_arrow.effect.luck")
);
let mut taken = ItemStack::new("minecraft:potion", 1);
taken.data_mut().set_other(
"!minecraft:potion_contents",
Some(Tag::compound(Vec::<(&str, Tag)>::new())),
);
assert_eq!(contents_name_key(&taken), None);
assert_eq!(
contents_name_key(&ItemStack::new("minecraft:stone", 1)),
None
);
assert_eq!(format_duration(9600), "08:00");
assert_eq!(format_duration(450), "00:22");
assert_eq!(format_duration(140), "00:07");
+26 -13
View File
@@ -357,6 +357,24 @@ impl Light {
}
/// The smallest form of packed light per block.
pub fn packed(light: Box<[u8; 4096]>) -> Self {
match Self::classify(&light) {
(false, false, first) => Self::Uniform(first),
(true, false, first) => Self::Sky(Self::pack_layer(&light, 4), first & 15),
(false, true, first) => Self::Block(Self::pack_layer(&light, 0), first >> 4),
(true, true, _) => Self::Full(light),
}
}
/// The smallest form of packed light per block, allocating a 4 KiB box only
/// when both sky and block light vary within the section.
pub fn from_slice(light: &[u8; 4096]) -> Self {
match Self::classify(light) {
(false, false, first) => Self::Uniform(first),
(true, false, first) => Self::Sky(Self::pack_layer(light, 4), first & 15),
(false, true, first) => Self::Block(Self::pack_layer(light, 0), first >> 4),
(true, true, _) => Self::Full(Box::new(*light)),
}
}
fn classify(light: &[u8; 4096]) -> (bool, bool, u8) {
let first = light[0];
let (mut sky_varies, mut block_varies) = (false, false);
for &v in light.iter() {
@@ -364,19 +382,14 @@ impl Light {
sky_varies |= d & 0xF0 != 0;
block_varies |= d & 15 != 0;
}
let layer = |shift: u32| {
let mut layer = Box::new([0u8; 2048]);
for (out, pair) in layer.iter_mut().zip(light.as_chunks::<2>().0) {
*out = (pair[0] >> shift & 15) | (pair[1] >> shift & 15) << 4;
}
layer
};
match (sky_varies, block_varies) {
(false, false) => Self::Uniform(first),
(true, false) => Self::Sky(layer(4), first & 15),
(false, true) => Self::Block(layer(0), first >> 4),
(true, true) => Self::Full(light),
(sky_varies, block_varies, first)
}
fn pack_layer(light: &[u8; 4096], shift: u32) -> Box<[u8; 2048]> {
let mut layer = Box::new([0u8; 2048]);
for (out, pair) in layer.iter_mut().zip(light.as_chunks::<2>().0) {
*out = (pair[0] >> shift & 15) | (pair[1] >> shift & 15) << 4;
}
layer
}
/// The packed light of blocks `at..at + out.len()`, into `out`.
#[inline]
@@ -576,7 +589,7 @@ pub struct Chunk {
/// Block entities read from a save, moved into the world on arrival.
pub block_entities: Vec<((i32, i32, i32), block_entity::BlockEntity)>,
/// `CustomName` of the container block entities (shown as the screen title).
pub block_names: Vec<((i32, i32, i32), String)>,
pub block_names: Vec<((i32, i32, i32), Tag)>,
/// Generation postprocessing marks (ProtoChunk.postProcessing) as world
/// positions, applied once by LevelChunk.postProcessGeneration.
pub postprocess: Vec<[i32; 3]>,
@@ -83,6 +83,8 @@ pub enum BlockEntity {
/// `DaylightDetectorBlockEntity`: no data, only the ticker
/// (`DaylightDetectorBlock.tickEntity`).
DaylightDetector,
/// `BellBlockEntity`: saved identity only; ringing state is kept separately.
Bell,
/// Suspicious sand and gravel: saved loot and the transient brushed face.
Brushable(Box<Brushable>),
/// A shelf holds three displayed item stacks.
@@ -452,6 +454,9 @@ pub struct Jukebox {
pub items: [Option<ItemStack>; 1],
/// `ticks_since_song_started`, while a song plays.
pub ticks: i64,
/// `JukeboxBlockEntity.saveAdditional` writes the clock only when its song
/// reference exists. Keep this separate from legacy playback adoption.
pub song_clock_present: bool,
pub playing: bool,
}
impl Jukebox {
@@ -510,6 +515,11 @@ pub struct Info {
pub pos: [f64; 3],
pub source: Option<Who>,
pub owner: Option<Who>,
/// `uuid`: the source's saved identity (`source`), taken when the event
/// was posted. `source` is the live entity and comes back `None` on load.
pub source_uuid: Option<[i32; 4]>,
/// `projectileOwnerUuid` (`projectile_owner`), likewise beside `owner`.
pub owner_uuid: Option<[i32; 4]>,
}
/// `VibrationSelector`: the closest, then highest-frequency candidate of a tick.
#[derive(Clone, Debug, Default, PartialEq)]
@@ -356,6 +356,38 @@ where
)
.unwrap_or(false)
}
/// `Level.loadedAndEntityCanStandOn(pos, projectile)` with the projectile's
/// feet at `entity_y` (`loadedAndEntityCanStandOnFace` with `UP`):
/// `Block.isFaceFull(state.getCollisionShape(level, pos,
/// CollisionContext.of(projectile)), UP)`. A projectile is not living and never
/// falls (it moves by `setPos`), so powder snow and liquids hold nothing up
/// and only scaffolding reads the height. An unloaded or out-of-world block
/// reads as air.
pub fn projectile_can_stand_on(
world: &World,
binding: &BlockCollisionRegistry<'_>,
pos: BlockPos,
entity_y: f64,
) -> bool {
use horizon_core::geometry::{Direction, ShapeOp};
let mut scene = SceneCollisions {
world,
binding,
subject: None,
};
let state = world.block(pos.x, pos.y, pos.z);
let context = CollisionContext::position(entity_y);
binding
.collision_shape_with_context(&mut scene, state, pos, &context)
.is_ok_and(|shape| {
shape.is_block()
|| shape.face_shape(Direction::Up).is_ok_and(|face| {
VoxelShape::block()
.join_is_not_empty(&face, ShapeOp::XOR)
.is_ok_and(|differs| !differs)
})
})
}
fn no_collision_in<W, E>(world: &mut W, bounds: Aabb, fluids: bool) -> bool
where
W: BlockCollisionWorld<Error = E> + EntityMovementWorld<Error = E>,
+70 -13
View File
@@ -19,26 +19,75 @@ pub struct ModMenuType {
pub slots: usize,
pub data_slots: usize,
pub results: Vec<usize>,
/// its crafting grid, if it has one (`crafting`).
pub crafting: Option<ModCrafting>,
/// its linked slots, if it has any (`links`).
pub links: Option<ModLinks>,
}
/// a mod menu type's linked slots: `count` container slots from `from` on,
/// which show the slots of the containers a native mod links them to
/// (`native_menu_links`) instead of the block entity's.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ModLinks {
pub from: usize,
pub count: usize,
}
impl ModLinks {
/// The linked container slots.
pub fn slots(&self) -> std::ops::Range<usize> {
self.from..self.from + self.count
}
}
/// a mod menu type's crafting grid: `size`x`size` container slots from
/// `grid` on, row by row, and the slot showing what they craft. The block
/// entity holds the grid; the result is the menu's.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ModCrafting {
pub grid: usize,
pub size: usize,
pub result: usize,
}
impl ModCrafting {
/// The grid's container slots.
pub fn grid_slots(&self) -> std::ops::Range<usize> {
self.grid..self.grid + self.size * self.size
}
}
static MOD_MENU_TYPES: std::sync::OnceLock<Vec<ModMenuType>> = std::sync::OnceLock::new();
/// registers the content mods' menu types, `(id, slots, data slots,
/// results)`, a list set once per process (false when it already was).
pub fn register_mod_menu_types(
menus: impl IntoIterator<Item = (String, usize, usize, Vec<usize>)>,
) -> bool {
/// One menu type as [`register_mod_menu_types`] takes it: `(id, slots, data
/// slots, results, crafting, links)`.
pub type ModMenuTypeEntry = (
String,
usize,
usize,
Vec<usize>,
Option<ModCrafting>,
Option<ModLinks>,
);
/// registers the content mods' menu types, a list set once per process
/// (false when it already was).
pub fn register_mod_menu_types(menus: impl IntoIterator<Item = ModMenuTypeEntry>) -> bool {
if MOD_MENU_TYPES.get().is_some() {
return false;
}
let menus = menus
.into_iter()
.map(|(id, slots, data_slots, results)| ModMenuType {
id: Box::leak(id.into_boxed_str()),
slots,
data_slots,
results,
});
let menus =
menus.into_iter().map(
|(id, slots, data_slots, results, crafting, links)| ModMenuType {
id: Box::leak(id.into_boxed_str()),
slots,
data_slots,
results,
crafting,
links,
},
);
MOD_MENU_TYPES.set(menus.collect()).is_ok()
}
@@ -392,6 +441,9 @@ impl BlockEntity {
if name == "minecraft:end_gateway" {
return Some(Self::EndGateway(EndGateway::default()));
}
if name == "minecraft:bell" {
return Some(Self::Bell);
}
if name == "minecraft:daylight_detector" {
return Some(Self::DaylightDetector);
}
@@ -487,6 +539,7 @@ impl BlockEntity {
Self::Crafter(_) => name == "minecraft:crafter",
Self::EndGateway(_) => name == "minecraft:end_gateway",
Self::DaylightDetector => name == "minecraft:daylight_detector",
Self::Bell => name == "minecraft:bell",
Self::StructureBlock(_) => name == "minecraft:structure_block",
Self::TestBlock(_) => name == "minecraft:test_block",
Self::TestInstanceBlock(_) => name == "minecraft:test_instance_block",
@@ -525,6 +578,7 @@ impl BlockEntity {
Self::Skull(_) => "minecraft:skull",
Self::EndGateway(_) => "minecraft:end_gateway",
Self::DaylightDetector => "minecraft:daylight_detector",
Self::Bell => "minecraft:bell",
Self::Brushable(_) => "minecraft:brushable_block",
Self::Campfire(_) => "minecraft:campfire",
Self::ChiseledBookshelf(_) => "minecraft:chiseled_bookshelf",
@@ -559,6 +613,7 @@ impl BlockEntity {
| Self::TestBlock(_)
| Self::TestInstanceBlock(_)
| Self::DaylightDetector
| Self::Bell
| Self::Brushable(_) => Vec::new(),
Self::Mod(m) => m.items.iter().flatten().cloned().collect(),
Self::Lectern(l) => l.book.iter().cloned().collect(),
@@ -589,6 +644,7 @@ impl BlockEntity {
| Self::TestBlock(_)
| Self::TestInstanceBlock(_)
| Self::DaylightDetector
| Self::Bell
| Self::Brushable(_) => &[],
Self::Jukebox(j) => &j.items,
Self::Crafter(c) => &c.items,
@@ -624,6 +680,7 @@ impl BlockEntity {
| Self::TestBlock(_)
| Self::TestInstanceBlock(_)
| Self::DaylightDetector
| Self::Bell
| Self::Brushable(_) => &mut [],
Self::Jukebox(j) => &mut j.items,
Self::Crafter(c) => &mut c.items,
@@ -83,6 +83,13 @@ fn choice_description(opt: Opt, pad: &PadSettings) -> Option<&'static str> {
GlyphStyle::PlayStation => "Always shows PlayStation buttons.",
GlyphStyle::Nintendo => "Always shows Nintendo buttons.",
},
Opt::PadNintendoButtons => {
if pad.nintendo_letters {
"A, on the right, confirms and jumps and B goes back, as on a Switch."
} else {
"B, at the bottom, confirms and jumps and A goes back, as on other controllers."
}
}
Opt::PadKeyboard => match pad.keyboard {
gamepad::TextKeyboard::Auto => {
"Opens Steam's keyboard on a Steam Deck under Steam, and Horizon's otherwise."
@@ -184,6 +191,10 @@ pub fn rows() -> Vec<(Page, Vec<(&'static str, Vec<Setting>)>)> {
Opt::PadGameplayGuide,
"Show the buttons for what you can do, while you play with a controller.",
),
option(
Opt::PadCraftOnServers,
"Lets LT + A craft on servers other than your own worlds. Some servers count it as a macro.",
),
option(
Opt::PadTriggerThreshold,
"How far a trigger is pulled before it counts as pressed.",
@@ -261,6 +272,10 @@ pub fn rows() -> Vec<(Page, Vec<(&'static str, Vec<Setting>)>)> {
Opt::PadGlyphs,
"Follow the controller, or always show one family's buttons.",
),
option(
Opt::PadNintendoButtons,
"Whether a Nintendo controller's A and B work by where they sit or by their letters.",
),
info(Info::Using, "The buttons menus show right now."),
],
),
@@ -333,6 +348,7 @@ impl Item {
Item::Option(Opt::PadAdaptiveTriggers) => Some(c.adaptive_triggers),
Item::Option(Opt::PadInvertX) => Some(c.invert_x),
Item::Option(Opt::PadInvertY) => Some(c.invert_y),
Item::Option(Opt::PadCraftOnServers) => Some(c.craft_on_servers),
_ => None,
}
}
@@ -1332,6 +1348,7 @@ mod tests {
Opt::PadLookDeadzone,
Opt::PadTriggerThreshold,
Opt::PadGlyphs,
Opt::PadNintendoButtons,
Opt::PadKeyboard,
Opt::PadPointerSpeed,
Opt::PadScrollSpeed,
@@ -1429,6 +1446,53 @@ mod tests {
assert!((s.controller.move_deadzone - before - 0.01).abs() < 0.001);
}
/// The Device page's Nintendo Buttons row sits with the glyphs, steps between its two
/// values rather than ticking a box, and what it sets is what the controller file keeps.
#[test]
fn the_nintendo_buttons_row_flips_letters_and_the_file_keeps_it() {
let (page, group) = rows()
.into_iter()
.flat_map(|(page, groups)| groups.into_iter().map(move |g| (page, g)))
.find(|(_, (_, rows))| {
rows.iter()
.any(|r| r.item == Item::Option(Opt::PadNintendoButtons))
})
.unwrap();
assert_eq!((page, group.0), (Page::Device, "Glyphs"));
let mut s = Settings::default();
let item = Item::Option(Opt::PadNintendoButtons);
assert!(item.steps(&s));
s.controller.nintendo_letters = false;
let mut ui = ControllerUi {
focus: Some(Target::Item(item)),
..ControllerUi::default()
};
// Vanilla's caption and value template; Horizon's own words come bundled.
struct Vanilla;
impl lang::ResourceSource for Vanilla {
fn read(&self, path: &str) -> Option<Vec<u8>> {
(path == "assets/minecraft/lang/en_us.json")
.then(|| br#"{"options.generic_value": "%s: %s"}"#.to_vec())
}
}
let value = |ui: &ControllerUi, s: &Settings| {
lang::scoped(lang::Language::load(&[&Vanilla], "en_us"), || {
ui.parts(item, s)
})
.0
};
assert_eq!(value(&ui, &s).0, "Nintendo Buttons");
assert_eq!(value(&ui, &s).1.as_deref(), Some("By Position"));
let actions = key(&mut ui, &mut s, K::Enter);
assert!(actions.contains(&Action::Changed), "{actions:?}");
assert!(s.controller.nintendo_letters);
assert_eq!(value(&ui, &s).1.as_deref(), Some("By Letter"));
assert!(PadSettings::parse(&s.controller.serialize()).nintendo_letters);
key(&mut ui, &mut s, K::Enter);
assert!(!s.controller.nintendo_letters);
assert!(!PadSettings::parse(&s.controller.serialize()).nintendo_letters);
}
/// What the screen draws at the bottom of the page changes with the choice, in every one of
/// these settings.
#[test]
@@ -1438,6 +1502,7 @@ mod tests {
for (opt, choices) in [
(Opt::PadGameplayGuide, 3),
(Opt::PadGlyphs, 4),
(Opt::PadNintendoButtons, 2),
(Opt::PadKeyboard, 3),
(Opt::PadLightbar, 3),
] {
@@ -1470,6 +1535,7 @@ mod tests {
for opt in [
Opt::PadGameplayGuide,
Opt::PadGlyphs,
Opt::PadNintendoButtons,
Opt::PadKeyboard,
Opt::PadLightbar,
] {
@@ -278,6 +278,43 @@ pub fn screen_packs(dir: &Path, resources: &Path) -> Vec<crate::pack_screen::Pac
}
infos
}
/// The folder of a game folder whose packs every new world there starts with: a modpack's profile
/// keeps the packs of its data-only jars here (`horizon-port-pack`). Each world gets its own copy,
/// as Create World's packs do, so a world keeps working when the folder changes. Vanilla has no
/// such folder, and without one nothing here happens.
pub const NEW_WORLD_PACKS: &str = "new-world-datapacks";
/// Create World's temporary pack folder holding `game_dir`'s [`NEW_WORLD_PACKS`], and their ids,
/// to show them selected in the Data Packs screen. `None` when there are none.
pub fn seed_create_world(game_dir: &Path) -> Option<(PathBuf, Vec<String>)> {
let from = game_dir.join(NEW_WORLD_PACKS);
let ids: Vec<String> = discover_folder(&from).into_iter().map(|p| p.id).collect();
if ids.is_empty() {
return None;
}
let seeded = temp_folder()
.map_err(|e| e.to_string())
.and_then(|dir| copy(&from, &dir).map(|()| dir));
match seeded {
Ok(dir) => Some((dir, ids)),
Err(e) => {
log::warn!("Horizon: data packs for new worlds: {e}");
None
}
}
}
/// A world about to be created without Create World (`--world`, the control socket) gets
/// `game_dir`'s [`NEW_WORLD_PACKS`]. The game turns on every pack it finds in a world.
pub fn install_new_world_packs(game_dir: &Path, world: &Path) -> Result<(), String> {
let from = game_dir.join(NEW_WORLD_PACKS);
let exists = |name: &str| world.join(name).exists();
if !from.is_dir() || exists("level.dat") || exists("level.dat_old") {
return Ok(());
}
copy(&from, &world.join("datapacks"))
}
/// A new empty folder for Create World's packs
/// (`Files.createTempDirectory("mcworld-")`).
pub fn temp_folder() -> std::io::Result<PathBuf> {
@@ -1101,6 +1138,35 @@ mod tests {
let _ = std::fs::remove_dir_all(&root);
}
#[test]
fn a_game_folder_s_new_world_packs_go_into_new_worlds_only() {
let root = std::env::temp_dir().join(format!("hz-new-world-packs-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&root);
let (game, world, old) = (root.join("game"), root.join("new"), root.join("old"));
assert!(seed_create_world(&game).is_none());
assert_eq!(install_new_world_packs(&game, &world), Ok(()));
assert!(!world.join("datapacks").exists());
for pack in ["void", "islands"] {
let dir = game.join(NEW_WORLD_PACKS).join(pack);
std::fs::create_dir_all(dir.join("data/v/function")).unwrap();
std::fs::write(dir.join("pack.mcmeta"), r#"{"pack":{"description":""}}"#).unwrap();
std::fs::write(dir.join("data/v/function/a.mcfunction"), "say a").unwrap();
}
let (temp, ids) = seed_create_world(&game).unwrap();
assert_eq!(ids, ["file/islands", "file/void"]);
assert!(temp.join("void/data/v/function/a.mcfunction").is_file());
let _ = std::fs::remove_dir_all(&temp);
install_new_world_packs(&game, &world).unwrap();
let ids: Vec<String> = discover(&world).into_iter().map(|p| p.id).collect();
assert_eq!(ids, ["file/islands", "file/void"]);
// A world that exists already keeps the packs it has.
std::fs::create_dir_all(&old).unwrap();
std::fs::write(old.join("level.dat"), "").unwrap();
install_new_world_packs(&game, &old).unwrap();
assert!(discover(&old).is_empty());
let _ = std::fs::remove_dir_all(&root);
}
#[test]
fn enabled_packs_override_worldgen_in_order() {
let dir = std::env::temp_dir().join(format!("hz-datapack-worldgen-{}", std::process::id()));
+37 -4
View File
@@ -33,7 +33,10 @@ struct Globals {
hdr_windows: array<vec4<f32>, 2>,
// HDR lighting: x how strongly the sky lights the world now (`Sky::sky_light_factor`),
// y what the sky and fog get: the same, but none under water.
// w: apply the no-pack HDR gain; HDR_WRITE_LIGHT independently keeps float alpha as coverage.
hdr_light: vec4<f32>,
hdr_settings: vec4<f32>,
hdr_shares: vec4<f32>,
}
@group(0) @binding(0) var<uniform> globals: Globals;
@group(0) @binding(1) var atlas: texture_2d<f32>;
@@ -276,6 +279,19 @@ fn crumbling_uv(uv: vec2<f32>, packed_origin: vec2<f32>, sprite_size: vec2<f32>,
}
// CRUMBLING_UV_END
@fragment fn fs_entity(in: Out, @builtin(front_facing) front: bool) -> @location(0) vec4<f32> {
return entity_written_color(in, entity_color(in, front));
}
// Takes entity_color's result rather than calling it: FXC (DX12) fails with "argument pulled into
// unrelated predicate" when entity_color's discards sit a function call below the entry point.
fn entity_written_color(in: Out, color: vec4<f32>) -> vec4<f32> {
if HDR_WRITE_LIGHT && globals.hdr_light.w != 0.0 && in.overlay != 11u && in.overlay != 12u {
var mark = hdr_entity_mark(in);
if in.overlay == 4u { mark = hdr_scene_alpha(globals.hdr_light.y); }
return vec4(hdr_written(color.rgb, mark, globals.hdr_settings, globals.hdr_shares), color.a);
}
return color;
}
@fragment fn fs_entity_unmarked(in: Out, @builtin(front_facing) front: bool) -> @location(0) vec4<f32> {
return entity_color(in, front);
}
fn entity_color(in: Out, front: bool) -> vec4<f32> {
@@ -358,15 +374,23 @@ fn shadow_color(in: Out) -> vec4<f32> {
if in.overlay == 6u { uv.y = in.wrap.x + fract(in.uv.y) * in.wrap.y; }
let texel = textureSample(atlas, atlas_sampler, uv);
if texel.a < 0.1 { discard; }
return vec4(0.0, 0.0, 0.0, hdr_entity_mark(in));
}
fn hdr_entity_mark(in: Out) -> f32 {
var uv = in.uv;
if in.overlay == 6u { uv.y = in.wrap.x + fract(in.uv.y) * in.wrap.y; }
let texel = textureSample(atlas, atlas_sampler, uv);
// Additive and procedural colour draws can survive where the legacy mark pass skips.
if texel.a < 0.1 { return 1.0; }
// Fog hides a light source and the light on a surface as it hides everything else.
let fogged = max(linear_fog(in.fog_distance.x, globals.fog.x, globals.fog.y),
linear_fog(in.fog_distance.y, globals.fog.z, globals.fog.w)) * globals.fog_color.a;
if in.tier == 0u {
return vec4(0.0, 0.0, 0.0, hdr_scene_alpha(mix(in.scene, globals.hdr_light.y, fogged)));
return hdr_scene_alpha(mix(in.scene, globals.hdr_light.y, fogged));
}
// A layer that fades (the warden's) shines by what's left of it.
let y = brightness(texel.rgb * in.color.rgb) * in.color.a * (1.0 - fogged);
return vec4(0.0, 0.0, 0.0, hdr_mark(in.tier, y));
return hdr_mark(in.tier, y);
}
fn brightness(c: vec3<f32>) -> f32 {
let l = pow(max(c, vec3(0.0)), vec3(2.2));
@@ -407,7 +431,11 @@ fn celestial_color(in: Out) -> vec4<f32> {
return textureSample(atlas, atlas_sampler, in.uv) * in.color * in.light_color;
}
@fragment fn fs_celestial(in: Out) -> @location(0) vec4<f32> {
return celestial_color(in);
let color = celestial_color(in);
if HDR_WRITE_LIGHT && globals.hdr_light.w != 0.0 {
return vec4(hdr_written(color.rgb, hdr_entity_mark(in), globals.hdr_settings, globals.hdr_shares), color.a);
}
return color;
}
// The sky's celestial pass (sun, moon, the End sky): fs_celestial's light,
@@ -424,7 +452,12 @@ fn celestial_color(in: Out) -> vec4<f32> {
let y = brightness(added);
// Only what's past the tier's window takes the mark: a soft edge keeps the sky's light,
// or it would come out darker than the sky around it.
if y < globals.hdr_windows[1][clamp(tier, 1u, 4u) - 1u] { return vec4(added, 0.0); }
let full = y >= globals.hdr_windows[1][clamp(tier, 1u, 4u) - 1u];
if HDR_WRITE_LIGHT && globals.hdr_light.w != 0.0 {
return vec4(hdr_written(added, select(1.0, hdr_mark(tier, y), full), globals.hdr_settings, globals.hdr_shares), color.a);
}
if HDR_WRITE_LIGHT { return vec4(added, color.a); }
if !full { return vec4(added, 0.0); }
return vec4(added, 1.0 - hdr_mark(tier, y));
}
File diff suppressed because it is too large. Load diff
+67 -1
View File
@@ -5,7 +5,7 @@ use crate::{
lang,
options_ui::{Event, Page},
settings::Settings,
settings_shell::{Group, Output, Row, Screen, Sheet, Value},
settings_shell::{self as shell, Group, Output, Row, Screen, Sheet, Value},
};
const TITLE: &str = "horizon.pages.extras";
@@ -85,6 +85,10 @@ impl Screen for ExtrasScreen {
fn note_lines(&self) -> usize {
NOTE_LINES
}
/// The rows read the extras, the mods and whether cosmetics are offered.
fn stamp(&self, s: &Settings) -> u64 {
shell::stamp_of(&(&s.extras, &s.mods, horizon_cosmetics::enabled()))
}
fn sheets(&self, s: &Settings) -> Vec<Sheet<(), ExtraRow>> {
let mut groups = vec![Group {
name: MODS,
@@ -228,4 +232,66 @@ mod tests {
assert!(s.extras.sort);
assert_eq!(screen.wheel_step(&mut s, ExtraRow::Zoom(0), true), None);
}
/// Extras has no Undo: a change leaves none to press or reach.
#[test]
fn a_change_on_extras_leaves_no_undo() {
use crate::settings_shell::{Columns, Target};
use winit::keyboard::KeyCode as K;
let mut s = Settings::default();
let mut shell = Shell::<ExtrasScreen>::default();
let at = shell.point_at(&s, SIZE, ExtraRow::Item(Item::Sort));
assert!(
!shell
.click(&mut s, at, SIZE, false, false, false)
.is_empty()
);
assert!(s.extras.sort && !shell.changed());
let cols = Columns::of(SIZE.0, SIZE.1).with_note_lines(NOTE_LINES);
let [x, y, ..] = cols.button(1);
assert!(
shell
.click(&mut s, (x + 2.0, y + 2.0), SIZE, false, false, false)
.is_empty()
);
assert!(s.extras.sort);
let reached = (0..100).any(|_| {
shell.key(&mut s, K::Tab, None, false, SIZE);
shell.focused() == Some(Target::Undo)
});
assert!(!reached);
}
/// A page with no page list has Done under the search field: Down goes to the first row
/// instead, from the keys and, as the frame declares it, from a controller's focus.
#[test]
fn down_from_the_search_field_lands_on_the_first_row() {
use crate::{hud::HudBatch, settings_shell::Columns, ui};
use winit::keyboard::KeyCode as K;
let atlas = crate::hud::HudAtlas::build(std::path::Path::new("/nonexistent")).unwrap();
let mut s = Settings::default();
let mut shell = Shell::<ExtrasScreen>::default();
let mut batch = HudBatch::new([1708, 960]);
shell.draw(&s, &mut batch, &atlas, (0.0, 0.0), false, None);
crate::widgets::end_frame(1);
let size = (batch.width, batch.height);
let cols = Columns::of(size.0, size.1).with_note_lines(NOTE_LINES);
// The Mods group's note can't take the focus: the first item can.
let first = ExtraRow::Item(Item::OwnNameTag);
let at = shell.point_at(&s, size, first);
let [x, y, w, h] = crate::widgets::linked_step(cols.search(), true).unwrap();
assert!(ui::hovered(at, x, y, w, h));
assert_eq!(crate::widgets::linked_step(cols.search(), false), None);
let [x, y, w, h] = cols.search();
shell.click(
&mut s,
(x + w / 2.0, y + h / 2.0),
size,
false,
false,
false,
);
shell.key(&mut s, K::ArrowDown, None, false, size);
assert_eq!(shell.focused_row(), Some(first));
}
}
File diff suppressed because it is too large. Load diff
+12 -1
View File
@@ -879,6 +879,7 @@ mod tests {
solid,
solid_slots: u64::from(solid) * 4,
packed: false,
packed_far: false,
sides: crate::mesher::Sides::unsorted(solid),
translucent,
sort: super::super::translucency::SortState::new(Vec::new()),
@@ -1047,7 +1048,15 @@ mod tests {
hdr: None,
}
};
let mut flat = flat::Flat::new(&device, &terrain_layout, 4 * GRAIN, 0, pipeline, solid);
let mut flat = flat::Flat::new(
&device,
&terrain_layout,
4 * GRAIN,
0,
false,
pipeline,
solid,
);
let stride = std::mem::size_of::<crate::mesher::TerrainVertex>() as u64;
let mut translucent = Arena::translucent(&device, stride, 4 * GRAIN);
translucent.page_limit = 4 * GRAIN;
@@ -1083,6 +1092,7 @@ mod tests {
solid: 64,
solid_slots: 64 * 4,
packed: false,
packed_far: false,
sides: crate::mesher::Sides::unsorted(64),
translucent: 128,
sort: super::super::translucency::SortState::new(Vec::new()),
@@ -1310,6 +1320,7 @@ mod tests {
solid,
solid_slots: u64::from(solid) * 4,
packed: false,
packed_far: false,
sides: crate::mesher::Sides::unsorted(solid),
translucent,
sort: super::super::translucency::SortState::new(Vec::new()),
@@ -67,6 +67,7 @@ fn copy(mesh: &SectionMesh) -> SectionMesh {
sides: mesh.sides,
translucent: mesh.translucent.clone(),
packed: mesh.packed.clone(),
packed_far: mesh.packed_far,
solid_tints: Vec::new(),
visibility: mesh.visibility,
block_entities: mesh.block_entities.clone(),
@@ -0,0 +1,436 @@
//! A resource pack's `core/sky` and `core/stars` shaders: the overworld's sky disc and stars drawn
//! with the pack's GLSL (`SkyRenderer.renderSkyDisc`, `renderStars`), as a pack that adds a haze
//! to the horizon or tints the night sky expects. Without one the sky draws natively (`fs_sky` in
//! terrain.wgsl, stars.rs).
use glam::Mat4;
use horizon_shaders::{CoreProgram, Glue};
use wgpu::util::DeviceExt;
/// `DefaultVertexFormat.POSITION`: the disc's and the stars' vertices.
pub(crate) const GLUE: Glue = Glue {
inputs: &[("Position", "vec3")],
prelude: "layout(location = 0) in vec3 hz_position;",
setup: "Position = hz_position;",
// 26.3's ProjMat already has wgpu's reversed 0 to 1 depth (Projection: zZeroToOne).
finish: "",
vertex_id: "int(gl_VertexIndex)",
};
/// Each uniform block's offset in the one buffer (`core_shader::BLOCKS` order).
const BLOCK_OFFSETS: [u64; 4] = [0, 256, 512, 768];
const BLOCK_SIZES: [u64; 4] = [48, 64, 160, 48];
/// `SkyRenderer.buildSkyDisc(16)`: a fan around the point 16 above the camera, out to 512 every
/// 45 degrees, as a triangle list.
pub(crate) fn disc_triangles() -> Vec<[f32; 3]> {
let rim: Vec<[f32; 3]> = (-180..=180)
.step_by(45)
.map(|i: i32| {
let a = (i as f32).to_radians();
[512.0 * a.cos(), 16.0, 512.0 * a.sin()]
})
.collect();
rim.windows(2)
.flat_map(|edge| [[0.0, 16.0, 0.0], edge[0], edge[1]])
.collect()
}
/// One of the sky's pack pipelines with its vertices and uniforms.
struct Part {
pipeline: wgpu::RenderPipeline,
group: wgpu::BindGroup,
uniform: wgpu::Buffer,
vertices: wgpu::Buffer,
count: u32,
}
impl Part {
fn new(
device: &wgpu::Device,
format: wgpu::TextureFormat,
program: &CoreProgram,
name: &str,
blend: Option<wgpu::BlendState>,
triangles: &[[f32; 3]],
) -> Option<Self> {
// A pack's shader is untrusted: the backend failing to compile it is an internal error.
let validation = device.push_error_scope(wgpu::ErrorFilter::Validation);
let internal = device.push_error_scope(wgpu::ErrorFilter::Internal);
let module = |stage, module: &naga::Module| {
device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some(&format!("Resource pack {name} ({stage})")),
source: wgpu::ShaderSource::Naga(std::borrow::Cow::Owned(module.clone())),
})
};
let vertex = module("vertex", &program.vertex);
let fragment = module("fragment", &program.fragment);
// Vanilla's SKY and STARS pipelines have no samplers: a pack that reads one is not used.
let entries: Vec<wgpu::BindGroupLayoutEntry> = (0..4)
.map(|binding| wgpu::BindGroupLayoutEntry {
binding,
visibility: wgpu::ShaderStages::VERTEX_FRAGMENT,
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform,
has_dynamic_offset: false,
min_binding_size: wgpu::BufferSize::new(BLOCK_SIZES[binding as usize]),
},
count: None,
})
.collect();
let layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some(name),
entries: &entries,
});
let uniform = device.create_buffer(&wgpu::BufferDescriptor {
label: Some(name),
size: 1024,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
let resources: Vec<wgpu::BindGroupEntry> = (0..4)
.map(|i| wgpu::BindGroupEntry {
binding: i as u32,
resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
buffer: &uniform,
offset: BLOCK_OFFSETS[i],
size: wgpu::BufferSize::new(BLOCK_SIZES[i]),
}),
})
.collect();
let group = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: Some(name),
layout: &layout,
entries: &resources,
});
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some(name),
bind_group_layouts: &[Some(&layout)],
..Default::default()
});
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some(name),
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &vertex,
entry_point: Some("main"),
compilation_options: Default::default(),
buffers: &[Some(wgpu::VertexBufferLayout {
array_stride: 12,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float32x3],
})],
},
primitive: wgpu::PrimitiveState::default(),
// The sky is drawn first, behind everything: no depth test, no depth write.
depth_stencil: Some(wgpu::DepthStencilState {
format: wgpu::TextureFormat::Depth32Float,
depth_write_enabled: Some(false),
depth_compare: Some(wgpu::CompareFunction::Always),
stencil: Default::default(),
bias: Default::default(),
}),
multisample: Default::default(),
fragment: Some(wgpu::FragmentState {
module: &fragment,
entry_point: Some("main"),
compilation_options: Default::default(),
targets: &[Some(wgpu::ColorTargetState {
format,
blend,
write_mask: wgpu::ColorWrites::ALL,
})],
}),
multiview_mask: None,
cache: None,
});
let internal = pollster::block_on(internal.pop());
if let Some(e) = internal.or(pollster::block_on(validation.pop())) {
log::warn!("the resource pack's {name} shader is not used: {e}");
return None;
}
let vertices = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some(name),
contents: bytemuck::cast_slice(triangles),
usage: wgpu::BufferUsages::VERTEX,
});
Some(Self {
pipeline,
group,
uniform,
vertices,
count: triangles.len() as u32,
})
}
fn draw(&self, pass: &mut wgpu::RenderPass<'_>) {
pass.set_pipeline(&self.pipeline);
pass.set_bind_group(0, &self.group, &[]);
pass.set_vertex_buffer(0, self.vertices.slice(..));
pass.draw(0..self.count, 0..1);
}
}
/// The packs' sky disc and stars pipelines, each present when a pack replaces that shader.
pub(super) struct CoreSky {
disc: Option<Part>,
stars: Option<Part>,
}
impl CoreSky {
/// `None` when neither shader is replaced or neither builds.
pub(super) fn new(
device: &wgpu::Device,
format: wgpu::TextureFormat,
disc: Option<&CoreProgram>,
stars: Option<&CoreProgram>,
) -> Option<Self> {
let disc = disc.and_then(|program| {
// RenderPipelines.SKY: ColorTargetState.DEFAULT, no blending.
Part::new(device, format, program, "sky", None, &disc_triangles())
});
let stars = stars.and_then(|program| {
// RenderPipelines.STARS: BlendFunction.OVERLAY (src alpha and one; alpha one, zero).
let overlay = wgpu::BlendState {
color: wgpu::BlendComponent {
src_factor: wgpu::BlendFactor::SrcAlpha,
dst_factor: wgpu::BlendFactor::One,
operation: wgpu::BlendOperation::Add,
},
alpha: wgpu::BlendComponent {
src_factor: wgpu::BlendFactor::One,
dst_factor: wgpu::BlendFactor::Zero,
operation: wgpu::BlendOperation::Add,
},
};
let triangles = super::stars::star_triangles();
Part::new(device, format, program, "stars", Some(overlay), &triangles)
});
(disc.is_some() || stars.is_some()).then_some(Self { disc, stars })
}
pub(super) fn draws_disc(&self) -> bool {
self.disc.is_some()
}
pub(super) fn draws_stars(&self) -> bool {
self.stars.is_some()
}
/// Uploads the disc's and the stars' blocks: `sky` and `stars` from [`uniforms`].
pub(super) fn prepare(
&self,
uploads: &mut super::upload::Uploads,
encoder: &mut wgpu::CommandEncoder,
sky: &[u8],
stars: Option<&[u8]>,
) {
if let Some(disc) = &self.disc {
uploads.buffer(encoder, &disc.uniform, 0, sky);
}
if let (Some(part), Some(data)) = (&self.stars, stars) {
uploads.buffer(encoder, &part.uniform, 0, data);
}
}
/// The disc, in place of the native sky colour. The caller sets its own group 0 again after.
pub(super) fn draw_disc(&self, pass: &mut wgpu::RenderPass<'_>) {
if let Some(disc) = &self.disc {
disc.draw(pass);
}
}
/// The stars, in place of the native ones. The caller sets its own group 0 again after.
pub(super) fn draw_stars(&self, pass: &mut wgpu::RenderPass<'_>) {
if let Some(stars) = &self.stars {
stars.draw(pass);
}
}
}
/// The std140 blocks for one sky draw: `Globals`, `Projection` (`projection`, far enough for the
/// disc's 512-block rim), `DynamicTransforms` (`model_view`: the camera's rotation, times the
/// stars' rotation for them; `color`: the sky colour, or the star brightness in every channel)
/// and `Fog` (`fog_color`, `fog`: environmental start and end, render distance start and end,
/// sky end, clouds end).
pub(super) fn uniforms(
globals: [u8; 48],
projection: Mat4,
model_view: Mat4,
color: [f32; 4],
fog_color: [f32; 4],
fog: [f32; 6],
) -> Vec<u8> {
let mut data = vec![0f32; 256];
data[64..80].copy_from_slice(&projection.to_cols_array());
let transforms = 128;
data[transforms..transforms + 16].copy_from_slice(&model_view.to_cols_array());
data[transforms + 16..transforms + 32].copy_from_slice(&Mat4::IDENTITY.to_cols_array());
data[transforms + 32..transforms + 36].copy_from_slice(&color);
data[192..196].copy_from_slice(&fog_color);
data[196..202].copy_from_slice(&fog);
let mut bytes: Vec<u8> = bytemuck::cast_slice(&data).to_vec();
bytes[..48].copy_from_slice(&globals);
bytes
}
#[cfg(test)]
mod tests {
use super::*;
/// `buildSkyDisc(16)`: eight triangles from the point above the camera to the rim, which
/// starts and ends at x -512 (cos 180°) and passes through z -512, x 512 and z 512.
#[test]
fn the_disc_is_vanillas_fan_as_triangles() {
let triangles = disc_triangles();
assert_eq!(triangles.len(), 24);
assert!(triangles.chunks(3).all(|t| t[0] == [0.0, 16.0, 0.0]));
let rim: Vec<[f32; 3]> = triangles.chunks(3).map(|t| t[1]).collect();
let near = |a: [f32; 3], b: [f32; 3]| a.iter().zip(b).all(|(x, y)| (x - y).abs() < 1e-3);
assert!(near(rim[0], [-512.0, 16.0, 0.0]));
assert!(near(rim[2], [0.0, 16.0, -512.0]));
assert!(near(rim[4], [512.0, 16.0, 0.0]));
assert!(near(rim[6], [0.0, 16.0, 512.0]));
assert!(near(triangles[23], [-512.0, 16.0, 0.0]));
}
/// The prepared resources (`HORIZON_RESOURCES`, or `.local/horizon-client/<version>`), where
/// vanilla's sky shader and its includes are.
fn resources() -> std::path::PathBuf {
std::env::var_os("HORIZON_RESOURCES")
.map(std::path::PathBuf::from)
.unwrap_or_else(|| {
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client")
.join(horizon_core::VANILLA_VERSION)
})
}
/// Vanilla's `sky.vsh` with a pack's fragment shader that paints `ColorModulator` (the sky
/// colour) where the disc is: looking at the horizon, the top half of the target is the
/// disc, the bottom half stays clear.
#[test]
fn a_pack_sky_shader_paints_the_disc_above_the_horizon() {
let root = resources();
let Ok(vertex) =
std::fs::read_to_string(root.join("assets/minecraft/shaders/core/sky.vsh"))
else {
eprintln!("skipping: no prepared resources at {}", root.display());
return;
};
let include = |id: &str| {
let (namespace, path) = id.split_once(':')?;
std::fs::read_to_string(root.join(format!("assets/{namespace}/{path}"))).ok()
};
let fragment = "#version 330\n#include <minecraft:dynamictransforms.glsl>\n\
layout(location = 0) out vec4 fragColor;\n\
void main() {\n fragColor = ColorModulator;\n}\n";
let program = horizon_shaders::translate_core(&vertex, fragment, &[], &include, &GLUE)
.expect("the sky shaders translate");
let instance = crate::gfx::test_gpu::instance();
let Some((device, queue)) =
pollster::block_on(instance.request_adapter(&Default::default()))
.ok()
.and_then(|adapter| {
pollster::block_on(adapter.request_device(&Default::default())).ok()
})
else {
eprintln!("no GPU: skipping");
return;
};
const SIZE: u32 = 64;
let format = wgpu::TextureFormat::Rgba8Unorm;
let sky = CoreSky::new(&device, format, Some(&program), None).expect("the sky pipeline");
let projection = crate::gfx::world_projection(90.0, 1.0, 2048.0);
let data = uniforms(
[0; 48],
projection,
Mat4::IDENTITY,
[0.25, 0.5, 1.0, 1.0],
[0.0; 4],
[1e6; 6],
);
queue.write_buffer(&sky.disc.as_ref().unwrap().uniform, 0, &data);
let target = |format, usage| {
device.create_texture(&wgpu::TextureDescriptor {
label: None,
size: wgpu::Extent3d {
width: SIZE,
height: SIZE,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | usage,
view_formats: &[],
})
};
let color = target(format, wgpu::TextureUsages::COPY_SRC);
let depth = target(
wgpu::TextureFormat::Depth32Float,
wgpu::TextureUsages::empty(),
);
let read = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: u64::from(SIZE * SIZE * 4),
usage: wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
let mut encoder = device.create_command_encoder(&Default::default());
{
let color_view = color.create_view(&Default::default());
let depth_view = depth.create_view(&Default::default());
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &color_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
view: &depth_view,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(0.0),
store: wgpu::StoreOp::Store,
}),
stencil_ops: None,
}),
..Default::default()
});
sky.draw_disc(&mut pass);
}
encoder.copy_texture_to_buffer(
color.as_image_copy(),
wgpu::TexelCopyBufferInfo {
buffer: &read,
layout: wgpu::TexelCopyBufferLayout {
offset: 0,
bytes_per_row: Some(SIZE * 4),
rows_per_image: Some(SIZE),
},
},
color.size(),
);
queue.submit([encoder.finish()]);
read.slice(..)
.map_async(wgpu::MapMode::Read, |r| r.unwrap());
device.poll(wgpu::PollType::wait_indefinitely()).unwrap();
let pixels = read.slice(..).get_mapped_range().unwrap().to_vec();
let at = |x: usize, y: usize| pixels[(y * 64 + x) * 4..(y * 64 + x) * 4 + 4].to_vec();
// Row 0 is the top: the disc, in the sky colour; the bottom row is below the horizon.
let top = at(32, 4);
assert!(
top.iter()
.zip([64u8, 128, 255, 255])
.all(|(&p, w)| p.abs_diff(w) <= 1),
"{top:?}"
);
assert_eq!(at(32, 60), vec![0, 0, 0, 0]);
}
}
+11 -2
View File
@@ -10,8 +10,8 @@
//! second pass, draws the sections whose box was seen; the others' draws have
//! an instance count of 0.
//!
//! The picture stays the one without culling: the boxes (grown by a block,
//! the farthest a block model reaches out of its cell) are drawn front faces
//! The picture stays the one without culling: the boxes around the mesh's
//! geometry (padded by a block) are drawn front faces
//! only, so a fragment is the box's nearest point on its pixel, and the
//! fragment shader runs only where the depth test passes (forced early), so a
//! section is left out only where all of its fragments would fail the depth
@@ -45,6 +45,15 @@ use std::sync::{
const WORDS: u64 = 5 * 4;
/// A tested section's box, around its origin: its cell grown by a block.
pub const SECTION_BOX: [[f32; 3]; 2] = [[-1.0; 3], [17.0; 3]];
/// Mesh bounds already contain `BOUNDS_PAD`; grow them to a block of padding
/// in total, keeping the box's faces off the geometry. Without mesh bounds,
/// keep the section cell grown by a block, as before.
pub fn section_box(bounds: Option<[glam::Vec3; 2]>) -> [[f32; 3]; 2] {
bounds.map_or(SECTION_BOX, |[low, high]| {
let pad = glam::Vec3::splat(1.0 - crate::mesher::SectionMesh::BOUNDS_PAD);
[(low - pad).to_array(), (high + pad).to_array()]
})
}
/// The bit that marks a far tile's slot (`Renderer::tile_cull_slot`): tiles
/// count their slots apart from the sections' resident ones.
pub const TILE: u32 = 1 << 31;
@@ -16,8 +16,8 @@ struct Globals {
// `place`): the first pass's first draw, both passes' draw counts (the
// second's in the high 16 bits), the second pass's first draw. No draws:
// phase 1 drew it, and the test only tells whether it is still in sight.
// Then its box's lowest and highest corner around the origin (a section's:
// -1 and 17, `SECTION_BOX`).
// Then its box's lowest and highest corner around the origin: a section's
// padded mesh bounds, or -1 and 17 (`SECTION_BOX`) without mesh bounds.
struct Test {
data: vec4<u32>,
low: vec4<f32>,
@@ -53,8 +53,8 @@ fn corner(origin: vec3<f32>, low: vec3<f32>, high: vec3<f32>, c: u32) -> vec3<f3
);
}
// Each tested section's or far tile's box, grown by a block (block models
// reach one block out of their cell), drawn after phase 1 against its depth
// Each tested section's or far tile's geometry box, padded by a block,
// drawn after phase 1 against its depth
// with back faces culled: a front face fragment that passes the depth test
// is the box's nearest point on that pixel in front of phase 1's depth, so
// the section may show there. A box failing everywhere would have every
@@ -33,6 +33,9 @@ struct Uniform {
brightness: f32,
mode: u32,
pad: [u32; 2],
hdr_settings: [f32; 4],
hdr_shares: [f32; 4],
hdr_light: [f32; 4],
}
#[repr(C)]
@@ -45,6 +48,8 @@ struct Vertex {
pub(super) struct CustomSky {
pipelines: Vec<wgpu::RenderPipeline>,
written_gain: Option<f32>,
written_debug: bool,
layout: wgpu::BindGroupLayout,
sampler: wgpu::Sampler,
uniform: wgpu::Buffer,
@@ -136,7 +141,10 @@ impl CustomSky {
});
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Custom sky shader"),
source: wgpu::ShaderSource::Wgsl(include_str!("custom_sky.wgsl").into()),
source: wgpu::ShaderSource::Wgsl(
(include_str!("../hdr_light.wgsl").to_owned() + include_str!("custom_sky.wgsl"))
.into(),
),
});
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Custom sky layout"),
@@ -146,7 +154,11 @@ impl CustomSky {
let attributes = wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x2, 2 => Float32x4];
let pipelines = MODES
.iter()
.map(|&mode| {
.copied()
.map(|mode| (mode, false, false))
.chain((format == super::LINEAR_FRAME).then_some((Blend::Screen, true, false)))
.chain((format == super::LINEAR_FRAME).then_some((Blend::Add, false, true)))
.map(|(mode, written_screen, debug_add)| {
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Custom sky layer"),
layout: Some(&pipeline_layout),
@@ -174,14 +186,31 @@ impl CustomSky {
multisample: Default::default(),
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: Some("fs_custom_sky"),
compilation_options: Default::default(),
entry_point: Some(if debug_add {
"fs_custom_sky_screen_light"
} else {
"fs_custom_sky"
}),
compilation_options: wgpu::PipelineCompilationOptions {
constants: &[(
"HDR_WRITE_LIGHT",
f64::from(u8::from(format == super::LINEAR_FRAME)),
)],
..Default::default()
},
targets: &[Some(wgpu::ColorTargetState {
format,
// The frame's alpha is HDR output's mark (hdr.wgsl): the sky
// under the layers keeps its own.
blend: Some(wgpu::BlendState {
color: blend(mode),
color: if written_screen {
wgpu::BlendComponent {
src_factor: wgpu::BlendFactor::Constant,
..blend(mode)
}
} else {
blend(mode)
},
alpha: wgpu::BlendComponent {
src_factor: wgpu::BlendFactor::Zero,
dst_factor: wgpu::BlendFactor::One,
@@ -215,6 +244,8 @@ impl CustomSky {
});
Self {
pipelines,
written_gain: None,
written_debug: false,
layout,
sampler,
uniform,
@@ -295,7 +326,20 @@ impl CustomSky {
encoder: &mut wgpu::CommandEncoder,
clip: Mat4,
draws: &[Draw],
globals: &super::Globals,
) {
self.written_gain = (globals.hdr_light[3] != 0.0).then(|| {
let mark =
((1.0 - 0.24 * globals.hdr_light[1]).clamp(0.0, 1.0) * 255.0).round() / 255.0;
if globals.hdr_settings[2] > 0.5 && globals.hdr_settings[0] > 1.0 {
(1.0 + (globals.hdr_settings[1] - 1.0) * (1.0 - mark) / 0.24).powf(1.0 / 2.2)
} else {
1.0
}
});
self.written_debug = self.written_gain.is_some()
&& globals.hdr_settings[3] > 0.5
&& globals.hdr_settings[2] > 0.5;
self.frame.clear();
for draw in draws.iter().take(MAX_DRAWS) {
if usize::from(draw.image) >= self.groups.len() {
@@ -307,6 +351,9 @@ impl CustomSky {
brightness: draw.brightness.clamp(0.0, 1.0),
mode: mode as u32,
pad: [0; 2],
hdr_settings: globals.hdr_settings,
hdr_shares: globals.hdr_shares,
hdr_light: globals.hdr_light,
};
let offset = STRIDE * self.frame.len() as u64;
uploads.buffer(encoder, &self.uniform, offset, bytemuck::bytes_of(&uniform));
@@ -323,7 +370,35 @@ impl CustomSky {
pub(super) fn draw(&self, pass: &mut wgpu::RenderPass<'_>) {
pass.set_vertex_buffer(0, self.vertices.slice(..));
for (i, &(image, mode)) in self.frame.iter().enumerate() {
pass.set_pipeline(&self.pipelines[usize::from(mode)]);
let screen_debug = usize::from(mode) == 5 && self.written_debug;
if screen_debug {
// Greyscale debug is not a uniform RGB gain. Attenuate with the original
// source first, then add its converted light, without changing the factor.
pass.set_pipeline(&self.pipelines[4]);
pass.set_bind_group(
0,
&self.groups[usize::from(image)],
&[(STRIDE * i as u64) as u32],
);
pass.draw(0..36, 0..1);
}
let index = if screen_debug {
10
} else if usize::from(mode) == 5 && self.written_gain.is_some() {
9
} else {
usize::from(mode)
};
if let Some(gain) = self.written_gain {
let gain = f64::from(gain);
pass.set_blend_constant(wgpu::Color {
r: gain,
g: gain,
b: gain,
a: 1.0,
});
}
pass.set_pipeline(&self.pipelines[index]);
pass.set_bind_group(
0,
&self.groups[usize::from(image)],
@@ -394,7 +469,10 @@ mod tests {
#[test]
fn the_shader_validates() {
let module = naga::front::wgsl::parse_str(include_str!("custom_sky.wgsl")).unwrap();
let module = naga::front::wgsl::parse_str(
&(include_str!("../hdr_light.wgsl").to_owned() + include_str!("custom_sky.wgsl")),
)
.unwrap();
naga::valid::Validator::new(
naga::valid::ValidationFlags::all(),
naga::valid::Capabilities::all(),
@@ -413,4 +491,259 @@ mod tests {
assert_eq!(v.position.iter().filter(|c| c.abs() == 1.0).count(), 3);
}
}
#[test]
fn written_custom_sky_modes_keep_factors_and_scale_only_screen_source() {
let instance = crate::gfx::test_gpu::instance();
let Ok(adapter) = pollster::block_on(instance.request_adapter(&Default::default())) else {
return;
};
let (device, queue) =
pollster::block_on(adapter.request_device(&Default::default())).unwrap();
let source = include_str!("../hdr_light.wgsl").to_owned()
+ include_str!("custom_sky.wgsl")
+ r#"
@vertex fn test_vertex(@builtin(vertex_index) i: u32) -> Out {
let p = vec2(f32((i << 1u) & 2u), f32(i & 2u));
return Out(vec4(p * 2.0 - 1.0, 0.0, 1.0), vec2(0.5), vec4(0.0, 0.0, 1.0, 1.0));
}
"#;
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: None,
source: wgpu::ShaderSource::Wgsl(source.into()),
});
let sky = CustomSky::new(&device, wgpu::TextureFormat::Rgba16Float);
let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: None,
bind_group_layouts: &[Some(&sky.layout)],
..Default::default()
});
let image = device.create_texture_with_data(
&queue,
&wgpu::TextureDescriptor {
label: None,
size: wgpu::Extent3d {
width: 1,
height: 1,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8Unorm,
usage: wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
},
wgpu::util::TextureDataOrder::LayerMajor,
&[204, 102, 51, 128],
);
let image = image.create_view(&Default::default());
let sampler = device.create_sampler(&Default::default());
let target = device.create_texture(&wgpu::TextureDescriptor {
label: None,
size: wgpu::Extent3d {
width: 1,
height: 1,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba16Float,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC,
view_formats: &[],
});
let view = target.create_view(&Default::default());
// Independent scalar expectation: a sky mark of 206/255 gives this gamma gain.
let hdr_gain = (1.0f32 + 3.0 * (1.0 - 206.0 / 255.0) / 0.24).powf(1.0 / 2.2);
for (mode_index, mode, debug, written) in MODES
.iter()
.copied()
.enumerate()
.map(|(i, m)| (i, m, false, true))
.chain([(5, Blend::Screen, true, true)])
.chain(
MODES
.iter()
.copied()
.enumerate()
.map(|(i, m)| (i, m, false, false)),
)
{
let gain = if written { hdr_gain } else { 1.0 };
let uniform = Uniform {
clip_from_sky: Mat4::IDENTITY.to_cols_array_2d(),
brightness: 0.7,
mode: mode_index as u32,
pad: [0; 2],
hdr_settings: [5.0, 4.0, 1.0, f32::from(u8::from(debug))],
hdr_shares: [0.2, 0.5, 0.6, 1.0],
hdr_light: [0.8, 0.8, 1.0, f32::from(u8::from(written))],
};
let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: None,
contents: bytemuck::bytes_of(&uniform),
usage: wgpu::BufferUsages::UNIFORM,
});
let color = if debug {
blend(Blend::Add)
} else if mode == Blend::Screen {
wgpu::BlendComponent {
src_factor: wgpu::BlendFactor::Constant,
..blend(mode)
}
} else {
blend(mode)
};
let pipeline_for = |entry, color| {
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: None,
layout: Some(&layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: Some("test_vertex"),
compilation_options: Default::default(),
buffers: &[],
},
primitive: Default::default(),
depth_stencil: None,
multisample: Default::default(),
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: Some(entry),
compilation_options: wgpu::PipelineCompilationOptions {
constants: &[("HDR_WRITE_LIGHT", 1.0)],
..Default::default()
},
targets: &[Some(wgpu::ColorTargetState {
format: wgpu::TextureFormat::Rgba16Float,
blend: Some(wgpu::BlendState {
color,
alpha: wgpu::BlendComponent::REPLACE,
}),
write_mask: wgpu::ColorWrites::ALL,
})],
}),
multiview_mask: None,
cache: None,
})
};
let pipeline = pipeline_for(
if debug {
"fs_custom_sky_screen_light"
} else {
"fs_custom_sky"
},
color,
);
let attenuate = debug.then(|| pipeline_for("fs_custom_sky", blend(Blend::Burn)));
let group = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: None,
layout: &sky.layout,
entries: &[
wgpu::BindGroupEntry {
binding: 0,
resource: buffer.as_entire_binding(),
},
wgpu::BindGroupEntry {
binding: 1,
resource: wgpu::BindingResource::TextureView(&image),
},
wgpu::BindGroupEntry {
binding: 2,
resource: wgpu::BindingResource::Sampler(&sampler),
},
],
});
let mut encoder = device.create_command_encoder(&Default::default());
{
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &view,
resolve_target: None,
depth_slice: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color {
r: 2.0,
g: 2.0,
b: 2.0,
a: 1.0,
}),
store: wgpu::StoreOp::Store,
},
})],
..Default::default()
});
let g = f64::from(gain);
pass.set_blend_constant(wgpu::Color {
r: g,
g,
b: g,
a: 1.0,
});
pass.set_bind_group(0, &group, &[0]);
if let Some(attenuate) = &attenuate {
pass.set_pipeline(attenuate);
pass.draw(0..3, 0..1);
}
pass.set_pipeline(&pipeline);
pass.draw(0..3, 0..1);
}
let readback = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: 256,
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ,
mapped_at_creation: false,
});
encoder.copy_texture_to_buffer(
target.as_image_copy(),
wgpu::TexelCopyBufferInfo {
buffer: &readback,
layout: wgpu::TexelCopyBufferLayout {
offset: 0,
bytes_per_row: Some(256),
rows_per_image: None,
},
},
target.size(),
);
queue.submit([encoder.finish()]);
readback.map_async(wgpu::MapMode::Read, .., |r| r.unwrap());
device.poll(wgpu::PollType::wait_indefinitely()).unwrap();
let data = readback.get_mapped_range(..).unwrap();
let got = half::f16::from_le_bytes([data[0], data[1]]).to_f32();
let (d, t, k) = (2.0, 0.8, 128.0 / 255.0 * 0.7);
let alpha = half::f16::from_le_bytes([data[6], data[7]]).to_f32();
let coverage = if mode == Blend::Alpha { k } else { 1.0 };
assert!(
(alpha - coverage).abs() < 0.001,
"{mode:?}: alpha {alpha}, expected {coverage}"
);
let expected = if debug {
let grey = (0.2126f32 * 0.8f32.powf(2.2)
+ 0.7152 * 0.4f32.powf(2.2)
+ 0.0722 * 0.2f32.powf(2.2))
.powf(1.0 / 2.2);
gain * grey * k + d * (1.0 - t * k)
} else {
match mode {
Blend::Add => d + gain * t * k,
Blend::Subtract => d - gain * t * k,
Blend::Multiply => d * (1.0 + (t - 1.0) * k),
Blend::Dodge => d + d * t * k,
Blend::Burn => d * (1.0 - t * k),
Blend::Screen => gain * t * k + d * (1.0 - t * k),
Blend::Replace => gain * t,
Blend::Overlay => 2.0 * d * (0.5 + (t - 0.5) * k),
Blend::Alpha => gain * t * k + d * (1.0 - k),
}
};
assert!(
(got - expected).abs() < 0.004,
"{mode:?} debug {debug}: {got} expected {expected}"
);
}
eprintln!(
"HDR custom sky GPU ran all nine modes with and without gain, plus debug Screen, checking RGB and coverage"
);
}
}
@@ -8,6 +8,10 @@ struct Layer {
brightness: f32,
// horizon_optifine::sky::Blend, in gfx/custom_sky.rs's MODES order.
mode: u32,
pad: vec2<u32>,
hdr_settings: vec4<f32>,
hdr_shares: vec4<f32>,
hdr_light: vec4<f32>,
}
@group(0) @binding(0) var<uniform> layer: Layer;
@group(0) @binding(1) var sky_texture: texture_2d<f32>;
@@ -42,20 +46,34 @@ const REPLACE: u32 = 6u;
const OVERLAY: u32 = 7u;
const ALPHA: u32 = 8u;
@fragment fn fs_custom_sky(in: Out) -> @location(0) vec4<f32> {
fn custom_sky_color(in: Out) -> vec4<f32> {
let half = 0.5 / vec2<f32>(textureDimensions(sky_texture));
let uv = clamp(in.uv, in.cell.xy + half, in.cell.zw - half);
let t = textureSample(sky_texture, sky_sampler, uv);
let k = t.a * layer.brightness;
var color = t.rgb;
if HDR_WRITE_LIGHT && layer.hdr_light.w != 0.0 &&
(layer.mode == ADD || layer.mode == SUBTRACT || layer.mode == REPLACE || layer.mode == ALPHA) {
color = hdr_written(color, 1.0 - 0.24 * layer.hdr_light.y, layer.hdr_settings, layer.hdr_shares);
}
switch layer.mode {
// dst * src: white leaves the sky alone.
case MULTIPLY: { return vec4(mix(vec3(1.0), t.rgb, k), 1.0); }
// 2 * dst * src: grey leaves it alone.
case OVERLAY: { return vec4(mix(vec3(0.5), t.rgb, k), 1.0); }
case REPLACE: { return vec4(t.rgb, 1.0); }
case REPLACE: { return vec4(color, 1.0); }
// mix(dst, src, alpha).
case ALPHA: { return vec4(t.rgb, k); }
case ALPHA: { return vec4(color, k); }
// add, subtract, dodge, burn, screen: the layer premultiplied, black leaves it alone.
default: { return vec4(t.rgb * k, 1.0); }
default: { return vec4(color * k, 1.0); }
}
}
@fragment fn fs_custom_sky(in: Out) -> @location(0) vec4<f32> {
return custom_sky_color(in);
}
@fragment fn fs_custom_sky_screen_light(in: Out) -> @location(0) vec4<f32> {
let color = custom_sky_color(in);
return vec4(hdr_written(color.rgb, 1.0 - 0.24 * layer.hdr_light.y, layer.hdr_settings, layer.hdr_shares), color.a);
}
@@ -12,7 +12,7 @@ use crate::mesher::TerrainVertex;
/// The solid quads the grid can draw a frame, and the sections they come from.
const MAX_QUADS: u64 = 1 << 16;
const MAX_SECTIONS: usize = 64;
pub(crate) const MAX_SECTIONS: usize = 64;
/// Bytes of one quad's corners.
const QUAD_BYTES: u64 = 4 * std::mem::size_of::<TerrainVertex>() as u64;
/// How far past the flat face the relief may reach, in blocks, for the view test.
@@ -413,6 +413,8 @@ pub struct Displacement {
pub shadow: Option<Picks>,
/// Group 1's layout for the grid's pipelines.
pub draw_layout: wgpu::BindGroupLayout,
/// CPU-side section table reused between displacement preparation passes.
table: Vec<Section>,
/// Sections the pick ran over this frame (0: nothing to draw).
pub drawn: usize,
}
@@ -598,6 +600,7 @@ impl Displacement {
view,
shadow,
draw_layout,
table: Vec::new(),
drawn: 0,
}
}
@@ -610,7 +613,8 @@ impl Displacement {
near: &[Near<'_>],
view_proj: glam::Mat4,
) {
let mut table = Vec::with_capacity(near.len().min(MAX_SECTIONS));
self.table.clear();
self.table.reserve(near.len().min(MAX_SECTIONS));
let mut first = 0u64;
let mut most = 0u32;
for n in near.iter().take(MAX_SECTIONS) {
@@ -626,7 +630,7 @@ impl Displacement {
first * QUAD_BYTES,
quads * QUAD_BYTES,
);
table.push(Section {
self.table.push(Section {
origin: [
n.origin[0],
n.origin[1],
@@ -640,11 +644,11 @@ impl Displacement {
first += quads;
most = most.max(quads as u32);
}
self.drawn = table.len();
if table.is_empty() {
self.drawn = self.table.len();
if self.table.is_empty() {
return;
}
queue.write_buffer(&self.sections, 0, bytemuck::cast_slice(&table));
queue.write_buffer(&self.sections, 0, bytemuck::cast_slice(&self.table));
let lists = std::iter::once((&self.view, 0)).chain(self.shadow.iter().map(|s| (s, 1)));
let mut pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor {
label: Some("Displacement pick"),
@@ -655,7 +659,7 @@ impl Displacement {
let params = Params {
view_proj: view_proj.to_cols_array_2d(),
distance: self.distance,
sections: table.len() as u32,
sections: self.table.len() as u32,
margin: RELIEF_MARGIN,
capacity: MAX_QUADS as u32,
shadow,
@@ -665,7 +669,7 @@ impl Displacement {
let vertices = grid_vertices(picks.cells, picks.steps);
queue.write_buffer(&picks.draw, 0, bytemuck::cast_slice(&[vertices, 0, 0, 0]));
pass.set_bind_group(0, &picks.pick_group, &[]);
pass.dispatch_workgroups(most.div_ceil(64), table.len() as u32, 1);
pass.dispatch_workgroups(most.div_ceil(64), self.table.len() as u32, 1);
}
}
+17 -2
View File
@@ -106,6 +106,8 @@ pub struct Flat {
phase2_calls: wgpu::Buffer,
phase2_call_capacity: u64,
phase2_call_data: Vec<[u32; 5]>,
/// GPU culling's phase 2 uses indirect draws; flat draws without culling do not.
indirect_execution: bool,
/// The copy of phase 2's draws, and its ranges.
phase2_group: Option<(wgpu::BindGroup, u32)>,
/// The layout of a page's bind group 1 (shader packs' terrain pipelines share it).
@@ -365,6 +367,7 @@ impl Flat {
terrain_layout: &wgpu::BindGroupLayout,
page_vertices: u64,
min_sections: usize,
indirect_execution: bool,
pipeline: impl Fn(
&wgpu::PipelineLayout,
&str,
@@ -489,10 +492,16 @@ impl Flat {
device,
"Flat section draw calls, phase 2",
20,
wgpu::BufferUsages::INDIRECT | storage_usage,
storage_usage
| if indirect_execution {
wgpu::BufferUsages::INDIRECT
} else {
wgpu::BufferUsages::empty()
},
),
phase2_call_capacity: 1,
phase2_call_data: Vec::new(),
indirect_execution,
phase2_group: None,
draw_layout,
blocks_per_page: page_vertices.div_ceil(GRAIN),
@@ -645,6 +654,7 @@ impl Flat {
timing: Option<&mut super::pack_timing::PassTiming>,
) -> bool {
self.phase2_group = None;
let phase2 = phase2.filter(|_| self.indirect_execution);
let phase1_draws = if phase2.is_some() {
phase1_draws
} else {
@@ -753,7 +763,12 @@ impl Flat {
device,
"Flat section draw calls, phase 2",
self.phase2_call_capacity * 20,
wgpu::BufferUsages::INDIRECT | wgpu::BufferUsages::STORAGE,
wgpu::BufferUsages::STORAGE
| if self.indirect_execution {
wgpu::BufferUsages::INDIRECT
} else {
wgpu::BufferUsages::empty()
},
);
}
if phase2_calls > 0 {
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,65 @@
// The light of colour `f` under the world's mark `a` (the alpha the world left, hdr_mark) where
// the world `shows`, else the colour clipped at white; and whether a light source lifted it.
// `eased` for the last pass, which eases it into the peak itself; the layered frame leaves that
// to the tone curve (fs_tonemap).
struct ReferenceLit {
light: vec3<f32>,
lifted: bool,
};
fn reference_lit(f: vec3<f32>, a: f32, shows: bool, eased: bool) -> ReferenceLit {
var lifted = false;
// Light over 1 (a float frame's) shows only where the world does and carries
// no mark (alpha 1), up to the peak: light written as light. Marked pixels clip
// at white before their lift, as on a unorm frame, so light sources, the sun and
// HDR lighting look as they do there; so do the HUD, menus and HDR Lighting off.
let c = select(min(f, vec3(1.0)), f, shows && a == 1.0);
// Gamma 2.2, as SDR displays and the compositors' SDR paths decode it.
var light = pow(c, vec3(2.2));
// HDR lighting: alpha between 0.76 and 1 is how much of it the surface gets. Vanilla's
// light is albedo times lightmap, so this is the lightmap going past 1. It eases into the
// peak from 60% of it, so bright textures keep their detail. Unmarked light (alpha 1)
// gets no gain and no knee: the clamp to the peak below is all it needs here.
if shows && a >= 0.75 && a < 1.0 {
let top = max(light.r, max(light.g, light.b));
let gain = 1.0 + (params.scene - 1.0) * (1.0 - a) / 0.24;
let v = top * gain;
let knee = max(0.6 * params.peak, 1.0);
var out = v;
if eased && v > knee && params.peak > knee {
out = knee + (params.peak - knee) * (1.0 - exp(-(v - knee) / (params.peak - knee)));
}
light *= select(gain, out / max(top, 1e-4), eased && v > knee);
}
// The world's alpha is below 0.75 on light sources, the sun and the moon
// (terrain.wgsl, entity.wgsl): its band of 0.175 is the tier, the lower the
// brighter, and where in the band how much (hdr_mark).
if shows && a < 0.75 {
let band = u32(clamp(floor((a + 0.005) / 0.175), 0.0, 3.0));
let tier = 3u - band;
let lift = 1.0 - clamp((a - 0.175 * f32(band)) / 0.165, 0.0, 1.0);
if lift > 0.0 {
let top = max(light.r, max(light.g, light.b));
var gain = 1.0 + (params.peak - 1.0) * params.share[tier] * lift;
if eased {
gain = min(gain, params.peak / max(top, 1e-4));
}
light *= max(gain, 1.0);
lifted = true;
}
}
// HORIZON_HDR_DEBUG=1: what isn't lifted turns grey, what is keeps its
// colour with a magenta tint, so a lift shows on any colour.
if params.debug > 0.5 && params.world > 0.5 {
if lifted {
light *= vec3(1.0, 0.6, 1.0);
} else {
light = vec3(dot(light, vec3(0.2126, 0.7152, 0.0722)));
}
}
if eased {
light = min(light, vec3(params.peak));
}
return ReferenceLit(light, lifted);
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,335 @@
//! A held world (`WorldHold`, the native hook `native_world_hold`): the terrain goes on being
//! drawn as it stands while what changes under it is meshed, and all of it takes its place on
//! one frame. A section already on screen that is meshed again is uploaded to the arena as ever,
//! over as many frames as its mesh takes to come, but waits beside the mesh drawn (`Hold`);
//! letting go only swaps which of the two is drawn, with nothing left to upload. Sections not on
//! screen yet (terrain streaming in) are not held.
//!
//! Both meshes of a waiting section are in memory, so a hold costs up to what the changed land's
//! new meshes come to. It is bounded, and each bound lets go at once rather than losing anything:
//! `MAX_BYTES` of waiting meshes, `MAX_HOLD` of time, and the arena running out
//! (`Renderer::upload`). It never outlives what asked for it: the mods are asked every frame,
//! and the sections' being cleared (the world left, another dimension) drops what waits. A hold
//! that ended by itself (spent) stays ended until no mod has asked for a frame.
use super::SectionKey;
use crate::fast_hash::{FxHashMap, FxHashSet};
use std::time::{Duration, Instant};
/// The longest a hold lasts.
pub(super) const MAX_HOLD: Duration = Duration::from_secs(30);
/// The most bytes of new meshes that wait.
pub(super) const MAX_BYTES: u64 = 1 << 30;
/// The most circles a hold is kept to (`WorldHold::hold_within`).
pub const MAX_AREAS: usize = 64;
/// What the mods ask of the terrain's picture this frame (`native_world_hold`): nothing, all of
/// it held, or only the sections inside some circles. Several mods add up: one holding all of it
/// holds all of it, and circles join.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct WorldHold {
all: bool,
within: Vec<[f64; 3]>,
}
impl WorldHold {
/// Hold the whole world's terrain as it is drawn, this frame.
pub fn hold(&mut self) {
self.all = true;
}
/// Hold the sections whose middle lies within `radius` blocks of (`x`, `z`), this frame. A
/// circle that isn't finite or has a negative radius is left out, as are those past
/// `MAX_AREAS`.
pub fn hold_within(&mut self, x: f64, z: f64, radius: f64) {
let good = x.is_finite() && z.is_finite() && radius.is_finite() && radius >= 0.0;
if good && self.within.len() < MAX_AREAS {
self.within.push([x, z, radius]);
}
}
/// Whether anything is held.
pub fn is_held(&self) -> bool {
self.all || !self.within.is_empty()
}
/// Whether section `key` is in what is held: all of the world, or a circle its middle lies in.
pub fn covers(&self, key: SectionKey) -> bool {
if self.all {
return true;
}
let (x, z) = (f64::from(key.0) * 16.0 + 8.0, f64::from(key.2) * 16.0 + 8.0);
self.within
.iter()
.any(|&[cx, cz, r]| (x - cx).powi(2) + (z - cz).powi(2) <= r * r)
}
}
/// What a frame's ask means for the sections waiting.
#[derive(Debug, PartialEq, Eq)]
pub(super) enum Release {
/// They go on waiting.
None,
/// Those the hold no longer covers take their place.
Outside,
/// All of them take their place.
All,
}
/// A section waiting behind the hold and the bytes its new mesh takes.
struct Waiting<S> {
section: S,
bytes: u64,
}
/// The renderer's side of a hold: whether it is on, what it covers, and the sections waiting.
pub(super) struct Hold<S> {
ask: WorldHold,
since: Option<Instant>,
spent: bool,
waiting: FxHashMap<SectionKey, Waiting<S>>,
bytes: u64,
}
impl<S> Default for Hold<S> {
fn default() -> Self {
Self {
ask: WorldHold::default(),
since: None,
spent: false,
waiting: FxHashMap::default(),
bytes: 0,
}
}
}
impl<S> Hold<S> {
/// Whether a new mesh of section `key` waits.
pub fn holds(&self, key: SectionKey) -> bool {
self.since.is_some() && !self.spent && self.ask.covers(key)
}
pub fn is_empty(&self) -> bool {
self.waiting.is_empty()
}
pub fn bytes(&self) -> u64 {
self.bytes
}
/// A frame's ask, at `now`.
pub fn ask(&mut self, ask: &WorldHold, now: Instant) -> Release {
if !ask.is_held() {
let was = self.since.is_some();
(self.since, self.spent) = (None, false);
self.ask = WorldHold::default();
return if was && !self.waiting.is_empty() {
Release::All
} else {
Release::None
};
}
if self.spent {
return Release::None;
}
let since = *self.since.get_or_insert(now);
if now.saturating_duration_since(since) >= MAX_HOLD {
log::warn!(
"Horizon: a mod held the world for {} s: let go",
MAX_HOLD.as_secs()
);
self.spend();
return Release::All;
}
if *ask == self.ask {
return Release::None;
}
// (fewer circles or smaller: some of what waits is let go; more: nothing waits that didn't)
self.ask.clone_from(ask);
if self.waiting.is_empty() {
Release::None
} else {
Release::Outside
}
}
/// Ended by itself: nothing waits from now on, until no mod has asked for a frame.
/// What waited is the caller's to place (`take_all`) or drop.
pub fn spend(&mut self) {
self.spent = self.since.is_some();
}
/// Section `key`'s new mesh waits: the one that waited before for it comes back, to free.
/// The bool is whether what waits is now too much (`MAX_BYTES`).
pub fn wait(&mut self, key: SectionKey, section: S, bytes: u64) -> (Option<S>, bool) {
let old = self.take(key);
self.bytes += bytes;
self.waiting.insert(key, Waiting { section, bytes });
(old, self.bytes > MAX_BYTES)
}
/// Section `key`'s waiting mesh, no longer waiting.
pub fn take(&mut self, key: SectionKey) -> Option<S> {
if self.waiting.is_empty() {
return None;
}
let w = self.waiting.remove(&key)?;
self.bytes -= w.bytes;
Some(w.section)
}
/// Everything waiting, no longer waiting.
pub fn take_all(&mut self) -> Vec<(SectionKey, S)> {
self.bytes = 0;
self.waiting.drain().map(|(k, w)| (k, w.section)).collect()
}
/// What waits that the hold no longer covers.
pub fn take_outside(&mut self) -> Vec<(SectionKey, S)> {
let ask = &self.ask;
let all = self.since.is_none() || self.spent;
let out: Vec<_> = self
.waiting
.extract_if(|&k, _| all || !ask.covers(k))
.collect();
self.bytes -= out.iter().map(|(_, w)| w.bytes).sum::<u64>();
out.into_iter().map(|(k, w)| (k, w.section)).collect()
}
/// What waits in these columns, which are going.
pub fn take_columns(&mut self, columns: &FxHashSet<(i32, i32)>) -> Vec<S> {
if self.waiting.is_empty() {
return Vec::new();
}
let out: Vec<_> = self
.waiting
.extract_if(|k, _| columns.contains(&(k.0, k.2)))
.collect();
self.bytes -= out.iter().map(|(_, w)| w.bytes).sum::<u64>();
out.into_iter().map(|(_, w)| w.section).collect()
}
/// The sections are all gone: what waits goes with them and the hold is spent.
pub fn clear(&mut self) {
self.waiting.clear();
self.bytes = 0;
self.spend();
}
pub fn sections(&self) -> impl Iterator<Item = &S> {
self.waiting.values().map(|w| &w.section)
}
pub fn sections_mut(&mut self) -> impl Iterator<Item = &mut S> {
self.waiting.values_mut().map(|w| &mut w.section)
}
}
#[cfg(test)]
mod tests {
use super::*;
fn all() -> WorldHold {
let mut h = WorldHold::default();
h.hold();
h
}
fn within(circles: &[[f64; 3]]) -> WorldHold {
let mut h = WorldHold::default();
for &[x, z, r] in circles {
h.hold_within(x, z, r);
}
h
}
#[test]
fn a_hold_covers_sections_by_their_middle() {
assert!(all().covers((900, 0, -900)));
assert!(!WorldHold::default().covers((0, 0, 0)));
assert!(within(&[[8.0, 8.0, 1.0]]).covers((0, 3, 0)));
assert!(!within(&[[0.0, 0.0, 11.0]]).covers((0, 3, 0)));
assert!(within(&[[0.0, 0.0, 12.0]]).covers((0, 3, 0)));
assert!(within(&[[1000.0, 0.0, 1.0], [24.0, 8.0, 0.5]]).covers((1, 0, 0)));
assert!(within(&[[-8.0, -8.0, 0.0]]).covers((-1, 0, -1)));
}
#[test]
fn bad_circles_are_left_out_and_there_are_at_most_max_areas() {
let h = within(&[
[f64::NAN, 0.0, 5.0],
[0.0, f64::INFINITY, 5.0],
[0.0, 0.0, -1.0],
[0.0, 0.0, f64::INFINITY],
]);
assert!(!h.is_held());
let mut many = WorldHold::default();
for i in 0..MAX_AREAS + 10 {
many.hold_within(i as f64 * 100.0, 0.0, 1.0);
}
assert_eq!(many.within.len(), MAX_AREAS);
// (several mods: all of it from one holds all of it)
many.hold();
assert!(many.covers((-5000, 0, 5000)));
}
#[test]
fn a_hold_starts_and_lets_go_when_no_one_asks() {
let (mut g, t) = (Hold::<u32>::default(), Instant::now());
assert_eq!(g.ask(&WorldHold::default(), t), Release::None);
assert!(!g.holds((0, 0, 0)));
assert_eq!(g.ask(&all(), t), Release::None);
assert!(g.holds((0, 0, 0)));
assert_eq!(g.ask(&all(), t + Duration::from_secs(5)), Release::None);
// (nothing waited: nothing to place)
assert_eq!(g.ask(&WorldHold::default(), t), Release::None);
g.ask(&all(), t);
g.wait((0, 0, 0), 7, 100);
assert_eq!(g.ask(&WorldHold::default(), t), Release::All);
assert_eq!(g.take_all(), vec![((0, 0, 0), 7)]);
assert!(!g.holds((0, 0, 0)));
}
#[test]
fn a_hold_ends_by_itself_and_stays_ended_until_let_go() {
let (mut g, t) = (Hold::<u32>::default(), Instant::now());
g.ask(&all(), t);
assert_eq!(g.ask(&all(), t + MAX_HOLD), Release::All);
assert!(!g.holds((0, 0, 0)));
assert_eq!(g.ask(&all(), t + MAX_HOLD * 2), Release::None);
assert!(!g.holds((0, 0, 0)));
g.ask(&WorldHold::default(), t + MAX_HOLD * 2);
g.ask(&all(), t + MAX_HOLD * 3);
assert!(g.holds((0, 0, 0)));
}
#[test]
fn smaller_circles_let_go_what_they_leave() {
let (mut g, t) = (Hold::<u32>::default(), Instant::now());
g.ask(&within(&[[0.0, 0.0, 100.0]]), t);
assert!(g.holds((0, 0, 0)) && g.holds((5, 0, 0)) && !g.holds((7, 0, 0)));
g.wait((0, 0, 0), 1, 10);
g.wait((5, 0, 0), 2, 20);
assert_eq!(g.ask(&within(&[[0.0, 0.0, 100.0]]), t), Release::None);
assert_eq!(g.ask(&within(&[[0.0, 0.0, 40.0]]), t), Release::Outside);
assert_eq!(g.take_outside(), vec![((5, 0, 0), 2)]);
assert_eq!((g.sections().count(), g.bytes()), (1, 10));
assert!(!g.holds((5, 0, 0)));
// (to all of it again: nothing more is let go, and all of it waits again)
assert_eq!(g.ask(&all(), t), Release::Outside);
assert!(g.take_outside().is_empty());
assert!(g.holds((5, 0, 0)));
}
#[test]
fn what_waits_is_counted_and_capped() {
let (mut g, t) = (Hold::<u32>::default(), Instant::now());
g.ask(&all(), t);
assert_eq!(g.wait((0, 0, 0), 1, MAX_BYTES - 10), (None, false));
// (a newer mesh of the same section replaces it, and the old one comes back to free)
assert_eq!(g.wait((0, 0, 0), 2, MAX_BYTES - 20), (Some(1), false));
assert_eq!(g.bytes(), MAX_BYTES - 20);
assert_eq!(g.wait((1, 0, 0), 3, 20), (None, false));
assert_eq!(g.wait((2, 0, 0), 4, 1), (None, true));
assert_eq!(g.take((1, 0, 0)), Some(3));
assert_eq!(g.take((1, 0, 0)), None);
assert_eq!(g.bytes(), MAX_BYTES - 19);
}
#[test]
fn columns_going_and_the_sections_cleared_drop_what_waits() {
let (mut g, t) = (Hold::<u32>::default(), Instant::now());
g.ask(&all(), t);
g.wait((0, 0, 0), 1, 10);
g.wait((0, 5, 0), 2, 10);
g.wait((3, 0, 0), 3, 10);
let gone: FxHashSet<(i32, i32)> = [(0, 0)].into_iter().collect();
let mut dropped = g.take_columns(&gone);
dropped.sort_unstable();
assert_eq!(dropped, vec![1, 2]);
assert_eq!((g.sections().count(), g.bytes()), (1, 10));
g.clear();
assert!(g.is_empty() && g.bytes() == 0 && !g.holds((3, 0, 0)));
// (cleared while held: spent until let go; with no hold, nothing to end)
assert_eq!(g.ask(&all(), t), Release::None);
assert!(!g.holds((3, 0, 0)));
let mut none = Hold::<u32>::default();
none.clear();
none.ask(&all(), t);
assert!(none.holds((3, 0, 0)));
}
}
@@ -3,17 +3,11 @@
pub(crate) const FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::R8Unorm;
pub(crate) fn supported(
lane: (bool, bool, bool),
hdr_offered: bool,
attachments: u32,
flags: wgpu::DownlevelFlags,
format: wgpu::TextureFormatFeatures,
) -> bool {
!lane.0
&& lane.1
&& lane.2
&& hdr_offered
&& attachments >= 2
attachments >= 2
&& flags.contains(wgpu::DownlevelFlags::INDEPENDENT_BLEND)
&& format
.allowed_usages
@@ -345,37 +339,17 @@ mod tests {
use super::*;
#[test]
fn coverage_requires_the_no_pack_float_hdr_lane_and_independent_r8_blending() {
fn coverage_requires_two_attachments_and_independent_r8_blending() {
let flags = wgpu::DownlevelFlags::INDEPENDENT_BLEND;
let format = wgpu::TextureFormatFeatures {
allowed_usages: wgpu::TextureUsages::RENDER_ATTACHMENT
| wgpu::TextureUsages::TEXTURE_BINDING,
flags: wgpu::TextureFormatFeatureFlags::BLENDABLE,
};
let lane = (false, true, true);
assert!(supported(lane, true, 2, flags, format));
// Switch unset (including legacy 16-bit HDR and 0.1 packs), HDR off, a 0.2
// pack's float frame, and unsupported devices never allocate coverage.
for other in [
(false, false, true),
(true, false, true),
(true, true, true),
(false, true, false),
] {
assert!(!supported(other, true, 2, flags, format));
}
assert!(!supported(lane, false, 2, flags, format));
assert!(!supported(lane, true, 1, flags, format));
assert!(supported(2, flags, format));
assert!(!supported(1, flags, format));
assert!(!supported(2, wgpu::DownlevelFlags::empty(), format));
assert!(!supported(
lane,
true,
2,
wgpu::DownlevelFlags::empty(),
format
));
assert!(!supported(
lane,
true,
2,
flags,
wgpu::TextureFormatFeatures {
@@ -384,8 +358,6 @@ mod tests {
}
));
assert!(!supported(
lane,
true,
2,
flags,
wgpu::TextureFormatFeatures {
@@ -393,6 +365,14 @@ mod tests {
..format
}
));
assert!(!supported(
2,
flags,
wgpu::TextureFormatFeatures {
allowed_usages: wgpu::TextureUsages::RENDER_ATTACHMENT,
..format
}
));
}
#[test]
@@ -446,7 +426,7 @@ mod tests {
#[test]
fn coverage_wraps_the_debug_crosshair_without_changing_world_entry_points() {
let mut module = naga::front::wgsl::parse_str(include_str!("../terrain.wgsl")).unwrap();
let mut module = naga::front::wgsl::parse_str(&crate::gfx::terrain_shader()).unwrap();
wrap(
&mut module,
"fs_debug_line",
@@ -98,8 +98,24 @@ fn interfaces(source: &str) -> Vec<Interface> {
/// The shaders as the renderer assembles them, by the `.wgsl` files each is made of.
fn composed() -> Vec<(&'static str, Vec<&'static str>, String)> {
let entity = crate::overlay::wgsl_constants() + include_str!("../entity.wgsl");
let entity = super::entity_shader();
vec![
(
"HDR",
vec!["hdr.wgsl", "hdr_light.wgsl"],
super::hdr::shader(),
),
("terrain", vec!["terrain.wgsl"], super::terrain_shader()),
(
"stars",
vec!["stars.wgsl"],
include_str!("../hdr_light.wgsl").to_owned() + include_str!("stars.wgsl"),
),
(
"custom sky",
vec!["custom_sky.wgsl"],
include_str!("../hdr_light.wgsl").to_owned() + include_str!("custom_sky.wgsl"),
),
("entity", vec!["entity.wgsl"], entity.clone()),
(
"GPU culling occlusion test",
@@ -124,14 +140,14 @@ fn composed() -> Vec<(&'static str, Vec<&'static str>, String)> {
(
"improved transparency world",
vec!["terrain.wgsl", "oit.wgsl", "oit_world.wgsl"],
include_str!("../terrain.wgsl").to_owned()
super::terrain_shader()
+ include_str!("../oit.wgsl")
+ include_str!("../oit_world.wgsl"),
),
(
"visibility buffer",
vec!["terrain.wgsl", "visbuffer.wgsl"],
include_str!("../terrain.wgsl").to_owned() + include_str!("../visbuffer.wgsl"),
super::terrain_shader() + include_str!("../visbuffer.wgsl"),
),
(
"improved transparency world border",
+21 -15
View File
@@ -50,8 +50,10 @@ impl Pending {
}
}
/// Small, its meshes boxed: `draw_frame` walks every tile each frame (thousands at long far
/// distances), and that walk is bound by the memory it reads.
pub(super) struct Tile {
pub mesh: SectionGpu,
pub mesh: Box<SectionGpu>,
bounds: Bounds,
/// When it began to fade in; none while the rest of its job uploads.
shown: Option<Instant>,
@@ -62,7 +64,7 @@ pub(super) struct Tile {
/// Its mesh before near chunks took some of its columns, drawn in its
/// place until they have faded in (from the job's end, the instant), so
/// no hole shows through them.
previous: Option<(SectionGpu, Option<Instant>)>,
previous: Option<Box<(SectionGpu, Option<Instant>)>>,
/// Its slot in occlusion culling's results (`cull::TILE`), kept while
/// meshes of the same tile replace one another.
pub cull_slot: u32,
@@ -155,10 +157,12 @@ pub(super) struct Visible {
impl Tile {
/// The mesh drawn this frame: the previous one while it stands in.
pub fn drawn(&self) -> &SectionGpu {
self.previous.as_ref().map_or(&self.mesh, |(mesh, _)| mesh)
self.previous
.as_deref()
.map_or(&self.mesh, |(mesh, _)| mesh)
}
pub fn drawn_mut(&mut self) -> &mut SectionGpu {
match &mut self.previous {
match self.previous.as_deref_mut() {
Some((mesh, _)) => mesh,
None => &mut self.mesh,
}
@@ -177,7 +181,7 @@ impl Tile {
}
/// Both meshes it holds in the arena: its own and the stand-in, if any.
pub fn meshes_mut(&mut self) -> impl Iterator<Item = &mut SectionGpu> {
std::iter::once(&mut self.mesh).chain(self.previous.as_mut().map(|(mesh, _)| mesh))
std::iter::once(&mut *self.mesh).chain(self.previous.as_deref_mut().map(|(mesh, _)| mesh))
}
pub fn visible(
&self,
@@ -214,12 +218,12 @@ impl Renderer {
let (shown, previous) = match self.lods.remove(&key) {
Some(old) if old.dying.is_none() => match old.previous {
Some(previous) => {
self.release_mesh(old.mesh);
self.release_mesh(*old.mesh);
(old.shown, Some(previous))
}
None if keep => (old.shown, Some((old.mesh, None))),
None if keep => (old.shown, Some(Box::new((*old.mesh, None)))),
None => {
self.release_mesh(old.mesh);
self.release_mesh(*old.mesh);
(old.shown, None)
}
},
@@ -240,7 +244,7 @@ impl Renderer {
self.lods.insert(
key,
Tile {
mesh,
mesh: Box::new(mesh),
bounds,
shown,
dying: None,
@@ -251,7 +255,7 @@ impl Renderer {
);
}
None => {
if let Some((previous, _)) = previous {
if let Some((previous, _)) = previous.map(|p| *p) {
self.release_mesh(previous);
}
self.lod_cull_free.extend(old_slot);
@@ -260,8 +264,8 @@ impl Renderer {
}
fn release_tile(&mut self, tile: Tile) {
self.release_mesh(tile.mesh);
if let Some((previous, _)) = tile.previous {
self.release_mesh(*tile.mesh);
if let Some((previous, _)) = tile.previous.map(|p| *p) {
self.release_mesh(previous);
}
}
@@ -337,8 +341,10 @@ impl Renderer {
let stood_in: Vec<_> = self
.lods
.values_mut()
.filter_map(|tile| match tile.previous {
Some((_, Some(since))) if start - since >= FADE => tile.previous.take(),
.filter_map(|tile| match tile.previous.as_deref() {
Some((_, Some(since))) if start - *since >= FADE => {
tile.previous.take().map(|p| *p)
}
_ => None,
})
.collect();
@@ -440,7 +446,7 @@ impl Renderer {
if tile.shown.is_none() {
tile.shown = Some(if over_replaced(key) { start } else { whole });
}
if let Some((_, since)) = &mut tile.previous {
if let Some((_, since)) = tile.previous.as_deref_mut() {
since.get_or_insert(start);
}
}
@@ -49,9 +49,23 @@ struct HorizonMaterialOut {
@location(14) @interpolate(flat) normal: vec3<f32>,
}
fn horizon_material_vertex(position: vec3<f32>, uv: vec2<f32>, layer: u32, color: vec4<f32>,
light: vec2<u32>, origin: vec3<f32>) -> HorizonMaterialOut {
let pos = horizon_material_displace(position + origin, uv, layer, color, light);
return horizon_material_out(pos, uv, layer, color, vec2<f32>(light));
light: vec2<u32>, origin: vec4<f32>) -> HorizonMaterialOut {
let pos = horizon_material_displace(position + origin.xyz, uv, layer, color, light);
var out = horizon_material_out(pos, uv, layer, color, vec2<f32>(light));
// The section's fade-in (`RenderSection.getVisibility`), as how far it is from whole, in the
// high 16 bits of `hdr_code`: no varying of its own, and 0 (whole) where nothing fades. It is
// the same for the whole section, so the flat varying loses nothing.
let instance = horizon_terrain_instance_visibility(origin.w);
out.hdr_code |= u32(round((1.0 - instance) * 65535.0)) << 16u;
return out;
}
// terrain.wgsl's fade-in (terrain.vsh's chunkVisibility): whole within 16 blocks, the section's
// own visibility from 32 out, toward the fog colour, alpha kept. The distance blend runs here on
// the interpolated distance, as vanilla's interpolated `visibility`, not once per triangle.
fn horizon_material_faded(in: HorizonMaterialOut, color: vec4<f32>) -> vec4<f32> {
let instance = 1.0 - f32(in.hdr_code >> 16u) / 65535.0;
let visibility = mix(1.0, instance, clamp((in.spherical - 16.0) / 16.0, 0.0, 1.0));
return vec4(mix(horizon_terrain_globals.fog_color.rgb, color.rgb, visibility), color.a);
}
// `light`: sky, block, 16 per level.
fn horizon_material_out(pos: vec3<f32>, uv: vec2<f32>, layer: u32, color: vec4<f32>,
@@ -94,7 +108,7 @@ fn horizon_material_out(pos: vec3<f32>, uv: vec2<f32>, layer: u32, color: vec4<f
@location(2) layer: u32, @location(3) color: vec4<f32>, @location(4) light: vec2<u32>,
@location(5) origin: vec4<f32>) -> HorizonMaterialOut {
return horizon_material_vertex(position, horizon_terrain_terrain_uv(uv, origin.w), layer,
color, light, origin.xyz);
color, light, origin);
}
@vertex fn horizon_material_vs_flat(
@builtin(vertex_index) vertex: u32,
@@ -103,7 +117,7 @@ fn horizon_material_out(pos: vec3<f32>, uv: vec2<f32>, layer: u32, color: vec4<f
) -> HorizonMaterialOut {
let origin = horizon_terrain_slot_origins[horizon_terrain_block_slots[vertex >> 8u]];
return horizon_material_vertex(position, horizon_terrain_terrain_uv(uv, origin.w), layer,
color, light, origin.xyz);
color, light, origin);
}
// The prelude's `block_normal_map` and `block_specular_map`: the resource packs' LabPBR maps
// in the pack's frame group (3), one array each, a blank 1x1 without them.
@@ -181,9 +195,11 @@ struct HorizonMaterialSolid {
// What `fs_solid` leaves in the frame's alpha for HDR output, from the sprite before the pack's
// material: the pack decides the colour, Horizon still knows which pixels are light sources.
fn horizon_material_mark(in: HorizonMaterialOut, texel: vec4<f32>) -> f32 {
if in.hdr_code > 0u {
let whole = in.hdr_code > 4u;
let tier = select(in.hdr_code, in.hdr_code - 4u, whole);
if horizon_terrain_HDR_WRITE_LIGHT { return 1.0; }
let code = in.hdr_code & 15u;
if code > 0u {
let whole = code > 4u;
let tier = select(code, code - 4u, whole);
let l = in.layer & 0x7fffu;
let t = textureLoad(horizon_terrain_emission_thresholds,
vec2(i32(l % horizon_terrain_SPRITE_SPLIT), i32(l / horizon_terrain_SPRITE_SPLIT)), 0);
@@ -202,7 +218,7 @@ fn horizon_material_mark(in: HorizonMaterialOut, texel: vec4<f32>) -> f32 {
return horizon_material_solid(in);
}
fn horizon_material_solid(in: HorizonMaterialOut) -> HorizonMaterialSolid {
let color = horizon_material_color(in, false);
let color = horizon_material_faded(in, horizon_material_color(in, false));
let texel = horizon_terrain_sprite(in.uv, in.layer & 0x7fffu);
// Bit 15 of the layer marks opaque leaves (forceOpaque): no alpha cutout.
if color.a < 0.5 && (in.layer & 0x8000u) == 0u { discard; }
@@ -216,7 +232,7 @@ fn horizon_material_solid(in: HorizonMaterialOut) -> HorizonMaterialSolid {
return out;
}
@fragment fn horizon_material_fs_translucent(in: HorizonMaterialOut) -> @location(0) vec4<f32> {
let color = horizon_material_color(in, true);
let color = horizon_material_faded(in, horizon_material_color(in, true));
if color.a < 0.01 { discard; }
return horizon_material_fogged(color, in.spherical, in.cylindrical);
}
@@ -294,7 +310,8 @@ pub struct NativeMaterial {
/// every name it declares prefixed.
fn vanilla_terrain() -> String {
prefixed(
section(TERRAIN, "struct Globals {", "// Sky (SkyRenderer)"),
&(include_str!("../hdr_light.wgsl").to_owned()
+ section(TERRAIN, "struct Globals {", "// Sky (SkyRenderer)")),
PREFIX,
)
}
@@ -416,6 +433,10 @@ impl NativeMaterial {
];
constants.extend(sprite_names.into_iter().zip(shape.sprites));
constants.push(("horizon_material_fog", f64::from(u8::from(fog))));
constants.push((
"horizon_terrain_HDR_WRITE_LIGHT",
f64::from(u8::from(shape.format == super::LINEAR_FRAME)),
));
constants.push((
"horizon_displace_distance",
displaced.map_or(0.0, |d| f64::from(d.distance)),
@@ -564,6 +585,39 @@ impl NativeMaterial {
}
}
#[cfg(test)]
pub(super) fn coverage_test_shader(api: horizon_shader_api::Api) -> String {
use horizon_shader_api::{MANIFEST, Pack, StageKind, check};
let manifest = format!(
"schema = 1\nid = \"coverage\"\nname = \"Coverage\"\nversion = \"1\"\napi = \"{api}\"\n[material]\nfile = \"material.wgsl\"\n[displacement]\n"
);
let material = "fn material(input: MaterialInput) -> Surface { return Surface(vec4<f32>(1.4, 0.3, 0.1, 0.7)); }\nfn displacement(input: DisplacementInput) -> f32 { return 0.0; }\n";
let files = [(MANIFEST, manifest.as_str()), ("material.wgsl", material)]
.map(|(n, text)| (n.to_owned(), text.as_bytes().to_vec()))
.into();
let report = check(&Pack::from_files(files).unwrap()).unwrap();
let stage = report
.stages
.iter()
.find(|s| s.kind == StageKind::Material)
.unwrap();
shader_source(&stage.source, &[], &[], (false, true), api)
+ r#"
override TEST_TIER: u32 = 0u;
override TEST_OVERLAY: u32 = 0u;
@vertex fn test_vertex(@builtin(vertex_index) i: u32) -> HorizonMaterialOut {
var o: HorizonMaterialOut;
o.clip = vec4(vec2(f32((i << 1u) & 2u), f32(i & 2u)) * 2.0 - 1.0, 0.0, 1.0);
o.uv = vec2(0.5);
o.tint = vec4(1.0);
o.lightmap = vec3(1.0);
o.hdr_code = TEST_TIER;
o.base = vec3(1.0);
return o;
}
"#
}
#[cfg(test)]
mod tests {
use super::*;
@@ -582,6 +636,25 @@ mod tests {
report.stages.remove(0)
}
/// The fade-in packed above the HDR code: a section a quarter visible (`section_instance`
/// with step 1: mantissa `1 - visibility` = 0.75) keeps its visibility through the code, and
/// a fragment 24 blocks away, half-way into the 16-block blend, is 1 - (1 - 0.25) / 2 = 0.625
/// visible; the code's low nibble survives.
#[test]
fn the_fade_in_rides_the_hdr_code() {
let w = f32::from_bits(1.0f32.to_bits() | (0.75 * 8_388_608.0) as u32);
// `horizon_material_vertex`.
let instance = 1.0 - (w.to_bits() & 0x7fffff) as f32 / 8_388_608.0;
let code = 7u32 | (((1.0 - instance) * 65535.0).round() as u32) << 16;
// `horizon_material_faded` and `horizon_material_mark`.
let unpacked = 1.0 - (code >> 16) as f32 / 65535.0;
assert!((unpacked - 0.25).abs() < 1.0 / 65535.0);
let blend = ((24.0f32 - 16.0) / 16.0).clamp(0.0, 1.0);
let visibility = 1.0 + (unpacked - 1.0) * blend;
assert!((visibility - 0.625).abs() < 1.0 / 65535.0);
assert_eq!(code & 15, 7);
}
#[test]
fn the_terrain_takes_a_prefix_and_validates_with_a_pack() {
let terrain = vanilla_terrain();
@@ -73,10 +73,15 @@ pub struct WorldDrawn<'a> {
pub entities: &'a [Vertex],
pub spans: &'a [EntitySpan],
/// Which entity each run of `entities` is, recorded every frame (`Frame::entity_motion`):
/// the run's first vertex and the entity, `(1 << 32) | id` for a mob or a player and
/// `(2 << 32) | id` for a dropped item (their entity ids), 0 for anything else. A run lasts
/// until the next. Unlike `spans`, whose ids name a type, these follow one entity from
/// frame to frame (API 371).
/// the run's first vertex and the entity, `(1 << 32) | id` for a mob or a player,
/// `(2 << 32) | id` for a dropped item, `(3 << 32) | id` for another entity (boat,
/// minecart, armor stand, item frame, painting, primed TNT, falling block) and
/// `(4 << 32) | id` for an item frame's held item (their entity ids), `(5 << 32) | p` for a
/// block entity (`p`: its position, x and z in 11 bits each, y in 10), `(6 << 32) | p`
/// for a block a piston moves (`p`: the cell it moves to), `7 << 32` for the player's own
/// model, 0 for anything else.
/// A run lasts until the next. Unlike `spans`, whose ids name a type, these follow one
/// entity from frame to frame (API 371).
pub motion: &'a [(u32, u64)],
/// The shared atlas entity UVs point into.
pub atlas: Option<&'a wgpu::Texture>,
@@ -512,7 +512,8 @@ fn shader_source(
format!(
"{head}// Horizon's terrain (terrain.wgsl)\n{}{solid}{}{displace}{ENTRIES}",
prefixed(
section(TERRAIN, "struct Globals {", "// Sky (SkyRenderer)"),
&(include_str!("../hdr_light.wgsl").to_owned()
+ section(TERRAIN, "struct Globals {", "// Sky (SkyRenderer)")),
PREFIX
),
super::native_post::line_helpers(api)
@@ -30,6 +30,7 @@ pub struct NativeSky {
/// terrain.wgsl's sky with every name it declares (and `globals`) prefixed.
fn vanilla_sky() -> String {
let text = [
include_str!("../hdr_light.wgsl"),
section(TERRAIN, "struct Globals {", "@group(0) @binding(1)"),
section(TERRAIN, "fn linear_fog(", "fn apply_fog("),
section(TERRAIN, "struct SkyOut {", "// rendertype_lines"),
+22 -5
View File
@@ -192,7 +192,7 @@ impl Oit {
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Horizon improved transparency"),
source: wgpu::ShaderSource::Wgsl(
(include_str!("../terrain.wgsl").to_owned()
(super::terrain_shader()
+ include_str!("../oit.wgsl")
+ include_str!("../oit_world.wgsl"))
.into(),
@@ -253,7 +253,14 @@ impl Oit {
..Default::default()
})
};
let constants = [("SPRITE_ARRAYS", sprites[0]), ("SPRITE_SPLIT", sprites[1])];
let constants = [
("SPRITE_ARRAYS", sprites[0]),
("SPRITE_SPLIT", sprites[1]),
(
"HDR_WRITE_LIGHT",
f64::from(u8::from(format == super::LINEAR_FRAME)),
),
];
let add = wgpu::BlendOperation::Add;
let depth = |write| {
Some(wgpu::DepthStencilState {
@@ -464,7 +471,10 @@ impl Oit {
fragment: Some(wgpu::FragmentState {
module: &cloud_shader,
entry_point: Some(fragment),
compilation_options: Default::default(),
compilation_options: wgpu::PipelineCompilationOptions {
constants: &constants[2..],
..Default::default()
},
targets: &stage_targets(stage),
}),
multiview_mask: None,
@@ -488,7 +498,14 @@ impl Oit {
Stage::Accumulate,
),
];
let features = Features::new(device, &layouts, features[0], features[1], features[2]);
let features = Features::new(
device,
&layouts,
features[0],
features[1],
features[2],
format,
);
Self {
uniform,
layouts,
@@ -912,7 +929,7 @@ mod tests {
#[test]
fn the_terrain_shader_validates() {
validate(
&(include_str!("../terrain.wgsl").to_owned()
&(crate::gfx::terrain_shader()
+ include_str!("../oit.wgsl")
+ include_str!("../oit_world.wgsl")),
&[
@@ -55,6 +55,7 @@ impl Features {
entity: &wgpu::BindGroupLayout,
weather: &wgpu::BindGroupLayout,
border: &wgpu::BindGroupLayout,
format: wgpu::TextureFormat,
) -> Self {
let entity_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Horizon improved transparency features"),
@@ -113,6 +114,15 @@ impl Features {
bind_group_layouts: &[groups[0], groups[1], Some(&layouts[stage as usize])],
..Default::default()
});
let fragment = if kind.label == "text" && stage == Stage::Accumulate {
"fs_oit_text_accumulate".to_owned()
} else {
format!("fs_oit_{}_{suffix}", kind.name)
};
let constants = [(
"HDR_WRITE_LIGHT",
f64::from(u8::from(format == super::LINEAR_FRAME)),
)];
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some(&format!("OIT {} {suffix}", kind.label)),
layout: Some(&layout),
@@ -136,8 +146,15 @@ impl Features {
multisample: Default::default(),
fragment: Some(wgpu::FragmentState {
module,
entry_point: Some(&format!("fs_oit_{}_{suffix}", kind.name)),
compilation_options: Default::default(),
entry_point: Some(&fragment),
compilation_options: wgpu::PipelineCompilationOptions {
constants: if kind.name == "border" {
&[]
} else {
&constants
},
..Default::default()
},
targets: &stage_targets(stage),
}),
multiview_mask: None,
@@ -728,6 +728,13 @@ impl PackAtlas {
),
("mc_Entity", entity),
("at_midBlock", mid_block),
// Horizon's own: the face's HDR tier (`mesher::emitting`'s code in the colour's low
// alpha nibble): 0 for none, 1 to 4 for low to very bright, plus 4 when the whole
// face shines (`mesher::WHOLE`).
(
"horizonTier",
"float(15u - (uint(round(hz_v_color.a * 255.0)) & 15u))",
),
(
"mc_midTexCoord",
"vec4((hz_cell + hz_mid) * hz_scale, 0.0, 1.0)",
@@ -750,6 +757,7 @@ impl PackAtlas {
alpha_test: None,
item_id_declared: false,
far_depth: false,
paged_maps: false,
}
}
}
@@ -157,6 +157,7 @@ fn terrain_fade_reaches_pack_pixels_through_real_instances() {
flat,
geometry,
origin,
0x80ffffff,
);
let fade = if requested { expected } else { 1.0 };
let expected = [
@@ -182,6 +183,96 @@ fn terrain_fade_reaches_pack_pixels_through_real_instances() {
assert_eq!(count, 98);
}
/// `horizonTier`: the HDR tier the mesher marks a light source's faces with (`mesher::emitting`),
/// read by a pack's terrain program, flat or instanced.
#[test]
fn terrain_tier_reaches_pack_pixels() {
let instance = crate::gfx::test_gpu::instance();
let adapter = match pollster::block_on(instance.request_adapter(&Default::default())) {
Ok(adapter) => adapter,
Err(error) => {
eprintln!("SKIP terrain tier GPU control: no adapter: {error}");
return;
}
};
let (device, queue) = pollster::block_on(adapter.request_device(&Default::default())).unwrap();
let array = device.create_texture(&wgpu::TextureDescriptor {
label: None,
size: wgpu::Extent3d {
width: 2,
height: 2,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8Unorm,
usage: wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
});
let mut encoder = device.create_command_encoder(&Default::default());
let atlas = PackAtlas::new(&device, &mut encoder, &[array], 1, 1, 2).unwrap();
queue.submit([encoder.finish()]);
let folder = ProbePack(
std::env::temp_dir().join(format!("horizon-terrain-tier-{}", std::process::id())),
);
std::fs::create_dir_all(folder.0.join("shaders")).unwrap();
std::fs::write(
folder.0.join("shaders/gbuffers_terrain.vsh"),
"#version 330\nin float horizonTier;\nout vec4 observation;\n\
void main() {\nobservation = vec4(horizonTier, 0.0, 0.0, 0.0);\n\
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n}",
)
.unwrap();
std::fs::write(
folder.0.join("shaders/gbuffers_terrain.fsh"),
"#version 330\nin vec4 observation;\nlayout(location = 0) out uvec4 pixel;\n\
void main() { pixel = floatBitsToUint(observation); }",
)
.unwrap();
let pack = horizon_shaders::Pack::open(&folder.0).unwrap();
let mut macros = horizon_shaders::Macros::standard();
let (properties, _) = horizon_shaders::read_properties(&pack, &mut macros);
use crate::mesher::{BRIGHT, LOW, VERY_BRIGHT, WHOLE, emitting};
// No light, low, very bright, and bright all over (4 more).
let cases = [
(0, 0.0),
(LOW, 1.0),
(VERY_BRIGHT, 4.0),
(BRIGHT | WHOLE, 7.0),
];
for flat in [false, true] {
let post = horizon_shaders::load_post(
&pack,
"",
&properties,
&macros,
&horizon_shaders::GameInputs {
terrain: Some(atlas.terrain_inputs(flat)),
..Default::default()
},
);
let program = post
.terrain
.as_ref()
.unwrap_or_else(|| panic!("{:?}", post.notes));
for (tier, expected) in cases {
let origin = section_instance([0.0; 3], 0, 1.0);
let pixel = sample(
&device,
&queue,
&atlas,
program.program.as_ref().unwrap(),
flat,
false,
origin,
emitting(0xffff_ffff, tier),
);
assert_eq!(pixel[0], expected, "tier {tier} flat={flat}");
}
}
}
fn sample(
device: &wgpu::Device,
queue: &wgpu::Queue,
@@ -190,6 +281,7 @@ fn sample(
flat: bool,
geometry: bool,
origin: [f32; 4],
color: u32,
) -> [f32; 4] {
let buffer = |bytes: &[u8], usage| {
device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
@@ -209,7 +301,7 @@ fn sample(
let slots = buffer(bytemuck::bytes_of(&0u32), wgpu::BufferUsages::STORAGE);
let vertices: Vec<_> = [[0., 0., 0.], [1., 0., 0.], [1., 1., 0.], [0., 1., 0.]]
.into_iter()
.map(|pos| TerrainVertex::new(pos, [0.25, 0.75], 0, 0x80ffffff, 0))
.map(|pos| TerrainVertex::new(pos, [0.25, 0.75], 0, color, 0))
.collect();
let data = buffer(
bytemuck::cast_slice(&vertices),
@@ -107,6 +107,10 @@ pub fn inputs() -> horizon_shaders::GbuffersInputs {
"at_velocity",
"hz_velocity(gbufferModelView, gbufferPreviousModelView)",
),
// Horizon's own, as for terrain: the HDR tier of a light-giving item, particle or glowing
// text (`mesher::hdr_tier`, the overlay's high bits), 0 for none, 1 to 4 for low to very
// bright.
("horizonTier", "float((hz_v_overlay >> 16u) & 255u)"),
];
horizon_shaders::GbuffersInputs {
declarations,
@@ -123,6 +127,8 @@ pub fn inputs() -> horizon_shaders::GbuffersInputs {
}),
item_id_declared: false,
far_depth: false,
// Entities, items and block entities read the shared atlas: its own maps (paged_maps.rs).
paged_maps: true,
}
}
@@ -186,6 +192,7 @@ pub fn cloud_inputs() -> horizon_shaders::GbuffersInputs {
alpha_test: None,
item_id_declared: false,
far_depth: false,
paged_maps: false,
}
}
@@ -1628,3 +1635,44 @@ mod velocity_translate_tests {
let _ = std::fs::remove_dir_all(&dir);
}
}
#[cfg(test)]
mod tier_translate_tests {
/// A pack's entity and hand programs may read `horizonTier`, the overlay's HDR tier.
#[test]
fn a_pack_reading_horizon_tier_translates_for_entities_and_the_hand() {
let dir = std::env::temp_dir().join(format!("hz-entity-tier-{}", std::process::id()));
let shaders = dir.join("shaders");
std::fs::create_dir_all(&shaders).unwrap();
std::fs::write(
shaders.join("gbuffers_entities.vsh"),
"#version 120\nattribute float horizonTier;\nvarying float t;\n\
void main() {\n gl_Position = ftransform();\n t = horizonTier;\n}\n",
)
.unwrap();
std::fs::write(
shaders.join("gbuffers_entities.fsh"),
"#version 120\nvarying float t;\nvoid main() {\n gl_FragData[0] = vec4(t);\n}\n",
)
.unwrap();
let pack = horizon_shaders::Pack::open(&dir).unwrap();
let m = horizon_shaders::Macros::standard();
let vsh = horizon_shaders::preprocess(&pack, "gbuffers_entities.vsh", &m);
let fsh = horizon_shaders::preprocess(&pack, "gbuffers_entities.fsh", &m);
for (who, inputs) in [
("entities", super::inputs()),
("hand", super::super::pack_hand::inputs()),
] {
let attribute = inputs.attributes.iter().find(|(n, _)| n == "horizonTier");
assert!(attribute.is_some(), "{who}");
horizon_shaders::translate_gbuffers(
&vsh,
&fsh,
horizon_shaders::Target::Buffers,
&inputs,
)
.unwrap_or_else(|e| panic!("{who}: {e:?}"));
}
let _ = std::fs::remove_dir_all(&dir);
}
}
@@ -82,6 +82,9 @@ pub(super) fn format(f: Format, packed_float: bool) -> wgpu::TextureFormat {
_ => rgba,
};
match (f.kind, f.bits) {
(Kind::Unorm, 10) => T::Rgb10a2Unorm,
(Kind::Uint, 10) => T::Rgb10a2Uint,
(Kind::Snorm, 16) => pick(T::R16Snorm, T::Rg16Snorm, T::Rgba16Snorm),
(Kind::Int, 8) => pick(T::R8Sint, T::Rg8Sint, T::Rgba8Sint),
(Kind::Int, 16) => pick(T::R16Sint, T::Rg16Sint, T::Rgba16Sint),
(Kind::Int, _) => pick(T::R32Sint, T::Rg32Sint, T::Rgba32Sint),
@@ -52,6 +52,7 @@ pub fn inputs() -> horizon_shaders::GbuffersInputs {
alpha_test: None,
item_id_declared: false,
far_depth: false,
paged_maps: false,
}
}
@@ -0,0 +1,207 @@
//! Paged maps (`paged_maps.rs`) through the translator's `hz_pagedTexture` and the pass's
//! binding: a pack reads the map's texels at the colour's coordinates.
use super::*;
use wgpu::util::DeviceExt;
/// The atlas the fixture's coordinates are in, and the one mapped texture's place.
const ATLAS: (u32, u32) = (64, 32);
const SPRITE: [u32; 4] = [20, 4, 20, 20];
/// The fixture's normal map texel at texel (x, y) of its texture.
fn texel(x: u32, y: u32) -> [u8; 4] {
[x as u8 * 10, y as u8 * 10, 7, 255]
}
#[test]
#[ignore = "requires a host GPU; missing adapter is a failure"]
fn a_pack_reads_paged_maps_at_the_colours_coordinates() {
let instance = crate::gfx::test_gpu::instance();
let adapter = pollster::block_on(instance.request_adapter(&Default::default())).unwrap();
let (device, queue) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor {
required_limits: adapter.limits(),
..Default::default()
}))
.unwrap();
let root = std::env::temp_dir().join(format!("horizon-paged-pack-{}", std::process::id()));
std::fs::create_dir_all(root.join("shaders")).unwrap();
std::fs::write(
root.join("shaders/gbuffers_terrain.vsh"),
"#version 120\nvoid main(){gl_Position=gl_Vertex;}",
)
.unwrap();
// Each pixel reads one atlas texel's centre: in the texture (on four pages), beside it,
// on a page without maps, and the specular map, which no texture has.
std::fs::write(
root.join("shaders/gbuffers_terrain.fsh"),
r#"#version 120
uniform sampler2D normals;
uniform sampler2D specular;
vec2 at(float x, float y) { return (vec2(x, y) + 0.5) / vec2(64.0, 32.0); }
void main() {
int x = int(floor(gl_FragCoord.x));
if (x == 0) gl_FragData[0] = texture2D(normals, at(20.0, 4.0));
else if (x == 1) gl_FragData[0] = texture2D(normals, at(39.0, 23.0));
else if (x == 2) gl_FragData[0] = texture2D(normals, at(31.0, 15.0), 2.0);
else if (x == 3) gl_FragData[0] = texture2DLod(normals, at(32.0, 16.0), 3.0);
else if (x == 4) gl_FragData[0] = texture2D(normals, at(19.0, 4.0));
else if (x == 5) gl_FragData[0] = texture2D(normals, at(50.0, 30.0));
else if (x == 6) gl_FragData[0] = texture2D(specular, at(25.0, 10.0));
else gl_FragData[0] = texture2D(normals, at(33.0, 5.0));
}
"#,
)
.unwrap();
let [x0, y0, w, h] = SPRITE;
let normal: Vec<u8> = (0..w * h).flat_map(|i| texel(i % w, i / w)).collect();
let [normals, specular] = crate::paged_maps::build(
ATLAS,
&[crate::paged_maps::SpriteMaps {
rect: SPRITE,
maps: [Some(normal), None],
}],
16384,
);
assert!(specular.is_none());
let normals = normals.unwrap();
let map = device
.create_texture_with_data(
&queue,
&wgpu::TextureDescriptor {
label: Some("Fixture paged normal map"),
size: wgpu::Extent3d {
width: normals.width,
height: normals.height,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8Unorm,
usage: wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
},
wgpu::util::TextureDataOrder::LayerMajor,
&normals.pixels,
)
.create_view(&Default::default());
let pack = horizon_shaders::Pack::open(&root).unwrap();
let macros = horizon_shaders::Macros::standard();
let properties = horizon_shaders::Properties::parse("alphaTest.gbuffers_terrain=off", &macros);
let inputs = horizon_shaders::GameInputs {
terrain: Some(horizon_shaders::GbuffersInputs {
body: "vec2 p = vec2(float((gl_VertexIndex << 1) & 2), float(gl_VertexIndex & 2)); hz_Vertex=vec4(p*2.0-1.0,0.0,1.0);".into(),
paged_maps: true,
..Default::default()
}),
..Default::default()
};
let post = horizon_shaders::load_post(&pack, "", &properties, &macros, &inputs);
assert!(post.terrain.is_some(), "{:?}", post.notes);
let world = World {
sprite_rects: &[],
atlas: None,
material_maps: None,
lightmap: map.clone(),
terrain: Some(Geometry {
buffers: &[],
table: None,
depth_write: true,
atlas: None,
material_maps: false,
ids: None,
cull: false,
}),
block_ids: &[],
celestial: None,
gui_size: [1, 1],
clouds: None,
weather: false,
hand: false,
};
let mut post = PackPost::new(
&device,
&queue,
&adapter,
post,
wgpu::TextureFormat::Rgba8Unorm,
world,
&Default::default(),
)
.expect("the pack runs");
let mut pass = post
.terrain
.take()
.unwrap_or_else(|| panic!("terrain pipeline must compile: {:?}", post.notes));
// As the entity passes are (`paged`), with the maps the renderer hands over.
pass.paged = true;
post.set_paged_maps([Some(map), None]);
post.copied |= 1;
post.resize(&device, [8, 1]);
let read = device.create_buffer(&wgpu::BufferDescriptor {
label: None,
size: 256,
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ,
mapped_at_creation: false,
});
let mut encoder = device.create_command_encoder(&Default::default());
{
let _clear = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("Initialize fixture depth"),
color_attachments: &[],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
view: &post.targets.as_ref().unwrap().depth,
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
store: wgpu::StoreOp::Store,
}),
stencil_ops: None,
}),
..Default::default()
});
}
let group = post.bind(&device, &queue, &mut encoder, &mut pass, [8, 1]);
{
let mut render = post.begin(&mut encoder, &pass);
render.set_pipeline(pass.render());
render.set_bind_group(0, &group, &[]);
if pass.draw {
post.draws.bind(&mut render, "TERRAIN_SOLID");
}
render.draw(0..3, 0..1);
}
let output = post.targets.as_ref().unwrap().color[0].as_ref().unwrap()[0].texture();
encoder.copy_texture_to_buffer(
output.as_image_copy(),
wgpu::TexelCopyBufferInfo {
buffer: &read,
layout: wgpu::TexelCopyBufferLayout {
bytes_per_row: Some(256),
..Default::default()
},
},
wgpu::Extent3d {
width: 8,
height: 1,
depth_or_array_layers: 1,
},
);
queue.submit([encoder.finish()]);
read.slice(..).map_async(wgpu::MapMode::Read, |_| {});
device.poll(wgpu::PollType::wait_indefinitely()).unwrap();
let data = read.slice(..).get_mapped_range().unwrap();
let local = |x: u32, y: u32| texel(x - x0, y - y0);
let expected = [
local(20, 4),
local(39, 23),
local(31, 15),
local(32, 16),
crate::sprites::FLAT_NORMAL,
crate::sprites::FLAT_NORMAL,
crate::sprites::NO_SPECULAR,
local(33, 5),
];
for (i, e) in expected.iter().enumerate() {
assert_eq!(&data[i * 4..i * 4 + 4], e, "pixel {i}");
}
std::fs::remove_dir_all(root).unwrap();
}
@@ -61,6 +61,9 @@ mod shadow_faces_tests;
#[cfg(test)]
mod r11f_image_tests;
#[cfg(test)]
mod work_group_fold_tests;
#[cfg(test)]
mod forced_flip_tests;
@@ -430,6 +433,9 @@ struct Pass {
/// What `texture` reads instead of the block atlas.
atlas: Option<wgpu::TextureView>,
material_maps: bool,
/// Draws the shared atlas's geometry: `normals` and `specular` are its paged maps
/// (`PackPost::set_paged_maps`), as its programs were translated to read them.
paged: bool,
/// Reads `mc_Entity`'s table (`PackPost::block_ids`).
ids: bool,
/// Bind groups by the sides read (bits 0–15), the buffers whose mip chain is current (bits
@@ -674,6 +680,8 @@ pub struct PackPost {
custom: horizon_shaders::Custom,
atlas: Option<wgpu::TextureView>,
material_maps: Option<[wgpu::TextureView; 2]>,
/// The shared atlas's normal and specular paged maps (`set_paged_maps`).
paged_maps: [Option<wgpu::TextureView>; 2],
lightmap: wgpu::TextureView,
deferred_pre: u16,
composite_pre: u16,
@@ -2179,6 +2187,7 @@ fn build_pass(
draw,
atlas: geometry.and_then(|g| g.atlas.clone()),
material_maps: geometry.is_some_and(|g| g.material_maps),
paged: false,
ids: geometry.is_some_and(|g| g.ids.is_some()),
groups: HashMap::new(),
portal_groups: HashMap::new(),
@@ -2319,6 +2328,7 @@ fn build_compute(
draw: false,
atlas: None,
material_maps: false,
paged: false,
ids: false,
groups: HashMap::new(),
portal_groups: HashMap::new(),
@@ -2357,6 +2367,13 @@ impl Refused {
}
impl PackPost {
/// The shared atlas's normal and specular paged maps (`paged_maps.rs`), which the programs
/// drawing its geometry read as `normals` and `specular`; set before the first frame (a pass's
/// bind groups are kept once made). A missing one reads as the dummy (flat, no specular).
pub fn set_paged_maps(&mut self, maps: [Option<wgpu::TextureView>; 2]) {
self.paged_maps = maps;
}
/// Builds the pipelines of `post` for a screen of `screen` format. An error when the pack
/// can't show anything on the screen: the game turns it off, as a pack that fails to load.
///
@@ -2447,6 +2464,12 @@ impl PackPost {
let textures = pack_textures::upload(device, queue, post.textures, &mut notes);
let shadow_config = post.config.shadow.clone();
let noise_size = post.config.noise_resolution.unwrap_or(256);
let half_lives = post.config.half_lives;
for (name, ticks) in horizon_shaders::HALF_LIVES.iter().zip(half_lives) {
if let Some(t) = ticks {
notes.push(format!("`{name}` is {t} ticks"));
}
}
// shadowcolor2 to 7 only for a pack that names `HIGHER_SHADOWCOLOR`.
let shadow_colors = (1u16 << post.shadow_colors) - 1;
let mut custom = post.custom;
@@ -2780,6 +2803,13 @@ impl PackPost {
ids: None,
cull: false,
});
// Programs drawing the shared atlas's geometry read its paged maps (`pack_entities::inputs`).
let paged = |pass: Option<Pass>| {
pass.map(|mut pass| {
pass.paged = true;
pass
})
};
let entity_passes = programs.map(|p| {
p.zip(entity_geometry.as_ref()).and_then(|(p, g)| {
if p.name == "gbuffers_damagedblock" {
@@ -2792,15 +2822,15 @@ impl PackPost {
ids: g.ids,
cull: false,
};
build(p, Some(&decal))
paged(build(p, Some(&decal)))
} else {
build(p, Some(g))
paged(build(p, Some(g)))
}
})
});
let shadow_entities = shadow_programs.map(|p| {
p.zip(entity_geometry.as_ref())
.and_then(|(p, g)| build(p, Some(g)))
.and_then(|(p, g)| paged(build(p, Some(g))))
});
let entities = entity_vertices
.filter(|_| (entity_passes.iter().chain(&shadow_entities)).any(Option::is_some))
@@ -2843,7 +2873,7 @@ impl PackPost {
ids: None,
cull: false,
};
build(p, Some(&g)).map(|pass| (pass, geometry))
paged(build(p, Some(&g))).map(|pass| (pass, geometry))
});
// Translucent held items, drawn from the hand's own buffer.
let hand_water = post.hand_water.and_then(|p| {
@@ -2857,7 +2887,7 @@ impl PackPost {
ids: None,
cull: false,
};
build(p, Some(&g))
paged(build(p, Some(&g)))
});
let weather = post
.weather
@@ -3296,6 +3326,7 @@ impl PackPost {
custom,
atlas: world.atlas.as_ref().map(|a| a.0.clone()),
material_maps: world.material_maps,
paged_maps: [None, None],
lightmap: world.lightmap,
deferred_pre: mask(&post.deferred_pre),
composite_pre: mask(&post.composite_pre),
@@ -3418,6 +3449,7 @@ impl PackPost {
let mut u = FrameUniforms::default();
u.atlas = world.atlas.map_or([0; 2], |a| a.1);
u.shadow = shadow_config;
u.half_lives = half_lives;
u
},
shadow_cache: Default::default(),
@@ -3656,6 +3688,12 @@ impl PackPost {
Source::Dummy if s.dimension == wgpu::TextureViewDimension::D1 => {
&self.dummy_1d
}
Source::Normals if pass.paged => {
self.paged_maps[0].as_ref().unwrap_or(&self.dummy_normal)
}
Source::Specular if pass.paged => {
self.paged_maps[1].as_ref().unwrap_or(&self.dummy_black)
}
Source::Normals => self
.material_maps
.as_ref()
@@ -3756,6 +3794,16 @@ impl PackPost {
[n(0), n(1), 1]
});
let (pipeline, groups) = (pipeline.clone(), groups);
// wgpu panics on a dispatch over its limit. The translator reshapes a large
// `workGroups`; a `workGroupsRender` that large is not run.
let most = device.limits().max_compute_workgroups_per_dimension;
if groups.iter().any(|&n| n > most) {
log::warn!(
"shader pack: {}: {groups:?} work groups is over {most} per dimension; not run",
pass.name
);
return;
}
for image in (0..self.images.len()).filter(|k| pass.snapshots & 1 << k != 0) {
pack_images::snapshot(encoder, &self.images[image]);
}
@@ -6256,6 +6304,34 @@ mod tests {
);
}
#[test]
fn an_image_is_made_in_its_layout_qualifiers_format() {
// `image.x = … RGB10_A2 …` read through `layout(rgb10_a2) image2D x`.
for q in [
"rgba32f",
"rgba16f",
"rg16f",
"r11f_g11f_b10f",
"r32f",
"rgba16",
"rgb10_a2",
"rgba8",
"rg8",
"r16",
"rgba16_snorm",
"rgba8_snorm",
"r8_snorm",
"rgba32i",
"r16i",
"rgb10_a2ui",
"rgba8ui",
"r32ui",
] {
let def = Format::parse(q).unwrap();
assert_eq!(Some(pack_images::format(def, true)), image_format(q), "{q}");
}
}
#[test]
fn samplers_read_custom_textures_of_their_type() {
use wgpu::TextureSampleType as T;
@@ -6301,6 +6377,10 @@ mod destination_tests;
#[path = "pack_material_tests.rs"]
mod material_tests;
#[cfg(test)]
#[path = "pack_paged_maps_tests.rs"]
mod paged_maps_tests;
#[cfg(test)]
mod rgb_alpha_tests;
@@ -322,7 +322,7 @@ fn check(sampler: &str, stage: Stage, scene: Scene, expected: [u8; 4]) {
let hand = matches!(scene, Scene::Terrain { hand: true, .. });
let water = matches!(scene, Scene::Terrain { water: true, .. } | Scene::WaterOnly);
let inputs=horizon_shaders::GameInputs {
terrain:terrain.then(|| horizon_shaders::GbuffersInputs { declarations:"layout(location=0)in vec3 fixture_position;\n".into(),body:"hz_Vertex=vec4(fixture_position,1.0);hz_Color=vec4(1.0);hz_MultiTexCoord0=vec4(0.0);hz_MultiTexCoord1=vec4(240.0);hz_MultiTexCoord2=vec4(240.0);hz_Normal=vec3(0.0,0.0,1.0);\n".into(),attributes:vec![],after:String::new(),alpha_test:None,item_id_declared:false,far_depth:false }),
terrain:terrain.then(|| horizon_shaders::GbuffersInputs { declarations:"layout(location=0)in vec3 fixture_position;\n".into(),body:"hz_Vertex=vec4(fixture_position,1.0);hz_Color=vec4(1.0);hz_MultiTexCoord0=vec4(0.0);hz_MultiTexCoord1=vec4(240.0);hz_MultiTexCoord2=vec4(240.0);hz_Normal=vec3(0.0,0.0,1.0);\n".into(),attributes:vec![],after:String::new(),alpha_test:None,item_id_declared:false,far_depth:false,paged_maps:false }),
hand:hand.then(crate::gfx::pack_hand::inputs),..Default::default()
};
let mut post = gpu.load(
@@ -719,6 +719,7 @@ fn shadow_depth_map_reads(
alpha_test: None,
item_id_declared: false,
far_depth: false,
paged_maps: false,
}),
..Default::default()
};
@@ -46,6 +46,7 @@ fn pack() -> Post {
terrain: Some(horizon_shaders::GbuffersInputs {
item_id_declared: false,
far_depth: false,
paged_maps: false,
declarations: "layout(location=0)in vec3 fixture_position;\n".into(),
body: "hz_Vertex=vec4(fixture_position,1.0);hz_Color=vec4(1.0);\
hz_MultiTexCoord0=vec4(0.0);hz_MultiTexCoord1=vec4(240.0);\
@@ -0,0 +1,57 @@
//! A `workGroups` over wgpu's 65535 per dimension runs, and its programs read the work group
//! built-ins of the dispatch they declared. The programs are original.
use super::destination_tests::Fixture;
use super::*;
use std::io::{Cursor, Write};
fn pack() -> Post {
let mut zip = zip::ZipWriter::new(Cursor::new(Vec::new()));
let mut add = |name: &str, source: &str| {
zip.start_file(
format!("shaders/{name}"),
zip::write::SimpleFileOptions::default(),
)
.unwrap();
zip.write_all(source.as_bytes()).unwrap();
};
// 70000 x 1 x 2 groups; the last 64 of the second layer each paint one pixel, green when
// the built-ins agree with that dispatch.
add(
"composite.csh",
"#version 430\nlayout(local_size_x=1) in;\nconst ivec3 workGroups=ivec3(70000,1,2);\n\
layout(rgba8) writeonly uniform image2D colorimg0;\n\
void main() {\n uint first = 70000u - 64u;\n\
if (gl_WorkGroupID.z != 1u || gl_WorkGroupID.x < first) return;\n\
uint k = gl_WorkGroupID.x - first;\n\
bool ok = gl_WorkGroupID.y == 0u && gl_NumWorkGroups == uvec3(70000u, 1u, 2u)\n\
&& gl_GlobalInvocationID == gl_WorkGroupID;\n\
imageStore(colorimg0, ivec2(k % 8u, k / 8u), ok ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1));\n}\n",
);
add(
"final.vsh",
"#version 120\nvarying vec2 uv;\nvoid main() { uv=gl_MultiTexCoord0.xy; gl_Position=ftransform(); }\n",
);
add(
"final.fsh",
"#version 330 compatibility\nuniform sampler2D colortex0;\nin vec2 uv;\n\
void main() { gl_FragColor = texelFetch(colortex0, ivec2(gl_FragCoord.xy), 0); }\n",
);
let pack =
horizon_shaders::Pack::from_zip_bytes("original-fold", zip.finish().unwrap().into_inner())
.unwrap();
let mut macros = horizon_shaders::Macros::standard();
let (properties, _) = horizon_shaders::read_properties(&pack, &mut macros);
horizon_shaders::load_post(&pack, "", &properties, &macros, &Default::default())
}
#[test]
fn a_dispatch_over_the_limit_reads_its_declared_work_groups() {
let Some(gpu) = Fixture::new() else { return };
let post = pack();
assert!(post.notes.is_empty(), "{:?}", post.notes);
let mut post = gpu.build(post);
let pixels = gpu.render(&mut post, [8, 8]);
for (k, got) in pixels.iter().enumerate() {
assert_eq!(*got, [0, 255, 0, 255], "pixel {k}; notes {:?}", post.notes);
}
}
@@ -104,6 +104,7 @@ pub fn inputs() -> horizon_shaders::GbuffersInputs {
alpha_test: None,
item_id_declared: false,
far_depth: true,
paged_maps: false,
}
}
@@ -131,6 +132,7 @@ pub fn celestial_inputs() -> horizon_shaders::GbuffersInputs {
alpha_test: None,
item_id_declared: false,
far_depth: true,
paged_maps: false,
}
}
@@ -355,6 +355,25 @@ pub const NAMES: &[&str] = &[
"hasSkylight",
"hasCeiling",
"cloudTime",
// Horizon's own: Horizon Extras' dynamic lights (`dynamic_light.rs`), nearest first: how
// many, and each one's camera-relative position and light level (zeros past the count).
"horizonDynamicLightCount",
"horizonDynamicLight0",
"horizonDynamicLight1",
"horizonDynamicLight2",
"horizonDynamicLight3",
"horizonDynamicLight4",
"horizonDynamicLight5",
"horizonDynamicLight6",
"horizonDynamicLight7",
"horizonDynamicLight8",
"horizonDynamicLight9",
"horizonDynamicLight10",
"horizonDynamicLight11",
"horizonDynamicLight12",
"horizonDynamicLight13",
"horizonDynamicLight14",
"horizonDynamicLight15",
"isElytraFlying",
"cloudHeight",
];
@@ -386,6 +405,8 @@ pub struct FrameUniforms {
center_depth: Option<f32>,
/// The pack's shadow settings (7.1).
pub shadow: Shadow,
/// The pack's smoothing half-lives in ticks (`horizon_shaders::HALF_LIVES`).
pub half_lives: [Option<f32>; 4],
}
impl Default for FrameUniforms {
@@ -403,6 +424,7 @@ impl Default for FrameUniforms {
center_depth_raw: None,
center_depth: None,
shadow: Shadow::default(),
half_lives: [None; 4],
}
}
}
@@ -715,6 +737,7 @@ impl FrameUniforms {
*self = Self {
atlas: self.atlas,
shadow: std::mem::take(&mut self.shadow),
half_lives: self.half_lives,
..Self::default()
};
}
@@ -779,10 +802,13 @@ impl FrameUniforms {
// a tenth of a second a tick: Iris 1.11.7 smooths that slowly (measured frame by frame
// with a probe pack: wetness 60 s rising, 20 s falling; eyeBrightnessSmooth 1 s;
// centerDepthSmooth 0.1 s).
// The pack's `wetnessHalflife`/`drynessHalflife` when it sets them (OptiFine's defaults
// otherwise), as for `eyeBrightnessHalflife` and `centerDepthHalflife` below.
let [wet, dry, eye_half, depth_half] = self.half_lives;
let half_life = if inputs.rain > self.wetness {
600.0
wet.unwrap_or(600.0)
} else {
200.0
dry.unwrap_or(200.0)
};
self.wetness = smooth(self.wetness, inputs.rain, half_life * SECONDS_A_TICK, dt);
let eye = inputs.eye_light.map(|l| (l * 16) as f32);
@@ -791,13 +817,18 @@ impl FrameUniforms {
self.eye_smooth = eye;
}
for (smoothed, target) in self.eye_smooth.iter_mut().zip(eye) {
*smoothed = smooth(*smoothed, target, 10.0 * SECONDS_A_TICK, dt);
*smoothed = smooth(
*smoothed,
target,
eye_half.unwrap_or(10.0) * SECONDS_A_TICK,
dt,
);
}
// `centerDepthHalflife`'s default, 1 tick (OptiFine's shaders.txt); the first value
// read back is taken as it is.
if let Some(raw) = self.center_depth_raw {
self.center_depth = Some(match self.center_depth {
Some(v) => smooth(v, raw, SECONDS_A_TICK, dt),
Some(v) => smooth(v, raw, depth_half.unwrap_or(1.0) * SECONDS_A_TICK, dt),
None => raw,
});
}
@@ -929,6 +960,12 @@ impl FrameUniforms {
"gbufferProjectionInverse" => m4(projection_inverse),
"gbufferPreviousModelView" => m4(previous_view),
"gbufferPreviousProjection" => m4(previous_projection),
"horizonDynamicLightCount" => Value::i(&[frame.dynamic_lights.len() as i32]),
n if dynamic_light_index(n).is_some() => Value::f(
&(dynamic_light_index(n).and_then(|k| frame.dynamic_lights.get(k)))
.copied()
.unwrap_or([0.0; 4]),
),
"heldItemId" => Value::i(&[inputs.held_items[0]]),
"heldItemId2" => Value::i(&[inputs.held_items[1]]),
"heldBlockLightValue" => Value::i(&[inputs.held_light[0]]),
@@ -1235,10 +1272,12 @@ mod tests {
format!(r#"{{"attributes": {attributes}}}"#),
)
.unwrap();
let environment =
crate::environment::Environment::load_dimension(&root, name, false).unwrap();
let environment = crate::environment::Environment::load_dimension(&root, name).unwrap();
std::fs::remove_dir_all(&root).unwrap();
environment.sample(6000, None, None)
environment.sample(&crate::environment::Sample {
day_time: 6000,
..Default::default()
})
}
#[test]
@@ -1785,6 +1824,29 @@ pub(super) mod initial_history_tests {
assert_eq!(crate::clouds::drift(256 * 400 + 3, 0.25, 256), 3.25);
}
#[test]
fn the_dynamic_lights_reach_the_pack_nearest_first() {
let hud = HudBatch::new([800, 450]);
let mut f = frame(&hud);
let lights = [[1.0, 2.0, 3.0, 14.0], [-4.0, 0.5, 6.0, 7.0]];
f.dynamic_lights = &lights;
let mut u = FrameUniforms::default();
u.update(&f, &PackInputs::default(), [800, 450]);
let count = index("horizonDynamicLightCount").unwrap();
assert_eq!(int(&u, count), 2);
assert_eq!(float(&u, "horizonDynamicLight0")[..4], lights[0]);
assert_eq!(float(&u, "horizonDynamicLight1")[..4], lights[1]);
// Past the count, and the last of the sixteen: zeros.
assert_eq!(float(&u, "horizonDynamicLight2")[..4], [0.0; 4]);
assert_eq!(float(&u, "horizonDynamicLight15")[..4], [0.0; 4]);
assert_eq!(index("horizonDynamicLight16"), None);
// Off (no lights): none.
f.dynamic_lights = &[];
u.update(&f, &PackInputs::default(), [800, 450]);
assert_eq!(int(&u, count), 0);
assert_eq!(float(&u, "horizonDynamicLight0")[..4], [0.0; 4]);
}
#[test]
fn environmental_smoothing_starts_at_the_first_inputs_without_resetting_each_frame() {
let hud = HudBatch::new([800, 450]);
@@ -2170,22 +2232,33 @@ pub(super) mod initial_history_tests {
let hud = HudBatch::new([800, 450]);
let f = frame(&hud);
let mut u = FrameUniforms::default();
// The next frame comes `seconds` after the last (and a few microseconds of the test).
let after = |u: &mut FrameUniforms, seconds: f32| {
u.last = Some(std::time::Instant::now() - std::time::Duration::from_secs_f32(seconds));
// A scripted clock: the next frame comes exactly `seconds` after the last, however long
// the test itself takes (a wall-clock gap of a millisecond moved centerDepthSmooth by
// more than the tolerance on a busy CI runner).
let mut counter = 1;
let mut elapsed = 0.0;
let mut after = |input: &mut PackInputs, seconds: f32| {
counter += 1;
elapsed += seconds;
input.frame_timing = Some(FrameTiming {
counter,
elapsed,
delta: seconds,
});
};
let mut input = PackInputs {
eye_light: [0, 15],
frame_timing: Some(FrameTiming::nth(1, 0.0)),
..Default::default()
};
u.center_depth_raw = Some(1.0);
u.update(&f, &input, [800, 450]);
input.eye_light = [0, 0];
u.center_depth_raw = Some(0.0);
after(&mut u, 0.1);
after(&mut input, 0.1);
u.update(&f, &input, [800, 450]);
assert!((float(&u, "centerDepthSmooth")[0] - 0.5).abs() < 1e-3);
after(&mut u, 0.6);
after(&mut input, 0.6);
u.update(&f, &input, [800, 450]);
// 240 falling toward 0 for 0.7 s: 147.8, read as 147.
match u.values[index("eyeBrightnessSmooth").unwrap()] {
@@ -2193,11 +2266,46 @@ pub(super) mod initial_history_tests {
_ => panic!("integer uniform expected"),
}
input.rain = 1.0;
after(&mut u, 60.0);
after(&mut input, 60.0);
u.update(&f, &input, [800, 450]);
assert!((float(&u, "wetness")[0] - 0.5).abs() < 1e-3);
input.rain = 0.0;
after(&mut u, 20.0);
after(&mut input, 20.0);
u.update(&f, &input, [800, 450]);
assert!((float(&u, "wetness")[0] - 0.25).abs() < 1e-3);
}
/// A pack's `const float wetnessHalflife = 30.0;` (and its dryness) replace the defaults:
/// wetness reaches half the rain in 3 s instead of 60 s.
#[test]
fn a_pack_s_half_lives_replace_the_defaults() {
let hud = HudBatch::new([800, 450]);
let f = frame(&hud);
let mut u = FrameUniforms {
half_lives: [Some(30.0), Some(10.0), None, None],
..Default::default()
};
// A scripted clock, as in `smoothed_uniforms_take_iris_half_lives`: the wall clock's gap
// between two updates is not exact on a busy runner.
let mut input = PackInputs {
frame_timing: Some(FrameTiming::nth(1, 0.0)),
..Default::default()
};
u.update(&f, &input, [800, 450]);
input.rain = 1.0;
input.frame_timing = Some(FrameTiming {
counter: 2,
elapsed: 3.0,
delta: 3.0,
});
u.update(&f, &input, [800, 450]);
assert!((float(&u, "wetness")[0] - 0.5).abs() < 1e-3);
input.rain = 0.0;
input.frame_timing = Some(FrameTiming {
counter: 3,
elapsed: 4.0,
delta: 1.0,
});
u.update(&f, &input, [800, 450]);
assert!((float(&u, "wetness")[0] - 0.25).abs() < 1e-3);
}
@@ -2534,6 +2642,12 @@ pub(super) mod initial_history_tests {
}
}
/// `horizonDynamicLight<k>`'s `k`, for the lights `Frame::dynamic_lights` holds.
fn dynamic_light_index(name: &str) -> Option<usize> {
let k: usize = name.strip_prefix("horizonDynamicLight")?.parse().ok()?;
(k < crate::dynamic_light::MAX).then_some(k)
}
#[cfg(test)]
#[path = "pack_uniforms/ftransform_test.rs"]
mod ftransform_test;
@@ -46,6 +46,7 @@ pub fn inputs() -> horizon_shaders::GbuffersInputs {
}),
item_id_declared: false,
far_depth: false,
paged_maps: false,
}
}
@@ -274,7 +274,13 @@ impl Panorama {
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: Some("fs_panorama"),
compilation_options: Default::default(),
compilation_options: wgpu::PipelineCompilationOptions {
constants: &[(
"HDR_WRITE_LIGHT",
f64::from(u8::from(format == super::LINEAR_FRAME)),
)],
..Default::default()
},
targets: &[Some(wgpu::ColorTargetState {
format,
blend: None,
@@ -1,4 +1,5 @@
// CubeMap's position-only cube and panorama.vsh/fsh: sample its untransformed direction.
override HDR_WRITE_LIGHT: bool = false;
struct Projection { view_proj: mat4x4<f32> }
@group(0) @binding(0) var<uniform> projection: Projection;
@group(0) @binding(1) var panorama: texture_cube<f32>;
@@ -26,5 +27,6 @@ struct Out {
return out;
}
@fragment fn fs_panorama(in: Out) -> @location(0) vec4<f32> {
return textureSample(panorama, panorama_sampler, in.direction);
let color = textureSample(panorama, panorama_sampler, in.direction);
return vec4(color.rgb, select(color.a, 1.0, HDR_WRITE_LIGHT));
}
@@ -124,6 +124,10 @@ impl<T> Resident<T> {
pub fn get_mut(&mut self, slot: u32) -> &mut T {
&mut self.items[slot as usize].1
}
/// Padded mesh bounds of the section in `slot`, relative to its origin.
pub fn bounds(&self, slot: u32) -> Option<[Vec3; 2]> {
self.bounds[slot as usize]
}
/// Sections from now on count from `min_y` (a level of another column).
pub fn set_min_y(&mut self, min_y: i32) {
self.min_y = min_y;
@@ -435,17 +439,18 @@ impl<T> Resident<T> {
if list.is_empty() {
continue;
}
let min = origin((column.x, column.low, column.z), self.min_y, camera).as_vec3();
let top = origin((column.x, column.high, column.z), self.min_y, camera).as_vec3();
let max = top + Vec3::splat(16.0);
let inside = frustum.contains(min, max);
if !inside && !frustum.intersects(min, max) {
continue;
}
let ox = f64::from(column.x * 16) - camera.x;
let oz = f64::from(column.z * 16) - camera.z;
let min_x = ox as f32;
let min_z = oz as f32;
let low_oy = (f64::from(self.min_y + column.low * 16) - camera.y) as f32;
let high_oy = (f64::from(self.min_y + column.high * 16) - camera.y) as f32;
let min = Vec3::new(min_x, low_oy, min_z);
let max = Vec3::new(min_x + 16.0, high_oy + 16.0, min_z + 16.0);
let inside = frustum.contains(min, max);
if !inside && !frustum.intersects(min, max) {
continue;
}
let dx8 = ox + 8.0;
let dz8 = oz + 8.0;
let xz_sq = dx8 * dx8 + dz8 * dz8;
+17 -2
View File
@@ -46,6 +46,9 @@ pub fn star_triangles() -> Vec<[f32; 3]> {
struct Uniform {
clip_from_sky: [[f32; 4]; 4],
color: [f32; 4],
hdr_settings: [f32; 4],
hdr_shares: [f32; 4],
hdr_light: [f32; 4],
}
pub(super) struct Stars {
@@ -93,7 +96,9 @@ impl Stars {
});
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Stars shader"),
source: wgpu::ShaderSource::Wgsl(include_str!("stars.wgsl").into()),
source: wgpu::ShaderSource::Wgsl(
(include_str!("../hdr_light.wgsl").to_owned() + include_str!("stars.wgsl")).into(),
),
});
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Stars layout"),
@@ -129,7 +134,13 @@ impl Stars {
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: Some("fs_stars"),
compilation_options: Default::default(),
compilation_options: wgpu::PipelineCompilationOptions {
constants: &[(
"HDR_WRITE_LIGHT",
f64::from(u8::from(format == super::LINEAR_FRAME)),
)],
..Default::default()
},
targets: &[Some(wgpu::ColorTargetState {
format,
// RenderPipelines.STARS: the celestial blend (src alpha, one), with the
@@ -165,11 +176,15 @@ impl Stars {
encoder: &mut wgpu::CommandEncoder,
clip_from_sky: Mat4,
brightness: f32,
globals: &super::Globals,
) {
let b = brightness.clamp(0.0, 1.0);
let uniform = Uniform {
clip_from_sky: clip_from_sky.to_cols_array_2d(),
color: [b; 4],
hdr_settings: globals.hdr_settings,
hdr_shares: globals.hdr_shares,
hdr_light: globals.hdr_light,
};
uploads.buffer(encoder, &self.uniform, 0, bytemuck::bytes_of(&uniform));
}
@@ -4,6 +4,9 @@ struct Stars {
clip_from_sky: mat4x4<f32>,
// starBrightness in every channel (RenderSystem.setShaderColor).
color: vec4<f32>,
hdr_settings: vec4<f32>,
hdr_shares: vec4<f32>,
hdr_light: vec4<f32>,
}
@group(0) @binding(0) var<uniform> stars: Stars;
@@ -16,5 +19,9 @@ struct Stars {
// fully lifted wherever they show at all. Nothing else reads the frame's alpha.
@fragment fn fs_stars() -> @location(0) vec4<f32> {
let b = stars.color.a;
if HDR_WRITE_LIGHT && stars.hdr_light.w != 0.0 {
return vec4(hdr_written(stars.color.rgb * b, 0.175, stars.hdr_settings, stars.hdr_shares), b);
}
if HDR_WRITE_LIGHT { return vec4(stars.color.rgb * b, b); }
return vec4(stars.color.rgb * b, 0.175);
}
@@ -8,6 +8,10 @@ pub(super) fn pipelines(
) -> [wgpu::RenderPipeline; 3] {
std::array::from_fn(|i| {
let mut constants = sprite_constants.to_vec();
constants.push((
"HDR_WRITE_LIGHT",
f64::from(u8::from(format == super::LINEAR_FRAME)),
));
constants.push(("NATIVE_MODEL_ALPHA_CUTOFF", [0.0, 0.1, 0.5][i]));
// The ordinary Vertex ABI is unchanged. This material's private payload uses
// normal's four bytes for a float z, and glint UV for float normal x/y.
@@ -65,13 +65,18 @@ impl Visbuffer {
let resolve_constants: Vec<(&str, f64)> = constants
.iter()
.copied()
.chain([("VIS_BLOCKS_PER_PAGE", blocks_per_page as f64)])
.chain([
("VIS_BLOCKS_PER_PAGE", blocks_per_page as f64),
(
"HDR_WRITE_LIGHT",
f64::from(u8::from(color == super::LINEAR_FRAME)),
),
])
.collect();
let module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Horizon visibility buffer"),
source: wgpu::ShaderSource::Wgsl(
(include_str!("../terrain.wgsl").to_owned() + include_str!("../visbuffer.wgsl"))
.into(),
(super::terrain_shader() + include_str!("../visbuffer.wgsl")).into(),
),
});
let fragment = wgpu::ShaderStages::FRAGMENT;
@@ -79,6 +79,7 @@ pub struct Post {
/// The last TAA frame's unjittered `view_proj` and camera, `None` once a frame ran without it.
taa_previous: Option<(DMat4, DVec3)>,
taa_this_frame: TaaUniform,
light_key: Option<(bool, [f32; 4], [f32; 4], [[f32; 4]; 2])>,
}
impl Post {
@@ -258,6 +259,28 @@ impl Post {
taa_frame: 0,
taa_previous: None,
taa_this_frame: bytemuck::Zeroable::zeroed(),
light_key: None,
}
}
// History stores baked light, so a change must reject it before jitter records the next frame.
pub(super) fn baked_light(
&mut self,
gain: bool,
settings: [f32; 4],
shares: [f32; 4],
windows: [[f32; 4]; 2],
) {
// These uniforms do not change baked colour without gain. Keep compatibility
// history stable when only its final display settings change.
let key = Some(if gain {
(true, settings, shares, windows)
} else {
(false, [0.0; 4], [0.0; 4], [[0.0; 4]; 2])
});
if self.light_key != key {
self.taa_previous = None;
self.light_key = key;
}
}
@@ -730,6 +753,60 @@ mod tests {
}
}
#[test]
fn baked_light_changes_and_returning_from_a_pack_reject_taa_history() {
let Some((device, _)) = test_device() else {
eprintln!("TAA baked-light GPU skipped: no test device");
return;
};
let mut post = Post::new(&device, wgpu::TextureFormat::Rgba16Float);
post.taa = true;
if !post.supports_taa() {
eprintln!("TAA baked-light GPU skipped: TAA unsupported");
return;
}
let key = (
[5.0, 4.0, 1.0, 0.0],
[0.2, 0.5, 0.6, 1.0],
[[0.1; 4], [0.4; 4]],
);
for gain in [true, false, true] {
post.baked_light(gain, key.0, key.1, key.2);
post.jitter([32, 32], true, Mat4::IDENTITY, DVec3::ZERO);
assert_eq!(post.taa_this_frame.jitter[2], 1.0);
post.baked_light(gain, key.0, key.1, key.2);
post.jitter([32, 32], true, Mat4::IDENTITY, DVec3::ZERO);
assert_eq!(post.taa_this_frame.jitter[2], 0.0);
}
for field in 0..16 {
let mut changed = key;
match field {
0..=3 => changed.0[field] += 0.01,
4..=7 => changed.1[field - 4] += 0.01,
_ => changed.2[(field - 8) / 4][(field - 8) % 4] += 0.01,
}
post.baked_light(true, changed.0, changed.1, changed.2);
post.jitter([32, 32], true, Mat4::IDENTITY, DVec3::ZERO);
assert_eq!(post.taa_this_frame.jitter[2], 1.0);
}
post.baked_light(false, key.0, key.1, key.2);
post.jitter([32, 32], true, Mat4::IDENTITY, DVec3::ZERO);
assert_eq!(post.taa_this_frame.jitter[2], 1.0);
post.baked_light(false, [0.0; 4], [0.0; 4], [[0.0; 4]; 2]);
post.jitter([32, 32], true, Mat4::IDENTITY, DVec3::ZERO);
assert_eq!(post.taa_this_frame.jitter[2], 0.0);
// A pack disables TAA even when the light settings stay the same. Its first
// world frame after the pack is dropped must not reuse the pre-pack history.
post.jitter([32, 32], false, Mat4::IDENTITY, DVec3::ZERO);
post.jitter([32, 32], true, Mat4::IDENTITY, DVec3::ZERO);
assert_eq!(post.taa_this_frame.jitter[2], 1.0);
post.jitter([32, 32], true, Mat4::IDENTITY, DVec3::ZERO);
assert_eq!(post.taa_this_frame.jitter[2], 0.0);
eprintln!(
"TAA baked-light GPU checked gain, all settings/shares/windows and the first frame after a pack"
);
}
fn test_device() -> Option<(wgpu::Device, wgpu::Queue)> {
let instance = crate::gfx::test_gpu::instance();
let adapter = pollster::block_on(instance.request_adapter(&Default::default())).ok()?;
@@ -33,7 +33,7 @@ pub(super) fn pipeline(
multisample: Default::default(),
fragment: Some(wgpu::FragmentState {
module: shader,
entry_point: Some("fs_entity"),
entry_point: Some("fs_entity_unmarked"),
compilation_options: Default::default(),
targets: &[Some(wgpu::ColorTargetState {
format,
@@ -67,7 +67,7 @@ struct Out { @builtin(position) pos:vec4<f32>, @location(0) color:vec4<f32> }
@vertex fn vs_entity(@location(0) pos:vec3<f32>, @location(3) color:vec4<f32>)->Out {
return Out(vec4(pos,1.0),color);
}
@fragment fn fs_entity(v:Out)->@location(0) vec4<f32> { return v.color; }
@fragment fn fs_entity_unmarked(v:Out)->@location(0) vec4<f32> { return v.color; }
"#
.into(),
),
+88 -9
View File
@@ -532,6 +532,54 @@ pub fn smooth_gradients_offered() -> bool {
SMOOTH_GRADIENTS_OFFERED.load(std::sync::atomic::Ordering::Relaxed)
}
/// GPU Culling's setting: off, on where it is offered, or Auto, which has it on only where the
/// CPU limits the frame and it makes the frame faster (`autotune::GpuCullingAuto`).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum GpuCullingMode {
#[default]
Off,
On,
Auto,
}
impl GpuCullingMode {
pub const ALL: [GpuCullingMode; 3] = [
GpuCullingMode::Off,
GpuCullingMode::On,
GpuCullingMode::Auto,
];
/// The value in `horizon-graphics.txt`: `true` and `false` as the switch wrote them.
pub fn key(self) -> &'static str {
match self {
Self::Off => "false",
Self::On => "true",
Self::Auto => "auto",
}
}
/// The word `horizon-ctl gpu-culling` takes.
pub fn name(self) -> &'static str {
match self {
Self::Off => "off",
Self::On => "on",
Self::Auto => "auto",
}
}
pub fn label(self) -> &'static str {
match self {
Self::Off => "Off",
Self::On => "On",
Self::Auto => "Auto",
}
}
fn parse(s: &str, default: Self) -> Self {
match s {
"true" | "on" => Self::On,
"false" | "off" => Self::Off,
"auto" => Self::Auto,
_ => default,
}
}
}
/// Whether GPU Culling (`Graphics::gpu_culling`) can be switched on here, and why not: set when a
/// renderer starts, and again when its pass can't be set up or its buffers stop fitting in video
/// memory. Where it isn't offered the settings grey its switch out with the reason, and the saved
@@ -672,8 +720,9 @@ pub struct Graphics {
/// Near solid terrain culled, and its draws listed, on the GPU (`gfx::gpu_culling`), where it
/// is offered (`gpu_culling_offer`). Off by default (GPU Culling, Performance graphics); it
/// applies at once, and no preset sets it. Every save writes it, so a default turned on later
/// needs a new key, as `batchTranslucent` did.
pub gpu_culling: bool,
/// needs a new key, as `batchTranslucent` did. Auto turns it on only where the CPU limits the
/// frame and it makes the frame faster (`autotune`).
pub gpu_culling: GpuCullingMode,
/// Skip drawing entities hidden behind opaque terrain, synchronously or asynchronously.
pub entity_culling: EntityCullingMode,
/// Minimum entity population for coarse AABB culling; zero disables it.
@@ -684,6 +733,8 @@ pub struct Graphics {
/// vanilla's fancy leaves. Ignored with a resource pack that may replace
/// the vanilla leaf models ([`Graphics::leaf_culling_effective`]).
pub leaf_culling: LeafCullingMode,
/// Draw regular ice opaque in the solid pass, without its see-through texture.
pub opaque_ice: bool,
/// Cache settled shulker-box models.
pub cache_shulker_boxes: bool,
/// Cache sign-text geometry.
@@ -786,11 +837,12 @@ impl Default for Graphics {
far_detail: FarDetail::Full,
blue_map: crate::bluemap::Settings::default(),
cave_culling: true,
gpu_culling: false,
gpu_culling: GpuCullingMode::Off,
entity_culling: EntityCullingMode::Off,
entity_culling_precheck: 64,
particle_culling: ParticleCullingMode::Off,
leaf_culling: LeafCullingMode::Off,
opaque_ice: false,
cache_shulker_boxes: false,
// Sign text has used its renderer cache independently of the new model caches.
cache_signs: true,
@@ -885,13 +937,14 @@ impl Graphics {
}
"blueMapAutoDetect" => g.blue_map.auto_detect = flag(g.blue_map.auto_detect),
"caveCulling" => g.cave_culling = flag(g.cave_culling),
"gpuCulling" => g.gpu_culling = flag(g.gpu_culling),
"gpuCulling" => g.gpu_culling = GpuCullingMode::parse(value, g.gpu_culling),
"entityCulling" => g.entity_culling = EntityCullingMode::parse(value),
"entityCullingPrecheck" => {
g.entity_culling_precheck = number(g.entity_culling_precheck).min(512)
}
"particleCulling" => g.particle_culling = ParticleCullingMode::parse(value),
"leafCulling" => g.leaf_culling = LeafCullingMode::parse(value),
"opaqueIce" => g.opaque_ice = flag(g.opaque_ice),
"blockEntityCache" => {
let enabled = flag(false);
g.cache_shulker_boxes = enabled;
@@ -986,7 +1039,7 @@ impl Graphics {
}
pub fn serialize(&self) -> String {
let mut text = format!(
"preset:{}\nlodDistance:{}\nfarDetail:{}\ncaveCulling:{}\nentityCulling:{}\nentityCullingPrecheck:{}\nparticleCulling:{}\nleafCulling:{}\nblockEntityCacheShulkerBoxes:{}\nblockEntityCacheSigns:{}\nblockEntityCacheDecoratedPots:{}\nblockEntityCacheBells:{}\nblockEntityCacheChests:{}\nblockEntityCacheBanners:{}\nblockEntityCacheCopperGolemStatues:{}\nchunkUpdates:{}\nuploadBudgetKiB:{}\ntextureBudgetMiB:{}\nsky:{}\nfog:{}\nweather:{}\nanimatedTextures:{}\nditherCutoutMips:{}\npresentMode:{}\nframePacing:{}\nworkers:{}\noverlay:{}\nresolutionScale:{}\nfxaa:{}\ntaa:{}\nupscaling:{}\nupscalingSharpness:{}\nscreenshotQuality:{}\nframeGeneration:{}\nhdr:{}\nhdrPaperWhite:{}\nhdrPeak:{}\nhdrBlackLevel:{}\nhdrUiBrightness:{}\nhdrLighting:{}\nhdrKey:{}\nbatteryMode:{}\nshadowCache:{}\ngraphicsApi:{}\npickedShaderPack:{}\nbatchTranslucent:{}\nhdrSmoothGradients:{}\ngpuCulling:{}\n",
"preset:{}\nlodDistance:{}\nfarDetail:{}\ncaveCulling:{}\nentityCulling:{}\nentityCullingPrecheck:{}\nparticleCulling:{}\nleafCulling:{}\nopaqueIce:{}\nblockEntityCacheShulkerBoxes:{}\nblockEntityCacheSigns:{}\nblockEntityCacheDecoratedPots:{}\nblockEntityCacheBells:{}\nblockEntityCacheChests:{}\nblockEntityCacheBanners:{}\nblockEntityCacheCopperGolemStatues:{}\nchunkUpdates:{}\nuploadBudgetKiB:{}\ntextureBudgetMiB:{}\nsky:{}\nfog:{}\nweather:{}\nanimatedTextures:{}\nditherCutoutMips:{}\npresentMode:{}\nframePacing:{}\nworkers:{}\noverlay:{}\nresolutionScale:{}\nfxaa:{}\ntaa:{}\nupscaling:{}\nupscalingSharpness:{}\nscreenshotQuality:{}\nframeGeneration:{}\nhdr:{}\nhdrPaperWhite:{}\nhdrPeak:{}\nhdrBlackLevel:{}\nhdrUiBrightness:{}\nhdrLighting:{}\nhdrKey:{}\nbatteryMode:{}\nshadowCache:{}\ngraphicsApi:{}\npickedShaderPack:{}\nbatchTranslucent:{}\nhdrSmoothGradients:{}\ngpuCulling:{}\n",
self.preset.name(),
self.lod_distance,
self.far_detail.name(),
@@ -995,6 +1048,7 @@ impl Graphics {
self.entity_culling_precheck,
self.particle_culling.name(),
self.leaf_culling.name(),
bool_text(self.opaque_ice),
bool_text(self.cache_shulker_boxes),
bool_text(self.cache_signs),
bool_text(self.cache_decorated_pots),
@@ -1041,7 +1095,7 @@ impl Graphics {
self.shader_pack,
bool_text(self.translucent_batching),
bool_text(self.hdr_smooth_gradients),
bool_text(self.gpu_culling),
self.gpu_culling.key(),
);
text += &self.blue_map.serialize();
text
@@ -1181,11 +1235,12 @@ mod tests {
servers: Vec::new(),
},
cave_culling: false,
gpu_culling: true,
gpu_culling: GpuCullingMode::On,
entity_culling: EntityCullingMode::Synchronous,
entity_culling_precheck: 128,
particle_culling: ParticleCullingMode::Asynchronous,
leaf_culling: LeafCullingMode::SolidAggressive,
opaque_ice: true,
cache_shulker_boxes: true,
cache_signs: true,
cache_decorated_pots: true,
@@ -1271,8 +1326,32 @@ mod tests {
assert!(!Graphics::parse("hdr:true\nhdrSmoothGradients:false\n").wide_frame());
assert!(Graphics::parse("translucentBatching:false\n").translucent_batching);
// GPU Culling is opt-in: only the file or its switch turns it on.
assert!(!Graphics::default().gpu_culling);
assert!(Graphics::parse("gpuCulling:true\n").gpu_culling);
assert_eq!(Graphics::default().gpu_culling, GpuCullingMode::Off);
assert_eq!(
Graphics::parse("gpuCulling:true\n").gpu_culling,
GpuCullingMode::On
);
// Auto is a third value of the same key. A file from before it reads as before, and an
// older Horizon reading `auto` finds a value it doesn't know and keeps Off.
assert_eq!(
Graphics::parse("gpuCulling:auto\n").gpu_culling,
GpuCullingMode::Auto
);
assert_eq!(
Graphics::parse("gpuCulling:false\n").gpu_culling,
GpuCullingMode::Off
);
assert_eq!(
Graphics::parse("gpuCulling:maybe\n").gpu_culling,
GpuCullingMode::Off
);
for mode in GpuCullingMode::ALL {
let g = Graphics {
gpu_culling: mode,
..Graphics::default()
};
assert_eq!(Graphics::parse(&g.serialize()).gpu_culling, mode);
}
// 0 is Auto; anything else is a peak the slider reaches.
assert_eq!(Graphics::parse("hdrPeak:0\n").hdr_peak, 0);
assert_eq!(Graphics::parse("hdrPeak:50\n").hdr_peak, 200);
File diff suppressed because it is too large. Load diff
+129 -72
View File
@@ -33,6 +33,11 @@ struct Params {
@group(0) @binding(2) var<uniform> params: Params;
// Horizon's logo, 1 inside, 0 outside, for calibration's test pictures.
@group(0) @binding(3) var logo: texture_2d<f32>;
// The float frame with HUD coverage (Hdr::layered): the frame keeps the world as light
// directly from its writers; the HUD draws on a picture of its own (`hud`, fs_keep), and `coverage` says how
// much of the world it hides there (gfx/hud_coverage.rs).
@group(0) @binding(4) var coverage: texture_2d<f32>;
@group(0) @binding(5) var hud: texture_2d<f32>;
// Light sources are lifted evenly rather than by a highlight curve: vanilla's
// textures were drawn for SDR, so a curve on their brightest pixels blows out
@@ -149,80 +154,28 @@ fn calibration_nits(p: vec2<f32>, size: vec2<f32>) -> f32 {
return vec4(0.0);
}
@fragment fn fs_hdr(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
let at = vec2<i32>(pos.xy);
// Calibration: above its controls the test picture, straight in nits, past
// paper white, the lift and the black level.
fn lit(f: vec3<f32>, a: f32, shows: bool, eased: bool) -> Lit {
return hdr_mark_light(f, a, shows, eased, vec4(params.peak, params.scene, params.world, params.debug), params.share);
}
// Calibration: above its controls the test picture, straight in nits, past
// paper white, the lift and the black level.
fn calibrating(pos: vec4<f32>) -> bool {
let size = vec2<f32>(textureDimensions(frame));
if params.calibration.x > 0.5 && pos.y < size.y * params.calibration.z {
let nits = vec3(calibration_nits(pos.xy, size));
if params.pq > 0.5 {
return vec4(pq(nits), 1.0);
}
return vec4(nits / 80.0, 1.0);
return params.calibration.x > 0.5 && pos.y < size.y * params.calibration.z;
}
fn calibration_picture(pos: vec4<f32>) -> vec4<f32> {
let nits = vec3(calibration_nits(pos.xy, vec2<f32>(textureDimensions(frame))));
if params.pq > 0.5 {
return vec4(pq(nits), 1.0);
}
let f = frame_texel(textureLoad(frame, at, 0));
// What covers the world here (Hdr::keep_world): nothing at 0, the hand at
// 1/255 (Hdr::mark_hand: drawn at the world's brightness), else the HUD or a
// menu, by how much.
let covered = f.a > 0.0;
let hand = covered && f.a < 1.5 / 255.0;
let ui = select(f.a, 0.0, hand);
let w = frame_texel(textureLoad(world, at, 0));
// The world's alpha is below 0.75 on light sources, the sun and the moon
// (terrain.wgsl, entity.wgsl): only those shine, and only where nothing was
// drawn over them since: grey text over the white sun still looks like the sun
// darkened, but it raised the frame's alpha. Its band of 0.175 is the tier, the
// lower the brighter, and where in the band how much (hdr_mark). The hand
// writes its own alpha there (Hdr::hand_light_view): 1, or a light source it holds.
var lifted = false;
let shows = params.world > 0.5 && params.peak > 1.0
&& (hand || (!covered && shows_world(f.rgb, w.rgb)));
// Light over 1 (a float frame's) shows only where the world does and carries
// no mark (alpha 1), up to the peak: light written as light. Marked pixels clip
// at white before their lift, as on a unorm frame, so light sources, the sun and
// HDR lighting look as they do there; so do the HUD, menus and HDR Lighting off.
let c = select(min(f.rgb, vec3(1.0)), f.rgb, shows && w.a == 1.0);
// Gamma 2.2, as SDR displays and the compositors' SDR paths decode it.
var light = pow(c, vec3(2.2));
// HDR lighting: alpha between 0.76 and 1 is how much of it the surface gets. Vanilla's
// light is albedo times lightmap, so this is the lightmap going past 1. It eases into the
// peak from 60% of it, so bright textures keep their detail. Unmarked light (alpha 1)
// gets no gain and no knee: the clamp to the peak below is all it needs here.
if shows && w.a >= 0.75 && w.a < 1.0 {
let top = max(light.r, max(light.g, light.b));
let gain = 1.0 + (params.scene - 1.0) * (1.0 - w.a) / 0.24;
let v = top * gain;
let knee = max(0.6 * params.peak, 1.0);
var out = v;
if v > knee && params.peak > knee {
out = knee + (params.peak - knee) * (1.0 - exp(-(v - knee) / (params.peak - knee)));
}
light *= select(gain, out / max(top, 1e-4), v > knee);
}
if shows && w.a < 0.75 {
let band = u32(clamp(floor((w.a + 0.005) / 0.175), 0.0, 3.0));
let tier = 3u - band;
let lift = 1.0 - clamp((w.a - 0.175 * f32(band)) / 0.165, 0.0, 1.0);
if lift > 0.0 {
let top = max(light.r, max(light.g, light.b));
let gain = min(1.0 + (params.peak - 1.0) * params.share[tier] * lift, params.peak / max(top, 1e-4));
light *= max(gain, 1.0);
lifted = true;
}
}
// HORIZON_HDR_DEBUG=1: what isn't lifted turns grey, what is keeps its
// colour with a magenta tint, so a lift shows on any colour.
if params.debug > 0.5 && params.world > 0.5 {
if lifted {
light *= vec3(1.0, 0.6, 1.0);
} else {
light = vec3(dot(light, vec3(0.2126, 0.7152, 0.0722)));
}
}
light = min(light, vec3(params.peak));
// The HUD and menus at their own brightness, by how much they cover.
light *= mix(1.0, params.ui, ui);
return vec4(nits / 80.0, 1.0);
}
// Light in units of paper white, as the swapchain takes it: HDR10 or scRGB, the black level
// lifted.
fn display(light: vec3<f32>) -> vec4<f32> {
let scrgb = light * params.paper;
if params.pq > 0.5 {
let e = pq(BT709_TO_BT2020 * scrgb * 80.0);
@@ -233,3 +186,107 @@ fn calibration_nits(p: vec2<f32>, size: vec2<f32>) -> f32 {
}
return vec4(scrgb, 1.0);
}
@fragment fn fs_hdr(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
if calibrating(pos) {
return calibration_picture(pos);
}
let at = vec2<i32>(pos.xy);
let f = frame_texel(textureLoad(frame, at, 0));
// What covers the world here (Hdr::keep_world): nothing at 0, the hand at
// 1/255 (Hdr::mark_hand: drawn at the world's brightness), else the HUD or a
// menu, by how much.
let covered = f.a > 0.0;
let hand = covered && f.a < 1.5 / 255.0;
let ui = select(f.a, 0.0, hand);
let w = frame_texel(textureLoad(world, at, 0));
// The world's marks lift only where nothing was drawn over them since: grey text over
// the white sun still looks like the sun darkened, but it raised the frame's alpha. The
// hand writes its own alpha there (Hdr::hand_light_view): 1, or a light source it holds.
let shows = params.world > 0.5 && params.peak > 1.0
&& (hand || (!covered && shows_world(f.rgb, w.rgb)));
var light = lit(f.rgb, w.a, shows, true).light;
// The HUD and menus at their own brightness, by how much they cover.
light *= mix(1.0, params.ui, ui);
return display(light);
}
// The tone curve's knee: up to it light stays as it is. Where HDR lighting eased into the peak
// before the curve (`lit`), 60% of it, so bright textures keep their detail; at least paper white.
fn tone_knee(headroom: f32) -> f32 {
return max(0.6 * headroom, 1.0);
}
// The tone curve on light whose brightest channel is `top`, in units of paper white `paper`
// nits: what to scale the light by, so it ends at most `headroom` (above 1). ITU-R BT.2390's
// EETF in PQ, without the black level lift (`display` does that): the same up to its knee, then
// a Hermite spline that reaches the peak level, at the source's peak. That peak is where the knee
// lands at `tone_knee`, PQ's 10 000 nits at most; light past it shows at the peak. The brightest
// channel sets the scale for all three, so light keeps its hue as it eases (lava stays orange)
// and no channel passes the peak.
fn tone_scale(top: f32, headroom: f32, paper: f32) -> f32 {
if top <= tone_knee(headroom) {
return 1.0;
}
let peak = pq(vec3(headroom * paper)).x;
let source = min(3.0 * peak - 2.0 * pq(vec3(tone_knee(headroom) * paper)).x, 1.0);
let e = pq(vec3(top * paper)).x / source;
let max_lum = peak / source;
let ks = 1.5 * max_lum - 0.5;
if e >= 1.0 {
return headroom / top;
}
if e <= ks {
return 1.0;
}
let t = (e - ks) / (1.0 - ks);
let t2 = t * t;
let t3 = t2 * t;
let p = (2.0 * t3 - 3.0 * t2 + 1.0) * ks + (t3 - 2.0 * t2 + t) * (1.0 - ks) + (3.0 * t2 - 2.0 * t3) * max_lum;
return pq_nits(vec3(p * source)).x / paper / top;
}
// Hdr::tonemap, after the post effects and before the camera overlays (docs/design/
// hdr-linear-light.md, `[tonemap]`): the light (`world` holds the frame) eased into the peak, in
// gamma, where scaling the light by s scales the stored colour by s^(1/2.2). Light up to the
// knee stays exactly as stored. With no headroom, a clip at white.
@fragment fn fs_tonemap(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
let g = textureLoad(world, vec2<i32>(pos.xy), 0).rgb;
if params.peak <= 1.0 {
return vec4(min(g, vec3(1.0)), 1.0);
}
let top = pow(max(max(g.r, max(g.g, g.b)), 0.0), 2.2);
let s = tone_scale(top, params.peak, params.paper * 80.0);
return vec4(select(g * pow(s, 1.0 / 2.2), g, s == 1.0), 1.0);
}
// Hdr::keep_world: the HUD's backdrop, the world clipped to white with alpha 0, the frame as
// the HUD found it before.
@fragment fn fs_keep(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
let w = textureLoad(frame, vec2<i32>(pos.xy), 0).rgb;
return vec4(clamp(w, vec3(0.0), vec3(1.0)), 0.0);
}
// The HUD over the world in gamma, the space the HUD blends in: its own part, what its backdrop
// B doesn't explain (H = P - (1 - c) B, exact for the layering blends), at UI Brightness, over
// (1 - c) of the world, light above white included. Where the world is at or below white, at
// 100%, that is the HUD's picture as drawn.
fn layered(at: vec2<i32>) -> vec3<f32> {
let w = max(textureLoad(frame, at, 0).rgb, vec3(0.0));
let p = clamp(textureLoad(hud, at, 0).rgb, vec3(0.0), vec3(1.0));
let c = textureLoad(coverage, at, 0).r;
let h = max(p - (1.0 - c) * min(w, vec3(1.0)), vec3(0.0));
return h * pow(params.ui, 1.0 / 2.2) + (1.0 - c) * w;
}
// Hdr::composite: the picture so far, stored as the frame stores light, for the menu blur.
@fragment fn fs_composite(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
return vec4(layered(vec2<i32>(pos.xy)), 1.0);
}
@fragment fn fs_hdr_layered(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
if calibrating(pos) {
return calibration_picture(pos);
}
return display(min(pow(layered(vec2<i32>(pos.xy)), vec3(2.2)), vec3(params.peak)));
}
@@ -0,0 +1,76 @@
override HDR_WRITE_LIGHT: bool = false;
// The light of colour `f` under the world's mark `a` (the alpha the world left, hdr_mark) where
// the world `shows`, else the colour clipped at white; and whether a light source lifted it.
// `eased` for the last pass, which eases it into the peak itself; the layered frame leaves that
// to the tone curve (fs_tonemap).
struct Lit {
light: vec3<f32>,
lifted: bool,
};
fn hdr_mark_light(f: vec3<f32>, a: f32, shows: bool, eased: bool, settings: vec4<f32>, shares: vec4<f32>) -> Lit {
var lifted = false;
// Light over 1 (a float frame's) shows only where the world does and carries
// no mark (alpha 1), up to the peak: light written as light. Marked pixels clip
// at white before their lift, as on a unorm frame, so light sources, the sun and
// HDR lighting look as they do there; so do the HUD, menus and HDR Lighting off.
let c = select(min(f, vec3(1.0)), f, shows && a == 1.0);
// Gamma 2.2, as SDR displays and the compositors' SDR paths decode it.
var light = pow(c, vec3(2.2));
// HDR lighting: alpha between 0.76 and 1 is how much of it the surface gets. Vanilla's
// light is albedo times lightmap, so this is the lightmap going past 1. It eases into the
// peak from 60% of it, so bright textures keep their detail. Unmarked light (alpha 1)
// gets no gain and no knee: the clamp to the peak below is all it needs here.
if shows && a >= 0.75 && a < 1.0 {
let top = max(light.r, max(light.g, light.b));
let gain = 1.0 + (settings.y - 1.0) * (1.0 - a) / 0.24;
let v = top * gain;
let knee = max(0.6 * settings.x, 1.0);
var out = v;
if eased && v > knee && settings.x > knee {
out = knee + (settings.x - knee) * (1.0 - exp(-(v - knee) / (settings.x - knee)));
}
light *= select(gain, out / max(top, 1e-4), eased && v > knee);
}
// The world's alpha is below 0.75 on light sources, the sun and the moon
// (terrain.wgsl, entity.wgsl): its band of 0.175 is the tier, the lower the
// brighter, and where in the band how much (hdr_mark).
if shows && a < 0.75 {
let band = u32(clamp(floor((a + 0.005) / 0.175), 0.0, 3.0));
let tier = 3u - band;
let lift = 1.0 - clamp((a - 0.175 * f32(band)) / 0.165, 0.0, 1.0);
if lift > 0.0 {
let top = max(light.r, max(light.g, light.b));
var gain = 1.0 + (settings.x - 1.0) * shares[tier] * lift;
if eased {
gain = min(gain, settings.x / max(top, 1e-4));
}
light *= max(gain, 1.0);
lifted = true;
}
}
// HORIZON_HDR_DEBUG=1: what isn't lifted turns grey, what is keeps its
// colour with a magenta tint, so a lift shows on any colour.
if settings.w > 0.5 && settings.z > 0.5 {
if lifted {
light *= vec3(1.0, 0.6, 1.0);
} else {
light = vec3(dot(light, vec3(0.2126, 0.7152, 0.0722)));
}
}
if eased {
light = min(light, vec3(settings.x));
}
return Lit(light, lifted);
}
// Marks are decoded at the precision of the original 8-bit frame, even in a float target.
fn hdr_quantized_mark(mark: f32) -> f32 {
return round(saturate(mark) * 255.0) / 255.0;
}
fn hdr_written(color: vec3<f32>, mark: f32, settings: vec4<f32>, shares: vec4<f32>) -> vec3<f32> {
let shows = settings.z > 0.5 && settings.x > 1.0;
return pow(hdr_mark_light(max(color, vec3(0.0)), hdr_quantized_mark(mark), shows, false, settings, shares).light, vec3(1.0 / 2.2));
}
+138 -55
View File
@@ -100,12 +100,18 @@ pub struct HudAtlas {
/// A resource pack's own `core/rendertype_lines` shader for the block outline, translated;
/// none draws the outline natively.
pub lines_shader: Option<std::sync::Arc<horizon_shaders::CoreProgram>>,
/// The packs' `core/sky` and `core/stars`, when a pack replaces them.
pub sky_shader: Option<std::sync::Arc<horizon_shaders::CoreProgram>>,
pub stars_shader: Option<std::sync::Arc<horizon_shaders::CoreProgram>>,
/// The packs' OptiFine random entity textures, whose variants this atlas packs.
pub random_textures: horizon_optifine::random_textures::RandomTextures,
/// Their emissive overlays (`_e`), packed here too.
pub emissive: std::sync::Arc<horizon_optifine::emissive::Emissive>,
/// ETF's blinking frames (`_blink`), packed here too.
pub blinks: horizon_optifine::blink::Blinks,
/// Of the shared atlas's textures, their LabPBR normal and specular maps as paged maps
/// (`paged_maps.rs`), read while loading for shader packs (`sprites::labpbr_maps`).
pub material_maps: std::sync::Arc<[Option<crate::paged_maps::PagedMap>; 2]>,
white: Rect,
}
/// Atlas rows reserved for glyphs rasterized at run time.
@@ -888,6 +894,10 @@ impl HudAtlas {
&[],
&crate::gfx::core_lines::GLUE,
);
let sky =
|name| pack_text::load_core(root, defaults, name, &[], &crate::gfx::core_sky::GLUE);
atlas.sky_shader = sky("sky");
atlas.stars_shader = sky("stars");
Ok(atlas)
}
/// Empty slots written at run time: map textures (game/maps.rs), the
@@ -967,6 +977,7 @@ impl HudAtlas {
revision: Self::next_revision(),
pixels: Vec::new(),
packed: None,
material_maps: Default::default(),
galactic_widths: [0; 128],
width: 1,
height: 1,
@@ -981,6 +992,8 @@ impl HudAtlas {
glint_armor: (Vec::new(), 1, 1),
text_shader: None,
lines_shader: None,
sky_shader: None,
stars_shader: None,
random_textures: Default::default(),
emissive: Arc::default(),
blinks: Default::default(),
@@ -1029,6 +1042,7 @@ impl HudAtlas {
(glyph_top, height - glyph_top),
white,
),
material_maps: Default::default(),
galactic_widths: galactic_widths(&sprites, &pixels, width, height),
pixels,
packed: None,
@@ -1045,6 +1059,8 @@ impl HudAtlas {
white,
text_shader: None,
lines_shader: None,
sky_shader: None,
stars_shader: None,
random_textures: Default::default(),
emissive: Default::default(),
blinks: Default::default(),
@@ -1192,9 +1208,21 @@ impl HudAtlas {
}
}
}
// The title panorama and the New World preset pictures load on their own. The
// Realms world-slot pictures are drawn from this atlas (vanilla draws their
// textures full size): the three faces and `presets/isles.png` stay, costing
// one 1024-tall shelf.
files.retain(|p| {
let s = p.to_string_lossy();
!s.contains("title/background") && !s.contains("presets")
let s = p.to_string_lossy().replace('\\', "/");
let slot_picture = [
"textures/gui/title/background/panorama_0.png",
"textures/gui/title/background/panorama_2.png",
"textures/gui/title/background/panorama_3.png",
"textures/gui/presets/isles.png",
]
.iter()
.any(|kept| s.ends_with(kept));
slot_picture || (!s.contains("title/background") && !s.contains("presets"))
});
// OptiFine random entity variants, under the names their scan gives them (those
// outside `textures/` are `<ns>:optifine/random/...`).
@@ -1269,61 +1297,87 @@ impl HudAtlas {
extra.sort();
files.extend(extra);
}
type Decoded = (PackedImage, Option<TextureFlags>, Option<(u32, u32)>, bool);
let decode_one = |path: &PathBuf| -> Option<Decoded> {
let name = if let Some(name) = named.get(path) {
name.clone()
} else {
match path.strip_prefix(&textures) {
Ok(rel) => rel.with_extension("").to_string_lossy().replace('\\', "/"),
Err(_) => {
let rel = path.strip_prefix(&assets).ok()?.with_extension("");
let rel = rel.to_string_lossy().replace('\\', "/");
let (namespace, rest) = rel.split_once("/textures/")?;
format!("{namespace}:{rest}")
// A texture's LabPBR maps, as decoded (width, height, RGBA8), for shader packs.
type Maps = [Option<(u32, u32, Vec<u8>)>; 2];
let read_maps = full && crate::sprites::labpbr_maps();
type Decoded = (
PackedImage,
Option<TextureFlags>,
Option<(u32, u32)>,
bool,
Option<Box<Maps>>,
);
let decode_one =
|path: &PathBuf| -> Option<Decoded> {
let name = if let Some(name) = named.get(path) {
name.clone()
} else {
match path.strip_prefix(&textures) {
Ok(rel) => rel.with_extension("").to_string_lossy().replace('\\', "/"),
Err(_) => {
let rel = path.strip_prefix(&assets).ok()?.with_extension("");
let rel = rel.to_string_lossy().replace('\\', "/");
let (namespace, rest) = rel.split_once("/textures/")?;
format!("{namespace}:{rest}")
}
}
};
// LabPBR's maps beside a texture are the world's (sprites.rs), not images to draw.
if let Some(base) = name.strip_suffix("_n").or_else(|| name.strip_suffix("_s"))
&& textures.join(format!("{base}.png")).is_file()
{
return None;
}
let image = decode(path)
.map_err(|e| log::warn!("skipped GUI texture {}: {e}", path.display()))
.ok()?;
let mcmeta = horizon_core::prepared_files::read_to_string(
&path.with_extension("png.mcmeta"),
)
.ok();
let animation = animation_of(mcmeta.as_deref());
// An animated strip keeps its first frame.
let frames =
animation.is_some() || name.starts_with("block/") || name.starts_with("item/");
let (w, h, pixels) = if frames {
first_frame(image, animation.as_ref())
} else {
image
};
// The default texture's size, when a pack's differs from it.
let gui_size = default_textures
.as_ref()
.and_then(|d| png_size(&d.join(format!("{name}.png"))))
.map(|(dw, dh)| {
let side = dw.min(dh);
if frames { (side, side) } else { (dw, dh) }
})
.filter(|&size| size != (w, h));
let flags = mcmeta.as_deref().and_then(TextureFlags::from_mcmeta);
let animated = frames && animation.is_some();
let (gw, gh) = gui_size.unwrap_or((w, h));
let maps = read_maps
.then(|| {
let stem = path.file_stem()?.to_str()?;
let maps: Maps = ["_n", "_s"].map(|suffix| {
decode(&path.with_file_name(format!("{stem}{suffix}.png"))).ok()
});
maps.iter().any(Option::is_some).then(|| Box::new(maps))
})
.flatten();
// The Realms world-slot pictures are 1024-tall GUI textures drawn as
// they are; the cap that keeps other GUI textures small does not
// apply to them.
let tall_picture = matches!(
name.as_str(),
"gui/title/background/panorama_0"
| "gui/title/background/panorama_2"
| "gui/title/background/panorama_3"
| "gui/presets/isles"
);
(gw <= 1024 && (gh <= 512 || tall_picture || name.starts_with("font/")))
.then_some(((name, w, h, pixels), flags, gui_size, animated, maps))
};
// LabPBR's maps beside a texture are the world's (sprites.rs), not images to draw.
if let Some(base) = name.strip_suffix("_n").or_else(|| name.strip_suffix("_s"))
&& textures.join(format!("{base}.png")).is_file()
{
return None;
}
let image = decode(path)
.map_err(|e| log::warn!("skipped GUI texture {}: {e}", path.display()))
.ok()?;
let mcmeta =
horizon_core::prepared_files::read_to_string(&path.with_extension("png.mcmeta"))
.ok();
let animation = animation_of(mcmeta.as_deref());
// An animated strip keeps its first frame.
let frames =
animation.is_some() || name.starts_with("block/") || name.starts_with("item/");
let (w, h, pixels) = if frames {
first_frame(image, animation.as_ref())
} else {
image
};
// The default texture's size, when a pack's differs from it.
let gui_size = default_textures
.as_ref()
.and_then(|d| png_size(&d.join(format!("{name}.png"))))
.map(|(dw, dh)| {
let side = dw.min(dh);
if frames { (side, side) } else { (dw, dh) }
})
.filter(|&size| size != (w, h));
let flags = mcmeta.as_deref().and_then(TextureFlags::from_mcmeta);
let animated = frames && animation.is_some();
let (gw, gh) = gui_size.unwrap_or((w, h));
(gw <= 1024 && (gh <= 512 || name.starts_with("font/"))).then_some((
(name, w, h, pixels),
flags,
gui_size,
animated,
))
};
let threads = std::thread::available_parallelism().map_or(2, |n| n.get());
let chunk = files.len().div_ceil(threads).max(1);
let decoded: Vec<_> = std::thread::scope(|scope| {
@@ -1342,7 +1396,11 @@ impl HudAtlas {
let mut gui_sizes = HashMap::new();
let mut animated: Vec<String> = Vec::new();
let mut images: Vec<PackedImage> = Vec::with_capacity(decoded.len());
for (image, image_flags, gui_size, is_animated) in decoded {
let mut maps: HashMap<String, Box<Maps>> = HashMap::new();
for (image, image_flags, gui_size, is_animated, image_maps) in decoded {
if let Some(m) = image_maps {
maps.insert(image.0.clone(), m);
}
if let Some(f) = image_flags {
flags.insert(image.0.clone(), f);
}
@@ -1517,6 +1575,28 @@ impl HudAtlas {
}
sprite_animations.push((rect, animation));
}
// Each mapped texture's maps at its size in the atlas, paged.
let material_maps = if maps.is_empty() {
Default::default()
} else {
let mapped: Vec<crate::paged_maps::SpriteMaps> = maps
.iter()
.filter_map(|(name, m)| {
let rect = sprites.get(name)?;
let (tw, th) = rect.texels((width, height));
let x = (rect.u0 * width as f32).round() as u32;
let y = (rect.v0 * height as f32).round() as u32;
Some(crate::paged_maps::SpriteMaps {
rect: [x, y, tw, th],
maps: m.each_ref().map(|map| {
let (mw, mh, pixels) = map.as_ref()?;
crate::paged_maps::fit(pixels, (*mw, *mh), (tw, th))
}),
})
})
.collect();
crate::paged_maps::build((width, height), &mapped, MAX_ATLAS_SIZE)
};
let white = sprites["horizon/white"];
let glint = Self::glint_texture(root, defaults, "enchanted_glint_item");
let glint_armor = Self::glint_texture(root, defaults, "enchanted_glint_armor");
@@ -1531,6 +1611,7 @@ impl HudAtlas {
);
Ok(Self {
revision: Self::next_revision(),
material_maps: std::sync::Arc::new(material_maps),
galactic_widths: galactic_widths(&sprites, &pixels, width, height),
pixels,
packed: None,
@@ -1546,6 +1627,8 @@ impl HudAtlas {
glint_armor,
text_shader: None,
lines_shader: None,
sky_shader: None,
stars_shader: None,
random_textures,
emissive,
blinks,
@@ -12,8 +12,6 @@ impl Gpu {
let instance = crate::gfx::test_gpu::instance();
let adapter = pollster::block_on(instance.request_adapter(&Default::default())).ok()?;
if !hud_coverage::supported(
(false, true, true),
true,
adapter.limits().max_color_attachments,
adapter.get_downlevel_capabilities().flags,
adapter.get_texture_format_features(hud_coverage::FORMAT),
@@ -0,0 +1,11 @@
//! The HUD kit: small immediate-mode pieces Horizon's own overlays share, so they fit around
//! vanilla's HUD and look alike (`docs/ui-kit.md`). Nothing here reaches gameplay; the game
//! builds the inputs (`Game::hud_room`) and the overlays draw with them.
//!
//! - `room`: what of a view an overlay may use, clear of the boss bars.
//! - `plate`: the box behind a notice's text.
//!
//! Vanilla's own display lists (`hud_layout`, `screen_draw`) never use the kit: they stay
//! exactly vanilla's.
pub mod plate;
pub mod room;
@@ -0,0 +1,64 @@
//! Plates: the boxes Horizon's HUD overlays draw behind their text, one place for each look so
//! overlays that mean the same thing look the same.
//!
//! A plate is drawn first, then the overlay's text and glyphs over it. Only the kinds the
//! overlays use today are here; each keeps the colours its overlay always had. Today that is
//! one, shared by the controller notice and splitscreen's prompts.
//!
//! ```
//! use horizon_client_render::hud_kit::plate::Plate;
//!
//! // A notice's box: a dark fill and a faint 1 px edge inside its area.
//! assert_eq!(Plate::Notice.fill(), 0xD200_0000);
//! assert_eq!(Plate::Notice.edge(), Some(0x5AFF_FFFF));
//! ```
//!
//! In a draw: `plate::draw(batch, atlas, Plate::Notice, [x, y, w, h])`, the area in GUI px.
use crate::hud::{HudAtlas, HudBatch, rgba};
/// A plate's look.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Plate {
/// Something to read now: controller notices and splitscreen's prompts. A dark fill with a
/// faint edge.
Notice,
}
impl Plate {
/// The fill colour as `0xAARRGGBB`.
pub fn fill(self) -> u32 {
match self {
Self::Notice => 0xD200_0000,
}
}
/// The 1 GUI px edge's colour as `0xAARRGGBB`, drawn inside the area; `None` for none.
pub fn edge(self) -> Option<u32> {
match self {
Self::Notice => Some(0x5AFF_FFFF),
}
}
}
/// `[a, r, g, b]` of `0xAARRGGBB` as the batch's colour.
fn colour(argb: u32) -> u32 {
let [a, r, g, b] = argb.to_be_bytes();
rgba(r, g, b, a)
}
/// Draws `plate` over `[x, y, w, h]` (GUI px): its fill, then its edge inside the area.
pub fn draw(batch: &mut HudBatch, atlas: &HudAtlas, plate: Plate, [x, y, w, h]: [f32; 4]) {
batch.fill(atlas, x, y, w, h, colour(plate.fill()));
if let Some(edge) = plate.edge() {
let edge = colour(edge);
for [ex, ey, ew, eh] in [
[x, y, w, 1.0],
[x, y + h - 1.0, w, 1.0],
[x, y, 1.0, h],
[x + w - 1.0, y, 1.0, h],
] {
batch.fill(atlas, ex, ey, ew, eh, edge);
}
}
}
@@ -0,0 +1,137 @@
//! Room: what of a view Horizon's own HUD overlays may use. Vanilla's HUD elements are
//! keep-outs; an overlay asks the room where it fits instead of assuming a fixed spot, so it
//! doesn't cover them. Today the only keep-out is the boss bars at the top centre.
//!
//! The room is built once a frame from what the HUD shows (`Game::hud_room` in gameplay). With
//! nothing showing it is empty, and every overlay stays exactly where it always was.
//!
//! All sizes are GUI px, from the view's top left. An area is `[x, y, w, h]`.
//!
//! ```
//! use horizon_client_render::hud_kit::room::{Keep, Room};
//! use horizon_client_render::hud_overlays::boss_bars_bottom;
//!
//! // A centred notice wants y = 18.
//! let empty = Room::new(320.0, 240.0);
//! assert_eq!(empty.below_top(18.0), 18.0);
//! // One boss bar ends at y 17: no overlap, so the notice stays.
//! let one = Room::new(320.0, 240.0).with(Keep::BossBars, [69.0, 0.0, 182.0, 17.0]);
//! assert_eq!(one.below_top(18.0), 18.0);
//! // Two end at y 36: the notice goes below them, a gap past.
//! let bars = boss_bars_bottom(240, 2) as f32;
//! let two = Room::new(320.0, 240.0).with(Keep::BossBars, [69.0, 0.0, 182.0, bars]);
//! assert_eq!(two.below_top(18.0), bars + 2.0);
//! ```
/// An area in GUI px: `[x, y, w, h]` from the view's top left.
pub type Area = [f32; 4];
/// The gap, in GUI px, an overlay leaves below a keep-out it moved past.
pub const GAP: f32 = 2.0;
/// A HUD element Horizon's overlays keep clear of.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Keep {
/// The boss bars and their names at the top centre (`hud_overlays::boss_bars_bottom`).
BossBars,
}
/// A view and the keep-outs its HUD shows this frame.
///
/// Invariants: the view's size is what the overlays draw in (the `HudBatch`'s size), and an
/// empty keep-out (no width or height) is never stored, so a room built from hidden elements
/// equals `Room::new`.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Room {
width: f32,
height: f32,
keeps: Vec<(Keep, Area)>,
}
impl Room {
/// A `width` x `height` GUI px view with nothing to keep clear of.
pub fn new(width: f32, height: f32) -> Self {
Self {
width,
height,
keeps: Vec::new(),
}
}
/// This room with `area` kept clear of as `keep`; an empty area is ignored.
pub fn with(mut self, keep: Keep, area: Area) -> Self {
self.add(keep, area);
self
}
/// Keeps clear of `area` as `keep`; an empty area is ignored.
pub fn add(&mut self, keep: Keep, area: Area) {
if area[2] > 0.0 && area[3] > 0.0 {
self.keeps.push((keep, area));
}
}
/// The view's width in GUI px.
pub fn width(&self) -> f32 {
self.width
}
/// The view's height in GUI px.
pub fn height(&self) -> f32 {
self.height
}
/// The keep-outs, in the order they were added.
pub fn keeps(&self) -> impl Iterator<Item = (Keep, Area)> + '_ {
self.keeps.iter().copied()
}
/// How far, in GUI px from the view's top, the keep-outs at the top reach down: the boss
/// bars' bottom, or 0 with none.
pub fn top(&self) -> f32 {
self.keeps()
.map(|(Keep::BossBars, [_, y, _, h])| y + h)
.fold(0.0, f32::max)
}
/// Where a centred overlay that wants its top at `wanted` (GUI px) goes: at `wanted` unless
/// a keep-out reaches past it (`top() > wanted`, a real overlap; touching isn't one), else
/// `GAP` below that keep-out.
pub fn below_top(&self, wanted: f32) -> f32 {
let top = self.top();
if top > wanted { top + GAP } else { wanted }
}
/// The view below the top keep-outs, with `GAP` past them: where a centred overlay may go.
/// The whole view when nothing is kept clear of.
pub fn usable(&self) -> Area {
let top = self.top();
let top = if top > 0.0 { top + GAP } else { 0.0 };
[0.0, top, self.width, (self.height - top).max(0.0)]
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn an_empty_room_is_the_whole_view_and_moves_nothing() {
let room = Room::new(320.0, 240.0).with(Keep::BossBars, [69.0, 0.0, 182.0, 0.0]);
assert_eq!(room, Room::new(320.0, 240.0));
assert_eq!(room.usable(), [0.0, 0.0, 320.0, 240.0]);
assert_eq!(room.below_top(18.0), 18.0);
}
#[test]
fn an_overlay_moves_only_when_the_bars_reach_past_it() {
let bars =
|bottom: f32| Room::new(500.0, 300.0).with(Keep::BossBars, [159.0, 0.0, 182.0, bottom]);
// Ending above or at its top: no overlap.
assert_eq!(bars(17.0).below_top(18.0), 18.0);
assert_eq!(bars(18.0).below_top(18.0), 18.0);
// Past it: below, a gap away.
assert_eq!(bars(36.0).below_top(18.0), 38.0);
assert_eq!(bars(36.0).usable(), [0.0, 38.0, 500.0, 262.0]);
}
}
@@ -571,6 +571,41 @@ pub fn boss_overlay(w: i32, h: i32, bars: &[BossBar], font: &Font) -> Vec<GuiDra
out
}
/// `BossHealthOverlay`'s first bar's top edge, in GUI px (its name sits 9 px above).
pub const BOSS_BAR_TOP: i32 = 12;
/// `BossHealthOverlay`'s step from one bar to the next, in GUI px (`10 + 9`).
pub const BOSS_BAR_STEP: i32 = 10 + 9;
/// A boss bar's sprite height, in GUI px.
pub const BOSS_BAR_HEIGHT: i32 = 5;
/// A boss bar's sprite width, in GUI px; it is centred on the view.
pub const BOSS_BAR_WIDTH: i32 = 182;
/// How many of `n` boss bars `BossHealthOverlay.extractRenderState` draws on a view `h` GUI px
/// tall: it stops once the next bar's top reaches a third of the height (integer division,
/// as vanilla's `guiHeight() / 3`), but always draws the first.
pub fn boss_bars_drawn(h: i32, n: usize) -> usize {
let mut drawn = 0;
let mut y = BOSS_BAR_TOP;
while drawn < n {
drawn += 1;
y += BOSS_BAR_STEP;
if y >= h / 3 {
break;
}
}
drawn
}
/// The bottom edge, in GUI px from the view's top, of the last of `n` boss bars a view `h` GUI
/// px tall shows (`boss_overlay`'s layout); 0 when there are none. Names sit above their bar,
/// so nothing of the overlay reaches below this.
pub fn boss_bars_bottom(h: i32, n: usize) -> i32 {
match boss_bars_drawn(h, n) {
0 => 0,
k => BOSS_BAR_TOP + BOSS_BAR_STEP * (k as i32 - 1) + BOSS_BAR_HEIGHT,
}
}
/// `JumpableVehicleBar.extractBackground`: `cooldown` is the mount's jump
/// cooldown and `scale` the player's `getJumpRidingScale()`.
pub fn jump_bar(w: i32, h: i32, cooldown: i32, scale: f32) -> Vec<GuiDraw> {
@@ -1381,3 +1416,64 @@ mod text_position_tests {
assert_eq!(relative, Some(-4));
}
}
#[cfg(test)]
mod boss_bar_room_tests {
use super::*;
/// `BossHealthOverlay.extractRenderState` worked by hand: bars at y 12, 31, 50, 69, 88...,
/// each 5 tall, until the next top reaches `guiHeight() / 3`.
#[test]
fn boss_bars_end_where_vanillas_overlay_stops() {
assert_eq!(boss_bars_bottom(300, 0), 0);
assert_eq!(boss_bars_bottom(300, 1), 17);
assert_eq!(boss_bars_bottom(300, 2), 36);
assert_eq!(boss_bars_bottom(300, 3), 55);
// A third of 300 is 100: the fifth bar is the last (its next top would be 107).
assert_eq!(boss_bars_drawn(300, 9), 5);
assert_eq!(boss_bars_bottom(300, 9), 93);
// A short view still draws the first.
assert_eq!(boss_bars_bottom(60, 3), 17);
// `guiHeight() / 3` is integer division: 152 / 3 = 50 stops at two, 153 / 3 = 51 not.
assert_eq!(boss_bars_drawn(152, 3), 2);
assert_eq!(boss_bars_drawn(153, 3), 3);
}
#[test]
fn boss_bars_bottom_is_below_every_drawn_bar() {
// The missing-glyph metrics: no game assets needed.
let font = Font::load(
std::path::Path::new("/nonexistent-horizon-hud-test-resources"),
&std::collections::HashMap::new(),
&[],
(1, 1),
(0, 0),
crate::hud::Rect {
u0: 0.0,
v0: 0.0,
u1: 1.0,
v1: 1.0,
w: 1,
h: 1,
},
);
let bars: Vec<BossBar> = (0..6)
.map(|_| BossBar {
name: Text::literal(""),
progress: 1.0,
color: 0,
overlay: 0,
})
.collect();
for h in [60, 120, 152, 153, 240, 300, 600] {
let bottom = boss_overlay(400, h, &bars, &font)
.iter()
.filter_map(|d| match d {
GuiDraw::Sprite { y, h, .. } => Some(y + h),
_ => None,
})
.max();
assert_eq!(bottom, Some(boss_bars_bottom(h, bars.len())), "height {h}");
}
}
}
+5
View File
@@ -5,6 +5,7 @@ pub mod assets;
pub mod atlas_sources;
pub mod audio;
pub mod auth;
pub mod autotune;
pub mod ban_notice;
pub mod bidi;
pub mod biome;
@@ -54,6 +55,7 @@ pub mod graphics_style;
pub mod graphics_ui;
pub mod hdr_calibration;
pub mod hud;
pub mod hud_kit;
pub mod hud_layout;
pub mod hud_overlays;
pub mod inventory_effects;
@@ -84,6 +86,7 @@ pub mod pack_screen;
pub mod packs;
pub mod pad_cursor;
pub mod pad_glyph;
pub mod paged_maps;
pub mod par;
pub mod particles;
pub mod poi_sections;
@@ -107,6 +110,7 @@ pub mod shader_pack_list;
pub mod shader_ui;
pub mod signs;
pub mod skins;
pub mod social;
pub mod sound_engine;
pub mod sound_events;
pub mod sound_preview;
@@ -126,6 +130,7 @@ pub mod test_block;
pub mod test_instance_block;
pub mod testgen;
pub mod title_edition;
pub mod touch;
pub mod trims;
pub mod ui;
pub mod vault;
+4 -2
View File
@@ -653,15 +653,17 @@ fn pack_lighting(
sky_light: bool,
) -> Vec<Light> {
let open = if sky_light { 0xF0 } else { 0x00 };
let mut data = [open; 4096];
(0..sections)
.map(|si| {
if si * 16 >= h {
return Light::Uniform(open);
}
let mut data = Box::new([open; 4096]);
for ly in 0..16 {
let y = si * 16 + ly;
if y >= h {
let out_row = ly << 8;
data[out_row..out_row + 256].fill(open);
continue;
}
let y_offset = y * (W * W);
@@ -674,7 +676,7 @@ fn pack_lighting(
}
}
}
Light::packed(data)
Light::from_slice(&data)
})
.collect()
}
+118 -7
View File
@@ -9,6 +9,8 @@ use crate::{
};
pub mod cache;
mod mesh;
pub mod packed;
mod samples;
use horizon_world::registry::BlockStateId;
use std::{
collections::VecDeque,
@@ -559,7 +561,8 @@ pub(crate) fn state_kinds(facts: &BlockFacts) -> Vec<u8> {
}
/// Blocks that fill their cell but neither draw solid nor collide as a full
/// block: far terrain draws them as blocks, or patches of powder snow leave
/// holes in mountains (and paths and fields dips).
/// holes in mountains (and paths and fields dips). Slabs use the same
/// full-cell approximation as stairs, so distant slab builds remain visible.
fn nearly_full(name: &str) -> bool {
matches!(
name,
@@ -568,6 +571,7 @@ fn nearly_full(name: &str) -> bool {
| "minecraft:farmland"
| "minecraft:honey_block"
) || name.ends_with("_stairs")
|| name.ends_with("_slab")
|| name.contains("fence")
|| name.contains("_wall")
|| name.contains("bars")
@@ -954,7 +958,7 @@ type Reduced = FxHashMap<(i32, i32), Arc<ReducedColumns>>;
/// every tile's inputs from it (gathering on the render thread stalled the
/// frame, tens of milliseconds for a large job on a 4-thread machine).
struct Snapshot {
samples: FxHashMap<TileKey, Arc<Vec<Column>>>,
samples: samples::Samples,
saved: Saved,
reduced: Reduced,
/// The plan's tiles, to tell terrain not drawn yet from terrain out of
@@ -1264,6 +1268,8 @@ pub struct Lod {
/// Stale tiles `refresh`ed again while sampled: that sample may be older.
restale: FxHashSet<TileKey>,
active: FxHashSet<TileKey>,
/// The active tiles' `ready` samples, as mesh jobs read them (`sync_sample`).
mesh_samples: samples::Samples,
/// Tiles needing a mesh, with the revision their job must carry.
dirty: FxHashMap<TileKey, u64>,
/// The newest revision of each active tile's mesh.
@@ -1414,7 +1420,13 @@ impl Lod {
&edges,
&input.finer,
);
// Sorts the quads by facing side, and clears
// the compact layout: a far tile has no tints
// for `mesher::packed`, so its own records
// (`lod::packed`) are laid out here, from the
// quads in the order the sort left them.
mesh.sort_solid();
crate::lod::packed::lay_out(&mut mesh);
let [ox, _, oz] = job.key.origin();
let size = job.key.size();
mesh.keep = keep_finer
@@ -1648,6 +1660,7 @@ impl Lod {
ready: FxHashMap::default(),
complete: FxHashMap::default(),
active: FxHashSet::default(),
mesh_samples: samples::Samples::default(),
dirty: FxHashMap::default(),
mesh_version: FxHashMap::default(),
shown_version: FxHashMap::default(),
@@ -1926,9 +1939,11 @@ impl Lod {
if active != was_active {
if active {
self.active.insert(node);
self.sync_sample(node);
self.removed_pending.remove(&node);
} else {
self.active.remove(&node);
self.sync_sample(node);
self.removed_pending.insert(node);
self.cancel_mesh(node);
self.mesh_version.remove(&node);
@@ -2201,6 +2216,7 @@ impl Lod {
}
}
for key in modified {
self.sync_sample(key);
self.mark_data_changed(key);
}
}
@@ -2262,6 +2278,7 @@ impl Lod {
return;
}
let existed = self.ready.insert(key, Arc::new(samples)).is_some();
self.sync_sample(key);
self.refresh_ready(key, existed);
}
}
@@ -2496,6 +2513,8 @@ impl Lod {
.collect();
self.plan = plan;
self.ready.retain(|key, _| self.plan.nodes.contains(key));
let nodes = &self.plan.nodes;
self.mesh_samples.retain(|key| nodes.contains(key));
// Queued tiles the view left are not sampled (a running one is
// dropped when it finishes, `finish_sample`).
drop_queued_samples(&self.shared, &mut self.pending, |key| {
@@ -2563,6 +2582,7 @@ impl Lod {
.retain(|key| !self.active.contains(key));
let changed: Vec<_> = old.symmetric_difference(&self.active).copied().collect();
for &key in &changed {
self.sync_sample(key);
if old.contains(&key) && !self.active.contains(&key) {
self.cancel_mesh(key);
self.removed_pending.insert(key);
@@ -2848,12 +2868,10 @@ impl Lod {
if keys.is_empty() {
return;
}
#[cfg(debug_assertions)]
self.check_mesh_samples();
let snapshot = Arc::new(Snapshot {
samples: self
.active
.iter()
.filter_map(|key| self.ready.get(key).map(|columns| (*key, columns.clone())))
.collect(),
samples: self.mesh_samples.clone(),
saved: self.saved.clone(),
reduced: self.reduced.clone(),
nodes: self.plan.nodes.clone(),
@@ -2886,6 +2904,31 @@ impl Lod {
self.outstanding_meshes += count;
self.shared.mesh_wake.notify_all();
}
/// Brings `mesh_samples` up to date for `key` after its `active` or `ready` changed.
fn sync_sample(&mut self, key: TileKey) {
let samples = self.ready.get(&key).filter(|_| self.active.contains(&key));
self.mesh_samples.set(key, samples);
}
/// `mesh_samples` holds every active tile's ready samples and nothing else (debug builds).
#[cfg(debug_assertions)]
fn check_mesh_samples(&self) {
let kept = self.mesh_samples.iter().count();
let mut want = 0;
for key in &self.active {
if let Some(columns) = self.ready.get(key) {
want += 1;
let got = self.mesh_samples.get(key);
assert!(
got.is_some_and(|got| Arc::ptr_eq(got, columns)),
"mesh samples of {key:?} out of date"
);
}
}
assert_eq!(
kept, want,
"mesh samples keep tiles no longer active or ready"
);
}
fn finer_of(&self, key: TileKey) -> Vec<TileKey> {
if !self.plan.split.contains(&key) {
return Vec::new();
@@ -3977,6 +4020,73 @@ mod tests {
}
#[test]
#[ignore = "requires prepared models/textures in HORIZON_TEST_RESOURCES"]
fn slab_materials_survive_chunk_summaries_and_draw_far_faces() -> crate::Result<()> {
use crate::{assets::Assets, biome::Biomes, light::LightTables, mesher::MeshTables};
let root = std::path::PathBuf::from(
std::env::var_os("HORIZON_TEST_RESOURCES").expect("HORIZON_TEST_RESOURCES"),
);
let assets = Arc::new(Assets::load(&root)?);
let render = Arc::new(assets.reload(&root)?);
let facts = BlockFacts::load(&root, assets.registry)?;
let context = WorkerContext {
light: Arc::new(LightTables::load(&root, assets.registry, &facts)?),
tables: Arc::new(MeshTables::new(
&assets,
&render,
&facts,
crate::models::load_visibility(&root, assets.registry)?,
)?),
assets: assets.clone(),
render,
biomes: Arc::new(Biomes::load(&root)?),
};
let kinds = state_kinds(&facts);
let mut chunk = Chunk::empty(0, 0);
let mut mesher = mesh::Mesher::default();
let mut materials = FxHashSet::default();
// Real top, bottom, double and waterlogged states: a waterlogged slab
// must keep its material rather than become a column of plain water.
for (i, f) in facts.states.iter().enumerate() {
if !f.name.ends_with("_slab") {
continue;
}
materials.insert(f.name.as_ref());
let state = BlockStateId(i as u32);
chunk.set(3, 90, 3, state.0);
let columns = summarize(&chunk, &kinds);
let column = &columns[3 * 16 + 3];
assert_eq!(column.spans.len(), 1, "{} state {i}", f.name);
assert_eq!(column.spans[0].state, state, "{} state {i}", f.name);
assert_eq!((column.spans[0].min, column.spans[0].max), (90, 91));
assert_eq!(Column::reduced(&columns, 0, 0, 4).spans, column.spans);
let mesh = mesher.mesh(
TileKey {
x: 0,
z: 0,
level: 0,
},
&columns.iter().collect::<Vec<_>>(),
&FxHashSet::default(),
None,
&context,
&std::array::from_fn(|_| Vec::new()),
&[],
);
// Like stairs, far slabs use the existing full-cell approximation.
assert_eq!(mesh.solid.len(), 6 * 4, "{} state {i}", f.name);
assert!(mesh.translucent.is_empty(), "{} state {i}", f.name);
}
for name in [
"minecraft:smooth_stone_slab",
"minecraft:oak_slab",
"minecraft:cut_copper_slab",
] {
assert!(materials.contains(name), "missing fixture {name}");
}
Ok(())
}
#[test]
#[ignore = "requires prepared models/textures in HORIZON_TEST_RESOURCES"]
fn real_mesh_clips_near_chunks_and_preserves_water_and_edited_surfaces() -> crate::Result<()> {
use crate::{
assets::Assets, biome::Biomes, light::LightTables, mesher::MeshTables,
@@ -4776,6 +4886,7 @@ mod tests {
lod.active.insert(key);
lod.ready
.insert(key, Arc::new(vec![Column::default(); CELLS * CELLS]));
lod.sync_sample(key);
lod.mark_mesh(key);
lod.set_near_loading(true);
lod.dispatch_meshes([0, 0]);
@@ -1386,6 +1386,52 @@ mod tests {
let p = |i: usize| glam::Vec3::from(q[i].pos);
(p(1) - p(0)).cross(p(2) - p(0))
}
/// Every solid quad the mesher emits packs into a far record, and the
/// record gives the quad back bit for bit (`lod::packed`).
///
/// `lod::packed`'s own tests check its records against its own copy of what
/// `emit_quad` does, which would pass just as well if the two had drifted
/// apart. This checks them against the real mesher, over terrain that makes
/// faces of every axis and winding: a hill of varied heights, a material
/// boundary, a light boundary and water.
#[test]
fn every_quad_the_mesher_emits_packs_and_comes_back() {
let mut columns = columns();
for (i, column) in columns.iter_mut().enumerate() {
let (x, z) = (i % CELLS, i / CELLS);
let top = 4 + (x as i16 % 5) * 2 + (z as i16 % 3);
let state = if (x + z) % 7 == 0 { 3 } else { 1 };
let light = if x % 4 == 0 { 16 } else { 240 };
column.spans = vec![
Span {
light,
..span(0, top, state)
},
// Water over the lower ground, for the fluid faces too.
span(top, 12.max(top + 1), 2),
]
.into();
}
let mesh = mesh(&columns);
let quads = mesh.solid.as_chunks::<4>().0;
assert!(
quads.len() > 50,
"{} quads is too few to say much",
quads.len()
);
for (i, quad) in quads.iter().enumerate() {
let words = crate::lod::packed::pack(quad)
.unwrap_or_else(|| panic!("quad {i} of {} did not pack", quads.len()));
let back = crate::lod::packed::corners(words)
.unwrap_or_else(|| panic!("quad {i}'s record names no face"));
assert_eq!(
bytemuck::cast::<_, [[u32; 6]; 4]>(back),
bytemuck::cast::<_, [[u32; 6]; 4]>(*quad),
"quad {i} came back changed"
);
}
}
#[test]
fn flat_solid_cube_merges_to_six_faces_with_block_scaled_uvs() {
let mut columns = columns();
@@ -0,0 +1,440 @@
//! The compact layout of a far tile's solid quads in the arena: one 24-byte
//! record each instead of four 24-byte vertices.
//!
//! A far tile's quads are not blocks' faces -- they are merged rectangles of a
//! voxel column's exposed side, hundreds of blocks wide -- so none of them fits
//! `mesher::packed`'s record, whose coordinates are a block grid of 16. They
//! are far more regular than a chunk's quads instead: a rectangle in an
//! axis-aligned plane, with one colour, one light and one sprite layer across
//! all four corners, and UVs that `lod::mesh::emit_quad` derives from the
//! positions. So a record holds what that function was given, and
//! terrain.wgsl's `far_corner` does what it did:
//!
//! - word 0: the colour (RGBA8), the same for all four corners;
//! - word 1: the sprite layer, and the light in the high half;
//! - word 2: the plane, the coordinate all four corners share, as an `i32`;
//! - word 3: the rectangle's low edge along the face's first axis, as an `i32`;
//! - word 4: its low edge along the second, as an `i32`;
//! - word 5: the plane's axis, whether the corners are reversed, the
//! rectangle's width and height, and `FULL` clear.
//!
//! Nothing here reasons about which record is right for a quad: `pack` builds
//! one, rebuilds the four vertices from it with the same code the shader
//! mirrors, and keeps it only if they come back bit for bit. A quad no record
//! reproduces -- a fractional coordinate, a rectangle too wide, a face whose
//! UVs were scaled down to fit (`lod::mesh::MAX_PIECES`) -- is kept as its four
//! vertices, exactly as `mesher::packed` keeps one.
use crate::mesher::{TerrainVertex, packed};
/// Word 5's bit of a quad kept as four vertices; word 0 is then the slots from
/// the record to its first vertex. The same bit `mesher::packed` uses, so the
/// two layouts place their records and spilled vertices alike.
pub use crate::mesher::packed::FULL;
/// The draws' base vertex of a compact far mesh, above `packed::PACKED_BASE`:
/// `FAR_BASE + 4 * slot + corner` is a corner of the quad whose record is at
/// `slot`. terrain.wgsl's `section_corner` reads the layout off the index, so
/// a far tile and a chunk section can share one arena and one pipeline.
pub const FAR_BASE: u32 = 1 << 29;
/// Whether far tiles meshed from now on get this layout: `HORIZON_FAR_PACK=0`
/// stops them and leaves chunk sections' own layout alone, so the two can be
/// told apart in one build. `HORIZON_PACKED_QUADS=0` stops both.
pub fn far_packing() -> bool {
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*ON.get_or_init(|| std::env::var("HORIZON_FAR_PACK").as_deref() != Ok("0"))
}
/// The widest rectangle a record's 11-bit width and height hold. `lod::mesh`
/// splits a face at `MAX_FACE` = 1024 blocks unless it scales its UVs instead,
/// and a scaled face does not pack, so this is never the binding limit.
const MAX_EXTENT: i64 = (1 << 11) - 1;
/// Which axis a face's plane lies on, and what `lod::mesh::emit_quad` makes of
/// the other two. The names are that function's: `u` is the rectangle's first
/// axis and `v` its second, and the UV of a corner is `[u, -v]` of it.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
enum Axis {
/// Up and Down: the plane is y, u is x and v is z.
Y,
/// North and South: the plane is z, u is x and v is y.
Z,
/// West and East: the plane is x, u is z and v is y.
X,
}
impl Axis {
const ALL: [Self; 3] = [Self::Y, Self::Z, Self::X];
fn bits(self) -> u32 {
match self {
Self::Y => 0,
Self::Z => 1,
Self::X => 2,
}
}
#[cfg(test)]
fn from_bits(bits: u32) -> Option<Self> {
Self::ALL.into_iter().find(|a| a.bits() == bits)
}
}
/// A face as `lod::mesh::emit_quad` was given it, which is all a record holds.
#[derive(Clone, Copy, Debug)]
struct Face {
axis: Axis,
/// Whether the corners go round the other way, as they do for Down, South
/// and East (that function's `points.reverse()`).
reversed: bool,
plane: i32,
u0: i32,
v0: i32,
du: u32,
dv: u32,
layer: u16,
light: u16,
color: u32,
}
impl Face {
/// The four vertices of it, as `lod::mesh::emit_quad` writes them. Kept
/// here and not shared with that function because it is what the shader
/// mirrors: the two have to agree, and `a_record_rebuilds_what_the_mesher_
/// emitted` is what holds them to it.
fn vertices(self) -> [TerrainVertex; 4] {
let (p, u0, v0) = (self.plane as f32, self.u0 as f32, self.v0 as f32);
let u1 = u0 + self.du as f32;
let v1 = v0 + self.dv as f32;
let mut points = match self.axis {
Axis::Y => [[u0, p, v1], [u1, p, v1], [u1, p, v0], [u0, p, v0]],
Axis::Z => [[u0, v1, p], [u1, v1, p], [u1, v0, p], [u0, v0, p]],
Axis::X => [[p, v1, u1], [p, v1, u0], [p, v0, u0], [p, v0, u1]],
};
if self.reversed {
points.reverse();
}
let uvs = points.map(|pos| match self.axis {
Axis::Y => [pos[0], -pos[2]],
Axis::Z => [pos[0], -pos[1]],
Axis::X => [pos[2], -pos[1]],
});
let corner = [0, 1].map(|i| {
uvs.iter()
.map(|uv| uv[i])
.fold(f32::INFINITY, f32::min)
.floor()
});
let mut out = [TerrainVertex::tiled([0.0; 3], [0.0; 2], 0, 0, 0); 4];
for ((to, pos), uv) in out.iter_mut().zip(points).zip(uvs) {
*to = TerrainVertex::tiled(
pos,
[uv[0] - corner[0], uv[1] - corner[1]],
self.layer,
self.color,
self.light,
);
}
out
}
fn words(self) -> [u32; 6] {
[
self.color,
u32::from(self.layer) | u32::from(self.light) << 16,
self.plane as u32,
self.u0 as u32,
self.v0 as u32,
self.axis.bits() | u32::from(self.reversed) << 2 | self.du << 3 | self.dv << 14,
]
}
/// The face a record names, or `None` for a record that spills its quad's
/// vertices (`FULL`) or that does not name an axis.
#[cfg(test)]
fn from_words(w: [u32; 6]) -> Option<Self> {
if w[5] & FULL != 0 {
return None;
}
Some(Self {
axis: Axis::from_bits(w[5] & 3)?,
reversed: (w[5] >> 2) & 1 != 0,
plane: w[2] as i32,
u0: w[3] as i32,
v0: w[4] as i32,
du: (w[5] >> 3) & 0x7ff,
dv: (w[5] >> 14) & 0x7ff,
layer: w[1] as u16,
light: (w[1] >> 16) as u16,
color: w[0],
})
}
}
/// A whole number in `i32`, or `None`.
fn whole(v: f32) -> Option<i32> {
(v.fract() == 0.0 && (f32::from(i16::MIN) * 16.0..=f32::from(i16::MAX) * 16.0).contains(&v))
.then_some(v as i32)
}
/// `quad`'s record, if one gives back its four vertices exactly.
pub fn pack(quad: &[TerrainVertex; 4]) -> Option<[u32; 6]> {
let first = quad[0];
// One colour, one light and one layer across the four corners, which is
// what lets a record hold them once.
if quad
.iter()
.any(|v| (v.color, v.light, v.layer) != (first.color, first.light, first.layer))
{
return None;
}
let lo = [0, 1, 2].map(|k| quad.iter().map(|v| v.pos[k]).fold(f32::INFINITY, f32::min));
let hi = [0, 1, 2].map(|k| {
quad.iter()
.map(|v| v.pos[k])
.fold(f32::NEG_INFINITY, f32::max)
});
// Every axis and winding the mesher can have emitted; the round trip below
// says which one it was, so nothing here has to work it out.
for axis in Axis::ALL {
let (plane, u, v) = match axis {
Axis::Y => (1, 0, 2),
Axis::Z => (2, 0, 1),
Axis::X => (0, 2, 1),
};
if lo[plane] != hi[plane] {
continue;
}
let (Some(plane), Some(u0), Some(v0)) = (whole(lo[plane]), whole(lo[u]), whole(lo[v]))
else {
continue;
};
let (Some(u1), Some(v1)) = (whole(hi[u]), whole(hi[v])) else {
continue;
};
let (du, dv) = (i64::from(u1 - u0), i64::from(v1 - v0));
if du > MAX_EXTENT || dv > MAX_EXTENT {
continue;
}
for reversed in [false, true] {
let face = Face {
axis,
reversed,
plane,
u0,
v0,
du: du as u32,
dv: dv as u32,
layer: first.layer,
light: first.light,
color: first.color,
};
let words = face.words();
// The record is kept only where it gives the quad back exactly, so
// a quad this layout cannot hold is spilled rather than altered.
if bytemuck::cast::<_, [[u32; 6]; 4]>(face.vertices())
== bytemuck::cast::<_, [[u32; 6]; 4]>(*quad)
{
return Some(words);
}
}
}
None
}
/// The four corners a record names, as the shader rebuilds them; `None` for a
/// record that spills its quad's vertices. For the tests that hold this layout
/// and `lod::mesh` to each other.
#[cfg(test)]
pub fn corners(words: [u32; 6]) -> Option<[TerrainVertex; 4]> {
Face::from_words(words).map(Face::vertices)
}
/// Lays a far tile's solid quads out compactly in `mesh.packed`, where the
/// renderer reads that layout. Call it after `SectionMesh::sort_solid`, which
/// reorders the quads and clears whatever layout was there.
pub fn lay_out(mesh: &mut crate::mesher::SectionMesh) {
if !packed::packing() || !far_packing() {
return;
}
mesh.packed = layout(&mesh.solid);
mesh.packed_far = !mesh.packed.is_empty();
}
/// A far tile's solid quads laid out compactly: a record each in mesh order,
/// then the vertices of the quads no record fits. Empty where that would not
/// be smaller than the vertices.
pub fn layout(solid: &[TerrainVertex]) -> Vec<[u32; 6]> {
let quads = solid.as_chunks::<4>().0;
let records: Vec<Option<[u32; 6]>> = quads.iter().map(pack).collect();
packed::place(&records, quads)
}
#[cfg(test)]
mod tests {
use super::*;
/// The four corners as bits: `TerrainVertex` has no `PartialEq`, and bit
/// identity is the guarantee the layout makes in any case.
fn words_of(quad: [TerrainVertex; 4]) -> [[u32; 6]; 4] {
bytemuck::cast(quad)
}
fn face() -> Face {
Face {
axis: Axis::Y,
reversed: false,
plane: 71,
u0: -48,
v0: 112,
du: 16,
dv: 7,
layer: 3,
light: 0xF0F0,
color: 0xFF_80_40_20,
}
}
/// Every axis and winding survives the words, so `from_words` and the
/// shader's `far_corner` read what `words` wrote.
#[test]
fn a_face_survives_its_record() {
for axis in Axis::ALL {
for reversed in [false, true] {
let want = Face {
axis,
reversed,
..face()
};
let got = Face::from_words(want.words()).expect("a record names a face");
assert_eq!(
words_of(got.vertices()),
words_of(want.vertices()),
"{axis:?} {reversed}"
);
assert_eq!((got.axis, got.reversed), (axis, reversed));
assert_eq!((got.plane, got.u0, got.v0), (want.plane, want.u0, want.v0));
assert_eq!((got.du, got.dv), (want.du, want.dv));
assert_eq!(
(got.layer, got.light, got.color),
(want.layer, want.light, want.color)
);
}
}
}
/// The widest and the most distant rectangle a record claims to hold comes
/// back exactly, so the bit fields are wide enough for what they say.
#[test]
fn the_extremes_a_record_claims_come_back() {
let want = Face {
du: MAX_EXTENT as u32,
dv: MAX_EXTENT as u32,
plane: i32::from(i16::MAX),
u0: -8_000_000,
v0: 8_000_000,
layer: u16::MAX,
light: u16::MAX,
color: u32::MAX,
..face()
};
let got = Face::from_words(want.words()).expect("a record names a face");
assert_eq!((got.du, got.dv), (want.du, want.dv));
assert_eq!((got.plane, got.u0, got.v0), (want.plane, want.u0, want.v0));
assert_eq!(
(got.layer, got.light, got.color),
(want.layer, want.light, want.color)
);
}
/// Any quad the mesher could have emitted packs, and unpacks to the very
/// vertices it emitted: this is the whole guarantee the layout makes.
#[test]
fn a_record_rebuilds_what_the_mesher_emitted() {
let mut packed = 0;
for axis in Axis::ALL {
for reversed in [false, true] {
for (du, dv) in [(1, 1), (16, 1), (1, 16), (37, 91), (1024, 1024)] {
let want = Face {
axis,
reversed,
du,
dv,
..face()
};
let quad = want.vertices();
let words = pack(&quad).expect("the mesher's own quad packs");
let back = Face::from_words(words).expect("a record names a face");
assert_eq!(
words_of(back.vertices()),
words_of(quad),
"{axis:?} {reversed} {du}x{dv}"
);
packed += 1;
}
}
}
assert_eq!(packed, 30, "every case packed");
}
/// A quad this layout cannot hold is refused rather than altered: the
/// corners disagreeing on a colour, a fractional coordinate, and a
/// rectangle wider than the width field.
#[test]
fn a_quad_no_record_fits_is_refused() {
let mut uneven = face().vertices();
uneven[2].color ^= 1;
assert!(pack(&uneven).is_none(), "corners differ in colour");
let mut fraction = face().vertices();
fraction[0].pos[0] += 0.5;
assert!(pack(&fraction).is_none(), "a fractional coordinate");
let wide = Face {
du: MAX_EXTENT as u32 + 1,
..face()
};
assert!(pack(&wide.vertices()).is_none(), "wider than the field");
}
/// A tile of quads that all pack takes a quarter of the slots its vertices
/// would, which is the point of the layout.
#[test]
fn a_tile_that_packs_takes_a_quarter_of_the_slots() {
let mut solid = Vec::new();
for n in 0..64 {
solid.extend(
Face {
u0: n * 4,
..face()
}
.vertices(),
);
}
let out = layout(&solid);
assert_eq!(out.len(), solid.len() / 4, "a slot a quad, none spilled");
for (quad, record) in solid.as_chunks::<4>().0.iter().zip(&out) {
let face = Face::from_words(*record).expect("a record names a face");
assert_eq!(words_of(face.vertices()), words_of(*quad),);
}
}
/// A tile whose quads mostly spill keeps the vertices and gives up on the
/// layout rather than growing: `place` is what decides, and this holds it
/// to the same rule `mesher::packed` follows.
#[test]
fn a_tile_that_mostly_spills_keeps_its_vertices() {
let mut solid = Vec::new();
for n in 0..64 {
let mut quad = Face {
u0: n * 4,
..face()
}
.vertices();
quad[1].color ^= 1;
solid.extend(quad);
}
assert!(layout(&solid).is_empty(), "no layout smaller than vertices");
}
}
@@ -0,0 +1,105 @@
//! The samples mesh jobs read (`Snapshot::samples`): the active tiles' ready columns, kept
//! as the tiles change rather than gathered again for every batch of jobs. Kept in shards of
//! nearby tiles behind `Arc`s: a batch's copy (`clone`) copies the shards' handles, and a
//! change copies only its shard, and only while a job still reads it.
use super::{Column, TileKey};
use crate::fast_hash::FxHashMap;
use std::sync::Arc;
type Shard = FxHashMap<TileKey, Arc<Vec<Column>>>;
/// 8 by 8 tiles of one level a shard.
fn shard_of(key: TileKey) -> (i32, i32, u8) {
(key.x >> 3, key.z >> 3, key.level)
}
#[derive(Clone, Default)]
pub(super) struct Samples {
shards: FxHashMap<(i32, i32, u8), Arc<Shard>>,
}
impl Samples {
pub fn get(&self, key: &TileKey) -> Option<&Arc<Vec<Column>>> {
self.shards.get(&shard_of(*key))?.get(key)
}
/// Sets `key`'s samples (`None`: not active or not ready), copying its shard only when
/// they change.
pub fn set(&mut self, key: TileKey, samples: Option<&Arc<Vec<Column>>>) {
let at = shard_of(key);
match samples {
Some(samples) => {
let shard = self.shards.entry(at).or_default();
if shard.get(&key).is_none_or(|s| !Arc::ptr_eq(s, samples)) {
Arc::make_mut(shard).insert(key, samples.clone());
}
}
None => {
let Some(shard) = self.shards.get_mut(&at) else {
return;
};
if shard.contains_key(&key) {
Arc::make_mut(shard).remove(&key);
if shard.is_empty() {
self.shards.remove(&at);
}
}
}
}
}
/// Keeps the tiles `keep` accepts.
pub fn retain(&mut self, mut keep: impl FnMut(&TileKey) -> bool) {
self.shards.retain(|_, shard| {
if !shard.keys().all(&mut keep) {
Arc::make_mut(shard).retain(|key, _| keep(key));
}
!shard.is_empty()
});
}
#[cfg(any(test, debug_assertions))]
pub fn iter(&self) -> impl Iterator<Item = (&TileKey, &Arc<Vec<Column>>)> {
self.shards.values().flat_map(|shard| shard.iter())
}
}
impl FromIterator<(TileKey, Arc<Vec<Column>>)> for Samples {
fn from_iter<I: IntoIterator<Item = (TileKey, Arc<Vec<Column>>)>>(iter: I) -> Self {
let mut samples = Self::default();
for (key, columns) in iter {
samples.set(key, Some(&columns));
}
samples
}
}
#[cfg(test)]
mod tests {
use super::*;
fn key(x: i32, z: i32, level: u8) -> TileKey {
TileKey { x, z, level }
}
#[test]
fn a_change_leaves_a_batchs_copy_as_it_was() {
let a = Arc::new(Vec::new());
let b = Arc::new(Vec::new());
let mut live: Samples = [(key(0, 0, 0), a.clone()), (key(40, -3, 1), a.clone())]
.into_iter()
.collect();
let batch = live.clone();
live.set(key(0, 0, 0), Some(&b));
live.set(key(40, -3, 1), None);
live.set(key(-9, 2, 0), Some(&b));
assert!(Arc::ptr_eq(batch.get(&key(0, 0, 0)).unwrap(), &a));
assert!(batch.get(&key(40, -3, 1)).is_some());
assert!(batch.get(&key(-9, 2, 0)).is_none());
assert!(Arc::ptr_eq(live.get(&key(0, 0, 0)).unwrap(), &b));
assert!(live.get(&key(40, -3, 1)).is_none());
live.retain(|k| k.x < 0);
assert_eq!(
live.iter().map(|(k, _)| *k).collect::<Vec<_>>(),
[key(-9, 2, 0)]
);
assert_eq!(batch.iter().count(), 2);
}
}
+94 -5
View File
@@ -6,8 +6,8 @@
//! keeps 7 archives a day, the newest with the highest index.
//!
//! Messages go through the `log` facade. Horizon's own still print their plain text on stderr,
//! as they did before the log existed; other crates' errors only reach the file (their
//! warnings are mostly the Vulkan loader's startup chatter).
//! as they did before the log existed. Other crates, including native mods and their helper
//! crates, reach the file through INFO too, with their target prefixed to identify the source.
use std::collections::{HashMap, VecDeque};
use std::fs::{self, File, OpenOptions};
use std::io::{self, Read, Seek, SeekFrom, Write};
@@ -424,14 +424,18 @@ fn ours(target: &str) -> bool {
impl log::Log for Logger {
fn enabled(&self, meta: &log::Metadata) -> bool {
meta.level() <= log::Level::Info
&& (ours(meta.target()) || meta.level() <= log::Level::Error)
}
fn log(&self, record: &log::Record) {
if !self.enabled(record.metadata()) {
return;
}
let message = record.args().to_string();
let horizon = ours(record.target());
let message = if horizon {
record.args().to_string()
} else {
format!("[{}] {}", record.target(), record.args())
};
let current = std::thread::current();
let thread = match current.name() {
Some("main") => self.main_thread,
@@ -460,7 +464,7 @@ impl log::Log for Logger {
),
_ => {}
}
let stderr = ours(record.target()).then(|| message.clone());
let stderr = horizon.then(|| message.clone());
self.send(thread, level, &message, stderr);
if gate == Gate::Last {
self.write(
@@ -652,6 +656,91 @@ pub fn newest_crash_report(home: &Path) -> Option<PathBuf> {
mod tests {
use super::*;
#[test]
fn native_mod_records_reach_the_file_with_their_targets() {
use log::Log;
let dir =
std::env::temp_dir().join(format!("horizon-native-log-test-{}", std::process::id()));
fs::create_dir_all(&dir).unwrap();
let (out, receive) = mpsc::channel();
let writer = Writer {
file: Some(open_latest(&dir).unwrap().unwrap()),
dir: dir.clone(),
date: Local::now().date_naive(),
};
let handle = std::thread::spawn(move || writer.run(receive));
let logger = Logger {
out,
recent: Mutex::new(VecDeque::new()),
main_thread: "Render thread",
floods: Mutex::new(Floods::default()),
};
for (target, level, message) in [
("meridian_horizon::save", log::Level::Warn, "save failed"),
("meridian_core::map", log::Level::Info, "map opened"),
("wgpu_core::device", log::Level::Error, "device lost"),
("meridian_core::map", log::Level::Debug, "debug detail"),
("meridian_core::map", log::Level::Trace, "trace detail"),
] {
logger.log(
&log::Record::builder()
.args(format_args!("{message}"))
.level(level)
.target(target)
.build(),
);
}
logger.flush();
drop(logger);
handle.join().unwrap();
let text = fs::read_to_string(dir.join("latest.log")).unwrap();
fs::remove_dir_all(&dir).unwrap();
assert!(
text.contains("[meridian_horizon::save] save failed"),
"{text}"
);
assert!(text.contains("[meridian_core::map] map opened"), "{text}");
assert!(text.contains("[wgpu_core::device] device lost"), "{text}");
assert!(!text.contains("debug detail"));
assert!(!text.contains("trace detail"));
}
#[test]
fn horizon_stderr_and_external_file_records_stay_separate() {
use log::Log;
let (out, receive) = mpsc::channel();
let logger = Logger {
out,
recent: Mutex::new(VecDeque::new()),
main_thread: "Render thread",
floods: Mutex::new(Floods::default()),
};
for target in ["horizon_client::game", "meridian_core", "wgpu_hal::vulkan"] {
logger.log(
&log::Record::builder()
.args(format_args!("diagnostic"))
.level(log::Level::Info)
.target(target)
.build(),
);
let Out::Write {
stderr,
record: (_, _, message),
..
} = receive.try_recv().unwrap()
else {
panic!("a diagnostic must write a record")
};
if ours(target) {
assert_eq!(stderr.as_deref(), Some("diagnostic"));
assert_eq!(message, "diagnostic");
} else {
assert!(stderr.is_none());
assert_eq!(message, format!("[{target}] diagnostic"));
}
}
}
#[test]
fn a_player_dir_keeps_the_shared_files_in_the_game_folder() {
let (game, player) = (Path::new("/games/shared"), Path::new("/games/players/alex"));
+29 -5
View File
@@ -202,20 +202,44 @@ impl MenuBlur {
target: &wgpu::TextureView,
size: [u32; 2],
radius: f32,
mut timing: Option<&mut crate::gfx::pack_timing::PassTiming>,
timing: Option<&mut crate::gfx::pack_timing::PassTiming>,
) {
self.ensure(device, size);
let work = self.work_size(size);
let copy = if self.half { 2 } else { 0 };
let copy = self.source(device, size).0;
encoder.copy_texture_to_texture(
frame.as_image_copy(),
self.targets[copy].0.as_image_copy(),
copy.as_image_copy(),
wgpu::Extent3d {
width: size[0],
height: size[1],
depth_or_array_layers: 1,
},
);
self.blur(device, queue, encoder, target, size, radius, timing);
}
/// The blur's copy of a frame of `size`, for a picture drawn into it rather than copied
/// (HDR output's composite, `Hdr::composite`), then `blur`.
pub fn source(
&mut self,
device: &wgpu::Device,
size: [u32; 2],
) -> (wgpu::Texture, wgpu::TextureView) {
self.ensure(device, size);
self.targets[if self.half { 2 } else { 0 }].clone()
}
/// Blur what `source` holds into `target`, as `apply` blurs its copy of the frame.
#[allow(clippy::too_many_arguments)]
pub fn blur(
&mut self,
device: &wgpu::Device,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
size: [u32; 2],
radius: f32,
mut timing: Option<&mut crate::gfx::pack_timing::PassTiming>,
) {
self.ensure(device, size);
let work = self.work_size(size);
let radius = if self.half { radius / 2.0 } else { radius };
if self.half {
// A radius of 0 samples each half-size pixel's 2x2 block at its shared
+37 -13
View File
@@ -347,6 +347,10 @@ pub struct SectionMesh {
/// model order before.
pub sides: Sides,
pub translucent: Vec<TerrainVertex>,
/// Whether `packed` holds far tile records (`lod::packed`) rather than
/// section records (`mesher::packed`): the two are read apart, by the base
/// vertex their draws use.
pub packed_far: bool,
/// `solid` in the compact layout (`packed`), when the renderer reads it and it is
/// smaller; empty otherwise. Made by `sort_solid`.
pub packed: Vec<[u32; 6]>,
@@ -379,6 +383,7 @@ impl Default for SectionMesh {
sides: Sides::default(),
translucent: Vec::new(),
packed: Vec::new(),
packed_far: false,
solid_tints: Vec::new(),
visibility: ALL_VISIBLE,
block_entities: Vec::new(),
@@ -413,6 +418,7 @@ impl SectionMesh {
self.solid.clear();
self.translucent.clear();
self.packed.clear();
self.packed_far = false;
self.solid_tints.clear();
self.block_entities.clear();
self.lights.clear();
@@ -442,8 +448,9 @@ impl SectionMesh {
self.sides = sides::sort_tinted(&mut self.solid, &mut self.solid_tints);
self.bounds = self.compute_bounds();
self.packed.clear();
self.packed_far = false;
if packed::packing() && quads > 0 && self.solid_tints.len() == quads {
self.packed = packed::layout(&self.solid, &self.solid_tints);
packed::layout_into(&self.solid, &self.solid_tints, &mut self.packed);
}
self.solid_tints.clear();
}
@@ -652,7 +659,11 @@ struct Info {
/// and a full collision shape. The only block leaf culling treats as solid.
opaque_cube: bool,
blocks_flow: bool,
/// `instanceof IceBlock` (frosted ice too): fluids read it.
ice: bool,
/// Regular ice, the block the Opaque Ice option draws opaque; frosted ice
/// keeps its see-through, cracking look.
opaque_ice: bool,
sturdy: u8,
/// Occlusion face per direction: 0 empty, 1 the full-block singleton, 2 partial.
face: [u8; 6],
@@ -844,6 +855,7 @@ impl MeshTables {
),
blocks_flow: assets.blocks_fluid_flow.contains(&*s.name),
ice: s.has_class("IceBlock"),
opaque_ice: s.has_class("IceBlock") && !s.has_class("FrostedIceBlock"),
sturdy: s.sturdy_full,
face,
cover,
@@ -1251,6 +1263,8 @@ fn row_masks_match_cell_definition() {
#[cfg(test)]
mod leaf_culling_tests;
#[cfg(test)]
mod opaque_ice_tests;
#[cfg(test)]
mod reuse_tests;
#[cfg(test)]
mod tint_tests;
@@ -1580,6 +1594,8 @@ pub struct Mesher<'a> {
pub smooth_lighting: bool,
/// The `cutoutLeaves` option (fancy graphics); off makes leaves opaque.
pub cutout_leaves: bool,
/// The `opaqueIce` option: regular ice draws opaque in the solid pass.
pub opaque_ice: bool,
/// Sprite layers a shader pack moves into the translucent pass, by layer.
pub translucent_layers: &'a [bool],
/// What the worker does with leaf faces inside a canopy.
@@ -1705,6 +1721,9 @@ impl Mesher<'_> {
let other = &info[neighbor as usize];
// LeavesBlock.skipRendering with opaque leaves.
let opaque_leaves = !self.cutout_leaves && state.leaves && other.leaves;
// Opaque Ice: faces between two ice blocks are hidden, as they are
// between two opaque blocks.
let opaque_ice = self.opaque_ice && state.opaque_ice && other.opaque_ice;
let culled_leaf = match self.leaf_culling {
LeafCullingMode::Hollow | LeafCullingMode::Hidden => {
state.leaves
@@ -1722,6 +1741,7 @@ impl Mesher<'_> {
_ => false,
};
visible[d as usize] = !opaque_leaves
&& !opaque_ice
&& !culled_leaf
&& self
.visibility
@@ -1950,9 +1970,11 @@ impl Mesher<'_> {
// The face's own UVs, already packed: no per-vertex rounding.
std::array::from_fn(|i| (vertex(tint, i, face.uv_fixed[i]), q.uv[i]))
};
// Opaque leaves (forceOpaque) and leaves a leaf-culling mode proved internal draw in the
// solid layer whatever their sprite.
let solid_leaves = !self.cutout_leaves && state.leaves || interior_leaf;
// Opaque leaves (forceOpaque), leaves a leaf-culling mode proved internal and Opaque
// Ice draw in the solid layer whatever their sprite.
let force_solid = !self.cutout_leaves && state.leaves
|| interior_leaf
|| self.opaque_ice && state.opaque_ice;
let own = TileLayer::Layer {
layer: face.layer as u16,
translucent: face.translucent,
@@ -1972,8 +1994,8 @@ impl Mesher<'_> {
TileLayer::Skip | TileLayer::Default => own,
};
match pick {
Pick::Keep => self.quad(out, solid_leaves, own, corners.map(|c| c.0), tint),
Pick::Tile(t) => self.quad(out, solid_leaves, tile(t), corners.map(|c| c.0), tint),
Pick::Keep => self.quad(out, force_solid, own, corners.map(|c| c.0), tint),
Pick::Tile(t) => self.quad(out, force_solid, tile(t), corners.map(|c| c.0), tint),
Pick::Quarters(tiles) => {
let cuts = cuts(&corners);
for s in cuts.windows(2) {
@@ -1982,7 +2004,7 @@ impl Mesher<'_> {
.map(|(s, t)| bilinear(&corners, s, t));
let quarter = quarter_of(&piece);
let piece = piece.map(|c| c.0);
self.quad(out, solid_leaves, tile(tiles[quarter]), piece, tint);
self.quad(out, force_solid, tile(tiles[quarter]), piece, tint);
}
}
}
@@ -2031,17 +2053,17 @@ impl Mesher<'_> {
}
}
}
/// One terrain quad with sprite `tile`, in the pass its alpha needs (`solid_leaves`: no
/// One terrain quad with sprite `tile`, in the pass its alpha needs (`force_solid`: no
/// alpha cutout whatever the sprite).
fn quad(
&self,
out: &mut SectionMesh,
solid_leaves: bool,
force_solid: bool,
tile: TileLayer,
v: [TerrainVertex; 4],
tint: Option<u32>,
) {
self.quad_as(out, solid_leaves, tile, v, true, tint);
self.quad_as(out, force_solid, tile, v, true, tint);
}
/// Whether [`Mesher::quad`] draws `tile` in the translucent pass.
fn translucent(&self, tile: TileLayer) -> bool {
@@ -2065,7 +2087,7 @@ impl Mesher<'_> {
fn quad_as(
&self,
out: &mut SectionMesh,
solid_leaves: bool,
force_solid: bool,
tile: TileLayer,
mut v: [TerrainVertex; 4],
by_sprite: bool,
@@ -2082,14 +2104,16 @@ impl Mesher<'_> {
if self.tables.is_animated(layer) {
out.note_sprite_layer(layer);
}
let translucent = if by_sprite {
let translucent = if force_solid {
false
} else if by_sprite {
self.translucent(tile)
} else {
translucent
};
// Quads over opaque texels draw in the solid layer: no alpha cutout (a dirt path's side
// skips its clear top row). All four vertices share the layer.
let layer = if opaque && !translucent || solid_leaves {
let layer = if opaque && !translucent || force_solid {
layer | OPAQUE_LAYER
} else {
layer
@@ -340,12 +340,11 @@ pub(super) fn tesselate(
} else {
(tables.lava_still, tables.lava_flow, None)
};
let target = if water {
&mut out.translucent
let (target, sprite_layers) = if water {
(&mut out.translucent, &mut out.sprite_layers)
} else {
&mut out.solid
(&mut out.solid, &mut out.sprite_layers)
};
let mut sprite_layers = Vec::new();
let mut quad = |v: [([f32; 3], [f32; 2]); 4],
layer: u16,
color: u32,
@@ -497,7 +496,6 @@ pub(super) fn tesselate(
d as usize,
);
}
out.sprite_layers.extend(sprite_layers);
}
#[cfg(test)]
@@ -343,6 +343,7 @@ mod tests {
opaque_cube: opaque,
blocks_flow: false,
ice: false,
opaque_ice: false,
sturdy: 0,
face: [0; 6],
cover: [0.0; 6],
@@ -83,6 +83,7 @@ fn mesh(
blend_radius: 0,
smooth_lighting: false,
cutout_leaves: true,
opaque_ice: false,
translucent_layers: &[],
leaf_culling: mode,
};
@@ -0,0 +1,140 @@
//! Opaque Ice through the real mesher: regular ice moves from the translucent
//! pass to the solid pass without its texture alpha, keeps its faces toward
//! air, loses the faces between two ice blocks, and leaves other translucent
//! blocks alone. Needs prepared resources, like the other mesher geometry tests.
use super::*;
use crate::{
assets::{Assets, RenderAssets},
biome::Biomes,
blocks::BlockFacts,
chunk::Chunk,
models,
};
struct Fixture {
assets: Assets,
biomes: Biomes,
render: RenderAssets,
visibility: horizon_world::block_render::FaceVisibility,
tables: MeshTables,
}
fn fixture() -> Fixture {
let root = std::env::var_os("HORIZON_MESH_TEST_RESOURCES")
.map(std::path::PathBuf::from)
.unwrap_or_else(|| {
std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../.local/horizon-client/26.3")
});
let assets = Assets::load(&root).unwrap();
let facts = BlockFacts::load(&root, assets.registry).unwrap();
let biomes = Biomes::load(&root).unwrap();
let render = assets.reload(&root).unwrap();
let visibility = models::load_visibility(&root, assets.registry).unwrap();
let tables = MeshTables::new(&assets, &render, &facts, visibility.clone()).unwrap();
Fixture {
assets,
biomes,
render,
visibility,
tables,
}
}
fn state(f: &Fixture, name: &str) -> u32 {
f.assets.registry.default_state(name).unwrap().0
}
fn mesh(f: &Fixture, chunk: &Chunk, opaque_ice: bool) -> SectionMesh {
let region = [[Some(chunk); 3]; 3];
let mut mesher = Mesher {
nether_shading: false,
shader_pack_lighting: false,
separate_ao: false,
shader_pack: false,
assets: &f.assets,
render: &f.render,
tables: &f.tables,
biomes: &f.biomes,
visibility: f.visibility.clone(),
zoom: BiomeZoom::new(0),
blend_radius: 0,
smooth_lighting: false,
cutout_leaves: true,
opaque_ice,
translucent_layers: &[],
leaf_culling: LeafCullingMode::Off,
};
mesher.mesh(&region, 0)
}
const BASE: i32 = MIN_Y + 4;
#[test]
#[ignore = "requires prepared 26.3 resources (HORIZON_MESH_TEST_RESOURCES or .local/horizon-client/26.3)"]
fn off_keeps_regular_ice_in_the_translucent_pass() {
let f = fixture();
let mut chunk = Chunk::empty(0, 0);
chunk.set(8, BASE, 8, state(&f, "minecraft:ice"));
let mesh = mesh(&f, &chunk, false);
assert!(mesh.solid.is_empty());
assert_eq!(mesh.translucent.len(), 24);
}
#[test]
#[ignore = "requires prepared 26.3 resources (HORIZON_MESH_TEST_RESOURCES or .local/horizon-client/26.3)"]
fn on_draws_regular_ice_opaque_in_the_solid_pass() {
let f = fixture();
let mut chunk = Chunk::empty(0, 0);
chunk.set(8, BASE, 8, state(&f, "minecraft:ice"));
let mesh = mesh(&f, &chunk, true);
assert!(mesh.translucent.is_empty());
let quads = mesh.solid.as_chunks::<4>().0;
assert_eq!(quads.len(), 6);
for quad in quads {
assert!(
quad.iter().all(|v| v.layer & OPAQUE_LAYER != 0),
"an opaque ice quad kept its texture alpha"
);
}
}
#[test]
#[ignore = "requires prepared 26.3 resources (HORIZON_MESH_TEST_RESOURCES or .local/horizon-client/26.3)"]
fn on_culls_the_face_between_two_ice_blocks() {
let f = fixture();
let ice = state(&f, "minecraft:ice");
let mut chunk = Chunk::empty(0, 0);
chunk.set(7, BASE, 8, ice);
chunk.set(8, BASE, 8, ice);
let mesh = mesh(&f, &chunk, true);
assert!(mesh.translucent.is_empty());
// Two cubes, six faces each, minus the face they share.
assert_eq!(mesh.solid.len(), 10 * 4);
}
#[test]
#[ignore = "requires prepared 26.3 resources (HORIZON_MESH_TEST_RESOURCES or .local/horizon-client/26.3)"]
fn on_leaves_other_translucent_blocks_alone() {
let f = fixture();
let mut chunk = Chunk::empty(0, 0);
chunk.set(4, BASE, 8, state(&f, "minecraft:ice"));
chunk.set(12, BASE, 8, state(&f, "minecraft:slime_block"));
let mesh = mesh(&f, &chunk, true);
assert_eq!(mesh.solid.len(), 24, "only the ice cube is solid");
assert!(
mesh.translucent.len() >= 24,
"the slime cube is still translucent"
);
}
#[test]
#[ignore = "requires prepared 26.3 resources (HORIZON_MESH_TEST_RESOURCES or .local/horizon-client/26.3)"]
fn on_leaves_frosted_ice_translucent() {
let f = fixture();
let mut chunk = Chunk::empty(0, 0);
chunk.set(8, BASE, 8, state(&f, "minecraft:frosted_ice"));
let mesh = mesh(&f, &chunk, true);
assert!(mesh.solid.is_empty());
assert_eq!(mesh.translucent.len(), 24);
}
@@ -199,15 +199,51 @@ pub fn packed_vertex(words: &[u32; 6], corner: usize) -> TerrainVertex {
}
}
thread_local! {
static RECORDS_SCRATCH: std::cell::RefCell<Vec<Option<[u32; 6]>>> =
const { std::cell::RefCell::new(Vec::new()) };
}
/// The compact layout of sorted solid quads with their tints (`SectionMesh::packed`), or
/// nothing when it would be no smaller than their vertices.
pub fn layout(solid: &[TerrainVertex], tints: &[u32]) -> Vec<[u32; 6]> {
let mut out = Vec::new();
layout_into(solid, tints, &mut out);
out
}
/// Writes the compact layout of sorted solid quads with their tints into `out`,
/// reusing `out`'s allocation and a thread-local record scratch buffer.
pub fn layout_into(solid: &[TerrainVertex], tints: &[u32], out: &mut Vec<[u32; 6]>) {
let quads = solid.as_chunks::<4>().0;
let records: Vec<Option<[u32; 6]>> = quads
.iter()
.zip(tints)
.map(|(q, &t)| pack_quad(q, t))
.collect();
RECORDS_SCRATCH.with(|cell| {
let mut records = cell.borrow_mut();
records.clear();
records.extend(quads.iter().zip(tints).map(|(q, &t)| pack_quad(q, t)));
place_into(&records, quads, out);
});
}
/// A mesh's solid range from a record per quad, `None` where no record fits:
/// the records in mesh order, padded to a multiple of 4 slots, then the four
/// vertices of each quad without one, whose record holds the distance to them
/// (`FULL`). Empty where that would not be smaller than the vertices, which is
/// what makes the layout never a loss.
///
/// Shared with `lod::packed`, whose records hold a far tile's quads instead but
/// spill and pad the same way.
pub fn place(records: &[Option<[u32; 6]>], quads: &[[TerrainVertex; 4]]) -> Vec<[u32; 6]> {
let mut out = Vec::new();
place_into(records, quads, &mut out);
out
}
pub fn place_into(
records: &[Option<[u32; 6]>],
quads: &[[TerrainVertex; 4]],
out: &mut Vec<[u32; 6]>,
) {
out.clear();
let n = quads.len();
let packed = records.iter().filter(|r| r.is_some()).count();
let full = n - packed;
@@ -217,9 +253,9 @@ pub fn layout(solid: &[TerrainVertex], tints: &[u32]) -> Vec<[u32; 6]> {
0
};
if n + pad + 4 * full >= 4 * n {
return Vec::new();
return;
}
let mut out = Vec::with_capacity(n + pad + 4 * full);
out.reserve(n + pad + 4 * full);
let mut next = n + pad;
for (i, record) in records.iter().enumerate() {
out.push(record.unwrap_or_else(|| {
@@ -229,7 +265,7 @@ pub fn layout(solid: &[TerrainVertex], tints: &[u32]) -> Vec<[u32; 6]> {
}));
}
out.resize(n + pad, [0; 6]);
for (q, record) in quads.iter().zip(&records) {
for (q, record) in quads.iter().zip(records) {
if record.is_none() {
out.extend(
q.iter()
@@ -237,7 +273,6 @@ pub fn layout(solid: &[TerrainVertex], tints: &[u32]) -> Vec<[u32; 6]> {
);
}
}
out
}
/// Quads `layout` gave a record of their own.
@@ -181,6 +181,7 @@ fn a_shader_pack_lights_the_faces_itself() {
blend_radius: 0,
smooth_lighting: false,
cutout_leaves: true,
opaque_ice: false,
translucent_layers: &[],
leaf_culling: LeafCullingMode::Off,
};
@@ -237,6 +238,7 @@ fn a_shader_pack_lights_every_nether_face_like_an_up_face() {
blend_radius: 0,
smooth_lighting: false,
cutout_leaves: true,
opaque_ice: false,
translucent_layers: &[],
leaf_culling: LeafCullingMode::Off,
};
@@ -289,6 +291,7 @@ fn separate_ao_passes_ao_in_alpha_without_darkening_rgb() {
blend_radius: 0,
smooth_lighting: true,
cutout_leaves: true,
opaque_ice: false,
translucent_layers: &[],
leaf_culling: LeafCullingMode::Off,
};
@@ -364,6 +367,7 @@ fn reused_mesh_matches_fresh_geometry_across_sections_and_resource_reload() {
blend_radius: 2,
smooth_lighting: reload == 0,
cutout_leaves: reload == 0,
opaque_ice: false,
translucent_layers: &[],
leaf_culling: LeafCullingMode::Off,
};
@@ -513,6 +517,7 @@ fn a_shader_pack_s_still_water_top_starts_at_its_south_west_corner() {
blend_radius: 0,
smooth_lighting: true,
cutout_leaves: true,
opaque_ice: false,
translucent_layers: &[],
leaf_culling: LeafCullingMode::Off,
};
@@ -92,6 +92,7 @@ fn info(solid: bool) -> Info {
opaque_cube: solid,
blocks_flow: false,
ice: false,
opaque_ice: false,
sturdy: 0,
face: [0; 6],
cover: [0.0; 6],
Loaded 100 of 894 files, more files were not shown because too many files have changed in this diff. Show more