Hello,
I'm working on a mod to incorporate a few custom materials and I'm currently having problems with one of my custom sapphire ore. I've managed to get the ore to drop the proper item (a sapphire) when mined, as well as respond properly to the fortune enchantment modifier. I'm now working on getting the ore to drop XP (3-7) when mined like the vanilla ores, which I've also managed to implement. I've tested all of this compared with the vanilla emerald ore and the emerald ore doesn't drop XP when you mine it with anything less than an iron pick, unlike my sapphire ore, which drops XP if it is broken by anything, doesn't matter what.
TL;DR
Sapphire Ore can drop XP when mined but still drops XP when destroyed with the wrong tool (which it shouldn't) although it doesn't drop items.
I've tried using the "onBlockDestroyedByPlayer(World, BlockPos, IBlockState)" method with the same result.
Any help is appreciated.
UPDATE: The Sapphire Ore also drops XP when picked up with a Silk Touch Pick, which it also shouldn't
Code below:
package com.nlbuescher.materealistic;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class BlockSapphireOre extends Block
{
public BlockSapphireOre(Material material)
{
super(material);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setHardness(3);
this.setHarvestLevel("pickaxe", 2);
this.setStepSound(soundTypeStone);
this.setUnlocalizedName("Sapphire Ore");
}
@Override
public Item getItemDropped(IBlockState state, Random random, int fortune)
{
return Materealistic.sapphire;
}
@Override
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player)
{
this.dropXpOnBlockBreak(world, pos, 3 + world.rand.nextInt(5));
}
@Override
public int damageDropped(IBlockState state)
{
return 0;
}
@Override
public int quantityDropped(IBlockState state, int fortune, Random random)
{
return 1 + random.nextInt(fortune + 1);
}
}