DialUp

LogEbony

Jan 2nd, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.21 KB | None | 0 0
  1. package net.brandoncow.mod.block;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import net.brandoncow.mod.BrandonCoW;
  7. import net.minecraft.block.Block;
  8. import net.minecraft.block.BlockRotatedPillar;
  9. import net.minecraft.block.material.Material;
  10. import net.minecraft.client.renderer.texture.IconRegister;
  11. import net.minecraft.creativetab.CreativeTabs;
  12. import net.minecraft.item.ItemStack;
  13. import net.minecraft.util.Icon;
  14. import net.minecraft.world.World;
  15. import cpw.mods.fml.relauncher.Side;
  16. import cpw.mods.fml.relauncher.SideOnly;
  17.  
  18. public class LogEbony extends BlockRotatedPillar
  19. {
  20.     /** The type of tree this log came from. */
  21.     public static final String[] woodType = new String[] {"ebony"};
  22.     @SideOnly(Side.CLIENT)
  23.     private Icon[] field_111052_c;
  24.     @SideOnly(Side.CLIENT)
  25.     private Icon[] tree_top;
  26.  
  27.     public LogEbony(int par1)
  28.     {
  29.         super(par1, Material.wood);
  30.         this.setCreativeTab(BrandonCoW.brandoncowTab);
  31.     }
  32.  
  33.     /**
  34.      * Returns the quantity of items to drop on block destruction.
  35.      */
  36.     public int quantityDropped(Random par1Random)
  37.     {
  38.         return 1;
  39.     }
  40.  
  41.     /**
  42.      * Returns the ID of the items to drop on destruction.
  43.      */
  44.     public int idDropped(int par1, Random par2Random, int par3)
  45.     {
  46.         return this.blockID;
  47.     }
  48.  
  49.     /**
  50.      * Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
  51.      * different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
  52.      * metadata
  53.      */
  54.     public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
  55.     {
  56.         byte b0 = 4;
  57.         int j1 = b0 + 1;
  58.  
  59.         if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1))
  60.         {
  61.             for (int k1 = -b0; k1 <= b0; ++k1)
  62.             {
  63.                 for (int l1 = -b0; l1 <= b0; ++l1)
  64.                 {
  65.                     for (int i2 = -b0; i2 <= b0; ++i2)
  66.                     {
  67.                         int j2 = par1World.getBlockId(par2 + k1, par3 + l1, par4 + i2);
  68.  
  69.                         if (Block.blocksList[j2] != null)
  70.                         {
  71.                             Block.blocksList[j2].beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2);
  72.                         }
  73.                     }
  74.                 }
  75.             }
  76.         }
  77.     }
  78.  
  79.     @SideOnly(Side.CLIENT)
  80.  
  81.     /**
  82.      * The icon for the side of the block.
  83.      */
  84.     protected Icon getSideIcon(int par1)
  85.     {
  86.         return this.field_111052_c[par1];
  87.     }
  88.  
  89.     @SideOnly(Side.CLIENT)
  90.  
  91.     /**
  92.      * The icon for the tops and bottoms of the block.
  93.      */
  94.     protected Icon getEndIcon(int par1)
  95.     {
  96.         return this.tree_top[par1];
  97.     }
  98.  
  99.     /**
  100.      * returns a number between 0 and 3
  101.      */
  102.     public static int limitToValidMetadata(int par0)
  103.     {
  104.         return par0 & 3;
  105.     }
  106.  
  107.     @SideOnly(Side.CLIENT)
  108.  
  109.     /**
  110.      * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
  111.      */
  112.     public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
  113.     {
  114.         par3List.add(new ItemStack(par1, 1, 0));
  115.     }
  116.  
  117.     @SideOnly(Side.CLIENT)
  118.  
  119.     /**
  120.      * When this method is called, your block should register all the icons it needs with the given IconRegister. This
  121.      * is the only chance you get to register icons.
  122.      */
  123.     public void registerIcons(IconRegister par1IconRegister)
  124.     {
  125.         this.field_111052_c = new Icon[woodType.length];
  126.         this.tree_top = new Icon[woodType.length];
  127.  
  128.         for (int i = 0; i < this.field_111052_c.length; ++i)
  129.         {
  130.             this.field_111052_c[i] = par1IconRegister.registerIcon("BrandonCoW:log" + "_" + woodType[i]);
  131.             this.tree_top[i] = par1IconRegister.registerIcon("BrandonCoW:log" + "_" + woodType[i] + "_top");
  132.         }
  133.     }
  134.  
  135.     @Override
  136.     public boolean canSustainLeaves(World world, int x, int y, int z)
  137.     {
  138.         return true;
  139.     }
  140.  
  141.     @Override
  142.     public boolean isWood(World world, int x, int y, int z)
  143.     {
  144.         return true;
  145.     }
  146.    
  147.  
  148.    
  149. }
Advertisement
Add Comment
Please, Sign In to add comment