Skip to content

fix: preserve legacy survival items and typed NBT on 1.26.50 - #20

Closed
pedrotelesh wants to merge 1 commit into
PowerNukkitX-Bundle:bedrock-1.26.50from
pedrotelesh:fix/legacy-survival-item-compatibility
Closed

pedrotelesh wants to merge 1 commit into
PowerNukkitX-Bundle:bedrock-1.26.50from
pedrotelesh:fix/legacy-survival-item-compatibility

Conversation

@pedrotelesh

Copy link
Copy Markdown
Contributor

Summary

Based on bedrock-1.26.50 (5c3dfa9), preserving its protocol 2192/2169 codecs, new block/item tables and RakNet fallback.

This contributes fixes discovered while running older Bedrock clients against a PNX 1.26.50 server:

  • Preserve the complete authoritative inventory item with Item.toNetwork() during legacy item-use translation. The previous partial builder lost stack count, wear and network stack identity, which can prevent survival interaction events from reaching plugins.
  • Supply MAINHAND when a legacy item-use transaction has no hand field, so the newer codec can serialize it.
  • Convert PNX NBT lists with their network representation, preserving typed empty lists and converting compound list entries to NbtMap. This prevents serialization failures on custom/enchanted items.
  • Share the NBT converter between item registry and inventory transaction conversion, keeping the existing instance method API of ItemRegistryHandler.fromCompound.
  • Omit legacy biome generation metadata that references unmapped server runtime block definitions, while keeping visual biome properties.
  • Add JUnit infrastructure and five regression tests covering survival item count/wear/identity, nested and empty NBT lists, legacy item-use encoding and biome encoding.

Validation

Both clean builds completed with 5 tests, 0 failures/errors/skips:

  1. PNX 3.0.5 with Java 21, using a temporary Gradle init script that forces org.powernukkitx:server:3.0.5.
  2. The existing nightly-SNAPSHOT dependency with Java 26, using a temporary init script selecting that toolchain.

No server version, plugin version, protocol numbers or production toolchain settings are changed by this PR.

For reproduction, the dependency override used for the first build is:

// pnx305.init.gradle
allprojects {
    configurations.configureEach {
        resolutionStrategy.force('org.powernukkitx:server:3.0.5')
    }
}
./gradlew --no-daemon --init-script pnx305.init.gradle clean test build

For the second build:

// current-jdk.init.gradle
allprojects {
    afterEvaluate {
        java.toolchain.languageVersion.set(JavaLanguageVersion.of(26))
    }
}
./gradlew --no-daemon --init-script current-jdk.init.gradle clean test build

Existing upstream build issue

The unmodified base branch also fails its normal Java 21 build: the currently resolved nightly-SNAPSHOT server contains Java 25 bytecode (69.0), while Java 21 accepts 65.0. The same issue appears in the existing branch's CI: https://github.com/PowerNukkitX-Bundle/AnyVersion/actions/runs/34882734423

The temporary overrides above allow the fixes to be tested without bundling an unrelated Java/toolchain migration into this PR. Upstream's default CI still needs its server dependency/toolchain alignment addressed separately.

@xRookieFight
xRookieFight deleted the branch PowerNukkitX-Bundle:bedrock-1.26.50 October 18, 2026 07:40
@xRookieFight

Copy link
Copy Markdown
Contributor

Fixed on latest commit

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.

2 participants