> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cheart.getvapu.today/llms.txt
> Use this file to discover all available pages before exploring further.

# Unsafe

> 反射访问工具

访问原生 MC 对象（按 SRG 名反射）：

```java theme={null}
u = me.unsafe();
```

### 获取内部对象（Object 形式，只配合其他 unsafe 方法用）

```java theme={null}
Object u.minecraft()           // net.minecraft.client.Minecraft
Object u.player()              // net.minecraft.client.player.LocalPlayer
Object u.world()               // net.minecraft.client.multiplayer.ClientLevel
Object u.minecraftInstance()   // 同上别名
Object u.playerInstance()
```

### 反射

```java theme={null}
Class<?> u.forName(String fqn)

Object u.get(Object instance, String fieldName)
void   u.set(Object instance, String fieldName, Object value)

Object u.getStatic(String className, String fieldName)
void   u.setStatic(String className, String fieldName, Object value)

Object u.invoke(Object instance, String methodName, Object... args)
Object u.invokeStatic(String className, String methodName, Object... args)
Object u.newInstance(String className, Object... args)
```

<Tip>
  MC 中的类的方法名被混淆成 SRG（`m_xxxxxx_`），`methodName` / `fieldName` 必须用 SRG 名才能命中。

  您可以使用[Mappings.dev](https://mappings.dev/1.20.1/index.html)查看对应的SRG (Searge) 命名
</Tip>
