Package io.papermc.paper.datacomponent
Interface DataComponentView
- All Known Subinterfaces:
AbstractArrow,AbstractCow,AbstractHorse,AbstractSkeleton,AbstractVillager,AbstractWindCharge,AcaciaBoat,AcaciaChestBoat,Ageable,Allay,Ambient,Animals,AreaEffectCloud,Armadillo,ArmorStand,Arrow,Axolotl,BambooChestRaft,BambooRaft,Bat,Bee,BirchBoat,BirchChestBoat,Blaze,BlockDisplay,Boat,Bogged,Boss,Breedable,Breeze,BreezeWindCharge,Bucketable,Camel,Cat,CaveSpider,CherryBoat,CherryChestBoat,ChestBoat,ChestedHorse,Chicken,Cod,CollarColorable,CommandMinecart,ComplexEntityPart,ComplexLivingEntity,Cow,Creaking,Creature,Creeper,Damageable,DarkOakBoat,DarkOakChestBoat,DataComponentHolder,Display,Dolphin,Donkey,DragonFireball,Drowned,Egg,ElderGuardian,EnderCrystal,EnderDragon,EnderDragonPart,Enderman,Endermite,EnderPearl,EnderSignal,Enemy,Entity,Evoker,EvokerFangs,ExperienceOrb,Explosive,ExplosiveMinecart,FallingBlock,Fireball,Firework,Fish,FishHook,Flying,Fox,Frog,Ghast,Giant,GlowItemFrame,GlowSquid,Goat,Golem,Guardian,Hanging,HappyGhast,Hoglin,HopperMinecart,Horse,HumanEntity,Husk,Illager,Illusioner,Interaction,IronGolem,Item,ItemDisplay,ItemFrame,JungleBoat,JungleChestBoat,LargeFireball,Leashable,LeashHitch,LightningStrike,LingeringPotion,LivingEntity,Llama,LlamaSpit,MagmaCube,MangroveBoat,MangroveChestBoat,Marker,Minecart,Mob,Monster,Mule,MushroomCow,NPC,OakBoat,OakChestBoat,Ocelot,OminousItemSpawner,Painting,PaleOakBoat,PaleOakChestBoat,Panda,Parrot,Phantom,Pig,Piglin,PiglinAbstract,PiglinBrute,PigZombie,Pillager,Player,PolarBear,PoweredMinecart,Projectile,PufferFish,Rabbit,Raider,RangedEntity,Ravager,RideableMinecart,Salmon,SchoolableFish,Shearable,Sheep,Shulker,ShulkerBullet,Silverfish,Sittable,SizedFireball,Skeleton,SkeletonHorse,Slime,SmallFireball,Sniffer,Snowball,Snowman,SpawnerMinecart,SpectralArrow,Spellcaster,Spider,SplashPotion,SpruceBoat,SpruceChestBoat,Squid,Steerable,StorageMinecart,Stray,Strider,Tadpole,Tameable,TextDisplay,ThrowableProjectile,ThrownExpBottle,ThrownPotion,TippedArrow,TNTPrimed,TraderLlama,Trident,TropicalFish,Turtle,Vehicle,Vex,Villager,Vindicator,WanderingTrader,Warden,WaterMob,WindCharge,Witch,Wither,WitherSkeleton,WitherSkull,Wolf,Zoglin,Zombie,ZombieHorse,ZombieVillager
- All Known Implementing Classes:
ItemStack
This represents a view of a data component holder. No
methods on this interface mutate the holder.
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T> @Nullable TgetData(DataComponentType.Valued<T> type) Gets the value for the data component type on this stack.<T> @Nullable TgetDataOrDefault(DataComponentType.Valued<? extends T> type, @Nullable T fallback) Gets the value for the data component type on this holder with a fallback value.booleanhasData(DataComponentType type) Checks if the data component type is set on this holder.
-
Method Details
-
getData
Gets the value for the data component type on this stack.- Type Parameters:
T- the value type- Parameters:
type- the data component type- Returns:
- the value for the data component type, or
nullif not set or marked as removed - See Also:
-
getDataOrDefault
@Contract(value="_, !null -> !null", pure=true) @Experimental <T> @Nullable T getDataOrDefault(DataComponentType.Valued<? extends T> type, @Nullable T fallback) Gets the value for the data component type on this holder with a fallback value.- Type Parameters:
T- the value type- Parameters:
type- the data component typefallback- the fallback value if the value isn't present- Returns:
- the value for the data component type or the fallback value
-
hasData
Checks if the data component type is set on this holder.- Parameters:
type- the data component type- Returns:
trueif set,falseotherwise
-