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/04 21:37] clomclemtutorial:mixin_injects [2025/09/24 12:13] (current) – Mark page as WIP in preparation for major review and edits upcoming gauntrecluse
Line 1: Line 1:
-====== Mixin Injects ======+FIXME //This page is under heavy rewrites due to prior edits being from 2022, and it thus contains seriously outdated advice. This page may change very suddenly and should only be taken with a grain of salt.// 
 + 
 +====== Mixin Injects (WIP) ======
  
 ===== Introduction ===== ===== Introduction =====
Line 5: Line 7:
  
 <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 30:
 | 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 35: Line 37:
 | [ | reference | one array dimension | | [ | reference | one array dimension |
  
-A method descriptor is comprised of the method name, followed by a set of parentheses containing the input types, followed by the output type. A method defined in Java as ''Object m(int i, double[] d, Thread t)'' would have the method descriptor ''m(I[DLjava/lang/Thread;)Ljava/lang/Object;''.+A method descriptor is comprised of the method name, followed by a set of parentheses containing the parameter types, followed by the return type. A method defined in Java as ''Object m(int i, double[] d, Thread t)'' would have the method descriptor ''m(I[DLjava/lang/Thread;)Ljava/lang/Object;''.
  
-In the case that the output type is void, you need to use V (Void Descriptor Type) as the type (for example, ''void foo(String bar)'' would become ''foo(Ljava/lang/String;)V'').+In the case that the return type is void, you need to use V (Void Descriptor Type) as the type (for example, ''void foo(String bar)'' would become ''foo(Ljava/lang/String;)V'').
  
-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.1659649070.txt.gz · Last modified: 2022/08/04 21:37 by clomclem