Posted March 1, 20178 yr Hello Everyone, I have been working on a small mod lately but ran into a problem, I can not seem to give my achievement to the player. What the problem is in details: I want to give the player an achievement when they craft a specific item. I got it to the point where everything works except giving the player the achievement, and it does work when I use a vanilla achievement. What I do know: The Achievement is displayed on the achievement page. The code to trigger the achievement is supposed to work, I have have it output a line into the console which triggers and when I change it to a vanilla achievement it works. Main Class Spoiler @Mod(modid = Reference.MODID, name = Reference.NAME, useMetadata = Reference.USEMETA) public class OmniTools { @SidedProxy(serverSide = Reference.COMMONPROXY, clientSide = Reference.CLIENTPROXY) public static CommonProxy proxy; @Instance public static OmniTools instance; public static Logger logger; @EventHandler public void preInit(FMLPreInitializationEvent event){ logger = event.getModLog(); proxy.preInit(event); AchievementInit.Achievements(); } @EventHandler public void init(FMLInitializationEvent event){ proxy.init(event); RecipeManager.registerRecipes(); //AchievementInit.Achievements(); FMLCommonHandler.instance().bus().register(new CraftingHandler()); } @EventHandler public void postInit(FMLPostInitializationEvent event){ proxy.postInit(event); } } Achievement Init Spoiler package com.jebbuh.omnitools.init; import net.minecraft.stats.Achievement; import net.minecraft.stats.AchievementList; public class AchievementInit { public static Achievement BUILD_WOOD_OMNITOOL; public static Achievement BUILD_STONE_OMNITOOL; public static Achievement BUILD_IRON_OMNITOOL; public static Achievement BUILD_DIAMOND_OMNITOOL; public static void Achievements(){ Achievement BUILD_WOOD_OMNITOOL = new Achievement("achievement.buildWoodOmnitool", "buildWoodOmnitool", 3, 2, OmniItems.woodOmnitool, AchievementList.OPEN_INVENTORY).registerStat(); AchievementList.ACHIEVEMENTS.add(BUILD_WOOD_OMNITOOL); Achievement BUILD_STONE_OMNITOOL = new Achievement("achievement.buildStoneOmnitool", "buildStoneOmnitool", 8, 2, OmniItems.stoneOmnitool, AchievementList.BUILD_BETTER_PICKAXE); AchievementList.ACHIEVEMENTS.add(BUILD_STONE_OMNITOOL); Achievement BUILD_IRON_OMNITOOL = new Achievement("achievement.buildIronOmnitool", "buildIronOmnitool", 0, 3, OmniItems.ironOmnitool, AchievementList.ACQUIRE_IRON); AchievementList.ACHIEVEMENTS.add(BUILD_IRON_OMNITOOL); Achievement BUILD_DIAMOND_OMNITOOL = new Achievement("achievement.buildDiamondOmnitool", "buildDiamondOmnitool", -3, 2, OmniItems.diamondOmnitool, AchievementList.DIAMONDS).setSpecial(); AchievementList.ACHIEVEMENTS.add(BUILD_DIAMOND_OMNITOOL); } } Crafting Handler Spoiler package com.jebbuh.omnitools.handlers; import com.jebbuh.omnitools.init.AchievementInit; import com.jebbuh.omnitools.init.OmniItems; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import net.minecraft.stats.AchievementList; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; public class CraftingHandler { @SubscribeEvent public void itemCraftEvent(ItemCraftedEvent e){ if(e.crafting.getItem().equals((Item)OmniItems.woodOmnitool)){ e.player.addStat(AchievementInit.BUILD_WOOD_OMNITOOL); System.out.println("crafted"); } } } Any help is really appreciated! Edited March 1, 20178 yr by Jebbuh
March 1, 20178 yr Author 1 hour ago, diesieben07 said: Don't manually add things into the AchievementList. Oops, I removed that and just added .registerStat() at the end. But this does not fix the issue
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.