Class EnderDragon

All Implemented Interfaces:
CommandSource, SyncedDataHolder, Attackable, EquipmentUser, Leashable, Enemy, Targeting, EntityAccess, Nameable, ScoreHolder, IAttachmentHolder, IEntityExtension, ILivingEntityExtension, INBTSerializable<CompoundTag>

public class EnderDragon extends Mob implements Enemy
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • DATA_PHASE

      public static final EntityDataAccessor<Integer> DATA_PHASE
    • CRYSTAL_DESTROY_TARGETING

      private static final TargetingConditions CRYSTAL_DESTROY_TARGETING
    • GROWL_INTERVAL_MIN

      private static final int GROWL_INTERVAL_MIN
      See Also:
    • GROWL_INTERVAL_MAX

      private static final int GROWL_INTERVAL_MAX
      See Also:
    • SITTING_ALLOWED_DAMAGE_PERCENTAGE

      private static final float SITTING_ALLOWED_DAMAGE_PERCENTAGE
      See Also:
    • DRAGON_DEATH_TIME_KEY

      private static final String DRAGON_DEATH_TIME_KEY
      See Also:
    • DRAGON_PHASE_KEY

      private static final String DRAGON_PHASE_KEY
      See Also:
    • positions

      public final double[][] positions
    • posPointer

      public int posPointer
    • subEntities

      private final EnderDragonPart[] subEntities
    • neck

      private final EnderDragonPart neck
    • body

      private final EnderDragonPart body
    • tail1

      private final EnderDragonPart tail1
    • tail2

      private final EnderDragonPart tail2
    • tail3

      private final EnderDragonPart tail3
    • wing1

      private final EnderDragonPart wing1
    • wing2

      private final EnderDragonPart wing2
    • oFlapTime

      public float oFlapTime
    • flapTime

      public float flapTime
    • inWall

      public boolean inWall
    • dragonDeathTime

      public int dragonDeathTime
    • yRotA

      public float yRotA
    • nearestCrystal

      @Nullable public EndCrystal nearestCrystal
    • dragonFight

      @Nullable private EndDragonFight dragonFight
    • fightOrigin

      private BlockPos fightOrigin
    • phaseManager

      private final EnderDragonPhaseManager phaseManager
    • growlTime

      private int growlTime
    • sittingDamageReceived

      private float sittingDamageReceived
    • nodes

      private final Node[] nodes
    • nodeAdjacency

      private final int[] nodeAdjacency
    • openSet

      private final BinaryHeap openSet
    • unlimitedLastHurtByPlayer

      @Nullable private @Nullable Player unlimitedLastHurtByPlayer
  • Constructor Details

  • Method Details

    • setId

      public void setId(int id)
      Overrides:
      setId in class Entity
    • setDragonFight

      public void setDragonFight(EndDragonFight dragonFight)
    • setFightOrigin

      public void setFightOrigin(BlockPos fightOrigin)
    • getFightOrigin

      public BlockPos getFightOrigin()
    • createAttributes

      public static AttributeSupplier.Builder createAttributes()
    • isFlapping

      public boolean isFlapping()
      Overrides:
      isFlapping in class Entity
    • onFlap

      public void onFlap()
      Overrides:
      onFlap in class Entity
    • defineSynchedData

      protected void defineSynchedData(SynchedEntityData.Builder builder)
      Overrides:
      defineSynchedData in class Mob
    • getLatencyPos

      public double[] getLatencyPos(int bufferIndexOffset, float partialTicks)
      Returns a double[3] array with movement offsets, used to calculate trailing tail/neck positions. [0] = yaw offset, [1] = y offset, [2] = unused, always 0. Parameters: buffer index offset, partial ticks.
    • aiStep

      public void aiStep()
      Overrides:
      aiStep in class Mob
    • tickPart

      private void tickPart(EnderDragonPart part, double offsetX, double offsetY, double offsetZ)
    • getHeadYOffset

      private float getHeadYOffset()
    • checkCrystals

      private void checkCrystals()
    • knockBack

      private void knockBack(ServerLevel level, List<Entity> targets)
    • hurt

      private void hurt(List<Entity> entities)
      Attacks all entities inside this list, dealing 5 hearts of damage.
    • rotWrap

      private float rotWrap(double angle)
      Simplifies the value of a number by adding/subtracting 180 to the point that the number is between -180 and 180.
    • checkWalls

      private boolean checkWalls(AABB area)
      Destroys all blocks that aren't associated with 'The End' inside the given bounding box.
    • hurt

      public boolean hurt(EnderDragonPart part, DamageSource source, float damage)
    • hurt

      public boolean hurt(DamageSource source, float amount)
      Called when the entity is attacked.
      Overrides:
      hurt in class LivingEntity
    • reallyHurt

      protected boolean reallyHurt(DamageSource damageSource, float amount)
      Provides a way to cause damage to an ender dragon.
    • kill

      public void kill()
      Overrides:
      kill in class LivingEntity
    • tickDeath

      protected void tickDeath()
      Overrides:
      tickDeath in class LivingEntity
    • findClosestNode

      public int findClosestNode()
    • findClosestNode

      public int findClosestNode(double x, double y, double z)
      Returns the index into pathPoints of the nearest PathPoint.
    • findPath

      @Nullable public Path findPath(int startIndex, int finishIndex, @Nullable Node andThen)
      Find and return a path among the circles described by pathPoints, or null if the shortest path would just be directly between the start and finish with no intermediate points. Starting with pathPoint[startIdx], it searches the neighboring points (and their neighboring points, and so on) until it reaches pathPoint[finishIdx], at which point it calls makePath to seal the deal.
    • reconstructPath

      private Path reconstructPath(Node start, Node finish)
      Create and return a new PathEntity defining a path from the start to the finish, using the connections already made by the caller, findPath.
    • addAdditionalSaveData

      public void addAdditionalSaveData(CompoundTag compound)
      Overrides:
      addAdditionalSaveData in class Mob
    • readAdditionalSaveData

      public void readAdditionalSaveData(CompoundTag compound)
      (abstract) Protected helper method to read subclass entity data from NBT.
      Overrides:
      readAdditionalSaveData in class Mob
    • checkDespawn

      public void checkDespawn()
      Overrides:
      checkDespawn in class Mob
    • getSubEntities

      public EnderDragonPart[] getSubEntities()
    • isPickable

      public boolean isPickable()
      Overrides:
      isPickable in class LivingEntity
    • getSoundSource

      public SoundSource getSoundSource()
      Overrides:
      getSoundSource in class Entity
    • getAmbientSound

      protected SoundEvent getAmbientSound()
      Overrides:
      getAmbientSound in class Mob
    • getHurtSound

      protected SoundEvent getHurtSound(DamageSource damageSource)
      Overrides:
      getHurtSound in class LivingEntity
    • getSoundVolume

      protected float getSoundVolume()
      Overrides:
      getSoundVolume in class LivingEntity
    • getHeadPartYOffset

      public float getHeadPartYOffset(int partIndex, double[] spineEndOffsets, double[] headPartOffsets)
    • getHeadLookVector

      public Vec3 getHeadLookVector(float partialTicks)
    • onCrystalDestroyed

      public void onCrystalDestroyed(EndCrystal crystal, BlockPos pos, DamageSource damageSource)
    • onSyncedDataUpdated

      public void onSyncedDataUpdated(EntityDataAccessor<?> key)
      Specified by:
      onSyncedDataUpdated in interface SyncedDataHolder
      Overrides:
      onSyncedDataUpdated in class LivingEntity
    • getPhaseManager

      public EnderDragonPhaseManager getPhaseManager()
    • getDragonFight

      @Nullable public EndDragonFight getDragonFight()
    • addEffect

      public boolean addEffect(MobEffectInstance effectInstance, @Nullable Entity entity)
      Overrides:
      addEffect in class LivingEntity
    • canRide

      protected boolean canRide(Entity entity)
      Overrides:
      canRide in class Entity
    • canUsePortal

      public boolean canUsePortal(boolean allowPassengers)
      Overrides:
      canUsePortal in class LivingEntity
    • isMultipartEntity

      public boolean isMultipartEntity()
      Description copied from interface: IEntityExtension
      This is used to specify that your entity has multiple individual parts, such as the Vanilla Ender Dragon. See EnderDragon for an example implementation.
      Specified by:
      isMultipartEntity in interface IEntityExtension
      Returns:
      true if this is a multipart entity.
    • getParts

      public PartEntity<?>[] getParts()
      Description copied from interface: IEntityExtension
      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 if IEntityExtension.isMultipartEntity() returns true. See EnderDragon for an example implementation.
      Specified by:
      getParts in interface IEntityExtension
      Returns:
      The child parts of this entity. The value to be returned here should be cached.
    • recreateFromPacket

      public void recreateFromPacket(ClientboundAddEntityPacket packet)
      Overrides:
      recreateFromPacket in class LivingEntity
    • canAttack

      public boolean canAttack(LivingEntity target)
      Overrides:
      canAttack in class LivingEntity
    • sanitizeScale

      protected float sanitizeScale(float scale)
      Overrides:
      sanitizeScale in class LivingEntity