Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. package blocks;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.material.Material;
  6. import net.minecraft.init.Items;
  7. import net.minecraft.item.Item;
  8.  
  9. public class BlockOre extends BlockBasic {
  10.  
  11.     Item toDrop = Items.APPLE;
  12.     int minDropAmount = 1;
  13.     int maxDropAmount = 0;
  14.    
  15.     public BlockOre(String name, Material material)
  16.     {
  17.         this(name, material, null, 1, 1);
  18.     }
  19.    
  20.     public BlockOre(String name, Material material, Item toDrop)
  21.     {
  22.         this(name, material, toDrop, 1, 1);
  23.     }
  24.    
  25.     public BlockOre(String name, Material material, Item toDrop, int dropAmount)
  26.     {
  27.         this(name, material, toDrop, dropAmount, dropAmount);
  28.     }
  29.    
  30.     public BlockOre(String name, Material material, Item toDrop, int minDropAmount, int maxDropAmount) {
  31.         super(name, material);
  32.         this.toDrop = toDrop;
  33.         this.minDropAmount = minDropAmount;
  34.         this.maxDropAmount = maxDropAmount;
  35.     }
  36.    
  37.     @Override
  38.     public int quantityDropped(Random random)
  39.     {
  40.         if(this.minDropAmount>this.maxDropAmount) {
  41.             int i = this.minDropAmount;
  42.             this.minDropAmount=this.maxDropAmount;
  43.             this.maxDropAmount=i;
  44.         }
  45.         return this.minDropAmount + random.nextInt(this.maxDropAmount - this.minDropAmount + 1);
  46.     }
  47.    
  48.     @Override
  49.     public int quantityDroppedWithBonus(int fortune, Random random)
  50.     {
  51.         if (fortune > 0 && Item.getItemFromBlock(this) != this.getItemDropped(this.getDefaultState(), random, fortune))
  52.         {
  53.             int i = random.nextInt(fortune + 2) - 1;
  54.             if (i < 0)
  55.             {
  56.                 i = 0;
  57.             }
  58.             return this.quantityDropped(random) * (i + 1);
  59.            
  60.         }
  61.         else
  62.         {
  63.            return this.quantityDropped(random);
  64.         }
  65.     }
  66.    
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement