Search in sources :

Example 1 with IDocumentedBlock

use of WayofTime.bloodmagic.iface.IDocumentedBlock in project BloodMagic by WayofTime.

the class ItemSanguineBook method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (world.isRemote)
        return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
    IBlockState hitState = world.getBlockState(pos);
    if (player.isSneaking()) {
        if (hitState.getBlock() instanceof IDocumentedBlock) {
            trySetDisplayedTier(world, pos);
            IDocumentedBlock documentedBlock = (IDocumentedBlock) hitState.getBlock();
            List<ITextComponent> docs = documentedBlock.getDocumentation(player, world, pos, hitState);
            if (!docs.isEmpty()) {
                ChatUtil.sendNoSpam(player, docs.toArray(new ITextComponent[docs.size()]));
                return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
            }
        }
    }
    return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IDocumentedBlock(WayofTime.bloodmagic.iface.IDocumentedBlock) ITextComponent(net.minecraft.util.text.ITextComponent)

Aggregations

IDocumentedBlock (WayofTime.bloodmagic.iface.IDocumentedBlock)1 IBlockState (net.minecraft.block.state.IBlockState)1 ITextComponent (net.minecraft.util.text.ITextComponent)1