Class BlockPredicatesChecker

java.lang.Object
net.minecraft.item.BlockPredicatesChecker

public class BlockPredicatesChecker extends Object
Checks if a block predicate stored inside ItemStack's NBT matches the block in a world. The predicate must be stored inside the key sub NBT of the item stack.

The result is cached to reduce cost for successive lookups on the same block.

API Note:
This is used to implement checks for restrictions specified using CanPlaceOn or CanDestroy.
Mappings:
Namespace Name
official brx
intermediary net/minecraft/class_6538
named net/minecraft/item/BlockPredicatesChecker
  • Field Details

    • BLOCK_PREDICATE

      public static final BlockPredicateArgumentType BLOCK_PREDICATE
      Mappings:
      Namespace Name Mixin selector
      official a Lbrx;a:Ler;
      intermediary field_34448 Lnet/minecraft/class_6538;field_34448:Lnet/minecraft/class_2252;
      named BLOCK_PREDICATE Lnet/minecraft/item/BlockPredicatesChecker;BLOCK_PREDICATE:Lnet/minecraft/command/argument/BlockPredicateArgumentType;
    • key

      private final String key
      Mappings:
      Namespace Name Mixin selector
      official b Lbrx;b:Ljava/lang/String;
      intermediary field_34449 Lnet/minecraft/class_6538;field_34449:Ljava/lang/String;
      named key Lnet/minecraft/item/BlockPredicatesChecker;key:Ljava/lang/String;
    • cachedPos

      Mappings:
      Namespace Name Mixin selector
      official c Lbrx;c:Lcog;
      intermediary field_34450 Lnet/minecraft/class_6538;field_34450:Lnet/minecraft/class_2694;
      named cachedPos Lnet/minecraft/item/BlockPredicatesChecker;cachedPos:Lnet/minecraft/block/pattern/CachedBlockPosition;
    • lastResult

      private boolean lastResult
      Mappings:
      Namespace Name Mixin selector
      official d Lbrx;d:Z
      intermediary field_34451 Lnet/minecraft/class_6538;field_34451:Z
      named lastResult Lnet/minecraft/item/BlockPredicatesChecker;lastResult:Z
    • nbtAware

      private boolean nbtAware
      Mappings:
      Namespace Name Mixin selector
      official e Lbrx;e:Z
      intermediary field_34452 Lnet/minecraft/class_6538;field_34452:Z
      named nbtAware Lnet/minecraft/item/BlockPredicatesChecker;nbtAware:Z
  • Constructor Details

    • BlockPredicatesChecker

      public BlockPredicatesChecker(String key)
      Parameters:
      key - the sub NBT key that stores the predicate, for example "CanPlaceOn"
      Mappings:
      Namespace Name Mixin selector
      official <init> Lbrx;<init>(Ljava/lang/String;)V
      intermediary <init> Lnet/minecraft/class_6538;<init>(Ljava/lang/String;)V
      named <init> Lnet/minecraft/item/BlockPredicatesChecker;<init>(Ljava/lang/String;)V
  • Method Details

    • canUseCache

      private static boolean canUseCache(CachedBlockPosition pos, @Nullable @Nullable CachedBlockPosition cachedPos, boolean nbtAware)
      Mappings:
      Namespace Name Mixin selector
      official a Lbrx;a(Lcog;Lcog;Z)Z
      intermediary method_38071 Lnet/minecraft/class_6538;method_38071(Lnet/minecraft/class_2694;Lnet/minecraft/class_2694;Z)Z
      named canUseCache Lnet/minecraft/item/BlockPredicatesChecker;canUseCache(Lnet/minecraft/block/pattern/CachedBlockPosition;Lnet/minecraft/block/pattern/CachedBlockPosition;Z)Z
    • check

      public boolean check(ItemStack stack, TagManager tagManager, CachedBlockPosition pos)
      Returns true if any of the predicates in the stack's NBT matched against the block at pos, false otherwise.
      Returns:
      true if any of the predicates in the stack's NBT matched against the block at pos, false otherwise
      Mappings:
      Namespace Name Mixin selector
      official a Lbrx;a(Lbue;Laht;Lcog;)Z
      intermediary method_38070 Lnet/minecraft/class_6538;method_38070(Lnet/minecraft/class_1799;Lnet/minecraft/class_5415;Lnet/minecraft/class_2694;)Z
      named check Lnet/minecraft/item/BlockPredicatesChecker;check(Lnet/minecraft/item/ItemStack;Lnet/minecraft/tag/TagManager;Lnet/minecraft/block/pattern/CachedBlockPosition;)Z