Jump to content

[Unsolved] How to make an armor using Forge for SMP?


Soviet

Recommended Posts

Hello again,

 

I would like some help to make my mod working on SMP.

According to the previous topic, http://www.minecraftforge.net/forum/index.php/topic,3053.msg20596.html#msg20596, all you need to do is to put your mod in the server and that's fine. Well, not for me. In solo, mod works fine and does not crash. I get immediate crash when trying to set it up on SMP. I used the Forge ModLoader to load my mod. Here's the log:

 

 

 

---- Minecraft Crash Report ----

// Ooh. Shiny.

 

Time: 30/06/13 00:23

Description: Exception in server tick loop

 

java.lang.NoSuchMethodError: net.minecraft.src.ModLoader.addArmor(Ljava/lang/String;)I

at s0vietique.alloycraft.client.Alloycraft.<clinit>(Alloycraft.java:55)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Unknown Source)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:425)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:192)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:172)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:103)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:504)

at cpw.mods.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:85)

at cpw.mods.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:350)

at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:69)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:431)

at net.minecraft.server.ThreadMinecraftServer.run(SourceFile:573)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- System Details --

Details:

Minecraft Version: 1.5.2

Operating System: Windows 7 (x86) version 6.1

Java Version: 1.7.0_25, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode, sharing), Oracle Corporation

Memory: 27327992 bytes (26 MB) / 48537600 bytes (46 MB) up to 259522560 bytes (247 MB)

JVM Flags: 0 total;

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v7.51 FML v5.2.23.737 Minecraft Forge 7.8.1.737 4 mods loaded, 4 mods active

mcp{7.51} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed

FML{5.2.23.737} [Forge Mod Loader] (coremods) Unloaded->Constructed

Forge{7.8.1.737} [Minecraft Forge] (coremods) Unloaded->Constructed

Alloycraft{0.5 BETA} [Alloycraft] (Alloycraft 1-5-2.zip) Unloaded

Profiler Position: N/A (disabled)

Is Modded: Definitely; Server brand changed to 'fml,forge'

Type: Dedicated Server (map_server.txt)

 

 

 

From what I read, it has trouble with the armor adding by ModLoader.

Here are the culprits:

 



public final static Item bootsCopper = new SovCopperBoots(912, CopperArmorMaterial, ModLoader.addArmor("copper"), 3).setUnlocalizedName("copperBoots").setCreativeTab(CreativeTabs.tabCombat);
		public final static Item leggingsCopper = new SovCopperLeggings(913, CopperArmorMaterial, ModLoader.addArmor("copper"), 2).setUnlocalizedName("copperLegging").setCreativeTab(CreativeTabs.tabCombat);
		public final static Item chestCopper = new SovCopperChest(914, CopperArmorMaterial, ModLoader.addArmor("copper"), 1).setUnlocalizedName("copperChest").setCreativeTab(CreativeTabs.tabCombat);
		public final static Item helmetCopper = new SovCopperHelmet(915, CopperArmorMaterial, ModLoader.addArmor("copper"), 0).setUnlocalizedName("copperHelmet").setCreativeTab(CreativeTabs.tabCombat);

public final static Item bootsSteel = new SovSteelBoots(908, steelArmorMaterial2, ModLoader.addArmor("steel"), 3).setUnlocalizedName("steelBoots").setCreativeTab(CreativeTabs.tabCombat);
		public final static Item leggingsSteel = new SovSteelLeggings(909, steelArmorMaterial2, ModLoader.addArmor("steel"), 2).setUnlocalizedName("steelLegging").setCreativeTab(CreativeTabs.tabCombat);
		public final static Item chestSteel = new SovSteelChest(910, steelArmorMaterial2, ModLoader.addArmor("steel"), 1).setUnlocalizedName("steelChest").setCreativeTab(CreativeTabs.tabCombat);
		public final static Item helmetSteel = new SovSteelHelmet(911, steelArmorMaterial2, ModLoader.addArmor("steel"), 0).setUnlocalizedName("steelHelmet").setCreativeTab(CreativeTabs.tabCombat);

 

 

Can anyone give a hand? Thanks by advance.

Link to comment
Share on other sites

I don't know if it helps, but when I put my mod in "coremods" instead of "mods" in my server folders, the server doesn't crash anymore. But! When I try to place a block from my mod, it instantly disappears (spawn protection not counted) and is removed from my inventory. Also, I don't see any traces of my custom ores...

Link to comment
Share on other sites

Here's the code I use to register armor in Forge:

 

public static Item gemChest = new GemChest(5004, EnumArmorMaterial.IRON, 2, 1).setUnlocalizedName("gemChest");
Registration.itemRegistration(gemChest, "Gem Chest");

public static void itemRegistration(Item par1, String par2)
  {
	  GameRegistry.registerItem(par1, par2);
      LanguageRegistry.addName(par1, par2);
  }

Link to comment
Share on other sites

I used the tutorial by TheGrovesyProject101. It uses a deprecated class, but it works.

 

Doesn't work.

Here's the code I use to register armor in Forge:

 

public static Item gemChest = new GemChest(5004, EnumArmorMaterial.IRON, 2, 1).setUnlocalizedName("gemChest");
Registration.itemRegistration(gemChest, "Gem Chest");

public static void itemRegistration(Item par1, String par2)
  {
	  GameRegistry.registerItem(par1, par2);
      LanguageRegistry.addName(par1, par2);
  }

 

I want to do an armor with custom textures. I don't want it to have iron textures.

Link to comment
Share on other sites

No problem, just override the texture in the item class:

@Override
        public String getArmorTextureFile(ItemStack itemstack) 
        {
                        return "/mods/Amanus/textures/gemArmor.png";
        }

Link to comment
Share on other sites

No problem, just override the texture in the item class:

@Override
        public String getArmorTextureFile(ItemStack itemstack) 
        {
                        return "/mods/Amanus/textures/gemArmor.png";
        }

 

I mean, my items are textured. It's when worn they aren't.

Link to comment
Share on other sites

I did like you said, I still get iron texture.

 

Pretty sure you method works but what do I have to change ?

Here's a sample of my code:

public final static Item bootsSteel = new SovSteelBoots(908, steelArmorMaterial2, 2, 3).setUnlocalizedName("steelBoots").setCreativeTab(CreativeTabs.tabCombat);

So, 2 is the iron texture. What do I replace it with ?

Link to comment
Share on other sites

In the new version you have to use the getArmorTexture() function from the Item class to your armor item calss.Here is an example on how to use it:(took from my own mod)

 

 

 

package mods.GeoActivity.common.items.armor;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IArmorTextureProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ReinforcedBoots extends ItemArmor
{
    public ReinforcedBoots(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4)
    {
        super(par1, par2EnumArmorMaterial, par3, par4);
    }

    @Override
    public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer)
    {
        return "/mods/GeoActivity/textures/armor1.png"; //path to the armor texture that is rendered on the player, see the Vanilla textures
    }

    @SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister icon)
    {
             this.itemIcon = icon.registerIcon("GeoActivity:reinforced_boots"); // the texture of the item in inventory
    }
}

 

 

 

Also when you register the armor you have to do it like so:

 

reinforcedBoots = new ReinforcedBoots(reBoots, ReinforcedArmorMaterial, RenderingRegistry.addNewArmourRendererPrefix("reinforced"), 3).setUnlocalizedName("reinforcedboots").setCreativeTab(CreativeTabs.tabCombat);

 

Notice the RenderingRegistry added there with a custom name you want.

It works perfectly fine for me, with no errors.

Link to comment
Share on other sites

In the new version you have to use the getArmorTexture() function from the Item class to your armor item calss.Here is an example on how to use it:(took from my own mod)

 

 

 

package mods.GeoActivity.common.items.armor;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IArmorTextureProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ReinforcedBoots extends ItemArmor
{
    public ReinforcedBoots(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4)
    {
        super(par1, par2EnumArmorMaterial, par3, par4);
    }

    @Override
    public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer)
    {
        return "/mods/GeoActivity/textures/armor1.png"; //path to the armor texture that is rendered on the player, see the Vanilla textures
    }

    @SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister icon)
    {
             this.itemIcon = icon.registerIcon("GeoActivity:reinforced_boots"); // the texture of the item in inventory
    }
}

 

 

 

Also when you register the armor you have to do it like so:

 

reinforcedBoots = new ReinforcedBoots(reBoots, ReinforcedArmorMaterial, RenderingRegistry.addNewArmourRendererPrefix("reinforced"), 3).setUnlocalizedName("reinforcedboots").setCreativeTab(CreativeTabs.tabCombat);

 

Notice the RenderingRegistry added there with a custom name you want.

It works perfectly fine for me, with no errors.

 

I used your methods and yes, it works. Problem is, it still crashes my server.jar:

 

 

---- Minecraft Crash Report ----

// You're mean.

 

Time: 30/06/13 22:25

Description: Exception in server tick loop

 

java.lang.NoClassDefFoundError: net/minecraft/client/renderer/entity/RenderPlayer

at cpw.mods.fml.client.registry.RenderingRegistry.addNewArmourRendererPrefix(RenderingRegistry.java:51)

at s0vietique.alloycraft.client.Alloycraft.<clinit>(Alloycraft.java:56)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Unknown Source)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:425)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:192)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:172)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:103)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:504)

at cpw.mods.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:85)

at cpw.mods.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:350)

at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:69)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:431)

at net.minecraft.server.ThreadMinecraftServer.run(SourceFile:573)

Caused by: java.lang.ClassNotFoundException: net.minecraft.client.renderer.entity.RenderPlayer

at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:238)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

... 32 more

Caused by: java.lang.RuntimeException: Attempted to load class bht for invalid side SERVER

at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50)

at cpw.mods.fml.relauncher.RelaunchClassLoader.runTransformers(RelaunchClassLoader.java:352)

at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:225)

... 34 more

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- System Details --

Details:

Minecraft Version: 1.5.2

Operating System: Windows 7 (x86) version 6.1

Java Version: 1.7.0_25, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode, sharing), Oracle Corporation

Memory: 20077712 bytes (19 MB) / 50151424 bytes (47 MB) up to 259522560 bytes (247 MB)

JVM Flags: 0 total;

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v7.51 FML v5.2.23.737 Minecraft Forge 7.8.1.737 4 mods loaded, 4 mods active

mcp{7.51} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed

FML{5.2.23.737} [Forge Mod Loader] (coremods) Unloaded->Constructed

Forge{7.8.1.737} [Minecraft Forge] (coremods) Unloaded->Constructed

Alloycraft{0.5 BETA} [Alloycraft] (Alloycraft 1-5-2.zip) Unloaded

Profiler Position: N/A (disabled)

Is Modded: Definitely; Server brand changed to 'fml,forge'

Type: Dedicated Server (map_server.txt)

 

 

Link to comment
Share on other sites

Bump... Please, I don't understand what I have to do to make it work on SMP.

Line 56 of Alloycraft is...?

 

public final static Item bootsSteel = new SovSteelBoots(908, steelArmorMaterial2, RenderingRegistry.addNewArmourRendererPrefix("steel"), 3).setUnlocalizedName("steelBoots").setCreativeTab(CreativeTabs.tabCombat);

This is the first armor line in my main class.

Link to comment
Share on other sites

Bump... Please, I don't understand what I have to do to make it work on SMP.

Line 56 of Alloycraft is...?

 

public final static Item bootsSteel = new SovSteelBoots(908, steelArmorMaterial2, RenderingRegistry.addNewArmourRendererPrefix("steel"), 3).setUnlocalizedName("steelBoots").setCreativeTab(CreativeTabs.tabCombat);

This is the first armor line in my main class.

Oh. Right. Erm, Decebal²? Where are you calling that? Because it's client-only.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

my mod use proxy's but i can tell your how i make mine work step by step and if that don't work your can pm me your skype and i can explain it to your

1. we need the client so we are gonna put

   public static int addArmor(String Armor){
        return 0;
    }

in the commonproxy

the server do not need it so that's why commonproxy will return 0

2. add the same code in your client proxy but this time it is going to return RenderingRegistry.addNewArmourRendererPrefix(armor) insted of 0

    public static int addArmor(String armor){
        return RenderingRegistry.addNewArmourRendererPrefix(armor);
    }

3. now to use this code in a item your are simple just gonna add it like this

Name = new Armorclass(id, Enum, CommonProxy.addArmor("add something here"), 0);

4. now we need the armor to show up but i think your all ready now that so just say if your need more help (or as i said before pm me your skype)

 

edit--

feel free to look at my mods github to see with 100% how i make armor work with forge and SMP

https://github.com/henrikse55/Item-Pack

Link to comment
Share on other sites

Easy fix use this:

 

Base Class

Static:

public static EnumArmorMaterial BRONZE = EnumHelper.addArmorMaterial("BRONZE", 8,  new int[]{2, 6, 4, 2}, 5);

Load:

BronzePlateChest = new BronzeArmor(2016,  Core.BRONZE, proxy.addArmor("Bronze Platechest"), 1).setUnlocalizedName("CyphScape_BronzeChestPlate");

 

Armor Class:

package mods.cyphereion.cyphscape.core;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IArmorTextureProvider;

public class BronzeArmor extends ItemArmor implements IArmorTextureProvider{

public BronzeArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial,
		int par3, int par4) {
	super(par1, par2EnumArmorMaterial, par3, par4);
	this.setCreativeTab(Core.tabCyphScape);
}

@Override
public String getArmorTextureFile(ItemStack itemstack) {
	if(itemstack.itemID == Core.BronzeFullHelmet.itemID || itemstack.itemID == Core.BronzePlateChest.itemID || itemstack.itemID == Core.BronzeBoots.itemID){
	return "/textures/armor/Bronze_1.png";
	}

	if(itemstack.itemID == Core.BronzePlateLegs.itemID){
		return "/textures/armor/Bronze_2.png";
	}

	else return null;

}

}

 

That is literally it. And btw try to avoid modloader methods, those need modloader mp to work. Forge has built in multiplayer so stick with that.

 

Whoops forgot. Here it is now :3

 

Client Proxy:

	public int addArmor(String armor){
	return RenderingRegistry.addNewArmourRendererPrefix(armor);
}

 

 

Common Proxy:

public static int addArmor(String Armor){
        return 0;
    }

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.