Skip to content

Overloaded registry members#6947

Draft
dktapps wants to merge 11 commits intominor-nextfrom
overloaded-registry-members
Draft

Overloaded registry members#6947
dktapps wants to merge 11 commits intominor-nextfrom
overloaded-registry-members

Conversation

@dktapps
Copy link
Member

@dktapps dktapps commented Dec 19, 2025

Blocks & items like wooden things might have different properties per wood type, so they're implemented as fully separate flattened blocks, like in vanilla.

However, we can avoid a lot of shitty code by auto-generating some simple functions that match an enum case to a block of a certain wood type.

The PR demonstrates this with VanillaBlocks::SIGN(WoodType $case) : FloorSign and VanillaItems::SIGN(WoodType $case) : ItemBlockWallOrFloor. A significant amount of boilerplate code is able to be deleted because of the additions of these simple functions.

This could be extended to all other wood-like blocks, but this PR mainly focused on a proof-of-concept to establish feasibility.

Future scope

  • Extend to other wood blocks
  • Better integration with regular registrations to avoid duplication of stuff like mb_strtolower($t->name) . "_sign") between overloaded member and actual registration
  • Use this to de-shittify VanillaBlockMappings, which currently has to do a horrendous amount of this sort of copy pasta to implement each wood type
  • Auto infer the overload's return type instead of requiring it to be specified explicitly

Backwards compatibility

Fully backwards compatible

Tests

Tests are green. The code is used in the core, so it's established that it's working.

this allows us to reference registry members with dynamic enum cases, which has a lot of potential applications.

this enables us to keep the blocks as unique types, but with some of the power of dynamic state properties.

this is a rough initial proof of concept; it will need to be improved for further integration.
@dktapps dktapps requested a review from a team as a code owner December 19, 2025 21:48
@dktapps dktapps added Category: API Related to the plugin API Category: Core Related to internal functionality Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Dec 19, 2025
pmmp-admin-bot[bot]
pmmp-admin-bot bot previously approved these changes Dec 19, 2025
@dktapps dktapps marked this pull request as draft December 19, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: API Related to the plugin API Category: Core Related to internal functionality Type: Enhancement Contributes features or other improvements to PocketMine-MP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant