Java 类net.minecraft.block.BlockWallSign 实例源码

项目:DecompiledMinecraft    文件:ItemSign.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
    {
        return false;
    }
    else
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else if (!Blocks.standing_sign.canPlaceBlockAt(worldIn, pos))
        {
            return false;
        }
        else if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            if (side == EnumFacing.UP)
            {
                int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                worldIn.setBlockState(pos, Blocks.standing_sign.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
            }
            else
            {
                worldIn.setBlockState(pos, Blocks.wall_sign.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
            }

            --stack.stackSize;
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
            {
                playerIn.openEditSign((TileEntitySign)tileentity);
            }

            return true;
        }
    }
}
项目:DecompiledMinecraft    文件:ItemBanner.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
    {
        return false;
    }
    else
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else if (!Blocks.standing_banner.canPlaceBlockAt(worldIn, pos))
        {
            return false;
        }
        else if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            if (side == EnumFacing.UP)
            {
                int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                worldIn.setBlockState(pos, Blocks.standing_banner.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
            }
            else
            {
                worldIn.setBlockState(pos, Blocks.wall_banner.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
            }

            --stack.stackSize;
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityBanner)
            {
                ((TileEntityBanner)tileentity).setItemValues(stack);
            }

            return true;
        }
    }
}
项目:DecompiledMinecraft    文件:ItemSign.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
    {
        return false;
    }
    else
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else if (!Blocks.standing_sign.canPlaceBlockAt(worldIn, pos))
        {
            return false;
        }
        else if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            if (side == EnumFacing.UP)
            {
                int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                worldIn.setBlockState(pos, Blocks.standing_sign.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
            }
            else
            {
                worldIn.setBlockState(pos, Blocks.wall_sign.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
            }

            --stack.stackSize;
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
            {
                playerIn.openEditSign((TileEntitySign)tileentity);
            }

            return true;
        }
    }
}
项目:DecompiledMinecraft    文件:ItemBanner.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
    {
        return false;
    }
    else
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else if (!Blocks.standing_banner.canPlaceBlockAt(worldIn, pos))
        {
            return false;
        }
        else if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            if (side == EnumFacing.UP)
            {
                int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                worldIn.setBlockState(pos, Blocks.standing_banner.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
            }
            else
            {
                worldIn.setBlockState(pos, Blocks.wall_banner.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
            }

            --stack.stackSize;
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityBanner)
            {
                ((TileEntityBanner)tileentity).setItemValues(stack);
            }

            return true;
        }
    }
}
项目:BaseClient    文件:ItemSign.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
    {
        return false;
    }
    else
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else if (!Blocks.standing_sign.canPlaceBlockAt(worldIn, pos))
        {
            return false;
        }
        else if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            if (side == EnumFacing.UP)
            {
                int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                worldIn.setBlockState(pos, Blocks.standing_sign.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
            }
            else
            {
                worldIn.setBlockState(pos, Blocks.wall_sign.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
            }

            --stack.stackSize;
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
            {
                playerIn.openEditSign((TileEntitySign)tileentity);
            }

            return true;
        }
    }
}
项目:BaseClient    文件:ItemBanner.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
    {
        return false;
    }
    else
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else if (!Blocks.standing_banner.canPlaceBlockAt(worldIn, pos))
        {
            return false;
        }
        else if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            if (side == EnumFacing.UP)
            {
                int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                worldIn.setBlockState(pos, Blocks.standing_banner.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
            }
            else
            {
                worldIn.setBlockState(pos, Blocks.wall_banner.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
            }

            --stack.stackSize;
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityBanner)
            {
                ((TileEntityBanner)tileentity).setItemValues(stack);
            }

            return true;
        }
    }
}
项目:BaseClient    文件:ItemSign.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
    {
        return false;
    }
    else
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else if (!Blocks.standing_sign.canPlaceBlockAt(worldIn, pos))
        {
            return false;
        }
        else if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            if (side == EnumFacing.UP)
            {
                int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                worldIn.setBlockState(pos, Blocks.standing_sign.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
            }
            else
            {
                worldIn.setBlockState(pos, Blocks.wall_sign.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
            }

            --stack.stackSize;
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
            {
                playerIn.openEditSign((TileEntitySign)tileentity);
            }

            return true;
        }
    }
}
项目:BaseClient    文件:ItemBanner.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (side == EnumFacing.DOWN)
    {
        return false;
    }
    else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
    {
        return false;
    }
    else
    {
        pos = pos.offset(side);

        if (!playerIn.canPlayerEdit(pos, side, stack))
        {
            return false;
        }
        else if (!Blocks.standing_banner.canPlaceBlockAt(worldIn, pos))
        {
            return false;
        }
        else if (worldIn.isRemote)
        {
            return true;
        }
        else
        {
            if (side == EnumFacing.UP)
            {
                int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                worldIn.setBlockState(pos, Blocks.standing_banner.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
            }
            else
            {
                worldIn.setBlockState(pos, Blocks.wall_banner.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
            }

            --stack.stackSize;
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityBanner)
            {
                ((TileEntityBanner)tileentity).setItemValues(stack);
            }

            return true;
        }
    }
}
项目:Backmemed    文件:ItemSign.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    IBlockState iblockstate = playerIn.getBlockState(worldIn);
    boolean flag = iblockstate.getBlock().isReplaceable(playerIn, worldIn);

    if (hand != EnumFacing.DOWN && (iblockstate.getMaterial().isSolid() || flag) && (!flag || hand == EnumFacing.UP))
    {
        worldIn = worldIn.offset(hand);
        ItemStack itemstack = stack.getHeldItem(pos);

        if (stack.canPlayerEdit(worldIn, hand, itemstack) && Blocks.STANDING_SIGN.canPlaceBlockAt(playerIn, worldIn))
        {
            if (playerIn.isRemote)
            {
                return EnumActionResult.SUCCESS;
            }
            else
            {
                worldIn = flag ? worldIn.down() : worldIn;

                if (hand == EnumFacing.UP)
                {
                    int i = MathHelper.floor((double)((stack.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                    playerIn.setBlockState(worldIn, Blocks.STANDING_SIGN.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 11);
                }
                else
                {
                    playerIn.setBlockState(worldIn, Blocks.WALL_SIGN.getDefaultState().withProperty(BlockWallSign.FACING, hand), 11);
                }

                TileEntity tileentity = playerIn.getTileEntity(worldIn);

                if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(playerIn, stack, worldIn, itemstack))
                {
                    stack.openEditSign((TileEntitySign)tileentity);
                }

                itemstack.func_190918_g(1);
                return EnumActionResult.SUCCESS;
            }
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:Backmemed    文件:ItemBanner.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    IBlockState iblockstate = playerIn.getBlockState(worldIn);
    boolean flag = iblockstate.getBlock().isReplaceable(playerIn, worldIn);

    if (hand != EnumFacing.DOWN && (iblockstate.getMaterial().isSolid() || flag) && (!flag || hand == EnumFacing.UP))
    {
        worldIn = worldIn.offset(hand);
        ItemStack itemstack = stack.getHeldItem(pos);

        if (stack.canPlayerEdit(worldIn, hand, itemstack) && Blocks.STANDING_BANNER.canPlaceBlockAt(playerIn, worldIn))
        {
            if (playerIn.isRemote)
            {
                return EnumActionResult.SUCCESS;
            }
            else
            {
                worldIn = flag ? worldIn.down() : worldIn;

                if (hand == EnumFacing.UP)
                {
                    int i = MathHelper.floor((double)((stack.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                    playerIn.setBlockState(worldIn, Blocks.STANDING_BANNER.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
                }
                else
                {
                    playerIn.setBlockState(worldIn, Blocks.WALL_BANNER.getDefaultState().withProperty(BlockWallSign.FACING, hand), 3);
                }

                TileEntity tileentity = playerIn.getTileEntity(worldIn);

                if (tileentity instanceof TileEntityBanner)
                {
                    ((TileEntityBanner)tileentity).setItemValues(itemstack, false);
                }

                itemstack.func_190918_g(1);
                return EnumActionResult.SUCCESS;
            }
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:CustomWorldGen    文件:ItemSign.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    boolean flag = iblockstate.getBlock().isReplaceable(worldIn, pos);

    if (facing != EnumFacing.DOWN && (iblockstate.getMaterial().isSolid() || flag) && (!flag || facing == EnumFacing.UP))
    {
        pos = pos.offset(facing);

        if (playerIn.canPlayerEdit(pos, facing, stack) && Blocks.STANDING_SIGN.canPlaceBlockAt(worldIn, pos))
        {
            if (worldIn.isRemote)
            {
                return EnumActionResult.SUCCESS;
            }
            else
            {
                pos = flag ? pos.down() : pos;

                if (facing == EnumFacing.UP)
                {
                    int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                    worldIn.setBlockState(pos, Blocks.STANDING_SIGN.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 11);
                }
                else
                {
                    worldIn.setBlockState(pos, Blocks.WALL_SIGN.getDefaultState().withProperty(BlockWallSign.FACING, facing), 11);
                }

                --stack.stackSize;
                TileEntity tileentity = worldIn.getTileEntity(pos);

                if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
                {
                    playerIn.openEditSign((TileEntitySign)tileentity);
                }

                return EnumActionResult.SUCCESS;
            }
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:CustomWorldGen    文件:ItemBanner.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    boolean flag = iblockstate.getBlock().isReplaceable(worldIn, pos);

    if (facing != EnumFacing.DOWN && (iblockstate.getMaterial().isSolid() || flag) && (!flag || facing == EnumFacing.UP))
    {
        pos = pos.offset(facing);

        if (playerIn.canPlayerEdit(pos, facing, stack) && Blocks.STANDING_BANNER.canPlaceBlockAt(worldIn, pos))
        {
            if (worldIn.isRemote)
            {
                return EnumActionResult.SUCCESS;
            }
            else
            {
                pos = flag ? pos.down() : pos;

                if (facing == EnumFacing.UP)
                {
                    int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                    worldIn.setBlockState(pos, Blocks.STANDING_BANNER.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
                }
                else
                {
                    worldIn.setBlockState(pos, Blocks.WALL_BANNER.getDefaultState().withProperty(BlockWallSign.FACING, facing), 3);
                }

                --stack.stackSize;
                TileEntity tileentity = worldIn.getTileEntity(pos);

                if (tileentity instanceof TileEntityBanner)
                {
                    ((TileEntityBanner)tileentity).setItemValues(stack);
                }

                return EnumActionResult.SUCCESS;
            }
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:BaMsGRAVE    文件:GraveDigger.java   
private void setTombstone() {
    // Check for solid ground if no wall exists
    boolean needsWall = !world.getBlockState(wallPos).getBlock().getMaterial().isSolid();
    BlockPos groundPos = wallPos.down();
    IBlockState groundState = world.getBlockState(groundPos);
    boolean isSolidGround = groundState.getBlock().getMaterial().isSolid();
    if (needsWall && !isSolidGround) {
        return;
    }

    // Find and take one sign
    boolean hasSign = false;
    if (BaMsConfig.needSignToMakeSign || isCreative) {
        for (int i = 0; i < inventory.getSizeInventory(); i++) {
            ItemStack stack = inventory.getStackInSlot(i);
            if (stack != null && stack.getItem() == Items.sign) {
                inventory.decrStackSize(i, 1);
                hasSign = true;
                break;
            }
        }
    } else {
        hasSign = true;
    }

    // Place wall if needed
    if (needsWall && !BaMsConfig.setTombstoneWall(world, wallPos, groundState, 2)) {
        // Place standing sign if wall can't be placed
        if (hasSign) {
            int oppositeRotation = oppositeFacing.getHorizontalIndex() * 4;
            BaMsConfig.setBlockState(world, wallPos, Blocks.standing_sign.getDefaultState().withProperty(BlockStandingSign.ROTATION, oppositeRotation), 2);
            addSignEngraving(wallPos);
        }
        return;
    }

    // Place wall sign
    if (hasSign) {
        BaMsConfig.setBlockState(world, signPos, Blocks.wall_sign.getDefaultState().withProperty(BlockWallSign.FACING, oppositeFacing), 2);
        addSignEngraving(signPos);
    }

    // Place flower pot
    BaMsConfig.setFlowerPot(world, flowerPotPos, 2);
}
项目:ExpandedRailsMod    文件:ItemSign.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    boolean flag = iblockstate.getBlock().isReplaceable(worldIn, pos);

    if (facing != EnumFacing.DOWN && (iblockstate.getMaterial().isSolid() || flag) && (!flag || facing == EnumFacing.UP))
    {
        pos = pos.offset(facing);

        if (playerIn.canPlayerEdit(pos, facing, stack) && Blocks.STANDING_SIGN.canPlaceBlockAt(worldIn, pos))
        {
            if (worldIn.isRemote)
            {
                return EnumActionResult.SUCCESS;
            }
            else
            {
                pos = flag ? pos.down() : pos;

                if (facing == EnumFacing.UP)
                {
                    int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                    worldIn.setBlockState(pos, Blocks.STANDING_SIGN.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 11);
                }
                else
                {
                    worldIn.setBlockState(pos, Blocks.WALL_SIGN.getDefaultState().withProperty(BlockWallSign.FACING, facing), 11);
                }

                --stack.stackSize;
                TileEntity tileentity = worldIn.getTileEntity(pos);

                if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
                {
                    playerIn.openEditSign((TileEntitySign)tileentity);
                }

                return EnumActionResult.SUCCESS;
            }
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:ExpandedRailsMod    文件:ItemBanner.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    boolean flag = iblockstate.getBlock().isReplaceable(worldIn, pos);

    if (facing != EnumFacing.DOWN && (iblockstate.getMaterial().isSolid() || flag) && (!flag || facing == EnumFacing.UP))
    {
        pos = pos.offset(facing);

        if (playerIn.canPlayerEdit(pos, facing, stack) && Blocks.STANDING_BANNER.canPlaceBlockAt(worldIn, pos))
        {
            if (worldIn.isRemote)
            {
                return EnumActionResult.SUCCESS;
            }
            else
            {
                pos = flag ? pos.down() : pos;

                if (facing == EnumFacing.UP)
                {
                    int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
                    worldIn.setBlockState(pos, Blocks.STANDING_BANNER.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
                }
                else
                {
                    worldIn.setBlockState(pos, Blocks.WALL_BANNER.getDefaultState().withProperty(BlockWallSign.FACING, facing), 3);
                }

                --stack.stackSize;
                TileEntity tileentity = worldIn.getTileEntity(pos);

                if (tileentity instanceof TileEntityBanner)
                {
                    ((TileEntityBanner)tileentity).setItemValues(stack);
                }

                return EnumActionResult.SUCCESS;
            }
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}