Jump to content

Custom repairable tools


DrOlive

Recommended Posts

Hey everyone,

I've been busy making a mod and I added a lot of tools which work perfect, except they can't be repaired on an anvil.

Is there any way to make a custom tool repairable (preferably without making a whole bunch of new classes)?

 

My main class:

package drolive.orenimals;

import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="Orenimals", name="Orenimals", version="1.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)

public class Orenimals {
//Creative Tab
public static CreativeTabs tabOrenimals = new CreativeTabs("tabOrenimals") {
	public ItemStack getIconItemStack() {
		return new ItemStack(Orenimals.ingotChickenium, 1, 0);
		}
};

//Tool Materials
public static EnumToolMaterial toolPorkite = EnumHelper.addToolMaterial("toolPorkite", 1, 260, 5.0F, 1.5F, 10);
public static EnumToolMaterial toolChickenium = EnumHelper.addToolMaterial("toolChickenium", 1, 200, 6.2F, 1.5F, 10);
public static EnumToolMaterial toolSteakite = EnumHelper.addToolMaterial("toolSteakite", 1, 200, 5.0F, 2.5F, 10);
public static EnumToolMaterial toolWoolidium = EnumHelper.addToolMaterial("toolWoolidium", 1, 200, 5.0F, 1.5F, 16);

//Armor Materials
public static EnumArmorMaterial armorPorkite = EnumHelper.addArmorMaterial("armorPorkite", 16, new int[]{2, 5, 4, 1}, 10);
public static EnumArmorMaterial armorChickenium = EnumHelper.addArmorMaterial("armorChickenium", 16, new int[]{2, 5, 4, 1}, 10);
public static EnumArmorMaterial armorSteakite = EnumHelper.addArmorMaterial("armorSteakite", 11, new int[]{3, 6, 5, 2}, 10);
public static EnumArmorMaterial armorWoolidium = EnumHelper.addArmorMaterial("armorWoolidium", 11, new int[]{2, 5, 4, 1}, 16);

//Item IDs
public static int ingotPorkiteID;
public static int ingotChickeniumID;
public static int ingotSteakiteID;
public static int ingotWoolidiumID;
public static int pickaxePorkiteID;
public static int pickaxeChickeniumID;
public static int pickaxeSteakiteID;
public static int pickaxeWoolidiumID;
public static int shovelPorkiteID;
public static int shovelChickeniumID;
public static int shovelSteakiteID;
public static int shovelWoolidiumID;
public static int hoePorkiteID;
public static int hoeChickeniumID;
public static int hoeSteakiteID;
public static int hoeWoolidiumID;
public static int axePorkiteID;
public static int axeChickeniumID;
public static int axeSteakiteID;
public static int axeWoolidiumID;
public static int swordPorkiteID;
public static int swordChickeniumID;
public static int swordSteakiteID;
public static int swordWoolidiumID;
public static int helmetPorkiteID;
public static int chestplatePorkiteID;
public static int leggingsPorkiteID;
public static int bootsPorkiteID;

//Block IDs
public static int orePorkiteID;
public static int oreChickeniumID;
public static int oreSteakiteID;
public static int oreWoolidiumID;

//Items
public static Item ingotPorkite;
public static Item ingotChickenium;
public static Item ingotSteakite;
public static Item ingotWoolidium;
public static Item pickaxePorkite;
public static Item pickaxeChickenium;
public static Item pickaxeSteakite;
public static Item pickaxeWoolidium;
public static Item shovelPorkite;
public static Item shovelChickenium;
public static Item shovelSteakite;
public static Item shovelWoolidium;
public static Item hoePorkite;
public static Item hoeChickenium;
public static Item hoeSteakite;
public static Item hoeWoolidium;
public static Item axePorkite;
public static Item axeChickenium;
public static Item axeSteakite;
public static Item axeWoolidium;
public static Item swordPorkite;
public static Item swordChickenium;
public static Item swordSteakite;
public static Item swordWoolidium;
public static Item helmetPorkite;
public static Item chestplatePorkite;
public static Item leggingsPorkite;
public static Item bootsPorkite;

//Blocks
public static Block orePorkite;
public static Block oreChickenium;
public static Block oreSteakite;
public static Block oreWoolidium;

@Instance("Orenimals")
public static Orenimals instance;

@SidedProxy(clientSide="drolive.orenimals.client.ClientProxy", serverSide="drolive.orenimals.CommonProxy")
public static CommonProxy proxy;

@EventHandler
public void preInit(FMLPreInitializationEvent event){

		Configuration config = new Configuration(event.getSuggestedConfigurationFile());
		config.load();

		ingotPorkiteID = config.getItem("Porkite Ingot", 26201).getInt();
		ingotChickeniumID = config.getItem("Chickenium Ingot", 26202).getInt();
		ingotSteakiteID = config.getItem("Steakite Ingot", 26203).getInt();
		ingotWoolidiumID = config.getItem("Woolidium Ingot", 26204).getInt();
		pickaxePorkiteID = config.getItem("Porkite Pickaxe", 26205).getInt();
		pickaxeChickeniumID = config.getItem("Chickenium Pickaxe", 26206).getInt();
		pickaxeSteakiteID = config.getItem("Steakite Pickaxe", 26207).getInt();
		pickaxeWoolidiumID = config.getItem("Woolidium Pickaxe", 26208).getInt();
		shovelPorkiteID = config.getItem("Porkite Shovel", 26209).getInt();
		shovelChickeniumID = config.getItem("Chickenium Shovel", 26210).getInt();
		shovelSteakiteID = config.getItem("Steakite Shovel", 26211).getInt();
		shovelWoolidiumID = config.getItem("Woolidium Shovel", 26212).getInt();
		hoePorkiteID = config.getItem("Porkite Hoe", 26213).getInt();
		hoeChickeniumID = config.getItem("Chickenium Hoe", 26214).getInt();
		hoeSteakiteID = config.getItem("Steakite Hoe", 26215).getInt();
		hoeWoolidiumID = config.getItem("Woolidium Hoe", 26216).getInt();
		axePorkiteID = config.getItem("Porkite Axe", 26217).getInt();
		axeChickeniumID = config.getItem("Chickenium Axe", 26218).getInt();
		axeSteakiteID = config.getItem("Steakite Axe", 26219).getInt();
		axeWoolidiumID = config.getItem("Woolidium Axe", 26220).getInt();
		swordPorkiteID = config.getItem("Porkite Sword", 26221).getInt();
		swordChickeniumID = config.getItem("Chickenium Sword", 26222).getInt();
		swordSteakiteID = config.getItem("Steakite Sword", 26223).getInt();
		swordWoolidiumID = config.getItem("Woolidium Sword", 26224).getInt();
		helmetPorkiteID = config.getItem("Porkite Helmet", 26225).getInt();
		chestplatePorkiteID = config.getItem("Porkite Chestplate", 26226).getInt();
		leggingsPorkiteID = config.getItem("Porkite Leggings", 26227).getInt();
		bootsPorkiteID = config.getItem("Porkite Boots", 26228).getInt();
		orePorkiteID = config.getBlock("Porkite Ore", 3001).getInt();
		oreChickeniumID = config.getBlock("Chickenium Ore", 3002).getInt();
		oreSteakiteID = config.getBlock("Steakite Ore", 3003).getInt();
		oreWoolidiumID = config.getBlock("Woolidium Ore", 3004).getInt();

		config.save();

GameRegistry.registerWorldGenerator(new OrenimalsWorldGen());

		LanguageRegistry.instance().addStringLocalization("itemGroup.tabOrenimals", "en_US", "Orenimals");

		//Items
		ingotPorkite = new OrenimalsItem(ingotPorkiteID, 64, tabOrenimals, "ingotPorkite").func_111206_d("orenimals:ingotPorkite");
		ingotChickenium = new OrenimalsItem(ingotChickeniumID, 64, tabOrenimals, "ingotChickenium").func_111206_d("orenimals:ingotChickenium");
		ingotSteakite = new OrenimalsItem(ingotSteakiteID, 64, tabOrenimals, "ingotSteakite").func_111206_d("orenimals:ingotSteakite");
		ingotWoolidium = new OrenimalsItem(ingotWoolidiumID, 64, tabOrenimals, "ingotWoolididum").func_111206_d("orenimals:ingotWoolidium");
		pickaxePorkite = new OrenimalsPickaxe(pickaxePorkiteID, toolPorkite, tabOrenimals, "pickaxePorkite").func_111206_d("Orenimals:pickaxePorkite");
		pickaxeChickenium = new OrenimalsPickaxe(pickaxeChickeniumID, toolChickenium, tabOrenimals, "pickaxeChickenium").func_111206_d("Orenimals:pickaxeChickenium");
		pickaxeSteakite = new OrenimalsPickaxe(pickaxeSteakiteID, toolSteakite, tabOrenimals, "pickaxeSteakite").func_111206_d("Orenimals:pickaxeSteakite");
		pickaxeWoolidium = new OrenimalsPickaxe(pickaxeWoolidiumID, toolWoolidium, tabOrenimals, "pickaxeWoolidium").func_111206_d("Orenimals:pickaxeWoolidium");
		shovelPorkite = new OrenimalsShovel(shovelPorkiteID, toolPorkite, tabOrenimals, "shovelPorkite").func_111206_d("Orenimals:shovelPorkite");
		shovelChickenium = new OrenimalsShovel(shovelChickeniumID, toolChickenium, tabOrenimals, "shovelChickenium").func_111206_d("Orenimals:shovelChickenium");
		shovelSteakite = new OrenimalsShovel(shovelSteakiteID, toolSteakite, tabOrenimals, "shovelSteakite").func_111206_d("Orenimals:shovelSteakite");
		shovelWoolidium = new OrenimalsShovel(shovelWoolidiumID, toolWoolidium, tabOrenimals, "shovelWoolidium").func_111206_d("Orenimals:shovelWoolidium");
		hoePorkite = new OrenimalsHoe(hoePorkiteID, toolPorkite, tabOrenimals, "hoePorkite").func_111206_d("Orenimals:hoePorkite");
		hoeChickenium = new OrenimalsHoe(hoeChickeniumID, toolChickenium, tabOrenimals, "hoeChickenium").func_111206_d("Orenimals:hoeChickenium");
		hoeSteakite = new OrenimalsHoe(hoeSteakiteID, toolSteakite, tabOrenimals, "hoeSteakite").func_111206_d("Orenimals:hoeSteakite");
		hoeWoolidium = new OrenimalsHoe(hoeWoolidiumID, toolWoolidium, tabOrenimals, "hoeWoolidium").func_111206_d("Orenimals:hoeWoolidium");
		axePorkite = new OrenimalsAxe(axePorkiteID, toolPorkite, tabOrenimals, "axePorkite").func_111206_d("Orenimals:hatchetPorkite");
		axeChickenium = new OrenimalsAxe(axeChickeniumID, toolChickenium, tabOrenimals, "axeChickenium").func_111206_d("Orenimals:hatchetChickenium");
		axeSteakite = new OrenimalsAxe(axeSteakiteID, toolSteakite, tabOrenimals, "axeSteakite").func_111206_d("Orenimals:hatchetSteakite");
		axeWoolidium = new OrenimalsAxe(axeWoolidiumID, toolWoolidium, tabOrenimals, "axeWoolidium").func_111206_d("Orenimals:hatchetWoolidium");
		swordPorkite = new OrenimalsSword(swordPorkiteID, toolPorkite, tabOrenimals, "swordPorkite").func_111206_d("Orenimals:swordPorkite");
		swordChickenium = new OrenimalsSword(swordChickeniumID, toolChickenium, tabOrenimals, "swordChickenium").func_111206_d("Orenimals:swordChickenium");
		swordSteakite = new OrenimalsSword(swordSteakiteID, toolSteakite, tabOrenimals, "swordSteakite").func_111206_d("Orenimals:swordSteakite");
		swordWoolidium = new OrenimalsSword(swordWoolidiumID, toolWoolidium, tabOrenimals, "swordWoolidium").func_111206_d("Orenimals:swordWoolidium");
		helmetPorkite = new OrenimalsArmor(helmetPorkiteID, armorPorkite, ModLoader.addArmor("porkite"), 0, tabOrenimals, "helmetPorkite").func_111206_d("Orenimals:helmetPorkite");
		chestplatePorkite = new OrenimalsArmor(chestplatePorkiteID, armorPorkite, ModLoader.addArmor("porkite"), 1, tabOrenimals, "chestplatePorkite").func_111206_d("Orenimals:chestplatePorkite");
		leggingsPorkite = new OrenimalsArmor(leggingsPorkiteID, armorPorkite, ModLoader.addArmor("porkite"), 2, tabOrenimals, "leggingsPorkite").func_111206_d("Orenimals:leggingsPorkite");
		bootsPorkite = new OrenimalsArmor(bootsPorkiteID, armorPorkite, ModLoader.addArmor("porkite"), 3, tabOrenimals, "bootsPorkite").func_111206_d("Orenimals:bootsPorkite");

		//Blocks
		orePorkite = new OrenimalsBlock(orePorkiteID, Material.rock, 3.0F, Block.soundStoneFootstep, "orePorkite", tabOrenimals).func_111022_d("orenimals:orePorkite");
		oreChickenium = new OrenimalsBlock(oreChickeniumID, Material.rock, 3.0F, Block.soundStoneFootstep, "oreChickenium", tabOrenimals).func_111022_d("orenimals:oreChickenium");
		oreSteakite = new OrenimalsBlock(oreSteakiteID, Material.rock, 3.0F, Block.soundStoneFootstep, "oreSteakite", tabOrenimals).func_111022_d("orenimals:oreSteakite");
		oreWoolidium = new OrenimalsBlock(oreWoolidiumID, Material.rock, 3.0F, Block.soundStoneFootstep, "oreWoolidium", tabOrenimals).func_111022_d("orenimals:oreWoolidium");

		//Recipes and other registry things
		ItemStack st = new ItemStack(Item.stick);
		ItemStack po = new ItemStack(Orenimals.ingotPorkite);
		ItemStack ch = new ItemStack(Orenimals.ingotChickenium);
		ItemStack ste = new ItemStack(Orenimals.ingotSteakite);
		ItemStack wo = new ItemStack(Orenimals.ingotWoolidium);

		LanguageRegistry.addName(ingotPorkite, "Porkite Ingot");
		GameRegistry.addSmelting(Orenimals.ingotPorkite.itemID, new ItemStack(Item.porkCooked), 0f);

		LanguageRegistry.addName(ingotChickenium, "Chickenium Ingot");
		GameRegistry.addSmelting(Orenimals.ingotChickenium.itemID, new ItemStack(Item.chickenCooked), 0f);

		LanguageRegistry.addName(ingotSteakite, "Steakite Ingot");
		GameRegistry.addSmelting(Orenimals.ingotSteakite.itemID, new ItemStack(Item.beefCooked), 0f);

		LanguageRegistry.addName(ingotWoolidium, "Woolidium Ingot");
		GameRegistry.addSmelting(Orenimals.ingotWoolidium.itemID, new ItemStack(Block.cloth), 0f);

		LanguageRegistry.addName(pickaxePorkite, "Porkite Pickaxe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.pickaxePorkite), "xxx", " y ", " y ", 'x', po, 'y', st);

		LanguageRegistry.addName(pickaxeChickenium, "Chickenium Pickaxe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.pickaxeChickenium), "xxx", " y ", " y ", 'x', ch, 'y', st);

		LanguageRegistry.addName(pickaxeSteakite, "Steakite Pickaxe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.pickaxeSteakite), "xxx", " y ", " y ", 'x', ste, 'y', st);

		LanguageRegistry.addName(pickaxeWoolidium, "Woolidium Pickaxe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.pickaxeWoolidium), "xxx", " y ", " y ", 'x', wo, 'y', st);

		LanguageRegistry.addName(shovelPorkite, "Porkite Shovel");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.shovelPorkite), "x", "y", "y", 'x', po, 'y', st);

		LanguageRegistry.addName(shovelChickenium, "Chickenium Shovel");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.shovelChickenium), "x", "y", "y", 'x', ch, 'y', st);

		LanguageRegistry.addName(shovelSteakite, "Steakite Shovel");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.shovelSteakite), "x", "y", "y", 'x', ste, 'y', st);

		LanguageRegistry.addName(shovelWoolidium, "Woolidium Shovel");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.shovelWoolidium), "x", "y", "y", 'x', wo, 'y', st);

		LanguageRegistry.addName(hoePorkite, "Porkite Hoe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.hoePorkite), "xx", " y", " y", 'x', po, 'y', st);

		LanguageRegistry.addName(hoeChickenium, "Chickenium Hoe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.hoeChickenium), "xx", " y", " y", 'x', ch, 'y', st);

		LanguageRegistry.addName(hoeSteakite, "Steakite Hoe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.hoeSteakite), "xx", " y", " y", 'x', ste, 'y', st);

		LanguageRegistry.addName(hoeWoolidium, "Woolidium Hoe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.hoeWoolidium), "xx", " y", " y", 'x', wo, 'y', st);

		LanguageRegistry.addName(axePorkite, "Porkite Axe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.axePorkite), "xx", "xy", " y", 'x', po, 'y', st);

		LanguageRegistry.addName(axeChickenium, "Chickenium Axe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.axeChickenium), "xx", "xy", " y", 'x', ch, 'y', st);

		LanguageRegistry.addName(axeSteakite, "Steakite Axe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.axeSteakite), "xx", "xy", " y", 'x', ste, 'y', st);

		LanguageRegistry.addName(axeWoolidium, "Woolidium Axe");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.axeWoolidium), "xx", "xy", " y", 'x', wo, 'y', st);

		LanguageRegistry.addName(swordPorkite, "Porkite Sword");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.swordPorkite), "x", "x", "y", 'x', po, 'y', st);

		LanguageRegistry.addName(swordChickenium, "Chickenium Sword");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.swordChickenium), "x", "x", "y", 'x', ch, 'y', st);

		LanguageRegistry.addName(swordSteakite, "Steakite Sword");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.swordSteakite), "x", "x", "y", 'x', ste, 'y', st);

		LanguageRegistry.addName(swordWoolidium, "Woolidium Sword");
		GameRegistry.addShapedRecipe(new ItemStack(Orenimals.swordWoolidium), "x", "x", "y", 'x', wo, 'y', st);

		LanguageRegistry.addName(helmetPorkite, "Porkite Helmet");
		GameRegistry.addShapedRecipe(new ItemStack(helmetPorkite),"xxx","x x", 'x', po);

		LanguageRegistry.addName(chestplatePorkite, "Porkite Chestplate");
		GameRegistry.addShapedRecipe(new ItemStack(chestplatePorkite),"x x","xxx", "xxx", 'x', po);

		LanguageRegistry.addName(leggingsPorkite, "Porkite Leggings");
		GameRegistry.addShapedRecipe(new ItemStack(leggingsPorkite),"xxx","x x","x x", 'x', po);

		LanguageRegistry.addName(bootsPorkite, "Porkite Boots");
		GameRegistry.addShapedRecipe(new ItemStack(bootsPorkite),"x x","x x", 'x', po);

		LanguageRegistry.addName(orePorkite, "Porkite Ore");
		GameRegistry.registerBlock(orePorkite, "orePorkite");
		MinecraftForge.setBlockHarvestLevel(orePorkite, "pickaxe", 1);
		GameRegistry.addSmelting(Orenimals.orePorkite.blockID, new ItemStack(Orenimals.ingotPorkite), 0.5f);

		LanguageRegistry.addName(oreChickenium, "Chickenium Ore");
		GameRegistry.registerBlock(oreChickenium, "oreChickenium");
		MinecraftForge.setBlockHarvestLevel(oreChickenium, "pickaxe", 1);
		GameRegistry.addSmelting(Orenimals.oreChickenium.blockID, new ItemStack(Orenimals.ingotChickenium), 0.5f);

		LanguageRegistry.addName(oreSteakite, "Steakite Ore");
		GameRegistry.registerBlock(oreSteakite, "oreSteakite");
		MinecraftForge.setBlockHarvestLevel(oreSteakite, "pickaxe", 1);
		GameRegistry.addSmelting(Orenimals.oreSteakite.blockID, new ItemStack(Orenimals.ingotSteakite), 0.5f);

		LanguageRegistry.addName(oreWoolidium, "Woolidium Ore");
		GameRegistry.registerBlock(oreWoolidium, "oreWoolidium");
		MinecraftForge.setBlockHarvestLevel(oreWoolidium, "pickaxe", 1);
		GameRegistry.addSmelting(Orenimals.oreWoolidium.blockID, new ItemStack(Orenimals.ingotWoolidium), 0.5f);

}

@EventHandler
public void load(FMLInitializationEvent event){
		proxy.registerRenderers();

}

@EventHandler
public void postInit(FMLPostInitializationEvent event){
}

}

 

My pickaxe class: (All of my tool classes are almost exactly the same as this one)

package drolive.orenimals;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;

public class OrenimalsPickaxe extends ItemPickaxe {

public OrenimalsPickaxe(int par1, EnumToolMaterial par2EnumToolMaterial, CreativeTabs tab, String name) {
	super(par1, par2EnumToolMaterial);
	setCreativeTab(tab);
	setUnlocalizedName(name);
}
}

 

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

    • 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 
    • When I came across the 'Exit Code: I got a 1 error in my Minecraft mods, so I decided to figure out what was wrong. First, I took a look at the logs. In the mods folder (usually where you'd find logs or crash reports), I found the latest.log file or the corresponding crash report. I read it through carefully, looking for any lines with errors or warnings. Then I checked the Minecraft Forge support site, where you can often find info on what causes errors and how to fix them. I then disabled half of my mods and tried running the game. If the error disappeared, it meant that the problem was with the disabled mod. I repeated this several times to find the problem mod.
  • Topics

×
×
  • Create New...

Important Information

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