Class Projectile

All Implemented Interfaces:
CommandSource, SyncedDataHolder, TraceableEntity, EntityAccess, Nameable, ScoreHolder, IAttachmentHolder, IEntityExtension, INBTSerializable<CompoundTag>
Direct Known Subclasses:
AbstractArrow, AbstractHurtingProjectile, FireworkRocketEntity, FishingHook, LlamaSpit, ShulkerBullet, ThrowableProjectile

public abstract class Projectile extends Entity implements TraceableEntity
  • Field Details

    • 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
    • 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
    • restoreFrom

      public void restoreFrom(Entity 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)
    • hitTargetOrDeflectSelf

      protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult)
    • deflect

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

      protected void onDeflection(@Nullable Entity entity, boolean deflectedByPlayer)
    • 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)
    • lerpMotion

      public void lerpMotion(double x, double y, double z)
      Updates the entity motion clientside, called by packets from the server
      Overrides:
      lerpMotion in class Entity
    • 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_entity)
      Overrides:
      getAddEntityPacket in class Entity
    • recreateFromPacket

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

      public boolean mayInteract(Level level, BlockPos pos)
      Overrides:
      mayInteract in class Entity
    • mayBreak

      public boolean mayBreak(Level 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)