Fabric-Tutorial-1.20.X icon indicating copy to clipboard operation
Fabric-Tutorial-1.20.X copied to clipboard

Clean up mixins

Open Daomephsta opened this issue 1 year ago • 0 comments

Below is a list of the changes with justification and an explanation for readers of the repo wondering why the code differs from the video.

  • Replace ItemRendererAccessor with a @Shadow in ItemRendererMixin. A shadow is a simpler and cleaner way to access a field declared by the mixin's target class. Accessors are for inaccessible fields of other classes.
    The shadow is @Final rather than final because
  • Replace ModelLoaderMixin with a ModelLoadingPlugin. FAPI APIs are preferable to mixins, as FAPI will avoid changing APIs if possible, while the internals mixins depend on may change at any time.
  • Make handler methods private when possible. It's standard Java best practice to minimise access levels. This applies to mixins too,
  • Use a constant ModelIdentifier field for the ruby staff. Avoids a typo in the mixin or ModelLoadingPlugin breaking the 3d model.

Daomephsta avatar Nov 09 '23 03:11 Daomephsta