Class ProjectileEntity

java.lang.Object
net.minecraft.entity.Entity
net.minecraft.entity.projectile.ProjectileEntity
All Implemented Interfaces:
DataTracked, Ownable, ScoreHolder, CommandOutput, Nameable, EntityLike
Direct Known Subclasses:
ExplosiveProjectileEntity, FireworkRocketEntity, FishingBobberEntity, LlamaSpitEntity, PersistentProjectileEntity, ShulkerBulletEntity, ThrownEntity

public abstract class ProjectileEntity extends Entity implements Ownable
Mappings:
Namespace Name
named net/minecraft/entity/projectile/ProjectileEntity
intermediary net/minecraft/class_1676
official cnp
  • Field Details

    • ownerUuid

      @Nullable private @Nullable UUID ownerUuid
      Mappings:
      Namespace Name Mixin selector
      named ownerUuid Lnet/minecraft/entity/projectile/ProjectileEntity;ownerUuid:Ljava/util/UUID;
      intermediary field_22478 Lnet/minecraft/class_1676;field_22478:Ljava/util/UUID;
      official b Lcnp;b:Ljava/util/UUID;
    • owner

      @Nullable private @Nullable Entity owner
      Mappings:
      Namespace Name Mixin selector
      named owner Lnet/minecraft/entity/projectile/ProjectileEntity;owner:Lnet/minecraft/entity/Entity;
      intermediary field_33399 Lnet/minecraft/class_1676;field_33399:Lnet/minecraft/class_1297;
      official c Lcnp;c:Lbsr;
    • leftOwner

      private boolean leftOwner
      Mappings:
      Namespace Name Mixin selector
      named leftOwner Lnet/minecraft/entity/projectile/ProjectileEntity;leftOwner:Z
      intermediary field_23740 Lnet/minecraft/class_1676;field_23740:Z
      official d Lcnp;d:Z
    • shot

      private boolean shot
      Mappings:
      Namespace Name Mixin selector
      named shot Lnet/minecraft/entity/projectile/ProjectileEntity;shot:Z
      intermediary field_28646 Lnet/minecraft/class_1676;field_28646:Z
      official e Lcnp;e:Z
    • lastDeflectedEntity

      @Nullable private @Nullable Entity lastDeflectedEntity
      Mappings:
      Namespace Name Mixin selector
      named lastDeflectedEntity Lnet/minecraft/entity/projectile/ProjectileEntity;lastDeflectedEntity:Lnet/minecraft/entity/Entity;
      intermediary field_51621 Lnet/minecraft/class_1676;field_51621:Lnet/minecraft/class_1297;
      official f Lcnp;f:Lbsr;
  • Constructor Details

    • ProjectileEntity

      ProjectileEntity(EntityType<? extends ProjectileEntity> type, World world)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/entity/Entity;<init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V
      intermediary <init> Lnet/minecraft/class_1297;<init>(Lnet/minecraft/class_1299;Lnet/minecraft/class_1937;)V
      official <init> Lbsr;<init>(Lbsx;Ldcw;)V
  • Method Details

    • setOwner

      public void setOwner(@Nullable @Nullable Entity entity)
      Mappings:
      Namespace Name Mixin selector
      named setOwner Lnet/minecraft/entity/projectile/ProjectileEntity;setOwner(Lnet/minecraft/entity/Entity;)V
      intermediary method_7432 Lnet/minecraft/class_1676;method_7432(Lnet/minecraft/class_1297;)V
      official c Lcnp;c(Lbsr;)V
    • getOwner

      @Nullable public @Nullable Entity getOwner()
      Specified by:
      getOwner in interface Ownable
      Mappings:
      Namespace Name Mixin selector
      named getOwner Lnet/minecraft/entity/Ownable;getOwner()Lnet/minecraft/entity/Entity;
      intermediary method_24921 Lnet/minecraft/class_8046;method_24921()Lnet/minecraft/class_1297;
      official s Lbun;s()Lbsr;
    • getEffectCause

      public Entity getEffectCause()
      Returns the cause entity of any effect applied by this projectile. If this projectile has an owner, the effect is attributed to the owner; otherwise, it is attributed to this projectile itself.
      Returns:
      the cause entity of any effect applied by this projectile
      Mappings:
      Namespace Name Mixin selector
      named getEffectCause Lnet/minecraft/entity/projectile/ProjectileEntity;getEffectCause()Lnet/minecraft/entity/Entity;
      intermediary method_37225 Lnet/minecraft/class_1676;method_37225()Lnet/minecraft/class_1297;
      official H Lcnp;H()Lbsr;
    • writeCustomDataToNbt

      protected void writeCustomDataToNbt(NbtCompound nbt)
      Writes custom data to nbt. Subclasses have to implement this.

      NBT is a storage format; therefore, a data from NBT is loaded to an entity instance's fields, which are used for other operations instead of the NBT. The data is written back to NBT when saving the entity.

      Specified by:
      writeCustomDataToNbt in class Entity
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named writeCustomDataToNbt Lnet/minecraft/entity/Entity;writeCustomDataToNbt(Lnet/minecraft/nbt/NbtCompound;)V
      intermediary method_5652 Lnet/minecraft/class_1297;method_5652(Lnet/minecraft/class_2487;)V
      official b Lbsr;b(Lub;)V
    • isOwner

      protected boolean isOwner(Entity entity)
      Mappings:
      Namespace Name Mixin selector
      named isOwner Lnet/minecraft/entity/projectile/ProjectileEntity;isOwner(Lnet/minecraft/entity/Entity;)Z
      intermediary method_34714 Lnet/minecraft/class_1676;method_34714(Lnet/minecraft/class_1297;)Z
      official e Lcnp;e(Lbsr;)Z
    • readCustomDataFromNbt

      protected void readCustomDataFromNbt(NbtCompound nbt)
      Reads custom data from nbt. Subclasses have to implement this.

      NBT is a storage format; therefore, a data from NBT is loaded to an entity instance's fields, which are used for other operations instead of the NBT. The data is written back to NBT when saving the entity.

      nbt might not have all expected keys, or might have a key whose value does not meet the requirement (such as the type or the range). This method should fall back to a reasonable default value instead of throwing an exception.

      Specified by:
      readCustomDataFromNbt in class Entity
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named readCustomDataFromNbt Lnet/minecraft/entity/Entity;readCustomDataFromNbt(Lnet/minecraft/nbt/NbtCompound;)V
      intermediary method_5749 Lnet/minecraft/class_1297;method_5749(Lnet/minecraft/class_2487;)V
      official a Lbsr;a(Lub;)V
    • copyFrom

      public void copyFrom(Entity original)
      Copies serializable data and nether portal data from original.
      Overrides:
      copyFrom in class Entity
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named copyFrom Lnet/minecraft/entity/Entity;copyFrom(Lnet/minecraft/entity/Entity;)V
      intermediary method_5878 Lnet/minecraft/class_1297;method_5878(Lnet/minecraft/class_1297;)V
      official w Lbsr;w(Lbsr;)V
    • tick

      public void tick()
      Ticks this entity.
      Overrides:
      tick in class Entity
      See Also:
      API Note:
      This can be overridden to add additional logics. super.tick(); should be called in those cases.
      Implementation Note:
      By default, this delegates all logics to Entity.baseTick().
      Mappings:
      Namespace Name Mixin selector
      named tick Lnet/minecraft/entity/Entity;tick()V
      intermediary method_5773 Lnet/minecraft/class_1297;method_5773()V
      official l Lbsr;l()V
    • shouldLeaveOwner

      private boolean shouldLeaveOwner()
      Mappings:
      Namespace Name Mixin selector
      named shouldLeaveOwner Lnet/minecraft/entity/projectile/ProjectileEntity;shouldLeaveOwner()Z
      intermediary method_26961 Lnet/minecraft/class_1676;method_26961()Z
      official t Lcnp;t()Z
    • calculateVelocity

      public Vec3d calculateVelocity(double x, double y, double z, float power, float uncertainty)
      Mappings:
      Namespace Name Mixin selector
      named calculateVelocity Lnet/minecraft/entity/projectile/ProjectileEntity;calculateVelocity(DDDFF)Lnet/minecraft/util/math/Vec3d;
      intermediary method_58645 Lnet/minecraft/class_1676;method_58645(DDDFF)Lnet/minecraft/class_243;
      official d Lcnp;d(DDDFF)Lexc;
    • setVelocity

      public void setVelocity(double x, double y, double z, float power, float uncertainty)
      Sets velocity and updates rotation accordingly.

      The velocity and rotation will be set to the same direction.

      The direction is calculated as follows: Based on the direction vector (x, y, z), a random vector is added, then multiplied by the speed.

      Parameters:
      x - the X component of the direction vector
      y - the Y component of the direction vector
      z - the Z component of the direction vector
      power - the speed
      uncertainty - the fuzziness added to the direction; player usages have 1.0 and other mobs/tools have higher values; some mobs have difficulty-adjusted values
      Mappings:
      Namespace Name Mixin selector
      named setVelocity Lnet/minecraft/entity/projectile/ProjectileEntity;setVelocity(DDDFF)V
      intermediary method_7485 Lnet/minecraft/class_1676;method_7485(DDDFF)V
      official c Lcnp;c(DDDFF)V
    • setVelocity

      public void setVelocity(Entity shooter, float pitch, float yaw, float roll, float speed, float divergence)
      Sets velocity and updates rotation accordingly.
      Parameters:
      shooter - the entity who shot this projectile; used to add the shooter's velocity to this projectile
      pitch - the pitch
      yaw - the yaw
      roll - the roll
      speed - the speed
      divergence - the fuzziness added to the direction; player usages have 1.0 and other mobs/tools have higher values; some mobs have difficulty-adjusted values
      Mappings:
      Namespace Name Mixin selector
      named setVelocity Lnet/minecraft/entity/projectile/ProjectileEntity;setVelocity(Lnet/minecraft/entity/Entity;FFFFF)V
      intermediary method_24919 Lnet/minecraft/class_1676;method_24919(Lnet/minecraft/class_1297;FFFFF)V
      official a Lcnp;a(Lbsr;FFFFF)V
    • hitOrDeflect

      protected ProjectileDeflection hitOrDeflect(HitResult hitResult)
      Mappings:
      Namespace Name Mixin selector
      named hitOrDeflect Lnet/minecraft/entity/projectile/ProjectileEntity;hitOrDeflect(Lnet/minecraft/util/hit/HitResult;)Lnet/minecraft/entity/ProjectileDeflection;
      intermediary method_59860 Lnet/minecraft/class_1676;method_59860(Lnet/minecraft/class_239;)Lnet/minecraft/class_9109;
      official b Lcnp;b(Lexa;)Lcnq;
    • deflect

      public boolean deflect(ProjectileDeflection deflection, @Nullable @Nullable Entity deflector, @Nullable @Nullable Entity owner, boolean fromAttack)
      Mappings:
      Namespace Name Mixin selector
      named deflect Lnet/minecraft/entity/projectile/ProjectileEntity;deflect(Lnet/minecraft/entity/ProjectileDeflection;Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/Entity;Z)Z
      intermediary method_59859 Lnet/minecraft/class_1676;method_59859(Lnet/minecraft/class_9109;Lnet/minecraft/class_1297;Lnet/minecraft/class_1297;Z)Z
      official a Lcnp;a(Lcnq;Lbsr;Lbsr;Z)Z
    • onDeflected

      protected void onDeflected(@Nullable @Nullable Entity deflector, boolean fromAttack)
      Mappings:
      Namespace Name Mixin selector
      named onDeflected Lnet/minecraft/entity/projectile/ProjectileEntity;onDeflected(Lnet/minecraft/entity/Entity;Z)V
      intermediary method_59525 Lnet/minecraft/class_1676;method_59525(Lnet/minecraft/class_1297;Z)V
      official b Lcnp;b(Lbsr;Z)V
    • onCollision

      protected void onCollision(HitResult hitResult)
      Mappings:
      Namespace Name Mixin selector
      named onCollision Lnet/minecraft/entity/projectile/ProjectileEntity;onCollision(Lnet/minecraft/util/hit/HitResult;)V
      intermediary method_7488 Lnet/minecraft/class_1676;method_7488(Lnet/minecraft/class_239;)V
      official a Lcnp;a(Lexa;)V
    • onEntityHit

      protected void onEntityHit(EntityHitResult entityHitResult)
      Mappings:
      Namespace Name Mixin selector
      named onEntityHit Lnet/minecraft/entity/projectile/ProjectileEntity;onEntityHit(Lnet/minecraft/util/hit/EntityHitResult;)V
      intermediary method_7454 Lnet/minecraft/class_1676;method_7454(Lnet/minecraft/class_3966;)V
      official a Lcnp;a(Lewz;)V
    • onBlockHit

      protected void onBlockHit(BlockHitResult blockHitResult)
      Mappings:
      Namespace Name Mixin selector
      named onBlockHit Lnet/minecraft/entity/projectile/ProjectileEntity;onBlockHit(Lnet/minecraft/util/hit/BlockHitResult;)V
      intermediary method_24920 Lnet/minecraft/class_1676;method_24920(Lnet/minecraft/class_3965;)V
      official a Lcnp;a(Lewy;)V
    • setVelocityClient

      public void setVelocityClient(double x, double y, double z)
      Overrides:
      setVelocityClient in class Entity
      Mappings:
      Namespace Name Mixin selector
      named setVelocityClient Lnet/minecraft/entity/Entity;setVelocityClient(DDD)V
      intermediary method_5750 Lnet/minecraft/class_1297;method_5750(DDD)V
      official l Lbsr;l(DDD)V
    • canHit

      protected boolean canHit(Entity entity)
      Mappings:
      Namespace Name Mixin selector
      named canHit Lnet/minecraft/entity/projectile/ProjectileEntity;canHit(Lnet/minecraft/entity/Entity;)Z
      intermediary method_26958 Lnet/minecraft/class_1676;method_26958(Lnet/minecraft/class_1297;)Z
      official b Lcnp;b(Lbsr;)Z
    • updateRotation

      protected void updateRotation()
      Mappings:
      Namespace Name Mixin selector
      named updateRotation Lnet/minecraft/entity/projectile/ProjectileEntity;updateRotation()V
      intermediary method_26962 Lnet/minecraft/class_1676;method_26962()V
      official I Lcnp;I()V
    • updateRotation

      protected static float updateRotation(float prevRot, float newRot)
      Mappings:
      Namespace Name Mixin selector
      named updateRotation Lnet/minecraft/entity/projectile/ProjectileEntity;updateRotation(FF)F
      intermediary method_26960 Lnet/minecraft/class_1676;method_26960(FF)F
      official e Lcnp;e(FF)F
    • createSpawnPacket

      public Packet<ClientPlayPacketListener> createSpawnPacket(EntityTrackerEntry entityTrackerEntry)
      Returns a packet to notify the clients of the entity's spawning.
      Overrides:
      createSpawnPacket in class Entity
      Returns:
      a packet to notify the clients of the entity's spawning
      API Note:
      Subclasses should return new EntitySpawnS2CPacket(this), unless they use a custom spawning packet.
      Mappings:
      Namespace Name Mixin selector
      named createSpawnPacket Lnet/minecraft/entity/Entity;createSpawnPacket(Lnet/minecraft/server/network/EntityTrackerEntry;)Lnet/minecraft/network/packet/Packet;
      intermediary method_18002 Lnet/minecraft/class_1297;method_18002(Lnet/minecraft/class_3231;)Lnet/minecraft/class_2596;
      official a Lbsr;a(Laqt;)Lzg;
    • onSpawnPacket

      public void onSpawnPacket(EntitySpawnS2CPacket packet)
      Called on the client when the entity receives a spawn packet.

      This sets the entity's position, angles, ID, and UUID. Subclasses can override this to initialize additional fields.

      Overrides:
      onSpawnPacket in class Entity
      Mappings:
      Namespace Name Mixin selector
      named onSpawnPacket Lnet/minecraft/entity/Entity;onSpawnPacket(Lnet/minecraft/network/packet/s2c/play/EntitySpawnS2CPacket;)V
      intermediary method_31471 Lnet/minecraft/class_1297;method_31471(Lnet/minecraft/class_2604;)V
      official a Lbsr;a(Labv;)V
    • canModifyAt

      public boolean canModifyAt(World world, BlockPos pos)
      Returns whether the entity can modify the world at pos.

      This returns true for most entities. Players check World.canPlayerModifyAt(net.minecraft.entity.player.PlayerEntity, net.minecraft.util.math.BlockPos) to prevent them from modifying entities in the spawn protection or outside the world border. ProjectileEntity delegates it to the owner if the owner is a player; if the owner is a non-player entity, this returns the value of GameRules.DO_MOB_GRIEFING, and ownerless projectiles are always allowed to modify the world.

      Overrides:
      canModifyAt in class Entity
      Returns:
      whether the entity can modify the world at pos
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named canModifyAt Lnet/minecraft/entity/Entity;canModifyAt(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Z
      intermediary method_36971 Lnet/minecraft/class_1297;method_36971(Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;)Z
      official a Lbsr;a(Ldcw;Ljd;)Z
    • canBreakBlocks

      public boolean canBreakBlocks(World world)
      Mappings:
      Namespace Name Mixin selector
      named canBreakBlocks Lnet/minecraft/entity/projectile/ProjectileEntity;canBreakBlocks(Lnet/minecraft/world/World;)Z
      intermediary method_54457 Lnet/minecraft/class_1676;method_54457(Lnet/minecraft/class_1937;)Z
      official b Lcnp;b(Ldcw;)Z
    • canHit

      public boolean canHit()
      Returns whether the entity can be hit with a projectile or be targeted by the player crosshair.
      Overrides:
      canHit in class Entity
      Returns:
      whether the entity can be hit with a projectile or be targeted by the player crosshair
      Mappings:
      Namespace Name Mixin selector
      named canHit Lnet/minecraft/entity/Entity;canHit()Z
      intermediary method_5863 Lnet/minecraft/class_1297;method_5863()Z
      official bA Lbsr;bA()Z
    • getTargetingMargin

      public float getTargetingMargin()
      Returns the margin around the entity's bounding box where the entity targeting is still successful.
      Overrides:
      getTargetingMargin in class Entity
      Returns:
      the margin around the entity's bounding box where the entity targeting is still successful
      API Note:
      ExplosiveProjectileEntity overrides this method to return 1.0f, which expands the ghast fireball's effective hitbox.
      Mappings:
      Namespace Name Mixin selector
      named getTargetingMargin Lnet/minecraft/entity/Entity;getTargetingMargin()F
      intermediary method_5871 Lnet/minecraft/class_1297;method_5871()F
      official bL Lbsr;bL()F
    • getKnockback

      public DoubleDoubleImmutablePair getKnockback(LivingEntity target, DamageSource source)
      Mappings:
      Namespace Name Mixin selector
      named getKnockback Lnet/minecraft/entity/projectile/ProjectileEntity;getKnockback(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/damage/DamageSource;)Lit/unimi/dsi/fastutil/doubles/DoubleDoubleImmutablePair;
      intermediary method_59959 Lnet/minecraft/class_1676;method_59959(Lnet/minecraft/class_1309;Lnet/minecraft/class_1282;)Lit/unimi/dsi/fastutil/doubles/DoubleDoubleImmutablePair;
      official a_ Lcnp;a_(Lbtn;Lbrk;)Lit/unimi/dsi/fastutil/doubles/DoubleDoubleImmutablePair;