PlayPrey Posted June 28, 2015 Share Posted June 28, 2015 Hello, this is something I could do fine (3 years ago)... Now I returned and see that this is completely diffrent. How do I check if the player has smelted or crafted an item? I tried: public class CraftingHandler (Usually I could implement CraftingHandler, however its now gone??? ) { @SubscribeEvent public void onSmelt(EntityPlayer player, ItemStack item) { if (item == new ItemStack(Items.baked_potato)) { player.addStat(AE.bakePotato, 1); } } } I am sorry for all the stupid questions, but it has been a long time since I modded Minecraft, I lost almost all the knowledge I had Quote Intel(R) Core(TM) i7-8700K 32GB DDR4 2400MHz NVIDIA GeForce RTX 2080 8GB Link to comment Share on other sites More sharing options...
Draco18s Posted June 28, 2015 Share Posted June 28, 2015 Creating is an event now. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
iame6162013 Posted June 28, 2015 Share Posted June 28, 2015 "item == new ItemStack(Items.baked_potato)" I think this is wrong... (because nothing will ever be == to it.) Quote Link to comment Share on other sites More sharing options...
PlayPrey Posted June 28, 2015 Author Share Posted June 28, 2015 Hmm, just noticed that some code didnt get pasted. So I got; @SubscribeEvent public void onSmelt(PlayerEvent.ItemSmeltedEvent e) { EntityPlayer player = (EntityPlayer) e.player; player.addChatMessage(new ChatComponentText("TYETJOASD")); if (e.smelting.equals(Items.baked_potato)) { player.addStat(AE.bakePotato 1); } } But the achievement is still not unlocking, neither am I getting the chat message. What am I missing here? (Also; I do know basic Java, but it has been 3 years since I programmed with Java, so things go about slowly. Also; Forge was diffrent back then.. Very diffrent , Nothing of my old code was usable.. ) So I am sorry for the stupid questions; I really am. But how do I compare with the event, and an Item? (Also x2: I know what == does, it compares 2 values to see if theyre the same... right? ) Quote Intel(R) Core(TM) i7-8700K 32GB DDR4 2400MHz NVIDIA GeForce RTX 2080 8GB Link to comment Share on other sites More sharing options...
PlayPrey Posted June 28, 2015 Author Share Posted June 28, 2015 Hehe sorry; Dont know why I tried equals. Here's the up to date code: (Not including the proxy classes) Main.java http://pastebin.com/9PCZ05hS CraftingHandler.java http://pastebin.com/qz4RKLx7 Additional notes; -Yes the achievement is being registered. -The other handler's (found in main.java) work fine for what I use them for. Quote Intel(R) Core(TM) i7-8700K 32GB DDR4 2400MHz NVIDIA GeForce RTX 2080 8GB Link to comment Share on other sites More sharing options...
PlayPrey Posted June 28, 2015 Author Share Posted June 28, 2015 Thank you! The game now gives the achievement and outputs the text! Just wondering though, why does the message appear at a random amount? Sometimes I get the message 4 times, sometimes 2, others 5 and so on... If I were to try and count the amount of times something has been smelted, I would get a completely wrong resoult. (int bakedPotatos; (inside method) bakedPotatos += 1; ) If I did that It would get more than just one. Quote Intel(R) Core(TM) i7-8700K 32GB DDR4 2400MHz NVIDIA GeForce RTX 2080 8GB Link to comment Share on other sites More sharing options...
Recommended Posts
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.