tterrag1098

Untitled

Nov 4th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.17 KB | None | 0 0
  1. package niel.mod.Block;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import net.minecraft.block.Block;
  6. import net.minecraft.block.BlockFence;
  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.entity.Entity;
  11. import net.minecraft.entity.player.EntityPlayer;
  12. import net.minecraft.item.ItemLeash;
  13. import net.minecraft.util.AxisAlignedBB;
  14. import net.minecraft.util.Icon;
  15. import net.minecraft.world.IBlockAccess;
  16. import net.minecraft.world.World;
  17.  
  18. import java.util.List;
  19.  
  20. public class BirchFence extends BlockFence {
  21.     public BirchFence(int id) {
  22.         super(id, "modtweak" + ":" + "birch", Material.rock);
  23.         setHardness(1000F);
  24.         setCreativeTab(CreativeTabs.tabBlock);
  25.     }
  26.    
  27.     public void addCollisionBoxesToList(World par1World, int par2, int par3,
  28.             int par4, AxisAlignedBB par5AxisAlignedBB, List par6List,
  29.             Entity par7Entity) {
  30.         boolean flag = this.canConnectFenceTo(par1World, par2, par3, par4 - 1);
  31.         boolean flag1 = this.canConnectFenceTo(par1World, par2, par3, par4 + 1);
  32.         boolean flag2 = this.canConnectFenceTo(par1World, par2 - 1, par3, par4);
  33.         boolean flag3 = this.canConnectFenceTo(par1World, par2 + 1, par3, par4);
  34.         float f = 0.375F;
  35.         float f1 = 0.625F;
  36.         float f2 = 0.375F;
  37.         float f3 = 0.625F;
  38.  
  39.         if (flag) {
  40.             f2 = 0.0F;
  41.         }
  42.  
  43.         if (flag1) {
  44.             f3 = 1.0F;
  45.         }
  46.  
  47.         if (flag || flag1) {
  48.             this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3);
  49.             super.addCollisionBoxesToList(par1World, par2, par3, par4,
  50.                     par5AxisAlignedBB, par6List, par7Entity);
  51.         }
  52.  
  53.         f2 = 0.375F;
  54.         f3 = 0.625F;
  55.  
  56.         if (flag2) {
  57.             f = 0.0F;
  58.         }
  59.  
  60.         if (flag3) {
  61.             f1 = 1.0F;
  62.         }
  63.  
  64.         if (flag2 || flag3 || !flag && !flag1) {
  65.             this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3);
  66.             super.addCollisionBoxesToList(par1World, par2, par3, par4,
  67.                     par5AxisAlignedBB, par6List, par7Entity);
  68.         }
  69.  
  70.         if (flag) {
  71.             f2 = 0.0F;
  72.         }
  73.  
  74.         if (flag1) {
  75.             f3 = 1.0F;
  76.         }
  77.  
  78.         this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
  79.     }
  80.  
  81.     /**
  82.      * Updates the blocks bounds based on its current state. Args: world, x, y,
  83.      * z
  84.      */
  85.     public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess,
  86.             int par2, int par3, int par4) {
  87.         boolean flag = this.canConnectFenceTo(par1IBlockAccess, par2, par3,
  88.                 par4 - 1);
  89.         boolean flag1 = this.canConnectFenceTo(par1IBlockAccess, par2, par3,
  90.                 par4 + 1);
  91.         boolean flag2 = this.canConnectFenceTo(par1IBlockAccess, par2 - 1,
  92.                 par3, par4);
  93.         boolean flag3 = this.canConnectFenceTo(par1IBlockAccess, par2 + 1,
  94.                 par3, par4);
  95.         float f = 0.375F;
  96.         float f1 = 0.625F;
  97.         float f2 = 0.375F;
  98.         float f3 = 0.625F;
  99.  
  100.         if (flag) {
  101.             f2 = 0.0F;
  102.         }
  103.  
  104.         if (flag1) {
  105.             f3 = 1.0F;
  106.         }
  107.  
  108.         if (flag2) {
  109.             f = 0.0F;
  110.         }
  111.  
  112.         if (flag3) {
  113.             f1 = 1.0F;
  114.         }
  115.  
  116.         this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
  117.     }
  118.  
  119.     /**
  120.      * Is this block (a) opaque and (b) a full 1m cube? This determines whether
  121.      * or not to render the shared face of two adjacent blocks and also whether
  122.      * the player can attach torches, redstone wire, etc to this block.
  123.      */
  124.     public boolean isOpaqueCube() {
  125.         return false;
  126.     }
  127.  
  128.     /**
  129.      * If this block doesn't render as an ordinary block it will return False
  130.      * (examples: signs, buttons, stairs, etc)
  131.      */
  132.     public boolean renderAsNormalBlock() {
  133.         return false;
  134.     }
  135.  
  136.     public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2,
  137.             int par3, int par4) {
  138.         return false;
  139.     }
  140.  
  141.     /**
  142.      * The type of render function that is called for this block
  143.      */
  144.     public int getRenderType() {
  145.         return 11;
  146.     }
  147.  
  148.     /**
  149.      * Returns true if the specified block can be connected by a fence
  150.      */
  151.     public boolean canConnectFenceTo(IBlockAccess par1IBlockAccess, int par2,
  152.             int par3, int par4) {
  153.         int l = par1IBlockAccess.getBlockId(par2, par3, par4);
  154.  
  155.         if (l != this.blockID && l != Block.fenceGate.blockID) {
  156.             Block block = Block.blocksList[l];
  157.             return block != null && block.blockMaterial.isOpaque()
  158.                     && block.renderAsNormalBlock() ? block.blockMaterial != Material.pumpkin
  159.                     : false;
  160.         } else {
  161.             return true;
  162.         }
  163.     }
  164.  
  165.     public static boolean isIdAFence(int par0) {
  166.         return par0 == Block.fence.blockID || par0 == Block.netherFence.blockID;
  167.     }
  168.  
  169.     @SideOnly(Side.CLIENT)
  170.     /**
  171.      * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
  172.      * coordinates.  Args: blockAccess, x, y, z, side
  173.      */
  174.     public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess,
  175.             int par2, int par3, int par4, int par5) {
  176.         return false;
  177.     }
  178.  
  179.     @SideOnly(Side.CLIENT)
  180.     /**
  181.      * When this method is called, your block should register all the icons it needs with the given IconRegister. This
  182.      * is the only chance you get to register icons.
  183.  
  184.  
  185.     /**
  186.      * Called upon block activation (right click on the block.)
  187.      */
  188.     public boolean onBlockActivated(World par1World, int par2, int par3,
  189.             int par4, EntityPlayer par5EntityPlayer, int par6, float par7,
  190.             float par8, float par9) {
  191.         return par1World.isRemote ? true : ItemLeash.func_135066_a(
  192.                 par5EntityPlayer, par1World, par2, par3, par4);
  193.     }
  194. }
Advertisement
Add Comment
Please, Sign In to add comment