Fix FAWE compat, keep fast blockstate palette - #199
Conversation
Nrleryxx
left a comment
There was a problem hiding this comment.
-
Block.java.patch currently has two plus lines adding the same static final field name
after removing the old IdMapper line both of these would end up in the patched file
producing duplicate field compile error
also the first added line declares type as BlockStateIdMapper which would break the FAWE compat goal anyway
fix keep only the plus line that declares IdMapper BlockState BLOCK_STATE_REGISTRY completely delete the other plus line
you should end up with exactly one minus and one plus for that field -
Blocks.java.patch has two separate plus lines adding trimToSize calls and no deletions
both end up in final code causing redundant calls
worse the first line calls Block BLOCK_STATE_REGISTRY trimToSize directly without cast
after the field type changes to IdMapper this becomes compile error because vanilla IdMapper class has no trimToSize method
fix keep only the cast version and fully delete the uncast direct call line
Nrleryxx
left a comment
There was a problem hiding this comment.
after changing class from implements IdMap to extends IdMapper you now rely on inherited methods for byId iterator size and trimToSize
those inherited implementations use the slow vanilla ArrayList internal storage from IdMapper not our fast idToT array
this completely negates the intrusive array backed performance optimization back to slow vanilla speeds
fix keep and explicitly override all four of these in BlockStateIdMapper making sure they read from idToT and our own size field not the parent storage
byId with Nullable return the fast array bounds checked lookup
iterator return the existing anonymous inner class walking idToT directly
size return this size
trimToSize Arrays copyOf idToT trimmed to this size
the access transformer for IdMapper byId final removal only helps if you actually override the method otherwise nobody benefits
Nrleryxx
left a comment
There was a problem hiding this comment.
the new getId method taking state parameter is missing the Override annotation above it
the annotation is still attached to the old thing variant which is being removed
not a compile error but please add the annotation to the new state based variant
|
Thanks for reviewing! I checked each point against this commit (cc45af0, Files tab):
|
|
shit my bad github files tab served me a 10 hour stale cache of the diff Thanks for the pr! |
|
Didn't check FAWE's code, but if FAWE just accesses the |
Motivation
FAWE crashes on Gale with NoSuchFieldError: Block does not have member field 'IdMapper BLOCK_STATE_REGISTRY'. Gale's blockstate-palette optimization changed the public field's type from IdMapper to the custom BlockStateIdMapper, so any plugin compiled against vanilla/Paper (FAWE's PaperweightFaweAdapter.adaptToChar) fails to link.
Changes
Context
Was AI used to write this pull request: Yes