Résolu Supprimer les crafts des armures de bases
-
Bonjour,
je commence depuis peu à modder avec Forge, j’ai fais un mod qui rajoute des armures à Minecraft.
Et séparément, j’aimerai faire un mod qui permet de supprimer les crafts de bases des armures de minecrafts pour qu’ils ne soient plus craftables et qu’ils soient seulement dans le créative.Mais je ne sais pas comment m’y prendre sans toucher aux fichiers originaux! J’ai cru voir une fois un post parlant de ça, mais impossible de retomber sur le lien! Je suppose que je dois faire un lien vers le craftingManager.java où là, je fais un null sur les crafts? :huh: :huh:
En espérant avoir une réponse claire
Cordialement,
RageAgain -
Salut,
Après une petite recherche :
http://www.minecraftforge.net/forum/index.php/topic,7146.msg58748.html#msg58748
Ou alors : https://github.com/FFMT/FFMT-libs/blob/master/common/fr/minecraftforgefrance/ffmtlibs/FFMTRegistry.java#L254 -
J’ai pas pensé à regarder chez les anglais…merci beaucoup! :)___Et où dois-je l’insérer?
En sachant que mon code de base ne ressemble que à ça pour l’instant :
package fr.anticraftarmor.common; 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 fr.anticraftarmor.proxy.CommonProxy; @Mod(modid = "anticraftarmor", name = "Anti Craft Armor", version = "1.0.0") public class AntiCraftArmor { @Instance("anticraftarmor") public static AntiCraftArmor instance; @SidedProxy(clientSide = "fr.anticraftarmor.proxy.ClientProxy", serverSide = "fr.anticraftarmor.proxy.CommonProxy") public static CommonProxy proxy; public static final String MODID = "anticraftarmor"; @EventHandler public void preInit(FMLPreInitializationEvent event){ } @EventHandler public void init(FMLInitializationEvent event){ proxy.RegisterRender(); } @EventHandler public void postInit(FMLPostInitializationEvent event){ } }
-
N’importe ou dans la classe, puis dans la fonction postInit tu appelle la fonction avec en argument l’item que tu veux retirer.
-
Non, en faites, le code que tu m’as donné, c’est pour enlever les recettes d’items, mais lorsque je met en paramètre, ca me dit qu’il faut que ca soit un ItemArmor…
-
Heu tu as fait quoi ?
Envoie ton code. -
package fr.anticraftarmor.common; import java.util.List; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.RecipesArmor; import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; 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.registry.GameRegistry; import fr.anticraftarmor.proxy.CommonProxy; @Mod(modid = "anticraftarmor", name = "Anti Craft Armor", version = "1.0.0") public class AntiCraftArmor { @Instance("anticraftarmor") public static AntiCraftArmor instance; @SidedProxy(clientSide = "fr.anticraftarmor.proxy.ClientProxy", serverSide = "fr.anticraftarmor.proxy.CommonProxy") public static CommonProxy proxy; public static final String MODID = "anticraftarmor"; @EventHandler public void preInit(FMLPreInitializationEvent event){ } @EventHandler public void init(FMLInitializationEvent event){ proxy.RegisterRender(); } @EventHandler public void postInit(FMLPostInitializationEvent event){ removeRecipe(Items.leather_helmet); //Ici, erreur : The method removeRecipe(ItemStack) in the type AntiCraftArmor is not applicable for the arguments (ItemArmor) } public static void removeRecipe(ItemStack stack) { List <irecipe>recipeList = CraftingManager.getInstance().getRecipeList(); for(int i = 0; i < recipeList.size(); i++) { ItemStack output = recipeList.get(i).getRecipeOutput(); if(output != null && stack.getItem() == output.getItem() && stack.getItemDamage() == output.getItemDamage()) { recipeList.remove(i); FFMTLibs.ffmtLog.info("Removed recipe for : " + output.getItem().getUnlocalizedName(output)); //Ici, erreur aussi : FFMTLibs cannot be resolved } } } }
Voila…la je coince! :(</irecipe>
-
removeRecipe(new ItemStack(Items.leather_helmet));
-
Il y a toujours cette erreur là :
public static void removeRecipe(ItemStack stack) { List <irecipe>recipeList = CraftingManager.getInstance().getRecipeList(); for(int i = 0; i < recipeList.size(); i++) { ItemStack output = recipeList.get(i).getRecipeOutput(); if(output != null && stack.getItem() == output.getItem() && stack.getItemDamage() == output.getItemDamage()) { recipeList.remove(i); FFMTLibs.ffmtLog.info("Removed recipe for : " + output.getItem().getUnlocalizedName(output)); //Ici, erreur aussi : FFMTLibs cannot be resolved } } } ```</irecipe>
-
Mais en tout cas, merci beaucoup, c’est déjà une erreur en moins
-
J’ai rien dis! Il a suffit que je supprime cette ligne :
FFMTLibs.ffmtLog.info("Removed recipe for : " + output.getItem().getUnlocalizedName(output));
Et c’était réglé, c’était juste une info d’après ce que je comprend!
Le craft est enlevé! J’ai plus qu’a faire ca pour le reste des itemsT’es un vrai DIEU robin4002!
Merci beaucoup à toi! -
ENCORE UN PROBLEME =(
Au lancement de minecraft, celui-ci se crash après que j’ai rajouté mon petit AntiCraftArmor mod…Le log dans le spoiler !
:::
---- Minecraft Crash Report ----
// You should try our sister game, Minceraft!Time: 22/12/14 1:42
Description: There was a severe problem during mod loading that has caused the game to failcpw.mods.fml.common.LoaderException: java.lang.NoSuchFieldError: leather_helmet
at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)
at cpw.mods.fml.common.Loader.initializeMods(Loader.java:695)
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:288)
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:541)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:867)
at net.minecraft.client.main.Main.main(SourceFile:148)
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 net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.NoSuchFieldError: leather_helmet
at fr.anticraftarmor.common.AntiCraftArmor.postInit(AntiCraftArmor.java:52)
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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at cpw.mods.fml.common.Loader.initializeMods(Loader.java:694)
… 10 moreA detailed walkthrough of the error, its code path and all known details is as follows:
– System Details –
Details:
Minecraft Version: 1.7.10
Operating System: Windows 8.1 (x86) version 6.3
Java Version: 1.8.0_25, Oracle Corporation
Java VM Version: Java HotSpot Client VM (mixed mode), Oracle Corporation
Memory: 103540136 bytes (98 MB) / 272281600 bytes (259 MB) up to 518979584 bytes (494 MB)
JVM Flags: 2 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx512M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.85.1230 Minecraft Forge 10.13.2.1230 8 mods loaded, 8 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized
FML{7.10.85.1230} [Forge Mod Loader] (forge-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized
Forge{10.13.2.1230} [Minecraft Forge] (forge-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized
anticraftarmor{1.0.0} [Anti Craft Armor] (AntiCraftArmor.jar) Unloaded->Constructed->Pre-initialized->Initialized->Errored
ModName{1.0.0} [ModName] (equipement_1.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized
flansmod{4.8.0} [Flan’s Mod] (Flans Mod-1.7.10-4.8.0.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized
gvc{0.4.0} [Gliby’s Voice Chat Mod] (GlibysVC-1710_040.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized
mcheli{0.10.2} [MC Helicopter] (mcheli) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized:::
-
Si il faut, voila les codes de mon mod!
AntiCraftArmor.java
package fr.anticraftarmor.common; import java.util.List; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.RecipesArmor; import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; 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.registry.GameRegistry; import fr.anticraftarmor.proxy.CommonProxy; @Mod(modid = "anticraftarmor", name = "Anti Craft Armor", version = "1.0.0") public class AntiCraftArmor { @Instance("anticraftarmor") public static AntiCraftArmor instance; @SidedProxy(clientSide = "fr.anticraftarmor.proxy.ClientProxy", serverSide = "fr.anticraftarmor.proxy.CommonProxy") public static CommonProxy proxy; public static final String MODID = "anticraftarmor"; @EventHandler public void preInit(FMLPreInitializationEvent event){ } @EventHandler public void init(FMLInitializationEvent event){ proxy.RegisterRender(); } @EventHandler public void postInit(FMLPostInitializationEvent event){ //SUPPRESSION DES CRAFTS POUR LES ARMURES DE BASES //Leather Armor removeRecipes.removeRecipe(new ItemStack(Items.leather_helmet)); removeRecipes.removeRecipe(new ItemStack(Items.leather_chestplate)); removeRecipes.removeRecipe(new ItemStack(Items.leather_leggings)); removeRecipes.removeRecipe(new ItemStack(Items.leather_boots)); //Chainmail Armor removeRecipes.removeRecipe(new ItemStack(Items.chainmail_helmet)); removeRecipes.removeRecipe(new ItemStack(Items.chainmail_chestplate)); removeRecipes.removeRecipe(new ItemStack(Items.chainmail_leggings)); removeRecipes.removeRecipe(new ItemStack(Items.chainmail_boots)); //Iron Armor removeRecipes.removeRecipe(new ItemStack(Items.iron_helmet)); removeRecipes.removeRecipe(new ItemStack(Items.iron_chestplate)); removeRecipes.removeRecipe(new ItemStack(Items.iron_leggings)); removeRecipes.removeRecipe(new ItemStack(Items.iron_boots)); //Golden Armor removeRecipes.removeRecipe(new ItemStack(Items.golden_helmet)); removeRecipes.removeRecipe(new ItemStack(Items.golden_chestplate)); removeRecipes.removeRecipe(new ItemStack(Items.golden_leggings)); removeRecipes.removeRecipe(new ItemStack(Items.golden_boots)); //Diamond Armor removeRecipes.removeRecipe(new ItemStack(Items.diamond_helmet)); removeRecipes.removeRecipe(new ItemStack(Items.diamond_chestplate)); removeRecipes.removeRecipe(new ItemStack(Items.diamond_leggings)); removeRecipes.removeRecipe(new ItemStack(Items.diamond_boots)); } }
removeRecipes.java
package fr.anticraftarmor.common; import java.util.List; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; public class removeRecipes extends AntiCraftArmor{ public static void removeRecipe(ItemStack stack) { List <irecipe>recipeList = CraftingManager.getInstance().getRecipeList(); for(int i = 0; i < recipeList.size(); i++) { ItemStack output = recipeList.get(i).getRecipeOutput(); if(output != null && stack.getItem() == output.getItem() && stack.getItemDamage() == output.getItemDamage()) { recipeList.remove(i); } } } } ```</irecipe>
-
Tu as compilé comment ton mod ?
-
Déjà, les multi-posts d’affilé ne sont pas autorisés, il y a le bouton “Editer” qui est là. Ensuite, je te conseille fortement d’apprendre le Java et l’Anglais, parce que les erreurs sont en anglais.
-
@robin4002: J’ai sélectionné mes packages et je les ais exporté en un .jar !
@Superloup10: Excusez moi pour les multis post… D’accord pour l’anglais, mais le java, j’ai déjà fait des petites applications en console après avoir terminé le tutoriel sur le POO de openclassrooms, donc je crois avoir au moins les bases, mais j’ai beaucoup de mal en reprenant le codage de Minecraft et Forge… existe-t-il une javadoc?
-
Tu compile mal ton mod.
Il faut faire comme pour le setup de forge, sauf que la c’est :
gradlew build
Ensuite le jar du mod se trouve dans <dossier de=“” forge=“”>/build/libs/ et s’appelle par défaut modid-1.0.jar</dossier> -
Okay! Super!
merci beaucoup !