Interface IAttachmentHolder
- All Known Implementing Classes:
net.minecraft.world.entity.AgeableMob
,net.minecraft.world.entity.animal.Animal
,AttachmentHolder
,AttachmentHolder.AsField
,net.minecraft.world.level.block.entity.BlockEntity
,BlockPropertyTests.LightBlockEntity
,CustomHeadTest.CustomSkullBlockEntity
,CustomItemDisplayContextTest.ItemHangerBlockEntity
,CustomSignsTest.CustomHangingSignBlockEntity
,CustomSignsTest.CustomSignBlockEntity
,net.minecraft.world.entity.Entity
,EntityDataSerializerTest.TestEntity
,EntityRendererEventsTest.MyEntity
,EntityTests.AdaptedSpawnEntity
,EntityTests.CustomComplexSpawnEntity
,EntityTests.SimpleEntity
,FakePlayer
,FullPotsAccessorDemo.DioriteFlowerPotBlockEntity
,GameTestPlayer
,net.minecraft.world.level.block.entity.HangingSignBlockEntity
,net.minecraft.world.entity.LivingEntity
,MegaModelTest.TestBlock.Entity
,net.minecraft.world.entity.Mob
,PartEntity
,PartEntityTest.TestEntity
,PartEntityTest.TestEntityPart
,net.minecraft.world.entity.PathfinderMob
,net.minecraft.world.entity.animal.Pig
,net.minecraft.world.entity.player.Player
,net.minecraft.server.level.ServerPlayer
,net.minecraft.world.level.block.entity.SignBlockEntity
,net.minecraft.world.level.block.entity.SkullBlockEntity
public interface IAttachmentHolder
An object that can hold data attachments.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> T
getData
(Supplier<AttachmentType<T>> type) Returns the data attachment of the given type.<T> T
getData
(AttachmentType<T> type) Returns the data attachment of the given type.default <T> Optional
<T> getExistingData
(Supplier<AttachmentType<T>> type) Returns an optional possibly containing a data attachment value of the given type.default <T> Optional
<T> getExistingData
(AttachmentType<T> type) Returns an optional possibly containing a data attachment value of the given type.default <T> T
getExistingDataOrNull
(Supplier<AttachmentType<T>> type) <T> T
getExistingDataOrNull
(AttachmentType<T> type) boolean
Returnstrue
if there is any data attachments,false
otherwise.default <T> boolean
hasData
(Supplier<AttachmentType<T>> type) Returnstrue
if there is a data attachment of the give type,false
otherwise.boolean
hasData
(AttachmentType<?> type) Returnstrue
if there is a data attachment of the give type,false
otherwise.default <T> T
removeData
(Supplier<AttachmentType<T>> type) Removes the data attachment of the given type.<T> T
removeData
(AttachmentType<T> type) Removes the data attachment of the given type.default <T> T
setData
(Supplier<AttachmentType<T>> type, T data) Sets the data attachment of the given type.<T> T
setData
(AttachmentType<T> type, T data) Sets the data attachment of the given type.
-
Method Details
-
hasAttachments
boolean hasAttachments()Returnstrue
if there is any data attachments,false
otherwise. -
hasData
Returnstrue
if there is a data attachment of the give type,false
otherwise. -
hasData
Returnstrue
if there is a data attachment of the give type,false
otherwise. -
getData
Returns the data attachment of the given type.If there is no data attachment of the given type, the default value is stored in this holder and returned.
- Returns:
- the data attachment of the given type
-
getData
Returns the data attachment of the given type.If there is no data attachment of the given type, the default value is stored in this holder and returned.
- Returns:
- the data attachment of the given type
-
getExistingData
Returns an optional possibly containing a data attachment value of the given type.If there is no data attachment of the given type, an empty optional is returned.
- Returns:
- an optional possibly containing a data attachment value of the given type
-
getExistingData
Returns an optional possibly containing a data attachment value of the given type.If there is no data attachment of the given type, an empty optional is returned.
- Returns:
- an optional possibly containing a data attachment value of the given type
-
getExistingDataOrNull
- Returns:
- an existing data attachment value of the given type, or null if there is no data attachment of the given type
-
getExistingDataOrNull
- Returns:
- an existing data attachment value of the given type, or null if there is no data attachment of the given type
-
setData
Sets the data attachment of the given type.- Returns:
- the previous value for that attachment type, if any, or
null
if there was none
-
setData
Sets the data attachment of the given type.- Returns:
- the previous value for that attachment type, if any, or
null
if there was none
-
removeData
Removes the data attachment of the given type.- Returns:
- the previous value for that attachment type, if any, or
null
if there was none
-
removeData
Removes the data attachment of the given type.- Returns:
- the previous value for that attachment type, if any, or
null
if there was none
-