Package net.minecraft.item
Class BlockPredicatesChecker
java.lang.Object
net.minecraft.item.BlockPredicatesChecker
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
orCanDestroy
. - Mappings:
Namespace Name official brq
intermediary net/minecraft/class_6538
named net/minecraft/item/BlockPredicatesChecker
-
Field Summary
Modifier and TypeFieldDescriptionstatic final BlockPredicateArgumentType
private @Nullable CachedBlockPosition
private final String
private boolean
private boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
canUseCache
(CachedBlockPosition pos, @Nullable CachedBlockPosition cachedPos, boolean nbtAware) boolean
check
(ItemStack stack, TagManager tagManager, CachedBlockPosition pos) Returns true if any of the predicates in thestack
's NBT matched against the block atpos
, false otherwise.
-
Field Details
-
BLOCK_PREDICATE
- Mappings:
Namespace Name Mixin selector official a
Lbrq;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
- Mappings:
Namespace Name Mixin selector official b
Lbrq;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
Lbrq;c:Lcnz;
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
Lbrq;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
Lbrq;e:Z
intermediary field_34452
Lnet/minecraft/class_6538;field_34452:Z
named nbtAware
Lnet/minecraft/item/BlockPredicatesChecker;nbtAware:Z
-
-
Constructor Details
-
BlockPredicatesChecker
- Parameters:
key
- the sub NBT key that stores the predicate, for example"CanPlaceOn"
- Mappings:
Namespace Name Mixin selector official <init>
Lbrq;<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
Lbrq;a(Lcnz;Lcnz;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
Returns true if any of the predicates in thestack
's NBT matched against the block atpos
, false otherwise.- Returns:
- true if any of the predicates in the
stack
's NBT matched against the block atpos
, false otherwise - Mappings:
Namespace Name Mixin selector official a
Lbrq;a(Lbtx;Lahn;Lcnz;)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
-