Monstrous_Apple Posted May 22, 2016 Share Posted May 22, 2016 So I have this code which makes it so that my ores drop an item rather than themselves (like Diamond Ore does) but I can't get it to drop more with fortune, how would I make it so that they multiply with fortune like diamond ore does? package com.MonstrousApple.mod.gems; import java.util.Random; import com.MonstrousApple.mod.MAGlobal; import com.MonstrousApple.mod.items.MAItems; import com.MonstrousApple.mod.ores.MAOres; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Items; import net.minecraft.item.Item; public class MAGem extends Block { public MAGem(String unlocalizedName, Material material, float hardness, float resistance) { super(material); this.setCreativeTab(MAGlobal.maCreativeTabOres); this.setUnlocalizedName(unlocalizedName); this.setHardness(hardness); this.setResistance(resistance); } public Item getItemDropped(IBlockState state, Random rand, int fortune) { if (this == MAGems.SapphireOre) { return MAItems.Sapphire; } else if (this == MAGems.RubyOre) { return MAItems.Ruby; } else { return null; } } public int quantityDropped(Random random) { if (this == MAGems.SapphireOre) { return 4 + random.nextInt(5); } else if (this == MAGems.RubyOre) { return 4 + random.nextInt(5); } else { return 0; } } } Quote Link to comment Share on other sites More sharing options...
Choonster Posted May 22, 2016 Share Posted May 22, 2016 Override Block#quantityDropped(IBlockState, int, Random) instead of Block#quantityDropped(Random) , this gives you the fortune level. I would personally recommend having fields to store the dropped item and quantity rather than checking which instance this is, it makes your code more extendable. Side note: Always annotate override methods with @Override so you get a compiler error if they don't override a super method. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
Monstrous_Apple Posted May 22, 2016 Author Share Posted May 22, 2016 So like this? Or is there more to add? package com.MonstrousApple.mod.gems; import java.util.Random; import com.MonstrousApple.mod.MAGlobal; import com.MonstrousApple.mod.items.MAItems; import com.MonstrousApple.mod.ores.MAOres; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Items; import net.minecraft.item.Item; public class MAGem extends Block { public MAGem(String unlocalizedName, Material material, float hardness, float resistance) { super(material); this.setCreativeTab(MAGlobal.maCreativeTabOres); this.setUnlocalizedName(unlocalizedName); this.setHardness(hardness); this.setResistance(resistance); } @Override public Item getItemDropped(IBlockState state, Random random, int fortune) { if (this == MAGems.SapphireOre) { return MAItems.Sapphire; } else if (this == MAGems.RubyOre) { return MAItems.Ruby; } else if (this == MAGems.DiamondOre) { return Items.diamond; } else { return null; } } public int quantityDropped(IBlockState state, int fortune, Random random) { if (this == MAGems.SapphireOre) { return 4 + random.nextInt(5); } else if (this == MAGems.RubyOre) { return 4 + random.nextInt(5); } else { return 0; } } } Quote Link to comment Share on other sites More sharing options...
Choonster Posted May 22, 2016 Share Posted May 22, 2016 Your new code is doing exactly the same thing as your old code, you need to add the fortune bonus yourself. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
Monstrous_Apple Posted May 22, 2016 Author Share Posted May 22, 2016 Okay but I need it the exact same effect as on diamond ore? Quote Link to comment Share on other sites More sharing options...
Choonster Posted May 22, 2016 Share Posted May 22, 2016 Look at BlockOre#quantityDroppedWithBonus to see how vanilla ores add the fortune bonus. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
Monstrous_Apple Posted May 22, 2016 Author Share Posted May 22, 2016 Okay thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.