Jump to content

[Almost Solved][1.8] Detect Player Using Furnace or Craft's an item


PlayPrey

Recommended Posts

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 :P

 

Intel(R) Core(TM) i7-8700K

32GB DDR4 2400MHz 

NVIDIA GeForce RTX 2080 8GB

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :P , Nothing of my old code was usable.. :P )

 

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.