Jump to content

[Solved][1.7.10] Block Drops Dependent on Item Held


Fenrir_Felix

Recommended Posts

Okay, so I've been trying to get a block to drop a number of items depending on tool used to break it by making the quantityDropped method variable. More or less so that improved tools will drop more ore and whatnot:

 

 

 

package com.felix.advancecraft.block;

import java.util.Random;

import com.felix.advancecraft.ACCreativeTabs;
import com.felix.advancecraft.AdvanceCraft;
import com.felix.advancecraft.item.ACItems;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class BlockCopperOre extends Block {

private EntityPlayer player;

public BlockCopperOre(String name)
{
		super(Material.rock);

		setBlockName(AdvanceCraft.MODID + "_" + name);
		setBlockTextureName(AdvanceCraft.MODID + ":" + name);
		setCreativeTab(ACCreativeTabs.ACores);
		setHardness(3.0F);
		setResistance(15F);
		setStepSound(soundTypeStone);
		setHarvestLevel("pickaxe", 0);
}
public int quantityDropped(Random rand, int amt)
{
	{
		int drops = oreAmount(amt);

		return drops + rand.nextInt(2);
	}

}

public int oreAmount(int amount)
{


	ItemStack tool = player.getHeldItem();

	Item itool = tool.getItem();

	if(itool == ACItems.primitivepick) amount = 1;
	if(itool == ACItems.copper_pick)  amount = 2;
	if(itool == ACItems.bronze_pick) amount = 3;

	else
	{
		amount = 0;
	}

	return amount;
}

public Item getItemDropped(int meta, Random rand, int fortune)
{
	switch (rand.nextInt(3)) 
	{
	case 0: 

	case 1:

			return ACItems.copperchunk;

	default:

		return ACItems.coppershard;
	}

}

}

 

 

 

Currently this only makes it drop the default of 1 each time, as opposed to a variable amount dependent on the tool. Probably an easy fix, but I've been stuck on it for awhile now and can't seem to figure it out, any help is much appreciated as always!

Maker of the WIP mod: AdvanceCraft

Link to comment
Share on other sites

Haha I thought that might be the case, which makes perfect sense, this was just my first attempt. I'll give it a shot with the HarvestDropsEvent, I've added drops to vanilla blocks with it so I can probably figure it out with my own blocks. 

 

Also, that made me think of Ace Ventura. "You must be the Monopoly Guy"

 

Thanks again for your help!

Maker of the WIP mod: AdvanceCraft

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.