Jump to content

NLBuescher

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by NLBuescher

  1. So I went with this solution simply because my goal was to create a vanilla style ore, with all the same works. I also finally managed to get a look at the Minecraft source code (I wasn't able to before because I set up the workspace wrong ), which was immeasurably helpful in figuring out how to go about extending the BlockOre class I ended up extending "BlockOre" instead of "Block" and overriding the "getExpDrop(IBlockAccess, BlockPos, int)" method, which worked wonderfully since this way the game automatically knows not to drop XP if the block isn't properly destroyed. EDIT: No way dude, that was meant for vanilla ores. To clarify, the vanilla "BlockOre.getExpDrop(...)" method did have all of the vanilla ores hardcoded into the calculations for how much XP to drop, but overriding that method will fix that problem.
  2. 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); } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.