Skip to content

Commit cfa4a5b

Browse files
committed
fix: rewrite internals page
1 parent d94169d commit cfa4a5b

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

src/content/docs/paper/dev/misc/internal-code.md

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The code that runs Minecraft is not open source. Bukkit is an API that allows pl
88
is implemented by CraftBukkit and interacts with Minecraft's code. You will often hear the terms NMS and CraftBukkit
99
when talking about Minecraft internals.
1010

11-
:::danger[Using Minecraft Internals]
11+
:::danger[Using Minecraft internals]
1212

1313
Using Minecraft internals is not recommended. This is because using internal code directly is not guaranteed to be
1414
stable and it changes often. This means that your plugin may break when a new version of Minecraft is released.
@@ -24,7 +24,7 @@ NMS stands for `net.minecraft.server` and refers to a Java package that contains
2424
proprietary and is not open source. This code is not guaranteed to be stable when invoked externally and may change at
2525
any time.
2626

27-
## Accessing Minecraft Internals
27+
## Accessing Minecraft internals
2828

2929
In order to use Mojang and CraftBukkit code, you may either use the `paperweight-userdev` Gradle plugin or use reflection.
3030
[`paperweight-userdev`](https://github.com/PaperMC/paperweight-test-plugin) is the recommended way to access internal code
@@ -42,17 +42,12 @@ you should cache the [`Field`](jd:java:java.lang.reflect.Field)/
4242
[`Method`](jd:java:java.lang.reflect.Method) to prevent the performance
4343
impact of looking up the field/method each time.
4444

45-
The internal CraftBukkit code is relocated to `org.bukkit.craftbukkit.<version>` unless you run a Mojang-mapped version
46-
of Paper. This is unlikely to be the case in most production environments. This means that any attempts to reflect must
47-
include the version. For example, `org.bukkit.craftbukkit.v1_20_R2.CraftServer` is the full class and package name
48-
for the CraftServer class in version 1.20.2. You can access these classes easily with some reflection utilities.
45+
:::caution[1.20.4 and older]
4946

50-
:::caution[Removal of relocation in 1.20.5]
51-
52-
As of 1.20.5, the versioned relocation of the CraftBukkit package was removed and
53-
CraftBukkit packages are now located in `org.bukkit.craftbukkit` and not in `org.bukkit.craftbukkit.<version>`.
54-
55-
:::
47+
The internal CraftBukkit code was relocated to `org.bukkit.craftbukkit.<version>` unless you ran a Mojang-mapped version
48+
of Paper. This was unlikely to be the case in most production environments until 1.20.5. This means that any attempts to reflect had to
49+
include the version. For example, `org.bukkit.craftbukkit.v1_20_R2.CraftServer` was the full class and package name
50+
for the CraftServer class in version 1.20.2. You could access these classes easily with some reflection utilities.
5651

5752
```java
5853
private static final String CRAFTBUKKIT_PACKAGE = Bukkit.getServer().getClass().getPackageName();
@@ -65,28 +60,30 @@ public static String cbClass(String clazz) {
6560
Class.forName(cbClass("entity.CraftBee"));
6661
```
6762

68-
Minecraft's code is obfuscated. This means that the names of classes and methods are changed to make them harder to
69-
understand. Paper deobfuscates these identifiers for development; however, to provide compatibility with legacy plugins,
70-
Paper is re-obfuscated at runtime. You can use a library like [reflection-remapper](https://github.com/jpenilla/reflection-remapper) to automatically remap the
71-
reflection references. This will allow you to use the de-obfuscated, Mojang-mapped, names in your code. This is recommended as
72-
it makes the code easier to understand.
63+
:::
7364

74-
### Mojang-Mapped Servers
65+
Minecraft's code is obfuscated. This means that the names of classes and methods are changed to make them harder to
66+
understand. Paper deobfuscates these identifiers for development and since 1.20.5, also for runtime.
7567

76-
:::note[Mojang-mapped runtime as of 1.20.5]
68+
:::caution[1.20.4 and older]
7769

78-
As of 1.20.5, Paper ships with a Mojang-mapped runtime instead of reobfuscating the server to Spigot mappings.
79-
For more information, see the [plugin remapping](/paper/dev/project-setup#plugin-remapping) section and [userdev](/paper/dev/userdev#1205-and-beyond) documentation covering these changes.
70+
Previously, to provide compatibility with legacy plugins, Paper was reobfuscated at runtime.
71+
You could use a library like [reflection-remapper](https://github.com/jpenilla/reflection-remapper) to automatically remap the
72+
reflection references. This allowed you to use the deobfuscated, Mojang-mapped names in your code. This was recommended as
73+
it made the code easier to understand.
8074

8175
:::
8276

83-
Running a Mojang-Mapped (moj-map) server is an excellent way to streamline your processes because you can develop using
84-
the same mappings that will be present at runtime. This eliminates the need for remapping in your compilation. If you
85-
are creating custom plugins for your server, we highly recommend running a moj-map server. It simplifies debugging and
86-
allows you to hotswap plugins.
77+
### Mojang-mapped servers
78+
79+
Running a Mojang-mapped (moj-map) server is an excellent way to streamline your processes because you can develop using
80+
the same mappings that will be present at runtime. This eliminates the need for remapping in your compilation, which in
81+
turn simplifies debugging and allows you to hotswap plugins.
8782

88-
In the future, the Paper server will no longer undergo remapping. By adopting Mojang mappings now, you can ensure that
89-
your plugin won't require internal remapping when we make the switch.
83+
As of 1.20.5, Paper ships with a Mojang-mapped runtime by default instead of reobfuscating the server to Spigot mappings.
84+
By adopting Mojang mappings, you ensure that your plugin won't require internal remapping at runtime.
85+
For more information, see the [plugin remapping](/paper/dev/project-setup#plugin-remapping) section
86+
and [userdev](/paper/dev/userdev#1205-and-beyond) documentation covering these changes.
9087

9188
### Getting the current Minecraft version
9289

0 commit comments

Comments
 (0)