Skip to content

Instantly share code, notes, and snippets.

@dealingwith
Last active May 18, 2019 04:26
Show Gist options
  • Save dealingwith/5b2f5f8e38d9e210753be85713cfe6e4 to your computer and use it in GitHub Desktop.
Save dealingwith/5b2f5f8e38d9e210753be85713cfe6e4 to your computer and use it in GitHub Desktop.
Showing the diff of a simple Minecraft block and one that drops items
public class BlockDropper extends Block
{
public BlockDropper()
{
super(Material.ROCK);
this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS); // the block will appear on the Blocks tab in creative
this.setHardness(0.5f);
}
@SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.SOLID;
}
@Override
public boolean isOpaqueCube(IBlockState iBlockState) {
return true;
}
@Override
public boolean isFullCube(IBlockState iBlockState) {
return true;
}
@Override
public EnumBlockRenderType getRenderType(IBlockState iBlockState) {
return EnumBlockRenderType.MODEL;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.COOKIE;
}
@Override
public int quantityDropped(Random random) {
return random.nextInt(4) + 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment