You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
5.4 KiB
Java
196 lines
5.4 KiB
Java
package net.minecraft.block;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import java.util.Random;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
import static net.minecraftforge.common.util.ForgeDirection.*;
|
|
|
|
public class BlockLadder extends Block
|
|
{
|
|
private static final String __OBFID = "CL_00000262";
|
|
|
|
protected BlockLadder()
|
|
{
|
|
super(Material.circuits);
|
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
|
}
|
|
|
|
/**
|
|
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
|
* cleared to be reused)
|
|
*/
|
|
public AxisAlignedBB getCollisionBoundingBoxFromPool(World worldIn, int x, int y, int z)
|
|
{
|
|
this.setBlockBoundsBasedOnState(worldIn, x, y, z);
|
|
return super.getCollisionBoundingBoxFromPool(worldIn, x, y, z);
|
|
}
|
|
|
|
/**
|
|
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
|
*/
|
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, int x, int y, int z)
|
|
{
|
|
this.func_149797_b(worldIn.getBlockMetadata(x, y, z));
|
|
}
|
|
|
|
/**
|
|
* Returns the bounding box of the wired rectangular prism to render.
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
public AxisAlignedBB getSelectedBoundingBoxFromPool(World worldIn, int x, int y, int z)
|
|
{
|
|
this.setBlockBoundsBasedOnState(worldIn, x, y, z);
|
|
return super.getSelectedBoundingBoxFromPool(worldIn, x, y, z);
|
|
}
|
|
|
|
public void func_149797_b(int p_149797_1_)
|
|
{
|
|
float f = 0.125F;
|
|
|
|
if (p_149797_1_ == 2)
|
|
{
|
|
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
|
|
}
|
|
|
|
if (p_149797_1_ == 3)
|
|
{
|
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
|
|
}
|
|
|
|
if (p_149797_1_ == 4)
|
|
{
|
|
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
}
|
|
|
|
if (p_149797_1_ == 5)
|
|
{
|
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
/**
|
|
* The type of render function that is called for this block
|
|
*/
|
|
public int getRenderType()
|
|
{
|
|
return 8;
|
|
}
|
|
|
|
/**
|
|
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
|
*/
|
|
public boolean canPlaceBlockAt(World worldIn, int x, int y, int z)
|
|
{
|
|
return worldIn.isSideSolid(x - 1, y, z, EAST ) ||
|
|
worldIn.isSideSolid(x + 1, y, z, WEST ) ||
|
|
worldIn.isSideSolid(x, y, z - 1, SOUTH) ||
|
|
worldIn.isSideSolid(x, y, z + 1, NORTH);
|
|
}
|
|
|
|
/**
|
|
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
|
|
*/
|
|
public int onBlockPlaced(World worldIn, int x, int y, int z, int side, float subX, float subY, float subZ, int meta)
|
|
{
|
|
int j1 = meta;
|
|
|
|
if ((meta == 0 || side == 2) && worldIn.isSideSolid(x, y, z + 1, NORTH))
|
|
{
|
|
j1 = 2;
|
|
}
|
|
|
|
if ((j1 == 0 || side == 3) && worldIn.isSideSolid(x, y, z - 1, SOUTH))
|
|
{
|
|
j1 = 3;
|
|
}
|
|
|
|
if ((j1 == 0 || side == 4) && worldIn.isSideSolid(x + 1, y, z, WEST))
|
|
{
|
|
j1 = 4;
|
|
}
|
|
|
|
if ((j1 == 0 || side == 5) && worldIn.isSideSolid(x - 1, y, z, EAST))
|
|
{
|
|
j1 = 5;
|
|
}
|
|
|
|
return j1;
|
|
}
|
|
|
|
/**
|
|
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
|
* their own) Args: x, y, z, neighbor Block
|
|
*/
|
|
public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor)
|
|
{
|
|
int l = worldIn.getBlockMetadata(x, y, z);
|
|
boolean flag = false;
|
|
|
|
if (l == 2 && worldIn.isSideSolid(x, y, z + 1, NORTH))
|
|
{
|
|
flag = true;
|
|
}
|
|
|
|
if (l == 3 && worldIn.isSideSolid(x, y, z - 1, SOUTH))
|
|
{
|
|
flag = true;
|
|
}
|
|
|
|
if (l == 4 && worldIn.isSideSolid(x + 1, y, z, WEST))
|
|
{
|
|
flag = true;
|
|
}
|
|
|
|
if (l == 5 && worldIn.isSideSolid(x - 1, y, z, EAST))
|
|
{
|
|
flag = true;
|
|
}
|
|
|
|
if (!flag)
|
|
{
|
|
this.dropBlockAsItem(worldIn, x, y, z, l, 0);
|
|
worldIn.setBlockToAir(x, y, z);
|
|
}
|
|
|
|
super.onNeighborBlockChange(worldIn, x, y, z, neighbor);
|
|
}
|
|
|
|
/**
|
|
* Returns the quantity of items to drop on block destruction.
|
|
*/
|
|
public int quantityDropped(Random random)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
@Override
|
|
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
|
|
{
|
|
return true;
|
|
}
|
|
} |