User Tools

Site Tools


tutorial:mixin_registration

Differences

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

Link to this comparison view

Next revision
Previous revision
tutorial:mixin_registration [2020/06/08 21:26] – created lvanderzandetutorial:mixin_registration [2022/08/17 22:25] (current) – external edit 127.0.0.1
Line 3: Line 3:
 ==== Introduction ==== ==== Introduction ====
  
-In this example, you will learn how to register your Mixins through the ''%%resources/fabric.mod.json%%''.+In this tutorial, you will learn how to register your Mixins through the ''%%resources/fabric.mod.json%%''.
  
 Inside your ''%%resources%%'' folder is where your ''%%fabric.mod.json%%'' should be.  Inside your ''%%resources%%'' folder is where your ''%%fabric.mod.json%%'' should be. 
Line 19: Line 19:
 { {
   "mixins": [   "mixins": [
-    "modid.mixins.json",  +    "modid.mixins.json"
-    { +
-      "environment": "client", +
-      "config": "modid.client.mixins.json" +
-    }+
   ]   ]
 } }
 </code> </code>
  
-Providing a String ''%%"<modid>.mixins.json"%%'' inside the mixins array tells Fabric to load the mixins defined inside the file ''<modid>.mixins.json'' on **both client and server**. +Providing a String ''%%"<modid>.mixins.json"%%'' inside the mixins array tells Fabric to load the mixins defined inside the file ''<modid>.mixins.json''.
- +
-Providing an Object allows for deeper customization. +
- +
-Taking a closer look at the Object from lines 4 to 7: +
- +
-<code json> +
-+
-  "environment": "client",  +
-  "config": "modid.client.mixins.json" +
-+
-</code> +
- +
-The ''%%environment%%'' field is set to 'client'. Which lets Fabric know we want these mixins to only be loaded on the client. +
- +
-The ''%%config%%'' field should point to the file where all the mixins for that ''%%environment%%'' are defined. +
  
 ==== Register Mixins ==== ==== Register Mixins ====
  
-In the previous section, you learned about registering your client/server ''<modid>.mixins.json'' and environment specific ''<modid>.<environment>.mixins.json'' files.+In the previous section, you learned about registering your ''<modid>.mixins.json'' files.
  
 We still have to define which mixins to load and where these mixins are located. We still have to define which mixins to load and where these mixins are located.
  
-Inside your registered ''<modid>.<environment>.mixins.json'':+Inside your registered ''<modid>.mixins.json'':
  
 <code json> <code json>
Line 59: Line 39:
   "minVersion": "0.8",   "minVersion": "0.8",
   "package": "net.fabricmc.example.mixin",   "package": "net.fabricmc.example.mixin",
-  "compatibilityLevel": "JAVA_8",+  "compatibilityLevel": "JAVA_17",
   "mixins": [],   "mixins": [],
   "client": [   "client": [
     "TitleScreenMixin"     "TitleScreenMixin"
   ],   ],
 +  "server": [],
   "injectors": {   "injectors": {
     "defaultRequire": 1     "defaultRequire": 1
Line 70: Line 51:
 </code> </code>
  
-The **2** main fields you should worry about when getting started with mixins are the ''package'' field and ''client'' array.+The **4** main fields you should worry about when getting started with mixins are the ''package'' fieldand the ''mixins'', ''client'', ''server'' arrays.
  
 The ''package'' field defines which folder (package) to find the Mixins in. The ''package'' field defines which folder (package) to find the Mixins in.
  
-The ''client'' array defines which classes should be loaded.+The ''mixins'' array defines which classes should be loaded on both the client and server. 
 + 
 +The ''client'' array defines which classes should be loaded on the client. 
 + 
 +The ''server'' array defines which classes should be loaded on the server.
  
-Following that logic: ''net.fabricmc.example.mixin.TitleScreenMixin'' is the mixin.+Following that logic: ''net.fabricmc.example.mixin.TitleScreenMixin'' is the mixin class that will be loaded on the client.
  
  
tutorial/mixin_registration.1591651583.txt.gz · Last modified: 2020/06/08 21:26 by lvanderzande