mojira.dev
MCPE-232074

ItemStack.matches throws erroneous content log error when checking against a block item

The bug

ItemStack.matches checks if the given item matches the provided identifier. When the given item is a block item and the provided identifier is not a block, it should simply return false. However, it also currently produces a content log error:

[Json][error]-Unknown block during Deferred BlockDescriptor resolution: <identifier>

How to reproduce

  1. Download and open the attached world

  2. Ensure content logs are enabled in creator settings

  3. Select the dirt block in your inventory

Expected results

Nothing should happen

Observed results

Content log error appears

Notes

The relevant scripting code is provided here:

import { world } from "@minecraft/server"

world.afterEvents.playerHotbarSelectedSlotChange.subscribe(e => {
   if (e.itemStack !== undefined && e.itemStack.matches("minecraft:diamond")) {
      world.sendMessage("diamond");
   }
});

Attachments

Comments 3

Could you please provide a video showcasing the issue?

tryashtar

(Unassigned)

1518973

Confirmed

Windows

1.21.130.28 Preview, 1.21.123 Hotfix

Retrieved