Class Projectile
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.entity.Entity
net.minecraft.world.entity.projectile.Projectile
- All Implemented Interfaces:
DataComponentGetter, TypedInstance<EntityType<?>>, SyncedDataHolder, DebugValueSource, ItemOwner, SlotProvider, TraceableEntity, EntityAccess, UniquelyIdentifyable, Nameable, ScoreHolder, IAttachmentHolder, IEntityExtension
- Direct Known Subclasses:
AbstractArrow, AbstractHurtingProjectile, FireworkRocketEntity, FishingHook, LlamaSpit, ShulkerBullet, ThrowableProjectile
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceProjectile.ProjectileFactory<T extends Projectile>Nested classes/interfaces inherited from class Entity
Entity.Flags, Entity.MoveFunction, Entity.MovementEmission, Entity.RemovalReasonNested classes/interfaces inherited from class AttachmentHolder
AttachmentHolder.AsFieldNested classes/interfaces inherited from interface DebugValueSource
DebugValueSource.Registration, DebugValueSource.ValueGetter<T>Nested classes/interfaces inherited from interface ItemOwner
ItemOwner.OffsetFromOwner -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprivate static final booleanprivate booleanprivate @Nullable Entityprivate booleanprivate booleanprotected @Nullable EntityReference<Entity> Fields inherited from class Entity
BASE_SAFE_FALL_DISTANCE, BASE_TICKS_REQUIRED_TO_FREEZE, blocksBuilding, BOARDING_COOLDOWN, boardingCooldown, CONTENTS_SLOT_INDEX, 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, ENTITY_COUNTER, entityData, fallDistance, firstTick, FLAG_FALL_FLYING, FLAG_GLOWING, FLAG_ONFIRE, flyDist, FREEZE_HURT_FREQUENCY, horizontalCollision, hurtMarked, invulnerableTime, isInPowderSnow, mainSupportingBlockPos, MAX_ENTITY_TAG_COUNT, MAX_MOVEMENTS_HANDELED_PER_TICK, minorHorizontalCollision, moveDist, needsSync, noPhysics, portalProcess, random, stringUUID, stuckSpeedMultiplier, TAG_AIR, TAG_CUSTOM_NAME, TAG_DATA, TAG_FALL_DISTANCE, TAG_FIRE, TAG_GLOWING, TAG_ID, TAG_INVULNERABLE, TAG_MOTION, TAG_NO_GRAVITY, TAG_ON_GROUND, TAG_PASSENGERS, TAG_PORTAL_COOLDOWN, TAG_POS, TAG_ROTATION, TAG_SILENT, TAG_UUID, tickCount, TOTAL_AIR_SUPPLY, uuid, verticalCollision, verticalCollisionBelow, wasEyeInWater, wasInPowderSnow, wasTouchingWater, xo, xOld, xRotO, yo, yOld, yRotO, zo, zOldFields inherited from class AttachmentHolder
ATTACHMENTS_NBT_KEYFields inherited from interface ScoreHolder
WILDCARD, WILDCARD_NAME -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProjectile(EntityType<? extends Projectile> type, Level level) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAdditionalSaveData(ValueOutput output) voidapplyOnProjectileSpawned(ServerLevel serverLevel, ItemStack pickupItemStack) it.unimi.dsi.fastutil.doubles.DoubleDoubleImmutablePaircalculateHorizontalHurtKnockbackDirection(LivingEntity hurtEntity, DamageSource damageSource) protected booleancanHitEntity(Entity entity) protected voidbooleandeflect(ProjectileDeflection deflection, @Nullable Entity deflectingEntity, @Nullable EntityReference<Entity> newOwner, boolean byAttack) getAddEntityPacket(ServerEntity serverEntity) intgetMovementToShoot(double xd, double yd, double zd, float pow, float uncertainty) @Nullable EntitygetOwner()floatprotected ProjectileDeflectionhitTargetOrDeflectSelf(HitResult hitResult) booleanhurtServer(ServerLevel level, DamageSource source, float damage) private booleanbooleanprotected static floatlerpRotation(float rotO, float rot) booleanmayBreak(ServerLevel level) booleanmayInteract(ServerLevel level, BlockPos pos) voidonAboveBubbleColumn(boolean dragDown, BlockPos pos) protected voidonDeflection(boolean byAttack) protected voidprotected voidonHitBlock(BlockHitResult hitResult) protected voidonHitEntity(EntityHitResult hitResult) voidonInsideBubbleColumn(boolean dragDown) protected voidonItemBreak(Item item) protected booleanprotected voidreadAdditionalSaveData(ValueInput input) voidvoidrestoreFrom(Entity oldEntity) voidprotected voidsetOwner(@Nullable EntityReference<Entity> owner) voidshoot(double xd, double yd, double zd, float pow, float uncertainty) voidshootFromRotation(Entity source, float xRot, float yRot, float yOffset, float pow, float uncertainty) protected booleanstatic <T extends Projectile>
TspawnProjectile(T projectile, ServerLevel serverLevel, ItemStack itemStack) static <T extends Projectile>
TspawnProjectile(T projectile, ServerLevel serverLevel, ItemStack itemStack, Consumer<T> shootFunction) static <T extends Projectile>
TspawnProjectileFromRotation(Projectile.ProjectileFactory<T> creator, ServerLevel serverLevel, ItemStack itemStack, LivingEntity source, float yOffset, float pow, float uncertainty) static <T extends Projectile>
TspawnProjectileUsingShoot(Projectile.ProjectileFactory<T> creator, ServerLevel serverLevel, ItemStack itemStack, LivingEntity source, double targetX, double targetY, double targetZ, float pow, float uncertainty) static <T extends Projectile>
TspawnProjectileUsingShoot(T projectile, ServerLevel serverLevel, ItemStack itemStack, double targetX, double targetY, double targetZ, float pow, float uncertainty) voidtick()protected voidMethods inherited from class Entity
absSnapRotationTo, absSnapTo, absSnapTo, addDeltaMovement, addPassenger, addTag, adjustSpawnLocation, animateHurt, applyComponentsFromItemStack, applyEffectsFromBlocks, applyEffectsFromBlocks, applyEffectsFromBlocksForLastMovements, applyGravity, applyImplicitComponent, applyImplicitComponentIfPresent, applyImplicitComponents, awardKillScore, baseTick, belowNameDisplay, blockPosition, broadcastToPlayer, calculateUpVector, calculateViewVector, canAddPassenger, canBeCollidedWith, canBeHitByProjectile, canCollideWith, canControlVehicle, canFreeze, canInteractWithLevel, canRide, canSimulateMovement, canSpawnSprintParticle, canSprint, canTeleport, canTrample, canUsePortal, captureDrops, captureDrops, castComponentValue, causeFallDamage, checkBelowWorld, checkDespawn, checkFallDamage, checkFallDistanceAccumulation, checkSupportingBlock, chunkPosition, clearFire, clearFreeze, clearMovementThisTick, closerThan, closerThan, collectAllColliders, collideBoundingBox, collidedWithFluid, collidedWithShapeMovingFrom, computeSpeed, considersEntityAsAlly, copyPosition, couldAcceptPassenger, countPlayerPassengers, createCommandSourceStackForNameResolution, createHoverEvent, damageSources, dampensVibrations, defineSynchedData, deflection, discard, dismountsUnderwater, dismountTo, displayFireAnimation, distanceTo, distanceToSqr, distanceToSqr, distanceToSqr, doCheckFallDamage, doWaterSplashEffect, dropAllLeashConnections, ejectPassengers, entityTags, equals, extinguishFire, fillCrashReportCategory, fireImmune, fixupDimensions, forceSetRotation, fudgePositionAfterSizeChange, gameEvent, gameEvent, get, getAirSupply, getAttachments, getAvailableSpaceBelow, getBbHeight, getBbWidth, getBlockExplosionResistance, getBlockJumpFactor, getBlockPosBelowThatAffectsMyMovement, getBlockSpeedFactor, getBlockStateOn, getBlockStateOnLegacy, getBlockX, getBlockY, getBlockZ, getBoundingBox, getCapability, getCapability, getCollisionHorizontalEscapeVector, getControlledVehicle, getControllingPassenger, getCustomName, getDefaultGravity, getDefaultPassengerAttachmentPoint, getDeltaMovement, getDimensions, getDirection, getDismountLocationForPassenger, getDisplayName, getEncodeId, getEntityData, getEyeHeight, getEyeHeight, getEyePosition, getEyePosition, getEyeY, getFireImmuneTicks, getFirstPassenger, getFluidHeight, getFluidInteractionBox, getFluidJumpThreshold, getForward, getGravity, getHandHoldingItemAngle, getHeadLookAngle, getId, getInBlockState, getIndirectPassengers, getInputVector, getInterpolation, getKnownMovement, getKnownSpeed, getLightLevelDependentMagicValue, getLightProbePosition, getLookAngle, getLootTable, getMaxAirSupply, getMaxFallDistance, getMotionDirection, getMovementEmission, getName, getNearestViewDirection, getOnPos, getOnPos, getOnPosLegacy, getPassengerAttachmentPoint, getPassengerRidingPosition, getPassengers, getPassengersAndSelf, getPercentFrozen, getPersistentData, getPickResult, getPistonPushReaction, getPortalCooldown, getPose, getPosition, getPositionCodec, getPreciseBodyRotation, getPrimaryStepSoundBlockPos, getQuadLeashHolderOffsets, getRandom, getRandomX, getRandomY, getRandomY, getRandomZ, getRelativePortalPosition, getRemainingFireTicks, getRemovalReason, getRequiresPrecisePosition, getRootVehicle, getRopeHoldPosition, getRotationVector, getScoreboardName, getSelfAndPassengers, getSharedFlag, getSlot, getSoundSource, getStringUUID, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getTeam, getTeamColor, getTicksFrozen, getTicksRequiredToFreeze, getType, getTypeName, getUpVector, getUUID, getVehicle, getVehicleAttachmentPoint, getViewScale, getViewVector, getViewXRot, getViewYRot, getVisualRotationYInDegrees, getWeaponItem, getX, getX, getXRot, getXRot, getY, getY, getYHeadRot, getYRot, getYRot, getZ, getZ, handleDamageEvent, handleEntityEvent, handleOnAboveBubbleColumn, handleOnInsideBubbleColumn, handlePortal, hasControllingPassenger, hasCustomName, hasExactlyOnePlayerPassenger, hasGlowingTag, hashCode, hasIndirectPassenger, hasMovedHorizontallyRecently, hasPassenger, hasPassenger, hasPose, hurt, hurtClient, hurtOrSimulate, igniteForSeconds, igniteForTicks, ignoreExplosion, interact, is, isAddedToLevel, isAffectedByBlocks, isAlive, isAlliedTo, isAlliedTo, isAlwaysTicking, isAttackable, isClientAuthoritative, isColliding, isCrouching, isCurrentlyGlowing, isCustomNameVisible, isDescending, isDiscrete, isEffectiveAi, isEyeInFluid, isFlapping, isFlyingVehicle, isFree, isFreezing, isFullyFrozen, isHorizontalCollisionMinor, isIgnoringBlockTriggers, isInClouds, isInLava, isInLiquid, isInShallowWater, isInterpolating, isInvisible, isInvisibleTo, isInvulnerable, isInvulnerableToBase, isInWall, isInWater, isInWaterOrRain, isLocalClientAuthoritative, isLocalInstanceAuthoritative, isNoGravity, isOnFire, isOnPortalCooldown, isOnRails, isPassenger, isPassengerOfSameVehicle, isPushable, isPushedByFluid, isRemoved, isShiftKeyDown, isSilent, isSpectator, isSprinting, isSteppingCarefully, isSupportedBy, isSuppressingBounce, isSwimming, isUnderWater, isVehicle, isVisuallyCrawling, isVisuallySwimming, kill, killedEntity, lavaHurt, lavaIgnite, lerpHeadTo, lerpMotion, lerpPositionAndRotationStep, level, limitPistonMovement, load, lookAt, makeBoundingBox, makeBoundingBox, makeStuckInBlock, markHurt, maxUpStep, maybeBackOffFromEdge, mirror, modifyPassengerFluidInteractionBox, move, moveOrInterpolateTo, moveOrInterpolateTo, moveOrInterpolateTo, moveOrInterpolateTo, moveRelative, moveTowardsClosestSpace, nextStep, notifyLeasheeRemoved, notifyLeashHolder, oldPosition, onAddedToLevel, onBelowWorld, onClientRemoval, onExplosionHit, onFlap, onGround, onInsideBlock, onPassengerTurned, onRemoval, onRemovedFromLevel, onSyncedDataUpdated, onSyncedDataUpdated, pick, placePortalTicket, playCombinationStepSounds, playEntityOnFireExtinguishedSound, playerTouch, playMuffledStepSound, playSound, playSound, playStepSound, playSwimSound, position, positionRider, positionRider, problemPath, processFlappingMovement, processPortalCooldown, propagateFallToPassengers, push, push, push, reapplyPosition, refreshDimensions, registerDebugValues, registryAccess, remove, removeAfterChangingDimensions, removeLatestMovementRecording, removePassenger, removeTag, removeVehicle, repositionEntityAfterLoad, resetFallDistance, revive, rideTick, rotate, save, saveAsPassenger, saveWithoutId, sendBubbleColumnParticles, setAirSupply, setAsInsidePortal, setBoundingBox, setComponent, setCustomName, setCustomNameVisible, setData, setDeltaMovement, setDeltaMovement, setGlowingTag, setId, setInvisible, setInvulnerable, setIsInPowderSnow, setLevel, setLevelCallback, setNoGravity, setOldPos, setOldPosAndRot, setOldPosAndRot, setOldRot, setOnGround, setOnGroundWithMovement, setOnGroundWithMovement, setPortalCooldown, setPortalCooldown, setPos, setPos, setPose, setPosRaw, setRemainingFireTicks, setRemoved, setRequiresPrecisePosition, setRot, setSharedFlag, setSharedFlagOnFire, setShiftKeyDown, setSilent, setSprinting, setSwimming, setTicksFrozen, setUUID, setViewScale, setXRot, setYBodyRot, setYHeadRot, setYRot, shearOffAllLeashConnections, shouldBeSaved, shouldBlockExplode, shouldPlayLavaHurtSound, shouldRender, shouldRenderAtSqrDistance, shouldShowName, showVehicleHealth, skipAttackInteraction, snapTo, snapTo, snapTo, snapTo, snapTo, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnSprintParticle, startRiding, startRiding, startSeenByPlayer, stopRiding, stopSeenByPlayer, supportQuadLeashAsHolder, syncData, syncPacketPositionCodec, teleport, teleportRelative, teleportSetPosition, teleportSetPosition, teleportSpectators, teleportTo, teleportTo, thunderHit, toString, touchingUnloadedChunk, trackingPosition, turn, typeHolder, unRide, unsetRemoved, updateDataBeforeSync, updateDynamicGameEventListener, updateFluidInteraction, updateSwimming, waterSwimSoundMethods inherited from class AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, removeData, serializeAttachmentsMethods inherited from interface DataComponentGetter
get, getOrDefault, getOrDefault, getTyped, has, hasMethods inherited from interface IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncDataMethods inherited from interface IEntityExtension
canBeRiddenUnderFluidType, canFluidExtinguish, canHydrateInFluidType, canRiderInteract, canSwimInFluidType, copyAttachmentsFrom, getClassification, getFluidFallDistanceModifier, getFluidMotionScale, getParts, getSoundFromFluidType, hasCustomOutlineRendering, isMultipartEntity, isPushedByFluid, sendPairingData, shouldRiderSitMethods inherited from interface ItemOwner
asLivingEntityMethods inherited from interface Nameable
getPlainTextNameMethods inherited from interface ScoreHolder
getFeedbackDisplayNameMethods inherited from interface SlotProvider
getSlotsFromRange
-
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:
-
owner
-
leftOwner
private boolean leftOwner -
leftOwnerChecked
private boolean leftOwnerChecked -
hasBeenShot
private boolean hasBeenShot -
lastDeflectedBy
-
-
Constructor Details
-
Projectile
-
-
Method Details
-
setOwner
-
setOwner
-
getOwner
- Specified by:
getOwnerin interfaceTraceableEntity
-
getEffectSource
-
addAdditionalSaveData
- Specified by:
addAdditionalSaveDatain classEntity
-
ownedBy
-
readAdditionalSaveData
- Specified by:
readAdditionalSaveDatain classEntity
-
restoreFrom
- Overrides:
restoreFromin classEntity
-
tick
-
checkLeftOwner
protected void checkLeftOwner() -
isOutsideOwnerCollisionRange
private boolean isOutsideOwnerCollisionRange() -
getMovementToShoot
-
shoot
public void shoot(double xd, double yd, double zd, float pow, float uncertainty) -
shootFromRotation
public void shootFromRotation(Entity source, float xRot, float yRot, float yOffset, float pow, float uncertainty) -
onAboveBubbleColumn
- Overrides:
onAboveBubbleColumnin classEntity
-
onInsideBubbleColumn
public void onInsideBubbleColumn(boolean dragDown) - Overrides:
onInsideBubbleColumnin classEntity
-
spawnProjectileFromRotation
public static <T extends Projectile> T spawnProjectileFromRotation(Projectile.ProjectileFactory<T> creator, ServerLevel serverLevel, ItemStack itemStack, LivingEntity source, float yOffset, float pow, float uncertainty) -
spawnProjectileUsingShoot
public static <T extends Projectile> T spawnProjectileUsingShoot(Projectile.ProjectileFactory<T> creator, ServerLevel serverLevel, ItemStack itemStack, LivingEntity source, double targetX, double targetY, double targetZ, float pow, float uncertainty) -
spawnProjectileUsingShoot
public static <T extends Projectile> T spawnProjectileUsingShoot(T projectile, ServerLevel serverLevel, ItemStack itemStack, double targetX, double targetY, double targetZ, float pow, float uncertainty) -
spawnProjectile
public static <T extends Projectile> T spawnProjectile(T projectile, ServerLevel serverLevel, ItemStack itemStack) -
spawnProjectile
public static <T extends Projectile> T spawnProjectile(T projectile, ServerLevel serverLevel, ItemStack itemStack, Consumer<T> shootFunction) -
applyOnProjectileSpawned
-
hitTargetOrDeflectSelf
-
shouldBounceOnWorldBorder
protected boolean shouldBounceOnWorldBorder() -
deflect
public boolean deflect(ProjectileDeflection deflection, @Nullable Entity deflectingEntity, @Nullable EntityReference<Entity> newOwner, boolean byAttack) -
onDeflection
protected void onDeflection(boolean byAttack) -
onItemBreak
-
onHit
-
onHitEntity
-
onHitBlock
-
canHitEntity
-
updateRotation
protected void updateRotation() -
lerpRotation
protected static float lerpRotation(float rotO, float rot) -
getAddEntityPacket
- Overrides:
getAddEntityPacketin classEntity
-
recreateFromPacket
- Overrides:
recreateFromPacketin classEntity
-
mayInteract
- Overrides:
mayInteractin classEntity
-
mayBreak
-
isPickable
public boolean isPickable()- Overrides:
isPickablein classEntity
-
getPickRadius
public float getPickRadius()- Overrides:
getPickRadiusin classEntity
-
calculateHorizontalHurtKnockbackDirection
public it.unimi.dsi.fastutil.doubles.DoubleDoubleImmutablePair calculateHorizontalHurtKnockbackDirection(LivingEntity hurtEntity, DamageSource damageSource) -
getDimensionChangingDelay
public int getDimensionChangingDelay()- Overrides:
getDimensionChangingDelayin classEntity
-
hurtServer
- Specified by:
hurtServerin classEntity
-