Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.loungecraft.munky;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import cpw.mods.fml.common.registry.GameRegistry;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.client.renderer.texture.IIconRegister;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.IIcon;
- public class BlockMunkyStone extends Block
- {
- private static String name;
- private static String[] metaNames;
- private Item[] droplist;
- public IIcon[] icons = new IIcon[] {};
- public BlockMunkyStone(String blockName, String[] metas, Item[] drops, Material material, CreativeTabs tab, Float hardness,
- Float resistance, SoundType soundtype, String tool, int mininglevel)
- {
- super(material);
- droplist = drops;
- metaNames = metas;
- name = blockName;
- GameRegistry.registerBlock(this, ItemBlockMetaBlock.class, name);
- setCreativeTab(tab);
- setHardness(hardness);
- setResistance(resistance);
- setStepSound(soundTypeStone);
- setHarvestLevel(tool, mininglevel);
- }
- public String getName()
- {
- return name;
- }
- @Override
- public Item getItemDropped(int meta, Random rand, int fortune)
- {
- if (droplist[meta] != null)
- return droplist[meta];
- else return Item.getItemFromBlock(this);
- }
- @Override
- public IIcon getIcon(int side, int meta)
- {
- if (meta > (metaNames.length - 1))
- meta = meta % metaNames.length;
- return this.icons[meta];
- }
- @Override
- public void getSubBlocks(Item item, CreativeTabs tab, List list)
- {
- for (int i = 0; i < metaNames.length; i++)
- list.add(new ItemStack(item, 1, i));
- }
- @Override
- public void registerBlockIcons(IIconRegister reg)
- {
- for(int i= 0; i < metaNames.length; i++)
- icons[i] = reg.registerIcon(Munky.MODID + ":" + getNameFromDamage(i));
- }
- public static String getNameFromDamage(int damage)
- {
- return name + metaNames[damage];
- }
- @Override
- public int damageDropped(int meta)
- {
- return meta;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement