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
CanPlaceOnorCanDestroy. - Mappings:
Namespace Name official cdfintermediary net/minecraft/class_6538named net/minecraft/item/BlockPredicatesChecker
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate @Nullable CachedBlockPositionprivate final Stringprivate booleanprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleancanUseCache(CachedBlockPosition pos, @Nullable CachedBlockPosition cachedPos, boolean nbtAware) booleancheck(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 aLcdf;a:Ljava/lang/String;intermediary field_34449Lnet/minecraft/class_6538;field_34449:Ljava/lang/String;named keyLnet/minecraft/item/BlockPredicatesChecker;key:Ljava/lang/String;
-
cachedPos
- Mappings:
Namespace Name Mixin selector official bLcdf;b:Ldcc;intermediary field_34450Lnet/minecraft/class_6538;field_34450:Lnet/minecraft/class_2694;named cachedPosLnet/minecraft/item/BlockPredicatesChecker;cachedPos:Lnet/minecraft/block/pattern/CachedBlockPosition;
-
lastResult
private boolean lastResult- Mappings:
Namespace Name Mixin selector official cLcdf;c:Zintermediary field_34451Lnet/minecraft/class_6538;field_34451:Znamed lastResultLnet/minecraft/item/BlockPredicatesChecker;lastResult:Z
-
nbtAware
private boolean nbtAware- Mappings:
Namespace Name Mixin selector official dLcdf;d:Zintermediary field_34452Lnet/minecraft/class_6538;field_34452:Znamed nbtAwareLnet/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;)Vintermediary <init>Lnet/minecraft/class_6538;<init>(Ljava/lang/String;)Vnamed <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 aLcdf;a(Ldcc;Ldcc;Z)Zintermediary method_38071Lnet/minecraft/class_6538;method_38071(Lnet/minecraft/class_2694;Lnet/minecraft/class_2694;Z)Znamed canUseCacheLnet/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 aLcdf;a(Lcfx;Lhr;Ldcc;)Zintermediary method_38070Lnet/minecraft/class_6538;method_38070(Lnet/minecraft/class_1799;Lnet/minecraft/class_2378;Lnet/minecraft/class_2694;)Znamed checkLnet/minecraft/item/BlockPredicatesChecker;check(Lnet/minecraft/item/ItemStack;Lnet/minecraft/registry/Registry;Lnet/minecraft/block/pattern/CachedBlockPosition;)Z
-