Package net.minecraft.server.level
Class ServerPlayer
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.entity.Entity
net.minecraft.world.entity.LivingEntity
net.minecraft.world.entity.player.Player
net.minecraft.server.level.ServerPlayer
- All Implemented Interfaces:
CommandSource
,SyncedDataHolder
,Attackable
,EntityAccess
,Nameable
,ScoreHolder
,IAttachmentHolder
,IEntityExtension
,ILivingEntityExtension
,IPlayerExtension
,INBTSerializable<CompoundTag>
- Direct Known Subclasses:
FakePlayer
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.minecraft.world.entity.player.Player
Player.BedSleepingProblem
Nested classes/interfaces inherited from class net.minecraft.world.entity.LivingEntity
LivingEntity.Fallsounds
Nested classes/interfaces inherited from class net.minecraft.world.entity.Entity
Entity.MoveFunction, Entity.MovementEmission, Entity.RemovalReason
Nested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
AttachmentHolder.AsField
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PlayerAdvancements
private boolean
private Entity
The entity the player is currently spectating through.private boolean
private RemoteChatSession
private ChatVisiblity
private ChunkTrackingView
private int
private final ContainerListener
private final ContainerSynchronizer
private static final AttributeModifier
private static final AttributeModifier
private boolean
private Vec3
private Vec3
private static final int
final ServerPlayerGameMode
private boolean
static final double
private boolean
private String
private long
private boolean
private Vec3
private int
private int
private int
private int
private float
the total health of the player, includes actual health and absorption health.private int
private SectionPos
Player section position as last updated by TicketManager, used by ChunkManagerprivate int
private int
private float
private Vec3
private int
private static final org.slf4j.Logger
private static final int
private static final int
final Object
private BlockPos
private final ServerRecipeBook
private int
private float
private ResourceKey
<Level> private boolean
private BlockPos
boolean
final MinecraftServer
private boolean
private int
private Vec3
private final ServerStatsCounter
private Component
private Component
private Component
private final TextFilter
private boolean
private WardenSpawnTracker
boolean
Fields inherited from class net.minecraft.world.entity.player.Player
bob, containerMenu, CRAFTING_SLOT_OFFSET, CROUCH_BB_HEIGHT, currentExplosionCause, currentImpulseImpactPos, DATA_PLAYER_MAIN_HAND, DATA_PLAYER_MODE_CUSTOMISATION, DATA_SHOULDER_LEFT, DATA_SHOULDER_RIGHT, DEFAULT_BLOCK_INTERACTION_RANGE, DEFAULT_ENTITY_INTERACTION_RANGE, DEFAULT_EYE_HEIGHT, DEFAULT_MAIN_HAND, DEFAULT_MODEL_CUSTOMIZATION, DEFAULT_VEHICLE_ATTACHMENT, defaultFlySpeed, enchantmentSeed, ENDER_SLOT_OFFSET, enderChestInventory, experienceLevel, experienceProgress, fishing, foodData, HELD_ITEM_SLOT, hurtDir, inventoryMenu, jumpTriggerTime, MAX_HEALTH, oBob, PERSISTED_NBT_TAG, SLEEP_DURATION, STANDING_DIMENSIONS, SWIMMING_BB_HEIGHT, SWIMMING_BB_WIDTH, takeXpDelay, totalExperience, WAKE_UP_DURATION, wasUnderwater, xCloak, xCloakO, yCloak, yCloakO, zCloak, zCloakO
Fields inherited from class net.minecraft.world.entity.LivingEntity
animStep, animStepO, appliedScale, ARMOR_SLOT_OFFSET, ARMOR_SLOTS, attackAnim, attackStrengthTicker, ATTRIBUTES_FIELD, autoSpinAttackDmg, autoSpinAttackItemStack, autoSpinAttackTicks, BASE_JUMP_POWER, BODY_ARMOR_OFFSET, brain, damageContainers, DATA_LIVING_ENTITY_FLAGS, dead, DEATH_DURATION, deathScore, deathTime, DEFAULT_BABY_SCALE, DEFAULT_BASE_GRAVITY, EQUIPMENT_SLOT_OFFSET, EXTRA_RENDER_CULLING_SIZE_WITH_BIG_HAT, fallFlyTicks, HAND_SLOTS, hurtDuration, hurtTime, invulnerableDuration, jumping, lastHurt, lastHurtByPlayer, lastHurtByPlayerTime, lerpHeadSteps, lerpSteps, lerpX, lerpXRot, lerpY, lerpYHeadRot, lerpYRot, lerpZ, LIVING_ENTITY_FLAG_IS_USING, LIVING_ENTITY_FLAG_OFF_HAND, LIVING_ENTITY_FLAG_SPIN_ATTACK, MIN_MOVEMENT_DISTANCE, noActionTime, oAttackAnim, oRun, PLAYER_HURT_EXPERIENCE_TIME, removeArrowTime, removeStingerTime, rotA, rotOffs, run, SLEEPING_DIMENSIONS, SWING_DURATION, swinging, swingingArm, swingTime, timeOffs, USE_ITEM_INTERVAL, useItem, useItemRemaining, walkAnimation, xxa, yBodyRot, yBodyRotO, yHeadRot, yHeadRotO, yya, zza
Fields inherited from class net.minecraft.world.entity.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, fluidHeight, flyDist, forgeFluidTypeHeight, FREEZE_HURT_FREQUENCY, hasImpulse, horizontalCollision, hurtMarked, ID_TAG, invulnerableTime, isInPowderSnow, mainSupportingBlockPos, MAX_ENTITY_TAG_COUNT, minorHorizontalCollision, moveDist, noCulling, noPhysics, PASSENGERS_TAG, portalProcess, 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 class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY
Fields inherited from interface net.minecraft.commands.CommandSource
NULL
Fields inherited from interface net.minecraft.world.scores.ScoreHolder
WILDCARD, WILDCARD_NAME
-
Constructor Summary
ConstructorsConstructorDescriptionServerPlayer
(MinecraftServer server, ServerLevel level, com.mojang.authlib.GameProfile gameProfile, ClientInformation clientInformation) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
private boolean
acceptsSystemMessages
(boolean bypassHiddenChat) void
addAdditionalSaveData
(CompoundTag compound) adjustSpawnLocation
(ServerLevel level, BlockPos pos) boolean
void
Attacks for the player the targeted entity with the currently equipped item.void
awardKillScore
(Entity killed, int scoreValue, DamageSource damageSource) int
awardRecipes
(Collection<RecipeHolder<?>> recipes) void
awardRecipesByKey
(List<ResourceLocation> recipes) void
Adds a value to a statistic field.private boolean
bedBlocked
(BlockPos pos, Direction direction) private boolean
bedInRange
(BlockPos pos, Direction direction) boolean
broadcastToPlayer
(ServerPlayer player) private GameType
calculateGameModeForNewPlayer
(GameType gameType) boolean
boolean
canHarmPlayer
(Player other) changeDimension
(DimensionTransition transition) protected void
checkFallDamage
(double y, boolean onGround, BlockState state, BlockPos pos) void
checkMovementStatistics
(double dx, double dy, double dz) void
checkRidingStatistics
(double dx, double dy, double dz) void
void
protected void
void
copyRespawnPosition
(ServerPlayer player) createCommonSpawnInfo
(ServerLevel level) protected ItemCooldowns
void
Called when the entity is dealt a critical hit.private static boolean
didNotMove
(double dx, double dy, double dz) void
die
(DamageSource cause) Called when the mob's health reaches 0.void
void
dismountTo
(double x, double y, double z) void
displayClientMessage
(Component chatComponent, boolean actionBar) void
doCheckFallDamage
(double movementX, double movementY, double movementZ, boolean onGround) void
void
doTick()
boolean
drop
(boolean dropStack) Creates and drops the provided item.private static Optional
<ServerPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock
(ServerLevel level, BlockPos pos, float angle, boolean forced, boolean keepInventory) findRespawnPositionAndUseSpawnBlock
(boolean keepInventory, DimensionTransition.PostDimensionTransition postDimensionTransition) private int
getCoprime
(int spawnArea) protected float
getEnchantedDamage
(Entity entity, float damage, DamageSource damageSource) Returns the language last reported by the player as their local language.long
protected int
float
getStats()
void
giveExperienceLevels
(int levels) Add experience levels to this player.void
giveExperiencePoints
(int xpPoints) private void
handleTeamKill
(ScoreHolder scoreHolder, ScoreHolder teamMember, ObjectiveCriteria[] crtieria) void
boolean
boolean
hurt
(DamageSource source, float amount) Called when the entity is attacked.void
indicateDamage
(double xDistance, double zDistance) void
private void
boolean
boolean
boolean
isInvulnerableTo
(DamageSource source) Returns whether this Entity is invulnerable to the given DamageSource.private boolean
private boolean
boolean
boolean
boolean
void
loadGameTypes
(CompoundTag tag) void
lookAt
(EntityAnchorArgument.Anchor fromAnchor, Entity entity, EntityAnchorArgument.Anchor toAnchor) void
lookAt
(EntityAnchorArgument.Anchor anchor, Vec3 target) void
Called when the entity hit is dealt extra melee damage due to an enchantment.boolean
mayInteract
(Level level, BlockPos pos) void
moveTo
(double x, double y, double z) private void
protected void
onChangedBlock
(ServerLevel level, BlockPos pos) protected void
onEffectAdded
(MobEffectInstance effectInstance, Entity entity) protected void
onEffectRemoved
(MobEffectInstance effect) protected void
onEffectUpdated
(MobEffectInstance effectInstance, boolean forced, Entity entity) void
onEnchantmentPerformed
(ItemStack enchantedItem, int cost) void
void
onEquippedItemBroken
(Item item, EquipmentSlot slot) void
onExplosionHit
(Entity entity) void
onInsideBlock
(BlockState state) void
onItemPickup
(ItemEntity itemEntity) void
void
void
openCommandBlock
(CommandBlockEntity commandBlock) void
openHorseInventory
(AbstractHorse horse, Container inventory) void
openItemGui
(ItemStack stack, InteractionHand hand) openMenu
(MenuProvider menu) openMenu
(MenuProvider menu, Consumer<RegistryFriendlyByteBuf> extraDataWriter) Request to open a GUI on the client, from the servervoid
openTextEdit
(SignBlockEntity signEntity, boolean isFrontText) void
playNotifySound
(SoundEvent sound, SoundSource source, float volume, float pitch) protected void
protected void
void
readAdditionalSaveData
(CompoundTag compound) (abstract) Protected helper method to read subclass entity data from NBT.private static GameType
readPlayerMode
(CompoundTag tag, String key) void
Force the name displayed in the tab list to refresh, by firingPlayerEvent.TabListNameFormat
.int
void
void
int
resetRecipes
(Collection<RecipeHolder<?>> recipes) void
void
void
restoreFrom
(ServerPlayer that, boolean keepEverything) void
rideTick()
void
sendChatMessage
(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundType) void
sendMerchantOffers
(int containerId, MerchantOffers offers, int level, int xp, boolean showProgress, boolean canRestock) void
sendServerStatus
(ServerStatus serverStatus) void
sendSystemMessage
(Component component) void
sendSystemMessage
(Component p_component, boolean bypassHiddenChat) void
void
setChatSession
(RemoteChatSession chatSession) void
setChunkTrackingView
(ChunkTrackingView chunkTrackingView) void
setExperienceLevels
(int level) void
setExperiencePoints
(int experiencePoints) boolean
setGameMode
(GameType gameMode) void
setKnownMovement
(Vec3 knownMovement) void
setLastSectionPos
(SectionPos sectionPos) void
setPlayerInput
(float strafe, float forward, boolean jumping, boolean sneaking) void
setRaidOmenPosition
(BlockPos raidOmenPosition) void
setRespawnPosition
(ResourceKey<Level> dimension, BlockPos position, float angle, boolean forced, boolean sendMessage) void
setServerLevel
(ServerLevel level) void
setSpawnExtraParticlesOnFall
(boolean spawnExtraParticlesOnFall) void
setTabListFooter
(Component footer) Set the tab list footer while preserving the header.void
setTabListHeader
(Component header) Set the tab list header while preserving the footer.void
setTabListHeaderFooter
(Component header, Component footer) Set the tab list header and footer at once.boolean
shouldFilterMessageTo
(ServerPlayer player) void
boolean
startRiding
(Entity vehicle, boolean force) com.mojang.datafixers.util.Either
<Player.BedSleepingProblem, Unit> void
startSleeping
(BlockPos pos) void
void
stopSleepInBed
(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) private void
void
swing
(InteractionHand hand) void
Called when the entity picks up an item.void
teleportRelative
(double dx, double dy, double dz) void
teleportTo
(double x, double y, double z) Sets the position of the entity and updates the 'last' variablesvoid
teleportTo
(ServerLevel newLevel, double x, double y, double z, float yaw, float pitch) boolean
teleportTo
(ServerLevel level, double x, double y, double z, Set<RelativeMovement> relativeMovements, float yRot, float xRot) private void
void
tick()
void
void
void
private void
void
triggerRecipeCrafted
(RecipeHolder<?> recipe, List<ItemStack> items) protected void
void
updateOptions
(ClientInformation clientInformation) private void
private void
updateScoreForCriteria
(ObjectiveCriteria criteria, int points) protected void
updateUsingItem
(ItemStack usingItem) Methods inherited from class net.minecraft.world.entity.player.Player
actuallyHurt, addItem, aiStep, animateHurt, awardStat, awardStat, awardStat, blockActionRestricted, blockInteractionRange, blockUsingShield, canBeHitByProjectile, canBeSeenAsEnemy, canEat, canInteractWithBlock, canInteractWithEntity, canInteractWithEntity, canPlayerFitWithinBlocksAndEntitiesWhen, canSprint, canTakeItem, canUseGameMasterBlocks, canUseSlot, causeFallDamage, causeFoodExhaustion, createAttributes, defineSynchedData, destroyVanishingCursedItems, disableShield, doAutoAttackOnTouch, doesEmitEquipEvent, doWaterSplashEffect, drop, dropEquipment, eat, entityInteractionRange, freeAt, getAbilities, getAbsorptionAmount, getArmorSlots, getAttackStrengthScale, getBaseExperienceReward, getBlockSpeedFactor, getCooldowns, getCurrentItemAttackStrengthDelay, getDeathSound, getDefaultDimensions, getDestroySpeed, getDigSpeed, getDimensionChangingDelay, getDismountPoses, getDisplayName, getEnchantmentSeed, getEnderChestInventory, getFallSounds, getFireImmuneTicks, getFlyingSpeed, getFoodData, getForcedPose, getGameProfile, getHandSlots, getHurtDir, getHurtSound, getInventory, getItemBySlot, getLastDeathLocation, getLuck, getMainArm, getMaxHeadRotationRelativeToBody, getMovementEmission, getName, getPrefixes, getProjectile, getRopeHoldPosition, getScore, getScoreboard, getScoreboardName, getShoulderEntityLeft, getShoulderEntityRight, getSleepTimer, getSlot, getSoundSource, getSpeed, getSuffixes, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getWeaponItem, getXpNeededForNextLevel, handleEntityEvent, hasContainerOpen, hasCorrectToolForDrops, hasCorrectToolForDrops, hasInfiniteMaterials, hurtArmor, hurtCurrentlyUsedShield, hurtHelmet, increaseScore, interactOn, internalSetAbsorptionAmount, isAffectedByFluids, isAlwaysExperienceDropper, isAlwaysTicking, isHurt, isIgnoringFallDamageFromCurrentImpulse, isImmobile, isLocalPlayer, isModelPartShown, isPushedByFluid, isReducedDebugInfo, isScoping, isSecondaryUseActive, isSleepingLongEnough, isStayingOnGroundSurface, isSwimming, jumpFromGround, killedEntity, makeStuckInBlock, maybeBackOffFromEdge, mayBuild, mayUseItemAt, openJigsawBlock, openMinecartCommandBlock, openStructureBlock, playSound, playStepSound, refreshDisplayName, remove, removeEntitiesOnShoulder, removeVehicle, resetAttackStrengthTicker, resetCurrentImpulseContext, respawn, serverAiStep, setEntityOnShoulder, setForcedPose, setIgnoreFallDamageFromCurrentImpulse, setItemSlot, setLastDeathLocation, setMainArm, setReducedDebugInfo, setRemainingFireTicks, setScore, setShoulderEntityLeft, setShoulderEntityRight, shouldBeSaved, shouldShowName, startAutoSpinAttack, startFallFlying, stopFallFlying, stopSleeping, sweepAttack, tryResetCurrentImpulseContext, tryToStartFallFlying, updateIsUnderwater, updatePlayerPose, updateSwimming, updateTutorialInventoryAction, wantsToStopRiding
Methods inherited from class net.minecraft.world.entity.LivingEntity
activeLocationDependentEnchantments, addEffect, addEffect, areAllEffectsAmbient, attackable, baseTick, blockedByShield, brainProvider, calculateEntityAnimation, calculateFallDamage, canAttack, canAttack, canAttackType, canBeAffected, canBeSeenByAnyone, canBreatheUnderwater, canDisableShield, canFreeze, canStandOnFluid, canUsePortal, checkAutoSpinAttack, clearSleepingPos, createLivingAttributes, createWitherRose, decreaseAirSupply, doHurtEquipment, doHurtTarget, doPush, dropAllDeathLoot, dropCustomDeathLoot, dropExperience, dropFromLootTable, eat, equipmentHasChanged, forceAddEffect, getActiveEffects, getActiveEffectsMap, getAgeScale, getAllSlots, getArmorAndBodyArmorSlots, getArmorCoverPercentage, getArmorValue, getArrowCount, getAttackAnim, getAttribute, getAttributeBaseValue, getAttributes, getAttributeValue, getBedOrientation, getBoundingBoxForCulling, getBrain, getCombatTracker, getComfortableFallDistance, getCurrentSwingDuration, getDamageAfterArmorAbsorb, getDamageAfterMagicAbsorb, getDefaultGravity, getDimensions, getDrinkingSound, getEatingSound, getEffect, getEquipmentSlotForItem, getExperienceReward, getFallFlyingTicks, getFluidFallingAdjustedMovement, getHealth, getHitbox, getItemInHand, getJumpBoostPower, getJumpPower, getJumpPower, getKillCredit, getKnockback, getLastAttacker, getLastClimbablePos, getLastDamageSource, getLastHurtByMob, getLastHurtByMobTimestamp, getLastHurtMob, getLastHurtMobTimestamp, getLocalBoundsForPose, getLootTable, getLootTableSeed, getMainHandItem, getMaxAbsorption, getMaxFallDistance, getMaxHealth, getNoActionTime, getOffhandItem, getPassengerRidingPosition, getPreciseBodyRotation, getRelativePortalPosition, getRiddenInput, getRiddenSpeed, getScale, getSleepingPos, getSlotForHand, getSoundVolume, getStingerCount, getSwimAmount, getTicksUsingItem, getUsedItemHand, getUseItem, getUseItemRemainingTicks, getViewYRot, getVisibilityPercent, getVisualRotationYInDegrees, getVoicePitch, getWaterSlowDown, getYHeadRot, goDownInWater, handleDamageEvent, handleRelativeFrictionAndCalculateMovement, hasEffect, hasItemInSlot, hasLandedInLiquid, hasLineOfSight, heal, igniteForTicks, increaseAirSupply, isAffectedByPotions, isAlive, isAutoSpinAttack, isBaby, isBlocking, isCurrentlyGlowing, isDamageSourceBlocked, isDeadOrDying, isFallFlying, isHolding, isHolding, isInvertedHealAndHarm, isInWall, isPickable, isPushable, isSensitiveToWater, isSleeping, isSuppressingSlidingDownLadder, isUsingItem, isVisuallySwimming, jumpInLiquid, kill, knockback, lerpHeadRotationStep, lerpHeadTo, lerpTargetX, lerpTargetXRot, lerpTargetY, lerpTargetYRot, lerpTargetZ, lerpTo, makeBrain, makeSound, maxUpStep, onBelowWorld, onClimbable, onEquipItem, onSyncedDataUpdated, playBlockFallSound, playHurtSound, push, randomTeleport, recreateFromPacket, releaseUsingItem, removeAllEffects, removeEffect, removeEffectNoUpdate, removeEffectParticles, removeEffectsCuredBy, removeFrost, resetForwardDirectionOfRelativePortalPosition, sanitizeScale, sendEffectToPassengers, setAbsorptionAmount, setArrowCount, setDiscardFriction, setHealth, setItemInHand, setJumping, setLastHurtByMob, setLastHurtByPlayer, setLastHurtMob, setLivingEntityFlag, setNoActionTime, setRecordPlayingNearby, setSleepingPos, setSpeed, setSprinting, setStingerCount, setYBodyRot, setYHeadRot, shouldDiscardFriction, shouldDropExperience, shouldDropLoot, shouldRiderFaceForward, skipDropExperience, startUsingItem, stopUsingItem, swing, tickDeath, tickEffects, tickHeadTurn, tickRidden, triggerItemUseEffects, triggerOnDeathMobEffects, tryAddFrost, updateEffectVisibility, updateSwingTime, updateWalkAnimation, verifyEquippedItem, wasExperienceConsumed, wouldNotSuffocateAtTargetPose
Methods inherited from class net.minecraft.world.entity.Entity
absMoveTo, absMoveTo, absRotateTo, acceptsFailure, acceptsSuccess, addDeltaMovement, addPassenger, addTag, applyGravity, blockPosition, calculateUpVector, calculateViewVector, canAddPassenger, canBeCollidedWith, canChangeDimensions, canCollideWith, canControlVehicle, canRide, canSpawnSprintParticle, canTrample, captureDrops, captureDrops, checkBelowWorld, checkDespawn, checkInsideBlocks, checkSlowFallDistance, checkSupportingBlock, chunkPosition, clearFire, closerThan, closerThan, collideBoundingBox, copyPosition, couldAcceptPassenger, countPlayerPassengers, createCommandSourceStack, createHoverEvent, damageSources, dampensVibrations, deflection, discard, dismountsUnderwater, displayFireAnimation, distanceTo, distanceToSqr, distanceToSqr, distanceToSqr, ejectPassengers, equals, extinguishFire, fillCrashReportCategory, fireImmune, fixupDimensions, fudgePositionAfterSizeChange, gameEvent, gameEvent, getAddEntityPacket, getAirSupply, getAttachments, getBbHeight, getBbWidth, getBlockExplosionResistance, getBlockJumpFactor, getBlockPosBelowThatAffectsMyMovement, getBlockStateOn, getBlockStateOnLegacy, getBlockX, getBlockY, getBlockZ, getBoundingBox, getCapability, getCapability, getCollisionHorizontalEscapeVector, getCommandSenderWorld, getControlledVehicle, getControllingPassenger, getCustomName, getDefaultPassengerAttachmentPoint, getDeltaMovement, getDirection, getDismountLocationForPassenger, getEncodeId, getEntityData, getEyeHeight, getEyeHeight, getEyeInFluidType, getEyePosition, getEyePosition, getEyeY, getFirstPassenger, getFluidHeight, getFluidJumpThreshold, getFluidTypeHeight, getForward, getGravity, getHandHoldingItemAngle, getId, getInBlockState, getIndirectPassengers, getLeashOffset, getLeashOffset, getLightLevelDependentMagicValue, getLightProbePosition, getLookAngle, getMaxAirSupply, getMaxHeightFluidType, getMotionDirection, getNearestViewDirection, getOnPos, getOnPos, getOnPosLegacy, getPassengerAttachmentPoint, getPassengers, getPassengersAndSelf, getPercentFrozen, getPersistentData, getPickRadius, getPickResult, getPistonPushReaction, getPortalCooldown, getPose, getPosition, getPositionCodec, getPrimaryStepSoundBlockPos, getRandom, getRandomX, getRandomY, getRandomZ, getRemainingFireTicks, getRemovalReason, getRootVehicle, getRotationVector, getSelfAndPassengers, getServer, getSharedFlag, getStringUUID, getTags, getTeam, getTeamColor, getTicksFrozen, getTicksRequiredToFreeze, getType, getTypeName, getUpVector, getUUID, getVehicle, getVehicleAttachmentPoint, getViewScale, getViewVector, getViewXRot, getX, getX, getXRot, getY, getY, getYRot, getZ, getZ, handlePortal, hasControllingPassenger, hasCustomName, hasExactlyOnePlayerPassenger, hasGlowingTag, hashCode, hasIndirectPassenger, hasPassenger, hasPassenger, hasPermissions, hasPose, igniteForSeconds, ignoreExplosion, interact, interactAt, is, isAddedToLevel, isAlliedTo, isAlliedTo, isAttackable, isColliding, isControlledByLocalInstance, isCrouching, isCustomNameVisible, isDescending, isDiscrete, isEffectiveAi, isEyeInFluid, isFlapping, isFree, isFreezing, isFullyFrozen, isHorizontalCollisionMinor, isIgnoringBlockTriggers, isInFluidType, isInFluidType, isInLava, isInLiquid, isInvisible, isInvisibleTo, isInvulnerable, isInWater, isInWaterOrBubble, isInWaterOrRain, isInWaterRainOrBubble, isNoGravity, isOnFire, isOnPortalCooldown, isOnRails, isPassenger, isPassengerOfSameVehicle, isRemoved, isShiftKeyDown, isSilent, isSprinting, isSteppingCarefully, isSupportedBy, isSuppressingBounce, isUnderWater, isVehicle, isVisuallyCrawling, lavaHurt, lerpMotion, lerpPositionAndRotationStep, level, limitPistonMovement, load, makeBoundingBox, markHurt, mirror, move, moveRelative, moveTo, moveTo, moveTo, moveTo, moveTowardsClosestSpace, newDoubleList, newFloatList, nextStep, onAboveBubbleCol, onAddedToLevel, onClientRemoval, onFlap, onGround, onInsideBubbleColumn, onlyOpCanSetNbt, onPassengerTurned, onRemovedFromLevel, onSyncedDataUpdated, pick, placePortalTicket, playCombinationStepSounds, playEntityOnFireExtinguishedSound, playerTouch, playMuffledStepSound, playSound, playSwimSound, position, positionRider, positionRider, processFlappingMovement, push, push, reapplyPosition, refreshDimensions, registryAccess, removeAfterChangingDimensions, removePassenger, removeTag, repositionEntityAfterLoad, restoreFrom, revive, rotate, save, saveAsPassenger, saveWithoutId, setAirSupply, setAsInsidePortal, setBoundingBox, setCustomName, setCustomNameVisible, setData, setDeltaMovement, setDeltaMovement, setFluidTypeHeight, setGlowingTag, setId, setInvisible, setInvulnerable, setIsInPowderSnow, setLevel, setLevelCallback, setNoGravity, setOldPosAndRot, setOnGround, setOnGroundWithMovement, setPortalCooldown, setPortalCooldown, setPos, setPos, setPose, setPosRaw, setRemoved, setRot, setSharedFlag, setSharedFlagOnFire, setShiftKeyDown, setSilent, setSwimming, setTicksFrozen, setUUID, setViewScale, setXRot, setYRot, shouldBlockExplode, shouldInformAdmins, shouldRender, shouldRenderAtSqrDistance, showVehicleHealth, skipAttackInteraction, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnSprintParticle, startRiding, startSeenByPlayer, stopSeenByPlayer, syncPacketPositionCodec, thunderHit, toString, touchingUnloadedChunk, trackingPosition, tryCheckInsideBlocks, turn, unRide, unsetRemoved, updateDynamicGameEventListener, updateFluidHeightAndDoFluidPushing, updateFluidHeightAndDoFluidPushing, updateInWaterStateAndDoFluidPushing, waterSwimSound
Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, removeData, serializeAttachments
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minecraft.commands.CommandSource
alwaysAccepts
Methods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData
Methods inherited from interface net.neoforged.neoforge.common.extensions.IEntityExtension
canBeRiddenUnderFluidType, canFluidExtinguish, canHydrateInFluidType, canRiderInteract, canStartSwimming, canTrample, captureDrops, captureDrops, copyAttachmentsFrom, deserializeNBT, getClassification, getEyeInFluidType, getFluidFallDistanceModifier, getFluidMotionScale, getFluidTypeHeight, getMaxHeightFluidType, getParts, getPersistentData, getPickedResult, getSoundFromFluidType, hasCustomOutlineRendering, isAddedToLevel, isEyeInFluidType, isInFluidType, isInFluidType, isInFluidType, isInFluidType, isInFluidType, isMultipartEntity, isPushedByFluid, onAddedToLevel, onRemovedFromLevel, revive, sendPairingData, serializeNBT, shouldRiderSit
Methods inherited from interface net.neoforged.neoforge.common.extensions.ILivingEntityExtension
canDrownInFluidType, canSwimInFluidType, jumpInFluid, moveInFluid, onDamageTaken, self, sinkInFluid
Methods inherited from interface net.neoforged.neoforge.common.extensions.IPlayerExtension
isCloseEnough, isFakePlayer, mayFly, openMenu
Methods inherited from interface net.minecraft.world.scores.ScoreHolder
getFeedbackDisplayName
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ
private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ- See Also:
-
NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y
private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y- See Also:
-
FLY_STAT_RECORDING_SPEED
private static final int FLY_STAT_RECORDING_SPEED- See Also:
-
INTERACTION_DISTANCE_VERIFICATION_BUFFER
public static final double INTERACTION_DISTANCE_VERIFICATION_BUFFER- See Also:
-
CREATIVE_BLOCK_INTERACTION_RANGE_MODIFIER
-
CREATIVE_ENTITY_INTERACTION_RANGE_MODIFIER
-
connection
-
server
-
gameMode
-
advancements
-
stats
-
lastRecordedHealthAndAbsorption
private float lastRecordedHealthAndAbsorptionthe total health of the player, includes actual health and absorption health. Updated every tick. -
lastRecordedFoodLevel
private int lastRecordedFoodLevel -
lastRecordedAirLevel
private int lastRecordedAirLevel -
lastRecordedArmor
private int lastRecordedArmor -
lastRecordedLevel
private int lastRecordedLevel -
lastRecordedExperience
private int lastRecordedExperience -
lastSentHealth
private float lastSentHealth -
lastSentFood
private int lastSentFood -
lastFoodSaturationZero
private boolean lastFoodSaturationZero -
lastSentExp
private int lastSentExp -
spawnInvulnerableTime
private int spawnInvulnerableTime -
chatVisibility
-
canChatColor
private boolean canChatColor -
lastActionTime
private long lastActionTime -
camera
The entity the player is currently spectating through. -
isChangingDimension
private boolean isChangingDimension -
seenCredits
public boolean seenCredits -
recipeBook
-
levitationStartPos
-
levitationStartTime
private int levitationStartTime -
disconnected
private boolean disconnected -
requestedViewDistance
private int requestedViewDistance -
language
-
startingToFallPosition
-
enteredNetherPosition
-
enteredLavaOnVehiclePosition
-
lastSectionPos
Player section position as last updated by TicketManager, used by ChunkManager -
chunkTrackingView
-
respawnDimension
-
respawnPosition
-
respawnForced
private boolean respawnForced -
respawnAngle
private float respawnAngle -
textFilter
-
textFilteringEnabled
private boolean textFilteringEnabled -
allowsListing
private boolean allowsListing -
spawnExtraParticlesOnFall
private boolean spawnExtraParticlesOnFall -
wardenSpawnTracker
-
raidOmenPosition
-
lastKnownClientMovement
-
containerSynchronizer
-
containerListener
-
chatSession
-
object
-
containerCounter
private int containerCounter -
wonGame
public boolean wonGame -
tabListHeader
-
hasTabListName
private boolean hasTabListName -
tabListDisplayName
-
-
Constructor Details
-
ServerPlayer
public ServerPlayer(MinecraftServer server, ServerLevel level, com.mojang.authlib.GameProfile gameProfile, ClientInformation clientInformation)
-
-
Method Details
-
adjustSpawnLocation
- Overrides:
adjustSpawnLocation
in classEntity
-
getCoprime
private int getCoprime(int spawnArea) -
readAdditionalSaveData
(abstract) Protected helper method to read subclass entity data from NBT.- Overrides:
readAdditionalSaveData
in classPlayer
-
addAdditionalSaveData
- Overrides:
addAdditionalSaveData
in classPlayer
-
setExperiencePoints
public void setExperiencePoints(int experiencePoints) -
setExperienceLevels
public void setExperienceLevels(int level) -
giveExperienceLevels
public void giveExperienceLevels(int levels) Add experience levels to this player.- Overrides:
giveExperienceLevels
in classPlayer
-
onEnchantmentPerformed
- Overrides:
onEnchantmentPerformed
in classPlayer
-
initMenu
-
initInventoryMenu
public void initInventoryMenu() -
onEnterCombat
public void onEnterCombat()- Overrides:
onEnterCombat
in classLivingEntity
-
onLeaveCombat
public void onLeaveCombat()- Overrides:
onLeaveCombat
in classLivingEntity
-
onInsideBlock
- Overrides:
onInsideBlock
in classEntity
-
createItemCooldowns
- Overrides:
createItemCooldowns
in classPlayer
-
tick
public void tick() -
updatePlayerAttributes
private void updatePlayerAttributes() -
doTick
public void doTick() -
resetFallDistance
public void resetFallDistance()- Overrides:
resetFallDistance
in classEntity
-
trackStartFallingPosition
public void trackStartFallingPosition() -
trackEnteredOrExitedLavaOnVehicle
public void trackEnteredOrExitedLavaOnVehicle() -
updateScoreForCriteria
-
die
Called when the mob's health reaches 0. -
tellNeutralMobsThatIDied
private void tellNeutralMobsThatIDied() -
awardKillScore
- Overrides:
awardKillScore
in classEntity
-
handleTeamKill
private void handleTeamKill(ScoreHolder scoreHolder, ScoreHolder teamMember, ObjectiveCriteria[] crtieria) -
hurt
Called when the entity is attacked. -
canHarmPlayer
- Overrides:
canHarmPlayer
in classPlayer
-
isPvpAllowed
private boolean isPvpAllowed() -
findRespawnPositionAndUseSpawnBlock
public DimensionTransition findRespawnPositionAndUseSpawnBlock(boolean keepInventory, DimensionTransition.PostDimensionTransition postDimensionTransition) -
findRespawnAndUseSpawnBlock
private static Optional<ServerPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(ServerLevel level, BlockPos pos, float angle, boolean forced, boolean keepInventory) -
showEndCredits
public void showEndCredits() -
changeDimension
- Overrides:
changeDimension
in classEntity
-
triggerDimensionChangeTriggers
-
broadcastToPlayer
- Overrides:
broadcastToPlayer
in classEntity
-
take
Called when the entity picks up an item.- Overrides:
take
in classLivingEntity
-
startSleepInBed
public com.mojang.datafixers.util.Either<Player.BedSleepingProblem,Unit> startSleepInBed(BlockPos at) - Overrides:
startSleepInBed
in classPlayer
-
startSleeping
- Overrides:
startSleeping
in classLivingEntity
-
bedInRange
-
isReachableBedBlock
-
bedBlocked
-
stopSleepInBed
public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) - Overrides:
stopSleepInBed
in classPlayer
-
dismountTo
public void dismountTo(double x, double y, double z) - Overrides:
dismountTo
in classEntity
-
isInvulnerableTo
Returns whether this Entity is invulnerable to the given DamageSource.- Overrides:
isInvulnerableTo
in classPlayer
-
checkFallDamage
- Overrides:
checkFallDamage
in classLivingEntity
-
onChangedBlock
- Overrides:
onChangedBlock
in classLivingEntity
-
doCheckFallDamage
public void doCheckFallDamage(double movementX, double movementY, double movementZ, boolean onGround) -
onExplosionHit
- Overrides:
onExplosionHit
in classEntity
-
pushEntities
protected void pushEntities()- Overrides:
pushEntities
in classLivingEntity
-
openTextEdit
- Overrides:
openTextEdit
in classPlayer
-
nextContainerCounter
private void nextContainerCounter() -
openMenu
-
openMenu
public OptionalInt openMenu(@Nullable MenuProvider menu, @Nullable Consumer<RegistryFriendlyByteBuf> extraDataWriter) Description copied from interface:IPlayerExtension
Request to open a GUI on the client, from the serverRefer to
IMenuTypeExtension.create(IContainerFactory)
for creating aMenuType
that can consume the extra data sent to the client by this method.The maximum size for #extraDataWriter is 32600 bytes.
- Parameters:
menu
- A supplier of container properties including the registry name of the containerextraDataWriter
- Consumer to write any additional data the GUI needs. This data is written afterinvalid reference
IMenuProviderExtension#writeClientSideData(AbstractContainerMenu, RegistryFriendlyByteBuf)
- Returns:
- The window ID of the opened GUI, or empty if the GUI could not be opened
-
sendMerchantOffers
public void sendMerchantOffers(int containerId, MerchantOffers offers, int level, int xp, boolean showProgress, boolean canRestock) - Overrides:
sendMerchantOffers
in classPlayer
-
openHorseInventory
- Overrides:
openHorseInventory
in classPlayer
-
openItemGui
- Overrides:
openItemGui
in classPlayer
-
openCommandBlock
- Overrides:
openCommandBlock
in classPlayer
-
closeContainer
public void closeContainer()- Overrides:
closeContainer
in classPlayer
-
doCloseContainer
public void doCloseContainer()- Overrides:
doCloseContainer
in classPlayer
-
setPlayerInput
public void setPlayerInput(float strafe, float forward, boolean jumping, boolean sneaking) -
travel
-
rideTick
public void rideTick() -
checkMovementStatistics
public void checkMovementStatistics(double dx, double dy, double dz) -
checkRidingStatistics
public void checkRidingStatistics(double dx, double dy, double dz) -
didNotMove
private static boolean didNotMove(double dx, double dy, double dz) -
awardStat
Adds a value to a statistic field. -
resetStat
-
awardRecipes
- Overrides:
awardRecipes
in classPlayer
-
triggerRecipeCrafted
- Overrides:
triggerRecipeCrafted
in classPlayer
-
awardRecipesByKey
- Overrides:
awardRecipesByKey
in classPlayer
-
resetRecipes
- Overrides:
resetRecipes
in classPlayer
-
giveExperiencePoints
public void giveExperiencePoints(int xpPoints) - Overrides:
giveExperiencePoints
in classPlayer
-
disconnect
public void disconnect() -
hasDisconnected
public boolean hasDisconnected() -
resetSentInfo
public void resetSentInfo() -
displayClientMessage
- Overrides:
displayClientMessage
in classPlayer
-
completeUsingItem
protected void completeUsingItem()- Overrides:
completeUsingItem
in classLivingEntity
-
lookAt
- Overrides:
lookAt
in classLivingEntity
-
lookAt
public void lookAt(EntityAnchorArgument.Anchor fromAnchor, Entity entity, EntityAnchorArgument.Anchor toAnchor) -
restoreFrom
-
onEffectAdded
- Overrides:
onEffectAdded
in classLivingEntity
-
onEffectUpdated
protected void onEffectUpdated(MobEffectInstance effectInstance, boolean forced, @Nullable Entity entity) - Overrides:
onEffectUpdated
in classLivingEntity
-
onEffectRemoved
- Overrides:
onEffectRemoved
in classLivingEntity
-
teleportTo
public void teleportTo(double x, double y, double z) Sets the position of the entity and updates the 'last' variables- Overrides:
teleportTo
in classEntity
-
teleportRelative
public void teleportRelative(double dx, double dy, double dz) - Overrides:
teleportRelative
in classEntity
-
teleportTo
public boolean teleportTo(ServerLevel level, double x, double y, double z, Set<RelativeMovement> relativeMovements, float yRot, float xRot) - Overrides:
teleportTo
in classEntity
-
moveTo
public void moveTo(double x, double y, double z) -
crit
Called when the entity is dealt a critical hit. -
magicCrit
Called when the entity hit is dealt extra melee damage due to an enchantment. -
onUpdateAbilities
public void onUpdateAbilities()- Overrides:
onUpdateAbilities
in classPlayer
-
serverLevel
-
setGameMode
-
isSpectator
public boolean isSpectator()- Specified by:
isSpectator
in classPlayer
-
isCreative
public boolean isCreative()- Specified by:
isCreative
in classPlayer
-
sendSystemMessage
- Specified by:
sendSystemMessage
in interfaceCommandSource
- Overrides:
sendSystemMessage
in classEntity
-
sendSystemMessage
-
sendChatMessage
public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundType) -
getIpAddress
-
updateOptions
-
clientInformation
-
canChatInColor
public boolean canChatInColor() -
getChatVisibility
-
acceptsSystemMessages
private boolean acceptsSystemMessages(boolean bypassHiddenChat) -
acceptsChatMessages
private boolean acceptsChatMessages() -
requestedViewDistance
public int requestedViewDistance() -
sendServerStatus
-
getPermissionLevel
protected int getPermissionLevel()- Overrides:
getPermissionLevel
in classEntity
-
resetLastActionTime
public void resetLastActionTime() -
getStats
-
getRecipeBook
-
updateInvisibilityStatus
protected void updateInvisibilityStatus()- Overrides:
updateInvisibilityStatus
in classLivingEntity
-
getCamera
-
setCamera
-
processPortalCooldown
protected void processPortalCooldown()- Overrides:
processPortalCooldown
in classEntity
-
attack
Attacks for the player the targeted entity with the currently equipped item. The equipped item has hitEntity called on it. Args: targetEntity -
getLastActionTime
public long getLastActionTime() -
getTabListDisplayName
-
swing
- Overrides:
swing
in classLivingEntity
-
isChangingDimension
public boolean isChangingDimension() -
hasChangedDimension
public void hasChangedDimension() -
getAdvancements
-
teleportTo
-
getRespawnPosition
-
getRespawnAngle
public float getRespawnAngle() -
getRespawnDimension
-
isRespawnForced
public boolean isRespawnForced() -
copyRespawnPosition
-
setRespawnPosition
public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos position, float angle, boolean forced, boolean sendMessage) -
getLastSectionPos
-
setLastSectionPos
-
getChunkTrackingView
-
setChunkTrackingView
-
playNotifySound
- Overrides:
playNotifySound
in classPlayer
-
drop
Creates and drops the provided item. Depending on the dropAround, it will drop the item around the player, instead of dropping the item from where the player is pointing at. Likewise, if includeThrowerName is true, the dropped item entity will have the thrower set as the player. -
getLanguage
Returns the language last reported by the player as their local language. Defaults to en_us if the value is unknown. -
getTabListHeader
-
setTabListHeader
Set the tab list header while preserving the footer.- Parameters:
header
- the new header, orComponent.empty()
to clear
-
refreshTabListName
public void refreshTabListName()Force the name displayed in the tab list to refresh, by firingPlayerEvent.TabListNameFormat
. -
getTextFilter
-
setServerLevel
-
readPlayerMode
-
calculateGameModeForNewPlayer
-
loadGameTypes
-
storeGameTypes
-
isTextFilteringEnabled
public boolean isTextFilteringEnabled()- Overrides:
isTextFilteringEnabled
in classPlayer
-
shouldFilterMessageTo
-
mayInteract
- Overrides:
mayInteract
in classEntity
-
updateUsingItem
- Overrides:
updateUsingItem
in classLivingEntity
-
drop
public boolean drop(boolean dropStack) - Parameters:
dropStack
- Whether to drop the entire stack of items. Iffalse
, drops a single item.
-
allowsListing
public boolean allowsListing() -
getWardenSpawnTracker
- Overrides:
getWardenSpawnTracker
in classPlayer
-
setSpawnExtraParticlesOnFall
public void setSpawnExtraParticlesOnFall(boolean spawnExtraParticlesOnFall) -
onItemPickup
- Overrides:
onItemPickup
in classLivingEntity
-
setChatSession
-
getChatSession
-
indicateDamage
public void indicateDamage(double xDistance, double zDistance) - Overrides:
indicateDamage
in classLivingEntity
-
startRiding
- Overrides:
startRiding
in classEntity
-
stopRiding
public void stopRiding()- Overrides:
stopRiding
in classLivingEntity
-
createCommonSpawnInfo
-
setRaidOmenPosition
-
clearRaidOmenPosition
public void clearRaidOmenPosition() -
getRaidOmenPosition
-
getKnownMovement
- Overrides:
getKnownMovement
in classEntity
-
setKnownMovement
-
getEnchantedDamage
- Overrides:
getEnchantedDamage
in classPlayer
-
onEquippedItemBroken
- Overrides:
onEquippedItemBroken
in classLivingEntity
-