So I've been fiddling around with this and was wondering if someone could give me a hand.
I have a block and when this block is mined I would like it to drop more then 1 type of item. I've been snooping around the Minecraft source and so far haven't found anything to help.
At one point I was looking through ContainerWorkbench and found the code that drops items left on the crafting table and attempted to create a method using a similar method with no luck.
package net.minecraft.src;
import java.util.Random;
public class BlockTest extends Block
{
public BlockTest(int i, int j)
{
super(i,j,Material.ground);
}
public int idDropped(int i, Random random)
{
Test();
return mod_Test.Test.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
public void Test(EntityPlayer entityplayer)
{
entityplayer.dropPlayerItem(Item.coal);
entityplayer.dropPlayerItem(Item.stick);
}
}
I know pretty much why this won't work, but it was worth a try.
So any light someone can shed on this subject is greatly appreciated, even pointing me in the right direction would be awesome.
So I've been fiddling around with this and was wondering if someone could give me a hand.
I have a block and when this block is mined I would like it to drop more then 1 type of item. I've been snooping around the Minecraft source and so far haven't found anything to help.
At one point I was looking through ContainerWorkbench and found the code that drops items left on the crafting table and attempted to create a method using a similar method with no luck.
package net.minecraft.src;
import java.util.Random;
public class BlockTest extends Block
{
public BlockTest(int i, int j)
{
super(i,j,Material.ground);
}
public int idDropped(int i, Random random)
{
Test();
return mod_Test.Test.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
public void Test(EntityPlayer entityplayer)
{
entityplayer.dropPlayerItem(Item.coal);
entityplayer.dropPlayerItem(Item.stick);
}
}
I know pretty much why this won't work, but it was worth a try.
So any light someone can shed on this subject is greatly appreciated, even pointing me in the right direction would be awesome.
You're not passing your method 'entityplayer' for starters... You'll need to find a way to get the instance of the player so that you can pass it as a method argument.
Rollback Post to RevisionRollBack
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then. WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
You're not passing your method 'entityplayer' for starters... You'll need to find a way to get the instance of the player so that you can pass it as a method argument.
No I realized that, I merely provided that as proof that I've been attempting to figure it out myself. The method won't work because there isn't a way to pass the instance into the method without modifying a bunch of files.
I've been looking at the BlockCrops file because I know a fully grown crop yields a wheat and 2 seeds, but I'm not entirely sure what all of the code does within the method that executes that action.
public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f)
{
super.dropBlockAsItemWithChance(world, i, j, k, l, f);
if(world.multiplayerWorld)
{
return;
}
for(int i1 = 0; i1 < 3; i1++)
{
if(world.rand.nextInt(15) <= l)
{
float f1 = 0.7F;
float f2 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F;
float f3 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F;
float f4 = world.rand.nextFloat() * f1 + (1.0F - f1) * 0.5F;
EntityItem entityitem = new EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new ItemStack(Item.seeds));
entityitem.delayBeforeCanPickup = 10;
world.entityJoinedWorld(entityitem);
}
}
Would you mind posting how you did it? A lot of people have wanted this in the past
Don't worry I plan on making a tutorial once I understand 100% of it. I'll hopefully have it out in the next couple of days. That was the first thought in my head when I figured it out.
I have a block and when this block is mined I would like it to drop more then 1 type of item. I've been snooping around the Minecraft source and so far haven't found anything to help.
At one point I was looking through ContainerWorkbench and found the code that drops items left on the crafting table and attempted to create a method using a similar method with no luck.
I know pretty much why this won't work, but it was worth a try.
So any light someone can shed on this subject is greatly appreciated, even pointing me in the right direction would be awesome.
You're not passing your method 'entityplayer' for starters... You'll need to find a way to get the instance of the player so that you can pass it as a method argument.
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then.
WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
No I realized that, I merely provided that as proof that I've been attempting to figure it out myself. The method won't work because there isn't a way to pass the instance into the method without modifying a bunch of files.
I've been looking at the BlockCrops file because I know a fully grown crop yields a wheat and 2 seeds, but I'm not entirely sure what all of the code does within the method that executes that action.
This is from BlockCrop.java
Would you mind posting how you did it? A lot of people have wanted this in the past
Don't worry I plan on making a tutorial once I understand 100% of it. I'll hopefully have it out in the next couple of days. That was the first thought in my head when I figured it out.