Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package niel.mod.Block;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockFence;
- import net.minecraft.block.material.Material;
- import net.minecraft.client.renderer.texture.IconRegister;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemLeash;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.Icon;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- import java.util.List;
- public class BirchFence extends BlockFence {
- public BirchFence(int id) {
- super(id, "modtweak" + ":" + "birch", Material.rock);
- setHardness(1000F);
- setCreativeTab(CreativeTabs.tabBlock);
- }
- public void addCollisionBoxesToList(World par1World, int par2, int par3,
- int par4, AxisAlignedBB par5AxisAlignedBB, List par6List,
- Entity par7Entity) {
- boolean flag = this.canConnectFenceTo(par1World, par2, par3, par4 - 1);
- boolean flag1 = this.canConnectFenceTo(par1World, par2, par3, par4 + 1);
- boolean flag2 = this.canConnectFenceTo(par1World, par2 - 1, par3, par4);
- boolean flag3 = this.canConnectFenceTo(par1World, par2 + 1, par3, par4);
- float f = 0.375F;
- float f1 = 0.625F;
- float f2 = 0.375F;
- float f3 = 0.625F;
- if (flag) {
- f2 = 0.0F;
- }
- if (flag1) {
- f3 = 1.0F;
- }
- if (flag || flag1) {
- this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3);
- super.addCollisionBoxesToList(par1World, par2, par3, par4,
- par5AxisAlignedBB, par6List, par7Entity);
- }
- f2 = 0.375F;
- f3 = 0.625F;
- if (flag2) {
- f = 0.0F;
- }
- if (flag3) {
- f1 = 1.0F;
- }
- if (flag2 || flag3 || !flag && !flag1) {
- this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3);
- super.addCollisionBoxesToList(par1World, par2, par3, par4,
- par5AxisAlignedBB, par6List, par7Entity);
- }
- if (flag) {
- f2 = 0.0F;
- }
- if (flag1) {
- f3 = 1.0F;
- }
- this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
- }
- /**
- * Updates the blocks bounds based on its current state. Args: world, x, y,
- * z
- */
- public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess,
- int par2, int par3, int par4) {
- boolean flag = this.canConnectFenceTo(par1IBlockAccess, par2, par3,
- par4 - 1);
- boolean flag1 = this.canConnectFenceTo(par1IBlockAccess, par2, par3,
- par4 + 1);
- boolean flag2 = this.canConnectFenceTo(par1IBlockAccess, par2 - 1,
- par3, par4);
- boolean flag3 = this.canConnectFenceTo(par1IBlockAccess, par2 + 1,
- par3, par4);
- float f = 0.375F;
- float f1 = 0.625F;
- float f2 = 0.375F;
- float f3 = 0.625F;
- if (flag) {
- f2 = 0.0F;
- }
- if (flag1) {
- f3 = 1.0F;
- }
- if (flag2) {
- f = 0.0F;
- }
- if (flag3) {
- f1 = 1.0F;
- }
- this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
- }
- /**
- * Is this block (a) opaque and (b) a full 1m cube? This determines whether
- * or not to render the shared face of two adjacent blocks and also whether
- * the player can attach torches, redstone wire, etc to this block.
- */
- public boolean isOpaqueCube() {
- return false;
- }
- /**
- * If this block doesn't render as an ordinary block it will return False
- * (examples: signs, buttons, stairs, etc)
- */
- public boolean renderAsNormalBlock() {
- return false;
- }
- public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2,
- int par3, int par4) {
- return false;
- }
- /**
- * The type of render function that is called for this block
- */
- public int getRenderType() {
- return 11;
- }
- /**
- * Returns true if the specified block can be connected by a fence
- */
- public boolean canConnectFenceTo(IBlockAccess par1IBlockAccess, int par2,
- int par3, int par4) {
- int l = par1IBlockAccess.getBlockId(par2, par3, par4);
- if (l != this.blockID && l != Block.fenceGate.blockID) {
- Block block = Block.blocksList[l];
- return block != null && block.blockMaterial.isOpaque()
- && block.renderAsNormalBlock() ? block.blockMaterial != Material.pumpkin
- : false;
- } else {
- return true;
- }
- }
- public static boolean isIdAFence(int par0) {
- return par0 == Block.fence.blockID || par0 == Block.netherFence.blockID;
- }
- @SideOnly(Side.CLIENT)
- /**
- * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
- * coordinates. Args: blockAccess, x, y, z, side
- */
- public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess,
- int par2, int par3, int par4, int par5) {
- return false;
- }
- @SideOnly(Side.CLIENT)
- /**
- * When this method is called, your block should register all the icons it needs with the given IconRegister. This
- * is the only chance you get to register icons.
- /**
- * Called upon block activation (right click on the block.)
- */
- public boolean onBlockActivated(World par1World, int par2, int par3,
- int par4, EntityPlayer par5EntityPlayer, int par6, float par7,
- float par8, float par9) {
- return par1World.isRemote ? true : ItemLeash.func_135066_a(
- par5EntityPlayer, par1World, par2, par3, par4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment