Advertisement
Guest User

Untitled

a guest
Oct 8th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.09 KB | None | 0 0
  1. package com.loungecraft.munky;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Random;
  6.  
  7. import cpw.mods.fml.common.registry.GameRegistry;
  8. import net.minecraft.block.Block;
  9. import net.minecraft.block.material.Material;
  10. import net.minecraft.client.renderer.texture.IIconRegister;
  11. import net.minecraft.creativetab.CreativeTabs;
  12. import net.minecraft.item.Item;
  13. import net.minecraft.item.ItemStack;
  14. import net.minecraft.util.IIcon;
  15.  
  16. public class BlockMunkyStone extends Block
  17. {
  18.     private static String name;
  19.     private static String[] metaNames;
  20.     private Item[] droplist;
  21.     public IIcon[] icons = new IIcon[] {};
  22.  
  23.     public BlockMunkyStone(String blockName, String[] metas, Item[] drops, Material material, CreativeTabs tab, Float hardness,
  24.                            Float resistance, SoundType soundtype, String tool, int mininglevel)
  25.     {
  26.         super(material);
  27.         droplist = drops;
  28.         metaNames = metas;
  29.         name = blockName;
  30.         GameRegistry.registerBlock(this, ItemBlockMetaBlock.class, name);
  31.         setCreativeTab(tab);
  32.         setHardness(hardness);
  33.         setResistance(resistance);
  34.         setStepSound(soundTypeStone);
  35.         setHarvestLevel(tool, mininglevel);
  36.     }
  37.    
  38.    
  39.     public String getName()
  40.     {
  41.         return name;
  42.     }
  43.    
  44.     @Override
  45.     public Item getItemDropped(int meta, Random rand, int fortune)
  46.     {      
  47.         if (droplist[meta] != null)
  48.             return droplist[meta];
  49.         else return Item.getItemFromBlock(this);
  50.     }
  51.    
  52.     @Override
  53.     public IIcon getIcon(int side, int meta)
  54.     {
  55.         if (meta > (metaNames.length - 1))
  56.             meta = meta % metaNames.length;
  57.         return this.icons[meta];
  58.     }
  59.    
  60.     @Override
  61.     public void getSubBlocks(Item item, CreativeTabs tab, List list)
  62.     {
  63.         for (int i = 0; i < metaNames.length; i++)
  64.             list.add(new ItemStack(item, 1, i));
  65.     }
  66.    
  67.     @Override
  68.     public void registerBlockIcons(IIconRegister reg)
  69.     {
  70.         for(int i= 0; i < metaNames.length; i++)
  71.             icons[i] = reg.registerIcon(Munky.MODID + ":" + getNameFromDamage(i));
  72.     }
  73.    
  74.     public static String getNameFromDamage(int damage)
  75.     {
  76.         return name + metaNames[damage];
  77.     }
  78.    
  79.     @Override
  80.     public int damageDropped(int meta)
  81.     {
  82.         return meta;
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement