Skip to content

[1.20.1] NPE - ItemBuilder#appendHoverText does not respect @Nullable in definition #578

@NotRyken

Description

@NotRyken

ItemBuilder#appendHoverText overrides the MC method Item#appendHoverText which specifies the second param (type Level) as @Nullable, but passes the param to ItemBuilder#getBlockState without a check, causing a NPE on the Level#holderLookup call.

This bug may not be triggered by any current vanilla code, but can be triggered by other mods respecting the method declaration.

public void appendHoverText(ItemStack stack, Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {

BlockState target = ItemBuilder.getBlockState(worldIn, stack);

return NbtUtils.readBlockState(level.holderLookup(Registries.BLOCK), wand.getOrCreateTag().getCompound(NBTBLOCKSTATE));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions