Jump to content

Recommended Posts

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

Posted

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

Posted

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.

 

Posted

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.

Posted

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.

Posted

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.

Posted

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;

    }

Posted

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.

Posted

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

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