SHARE
TWEET

Untitled

a guest Jul 19th, 2017 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.rbs.slurpiesdongles.blocks;
  2.  
  3. import com.rbs.slurpiesdongles.SlurpiesDongles;
  4. import com.rbs.slurpiesdongles.init.SDBlocks;
  5. import com.rbs.slurpiesdongles.init.SDItems;
  6. import net.minecraft.block.SoundType;
  7. import net.minecraft.block.material.Material;
  8. import net.minecraft.block.state.IBlockState;
  9. import net.minecraft.creativetab.CreativeTabs;
  10. import net.minecraft.item.Item;
  11. import net.minecraft.item.ItemBlock;
  12. import net.minecraft.util.math.BlockPos;
  13. import net.minecraft.util.math.MathHelper;
  14. import net.minecraft.world.IBlockAccess;
  15. import net.minecraft.world.World;
  16. import net.minecraft.block.Block;
  17.  
  18. import java.util.Random;
  19.  
  20. /**
  21.  * Created by Consular on 7/19/2017.
  22.  */
  23. public class BlockSapphireOre extends Block {
  24.  
  25.     protected String name;
  26.  
  27.     public BlockSapphireOre( String name) {
  28.         super(Material.ROCK);
  29.         this.name = name;
  30.  
  31.         setUnlocalizedName(name);
  32.         setRegistryName(name);
  33.  
  34.         this.setHarvestLevel("pickaxe", 2);
  35.         this.setHardness(3.0F);
  36.         this.setResistance(5.0F);
  37.         this.setSoundType(SoundType.STONE);
  38.     }
  39.  
  40.     public void registerItemModel(ItemBlock itemBlock) {
  41.         SlurpiesDongles.proxy.registerItemRenderer(itemBlock, 0, name);
  42.     }
  43.  
  44.     public Item createItemBlock() {
  45.         return new ItemBlock(this);
  46.     }
  47.  
  48.     @Override
  49.     public BlockSapphireOre setCreativeTab(CreativeTabs tab) {
  50.         super.setCreativeTab(tab);
  51.         return this;
  52.     }
  53.  
  54.  
  55.     public Item getItemDropped(IBlockState state, Random random, int fortune){
  56.  
  57.         return this == SDBlocks.oreSapphire ? SDItems.sapphire : Item.getItemFromBlock(this);
  58.     }
  59.  
  60.     public int quantityDroppedWithBonus(int fortune, Random random){
  61.  
  62.         if(fortune > 0 && Item.getItemFromBlock(this) != this.getItemDropped((IBlockState)this.getBlockState().getValidStates().iterator().next(), random, fortune)){
  63.  
  64.             int i = random.nextInt(fortune + 2) - 1;
  65.  
  66.             if (i < 0){
  67.                 i = 0;
  68.             }
  69.  
  70.             return this.quantityDropped(random) * (i + 1);
  71.         }else{
  72.  
  73.             return this.quantityDropped(random);
  74.         }
  75.     }
  76.  
  77.     public void dropBlockAsItemWithChance(World world, BlockPos pos, IBlockState state, float chance, int fortune){
  78.  
  79.         super.dropBlockAsItemWithChance(world, pos, state, chance, fortune);
  80.     }
  81.  
  82.     public int getExpDrop(IBlockAccess world, BlockPos pos, int fortune){
  83.  
  84.         IBlockState state = world.getBlockState(pos);
  85.         Random random = world instanceof World ? ((World)world).rand : new Random();
  86.  
  87.         if (this.getItemDropped(state, random, fortune) != Item.getItemFromBlock(this)){
  88.  
  89.             int i = 0;
  90.  
  91.             if (this == SDBlocks.oreSapphire)
  92.             {
  93.                 i = MathHelper.getInt(random, 3, 7);
  94.             }
  95.  
  96.             return i;
  97.         }
  98.         return 0;
  99.     }
  100.  
  101.     public int getDamageValue(World world, BlockPos pos){
  102.  
  103.         return 0;
  104.     }
  105.  
  106.     public void registerItemModel(Item itemFromBlock) {
  107.     }
  108. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top