手册:getPlayerEnt

来自Minecraft基岩版开发Wiki

语法[编辑]

getPlayerEnt();

参数[编辑]

返回值
Object类型 玩家实体

效果[编辑]

获取玩家实体

注意事项[编辑]

若Object型的实体强制输出为文字,则显示为它的UUID。 除Entity.getUniqueId(Object)等一些函数外,对于其他需要填Object型实体的函数,其Object都可以用该实体的UUID值来代替。

参考[编辑]

Entity这种类型在Java源码中的定义(NativeEntity):

private static class NativeEntity extends ScriptableObject {
    public int entityId;
    public NativeEntity(int entityId) {
        this.entityId = entityId;
    }
    @Override
    public String getClassName() {
        return "NativeEntity";
    }
    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (obj instanceof NativeEntity) {
            return ((NativeEntity) obj).entityId == this.entityId;
        }
        return false;
    }
}

Template:ModPE