Jump to content

Recommended Posts

Posted

Hi,

 

got a problem. I need to change the drops of a modded item. I know, I can access the HarvestDropsEvent event, so I can do something like this:

 

public void onHarvestDropsEvent(HarvestDropsEvent event)
{
	if(event.block.toString().contains("net.minecraft.block.BlockOldLog"))
	{
		event.drops.clear();
		event.drops.add(new ItemStack(Items.stick, random.nextInt(3)+1));
	}
}

 

When I break wood, I get a few sticks instead of the wood logs. That works! But now I want to drop a modded item. How can I spawn it when I only got the name of it and not the actual class? Thank you!

Posted

don't check against the string, check against the Item class,

 

public void onHarvestDropsEvent(HarvestDropsEvent event)
{
	if(event.state.getBlock() == Blocks.log)
	{
		event.drops.clear();
		event.drops.add(new ItemStack(Items.stick, random.nextInt(3)+1));
	}
}

 

same idea for your own modded item, make sure you have a public static variable to your item such as

 

public static Item sharpstick = new SharpStick(); (where the class SharpStick extends Item)

 

then you add it using your main Mod class

 

public void onHarvestDropsEvent(HarvestDropsEvent event)
{
	if(event.state.getBlock() == Blocks.log)
	{
		event.drops.clear();
		event.drops.add(new ItemStack(Items.stick, random.nextInt(3)+1));
                        event.drops.add(new ItemStack(ModClass.sharpstick, random.nextInt(3)+1));
	}
}

 

 

Posted

Thank you! But for that I need to include the modded class. I want to find a way around this.

 

little confused about what you mean... if you want to drop a mod item, then the mod has to be included, you cant drop something that doesn't exist

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.