Posted June 28, 201510 yr 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 Intel(R) Core(TM) i7-8700K 32GB DDR4 2400MHz NVIDIA GeForce RTX 2080 8GB
June 28, 201510 yr Creating is an event now. 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.
June 28, 201510 yr "item == new ItemStack(Items.baked_potato)" I think this is wrong... (because nothing will ever be == to it.)
June 28, 201510 yr Author 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? ) Intel(R) Core(TM) i7-8700K 32GB DDR4 2400MHz NVIDIA GeForce RTX 2080 8GB
June 28, 201510 yr Author 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. Intel(R) Core(TM) i7-8700K 32GB DDR4 2400MHz NVIDIA GeForce RTX 2080 8GB
June 28, 201510 yr Author 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. Intel(R) Core(TM) i7-8700K 32GB DDR4 2400MHz NVIDIA GeForce RTX 2080 8GB
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.