Class Projectile

All Implemented Interfaces:
DataComponentGetter, SyncedDataHolder, TraceableEntity, EntityAccess, UniquelyIdentifyable, Nameable, ScoreHolder, IAttachmentHolder, IEntityExtension
Direct Known Subclasses:
AbstractArrow, AbstractHurtingProjectile, FireworkRocketEntity, FishingHook, LlamaSpit, ShulkerBullet, ThrowableProjectile

public abstract class Projectile extends Entity implements TraceableEntity
  • Field Details

    • DEFAULT_LEFT_OWNER

      private static final boolean DEFAULT_LEFT_OWNER
      See Also:
    • DEFAULT_HAS_BEEN_SHOT

      private static final boolean DEFAULT_HAS_BEEN_SHOT
      See Also:
    • ownerUUID

      @Nullable private UUID ownerUUID
    • cachedOwner

      @Nullable private Entity cachedOwner
    • leftOwner

      private boolean leftOwner
    • hasBeenShot

      private boolean hasBeenShot
    • lastDeflectedBy

      @Nullable private Entity lastDeflectedBy
  • Constructor Details

  • Method Details

    • setOwner

      public void setOwner(@Nullable Entity owner)
    • getOwner

      @Nullable public Entity getOwner()
      Specified by:
      getOwner in interface TraceableEntity
    • findOwner

      @Nullable protected Entity findOwner(UUID entityUuid)
    • getEffectSource

      public Entity getEffectSource()
    • addAdditionalSaveData

      protected void addAdditionalSaveData(CompoundTag compound)
      Specified by:
      addAdditionalSaveData in class Entity
    • ownedBy

      protected boolean ownedBy(Entity entity)
    • readAdditionalSaveData

      protected void readAdditionalSaveData(CompoundTag compound)
      (abstract) Protected helper method to read subclass entity data from NBT.
      Specified by:
      readAdditionalSaveData in class Entity
    • setOwnerThroughUUID

      protected void setOwnerThroughUUID(@Nullable UUID uuid)
    • restoreFrom

      public void restoreFrom(Entity p_305838_)
      Description copied from class: Entity
      Prepares this entity in new dimension by copying NBT data from entity in old dimension
      Overrides:
      restoreFrom in class Entity
    • tick

      public void tick()
      Overrides:
      tick in class Entity
    • checkLeftOwner

      private boolean checkLeftOwner()
    • getMovementToShoot

      public Vec3 getMovementToShoot(double x, double y, double z, float velocity, float inaccuracy)
    • shoot

      public void shoot(double x, double y, double z, float velocity, float inaccuracy)
      Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
    • shootFromRotation

      public void shootFromRotation(Entity shooter, float x, float y, float z, float velocity, float inaccuracy)
    • onAboveBubbleColumn

      public void onAboveBubbleColumn(boolean p_400117_, BlockPos p_400267_)
      Overrides:
      onAboveBubbleColumn in class Entity
    • onInsideBubbleColumn

      public void onInsideBubbleColumn(boolean p_399932_)
      Overrides:
      onInsideBubbleColumn in class Entity
    • spawnProjectileFromRotation

      public static <T extends Projectile> T spawnProjectileFromRotation(Projectile.ProjectileFactory<T> factory, ServerLevel level, ItemStack spawnedFrom, LivingEntity owner, float z, float velocity, float innaccuracy)
    • spawnProjectileUsingShoot

      public static <T extends Projectile> T spawnProjectileUsingShoot(Projectile.ProjectileFactory<T> factory, ServerLevel level, ItemStack spawnedFrom, LivingEntity owner, double x, double y, double z, float velocity, float inaccuracy)
    • spawnProjectileUsingShoot

      public static <T extends Projectile> T spawnProjectileUsingShoot(T projectile, ServerLevel level, ItemStack spawnedFrom, double x, double y, double z, float velocity, float inaccuracy)
    • spawnProjectile

      public static <T extends Projectile> T spawnProjectile(T projectile, ServerLevel level, ItemStack spawnedFrom)
    • spawnProjectile

      public static <T extends Projectile> T spawnProjectile(T projectile, ServerLevel level, ItemStack stack, Consumer<T> adapter)
    • applyOnProjectileSpawned

      public void applyOnProjectileSpawned(ServerLevel level, ItemStack spawnedFrom)
    • hitTargetOrDeflectSelf

      protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult)
    • shouldBounceOnWorldBorder

      protected boolean shouldBounceOnWorldBorder()
    • deflect

      public boolean deflect(ProjectileDeflection deflection, @Nullable Entity entity, @Nullable Entity owner, boolean deflectedByPlayer)
    • onDeflection

      protected void onDeflection(@Nullable Entity entity, boolean deflectedByPlayer)
    • onItemBreak

      protected void onItemBreak(Item item)
    • onHit

      protected void onHit(HitResult result)
      Called when this EntityFireball hits a block or entity.
    • onHitEntity

      protected void onHitEntity(EntityHitResult result)
      Called when the arrow hits an entity
    • onHitBlock

      protected void onHitBlock(BlockHitResult result)
    • canHitEntity

      protected boolean canHitEntity(Entity target)
    • updateRotation

      protected void updateRotation()
    • lerpRotation

      protected static float lerpRotation(float currentRotation, float targetRotation)
    • getAddEntityPacket

      public Packet<ClientGamePacketListener> getAddEntityPacket(ServerEntity p_352459_)
      Overrides:
      getAddEntityPacket in class Entity
    • recreateFromPacket

      public void recreateFromPacket(ClientboundAddEntityPacket p_150170_)
      Overrides:
      recreateFromPacket in class Entity
    • mayInteract

      public boolean mayInteract(ServerLevel p_376318_, BlockPos p_150168_)
      Overrides:
      mayInteract in class Entity
    • mayBreak

      public boolean mayBreak(ServerLevel level)
    • isPickable

      public boolean isPickable()
      Overrides:
      isPickable in class Entity
    • getPickRadius

      public float getPickRadius()
      Overrides:
      getPickRadius in class Entity
    • calculateHorizontalHurtKnockbackDirection

      public it.unimi.dsi.fastutil.doubles.DoubleDoubleImmutablePair calculateHorizontalHurtKnockbackDirection(LivingEntity entity, DamageSource damageSource)
    • getDimensionChangingDelay

      public int getDimensionChangingDelay()
      Overrides:
      getDimensionChangingDelay in class Entity
    • hurtServer

      public boolean hurtServer(ServerLevel p_376191_, DamageSource p_376581_, float p_376638_)
      Specified by:
      hurtServer in class Entity