Skip to content

Fix water/lava diggable by detecting fluid blocks from code - #80

Open
AnonymoDGH wants to merge 1 commit into
PrismarineJS:mainfrom
AnonymoDGH:fix/fluid-diggable
Open

AnonymoDGH wants to merge 1 commit into
PrismarineJS:mainfrom
AnonymoDGH:fix/fluid-diggable

Conversation

@AnonymoDGH

Copy link
Copy Markdown

Fixes water/lava being marked diggable: true.

The bug

The diggable logic is hardness != -1.0f && !(block instanceof AirBlock). Fluids have a hardness of 100 (not -1), so water and lava were incorrectly marked diggable in every version that has fluid blocks.

The fix

Detect fluid blocks from the game code instead of hardcoding names — per @extremeheat's guidance on #79:

  • 1.13+ (Yarn & Mojmap): defaultState.getFluidState().isEmpty() — a block is diggable only if its default state has no fluid.
  • 1.7–1.12.2 (legacyYarn): Material.isFluid() — !block.getMaterial().isFluid() for 1.7/1.8.9, !defaultState.getMaterial().isFluid() for 1.9.4–1.12.2.

No block names are hardcoded; the check queries the actual Minecraft source.

Verification

Every API was confirmed against the real mapping files for its era (Yarn v2 tiny mappings for 1.14/1.15/1.16/1.20, legacyYarn for 1.7–1.13, Mojmap for 1.21.5+):

  • BlockState.getFluidState() (no-arg) exists from 1.13 onward (on AbstractBlock.AbstractBlockState, inherited by BlockState).
  • FluidState.isEmpty() exists in all those versions.
  • Material.isFluid() exists in all legacyYarn versions.

CI runs runServer for all 28 versions, which compiles and executes each generator, so any wrong API will fail the build.

Water and lava blocks were incorrectly marked diggable=true because their hardness is 100 (not -1). Detect fluid blocks from the source instead of hardcoding names: use instanceof FluidBlock (yarn 1.14+), instanceof LiquidBlock (mojmap 1.21.5+), Material.isFluid() (legacy 1.7-1.12.2), and FlowingFluidBlock via net.minecraft.class_3710 (1.13.2). This mirrors the existing instanceof AirBlock check and only flips actual fluid blocks.
@AnonymoDGH

Copy link
Copy Markdown
Author

Verified against the freshly generated artifacts — diffing the PR branch output against main for all 28 versions:

diggable flips (the fix):

  • water, lava: true → false in every version
  • flowing_water, flowing_lava: true → false in 1.7–1.12.2
  • Exactly those blocks — nothing else flipped (no seagrass/kelp/corals/sea_pickle/conduit/bubble_column)

example diffs (all other versions identical in shape):

1.13.2: water true->false, lava true->false   (bubble_column stays true)
1.18:   water true->false, lava true->false
26.1:   water true->false, lava true->false

Only other difference across all versions: the drops field on 122 blocks in various versions — runtime non-determinism from loot-table evaluation at server boot (differs between independent CI runs on main too); unrelated to this change.

CI: all 28 Build jobs green. Also confirmed the 1.13.2 class net/minecraft/class_3710 (unmapped in legacyYarn) resolves in the intermediary fallback namespace and is exactly FlowingFluidBlock: it extends Block, implements FluidDrainable, holds a FlowableFluid, and has getFluidState/bucket methods — checked against the 1.13.2 server jar.

@extremeheat extremeheat changed the title 🎈 Fix water/lava diggable by detecting fluid blocks from code Fix water/lava diggable by detecting fluid blocks from code Aug 18, 2026
@extremeheat

Copy link
Copy Markdown
Member

Can you open PR in minecraft-data with the updated data?

@rom1504 rom1504 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Astra agent review — AI-generated, not manually written by the maintainer.

At 4e3659d, this looks ready for maintainer merge review in the fluid-diggability scope. The current implementation distinguishes actual fluid blocks using the version’s native class/material APIs, rather than excluding every water-containing solid block. The author’s exact-head generated comparison reports only the water/lava variants changing, with all 28 generation jobs passing.

Coordinate the requested data update #1237 so users receive the corrected facts. I read the producer variants and companion data; I did not rerun all native generators or claim the older description of getFluidState().isEmpty() describes the final code.

Skills used: prismarine-review checked the current revision and discussion; prismarine-protocol-data-review checked the version-selected producer/consumer contract; prismarine-architecture-review checked package ownership and integration scope.

arielvino added a commit to arielvino/minecraft-data-generator that referenced this pull request Oct 9, 2026
* Add version 26.2

* fix 26.2 build (PrismarineJS#78)

* Add 26.3 module, copied from 26.2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mc/26.3: port to the 26.3 API

RedStoneWireBlock is now RedstoneWireBlock, and the SKY_COLOR environment
attribute holds a Vector3fc instead of a packed int; convert it with
ARGB.colorFromVector3f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mc/26.3: water and lava are not diggable

Same fix PrismarineJS#80 applied to the other modules: fluid blocks report hardness 100, so
diggable was true.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mc/26.3: skip incorrect_for_* when picking a block's material

Port of PrismarineJS#86: tier-gated blocks (iron ore, obsidian, ...) reported
incorrect_for_wooden_tool, whose speed table only has wooden tools, so dig times
fell back to hand speed. Also adds the plant;mineable/hoe and
sword_instantly_mines;mineable/axe composites.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mc/26.3: copper tools have speed 5

Port of PrismarineJS#87: copper was missing from the speed table, so copper tools got 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: mc-zuri <174940476+mc-zuri@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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