Posted October 7, 20159 yr 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
October 7, 20159 yr do you mean it drops a seed and itself when broken, and then when placed will only drop itself?
October 7, 20159 yr 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
October 7, 20159 yr Author no, I want that every crop drops only one seed when harvested. As they do when they are in AGE 0-6
October 7, 20159 yr 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.
October 7, 20159 yr 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.
October 7, 20159 yr 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.
October 7, 20159 yr Author ok, thanks for the answer. Never worked with events before, but it seems that this will be my next topic to learn.
October 8, 20159 yr events is how you change player / world interaction, I think it is the most important part of modding.
October 8, 20159 yr 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.
October 8, 20159 yr 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; }
October 8, 20159 yr 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.
October 8, 20159 yr Author I only mean that when i click on the [insert code] button in the text editor of this forum, nothing changes...
October 8, 20159 yr 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.