Skip to content

Blockhaven: block models in Java's element format, so pack textures map like Java - #67

Merged
eklonofficial merged 5 commits into
eklonofficial:mainfrom
k1519035:blockhaven-block-models
Oct 3, 2026
Merged

eklonofficial merged 5 commits into
eklonofficial:mainfrom
k1519035:blockhaven-block-models

Conversation

@k1519035

@k1519035 k1519035 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Block shapes whose texture is a sprite sheet rather than one picture per face were drawn with the wrong parts of their textures. With the bundled pack, lanterns and end rods were nearly invisible, bamboo was a wide box, and cacti, torches and the rest only approximated Java. These blocks now use Java 1.20.1's own block model geometry and per-face UVs. Any Java resource pack's textures land exactly where they do in Java.

How

  • js/data/models.js (new): Java's block-model element format in a compact form.
    • Each element is a box with its own UV rectangle per face.
    • Elements can have a face rotation, a cullface, a turn of 22.5° or 45° about one axis (with Java's rescale), and shade: false.
  • model() in the mesher: draws these elements.
    • UVs map onto each face as Java's FaceBakery does, and face rotations turn the texture as Java's do.
    • Lighting and culling work as for the existing boxes.
    • Each block's state turns the model as its Java blockstate does. The rotations come from the existing Java state mapping in javablocks.js.

Blocks changed

Block Now (Java model) Before
Torch, soul and redstone torches template_torch: the texture on two crossed 2-px slabs, flame UV on top box with the top 1 px off
Wall torches template_torch_wall, leaning 22.5° sheared box
Cactus full top/bottom, sides inset 1 px with the whole texture 14 px top
Lantern, hanging lantern the lantern sheet's body, cap and handles whole-texture faces (mostly transparent)
End rod rod sheet invisible
Bamboo one of Java's 4 stalk models, by position 3×3 box
Campfire 4 logs with lit inner faces, rescaled fire planes 2 oak logs
Glass pane, iron bars Java's multipart arms, caps and posts, pane edges from glass_pane_top —
Ladder, doors (incl. open models), trapdoors (top/bottom/open), anvil, end portal frame (+eye) Java models —
Fire floor planes plus 4 side planes, showing the animated fire texture (was a shader effect) —
Pumpkin/melon stems Java's diagonal stem growing 2 px per age, tinted green→yellow by age; packs' grey stem textures are now tinted, and every age uses the plain stem wheat-style, full height, untinted grey with packs (age 7 showed the bent attached_ stem)
  • New texture layers: campfire_log, campfire_log_lit and glass_pane_top.
  • Fallback textures: the procedural fallbacks for lantern, end rod and bamboo are redrawn in Java's sheet layouts, so they map the same way when no pack is loaded.

Not in this PR: block entities that use entity textures (chests, beds, skulls) come with the entity-texture work later.

Build fix

tools/build.mjs injects the bundled worker into the packed page with String.replace. A replacement string treats $& and similar sequences as patterns. The minified worker now has a variable named $ masked with $&1, which the build replaced with the matched URL, so the packed worker failed to load. The injections now use replacer functions, so no bundled code can trip this again.

Testing

  • tests/models.test.mjs (new) checks:
    • Every face has a texture and a UV inside the texture.
    • Torch geometry and flame UV.
    • The wall torch leans away from its wall.
    • The lantern uses the sheet's body rectangle.
    • The cactus inset.
    • Stem heights.
  • node --test: 120 pass.
  • Packed build: npm run build, surface-check and browser-check pass locally, using Edge.
  • By eye: checked in a headless Edge test scene with the bundled pack, block by block: torches, wall torch, cactus, lanterns (standing and hanging), end rod, bamboo, campfire, panes and bars (lines, corners, lone), doors (closed and open), trapdoors, ladder, anvil, end portal frame with eye, fire, soul fire and stems at every age.

🤖 Generated with Claude Code

https://claude.ai/code/session_01R5yMmGQVzFD1XVDyZe42KG

Copilot AI balanced review requested due to automatic review settings October 2, 2026 17:12
@vercel

vercel Bot commented Oct 2, 2026

Copy link
Copy Markdown

@k1519035 is attempting to deploy a commit to the Marin Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

k1519035 and others added 5 commits October 2, 2026 20:25
…ap like Java

Torches, wall torches, cactus, lanterns, end rods, bamboo, campfires, glass panes, iron
bars, ladders, doors, trapdoors, anvils, end portal frames, fire and stems now use Java
1.20.1's block model geometry and per-face UVs (js/data/models.js), drawn by a new
element emitter in the mesher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R5yMmGQVzFD1XVDyZe42KG
A replacement string treats "$&" and similar as patterns; the minified worker now has a
variable named $ masked with $&1, which the injection replaced with the matched URL and
broke the packed worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R5yMmGQVzFD1XVDyZe42KG
…s line up

Positions were stored to the half pixel, so each corner of a rotated element (wall torch,
lantern handles, fire, stems) snapped on its own and the torch's sides and cap no longer met.
The same 16-bit fields now hold 1/8 px (the world's top is about 33,000 of 65,535), and
Java's 0.001/0.01 px offsets on bar caps and fire sides become one 1/8 px step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R5yMmGQVzFD1XVDyZe42KG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R5yMmGQVzFD1XVDyZe42KG
@k1519035
k1519035 force-pushed the blockhaven-block-models branch from 2c9a155 to e7c5fea Compare October 3, 2026 01:26
@eklonofficial
eklonofficial merged commit e85502f into eklonofficial:main Oct 3, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants