Jump to content

Custom Rendered Helmet won't attach to head


TrunkS

Recommended Posts

So, I made a helmet with custom render code some time ago which makes use of the getArmorModel() method in the Item class and a ModelBiped extending rendering class. It seems to work fine to that point but now comes the problem:

When I put on the helmet it attaches to the whole body model but not separately to the head. Like when I run around the helmet follows the orientation of the rest of the body but when I move the mouse and look in another direction the helmet still faces the direction I run towards.

Thanks in advance.

And no my name is not inspired by DBZ ^^

Link to comment
Share on other sites

Sorry for not posting the code but there's really not much code to it ^^

Btw I'm using a techne made model (very basic with no rotation) and I've made another helmet without custom rendering code to test if this problem is caused by the render code and indeed it is.

 

So anyway here's the code:

 

@Mod Class:

@Mod(modid = "TrunkSMod", name = "TrunkS Mod", version = "Dev v1")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)

public class mod_Particles
{
public static Item helmetTest;

Instance("TrunkSMod")
        public static mod_Particles instance;
       
        @PreInit
        public void preInit(FMLPreInitializationEvent event)
        {
                instance = this;
        }
@Init
        public void load(FMLInitializationEvent event)
        {
helmetTest = new ItemTrunksArmorHelmet(5005, EnumArmorMaterial.IRON, 0, 0).setCreativeTab(mod_Particles.tabParticles).setFull3D().setUnlocalizedName("helmetTest");
GameRegistry.registerItem(helmetTest, "helmetTest");
LanguageRegistry.addName(helmetTest, "Test Helmet");
}

@PostInit
        public void postInit(FMLPostInitializationEvent event)
        {
               
        }

 

ItemTrunksArmorHelmet Class:

public class ItemTrunksArmorHelmet extends ItemArmor
{
       
        public ItemTrunksArmorHelmet(int par1, EnumArmorMaterial enumToolMaterial, int par3, int par4)
        {
                super(par1, enumToolMaterial, par3, par4);     
        }
       
        @Override
        public ModelBiped getArmorModel(EntityLiving entityLiving, ItemStack stack, int armorSlot)
        {
                return new ItemHelmetTestRenderer();
        }
       
}

 

ItemHelmetTestRenderer Class:

public class ItemHelmetTestRenderer extends ModelBiped
{
        protected HelmetTestModel helmetModel;
       
        public ItemHelmetTestRenderer()
        {
            super();
            helmetModel = new HelmetTestModel();
        }
       
        public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
        {
               
                GL11.glPushMatrix();
               
                GL11.glTranslatef(0.0F, 0.01F, 0.05F);
               
                FMLClientHandler.instance().getClient().renderEngine.bindTexture("/trunkS/mod/textures/items/helmetTestTexture.png");
               
                helmetModel.render(par1Entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
               
                GL11.glPopMatrix();
                return;
               
        }


}

 

HelmetTestModel Class:

package trunkS.mod;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class HelmetTestModel extends ModelBase
{
  //fields
    ModelRenderer HeadRight;
    ModelRenderer VisorBrow1;
    ModelRenderer VisorRight1;
    ModelRenderer VisorLeft1;
    ModelRenderer VisorLeft2;
    ModelRenderer VisorRight2;
    ModelRenderer VisorLeft3;
    ModelRenderer VisorRight3;
    ModelRenderer Cheek1;
    ModelRenderer Cheek2;
    ModelRenderer HeadLeft;
    ModelRenderer HeadBack;
    ModelRenderer RimFrontRight;
    ModelRenderer RimFrontLeft;
    ModelRenderer RimRight;
    ModelRenderer RimLeft;
    ModelRenderer RimBack;
    ModelRenderer VisorBrow2;
    ModelRenderer DecoRimFrontLeft;
    ModelRenderer DecoRimFrontRight;
    ModelRenderer Top1;
    ModelRenderer Top2;
    ModelRenderer Top3;
    ModelRenderer DecoRimTopLeft;
    ModelRenderer DecoRimTopRight;
    ModelRenderer DecoRimBackLeft;
    ModelRenderer DecoRimBackRight;
    ModelRenderer WingLeft1;
    ModelRenderer WingLeft2;
    ModelRenderer WingLeft3;
    ModelRenderer WingLeft4;
    ModelRenderer WingRight1;
    ModelRenderer WingRight2;
    ModelRenderer WingRight3;
    ModelRenderer WingRight4;
    ModelRenderer Forehead;
    ModelRenderer SinglePixelRim;
    ModelRenderer SinglePixelRim2;

  public HelmetTestModel()
  {
    textureWidth = 128;
    textureHeight = 64;
   
      HeadRight = new ModelRenderer(this, 102, 0);
      HeadRight.addBox(0F, 0F, 0F, 1, 9, 10);
      HeadRight.setRotationPoint(4F, -9F, -5F);
      HeadRight.setTextureSize(128, 64);
      HeadRight.mirror = true;
      setRotation(HeadRight, 0F, 0F, 0F);
      VisorBrow1 = new ModelRenderer(this, 78, 0);
      VisorBrow1.addBox(0F, 0F, 0F, 10, 1, 1);
      VisorBrow1.setRotationPoint(-5F, -7F, -6F);
      VisorBrow1.setTextureSize(128, 64);
      VisorBrow1.mirror = true;
      setRotation(VisorBrow1, 0F, 0F, 0F);
      VisorRight1 = new ModelRenderer(this, 96, 3);
      VisorRight1.addBox(0F, 0F, 0F, 1, 2, 1);
      VisorRight1.setRotationPoint(4F, -6F, -6F);
      VisorRight1.setTextureSize(128, 64);
      VisorRight1.mirror = true;
      setRotation(VisorRight1, 0F, 0F, 0F);
      VisorLeft1 = new ModelRenderer(this, 91, 3);
      VisorLeft1.addBox(0F, 0F, 0F, 1, 2, 1);
      VisorLeft1.setRotationPoint(-5F, -6F, -6F);
      VisorLeft1.setTextureSize(128, 64);
      VisorLeft1.mirror = true;
      setRotation(VisorLeft1, 0F, 0F, 0F);
      VisorLeft2 = new ModelRenderer(this, 84, 3);
      VisorLeft2.addBox(0F, 0F, 0F, 2, 1, 1);
      VisorLeft2.setRotationPoint(-4F, -4F, -6F);
      VisorLeft2.setTextureSize(128, 64);
      VisorLeft2.mirror = true;
      setRotation(VisorLeft2, 0F, 0F, 0F);
      VisorRight2 = new ModelRenderer(this, 77, 3);
      VisorRight2.addBox(0F, 0F, 0F, 2, 1, 1);
      VisorRight2.setRotationPoint(2F, -4F, -6F);
      VisorRight2.setTextureSize(128, 64);
      VisorRight2.mirror = true;
      setRotation(VisorRight2, 0F, 0F, 0F);
      VisorLeft3 = new ModelRenderer(this, 71, 0);
      VisorLeft3.addBox(0F, 0F, 0F, 1, 3, 1);
      VisorLeft3.setRotationPoint(-2F, -3F, -6F);
      VisorLeft3.setTextureSize(128, 64);
      VisorLeft3.mirror = true;
      setRotation(VisorLeft3, 0F, 0F, 0F);
      VisorRight3 = new ModelRenderer(this, 66, 0);
      VisorRight3.addBox(0F, 0F, 0F, 1, 3, 1);
      VisorRight3.setRotationPoint(1F, -3F, -6F);
      VisorRight3.setTextureSize(128, 64);
      VisorRight3.mirror = true;
      setRotation(VisorRight3, 0F, 0F, 0F);
      Cheek1 = new ModelRenderer(this, 92, 7);
      Cheek1.addBox(0F, 0F, 0F, 3, 3, 1);
      Cheek1.setRotationPoint(-4F, -3F, -5F);
      Cheek1.setTextureSize(128, 64);
      Cheek1.mirror = true;
      setRotation(Cheek1, 0F, 0F, 0F);
      Cheek2 = new ModelRenderer(this, 83, 7);
      Cheek2.addBox(0F, 0F, 0F, 3, 3, 1);
      Cheek2.setRotationPoint(1F, -3F, -5F);
      Cheek2.setTextureSize(128, 64);
      Cheek2.mirror = true;
      setRotation(Cheek2, 0F, 0F, 0F);
      HeadLeft = new ModelRenderer(this, 102, 20);
      HeadLeft.addBox(0F, 0F, 0F, 1, 9, 10);
      HeadLeft.setRotationPoint(-5F, -9F, -5F);
      HeadLeft.setTextureSize(128, 64);
      HeadLeft.mirror = true;
      setRotation(HeadLeft, 0F, 0F, 0F);
      HeadBack = new ModelRenderer(this, 82, 13);
      HeadBack.addBox(0F, 0F, 0F, 8, 9, 1);
      HeadBack.setRotationPoint(-4F, -9F, 4F);
      HeadBack.setTextureSize(128, 64);
      HeadBack.mirror = true;
      setRotation(HeadBack, 0F, 0F, 0F);
      RimFrontRight = new ModelRenderer(this, 74, 7);
      RimFrontRight.addBox(0F, 0F, 0F, 3, 1, 1);
      RimFrontRight.setRotationPoint(1F, 0F, -6F);
      RimFrontRight.setTextureSize(128, 64);
      RimFrontRight.mirror = true;
      setRotation(RimFrontRight, 0F, 0F, 0F);
      RimFrontLeft = new ModelRenderer(this, 74, 10);
      RimFrontLeft.addBox(0F, 0F, 0F, 3, 1, 1);
      RimFrontLeft.setRotationPoint(-4F, 0F, -6F);
      RimFrontLeft.setTextureSize(128, 64);
      RimFrontLeft.mirror = true;
      setRotation(RimFrontLeft, 0F, 0F, 0F);
      RimRight = new ModelRenderer(this, 102, 41);
      RimRight.addBox(0F, 0F, 0F, 1, 1, 10);
      RimRight.setRotationPoint(5F, -1F, -5F);
      RimRight.setTextureSize(128, 64);
      RimRight.mirror = true;
      setRotation(RimRight, 0F, 0F, 0F);
      RimLeft = new ModelRenderer(this, 78, 24);
      RimLeft.addBox(0F, 0F, 0F, 1, 1, 10);
      RimLeft.setRotationPoint(-6F, -1F, -5F);
      RimLeft.setTextureSize(128, 64);
      RimLeft.mirror = true;
      setRotation(RimLeft, 0F, 0F, 0F);
      RimBack = new ModelRenderer(this, 78, 36);
      RimBack.addBox(0F, 0F, 0F, 10, 1, 1);
      RimBack.setRotationPoint(-5F, -1F, 5F);
      RimBack.setTextureSize(128, 64);
      RimBack.mirror = true;
      setRotation(RimBack, 0F, 0F, 0F);
      VisorBrow2 = new ModelRenderer(this, 67, 7);
      VisorBrow2.addBox(0F, 0F, 0F, 2, 1, 1);
      VisorBrow2.setRotationPoint(-1F, -6F, -6F);
      VisorBrow2.setTextureSize(128, 64);
      VisorBrow2.mirror = true;
      setRotation(VisorBrow2, 0F, 0F, 0F);
      DecoRimFrontLeft = new ModelRenderer(this, 76, 14);
      DecoRimFrontLeft.addBox(0F, 0F, 0F, 1, 4, 1);
      DecoRimFrontLeft.setRotationPoint(-2F, -11F, -6F);
      DecoRimFrontLeft.setTextureSize(128, 64);
      DecoRimFrontLeft.mirror = true;
      setRotation(DecoRimFrontLeft, 0F, 0F, 0F);
      DecoRimFrontRight = new ModelRenderer(this, 71, 14);
      DecoRimFrontRight.addBox(0F, 0F, 0F, 1, 4, 1);
      DecoRimFrontRight.setRotationPoint(1F, -11F, -6F);
      DecoRimFrontRight.setTextureSize(128, 64);
      DecoRimFrontRight.mirror = true;
      setRotation(DecoRimFrontRight, 0F, 0F, 0F);
      Top1 = new ModelRenderer(this, 64, 41);
      Top1.addBox(0F, 0F, 0F, 10, 1, ;
      Top1.setRotationPoint(-5F, -10F, -4F);
      Top1.setTextureSize(128, 64);
      Top1.mirror = true;
      setRotation(Top1, 0F, 0F, 0F);
      Top2 = new ModelRenderer(this, 46, 0);
      Top2.addBox(0F, 0F, 0F, 8, 1, 1);
      Top2.setRotationPoint(-4F, -10F, 4F);
      Top2.setTextureSize(128, 64);
      Top2.mirror = true;
      setRotation(Top2, 0F, 0F, 0F);
      Top3 = new ModelRenderer(this, 46, 4);
      Top3.addBox(0F, 0F, 0F, 8, 1, 1);
      Top3.setRotationPoint(-4F, -10F, -5F);
      Top3.setTextureSize(128, 64);
      Top3.mirror = true;
      setRotation(Top3, 0F, 0F, 0F);
      DecoRimTopLeft = new ModelRenderer(this, 54, 27);
      DecoRimTopLeft.addBox(0F, 0F, 0F, 1, 1, 10);
      DecoRimTopLeft.setRotationPoint(-2F, -11F, -5F);
      DecoRimTopLeft.setTextureSize(128, 64);
      DecoRimTopLeft.mirror = true;
      setRotation(DecoRimTopLeft, 0F, 0F, 0F);
      DecoRimTopRight = new ModelRenderer(this, 29, 27);
      DecoRimTopRight.addBox(0F, 0F, 0F, 1, 1, 10);
      DecoRimTopRight.setRotationPoint(1F, -11F, -5F);
      DecoRimTopRight.setTextureSize(128, 64);
      DecoRimTopRight.mirror = true;
      setRotation(DecoRimTopRight, 0F, 0F, 0F);
      DecoRimBackLeft = new ModelRenderer(this, 65, 14);
      DecoRimBackLeft.addBox(0F, 0F, 0F, 1, 9, 1);
      DecoRimBackLeft.setRotationPoint(-2F, -10F, 5F);
      DecoRimBackLeft.setTextureSize(128, 64);
      DecoRimBackLeft.mirror = true;
      setRotation(DecoRimBackLeft, 0F, 0F, 0F);
      DecoRimBackRight = new ModelRenderer(this, 59, 14);
      DecoRimBackRight.addBox(0F, 0F, 0F, 1, 9, 1);
      DecoRimBackRight.setRotationPoint(1F, -10F, 5F);
      DecoRimBackRight.setTextureSize(128, 64);
      DecoRimBackRight.mirror = true;
      setRotation(DecoRimBackRight, 0F, 0F, 0F);
      WingLeft1 = new ModelRenderer(this, 53, 9);
      WingLeft1.addBox(0F, 0F, 0F, 4, 1, 2);
      WingLeft1.setRotationPoint(-9F, -8F, -1F);
      WingLeft1.setTextureSize(128, 64);
      WingLeft1.mirror = true;
      setRotation(WingLeft1, 0F, 0F, 0F);
      WingLeft2 = new ModelRenderer(this, 42, 9);
      WingLeft2.addBox(0F, 0F, 0F, 3, 1, 2);
      WingLeft2.setRotationPoint(-8F, -7F, -1F);
      WingLeft2.setTextureSize(128, 64);
      WingLeft2.mirror = true;
      setRotation(WingLeft2, 0F, 0F, 0F);
      WingLeft3 = new ModelRenderer(this, 49, 14);
      WingLeft3.addBox(0F, 0F, 0F, 2, 1, 2);
      WingLeft3.setRotationPoint(-7F, -6F, -1F);
      WingLeft3.setTextureSize(128, 64);
      WingLeft3.mirror = true;
      setRotation(WingLeft3, 0F, 0F, 0F);
      WingLeft4 = new ModelRenderer(this, 51, 19);
      WingLeft4.addBox(0F, 0F, 0F, 1, 1, 2);
      WingLeft4.setRotationPoint(-6F, -5F, -1F);
      WingLeft4.setTextureSize(128, 64);
      WingLeft4.mirror = true;
      setRotation(WingLeft4, 0F, 0F, 0F);
      WingRight1 = new ModelRenderer(this, 32, 0);
      WingRight1.addBox(0F, 0F, 0F, 4, 1, 2);
      WingRight1.setRotationPoint(5F, -8F, -1F);
      WingRight1.setTextureSize(128, 64);
      WingRight1.mirror = true;
      setRotation(WingRight1, 0F, 0F, 0F);
      WingRight2 = new ModelRenderer(this, 33, 5);
      WingRight2.addBox(0F, 0F, 0F, 3, 1, 2);
      WingRight2.setRotationPoint(5F, -7F, -1F);
      WingRight2.setTextureSize(128, 64);
      WingRight2.mirror = true;
      setRotation(WingRight2, 0F, 0F, 0F);
      WingRight3 = new ModelRenderer(this, 40, 14);
      WingRight3.addBox(0F, 0F, 0F, 2, 1, 2);
      WingRight3.setRotationPoint(5F, -6F, -1F);
      WingRight3.setTextureSize(128, 64);
      WingRight3.mirror = true;
      setRotation(WingRight3, 0F, 0F, 0F);
      WingRight4 = new ModelRenderer(this, 43, 19);
      WingRight4.addBox(0F, 0F, 0F, 1, 1, 2);
      WingRight4.setRotationPoint(5F, -5F, -1F);
      WingRight4.setTextureSize(128, 64);
      WingRight4.mirror = true;
      setRotation(WingRight4, 0F, 0F, 0F);
      Forehead = new ModelRenderer(this, 11, 0);
      Forehead.addBox(0F, 0F, 0F, 8, 3, 1);
      Forehead.setRotationPoint(-4F, -9F, -5F);
      Forehead.setTextureSize(128, 64);
      Forehead.mirror = true;
      setRotation(Forehead, 0F, 0F, 0F);
      SinglePixelRim = new ModelRenderer(this, 0, 0);
      SinglePixelRim.addBox(0F, 0F, 0F, 1, 1, 1);
      SinglePixelRim.setRotationPoint(-5F, -1F, -6F);
      SinglePixelRim.setTextureSize(128, 64);
      SinglePixelRim.mirror = true;
      setRotation(SinglePixelRim, 0F, 0F, 0F);
      SinglePixelRim2 = new ModelRenderer(this, 5, 0);
      SinglePixelRim2.addBox(0F, 0F, 0F, 1, 1, 1);
      SinglePixelRim2.setRotationPoint(4F, -1F, -6F);
      SinglePixelRim2.setTextureSize(128, 64);
      SinglePixelRim2.mirror = true;
      setRotation(SinglePixelRim2, 0F, 0F, 0F);
  }

  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    HeadRight.render(f5);
    VisorBrow1.render(f5);
    VisorRight1.render(f5);
    VisorLeft1.render(f5);
    VisorLeft2.render(f5);
    VisorRight2.render(f5);
    VisorLeft3.render(f5);
    VisorRight3.render(f5);
    Cheek1.render(f5);
    Cheek2.render(f5);
    HeadLeft.render(f5);
    HeadBack.render(f5);
    RimFrontRight.render(f5);
    RimFrontLeft.render(f5);
    RimRight.render(f5);
    RimLeft.render(f5);
    RimBack.render(f5);
    VisorBrow2.render(f5);
    DecoRimFrontLeft.render(f5);
    DecoRimFrontRight.render(f5);
    Top1.render(f5);
    Top2.render(f5);
    Top3.render(f5);
    DecoRimTopLeft.render(f5);
    DecoRimTopRight.render(f5);
    DecoRimBackLeft.render(f5);
    DecoRimBackRight.render(f5);
    WingLeft1.render(f5);
    WingLeft2.render(f5);
    WingLeft3.render(f5);
    WingLeft4.render(f5);
    WingRight1.render(f5);
    WingRight2.render(f5);
    WingRight3.render(f5);
    WingRight4.render(f5);
    Forehead.render(f5);
    SinglePixelRim.render(f5);
    SinglePixelRim2.render(f5);
  }

  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }

  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

And no my name is not inspired by DBZ ^^

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • rp.crazyheal.xyz mods  
    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.