Java Code Examples for net.minecraft.entity.player.EntityPlayer.openEditSign()

The following are Jave code examples for showing how to use openEditSign() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: ItemSign.java   View Source Code Vote up 4 votes
/**
 * 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;
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: ItemSign.java   View Source Code Vote up 4 votes
/**
 * 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;
        }
    }
}
 
Example 3
Project: BaseClient   File: ItemSign.java   View Source Code Vote up 4 votes
/**
 * 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;
        }
    }
}
 
Example 4
Project: BaseClient   File: ItemSign.java   View Source Code Vote up 4 votes
/**
 * 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;
        }
    }
}
 
Example 5
Project: Backmemed   File: ItemSign.java   View Source Code Vote up 4 votes
/**
 * 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;
    }
}
 
Example 6
Project: CustomWorldGen   File: ItemSign.java   View Source Code Vote up 4 votes
/**
 * 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;
    }
}