AbstractClientPlayer.java
net.minecraft.client.player.AbstractClientPlayer
信息
- 全限定名:net.minecraft.client.player.AbstractClientPlayer
- 类型:public abstract class
- 包:net.minecraft.client.player
- 源码路径:src/main/java/net/minecraft/client/player/AbstractClientPlayer.java
- 起始行号:L22
- 继承:Player
- 实现:ClientAvatarEntity
- 职责:
TODO
字段/常量
-
playerInfo- 类型:
PlayerInfo - 修饰符:
private - 源码定位:
L23 - 说明:
TODO
- 类型:
-
showExtraEars- 类型:
boolean - 修饰符:
private final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
clientAvatarState- 类型:
ClientAvatarState - 修饰符:
private final - 源码定位:
L25 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public AbstractClientPlayer(ClientLevel level, GameProfile gameProfile) @ L27
- 构造器名:AbstractClientPlayer
- 源码定位:L27
- 修饰符:public
参数:
- level: ClientLevel
- gameProfile: GameProfile
说明:
TODO
方法
下面的方法块按源码顺序生成。
public GameType gameMode() @ L32
- 方法名:gameMode
- 源码定位:L32
- 返回类型:GameType
- 修饰符:public
参数:
- 无
说明:
TODO
protected PlayerInfo getPlayerInfo() @ L38
- 方法名:getPlayerInfo
- 源码定位:L38
- 返回类型:PlayerInfo
- 修饰符:protected
参数:
- 无
说明:
TODO
public void tick() @ L46
- 方法名:tick
- 源码定位:L46
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
protected void addWalkedDistance(float distance) @ L52
- 方法名:addWalkedDistance
- 源码定位:L52
- 返回类型:void
- 修饰符:protected
参数:
- distance: float
说明:
TODO
public ClientAvatarState avatarState() @ L56
- 方法名:avatarState
- 源码定位:L56
- 返回类型:ClientAvatarState
- 修饰符:public
参数:
- 无
说明:
TODO
public PlayerSkin getSkin() @ L61
- 方法名:getSkin
- 源码定位:L61
- 返回类型:PlayerSkin
- 修饰符:public
参数:
- 无
说明:
TODO
public Parrot.Variant getParrotVariantOnShoulder(boolean left) @ L67
- 方法名:getParrotVariantOnShoulder
- 源码定位:L67
- 返回类型:Parrot.Variant
- 修饰符:public
参数:
- left: boolean
说明:
TODO
public void rideTick() @ L72
- 方法名:rideTick
- 源码定位:L72
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void aiStep() @ L78
- 方法名:aiStep
- 源码定位:L78
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
protected void updateBob() @ L84
- 方法名:updateBob
- 源码定位:L84
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public float getFieldOfViewModifier(boolean firstPerson, float effectScale) @ L95
- 方法名:getFieldOfViewModifier
- 源码定位:L95
- 返回类型:float
- 修饰符:public
参数:
- firstPerson: boolean
- effectScale: float
说明:
TODO
public boolean showExtraEars() @ L119
- 方法名:showExtraEars
- 源码定位:L119
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public abstract class AbstractClientPlayer extends Player implements ClientAvatarEntity {
private @Nullable PlayerInfo playerInfo;
private final boolean showExtraEars;
private final ClientAvatarState clientAvatarState = new ClientAvatarState();
public AbstractClientPlayer(ClientLevel level, GameProfile gameProfile) {
super(level, gameProfile);
this.showExtraEars = "deadmau5".equals(this.getGameProfile().name());
}
@Override
public @Nullable GameType gameMode() {
PlayerInfo info = this.getPlayerInfo();
return info != null ? info.getGameMode() : null;
}
protected @Nullable PlayerInfo getPlayerInfo() {
if (this.playerInfo == null) {
this.playerInfo = Minecraft.getInstance().getConnection().getPlayerInfo(this.getUUID());
}
return this.playerInfo;
}
@Override
public void tick() {
this.clientAvatarState.tick(this.position(), this.getDeltaMovement());
super.tick();
}
protected void addWalkedDistance(float distance) {
this.clientAvatarState.addWalkDistance(distance);
}
@Override
public ClientAvatarState avatarState() {
return this.clientAvatarState;
}
@Override
public PlayerSkin getSkin() {
PlayerInfo info = this.getPlayerInfo();
return info == null ? DefaultPlayerSkin.get(this.getUUID()) : info.getSkin();
}
@Override
public Parrot.@Nullable Variant getParrotVariantOnShoulder(boolean left) {
return (left ? this.getShoulderParrotLeft() : this.getShoulderParrotRight()).orElse(null);
}
@Override
public void rideTick() {
super.rideTick();
this.avatarState().resetBob();
}
@Override
public void aiStep() {
this.updateBob();
super.aiStep();
}
protected void updateBob() {
float tBob;
if (this.onGround() && !this.isDeadOrDying() && !this.isSwimming()) {
tBob = Math.min(0.1F, (float)this.getDeltaMovement().horizontalDistance());
} else {
tBob = 0.0F;
}
this.avatarState().updateBob(tBob);
}
public float getFieldOfViewModifier(boolean firstPerson, float effectScale) {
float modifier = 1.0F;
if (this.getAbilities().flying) {
modifier *= 1.1F;
}
float walkingSpeed = this.getAbilities().getWalkingSpeed();
if (walkingSpeed != 0.0F) {
float speedFactor = (float)this.getAttributeValue(Attributes.MOVEMENT_SPEED) / walkingSpeed;
modifier *= (speedFactor + 1.0F) / 2.0F;
}
if (this.isUsingItem()) {
if (this.getUseItem().is(Items.BOW)) {
float scale = Math.min(this.getTicksUsingItem() / 20.0F, 1.0F);
modifier *= 1.0F - Mth.square(scale) * 0.15F;
} else if (firstPerson && this.isScoping()) {
return 0.1F;
}
}
return Mth.lerp(effectScale, 1.0F, modifier);
}
@Override
public boolean showExtraEars() {
return this.showExtraEars;
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
字段/构造调用/返回值 - 关联成员:
ClientAvatarState()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
DefaultPlayerSkin.get()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.lerp(), Mth.square()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
返回值
- 引用位置: