Search code examples
javaminecraft-forge

How to modify player in minecraft forge?


I tried to modify the player in minecraft forge (1.18.1) so that a particular player can breath under water but not above water. So is it possible to change the player abilities?


Solution

  • It is possible via Mixin. Check out https://github.com/SpongePowered/Mixin/wiki. With that you're able to overwrite Minecraft's code and make, as you want, player or any other mob breathe under water. Explore Fabric's mixin tutorial: https://fabricmc.net/wiki/tutorial:mixin_introduction it will help you understanding this. You'll have to add to your build.gradle new imports as well as creating refmap.json file