Oh damn, my bad sorry but couldnt you look at the redstone and lapiz blocks original code?
they do drop 3-6 items when they are broken so you probally could use the same logic?
edit:
Hmm it only works if you are going to drop more of the same ID
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return Item.redstone.shiftedIndex;
}
/**
* Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
*/
public int quantityDroppedWithBonus(int par1, Random par2Random)
{
return this.quantityDropped(par2Random) + par2Random.nextInt(par1 + 1);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random)
{
return 4 + par1Random.nextInt(2);
}
Oh damn, my bad sorry but couldnt you look at the redstone and lapiz blocks original code?
they do drop 3-6 items when they are broken so you probally could use the same logic?
edit:
Hmm it only works if you are going to drop more of the same ID
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return Item.redstone.shiftedIndex;
}
/**
* Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
*/
public int quantityDroppedWithBonus(int par1, Random par2Random)
{
return this.quantityDropped(par2Random) + par2Random.nextInt(par1 + 1);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random)
{
return 4 + par1Random.nextInt(2);
}
Yeah. I'm not sure if there's any easy way to do this.
Rollback Post to RevisionRollBack
I've been working on a Warcraft mod an incredibly long time. Just you wait, people.
Come to think of it, are you using forge when you are modding?
beacuse these are all modloader hooks, but forge adds a good amount of new hooks to play with, to amke life easier and avoid baseclass editing etc. I wouldn't be surprised if forge has methods for doing this
Wrote a quick one
Need to test though, modify to your needings,
replace "youritem" with the different Items you want to drop ^^
public int idDropped(int par1, Random par2Random, int par3)
{
int w = par2Random.nextInt(6);
if (w == 0)
{
return youritem;
}
if (w == 1)
{
return youritem;
}
if (w == 2)
{
return youritem;
}
if (w == 3)
{
return youritem;
}
if (w == 4)
{
return youritem;
}
else
{
return youritem;
}
}
public int quantityDroppedWithBonus(int par1, Random par2Random)
{
return quantityDropped(par2Random) + par2Random.nextInt(par1 + 1);
}
public int quantityDropped(Random par1Random)
{
return 6 + par1Random.nextInt(2); //replace 6 to a higher number if you want to drop more
}
ya this work for me. On this example, the block drop 1-3 wood and 1-3 stick.
/**
* Drops 1 to 3 itens.
*/
@Override
public int quantityDropped(Random par1Random){
return nextRandom(3)+1;
}
@Override
public int idDropped(int par1, Random par2Random, int par3){
switch (nextRandom(3)) {
case 0: case 1:
return Block.wood.blockID;
default:
return Item.stick.shiftedIndex;
}
}
@Override
public int quantityDroppedWithBonus(int par1, Random par2Random){
return quantityDropped(par2Random) + nextRandom(par1 + 1);
}
The " nextRandom " is a function that return rand.nextInt(size), i dont like to use Minecraft random.
hi guys I recently created an account here and noticed this topic was what had troubled me in making my mod.
First, I debugged the program and found out that the idDropped method is used by Block's method dropBlockAsItemWithChance.
So I overrode dropBlockAsItemWithChance in my custom block class and edited it:
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
{
if (!par1World.isRemote)
{
int var8 = this.quantityDroppedWithBonus(par7, par1World.rand);
for (int var9 = 0; var9 < var8; ++var9)
{
if (par1World.rand.nextFloat() <= par6)
{
int var10 = this.idDropped(par5, par1World.rand, par7);
int var11 = 262;
if(dropArrows) {
this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(var10, 1, this.damageDropped(par5)));
this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(var11, 64, this.damageDropped(par5)));
dropArrows = false;
} else {
if (var10 > 0) {
this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(var10, 1, this.damageDropped(par5)));
}
}
}
}
}
}
I made the method call dropBlockAsItem_do twice if dropArrows was set to true.
I tested this and it works perfectly.
I hope this helped you!
I have a video of my mod below that demonstrates the code above at this link:
This is the quickest and easiest way to do this. In your Blocks class add this method.
public int idDropped(int i, Random random, int j)
{
return Item.appleGold.itemID & Item.arrow.itemID & Item.bakedPotato.itemID;
}
As you can see this will make the block drop a gold apple, an arrow and a backed potato. As you can see you need to add this & Item.youritemhere.itemID you can make that whatever. For more swords it would be MSMItems.blazeSword.itemID
ya this work for me. On this example, the block drop 1-3 wood and 1-3 stick.
/**
* Drops 1 to 3 itens.
*/
@Override
public int quantityDropped(Random par1Random){
return nextRandom(3)+1;
}
@Override
public int idDropped(int par1, Random par2Random, int par3){
switch (nextRandom(3)) {
case 0: case 1:
return Block.wood.blockID;
default:
return Item.stick.shiftedIndex;
}
}
@Override
public int quantityDroppedWithBonus(int par1, Random par2Random){
return quantityDropped(par2Random) + nextRandom(par1 + 1);
}
The " nextRandom " is a function that return rand.nextInt(size), i dont like to use Minecraft random.
Thankyou for digging up an old post. Try not to do it again.
I copied the code and got an Iron Shovel. I removed some arrows and also got an Iron Shovel.
Seriously guys, this post is quite old. It's great you are using the search feature, but start your own posts about your problems rather than digging up posts months (years!) old.
On top of that, make sure any advice you give actually works - that code is ridiculous.
I have:
And just need to add a few more items.
Any help is appreciated.
or do you want it to sometimes drop one item and other times the other?
or do you want it to be like the zombies. always dropping rotten flesh, but sometimes it can drop a rare item like iron equipment?
I know how to generate randoms, etc. I'm not a Java noob,so to speak. I'm just not quite sure how this works. I want it to drop about five items.
Hmm I believe I saw doing this on a tube tutorial,
I may be mistaken but I believe he added multiple drops here.
Thankyou very much
I'll go check it out.
EDIT: That tutorial is for mobs. I need one for blocks.
they do drop 3-6 items when they are broken so you probally could use the same logic?
edit:
Hmm it only works if you are going to drop more of the same ID
Yeah. I'm not sure if there's any easy way to do this.
beacuse these are all modloader hooks, but forge adds a good amount of new hooks to play with, to amke life easier and avoid baseclass editing etc. I wouldn't be surprised if forge has methods for doing this
http://www.minecraftforum.net/topic/1142517-125more-tools-and-weapons/
Ah true... that would work
Need to test though, modify to your needings,
replace "youritem" with the different Items you want to drop ^^
First, I debugged the program and found out that the idDropped method is used by Block's method dropBlockAsItemWithChance.
So I overrode dropBlockAsItemWithChance in my custom block class and edited it:
I made the method call dropBlockAsItem_do twice if dropArrows was set to true.
I tested this and it works perfectly.
I hope this helped you!
I have a video of my mod below that demonstrates the code above at this link:
As you can see this will make the block drop a gold apple, an arrow and a backed potato. As you can see you need to add this & Item.youritemhere.itemID you can make that whatever. For more swords it would be MSMItems.blazeSword.itemID
Thankyou for digging up an old post. Try not to do it again.
Farewell everyone o/
Yes:
Seriously guys, this post is quite old. It's great you are using the search feature, but start your own posts about your problems rather than digging up posts months (years!) old.
On top of that, make sure any advice you give actually works - that code is ridiculous.