> For the complete documentation index, see [llms.txt](https://turou.gitbook.io/arch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://turou.gitbook.io/arch/architectury-plugin/environment-and-onlyin.md).

# Environment & OnlyIn

### Transform to Environment

在Forge中, 为了标识某一方法只在逻辑服务端执行, 我们通常会添加@OnlyIn(Dists.DEDICATED\_SERVER)

在Fabric中, 为了标识某一方法只在逻辑服务端执行, 我们通常会添加@Environment(EnvType.SERVER)

为了统一这两个相同的需求, Architectury为我们添加了自动处理的映射关系.

在实际代码中, 我们只需要添加Environment注解即可, Architrctury会对Forge平台进行映射处理

![LightOverlay](https://s2.loli.net/2022/04/02/rU8y6HdeiV4oaXP.png)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://turou.gitbook.io/arch/architectury-plugin/environment-and-onlyin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
