Résolu Supprimer le craft d'un autre mod
-
Bonjour alors voila je voudrais supprimer des craft d’un autre mod dont je n’ai pas les sources, en gros supprimer des craft du mod IronChest en 1.7.10 seulement sur le github il n’y a pas de branche 1.7.10 je voulais savoir comment faire pour récuperer la recette et l’annuler.
Supprimer un craft je sais faire je bloc ici :removeRecipe(new ItemStack(???));
Je ne sais pas quoi mettre dans mon ItemStack.
-
Là ça supprime TOUS les crafts du mod ironchest (plus précisément : tous les crafts qui ont pour résultat un objet du mod ironchest), si tu ne veux en supprimer que quelques-uns sans connaitre les noms des objets, ça va être compliqué
Iterator <irecipe>it = CraftingManager.getInstance().getRecipeList().iterator(); while(it.hasNext()) { IRecipe recipe = it.next(); UniqueIdentifier uid = GameRegistry.findUniqueIdentifierFor(recipe.getRecipeOutput().getItem()); if(uid.modId.equalsIgnoreCase("ironchest")) { it.remove(); } } ```</irecipe>
-
je peux connaitre les noms en ouvrant avec JavaDecompiler
-
Tu n’as qu’à modifier la condition :
List <integer>metadatas = Arrays.asList(1); /** * Metadatas : * 0.Iron, 1.GOLD, 2.DIAMOND, 3.COPPER, 4.SILVER, 5.CRYSTAL, 6.OBSIDIAN, 7.DIRTCHEST9000, 8.WOOD * – il me semble que c'est ça -- */ Iterator <irecipe>it = CraftingManager.getInstance().getRecipeList().iterator(); while(it.hasNext()) { IRecipe recipe = it.next(); int metadata = recipe.getRecipeOutput().getItemDamage(); UniqueIdentifier uid = GameRegistry.findUniqueIdentifierFor(recipe.getRecipeOutput().getItem()); if(uid.modId.equalsIgnoreCase("ironchest") && uid.name.equalsIgnoreCase("blockironchest") && metadatas.contains(metadata)) { it.remove(); } } ```</irecipe></integer>
-
Salut,
Autre solution :removeRecipe(GameRegistry.findItemStack("modid", "nom de l'item ou du bloc"));
-
J’ai testé avec la solution de Robin et j’ai un crash:
:::
–-- Minecraft Crash Report ----
// There are four lights!Time: 26/12/16 18:05
Description: Initializing gamejava.lang.NullPointerException: Initializing game
at com.degraduck.atlantidecraft.craft.RemoveRecipe.removeRecipe(RemoveRecipe.java:27)
at com.degraduck.atlantidecraft.craft.RemoveRecipe.init(RemoveRecipe.java:16)
at com.degraduck.atlantidecraft.core.AtlantideCraft.init(AtlantideCraft.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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:212)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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:119)
at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:552)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:878)
at net.minecraft.client.main.Main.main(SourceFile:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)A detailed walkthrough of the error, its code path and all known details is as follows:
– Head –
Stacktrace:
at com.degraduck.atlantidecraft.craft.RemoveRecipe.removeRecipe(RemoveRecipe.java:27)
at com.degraduck.atlantidecraft.craft.RemoveRecipe.init(RemoveRecipe.java:16)
at com.degraduck.atlantidecraft.core.AtlantideCraft.init(AtlantideCraft.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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:212)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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:119)
at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:552)– Initialization –
Details:
Stacktrace:
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:878)
at net.minecraft.client.main.Main.main(SourceFile:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)– System Details –
Details:
Minecraft Version: 1.7.10
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_25, Oracle Corporation
Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 115954304 bytes (110 MB) / 312717312 bytes (298 MB) up to 5355339776 bytes (5107 MB)
JVM Flags: 6 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx5G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M
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.99.99 Minecraft Forge 10.13.4.1558 5 mods loaded, 5 mods active
States: ‘U’ = Unloaded ‘L’ = Loaded ‘C’ = Constructed ‘H’ = Pre-initialized ‘I’ = Initialized ‘J’ = Post-initialized ‘A’ = Available ‘D’ = Disabled ‘E’ = Errored
UCHI mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCHI FML{7.10.99.99} [Forge Mod Loader] (forge-1.7.10-10.13.4.1558-1.7.10.jar)
UCHI Forge{10.13.4.1558} [Minecraft Forge] (forge-1.7.10-10.13.4.1558-1.7.10.jar)
UCHI IronChest{6.0.62.742} [Iron Chest] (ironchest-1.7.10-6.0.62.742-universal.jar)
UCHE atlantidecraft{Beta 1.0.0} [Atlantide Craft] (modid-1.0.jar)
GL info: ’ Vendor: ‘Intel’ Version: ‘4.4.0 - Build 20.19.15.4300’ Renderer: ‘Intel HD Graphics 530’
Launched Version: 1.7.10-Forge10.13.4.1558-1.7.10
LWJGL: 2.9.1
OpenGL: Intel HD Graphics 530 GL version 4.4.0 - Build 20.19.15.4300, Intel
GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.Is Modded: Definitely; Client brand changed to ‘fml,forge’
Type: Client (map_client.txt)
Resource Packs: [Jea’s faithful64x_v.1.4.zip, Jea’alternate stonebrick.zip, Jea’BrightGrass.zip, Jea’BrightWater.zip, Jea’detailed cobble.zip]
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Anisotropic Filtering: Off (1)
:::Mon code:
removeRecipe(GameRegistry.findItemStack("IronChest", "ironchest:CRYSTAL", 0));
-
NullPointerException donc il n’a pas trouvé l’item, donc ce n’est pas le bon nom.
Je pense que c’est plutôt comme ça :
removeRecipe(GameRegistry.findItemStack(“IronChest”, “BlockIronChest”, 5));
(modid -> https://github.com/cpw/ironchest/blob/master/src/main/java/cpw/mods/ironchest/IronChest.java#L35)
(nom du bloc dans le registre -> https://github.com/cpw/ironchest/blob/master/src/main/java/cpw/mods/ironchest/IronChest.java#L58)
(et le metadata je crois que c’est 5, à vérifier)Sinon pour éviter le crash si l’item n’est pas trouvé, tu peux faire comme ça :
ItemStack cystalChest = GameRegistry.findItemStack("IronChest", "BlockIronChest", 5); if(cystalChest != null) { removeRecipe(cystalChest ); } else { System.out.println("cystal chest not found !"); }
-
Le troisième argument c’est le stackSize par contre, donc la solution de robin devrait être bonne :
ItemStack stack = GameRegistry.findItemStack("IronChest", "BlockIronChest", 1); if(stack != null) { stack.setItemDamage(5); removeRecipe(stack); } else { // … }
-
Merci à vous deux, j’ai pas réussi avec le code de Robin je n’arrivais pas à récupérer le métadata avec :
removeRecipe(GameRegistry.findItemStack("IronChest", "BlockIronChest", 5));
j’ai testé:
removeRecipe(GameRegistry.findItemStack("IronChest", "BlockIronChest", 1, 5));
Comme on peut le faire pour une pomme en or par exemple:
removeRecipe(new ItemStack(Items.golden_apple, 1 ,1));
Mais le .findItemStack n’accepte pas le deuxième int qui corresponds au métadata il prend que le stackSize.
J’ai donc pris le code BrokenSwing et niquel .
Juste une petite précision le setDamageItem(5) permet de récupérer un métadata d’après ce que je vois? j’aurai pas cru dans ma tête setItemDamage c’était plus pour mettre des dommages….
-
Métadata == durabilité (en gros)
-
Ah d’accord merci