Interface IEntityExtension
- All Superinterfaces:
INBTSerializable<CompoundTag>
- All Known Subinterfaces:
ILivingEntityExtension
- All Known Implementing Classes:
AbstractArrow,AbstractChestedHorse,AbstractClientPlayer,AbstractFish,AbstractGolem,AbstractHorse,AbstractHurtingProjectile,AbstractIllager,AbstractMinecart,AbstractMinecartContainer,AbstractPiglin,AbstractSchoolingFish,AbstractSkeleton,AbstractVillager,AbstractWindCharge,AgeableMob,Allay,AmbientCreature,Animal,AreaEffectCloud,Armadillo,ArmorStand,Arrow,Axolotl,Bat,Bee,Blaze,BlockAttachedEntity,Boat,Bogged,Breeze,BreezeWindCharge,Camel,Cat,CaveSpider,ChestBoat,Chicken,Cod,Cow,Creeper,Display,Display.BlockDisplay,Display.ItemDisplay,Display.TextDisplay,Dolphin,Donkey,DragonFireball,Drowned,ElderGuardian,EndCrystal,EnderDragon,EnderDragonPart,EnderMan,Endermite,Entity,EntityDataSerializerTest.TestEntity,EntityRendererEventsTest.MyEntity,EntityTests.AdaptedSpawnEntity,EntityTests.CustomComplexSpawnEntity,EntityTests.SimpleEntity,Evoker,EvokerFangs,ExperienceOrb,EyeOfEnder,FakePlayer,FallingBlockEntity,Fireball,FireworkRocketEntity,FishingHook,FlyingMob,Fox,Frog,GameTestPlayer,Ghast,Giant,GlowItemFrame,GlowSquid,Goat,Guardian,HangingEntity,Hoglin,Horse,Husk,Illusioner,Interaction,IronGolem,ItemEntity,ItemFrame,LargeFireball,LeashFenceKnotEntity,LightningBolt,LivingEntity,Llama,LlamaSpit,LocalPlayer,MagmaCube,Marker,Minecart,MinecartChest,MinecartCommandBlock,MinecartFurnace,MinecartHopper,MinecartSpawner,MinecartTNT,Mob,Monster,Mule,MushroomCow,Ocelot,OminousItemSpawner,Painting,Panda,Parrot,PartEntity,PartEntityTest.TestEntity,PartEntityTest.TestEntityPart,PathfinderMob,PatrollingMonster,Phantom,Pig,Piglin,PiglinBrute,Pillager,Player,PolarBear,PrimedTnt,Projectile,Pufferfish,Rabbit,Raider,Ravager,RemotePlayer,Salmon,ServerPlayer,Sheep,ShoulderRidingEntity,Shulker,ShulkerBullet,Silverfish,Skeleton,SkeletonHorse,Slime,SmallFireball,Sniffer,Snowball,SnowGolem,SpectralArrow,SpellcasterIllager,Spider,Squid,Stray,Strider,Tadpole,TamableAnimal,ThrowableItemProjectile,ThrowableProjectile,ThrownEgg,ThrownEnderpearl,ThrownExperienceBottle,ThrownPotion,ThrownTrident,TraderLlama,TropicalFish,Turtle,VehicleEntity,Vex,Villager,Vindicator,WanderingTrader,Warden,WaterAnimal,WindCharge,Witch,WitherBoss,WitherSkeleton,WitherSkull,Wolf,Zoglin,Zombie,ZombieHorse,ZombieVillager,ZombifiedPiglin
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanBeRiddenUnderFluidType(FluidType type, Entity rider) Returns whether the entity can ride in this vehicle under the fluid.default booleancanFluidExtinguish(FluidType type) Returns whether the entity can be extinguished by this fluid.default booleanReturns whether the entity can be hydrated by this fluid.default booleanIf a rider of this entity can interact with this entity.default booleanReturns whether the entity can start swimming in the fluid.default booleancanSwimInFluidType(FluidType type) Returns whether the entity can swim in the fluid.booleancanTrample(BlockState state, BlockPos pos, float fallDistance) @Nullable Collection<ItemEntity> captureDrops(@Nullable Collection<ItemEntity> captureDrops) default voidcopyAttachmentsFrom(Entity other, boolean isDeath) Copies the serialized attachments from another entity to this entity.default voiddeserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) default MobCategorygetClassification(boolean forSpawnCount) Returns The classification of this entityReturns the fluid that is on the entity's eyes.default floatReturns how much the fluid should scale the damage done to a falling entity when hitting the ground per tick.default doublegetFluidMotionScale(FluidType type) Returns how much the velocity of the fluid should be scaled by when applied to an entity.doublegetFluidTypeHeight(FluidType type) Returns the height of the fluid type in relation to the bounding box of the entity.Returns the fluid type which is the highest on the bounding box of the entity.default @Nullable PartEntity<?>[]getParts()Gets the individual sub parts that make up this entity.Returns a NBTTagCompound that can be used to store custom data for this entity.default @Nullable ItemStackgetPickedResult(HitResult target) Called when a user uses the creative pick block button on this entity.default @Nullable SoundEventgetSoundFromFluidType(FluidType type, SoundAction action) Returns a sound to play when a certain action is performed by the entity in the fluid.default booleanhasCustomOutlineRendering(Player player) Returns whether thisEntityhas custom outline rendering behavior which does not use the existing automatic outline rendering based onEntity.isCurrentlyGlowing()and the entity's team color.booleanGets whether this entity has been added to a world (for tracking).default booleanisEyeInFluidType(FluidType type) Returns whether the fluid is on the entity's eyes.booleanReturns whether the entity is in a fluid.default booleanisInFluidType(BiPredicate<FluidType, Double> predicate) Returns whether any fluid type the entity is currently in matches the specified condition.booleanisInFluidType(BiPredicate<FluidType, Double> predicate, boolean forAllTypes) Returns whether the fluid type the entity is currently in matches the specified condition.default booleanisInFluidType(FluidState state) Returns whether the entity is within the fluid type of the state.default booleanisInFluidType(FluidType type) Returns whether the entity is within the fluid type.default booleanThis is used to specify that your entity has multiple individual parts, such as the Vanilla Ender Dragon.default booleanisPushedByFluid(FluidType type) Returns whether the fluid can push an entity.voidCalled after the entity has been added to the world's ticking list.voidCalled after the entity has been removed to the world's ticking list.voidrevive()Revives an entity that has been removed from a world.private Entityself()default voidsendPairingData(ServerPlayer serverPlayer, Consumer<CustomPacketPayload> bundleBuilder) Sends the pairing data to the client.default CompoundTagserializeNBT(HolderLookup.Provider provider) default booleanUsed in model rendering to determine if the entity riding this entity should be in the 'sitting' position.
-
Method Details
-
self
-
deserializeNBT
- Specified by:
deserializeNBTin interfaceINBTSerializable<CompoundTag>
-
serializeNBT
- Specified by:
serializeNBTin interfaceINBTSerializable<CompoundTag>
-
captureDrops
-
captureDrops
-
getPersistentData
CompoundTag getPersistentData()Returns a NBTTagCompound that can be used to store custom data for this entity. It will be written, and read from disc, so it persists over world saves.- Returns:
- A NBTTagCompound
-
shouldRiderSit
default boolean shouldRiderSit()Used in model rendering to determine if the entity riding this entity should be in the 'sitting' position.- Returns:
- false to prevent an entity that is mounted to this entity from displaying the 'sitting' animation.
-
getPickedResult
Called when a user uses the creative pick block button on this entity.- Parameters:
target- The full target the player is looking at- Returns:
- A ItemStack to add to the player's inventory, null ItemStack if nothing should be added.
-
canRiderInteract
default boolean canRiderInteract()If a rider of this entity can interact with this entity. Should return true on the ridden entity if so.- Returns:
- if the entity can be interacted with from a rider
-
canBeRiddenUnderFluidType
Returns whether the entity can ride in this vehicle under the fluid.- Parameters:
type- the type of the fluidrider- the entity riding the vehicle- Returns:
trueif the vehicle can be ridden in under this fluid,falseotherwise
-
canTrample
- Parameters:
pos- The block posfallDistance- The fall distance- Returns:
trueif this entity can trample,falseotherwise
-
getClassification
Returns The classification of this entity- Parameters:
forSpawnCount- If this is being invoked to check spawn count caps.- Returns:
- If the creature is of the type provided
-
isAddedToWorld
boolean isAddedToWorld()Gets whether this entity has been added to a world (for tracking). Specifically between the times when an entity is added to a world and the entity being removed from the world's tracked lists.- Returns:
- True if this entity is being tracked by a world
-
onAddedToWorld
void onAddedToWorld()Called after the entity has been added to the world's ticking list. Can be overriden, but needs to call super to prevent MC-136995. -
onRemovedFromWorld
void onRemovedFromWorld()Called after the entity has been removed to the world's ticking list. Can be overriden, but needs to call super to prevent MC-136995. -
revive
void revive()Revives an entity that has been removed from a world. Used as replacement for entity.removed = true. Having it as a function allows the entity to react to being revived. -
isMultipartEntity
default boolean isMultipartEntity()This is used to specify that your entity has multiple individual parts, such as the Vanilla Ender Dragon. SeeEnderDragonfor an example implementation.- Returns:
- true if this is a multipart entity.
-
getParts
Gets the individual sub parts that make up this entity. The entities returned by this method are NOT saved to the world in nay way, they exist as an extension of their host entity. The child entity does not track its server-side(or client-side) counterpart, and the host entity is responsible for moving and managing these children. Only used ifisMultipartEntity()returns true. SeeEnderDragonfor an example implementation.- Returns:
- The child parts of this entity. The value to be returned here should be cached.
-
getFluidTypeHeight
Returns the height of the fluid type in relation to the bounding box of the entity. If the entity is not in the fluid type, then0is returned.- Parameters:
type- the type of the fluid- Returns:
- the height of the fluid compared to the entity
-
getMaxHeightFluidType
FluidType getMaxHeightFluidType()Returns the fluid type which is the highest on the bounding box of the entity.- Returns:
- the fluid type which is the highest on the bounding box of the entity
-
isInFluidType
Returns whether the entity is within the fluid type of the state.- Parameters:
state- the state of the fluid- Returns:
trueif the entity is within the fluid type of the state,falseotherwise
-
isInFluidType
Returns whether the entity is within the fluid type.- Parameters:
type- the type of the fluid- Returns:
trueif the entity is within the fluid type,falseotherwise
-
isInFluidType
Returns whether any fluid type the entity is currently in matches the specified condition.- Parameters:
predicate- a test taking in the fluid type and its height- Returns:
trueif a fluid type meets the condition,falseotherwise
-
isInFluidType
Returns whether the fluid type the entity is currently in matches the specified condition.- Parameters:
predicate- a test taking in the fluid type and its heightforAllTypes-trueif all fluid types should match the condition instead of at least one- Returns:
trueif a fluid type meets the condition,falseotherwise
-
isInFluidType
boolean isInFluidType()Returns whether the entity is in a fluid.- Returns:
trueif the entity is in a fluid,falseotherwise
-
getEyeInFluidType
FluidType getEyeInFluidType()Returns the fluid that is on the entity's eyes.- Returns:
- the fluid that is on the entity's eyes
-
isEyeInFluidType
Returns whether the fluid is on the entity's eyes.- Returns:
trueif the fluid is on the entity's eyes,falseotherwise
-
canStartSwimming
default boolean canStartSwimming()Returns whether the entity can start swimming in the fluid.- Returns:
trueif the entity can start swimming,falseotherwise
-
getFluidMotionScale
Returns how much the velocity of the fluid should be scaled by when applied to an entity.- Parameters:
type- the type of the fluid- Returns:
- a scalar to multiply to the fluid velocity
-
isPushedByFluid
Returns whether the fluid can push an entity.- Parameters:
type- the type of the fluid- Returns:
trueif the entity can be pushed by the fluid,falseotherwise
-
canSwimInFluidType
Returns whether the entity can swim in the fluid.- Parameters:
type- the type of the fluid- Returns:
trueif the entity can swim in the fluid,falseotherwise
-
canFluidExtinguish
Returns whether the entity can be extinguished by this fluid.- Parameters:
type- the type of the fluid- Returns:
trueif the entity can be extinguished,falseotherwise
-
getFluidFallDistanceModifier
Returns how much the fluid should scale the damage done to a falling entity when hitting the ground per tick.Implementation: If the entity is in many fluids, the smallest modifier is applied.
- Parameters:
type- the type of the fluid- Returns:
- a scalar to multiply to the fall damage
-
canHydrateInFluidType
Returns whether the entity can be hydrated by this fluid.Hydration is an arbitrary word which depends on the entity.
- Parameters:
type- the type of the fluid- Returns:
trueif the entity can be hydrated,falseotherwise
-
getSoundFromFluidType
Returns a sound to play when a certain action is performed by the entity in the fluid. If no sound is present, then the sound will benull.- Parameters:
type- the type of the fluidaction- the action being performed- Returns:
- the sound to play when performing the action
-
hasCustomOutlineRendering
Returns whether thisEntityhas custom outline rendering behavior which does not use the existing automatic outline rendering based onEntity.isCurrentlyGlowing()and the entity's team color.- Parameters:
player- the local player currently viewing thisEntity- Returns:
trueto enable outline processing
-
sendPairingData
default void sendPairingData(ServerPlayer serverPlayer, Consumer<CustomPacketPayload> bundleBuilder) Sends the pairing data to the client.- Parameters:
serverPlayer- The player to send the data to.bundleBuilder- Callback to add a custom payload to the packet.
-
copyAttachmentsFrom
Copies the serialized attachments from another entity to this entity.- Parameters:
other- the entity that attachments should be copied fromisDeath- iftrue, only attachments withAttachmentType.Builder.copyOnDeath()set are copied; iffalse, all serializable attachments are copied.
-