Créer un achievement
-
Il te faut un CraftingHandler, pour ça.
-
Comment on fait si on veut également intégrer un metadata dans le test pour avoir l’achievement ?
-
Dans la condition tu ajoute && stack.getItemDamage() == le metadata
-
Suite à vos demande, j’ai ajouté plus d’event (CraftingHandler et PlayerTracker de FML, et quelques event de Forge) et comment faire une page d’achievement.
-
Possibilité de mettre un bloc custon pas moi sa me mets une erreur quand je mets BlockUranium :/___
–-- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 16/01/14 19:57 Description: Initializing game java.lang.NullPointerException at net.minecraft.item.ItemStack.<init>(ItemStack.java:66) at net.minecraft.item.ItemStack.<init>(ItemStack.java:61) at net.minecraft.stats.Achievement.<init>(Achievement.java:57) at bdbladx.common.eryliablocks.PreInit(eryliablocks.java:45) 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:540) 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:313) 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:194) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:174) 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:313) 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:105) at cpw.mods.fml.common.Loader.loadMods(Loader.java:520) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:181) at net.minecraft.client.Minecraft.startGame(Minecraft.java:471) at net.minecraft.client.Minecraft.run(Minecraft.java:806) at net.minecraft.client.main.Main.main(Main.java:93) 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:57) at net.minecraft.launchwrapper.Launch.main(Launch.java:18) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.item.ItemStack.<init>(ItemStack.java:66) at net.minecraft.item.ItemStack.<init>(ItemStack.java:61) at net.minecraft.stats.Achievement.<init>(Achievement.java:57) at bdbladx.common.eryliablocks.PreInit(eryliablocks.java:45) 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:540) 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:313) 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:194) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:174) 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:313) 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:105) at cpw.mods.fml.common.Loader.loadMods(Loader.java:520) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:181) at net.minecraft.client.Minecraft.startGame(Minecraft.java:471) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:806) at net.minecraft.client.main.Main.main(Main.java:93) 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:57) at net.minecraft.launchwrapper.Launch.main(Launch.java:18) -- System Details -- Details: Minecraft Version: 1.6.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_45, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 946048528 bytes (902 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M 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 v8.04 FML v6.2.62.871 Minecraft Forge 9.10.1.871 5 mods loaded, 5 mods active mcp{8.04} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized FML{6.2.62.871} [Forge Mod Loader] (bin) Unloaded->Constructed->Pre-initialized Forge{9.10.1.871} [Minecraft Forge] (bin) Unloaded->Constructed->Pre-initialized eryliablock{1.0.0} [Biralva by EryliaCoders] (bin) Unloaded->Constructed->Errored Erylia{1.0.0} [Erylia] (bin) Unloaded->Constructed->Pre-initialized Launched Version: 1.6 LWJGL: 2.9.0 OpenGL: AMD Radeon HD 7310 Graphics GL version 4.2.11399 Compatibility Profile Context, ATI Technologies Inc. Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Pack: Default Current Language: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: ~~ERROR~~ NullPointerException: null ```</init></init></init></init></init></init>
-
Oui c’est possible. Envoie ton erreur.
-
elle est juste au-dessus ^^’
-
Je dirais que tu as fait une faute sur la déclaration de ton ItemStack, vérifie le code et poste-le également ici qu’on puisse le voir.
Le crash log c’est bien mais sans la classe de ton mod qui plante personne ne peux te donner une explication claire
-
package bdbladx.common; import net.minecraft.block.Block; import net.minecraftforge.common.EnumHelper; import net.minecraftforge.common.MinecraftForge; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.stats.Achievement; import net.minecraft.stats.AchievementList; import bdbladx.proxy.PlayerRenderEvent; import bdbladx.proxy.eryliaCommonProxy; 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; @Mod(modid = "eryliablock", name = "Biralva by EryliaCoders", version = "1.0.0") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class eryliablocks { @SidedProxy(clientSide = "bdbladx.proxy.eryliaClientProxy", serverSide = "bdbladx.proxy.eryliaCommonProxy") public static eryliaCommonProxy proxy; public static Block BlockTutorial; public static Item ItemUranium; public Achievement achievementUraniumBrut; public static Block BlockUranium; public static Item CasqueUranium, PlastronUranium, JambieresUranium, BottesUranium; static EnumArmorMaterial ArmureUranium = EnumHelper.addArmorMaterial("Uranium", 20, new int[]{4, 16, 8, 4}, 15); @EventHandler public void PreInit(FMLPreInitializationEvent event) { //Achievements achievementUraniumBrut = new Achievement(1200, "UraniumBrut", -2, 0, BlockUranium.blockID, AchievementList.openInventory).registerAchievement(); //Blocks BlockTutorial = new BlockTutorial(2000).setHardness(1.0F).setResistance(5.0F).setStepSound(Block.soundGlassFootstep) .setUnlocalizedName("BlockTutorial").setLightValue(1.0F).setTextureName("eryliablock:BlockTutorial"); GameRegistry.registerBlock(BlockTutorial, "BlockTutorial"); BlockUranium = new BlockUranium(3000).setHardness(3.0F).setResistance(15.0F).setStepSound(Block.soundStoneFootstep) .setUnlocalizedName("BlockUranium").setTextureName("eryliablock:BlockUranium"); GameRegistry.registerBlock(BlockUranium, "Uranium"); //Items ItemUranium = new ItemUranium(1200).setUnlocalizedName("ItemUranium").setTextureName("eryliablock:Uranium2"); GameRegistry.registerItem(ItemUranium, "ItemUranium", "eryliablock"); CasqueUranium = new CasqueUranium(4000, ArmureUranium, 0, 0).setUnlocalizedName("CasqueUranium").setTextureName("eryliablock:Casque_Uranium"); GameRegistry.registerItem(CasqueUranium, "Casqueuranium", "eryliablock"); PlastronUranium = new PlastronUranium(4001, ArmureUranium, 0, 1).setUnlocalizedName("PlastronUranium").setTextureName("eryliablock:Plastron_Uranium"); GameRegistry.registerItem(PlastronUranium, "PlastronUranium", "eryliablock"); } @EventHandler public void Init(FMLInitializationEvent event) { //generation de mondes GameRegistry.registerWorldGenerator(new WorldGeneratorMineralis()); //capes if(event.getSide().isClient()) { MinecraftForge.EVENT_BUS.register(new PlayerRenderEvent()); } //recettes four GameRegistry.addSmelting(BlockUranium.blockID, new ItemStack(ItemUranium.itemID, 2, 0), 0.2f); //reccettes GameRegistry.addRecipe(new ItemStack(BlockTutorial), new Object[]{"XXX", "XYX", "XXX", 'X', Block.planks, 'Y', Block.glowStone}); proxy.registerRender(); } @EventHandler public void PostInit(FMLPostInitializationEvent event) { } }
voilà ma classe principale
Cherchez pas trop voici le code ou l’erreur apparait :
achievementUraniumBrut = new Achievement(1200, “UraniumBrut”, -2, 0, BlockUranium.blockID, AchievementList.openInventory).registerAchievement();___
Sachant que pour les recettes avec se font avec notrebloc.blockID je crois que à ce point je suis juste mais reste à voir si je ne dois pas faire eryliablocks.BlockUranium ( testé mais crash quand meme ) ^^’ -
@‘jglrxavpok’:
Votre méthode preInit devrait ressembler à ça :
@EventHandler public void PreInit(FMLPreInitializationEvent event) { // Configuration […] // Blocks […] // Enregistrement des blocs […] // Items […] // Enregistrement des items […] // Achievements achievementTuto = new Achievement(2100, "achievementTuto", -2, 0, Block.dirt, AchievementList.openInventory).registerAchievement(); achievementTuto2 = new Achievement(2101, "achievementTuto2", -1, 0, this.BlockTutorial, null).registerAchievement(); maPage = new AchievementPage("Nom de la page", achievementTuto, achievementTuto2); AchievementPage.registerAchievementPage(maPage); }
Les blocs est items doivent être initialisés avant les achievements (sinon NPE (= NullPointerException)), et la page après les achievements (pareil, si vous ne le faite pas dans cette ordre, craft avec NPE). Petit rappel, si en icône vous voulez mettre un bloc ou item de votre mod, il faudra utiliser this.nomDuBloc/Item et non Item. ou Block.
-
Salut je voudrais que en minant le bloc pour la 1ere fois que le joueur gagne 30 nv mais juste la premiere fois mais je ne sais pas comment faire
event.entityPlayer.addExperienceLevel(30);
-
Tu fais un Extended Entity Property, une boolean, qui fait que quand l’event “miner” se déclenche, la boolean est set a true, et ne peut plus être changé par des commandes. Ainsi, une fois miné, le joueur ne recevras plus jamais les niveau bonus, sauf si le fichier player est effacé. Tu peut faire une commande de reset, et les Extended Entity Property sont complètement compatibles en multijoueur, et donc très pratiques
-
Merci je test ça et je te dis quelque chose et aufait merci robin pour la reponse à mon probleme j’avais oublié
Hum juste une question je dois mettre ```java
boolean (je sais pas quoi mettre ici) = true -
Ou alors tu check juste si le joueur a déjà l’achievement ou pas, tout simplement.
-
oui robin ca me parait un peut plus simple xD mais comment faire ? :0 ( sachez que je retiens toutes les suggestions et je les teste toutes =D comme ça j’apprends plus )
-
Ah, mais c’est vrai que tu passe par un achievement ( J’suis con )
Dans ce cas, c’est surement .hasAchievement ou .getAchievement il me semble
-
je dois mettre ou ce code ?
-
if(!player.hasAchieved / je sais plus la méthode )){
code pour give les niveau
}
-
celui que j’avais mis au dessus ? ```java
event.entityPlayer.addExperienceLevel(30); -
Yes