Jump to content

[1.8] Item and block drops - leaves [[Solved]]


PSmithgamer

Recommended Posts

I'm currently making a leaf block for my tree - but so far when ever the leaf block is broken it drops both the block and the mango so I need it to only drop the mango if its broken by hand and only the leaf if its broken by shears!

 

Second thing, if anyone knows how I can make the leaves decay like a on a normal tree that will be fantastic.

I'm sorry if this is something simple, I'm still learning Java and Forge.

 

(code is in my event handler class)

 

@SubscribeEvent

public void checkLeave(BlockEvent.HarvestDropsEvent event)

{

  if(event.state.getBlock() == AlkiaBlocks.mango_leaves)

  {

  event.drops.remove(AlkiaBlocks.mango_leaves);

  event.drops.add(new ItemStack(AlkiaItems.Mango));

  }

}

 

Link to comment
Share on other sites

Override the method getItemDropped in the block class

I'm such a noob to ask this but how would one do this? I've had an attempt and so far it say it doesn't want the @Override >:/

 

package com.PSmithgamer.Alkia.blocks;

 

import java.util.Random;

import java.lang.Override;

 

import com.PSmithgamer.Alkia.init.AlkiaItems;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

public class mango_leaves extends Block{

 

public mango_leaves(Material materialIn) {

super(materialIn);

this.setStepSound(soundTypeGrass);

this.setHardness(1);

this.setHarvestLevel("shears", 3);

this.getItemDropped();

}

        //@Override

public Item getItemDropped() {

return AlkiaItems.Mango;

}

 

}

 

Link to comment
Share on other sites

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.