Class MagicArrowEntity

java.lang.Object
net.minecraft.world.entity.Entity
net.minecraft.world.entity.projectile.Projectile
net.minecraft.world.entity.projectile.AbstractArrow
com.binaris.wizardry.api.content.entity.projectile.MagicArrowEntity
All Implemented Interfaces:
dev.onyxstudios.cca.api.v3.component.ComponentAccess, net.fabricmc.fabric.api.attachment.v1.AttachmentTarget, net.minecraft.commands.CommandSource, net.minecraft.world.entity.TraceableEntity, net.minecraft.world.level.entity.EntityAccess, net.minecraft.world.Nameable
Direct Known Subclasses:
DartEntity, FlamecatcherArrow, ForceArrow, IceLanceEntity, IceShardEntity, LightningArrow, MagicMissileEntity

public abstract class MagicArrowEntity extends net.minecraft.world.entity.projectile.AbstractArrow
This class uses the base code from AbstractArrow and adds some methods to make it easier to use with the mod. This is used as a base class for all the magic arrows spelled by the ArrowSpell class.

The methods aim(LivingEntity, float) and aim(LivingEntity, Entity, float, float) are used to set the shooter of the projectile and aim it in the direction they are looking. (Originally copied from Ebwizardry 1.12.2)

To register the renderer for this entity, use MagicArrowRenderer and register the respective texture in getTexture(), if you want to use another renderer, you can do so accordingly, but you will have to handle the texture yourself.

  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.entity.projectile.AbstractArrow

    net.minecraft.world.entity.projectile.AbstractArrow.Pickup

    Nested classes/interfaces inherited from class net.minecraft.world.entity.Entity

    net.minecraft.world.entity.Entity.MoveFunction, net.minecraft.world.entity.Entity.MovementEmission, net.minecraft.world.entity.Entity.RemovalReason
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
     
    static final float
     
    static final double
     
    static final int
     
    protected int
     
    protected int
     

    Fields inherited from class net.minecraft.world.entity.projectile.AbstractArrow

    inGround, inGroundTime, pickup, shakeTime

    Fields inherited from class net.minecraft.world.entity.Entity

    BASE_TICKS_REQUIRED_TO_FREEZE, blocksBuilding, BOARDING_COOLDOWN, boardingCooldown, BREATHING_DISTANCE_BELOW_EYES, DATA_POSE, DATA_SHARED_FLAGS_ID, DEFAULT_BB_HEIGHT, DEFAULT_BB_WIDTH, DELTA_AFFECTED_BY_BLOCKS_BELOW_0_2, DELTA_AFFECTED_BY_BLOCKS_BELOW_0_5, DELTA_AFFECTED_BY_BLOCKS_BELOW_1_0, entityData, fallDistance, firstTick, FLAG_FALL_FLYING, FLAG_GLOWING, FLAG_ONFIRE, fluidHeight, flyDist, FREEZE_HURT_FREQUENCY, hasImpulse, horizontalCollision, hurtMarked, ID_TAG, invulnerableTime, isInPowderSnow, isInsidePortal, mainSupportingBlockPos, MAX_ENTITY_TAG_COUNT, minorHorizontalCollision, moveDist, noCulling, noPhysics, PASSENGERS_TAG, portalEntrancePos, portalTime, random, stringUUID, stuckSpeedMultiplier, tickCount, TOTAL_AIR_SUPPLY, uuid, UUID_TAG, verticalCollision, verticalCollisionBelow, walkDist, walkDistO, wasEyeInWater, wasInPowderSnow, wasOnFire, wasTouchingWater, xo, xOld, xRotO, yo, yOld, yRotO, zo, zOld

    Fields inherited from interface net.fabricmc.fabric.api.attachment.v1.AttachmentTarget

    NBT_ATTACHMENT_KEY

    Fields inherited from interface net.minecraft.commands.CommandSource

    NULL
  • Constructor Summary

    Constructors
    Constructor
    Description
    MagicArrowEntity(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.projectile.AbstractArrow> entityType, net.minecraft.world.level.Level world)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAdditionalSaveData(@NotNull net.minecraft.nbt.CompoundTag compound)
     
    void
    aim(net.minecraft.world.entity.LivingEntity caster, float speed)
    Sets the shooter of the projectile to the given caster, positions the projectile at the given caster's eyes and aims it in the direction they are looking with the given speed.
    void
    aim(net.minecraft.world.entity.LivingEntity caster, net.minecraft.world.entity.Entity target, float speed, float aimingError)
     
    boolean
    Deprecated.
    boolean
    Deprecated.
    abstract double
    Subclasses must override this to set their own base damage.
    net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType>
    This method is used to get the damage type of the magic arrow.
    protected @NotNull net.minecraft.sounds.SoundEvent
     
    abstract int
    Returns the maximum flight time in ticks before this projectile disappears, or -1 if it can continue indefinitely until it hits something.
    float
    Returns the seeking strength of this projectile, or the maximum distance from a target the projectile can be heading for that will make it curve towards that target.
    abstract net.minecraft.resources.ResourceLocation
    This method is used to get the texture for the magic arrow.
    protected void
    onHitEntity(@NotNull net.minecraft.world.phys.EntityHitResult hitResult)
     
    void
    readAdditionalSaveData(@NotNull net.minecraft.nbt.CompoundTag compound)
     
    void
     
    void
     
    void
     
    protected boolean
    tryPickup(@NotNull net.minecraft.world.entity.player.Player player)
     

    Methods inherited from class net.minecraft.world.entity.projectile.AbstractArrow

    canHitEntity, defineSynchedData, doPostHurtEffects, findHitEntity, getBaseDamage, getEyeHeight, getHitGroundSoundEvent, getKnockback, getMovementEmission, getPickupItem, getPierceLevel, getWaterInertia, isAttackable, isCritArrow, isNoPhysics, lerpMotion, lerpTo, move, onHitBlock, playerTouch, setBaseDamage, setCritArrow, setEnchantmentEffectsFromEntity, setKnockback, setNoPhysics, setOwner, setPierceLevel, setShotFromCrossbow, setSoundEvent, shoot, shotFromCrossbow, shouldRenderAtSqrDistance, tickDespawn

    Methods inherited from class net.minecraft.world.entity.projectile.Projectile

    getAddEntityPacket, getEffectSource, getOwner, lerpRotation, mayInteract, onHit, ownedBy, recreateFromPacket, shootFromRotation, updateRotation

    Methods inherited from class net.minecraft.world.entity.Entity

    absMoveTo, absMoveTo, acceptsFailure, acceptsSuccess, addDeltaMovement, addPassenger, addTag, animateHurt, awardKillScore, baseTick, blockPosition, broadcastToPlayer, calculateUpVector, calculateViewVector, canAddPassenger, canBeCollidedWith, canBeHitByProjectile, canChangeDimensions, canCollideWith, canEnterPose, canFreeze, canRide, canSpawnSprintParticle, canSprint, causeFallDamage, changeDimension, checkBelowWorld, checkDespawn, checkFallDamage, checkInsideBlocks, checkSlowFallDistance, checkSupportingBlock, chunkPosition, clearFire, closerThan, closerThan, collideBoundingBox, copyPosition, couldAcceptPassenger, createCommandSourceStack, createHoverEvent, damageSources, dampensVibrations, discard, dismountsUnderwater, dismountTo, displayFireAnimation, distanceTo, distanceToSqr, distanceToSqr, distanceToSqr, doEnchantDamageEffects, doWaterSplashEffect, ejectPassengers, equals, extinguishFire, fillCrashReportCategory, findDimensionEntryPoint, fireImmune, fixupDimensions, gameEvent, gameEvent, getAirSupply, getAllSlots, getArmorSlots, getBbHeight, getBbWidth, getBlockExplosionResistance, getBlockJumpFactor, getBlockPosBelowThatAffectsMyMovement, getBlockSpeedFactor, getBlockStateOn, getBlockStateOnLegacy, getBlockX, getBlockY, getBlockZ, getBoundingBox, getBoundingBoxForCulling, getBoundingBoxForPose, getCollisionHorizontalEscapeVector, getCommandSenderWorld, getControlledVehicle, getControllingPassenger, getCustomName, getDeltaMovement, getDimensionChangingDelay, getDimensions, getDirection, getDismountLocationForPassenger, getDisplayName, getEncodeId, getEntityData, getExitPortal, getEyeHeight, getEyeHeight, getEyePosition, getEyePosition, getEyeY, getFeetBlockState, getFireImmuneTicks, getFirstPassenger, getFluidHeight, getFluidJumpThreshold, getForward, getHandHoldingItemAngle, getHandSlots, getId, getIndirectPassengers, getLeashOffset, getLeashOffset, getLightLevelDependentMagicValue, getLightProbePosition, getLookAngle, getMaxAirSupply, getMaxFallDistance, getMotionDirection, getMyRidingOffset, getName, getNameTagOffsetY, getOnPos, getOnPos, getOnPosLegacy, getPassengers, getPassengersAndSelf, getPassengersRidingOffset, getPercentFrozen, getPermissionLevel, getPickRadius, getPickResult, getPistonPushReaction, getPortalCooldown, getPortalWaitTime, getPose, getPosition, getPositionCodec, getPrimaryStepSoundBlockPos, getRandomX, getRandomY, getRandomZ, getRelativePortalPosition, getRemainingFireTicks, getRemovalReason, getRootVehicle, getRopeHoldPosition, getRotationVector, getScoreboardName, getSelfAndPassengers, getServer, getSharedFlag, getSlot, getSoundSource, getStringUUID, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getTags, getTeam, getTeamColor, getTicksFrozen, getTicksRequiredToFreeze, getType, getTypeName, getUpVector, getUUID, getVehicle, getViewScale, getViewVector, getViewXRot, getViewYRot, getVisualRotationYInDegrees, getX, getX, getXRot, getY, getY, getYHeadRot, getYRot, getZ, getZ, handleDamageEvent, handleEntityEvent, handleInsidePortal, handleNetherPortal, hasControllingPassenger, hasCustomName, hasExactlyOnePlayerPassenger, hasGlowingTag, hashCode, hasIndirectPassenger, hasPassenger, hasPassenger, hasPermissions, hasPose, hurt, ignoreExplosion, interact, interactAt, is, isAlive, isAlliedTo, isAlliedTo, isAlwaysTicking, isColliding, isControlledByLocalInstance, isCrouching, isCurrentlyGlowing, isCustomNameVisible, isDescending, isDiscrete, isEffectiveAi, isEyeInFluid, isFlapping, isFree, isFreezing, isFullyFrozen, isHorizontalCollisionMinor, isIgnoringBlockTriggers, isInLava, isInvisible, isInvisibleTo, isInvulnerable, isInvulnerableTo, isInWall, isInWater, isInWaterOrBubble, isInWaterOrRain, isInWaterRainOrBubble, isNoGravity, isOnFire, isOnPortalCooldown, isOnRails, isPassenger, isPassengerOfSameVehicle, isPickable, isPushable, isPushedByFluid, isRemoved, isShiftKeyDown, isSilent, isSpectator, isSprinting, isSteppingCarefully, isSupportedBy, isSuppressingBounce, isSwimming, isUnderWater, isVehicle, isVisuallyCrawling, isVisuallySwimming, kill, killedEntity, lavaHurt, lerpHeadTo, level, limitPistonMovement, load, lookAt, makeBoundingBox, makeStuckInBlock, markHurt, maxUpStep, maybeBackOffFromEdge, mirror, moveRelative, moveTo, moveTo, moveTo, moveTo, moveTowardsClosestSpace, newDoubleList, newFloatList, nextStep, onAboveBubbleCol, onBelowWorld, onClientRemoval, onFlap, onGround, onInsideBlock, onInsideBubbleColumn, onlyOpCanSetNbt, onPassengerTurned, onSyncedDataUpdated, onSyncedDataUpdated, pick, playCombinationStepSounds, playEntityOnFireExtinguishedSound, playMuffledStepSound, playSound, playSound, playStepSound, playSwimSound, position, positionRider, positionRider, processFlappingMovement, processPortalCooldown, push, push, reapplyPosition, refreshDimensions, remove, removeAfterChangingDimensions, removePassenger, removeTag, removeVehicle, repositionEntityAfterLoad, resetFallDistance, restoreFrom, rideTick, rotate, save, saveAsPassenger, saveWithoutId, sendSystemMessage, setAirSupply, setBoundingBox, setCustomName, setCustomNameVisible, setDeltaMovement, setDeltaMovement, setGlowingTag, setId, setInvisible, setInvulnerable, setIsInPowderSnow, setItemSlot, setLevel, setLevelCallback, setMaxUpStep, setNoGravity, setOldPosAndRot, setOnGround, setOnGroundWithKnownMovement, setPortalCooldown, setPortalCooldown, setPos, setPos, setPose, setPosRaw, setRemainingFireTicks, setRemoved, setRot, setSecondsOnFire, setSharedFlag, setSharedFlagOnFire, setShiftKeyDown, setSilent, setSprinting, setSwimming, setTicksFrozen, setUUID, setViewScale, setXRot, setYBodyRot, setYHeadRot, setYRot, shouldBeSaved, shouldBlockExplode, shouldInformAdmins, shouldRender, shouldShowName, showVehicleHealth, skipAttackInteraction, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnSprintParticle, startRiding, startRiding, startSeenByPlayer, stopRiding, stopSeenByPlayer, syncPacketPositionCodec, teleportRelative, teleportTo, teleportTo, teleportToWithTicket, thunderHit, toString, touchingUnloadedChunk, trackingPosition, tryCheckInsideBlocks, turn, unRide, unsetRemoved, updateDynamicGameEventListener, updateFluidHeightAndDoFluidPushing, updateInWaterStateAndDoFluidPushing, updateSwimming, waterSwimSound

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.fabricmc.fabric.api.attachment.v1.AttachmentTarget

    getAttached, getAttachedOrCreate, getAttachedOrCreate, getAttachedOrElse, getAttachedOrGet, getAttachedOrSet, getAttachedOrThrow, hasAttached, modifyAttached, removeAttached, setAttached

    Methods inherited from interface net.minecraft.commands.CommandSource

    alwaysAccepts

    Methods inherited from interface dev.onyxstudios.cca.api.v3.component.ComponentAccess

    asComponentProvider, getComponent, syncComponent, syncComponent, syncComponent
  • Field Details

    • LAUNCH_Y_OFFSET

      public static final double LAUNCH_Y_OFFSET
      See Also:
    • FORWARD_OFFSET

      public static final float FORWARD_OFFSET
      See Also:
    • SEEKING_TIME

      public static final int SEEKING_TIME
      See Also:
    • damageMultiplier

      public float damageMultiplier
    • ticksInGround

      protected int ticksInGround
    • ticksInAir

      protected int ticksInAir
  • Constructor Details

    • MagicArrowEntity

      public MagicArrowEntity(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.projectile.AbstractArrow> entityType, net.minecraft.world.level.Level world)
  • Method Details

    • aim

      public void aim(net.minecraft.world.entity.LivingEntity caster, float speed)
      Sets the shooter of the projectile to the given caster, positions the projectile at the given caster's eyes and aims it in the direction they are looking with the given speed.
    • aim

      public void aim(net.minecraft.world.entity.LivingEntity caster, net.minecraft.world.entity.Entity target, float speed, float aimingError)
    • onHitEntity

      protected void onHitEntity(@NotNull @NotNull net.minecraft.world.phys.EntityHitResult hitResult)
      Overrides:
      onHitEntity in class net.minecraft.world.entity.projectile.AbstractArrow
    • addAdditionalSaveData

      public void addAdditionalSaveData(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Overrides:
      addAdditionalSaveData in class net.minecraft.world.entity.projectile.AbstractArrow
    • readAdditionalSaveData

      public void readAdditionalSaveData(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Overrides:
      readAdditionalSaveData in class net.minecraft.world.entity.projectile.AbstractArrow
    • getDamage

      public abstract double getDamage()
      Subclasses must override this to set their own base damage.
    • getLifetime

      public abstract int getLifetime()
      Returns the maximum flight time in ticks before this projectile disappears, or -1 if it can continue indefinitely until it hits something. This should be constant.
    • getDamageType

      public net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> getDamageType()
      This method is used to get the damage type of the magic arrow. You must override this and return a valid ResourceKey<DamageType> for your magic arrow's damage type.
    • getTexture

      public abstract net.minecraft.resources.ResourceLocation getTexture()
      This method is used to get the texture for the magic arrow. The texture is represented by a ResourceLocation object. You must return a valid ResourceLocation or implement a different renderer of your own accordingly.
    • doDeceleration

      @Deprecated public boolean doDeceleration()
      Deprecated.
      Override this to disable deceleration (generally speaking, this isn't noticeable unless gravity is turned off). Returns true by default.
    • doOverpenetration

      @Deprecated public boolean doOverpenetration()
      Deprecated.
      Override this to allow the projectile to pass through mobs intact (the onEntityHit method will still be called and damage will still be applied). Returns false by default.
    • getSeekingStrength

      public float getSeekingStrength()
      Returns the seeking strength of this projectile, or the maximum distance from a target the projectile can be heading for that will make it curve towards that target. By default, this is 2 if the caster is wearing a ring of attraction, otherwise it is 0. You can override this method to give different behaviour for different projectiles and also make it depend on other factors such as the caster's equipment.
    • tick

      public void tick()
      Overrides:
      tick in class net.minecraft.world.entity.projectile.AbstractArrow
    • tickInGround

      public void tickInGround()
    • ticksInAir

      public void ticksInAir()
    • tryPickup

      protected boolean tryPickup(@NotNull @NotNull net.minecraft.world.entity.player.Player player)
      Overrides:
      tryPickup in class net.minecraft.world.entity.projectile.AbstractArrow
    • getDefaultHitGroundSoundEvent

      @NotNull protected @NotNull net.minecraft.sounds.SoundEvent getDefaultHitGroundSoundEvent()
      Overrides:
      getDefaultHitGroundSoundEvent in class net.minecraft.world.entity.projectile.AbstractArrow