Advertisement
Guest User

TutLog

a guest
Mar 25th, 2013
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.30 KB | None | 0 0
  1. package OliveCraft;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import net.minecraft.block.Block;
  7. import net.minecraft.block.material.Material;
  8. import net.minecraft.client.renderer.texture.IconRegister;
  9. import net.minecraft.creativetab.CreativeTabs;
  10. import net.minecraft.item.ItemStack;
  11. import net.minecraft.util.Icon;
  12. import net.minecraft.world.World;
  13. import cpw.mods.fml.relauncher.Side;
  14. import cpw.mods.fml.relauncher.SideOnly;
  15.  
  16. public class TutLog extends Block
  17. {
  18.     /** The type of tree this log came from. */
  19.     public static final String[] TutwoodType = new String[] {"Tut"};
  20.     @SideOnly(Side.CLIENT)
  21.     private Icon[] iconArray;
  22.     @SideOnly(Side.CLIENT)
  23.     private Icon tree_top;
  24.     private int blockIndexTexture;
  25.  
  26.     protected TutLog(int par1)
  27.     {
  28.         super(par1, Material.wood);
  29.         this.blockIndexTexture = 1;
  30.         this.setCreativeTab(CreativeTabs.tabBlock);
  31.     }
  32.  
  33.     /**
  34.      * The type of render function that is called for this block
  35.      */
  36.     public int getRenderType()
  37.     {
  38.         return 31;
  39.     }
  40.  
  41.     /**
  42.      * Returns the quantity of items to drop on block destruction.
  43.      */
  44.     public int quantityDropped(Random par1Random)
  45.     {
  46.         return 1;
  47.     }
  48.  
  49.     /**
  50.      * Returns the ID of the items to drop on destruction.
  51.      */
  52.     public int idDropped(int par1, Random par2Random, int par3)
  53.     {
  54.         return this.blockID;
  55.     }
  56.  
  57.     /**
  58.      * ejects contained items into the world, and notifies neighbours of an update, as appropriate
  59.      */
  60.     public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
  61.     {
  62.         byte b0 = 4;
  63.         int j1 = b0 + 1;
  64.  
  65.         if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1))
  66.         {
  67.             for (int k1 = -b0; k1 <= b0; ++k1)
  68.             {
  69.                 for (int l1 = -b0; l1 <= b0; ++l1)
  70.                 {
  71.                     for (int i2 = -b0; i2 <= b0; ++i2)
  72.                     {
  73.                         int j2 = par1World.getBlockId(par2 + k1, par3 + l1, par4 + i2);
  74.  
  75.                         if (Block.blocksList[j2] != null)
  76.                         {
  77.                             Block.blocksList[j2].beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2);
  78.                         }
  79.                     }
  80.                 }
  81.             }
  82.         }
  83.     }
  84.  
  85.     /**
  86.      * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
  87.      */
  88.     public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
  89.     {
  90.         int j1 = par9 & 3;
  91.         byte b0 = 0;
  92.  
  93.         switch (par5)
  94.         {
  95.             case 0:
  96.             case 1:
  97.                 b0 = 0;
  98.                 break;
  99.             case 2:
  100.             case 3:
  101.                 b0 = 8;
  102.                 break;
  103.             case 4:
  104.             case 5:
  105.                 b0 = 4;
  106.         }
  107.  
  108.         return j1 | b0;
  109.     }
  110.  
  111.     @SideOnly(Side.CLIENT)
  112.  
  113.     /**
  114.      * Determines the damage on the item the block drops. Used in cloth and wood.
  115.      */
  116.     public int damageDropped(int par1)
  117.     {
  118.         return par1 & 3;
  119.     }
  120.  
  121.     /**
  122.      * returns a number between 0 and 3
  123.      */
  124.     public static int limitToValidMetadata(int par0)
  125.     {
  126.         return par0 & 3;
  127.     }
  128.  
  129.     @SideOnly(Side.CLIENT)
  130.  
  131.     /**
  132.      * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
  133.      */
  134.     public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
  135.     {
  136.         par3List.add(new ItemStack(par1, 1, 0));
  137.     }
  138.  
  139.     /**
  140.      * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
  141.      * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
  142.      */
  143.     protected ItemStack createStackedBlock(int par1)
  144.     {
  145.         return new ItemStack(this.blockID, 1, limitToValidMetadata(par1));
  146.     }
  147.  
  148.     @Override
  149.     public boolean canSustainLeaves(World world, int x, int y, int z)
  150.     {
  151.         return true;
  152.     }
  153.  
  154.     @Override
  155.     public boolean isWood(World world, int x, int y, int z)
  156.     {
  157.         return true;
  158.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement