User Tools

Site Tools


tutorial:mixin_injects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:mixin_injects [2022/08/05 14:11] – Renamed output type and input type to return type and parameter type, and fixed a typo clomclemtutorial:mixin_injects [2022/08/05 19:19] (current) – Added signed to integer types clomclem
Line 5: Line 5:
  
 <code java> <code java>
-@Inject(method = "METHODNAME", at = @At("INJECTION POINT REFERENCE"))+@Inject(method = "METHOD NAME OR SIGNATURE", at = @At("INJECTION POINT REFERENCE"))
 private void injectMethod(METHOD ARGS, CallbackInfo info) { private void injectMethod(METHOD ARGS, CallbackInfo info) {
  
Line 28: Line 28:
 | D | double | double-precision floating-point value | | D | double | double-precision floating-point value |
 | F | float | single-precision floating-point value | | F | float | single-precision floating-point value |
-| I | int | integer | +| I | int | signed integer | 
-| J | long | long integer |+| J | long | signed long integer |
 | L//ClassName//; | reference | an instance of //ClassName// | | L//ClassName//; | reference | an instance of //ClassName// |
 | S | short | signed short | | S | short | signed short |
Line 41: Line 41:
 Generics' types are left out, as generics don't exist on runtime. So ''Pair<Integer, ? extends Task<? super VillagerEntity>‍>'' would become ''Lcom/mojang/datafixers/util/Pair''. Generics' types are left out, as generics don't exist on runtime. So ''Pair<Integer, ? extends Task<? super VillagerEntity>‍>'' would become ''Lcom/mojang/datafixers/util/Pair''.
  
-//@Inject// methods always have a void return type. The method name does not matter and neither does the access modifier; using something that describes what the inject does is best. The target method's arguments are placed first in the method's header, followed by a ''CallbackInfo'' object. If the target method has a return type (T), ''CallbackInfoReturnable<T>'' is used instead of ''CallbackInfo''.+''@Inject'' methods always have a void return type. The method name does not matter and neither does the access modifier; using something that describes what the inject does is best. The target method's arguments are placed first in the method's header, followed by a ''CallbackInfo'' object. If the target method has a return type (T), ''CallbackInfoReturnable<T>'' is used instead of ''CallbackInfo''.
  
 === Returning & Cancelling from Inject === === Returning & Cancelling from Inject ===
tutorial/mixin_injects.1659708713.txt.gz · Last modified: 2022/08/05 14:11 by clomclem