手冊: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