Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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!

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));
	}
}

 

 

  • Author

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

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

  • Author

The item is registered under a name in the system. When this item exists can I pull it from there?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.