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

Hello everyone,

 

I am trying to create a plant that only drops the seed once, not multiplied, what do I have to override to do so?

 

Thanks for the answer,

 

Kaneka

  • Author

I mean it should only drop the seed, the plant reproduces itself by placing itself on the next block. And if you harvest the Block, you should only get one seed, you should not reproduce it by getting more than 1 seed from harvesting the crop

  • Author

no, I want that every crop drops only one seed when harvested. As they do when they are in AGE 0-6

  • Author

I think you don´t understand me, this plant class extends BlockCrops, and yes, they drop seeds, but to much, I only want them to drop one, not more.

It doesn´t matter on which AGE they are, they should drop only one seed.

 

ohhh ok I THINK this is what you are after. you want to subscribe to HarvestDropsEvent. then clear the drops, then add the seed back in with the quantity of 1.

 

of cause checking that the block harvested is the correct block you want to change etc etc.

try something like this....

 

@SubscribeEvent
public void onHarvestEvent(HarvestDropsEvent event) {

	if (event.state.getBlock() == Blocks.wheat) {
		event.drops.clear();
		event.drops.add(new ItemStack(Items.wheat_seeds, 1, 1));
	}
}

 

haven't tested yet but should be close to what you want.

  • Author

ok, thanks for the answer. Never worked with events before, but it seems that this will be my next topic to learn.

If you have your own custom crop block, you do not need events.  Events is how you affect other mod's blocks (and in some cases, vanilla blocks).

 

If you have your own block all you have to do is override the function getDrops* and not call super() and then only add the items you want to add.

 

*Double check which function creates the seed stacks in BlockCrops, that's the one you want.

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.

  • Author

Thanks for the support, here the working code:

 

(can´t insert the code background, don´t know why...)

 

@Override

    public java.util.List<ItemStack> getDrops(net.minecraft.world.IBlockAccess world, BlockPos pos, IBlockState state, int fortune)

    {

        java.util.List<ItemStack> ret = super.getDrops(world, pos, state, fortune);

        ret.clear();

        ret.add(new ItemStack(this.getSeed(), 1, 0));

        return ret;

    }

you want to put the imports above all your functions such as

 

import java.util.List;

import net.minecraft.world.IBlockAccess

 

@Override

public void someFunction(theEvent e) { }

 

note, this is only if you create the item class yourself and you want to override the super class.

  • Author

I only mean that when i click on the [insert code] button in the text editor of this forum, nothing changes...

I only mean that when i click on the [insert code] button in the text editor of this forum, nothing changes...

 

yes, I was commenting on your code, can be tidied up a bit by doing that.

 

you can manually add code just by using the BB [ code] //your code here [ /code] without the space (I dont know how to escape BB code).

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.