WitherDoggie

Pane Class

May 19th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.35 KB | None | 0 0
  1. package com.wither.withermod.blocks;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.wither.withermod.Main;
  6. import com.wither.withermod.utils.WoodType;
  7.  
  8. import net.minecraft.block.Block;
  9. import net.minecraft.block.BlockPane;
  10. import net.minecraft.block.material.Material;
  11. import net.minecraft.block.state.IBlockState;
  12. import net.minecraft.client.Minecraft;
  13. import net.minecraft.creativetab.CreativeTabs;
  14. import net.minecraft.item.Item;
  15. import net.minecraft.util.BlockPos;
  16. import net.minecraft.util.MathHelper;
  17. import net.minecraft.world.IBlockAccess;
  18. import net.minecraft.world.World;
  19. import net.minecraftforge.fml.common.registry.GameRegistry;
  20.  
  21. public class ModPane extends BlockPane{
  22.    
  23.     private Item dropsOnHarvest;
  24.     private int dropamountmax = 1;
  25.     private int maxharvestEXP = 0;
  26.    
  27.     public ModPane(Material material, String name, float hardness, float resistance, CreativeTabs creativetab){
  28.        
  29.         super(material, false);
  30.        
  31.         this.setUnlocalizedName(name);
  32.         this.setHardness(hardness);
  33.         this.setResistance(resistance);
  34.         this.setStepSound(soundTypePiston);
  35.         this.setCreativeTab(creativetab);
  36.        
  37.         GameRegistry.registerBlock(this, name);
  38.        
  39.         this.dropsOnHarvest = Item.getItemFromBlock(this);
  40.     }
  41.    
  42.     public ModPane(Material material, String name, float hardness, float resistance, CreativeTabs creativetab, String[] woodTypeIds){
  43.        
  44.         super(material, false);
  45.        
  46.         this.setUnlocalizedName(name);
  47.         this.setHardness(hardness);
  48.         this.setResistance(resistance);
  49.         this.setStepSound(soundTypePiston);
  50.         this.setCreativeTab(creativetab);
  51.        
  52.         GameRegistry.registerBlock(this, name);
  53.        
  54.         this.dropsOnHarvest = Item.getItemFromBlock(this);
  55.     }
  56.    
  57.     public ModPane(Material material, String name, float hardness, float resistance, CreativeTabs creativetab, com.wither.withermod.blocks.ModBlock.HarvestToolEnum pickaxe, com.wither.withermod.blocks.ModBlock.HarvestLevelEnum wood){
  58.        
  59.         super(material, false);
  60.        
  61.         this.setUnlocalizedName(name);
  62.         this.setHardness(hardness);
  63.         this.setResistance(resistance);
  64.         this.setStepSound(soundTypePiston);
  65.         this.setCreativeTab(creativetab);
  66.         this.setHarvestLevel(pickaxe, wood);
  67.        
  68.         GameRegistry.registerBlock(this, name);
  69.        
  70.         this.dropsOnHarvest = Item.getItemFromBlock(this);
  71.     }
  72.    
  73.     public void RegisterRenderer(String modelName){
  74.        
  75.         System.out.println("Registering Block Renderer:" + modelName);
  76.         Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(this), 0, new net.minecraft.client.resources.model.ModelResourceLocation(Main.MODID + ":" + modelName, "inventory"));
  77.     }
  78.    
  79.     public void setHarvestLevel(com.wither.withermod.blocks.ModBlock.HarvestToolEnum pickaxe, com.wither.withermod.blocks.ModBlock.HarvestLevelEnum wood){
  80.         int level;
  81.         String tool = null;
  82.        
  83.         switch(pickaxe){
  84.        
  85.         case PICKAXE:
  86.             tool = "pickaxe";
  87.            
  88.         case SHOVEL:
  89.             tool = "shovel";
  90.        
  91.         case AXE:
  92.             tool = "axe";
  93.         }
  94.         switch(wood){
  95.        
  96.         case WOOD:
  97.             level = 0;
  98.             break;
  99.        
  100.         case STONE:
  101.             level = 1;
  102.             break;
  103.            
  104.         case IRON:
  105.             level = 2;
  106.             break;
  107.        
  108.         case DIAMOND:
  109.             level= 3;
  110.             break;
  111.            
  112.         case GOLD:
  113.             level = 0;
  114.             break;
  115.            
  116.         default:
  117.             level = 0;
  118.         }
  119.         super.setHarvestLevel(tool, level);
  120.     }
  121.    
  122.     public static enum HarvestToolEnum{
  123.        
  124.         PICKAXE,
  125.         SHOVEL,
  126.         AXE;
  127.     }
  128.     public static enum HarvestLevelEnum{
  129.        
  130.         WOOD,
  131.         STONE,
  132.         IRON,
  133.         DIAMOND,
  134.         GOLD;
  135.     }
  136.    
  137.     public void setMaxHarvestEXP(int expAmount){
  138.        
  139.         maxharvestEXP = expAmount;
  140.     }
  141.    
  142.     public void setDrops(Item drops){
  143.        
  144.         this.dropsOnHarvest = drops;
  145.     }
  146.    
  147.     public void setDrops(Block drops){
  148.        
  149.         this.dropsOnHarvest = Item.getItemFromBlock(drops);
  150.     }
  151.    
  152.     public void setDropMaxAmount(int dropamount){
  153.        
  154.         this.dropamountmax = dropamount;
  155.     }
  156.    
  157.     public Item getItemDropped(IBlockState state, Random rand, int fortune){
  158.        
  159.         return this.dropsOnHarvest;
  160.     }
  161.    
  162.     public int quantityDropped(Random random){
  163.        
  164.         int amount = random.nextInt(this.dropamountmax) + 1;
  165.         return amount;
  166.     }
  167.    
  168.     public int getExpDrops(IBlockAccess world, BlockPos pos, int fortune){
  169.        
  170.         IBlockState state = world.getBlockState(pos);
  171.         Random rand = world instanceof World ? ((World)world).rand : new Random();
  172.         if(this.getItemDropped(state, rand, fortune)!= Item.getItemFromBlock(this)){
  173.             return MathHelper.getRandomIntegerInRange(rand, 0, maxharvestEXP);
  174.         }
  175.         return 0;
  176.     }
  177. }
Add Comment
Please, Sign In to add comment