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

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

  • Author

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

  • Author

Got it working and it works great! Just a matter of using the event.harvester.getHeldItem to adjust the drop rates in my eventhandler. I'll post my working code for anybody who wants to know.

 

Thanks again!

 

 

 

Maker of the WIP mod: AdvanceCraft

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.