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.
209 lines
5.7 KiB
Java
209 lines
5.7 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.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.init.Items;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
|
|
public class BlockSign extends BlockContainer
|
|
{
|
|
private Class field_149968_a;
|
|
private boolean field_149967_b;
|
|
private static final String __OBFID = "CL_00000306";
|
|
|
|
protected BlockSign(Class p_i45426_1_, boolean p_i45426_2_)
|
|
{
|
|
super(Material.wood);
|
|
this.field_149967_b = p_i45426_2_;
|
|
this.field_149968_a = p_i45426_1_;
|
|
float f = 0.25F;
|
|
float f1 = 1.0F;
|
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
|
|
}
|
|
|
|
/**
|
|
* Gets the block's texture. Args: side, meta
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
public IIcon getIcon(int side, int meta)
|
|
{
|
|
return Blocks.planks.getBlockTextureFromSide(side);
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
if (!this.field_149967_b)
|
|
{
|
|
int l = worldIn.getBlockMetadata(x, y, z);
|
|
float f = 0.28125F;
|
|
float f1 = 0.78125F;
|
|
float f2 = 0.0F;
|
|
float f3 = 1.0F;
|
|
float f4 = 0.125F;
|
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
if (l == 2)
|
|
{
|
|
this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F);
|
|
}
|
|
|
|
if (l == 3)
|
|
{
|
|
this.setBlockBounds(f2, f, 0.0F, f3, f1, f4);
|
|
}
|
|
|
|
if (l == 4)
|
|
{
|
|
this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3);
|
|
}
|
|
|
|
if (l == 5)
|
|
{
|
|
this.setBlockBounds(0.0F, f, f2, f4, f1, f3);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
|
|
/**
|
|
* The type of render function that is called for this block
|
|
*/
|
|
public int getRenderType()
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* 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 worldIn, int x, int y, int z)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
/**
|
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
|
*/
|
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
|
{
|
|
try
|
|
{
|
|
return (TileEntity)this.field_149968_a.newInstance();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw new RuntimeException(exception);
|
|
}
|
|
}
|
|
|
|
public Item getItemDropped(int meta, Random random, int fortune)
|
|
{
|
|
return Items.sign;
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
boolean flag = false;
|
|
|
|
if (this.field_149967_b)
|
|
{
|
|
if (!worldIn.getBlock(x, y - 1, z).getMaterial().isSolid())
|
|
{
|
|
flag = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
int l = worldIn.getBlockMetadata(x, y, z);
|
|
flag = true;
|
|
|
|
if (l == 2 && worldIn.getBlock(x, y, z + 1).getMaterial().isSolid())
|
|
{
|
|
flag = false;
|
|
}
|
|
|
|
if (l == 3 && worldIn.getBlock(x, y, z - 1).getMaterial().isSolid())
|
|
{
|
|
flag = false;
|
|
}
|
|
|
|
if (l == 4 && worldIn.getBlock(x + 1, y, z).getMaterial().isSolid())
|
|
{
|
|
flag = false;
|
|
}
|
|
|
|
if (l == 5 && worldIn.getBlock(x - 1, y, z).getMaterial().isSolid())
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
|
|
if (flag)
|
|
{
|
|
this.dropBlockAsItem(worldIn, x, y, z, worldIn.getBlockMetadata(x, y, z), 0);
|
|
worldIn.setBlockToAir(x, y, z);
|
|
}
|
|
|
|
super.onNeighborBlockChange(worldIn, x, y, z, neighbor);
|
|
}
|
|
|
|
/**
|
|
* Gets an item for the block being called on. Args: world, x, y, z
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
public Item getItem(World worldIn, int x, int y, int z)
|
|
{
|
|
return Items.sign;
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public void registerBlockIcons(IIconRegister reg) {}
|
|
} |