Skip to content

Commit

Permalink
Use reflection to locate BlockTypeIds and ItemTypeIds for VanillaBloc…
Browse files Browse the repository at this point in the history
…ks/VanillaItems

since BlockTypeIds and ItemTypeIds are derived from VanillaBlocks and VanillaItems respectively anyway (they only exist to allow identifying blocks/items without having to create instances of them), this hack is probably OK, and reduces the chances of mistakes.
Previously it was explored to have these IDs generated by auto-incrementing in VanillaBlocks/Items and have the constants generated that way, but this proved to be too problematic because of unstable diffs no matter how we chose to sort the elements. See #6313 for previous research on the subject.

This is obviously not a desirable hack to keep long-term. In the future it will probably make sense to redesign VanillaBlocks like so:

enum VanillaBlocks { ... }
VanillaBlocks::STONE (the type ID)
VanillaBlocks::STONE->new() (to create a block)

However, more research is needed on this, as I'd prefer not to make block creation any more verbose.
  • Loading branch information
dktapps committed Nov 12, 2024
1 parent fa35299 commit 6611a81
Show file tree
Hide file tree
Showing 4 changed files with 1,003 additions and 1,165 deletions.
Loading

0 comments on commit 6611a81

Please sign in to comment.