Jump to content

[1.9] On crafting events


Bloopers

Recommended Posts

I want to make it so that when you craft a bed, it will be given a special lore(AddInformation method I think.) but I'm not sure how. I researched crafting handlers and achievements but they are for old versions and none seem to work.

Link to comment
Share on other sites

PlayerEvent.ItemCraftedEvent

should work.

I created this class, but am I supposed to register it in my main file? If so, how?

 

package bloopers.novelties.handlers;

import net.minecraft.item.ItemBed;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;

public class EventItemCrafted 
{
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event)
{
	ItemStack stack = event.crafting;
	NBTTagCompound nbt = stack.getTagCompound();

	if (stack.getItem() instanceof ItemBed)
	{
		stack.setTagInfo("Test", null);
	}
}
}

Link to comment
Share on other sites

I am sorry, but my magic remote code-viewing device is currently broken. You will have to post what you attempted manually.

 

He means that we need code you say you tried to use to register events for us to be able to fix it for ya.

No code = can't help.

 

Proper way:

MinecraftForge.EVENT_BUS.register(new EventClass());

 

Also - I am not sure if NBT accepts null values, maybe that was keys tho...

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

I am sorry, but my magic remote code-viewing device is currently broken. You will have to post what you attempted manually.

 

He means that we need code you say you tried to use to register events for us to be able to fix it for ya.

No code = can't help.

 

Proper way:

MinecraftForge.EVENT_BUS.register(new EventClass());

 

Also - I am not sure if NBT accepts null values, maybe that was keys tho...

1.7.10 is no longer supported by forge, you are on your own.

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.



×
×
  • Create New...

Important Information

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