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 cdf
intermediary net/minecraft/class_6538
named net/minecraft/item/BlockPredicatesChecker
-
Field Summary
Modifier and TypeFieldDescriptionprivate @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, Registry<Block> blockRegistry, CachedBlockPosition pos) Returns true if any of the predicates in thestack
's NBT matched against the block atpos
, false otherwise.
-
Field Details
-
key
- Mappings:
Namespace Name Mixin selector official a
Lcdf;a: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 b
Lcdf;b:Ldbu;
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 c
Lcdf;c: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 d
Lcdf;d: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>
Lcdf;<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
Lcdf;a(Ldbu;Ldbu;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
Lcdf;a(Lcfv;Lhq;Ldbu;)Z
intermediary method_38070
Lnet/minecraft/class_6538;method_38070(Lnet/minecraft/class_1799;Lnet/minecraft/class_2378;Lnet/minecraft/class_2694;)Z
named check
Lnet/minecraft/item/BlockPredicatesChecker;check(Lnet/minecraft/item/ItemStack;Lnet/minecraft/registry/Registry;Lnet/minecraft/block/pattern/CachedBlockPosition;)Z
-